@quartermaster-labs/pi-on-demand-context
v0.1.3
Published
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.
Maintainers
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/writeloads the file's directory;grep/ls/findload the searched directory; these do not move the bash working dir - Context is injected once, durably the moment a dir is touched (via
sendMessagewithdeliverAs: "steer"), so a dir'sCLAUDE.mdis 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-labsscope.
npm install -g @quartermaster-labs/pi-on-demand-contextSetup
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 guessingA 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
cdback to a visited directory - Uses
&& pwd(or; pwd) to reliably detect the actual new working directory - Works on Windows (WSL/bash) and Unix systems
