gitnexus-pr-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR Review with GitNexus

使用GitNexus进行PR审查

When to Use

适用场景

  • "Review this PR"
  • "What does PR #42 change?"
  • "Is this safe to merge?"
  • "What's the blast radius of this PR?"
  • "Are there missing tests for this PR?"
  • Reviewing someone else's code changes before merge
  • "Review this PR"
  • "What does PR #42 change?"
  • "Is this safe to merge?"
  • "What's the blast radius of this PR?"
  • "Are there missing tests for this PR?"
  • 合并前审查他人的代码变更

Workflow

工作流

1. gh pr diff <number>                                    → Get the raw diff
2. gitnexus_detect_changes({scope: "compare", base_ref: "main"})  → Map diff to affected flows
3. For each changed symbol:
   gitnexus_impact({target: "<symbol>", direction: "upstream"})    → Blast radius per change
4. gitnexus_context({name: "<key symbol>"})               → Understand callers/callees
5. READ gitnexus://repo/{name}/processes                   → Check affected execution flows
6. Summarize findings with risk assessment
If "Index is stale" → run
npx gitnexus analyze
in terminal before reviewing.
1. gh pr diff <number>                                    → Get the raw diff
2. gitnexus_detect_changes({scope: "compare", base_ref: "main"})  → Map diff to affected flows
3. For each changed symbol:
   gitnexus_impact({target: "<symbol>", direction: "upstream"})    → Blast radius per change
4. gitnexus_context({name: "<key symbol>"})               → Understand callers/callees
5. READ gitnexus://repo/{name}/processes                   → Check affected execution flows
6. Summarize findings with risk assessment
如果出现"Index is stale"提示 → 审查前先在终端运行
npx gitnexus analyze

Checklist

检查清单

- [ ] Fetch PR diff (gh pr diff or git diff base...head)
- [ ] gitnexus_detect_changes to map changes to affected execution flows
- [ ] gitnexus_impact on each non-trivial changed symbol
- [ ] Review d=1 items (WILL BREAK) — are callers updated?
- [ ] gitnexus_context on key changed symbols to understand full picture
- [ ] Check if affected processes have test coverage
- [ ] Assess overall risk level
- [ ] Write review summary with findings
- [ ] Fetch PR diff (gh pr diff or git diff base...head)
- [ ] gitnexus_detect_changes to map changes to affected execution flows
- [ ] gitnexus_impact on each non-trivial changed symbol
- [ ] Review d=1 items (WILL BREAK) — are callers updated?
- [ ] gitnexus_context on key changed symbols to understand full picture
- [ ] Check if affected processes have test coverage
- [ ] Assess overall risk level
- [ ] Write review summary with findings

Review Dimensions

审查维度

DimensionHow GitNexus Helps
Correctness
context
shows callers — are they all compatible with the change?
Blast radius
impact
shows d=1/d=2/d=3 dependents — anything missed?
Completeness
detect_changes
shows all affected flows — are they all handled?
Test coverage
impact({includeTests: true})
shows which tests touch changed code
Breaking changesd=1 upstream items that aren't updated in the PR = potential breakage
维度GitNexus的作用
正确性
context
展示调用方 —— 它们是否都能兼容本次变更?
影响范围
impact
展示d=1/d=2/d=3的依赖项 —— 有没有遗漏?
完整性
detect_changes
展示所有受影响的流程 —— 它们是否都被妥善处理?
测试覆盖率
impact({includeTests: true})
展示哪些测试覆盖了变更的代码
破坏性变更PR diff中未更新的d=1上游项 = 潜在的功能损坏

Risk Assessment

风险评估

SignalRisk
Changes touch <3 symbols, 0-1 processesLOW
Changes touch 3-10 symbols, 2-5 processesMEDIUM
Changes touch >10 symbols or many processesHIGH
Changes touch auth, payments, or data integrity codeCRITICAL
d=1 callers exist outside the PR diffPotential breakage — flag it
信号风险等级
变更涉及<3个符号,0-1个流程
变更涉及3-10个符号,2-5个流程
变更涉及>10个符号或大量流程
变更涉及鉴权、支付或数据完整性代码严重
d=1调用方存在于PR diff之外潜在功能损坏 —— 需标记

Tools

工具

gitnexus_detect_changes — map PR diff to affected execution flows:
gitnexus_detect_changes({scope: "compare", base_ref: "main"})

→ Changed: 8 symbols in 4 files
→ Affected processes: CheckoutFlow, RefundFlow, WebhookHandler
→ Risk: MEDIUM
gitnexus_impact — blast radius per changed symbol:
gitnexus_impact({target: "validatePayment", direction: "upstream"})

→ d=1 (WILL BREAK):
  - processCheckout (src/checkout.ts:42) [CALLS, 100%]
  - webhookHandler (src/webhooks.ts:15) [CALLS, 100%]

→ d=2 (LIKELY AFFECTED):
  - checkoutRouter (src/routes/checkout.ts:22) [CALLS, 95%]
gitnexus_impact with tests — check test coverage:
gitnexus_impact({target: "validatePayment", direction: "upstream", includeTests: true})

→ Tests that cover this symbol:
  - validatePayment.test.ts [direct]
  - checkout.integration.test.ts [via processCheckout]
gitnexus_context — understand a changed symbol's role:
gitnexus_context({name: "validatePayment"})

→ Incoming calls: processCheckout, webhookHandler
→ Outgoing calls: verifyCard, fetchRates
→ Processes: CheckoutFlow (step 3/7), RefundFlow (step 1/5)
gitnexus_detect_changes —— 将PR diff映射到受影响的执行流程:
gitnexus_detect_changes({scope: "compare", base_ref: "main"})

→ Changed: 8 symbols in 4 files
→ Affected processes: CheckoutFlow, RefundFlow, WebhookHandler
→ Risk: MEDIUM
gitnexus_impact —— 每个变更符号的影响范围:
gitnexus_impact({target: "validatePayment", direction: "upstream"})

→ d=1 (WILL BREAK):
  - processCheckout (src/checkout.ts:42) [CALLS, 100%]
  - webhookHandler (src/webhooks.ts:15) [CALLS, 100%]

→ d=2 (LIKELY AFFECTED):
  - checkoutRouter (src/routes/checkout.ts:22) [CALLS, 95%]
带测试查询的gitnexus_impact —— 检查测试覆盖率:
gitnexus_impact({target: "validatePayment", direction: "upstream", includeTests: true})

→ Tests that cover this symbol:
  - validatePayment.test.ts [direct]
  - checkout.integration.test.ts [via processCheckout]
gitnexus_context —— 了解变更符号的作用:
gitnexus_context({name: "validatePayment"})

→ Incoming calls: processCheckout, webhookHandler
→ Outgoing calls: verifyCard, fetchRates
→ Processes: CheckoutFlow (step 3/7), RefundFlow (step 1/5)

Example: "Review PR #42"

示例:"Review PR #42"

1. gh pr diff 42 > /tmp/pr42.diff
   → 4 files changed: payments.ts, checkout.ts, types.ts, utils.ts

2. gitnexus_detect_changes({scope: "compare", base_ref: "main"})
   → Changed symbols: validatePayment, PaymentInput, formatAmount
   → Affected processes: CheckoutFlow, RefundFlow
   → Risk: MEDIUM

3. gitnexus_impact({target: "validatePayment", direction: "upstream"})
   → d=1: processCheckout, webhookHandler (WILL BREAK)
   → webhookHandler is NOT in the PR diff — potential breakage!

4. gitnexus_impact({target: "PaymentInput", direction: "upstream"})
   → d=1: validatePayment (in PR), createPayment (NOT in PR)
   → createPayment uses the old PaymentInput shape — breaking change!

5. gitnexus_context({name: "formatAmount"})
   → Called by 12 functions — but change is backwards-compatible (added optional param)

6. Review summary:
   - MEDIUM risk — 3 changed symbols affect 2 execution flows
   - BUG: webhookHandler calls validatePayment but isn't updated for new signature
   - BUG: createPayment depends on PaymentInput type which changed
   - OK: formatAmount change is backwards-compatible
   - Tests: checkout.test.ts covers processCheckout path, but no webhook test
1. gh pr diff 42 > /tmp/pr42.diff
   → 4 files changed: payments.ts, checkout.ts, types.ts, utils.ts

2. gitnexus_detect_changes({scope: "compare", base_ref: "main"})
   → Changed symbols: validatePayment, PaymentInput, formatAmount
   → Affected processes: CheckoutFlow, RefundFlow
   → Risk: MEDIUM

3. gitnexus_impact({target: "validatePayment", direction: "upstream"})
   → d=1: processCheckout, webhookHandler (WILL BREAK)
   → webhookHandler is NOT in the PR diff — potential breakage!

4. gitnexus_impact({target: "PaymentInput", direction: "upstream"})
   → d=1: validatePayment (in PR), createPayment (NOT in PR)
   → createPayment uses the old PaymentInput shape — breaking change!

5. gitnexus_context({name: "formatAmount"})
   → Called by 12 functions — but change is backwards-compatible (added optional param)

6. Review summary:
   - MEDIUM risk — 3 changed symbols affect 2 execution flows
   - BUG: webhookHandler calls validatePayment but isn't updated for new signature
   - BUG: createPayment depends on PaymentInput type which changed
   - OK: formatAmount change is backwards-compatible
   - Tests: checkout.test.ts covers processCheckout path, but no webhook test

Review Output Format

审查输出格式

Structure your review as:
markdown
undefined
将你的审查结构化如下:
markdown
undefined

PR Review: <title>

PR审查:<title>

Risk: LOW / MEDIUM / HIGH / CRITICAL
风险:低 / 中 / 高 / 严重

Changes Summary

变更摘要

  • <N> symbols changed across <M> files
  • <P> execution flows affected
  • <N>个符号变更,涉及<M>个文件
  • 影响<P>个执行流程

Findings

发现问题

  1. [severity] Description of finding
    • Evidence from GitNexus tools
    • Affected callers/flows
  1. [严重程度] 问题描述
    • 来自GitNexus工具的证据
    • 受影响的调用方/流程

Missing Coverage

缺失覆盖

  • Callers not updated in PR: ...
  • Untested flows: ...
  • PR中未更新的调用方:...
  • 未测试的流程:...

Recommendation

建议

APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
undefined
批准 / 请求变更 / 需要讨论
undefined