--- name: "codegraph" description: CodeGraph — 代码知识图谱 MCP 工具集。为 AI 编程智能体提供语义级代码理解:一次调用获取符号源码、调用链路、影响范围。支持 35+ 语言、17+ Web 框架路由、iOS/RN 跨语言桥接。自动同步文件变更。 --- # CodeGraph 预构建的代码知识图谱 + MCP 服务器。解析代码库后用 SQLite(FTS5)存储所有符号、调用边、文件,通过 MCP 工具暴露给 Agent。自动同步文件变更。 --- ## 安装 本技能附带原版安装脚本(`scripts/install.ps1` / `scripts/install.sh`),复制本目录后执行: ```bash # 从技能目录运行安装脚本 cd ~/.agents/skills/codegraph/scripts # macOS / Linux chmod +x install.sh && ./install.sh # Windows PowerShell .\install.ps1 ``` 安装脚本自动完成:装 CLI → 连线 Agent → 建索引。完成后重启 Agent。 --- ## MCP 工具 ### `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` |