跳转到内容

GitNexus 工作流

本仓库使用 GitNexus 做代码理解和影响面分析。GitNexus 将代码库索引为知识图谱,通过 CLI 命令和 MCP 工具提供服务。

Terminal window
# 索引仓库(在仓库根目录运行)
npx gitnexus analyze
# 为编辑器配置 MCP(一次性)
npx gitnexus setup
# 检查索引状态
npx gitnexus status
# 列出所有已索引的仓库
npx gitnexus list

如果索引过期(例如大量代码变更后),重新运行 npx gitnexus analyze 刷新。

使用 CLI 命令理解架构和执行流:

Terminal window
# 从知识图谱生成仓库 wiki
npx gitnexus wiki
# 使用自定义模型生成 wiki
npx gitnexus wiki --model gpt-4o-mini

无需安装即可快速探索,使用 Web UI 或启动本地服务器:

Terminal window
# 启动本地 HTTP 服务器,供 Web UI 连接
npx gitnexus serve

修改函数、类或方法前检查上游影响:

  1. 运行 npx gitnexus status 确认索引是最新的。
  2. 在 AI 编辑器中使用 MCP 工具运行影响面分析(见下方提示框)。
  3. 记录:直接调用者、受影响流程、风险等级。
  4. 如果风险是 HIGHCRITICAL,先暂停并说明风险,不要直接继续改动。

确认变更仅影响预期的符号和执行流:

  1. 如有需要,运行 npx gitnexus analyze 刷新索引。
  2. 在 AI 编辑器中使用 MCP detect_changes 工具检查影响范围。
  3. 如果结果包含无关文件或流程,先检查工作区。

不要用全局查找替换重命名符号。使用 GitNexus 的 rename MCP 工具,以便同时处理调用关系和引用点。

Terminal window
gitnexus analyze [path] # 索引仓库(或更新过期索引)
gitnexus analyze --force # 完全重建:重新解析 + 图谱重建 + FTS 重建
gitnexus analyze --repair-fts # 仅重建/验证现有数据的 FTS 索引
gitnexus analyze --skip-embeddings # 跳过嵌入生成(更快)
gitnexus analyze --embeddings [n] # 启用嵌入生成(较慢,搜索更好)
gitnexus analyze --skills # 生成仓库专属技能文件
gitnexus analyze --skip-skills # 跳过安装技能文件
gitnexus analyze --skip-agents-md # 保留自定义 AGENTS.md/CLAUDE.md 编辑
gitnexus analyze --skip-git # 索引非 Git 仓库的文件夹
gitnexus analyze --verbose # 记录跳过的文件
gitnexus setup # 为编辑器配置 MCP(一次性)
gitnexus mcp # 启动 MCP 服务器(stdio)
gitnexus serve # 启动本地 HTTP 服务器供 Web UI 使用
gitnexus list # 列出所有已索引的仓库
gitnexus status # 显示当前仓库的索引状态
gitnexus clean # 删除当前仓库的索引
gitnexus clean --all --force # 删除所有索引
gitnexus wiki [path] # 从知识图谱生成仓库 wiki
gitnexus wiki --model <model> # 使用自定义 LLM 模型生成 wiki
gitnexus wiki --base-url <url> # 使用自定义 LLM API 地址生成 wiki