From de5725907a3fc507fde584f433e983cfd95ba79f Mon Sep 17 00:00:00 2001 From: kangxl <230263957+zh-xl-kang@users.noreply.github.com> Date: Sun, 28 Jun 2026 08:38:17 +0800 Subject: [PATCH 1/2] feat: add Pi agent support Add MCP server detection and configuration for Pi agent (~/.pi/agent/). Changes: - cli.h: Add 'pi' field to cbm_detected_agents_t struct - cli.h: Declare cbm_upsert_pi_mcp() and cbm_remove_pi_mcp() - cli.c: Detect Pi agent via ~/.pi/agent/ directory - cli.c: Implement upsert/remove using cbm_install_editor_mcp() format - cli.c: Add Pi agent to install/uninstall workflows - cli.c: Add display names 'Pi agent' and 'pi' Pi agent uses standard mcpServers format in ~/.pi/agent/mcp.json --- src/cli/cli.c | 32 ++++++++++++++++++++++++++++++++ src/cli/cli.h | 7 +++++++ 2 files changed, 39 insertions(+) diff --git a/src/cli/cli.c b/src/cli/cli.c index f159f5914..ac7d4ab7b 100644 --- a/src/cli/cli.c +++ b/src/cli/cli.c @@ -1143,6 +1143,10 @@ cbm_detected_agents_t cbm_detect_agents(const char *home_dir) { snprintf(path, sizeof(path), "%s/.kiro", home_dir); agents.kiro = dir_exists(path); + /* Pi agent: ~/.pi/agent/ */ + snprintf(path, sizeof(path), "%s/.pi/agent", home_dir); + agents.pi = dir_exists(path); + return agents; } @@ -1679,6 +1683,16 @@ int cbm_remove_antigravity_mcp(const char *config_path) { return cbm_remove_editor_mcp(config_path); } +/* ── Pi agent MCP config (JSON, standard mcpServers format) ───── */ + +int cbm_upsert_pi_mcp(const char *binary_path, const char *config_path) { + return cbm_install_editor_mcp(binary_path, config_path); +} + +int cbm_remove_pi_mcp(const char *config_path) { + return cbm_remove_editor_mcp(config_path); +} + /* ── Claude Code pre-tool hooks ───────────────────────────────── */ /* Matcher intentionally excludes Read: gating Read breaks Claude Code's @@ -2934,6 +2948,7 @@ static void print_detected_agents(const cbm_detected_agents_t *a) { {a->cursor, "Cursor"}, {a->openclaw, "OpenClaw"}, {a->kiro, "Kiro"}, + {a->pi, "Pi agent"}, }; printf("Detected agents:"); bool any = false; @@ -3181,6 +3196,14 @@ static void install_cli_agent_configs(const cbm_detected_agents_t *agents, const printf(" instructions: %s\n", ip); } } + if (agents->pi) { + char cp[CLI_BUF_1K]; + char ip[CLI_BUF_1K]; + snprintf(cp, sizeof(cp), "%s/.pi/agent/mcp.json", home); + snprintf(ip, sizeof(ip), "%s/.pi/agent/AGENTS.md", home); + install_generic_agent_config("Pi agent", binary_path, cp, ip, dry_run, + cbm_upsert_pi_mcp); + } } /* Install MCP configs for editor-based agents (Zed, KiloCode, VS Code, OpenClaw). */ @@ -3346,6 +3369,7 @@ char *cbm_build_install_plan_json(const char *home, const char *binary_path) { {det.cursor, "cursor"}, {det.openclaw, "openclaw"}, {det.kiro, "kiro"}, + {det.pi, "pi"}, }; yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); @@ -3658,6 +3682,14 @@ static void uninstall_cli_agents(const cbm_detected_agents_t *agents, const char } printf("Aider: removed instructions\n"); } + if (agents->pi) { + char cp[CLI_BUF_1K]; + char ip[CLI_BUF_1K]; + snprintf(cp, sizeof(cp), "%s/.pi/agent/mcp.json", home); + snprintf(ip, sizeof(ip), "%s/.pi/agent/AGENTS.md", home); + uninstall_agent_mcp_instr((mcp_uninstall_args_t){"Pi agent", cp, ip}, dry_run, + cbm_remove_pi_mcp); + } } /* Remove editor agent configs (Zed, KiloCode, VS Code, OpenClaw). */ diff --git a/src/cli/cli.h b/src/cli/cli.h index 9efe67896..617ac37e2 100644 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -128,6 +128,7 @@ typedef struct { bool cursor; /* ~/.cursor/ exists */ bool openclaw; /* ~/.openclaw/ exists */ bool kiro; /* ~/.kiro/ exists */ + bool pi; /* ~/.pi/agent/ exists */ } cbm_detected_agents_t; /* Detect which coding agents are installed. @@ -155,6 +156,12 @@ int cbm_upsert_antigravity_mcp(const char *binary_path, const char *config_path) /* Remove CMM MCP entry from antigravity mcp_config.json. Returns 0 on success. */ int cbm_remove_antigravity_mcp(const char *config_path); +/* Pi agent: upsert MCP entry in ~/.pi/agent/mcp.json. Returns 0 on success. */ +int cbm_upsert_pi_mcp(const char *binary_path, const char *config_path); + +/* Remove CMM MCP entry from Pi agent mcp.json. Returns 0 on success. */ +int cbm_remove_pi_mcp(const char *config_path); + /* ── Instructions file upsert ─────────────────────────────────── */ /* Upsert a codebase-memory-mcp instruction section in a markdown file. From 883080c01d9a03ad131b779d780e937e6b8fa13a Mon Sep 17 00:00:00 2001 From: kangxl <230263957+zh-xl-kang@users.noreply.github.com> Date: Sun, 28 Jun 2026 10:27:42 +0800 Subject: [PATCH 2/2] test: add Pi agent detection tests and update documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add cli_detect_agents_finds_pi test - Add ASSERT_FALSE(agents.pi) in cli_detect_agents_none_found - Add cli_upsert_pi_mcp_fresh and cli_upsert_pi_mcp_replace tests - Update README.md: 11 agents → 12 agents, add Pi configuration row - Update docs/index.html, docs/llms.txt, pkg/npm/README.md with Pi support --- README.md | 3 +- docs/index.html | 8 +++--- docs/llms.txt | 2 +- pkg/npm/README.md | 2 +- tests/test_cli.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cb5e90aa2..ea7be2fe9 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-si - **Plug and play** — single static binary for macOS (arm64/amd64), Linux (arm64/amd64), and Windows (amd64). No Docker, no runtime dependencies, no API keys. Download → `install` → restart agent → done. - **158 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks. - **120x fewer tokens** — 5 structural queries: ~3,400 tokens vs ~412,000 via file-by-file search. One graph query replaces dozens of grep/read cycles. -- **11 agents, one command** — `install` auto-detects Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro — configures MCP entries, instruction files, and pre-tool hooks for each. +- **12 agents, one command** — `install` auto-detects Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, OpenClaw, Kiro, and Pi — configures MCP entries, instruction files, and pre-tool hooks for each. - **Built-in graph visualization** — 3D interactive UI at `localhost:9749` (optional UI binary variant). - **Infrastructure-as-code indexing** — Dockerfiles, Kubernetes manifests, and Kustomize overlays indexed as graph nodes with cross-references. `Resource` nodes for K8s kinds, `Module` nodes for Kustomize overlays with `IMPORTS` edges to referenced resources. - **14 MCP tools** — search, trace, architecture, impact analysis, Cypher queries, dead code detection, cross-service HTTP linking, ADR management, and more. @@ -345,6 +345,7 @@ Restart your agent. Verify with `/mcp` — you should see `codebase-memory-mcp` | VS Code | `Code/User/mcp.json` | — | — | | OpenClaw | `openclaw.json` | — | — | | Kiro | `.kiro/settings/mcp.json` | — | — | +| Pi | `.pi/agent/mcp.json` | `.pi/agent/AGENTS.md` | — | **Hooks are structurally non-blocking** (exit code 0, every failure path). For Claude Code, the `PreToolUse` hook intercepts `Grep`/`Glob` (never `Read` — diff --git a/docs/index.html b/docs/index.html index 7e732406b..3c2263328 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@
- One command configures all 11 supported agents: Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode,
- Antigravity, Aider, KiloCode, VS Code, OpenClaw, and Kiro — with MCP entries, instruction files, and
+ One command configures all 12 supported agents: Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode,
+ Antigravity, Aider, KiloCode, VS Code, OpenClaw, Kiro, and Pi — with MCP entries, instruction files, and
pre-tool hooks for each. Windows users run install.ps1. Also available via
npm, pip, Homebrew, Scoop, Winget, Chocolatey, AUR, and go install.