add pi agent target#442
Open
peachest wants to merge 1 commit into
Open
Conversation
Add pi (https://pi.dev) agent framework support to the CodeGraph installer, following the established multi-target AgentTarget architecture. pi is a terminal coding harness that reads AGENTS.md from ~/.pi/agent/ (global) and parent/current directories (local). It does not natively support MCP servers, so this target writes CLI-oriented codegraph usage instructions to AGENTS.md instead of an MCP server config. Key decisions: - No MCP config writing — pi's design philosophy is 'No MCP' - CLI-based instructions template adapted for pi's bash tool - Marker-based section replacement (same pattern as claude/codex) - PI_CODING_AGENT_DIR env var support for custom config dirs - Both global (~/.pi/agent/AGENTS.md) and local (./AGENTS.md) - Legacy heading migration for pre-marker ## CodeGraph sections Closes colbymchenry#184, colbymchenry#328, colbymchenry#397. Refs colbymchenry#65. Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add pi agent framework support to the CodeGraph installer, following the established multi-target architecture.
pi is a minimal terminal coding harness that reads
AGENTS.md(orCLAUDE.md) from~/.pi/agent/(global) and from parent directories / the current working directory (local). It does not natively support MCP servers — its design philosophy is "No MCP. Build CLI tools with READMEs." — so this integration writes instructions intoAGENTS.mdtelling the pi agent to invoke codegraph via its CLI (codegraph search,codegraph trace, etc.) through pi'sbashtool, rather than writing an MCP server config.What this PR does
src/installer/targets/pi.ts(213 lines): A fullAgentTargetimplementation that:~/.pi/and thePI_CODING_AGENT_DIRenvironment variable~/.pi/agent/AGENTS.md(global) or./AGENTS.md(local) using the same marker-based section replacement as other targetsglobalandlocalinstall locations (pi walks from cwd upward loadingAGENTS.md)## CodeGraphsections by migrating them to the marker-delimited format (matching claude'swriteInstructionsEntrypattern)PI_CODING_AGENT_DIRenv var for custom config directories'pi'added to theTargetIdunion andpiTargetregistered inALL_TARGETS'pi'included in thegetTargetregistry assertionCLAUDE.mdtarget list updatedWhy CLI instructions instead of MCP?
pi explicitly does not support MCP servers. The template in
PI_INSTRUCTIONS_TEMPLATEadapts the standard codegraph usage guidance for CLI invocation (e.g.codegraph trace <from> <to>instead ofcodegraph_trace) and includes a note about MCP-gap extension workarounds.Related Issues
Closes the following requests for pi agent support:
piandompas code agents to the installer#184 was the original feature request filed shortly after the multi-target installer shipped. #328 shows real user demand — someone asking how to use codegraph with pi before installer support existed. #397 came with a companion pi-codegraph extension by @SeanPedersen, providing a complementary MCP-gap workaround.
This also relates to #65 ("Does it support other AI assistants besides Claude") — a broader request that this PR helps address by adding another supported agent to the installer.
Type of Change
How Has This Been Tested?
Unit tests
npx vitest run __tests__/installer-targets.test.ts # 92 tests passed (all existing tests continue to pass)Real-world detection verification
Tested against an actual pi installation on macOS:
Build
npm run build # compiles cleanlyCross-target comparison (via subagent review)
The implementation was reviewed side-by-side against all four existing targets:
All reviewers confirmed: pi correctly implements the
AgentTargetinterface, handles edge cases appropriately, and its "No MCP" design is correctly reflected.Checklist
CLAUDE.md)npm test)Files Changed
src/installer/targets/pi.tssrc/installer/targets/types.ts'pi'toTargetIdunionsrc/installer/targets/registry.tspiTarget__tests__/installer-targets.test.ts'pi'togetTargetassertionCLAUDE.mdpi.tsScreenshots / Demo
N/A — installer target, no UI.
Additional Context
Architecture notes
pi follows the same marker-based section replacement pattern as claude, cursor, codex, and opencode targets:
The
PI_INSTRUCTIONS_TEMPLATEdiverges from the sharedINSTRUCTIONS_TEMPLATEintentionally — the shared template assumes MCP tool calls (codegraph_search,codegraph_trace), while pi's template instructs the agent to use CLI commands viabash(codegraph search,codegraph trace).Environment variable support
piAgentDir()respectsPI_CODING_AGENT_DIRwhen set, falling back to~/.pi/agent/. This mirrorsHERMES_HOMEin the hermes target and provides users with flexible configuration.Subagent review methodology
Three parallel subagent reviewers examined the implementation from different angles:
All findings were addressed before finalizing the PR: legacy heading migration, install notes, env var support, and detection accuracy.