pi-graphnav
CodeGraph-first code navigation for pi: persistent index, auto init/sync, and a gate that steers structural searches to codegraph_* tools.
Package details
Install pi-graphnav from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-graphnav- Package
pi-graphnav- Version
0.3.3- Published
- Nov 12, 2026
- Downloads
- 1,278/mo · 334/wk
- Author
- greenspand
- License
- MIT
- Types
- extension
- Size
- 81.9 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/graphnav.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-graphnav
CodeGraph-first code navigation for pi: the agent understands code through CodeGraph's symbol graph instead of grepping and reading file after file, without being told to.
A pi extension.
What it does
- Keeps the index current. At session start, in the background:
codegraph initfor a git repo without an index, a fullcodegraph indexwhen the index is stale or was built by another CodeGraph version,codegraph syncfor pending changes. An index a killed run left half-built is rebuilt (unless another process is indexing right now), and a failure on a stale lock getscodegraph unlockand one more try. While pi runs, the server's file watcher follows your edits. - The
codegraph_*tools (explore,search,node,callers,callees,impact,files,status) on one long-livedcodegraph serve --mcpper project: no process start per call, and the watcher stays alive. Resilient, with arrow-resilience-kit: a server that dies under a call is restarted and the call retried once; after 3 failed calls in a row CodeGraph counts as unavailable for a minute, so calls fail fast and the gate stops sending the agent to it (status line:codegraph: unavailable). - Steers symbol searches to CodeGraph.
rg parseConfig,grep -rn UserService src,git grep,ag,ackand pi'sgreptool with a symbol-like pattern are blocked once with the CodeGraph call that answers it (enforce), or run with that hint appended (nudge). Running the same command again is allowed: CodeGraph cannot answer everything. Searches for phrases, string literals or in docs and config (*.md,--type yaml, …) are never touched, nor symbols already looked up with CodeGraph. Searches a codemode script makes with literaltools.bash({ command })/tools.grep({ pattern })are gated the same way. A pattern only counts as a symbol when it has code shape (parseConfig,ParseConfig,start_scan,Foo::new) or symbol syntax (fn summary,summary(); plain words likesummary,cacheorSuccessare text. Before blocking, the gate asks the index (onecodegraph_search, 2 s limit, fails open) and lets the search through when the index does not define the name. When it does, the block message already says where (path:line (kind)), so one blocked call still answers the question. A search inside named files (rg start_scan src/app.rs) is only nudged: the agent has already found the code. - Nudges file-name lookups.
fd UserService,find . -name '*ParseConfig*'and pi'sfindtool with a camelCase or snake_case name run, with a hint tocodegraph_search(never blocked). - Hints after blind reading. Reading several source files before any CodeGraph call adds
one hint to use
codegraph_explore; reading a whole source file over 400 lines adds one to fetch just the symbol withcodegraph_node. - Shows whether it helps.
/codegraph statuscounts blocked searches, how many the agent answered with CodeGraph and how many it re-ran instead. - Prompt guidance that stays the same every turn, so the prompt cache survives.
Needs the CodeGraph CLI: npm i -g @colbymchenry/codegraph. The project is the nearest
directory with .codegraph/, else the git work tree; never your home directory.
Demos
A repo without an index: indexed in the background, then a symbol rg is blocked and the
answer comes from codegraph_search and codegraph_callers.

nudge mode: the search runs, and its output points at CodeGraph.

The /codegraph command: status, mode, off/on, sync.

Recorded with VHS against a throw-away sample project and a
scripted local model (just vhs, scripts/vhs.nu, examples/vhs/): a real pi with only this plugin.
Install
pi install npm:pi-graphnav
Use
| Command | |
|---|---|
/codegraph or /codegraph status |
project, index state, mode, blocked/nudged counts |
/codegraph [on|off] |
switch it all (remembered across sessions) |
/codegraph mode <mode> |
symbol searches: enforce (default), nudge or off |
/codegraph statusline <when> |
status line: always (default), problems or never; CodeGraph keeps working |
/codegraph sync |
sync the index with changed files |
/codegraph reindex |
rebuild the index from scratch |
/codegraph init |
create the index (for a directory that is not a git repo) |
Settings live in <pi agent dir>/codegraph.json (PI_CODING_AGENT_DIR, else ~/.pi/agent):
| Key | Default | |
|---|---|---|
enabled |
true |
master switch |
showStatus |
"always" |
status line entry: "always", "problems" (only while indexing, or when the index is missing, failing or unavailable) or "never"; true/false still work |
mode |
"enforce" |
enforce, nudge or off |
autoInit |
true |
init a git repo that has no index |
autoSync |
true |
sync or rebuild a stale index at session start |
watch |
true |
keep the server's file watcher running |
readHintAfter |
3 |
source files read before the CodeGraph hint (0: never) |
timeoutMs |
30000 |
per-call timeout of the CodeGraph server |
A project can override enabled, mode, autoInit, autoSync and readHintAfter for itself in
<project>/.pi/codegraph.json (commit it to share), e.g. { "mode": "nudge" } for a repo full of
generated code. A /codegraph command still wins for the session.
Replaces @vndv/pi-codegraph (same tool names): uninstall that one first.
Development
bun install
just check # typecheck + tests (95% coverage gate) + pack check + nu script tests
just --list # everything else: fuzz, audit, release, remotes
Layout:
| Path | What |
|---|---|
extensions/graphnav.ts |
wiring: hooks, tools, the command, the status line |
extensions/core/gate.ts |
spotting symbol searches in shell commands; the gate decision |
extensions/core/project.ts |
project root, codegraph status -j, what keeps the index current |
extensions/core/mcp.ts |
the long-lived codegraph serve --mcp client |
extensions/core/resilience.ts |
circuit breaker and crash retry (arrow-resilience-kit) |
extensions/core/tools.ts |
tool definitions and prompt guidelines |
extensions/core/config.ts, extensions/command/parse.ts |
settings, /codegraph parsing |
tests/ |
bun test: one file per module, extension (hooks), fuzz (randomised properties) |
scripts/ |
Nushell only, each with a test in scripts/tests/ |
examples/vhs/ |
demo tapes, the scripted model, the rendered GIFs |
.github/, .gitea/ |
CI, release, nightlies on both hosts |
Releases: just release patch bumps package.json, regenerates CHANGELOG.md with git-cliff, tags and
pushes; the Release workflow publishes to npm (secret NPM_TOKEN).
License
MIT