mcpField
G
gitnexus-impact-analysis

gitnexus-impact-analysis

github.com/mindfold-ai开发15.1k86 次安装5 周前更新
代码仓库

关于 gitnexus-impact-analysis

gitnexus-impact-analysis 是供开发者评估代码变更影响的 GitNexus 技能。它追踪上游依赖和受影响的执行流程,并结合 Git 变更帮助在修改或提交前评估风险。

主要功能

  1. 01查找符号的上游依赖方
  2. 02检查受影响的执行流程
  3. 03将 Git 变更映射到流程
  4. 04按深度和置信度评估影响
  5. 05检查暂存区变更

适用场景

  1. 01评估修改函数前的风险
  2. 02找出可能受影响的直接调用方
  3. 03提交前检查受影响的流程
  4. 04估计代码变更的影响范围

MCP 相关

该技能使用 GitNexus 的 impact 和 detect_changes 工具,并读取仓库流程资源以检查受影响的执行流程。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mindfold-ai/trellis --skill gitnexus-impact-analysis

安装后在 Claude Code 中输入/gitnexus-impact-analysis确认已加载。

详细介绍

使用 GitNexus 进行影响分析

适用场景

  • “修改这个函数安全吗?”
  • “如果我修改 X,会破坏什么?”
  • “展示影响范围”
  • “哪些地方使用了这段代码?”
  • 在进行较大规模代码更改之前
  • 在提交之前——了解你的更改会影响什么

工作流

1. impact({target: "X", direction: "upstream"})  → What depends on this
2. READ gitnexus://repo/{name}/processes                   → Check affected execution flows
3. detect_changes()                               → Map current git changes to affected flows
4. Assess risk and report to user

如果出现“索引已过期” → 在终端中运行 node .gitnexus/run.cjs analyze。

检查清单

- [ ] impact({target, direction: "upstream"}) to find dependents
- [ ] Review d=1 items first (these WILL BREAK)
- [ ] Check high-confidence (>0.8) dependencies
- [ ] READ processes to check affected execution flows
- [ ] detect_changes() for pre-commit check
- [ ] Assess risk level and report to user

理解输出

深度风险级别含义
d=1将会破坏直接调用方/导入方
d=2可能受到影响间接依赖
d=3可能需要测试传递影响

风险评估

受影响范围风险
<5 个符号,少量进程低
5-15 个符号,2-5 个进程中
>15 个符号或大量进程高
关键路径(身份验证、支付)严重

工具

impact — 用于分析符号影响范围的主要工具:

impact({
  target: "validateUser",
  direction: "upstream",
  minConfidence: 0.8,
  maxDepth: 3
})

→ d=1 (WILL BREAK):
  - loginHandler (src/auth/login.ts:42) [CALLS, 100%]
  - apiMiddleware (src/api/middleware.ts:15) [CALLS, 100%]

→ d=2 (LIKELY AFFECTED):
  - authRouter (src/routes/auth.ts:22) [CALLS, 95%]

detect_changes — 基于 git 差异的影响分析:

detect_changes({scope: "staged"})

→ Changed: 5 symbols in 3 files
→ Affected: LoginFlow, TokenRefresh, APIMiddlewarePipeline
→ Risk: MEDIUM

示例:“如果我修改 validateUser,会破坏什么?”

1. impact({target: "validateUser", direction: "upstream"})
   → d=1: loginHandler, apiMiddleware (WILL BREAK)
   → d=2: authRouter, sessionManager (LIKELY AFFECTED)

2. READ gitnexus://repo/my-app/processes
   → LoginFlow and TokenRefresh touch validateUser

3. Risk: 2 direct callers, 2 processes = MEDIUM

评论

支持 Markdown