name: "codegraph"
预构建的代码知识图谱 + MCP 服务器。解析代码库后用 SQLite(FTS5)存储所有符号、调用边、文件,通过 MCP 工具暴露给 Agent。自动同步文件变更。
本技能附带原版安装脚本(scripts/install.ps1 / scripts/install.sh),复制本目录后执行:
# 从技能目录运行安装脚本
cd ~/.agents/skills/codegraph/scripts
# macOS / Linux
chmod +x install.sh && ./install.sh
# Windows PowerShell
.\install.ps1
安装脚本自动完成:装 CLI → 连线 Agent → 建索引。完成后重启 Agent。
codegraph_explore — 主工具,优先用codegraph_explore query:"AuthService loginUser UserRepository"
codegraph_explore query:"用户登录请求的完整链路"
codegraph_explore query:"app.ts"
返回源码 + 调用路径 + 影响范围。返回的源码视为已 Read,不要再用 Read 重读。
codegraph_node — 读文件 / 看符号codegraph_node file:"src/services/user.ts"
codegraph_node symbol:"getUserById"
codegraph_node symbol:"getUserById" file:"user.ts"
codegraph_search — 搜符号位置codegraph_search query:"UserRepo"
codegraph_search query:"getUser" kind:"function"
codegraph_callers / codegraph_callees — 调用关系codegraph_callers symbol:"handleRequest"
codegraph_callees symbol:"handleRequest"
codegraph_impact — 改代码前看影响codegraph_impact symbol:"UserService"
codegraph_impact symbol:"UserService" depth:3
codegraph_files — 项目文件结构codegraph_files
codegraph_files filter:"src/**/*.ts"
| 场景 | 工具 |
|---|---|
| 查架构/流程 | codegraph_explore |
| 读文件 | codegraph_node file:"路径" |
| 查符号定义+调用者 | codegraph_node symbol:"名" |
| 搜符号位置 | codegraph_search |
| 改前看影响 | codegraph_impact |
| 查谁调了我 | codegraph_callers |
| 查我调了谁 | codegraph_callees |
| ❌ 不要 | ✅ 应该 |
|---|---|
Read file |
codegraph_node file |
Grep → Read 循环 |
一次 codegraph_explore |
| 手搓调用链 | codegraph_explore query:"A B C" |
| 直接改代码 | 先 codegraph_impact |