| version | 0.1.0 | ||||
|---|---|---|---|---|---|
| status | active | ||||
| created | 2026-05-20 | ||||
| updated | 2026-05-22 | ||||
| owner | 工程团队 | ||||
| doc_tier | runbook | ||||
| last_verified | 2026-05-22 | ||||
| source_of_truth |
|
CodeGraph 在 TSP 中是 默认内置 MCP-backed 代码图谱能力。它适合 brownfield 项目的符号搜索、调用链、影响面、文件结构和 focused context 查询。
它不替代 /team-* 主链,也不替代 /update-codemaps 的轻量现状快照。CodeGraph 用于当前 agent 可直接消费的本地图谱查询;Graphify 偏轻量结构证据;GitNexus 偏更深 MCP 查询、diff impact、多仓和执行流证据。
先跑:
npm run codegraph:doctor检查项:
- 当前平台支持官方 standalone installer(macOS / Linux / Windows)
- macOS / Linux 可用
curl,Windows 可用 PowerShell - CodeGraph standalone CLI/bin 可用
- 当前
TSP_INSTALL_TARGET是否能映射到上游支持的claude/codex/cursor/opencode
TSP 通过 scripts/install-codegraph.js 优先复用已有 codegraph binary;如果缺失,则调用上游官方 standalone installer:
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh
# Windows PowerShell
irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex随后将当前 TSP target 映射成上游 target:
codegraph install --target=<claude|codex|cursor|opencode> --location=global --yes明确边界:
- 不使用上游
--target=auto - Claude
SessionStarthook 会在新项目缺少.codegraph/codegraph.db时静默执行codegraph init -i <projectRoot> - Codex / OpenCode 不做侵入式自动 hook,只依赖全局 MCP 配置、说明和 doctor 诊断
- 可用
TSP_CODEGRAPH_AUTO_INIT=0关闭 Claude 自动初始化 - 不把
.codegraph/数据库提交到 TSP 或消费方项目 - unsupported target 只输出跳过说明,不阻断 TSP 安装
/team-help -> /update-codemaps -> npm run codegraph:doctor -> Claude 自动初始化或 codegraph init -i -> MCP 查询 -> /team-plan 或 /team-review
非 Claude 或自动初始化关闭时,在目标项目根目录初始化索引:
codegraph init -i
codegraph status常用查询入口:
codegraph query <symbol>
codegraph context "<task>"
codegraph affected --stdin
codegraph files --format tree- 用
/update-codemaps先生成轻量现状快照 - 用 CodeGraph 查询关键 symbol、entrypoint、handler 和影响面
- 将发现写入 Brownfield Context Snapshot、challenge/design/readiness 证据
- 对 story slice 的关键 symbol/API/handler 做 callers、callees、impact 查询
- 对准备提交的 diff 使用
codegraph affected辅助定位回归测试 - 将结果写入执行日志或 handoff
评审结论至少记录:
- 本次分析目标
- 使用的 MCP tool 或 CLI 命令
- 关键影响面
- 风险等级或剩余疑点
- 对回归测试、发布或回滚的影响
## CodeGraph Evidence
- Goal: [本次要确认的问题]
- Entry: [MCP tool 或 CLI 命令]
- Findings: [关键调用链、依赖、影响面]
- Decision impact: [改变了哪个计划、测试或发布判断]
- Follow-up: [仍需验证或暂缓的事项]| 能力 | 默认用途 |
|---|---|
| CodeGraph | 默认内置 MCP-backed 符号搜索、调用链、impact 和 focused context |
| Graphify | 轻量结构扫描、依赖路径、架构问答证据 |
| GitNexus | 深 MCP 查询、symbol impact、detect_changes、多仓和执行流证据 |