npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-context-loader

v0.1.1

Published

Config-driven context injection for Pi agents. Loads files at session start and injects them as system prompt or message.

Readme

pi-context-loader

Config-driven context injection for Pi agents. Loads files at session start and injects them as system prompt or message — the Pi equivalent of a sessionStart hook.

Install

From npm:

pi install npm:pi-context-loader

From git:

pi install git+https://github.com/juanje/pi-context-loader.git

Or load directly without installing:

pi -e /path/to/pi-context-loader/extensions/context-loader.ts

Quick start

Create .pi/context-loader.json in your project:

{
  "files": [
    "context/user-profile.md",
    "context/current-state.md"
  ]
}

Start Pi — the listed files are read at session start and injected into the agent's context (system prompt by default, or as a message with "inject": "message").

How it works

The extension hooks into two Pi events:

  1. session_start — loads the config, reads all listed files and optional latest log, caches the combined context
  2. before_agent_start — injects the cached context via the configured mode

Injection modes

The inject field controls how context reaches the agent:

| Mode | Behavior | Survives compaction | LLM weight | |------|----------|-------------------|------------| | "systemPrompt" (default) | Appended to system prompt | Yes — always present | High — treated as instructions | | "message" | Injected as a conversation message | No — may be summarized | Normal — treated as context |

When to use each:

  • systemPrompt — for identity, rules, or context that must be present on every turn (e.g., user profile, agent guidelines)
  • message — for operational state that's useful at the start but shouldn't permanently occupy the context budget (e.g., active incidents, current sprint items)

Config format

Config file: .pi/context-loader.json

interface ContextLoaderConfig {
  files?: string[];        // paths relative to project root
  latestLog?: {
    index: string;         // path to an index file (e.g. "logs/index.md")
    dir: string;           // directory containing log files (e.g. "logs")
    marker: string;        // marker to match in index lines (e.g. "active")
  };
  separator?: string;      // join string (default: "\n\n---\n\n")
  inject?: "systemPrompt" | "message";  // injection mode (default: "systemPrompt")
}

files

Array of file paths relative to the project root. Each file is read and its content is included in the context. Missing files are silently skipped.

latestLog

Optional dynamic log finder. Scans the index file for lines matching marker (case-insensitive), extracts the last YYYY-MM-DD date found, and loads {dir}/{date}.md.

Useful for agents with session logs where you want to inject the most recent active log automatically.

separator

String used to join all loaded content. Defaults to "\n\n---\n\n" (markdown horizontal rule).

inject

How context is delivered to the agent. Either "systemPrompt" (default) or "message". See Injection modes for details.

Examples

Memory agent (Agentic Buddy-style)

{
  "files": [
    "agent_brain/identity/USER.md"
  ],
  "latestLog": {
    "index": "logs/index.md",
    "dir": "logs",
    "marker": "active"
  }
}

Diagnostic agent (active incidents as message)

{
  "files": ["kb/active/index.md"],
  "inject": "message"
}

Diagnostic agent (reference context in system prompt)

{
  "files": [
    "context/team-roster.md",
    "context/known-issues-summary.md"
  ]
}

Minimal

{
  "files": ["CONTEXT.md"]
}

Static context

This extension handles dynamic context — files that change between sessions. For static context, Pi has built-in support:

  • .pi/SYSTEM.md — replaces the default system prompt (agent identity)
  • AGENTS.md / CLAUDE.md — hierarchical context files loaded automatically

Use pi-context-loader for content that needs to be assembled from multiple files or includes dynamic elements like "latest active log."

Development

git clone https://github.com/juanje/pi-context-loader.git
cd pi-context-loader
npm install
npm run check    # typecheck + lint + test

License

MIT — see LICENSE.