feat: add context-mode CodeGraph MCP integration

This commit is contained in:
云服务部-叶林立
2026-08-18 15:33:11 +08:00
parent 0637139a16
commit 3984e37aa3
5 changed files with 2385 additions and 25 deletions
+30
View File
@@ -4,6 +4,8 @@
- `@ff-labs/pi-fff@0.10.5`:使用官方 `override` 模式接管 `find``grep``multi_grep`
- 本仓库维护的 `pi-rtk-optimizer`:只处理 Bash/read 等输出压缩,默认不改写命令,也不处理搜索工具结果。
- `context-mode@1.0.169`:通过 Pi adapter 提供 `ctx_*` 工具、上下文隔离和会话连续性。
- `pi-mcp-adapter@2.26.0`:只用于把机器现有的 CodeGraph MCP Server 接入为 `codegraph_explore`
- `pi-context-view@0.4.2`:查看上下文占用。
- `@firstpick/pi-extension-codex-fast-mode@0.1.1`:为 Codex provider 提供会话级 `/fast-mode`
- `@gotgenes/pi-permission-system@26.2.1`:加载组合包自带的权限基线。
@@ -22,6 +24,10 @@ pi install git:git@bitbucket.org:siakitem/my-pi.git
默认配置不需要系统 `rtk` CLI。只有以后在 `/rtk` 中主动开启
`RTK command rewriting` 时,才需要另外安装 `rtk` 可执行文件。
CodeGraph 本体不由组合包安装。需要使用 CodeGraph 的机器应自行确保 `codegraph`
启动 Pi 的 `PATH` 中,并在目标项目执行过 `codegraph init`。组合包不会创建或维护
`.codegraph/`,也不会修改 CodeGraph 的索引、更新或遥测设置。
## 组合行为
### 搜索归 FFF
@@ -37,6 +43,30 @@ RTK 保留 Bash、read、build、test、lint 和 Git 输出压缩。默认 `read
仍关闭;可用 `/rtk` 查看或调整。旧机器已有的 RTK 配置若没有
`commandRewritingEnabled` 字段,也会按 `false` 归一化,不需要迁移配置。
### 大输出归 Context Mode
Context Mode 直接加载 npm 包内置的 Pi adapter 和 skills,不需要额外写入
`~/.pi/agent/mcp.json`,也不需要全局安装 `context-mode` 命令。它提供 `ctx_*` 工具,
将批量读取、命令研究和网页内容先在隔离进程中处理,再把收敛后的结果送入上下文。
FFF 仍负责精确字面搜索;RTK 继续压缩未走 Context Mode 的 Bash、build、test、lint
和 Git 输出。Context Mode 不替换这两个扩展的现有配置。
### CodeGraph 只负责连接
`extensions/codegraph.ts` 使用隔离的 `pi-mcp-adapter` 配置启动
`codegraph serve --mcp`,不会读取或覆盖用户已有的 MCP 配置。连接采用
`keep-alive`,并只把官方当前主工具 `codegraph_explore` 作为同名 Pi 工具暴露;
CodeGraph 的文件 watcher 由该 MCP 进程自身维护。
若机器没有 `codegraph`,或当前项目尚未建立索引,CodeGraph 会报告连接/初始化错误,
其他扩展仍可正常工作。安装与索引状态可在机器上自行检查:
```bash
codegraph --version
codegraph status
```
### 权限基线自动部署
`extensions/permission-system.ts` 在权限扩展注册前,把仓库中的