@quartermaster-labs/pi-on-demand-context

Pi extension. Auto-loads CLAUDE.md / AGENTS.md context when the model works in a dir — via bash `cd` or any file tool (read/edit/write/grep/ls/find). Injected once, durably; deduped against pi's own loader.

Packages

Package details

extension

Install @quartermaster-labs/pi-on-demand-context from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@quartermaster-labs/pi-on-demand-context
Package
@quartermaster-labs/pi-on-demand-context
Version
0.1.3
Published
Jun 28, 2026
Downloads
92/mo · 12/wk
Author
radu-dev
License
MIT
Types
extension
Size
17.4 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

On-Demand Context Extension

Loads CLAUDE.md and AGENTS.md context files when the model works in a directory — by cd-ing into it, or by touching a file there with read/edit/write/grep/ls/find.

How it works

  • pi auto-loads context files for the launch dir + parents at startup (unchanged)
  • Model cd some/dir, or reads/edits/greps a file anywhere — no special tool needed
  • Extension resolves the target directory and injects context from it (+ parents)
  • A read/edit/write loads the file's directory; grep/ls/find load the searched directory; these do not move the bash working dir
  • Context is injected once, durably the moment a dir is touched (via sendMessage with deliverAs: "steer"), so a dir's CLAUDE.md is in view before the model acts there — same agent loop, no per-call re-send
  • Files pi already loaded (or a shared parent) are not re-sent
  • Multiple directories can be visited — context accumulates across the session

Install

Formerly published as @radu0120/pi-on-demand-context. Same package, republished under the @quartermaster-labs scope.

npm install -g @quartermaster-labs/pi-on-demand-context

Setup

Register the extension in ~/.pi/agent/settings.json:

{
  "extensions": ["@quartermaster-labs/pi-on-demand-context"]
}

Or use the local path:

{
  "extensions": ["~/.npm-global/lib/node_modules/@quartermaster-labs/pi-on-demand-context"]
}

No --no-context-files / noContextFiles needed — the extension complements pi's default loader instead of replacing it, deduping against what pi already injected via systemPromptOptions.contextFiles.

After modifying index.ts, run /reload.

Usage

For the model

cd some/dir          # plain cd works — new dir is resolved from the path
cd some/dir && pwd   # recommended — pwd gives the exact dir, no guessing

A plain cd <path> is enough for ordinary relative/absolute paths; the new directory is resolved against the last known one. Append && pwd when the path can't be computed from the string alone — cd -, cd ~user, cd $VAR, or cd $(...) — so pwd reports the real directory. Either way context files are injected before the next turn; no special tool needed.

For the user

  • /list-context — show all loaded context files
  • Context resets on /new, /resume, /fork

Notes

  • Context files are loaded from the target directory and all parent directories
  • Files are not re-loaded if you cd back to a visited directory
  • Uses && pwd (or ; pwd) to reliably detect the actual new working directory
  • Works on Windows (WSL/bash) and Unix systems