resolve-reviews

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Automatically resolve all review comments (both human and bot) on the current PR. Uses a two-phase workflow: fix all existing issues, then poll for new ones until quiet.
自动处理当前PR上的所有评审评论(包括人工和机器人发出的)。采用两阶段工作流:先修复所有现有问题,再轮询新评论直到无新内容产生。

Prerequisites

前置条件

All commands below use
npx agent-reviews
. If the project uses a different package manager, substitute the appropriate runner (e.g.,
pnpm dlx agent-reviews
for pnpm,
yarn dlx agent-reviews
for Yarn,
bunx agent-reviews
for Bun). Honor the user's package manager preference throughout.
Cloud environments only (e.g., Codespaces, remote agents): verify git author identity so CI checks can map commits to the user. Run
git config --global --get user.email
and if empty or a placeholder, set it manually. Skip this check in local environments.
以下所有命令均使用
npx agent-reviews
。如果项目使用其他包管理器,请替换为对应的执行命令(例如pnpm用
pnpm dlx agent-reviews
,Yarn用
yarn dlx agent-reviews
,Bun用
bunx agent-reviews
)。全程遵循用户的包管理器偏好。
仅云环境适用(如Codespaces、远程Agent):请验证git作者身份,以便CI检查可以将提交映射到对应用户。执行
git config --global --get user.email
,如果返回为空或占位符,请手动设置。本地环境可跳过此检查。

Phase 1: FETCH & FIX (synchronous)

第一阶段:拉取与修复(同步执行)

Step 1: Fetch All Comments (Expanded)

步骤1:拉取所有评论(扩展模式)

Run
npx agent-reviews --unanswered --expanded
The CLI auto-detects the current branch, finds the associated PR, and authenticates via
gh
CLI or environment variables. If anything fails (no token, no PR, CLI not installed), it exits with a clear error message.
This shows all unanswered comments (both human and bot) with full detail: complete comment body (no truncation), diff hunk (code context), and all replies. Each comment shows its ID in brackets (e.g.,
[12345678]
).
If zero comments are returned, print "No unanswered comments found" and skip to Phase 2.
执行
npx agent-reviews --unanswered --expanded
该CLI会自动检测当前分支,找到关联的PR,并通过
gh
CLI或环境变量进行身份验证。如果任何步骤失败(无token、无对应PR、CLI未安装),会输出清晰的错误信息并退出。
命令会返回所有未回复评论(含人工和机器人发出的)的完整详情:完整评论内容(无截断)、diff片段(代码上下文)以及所有回复。每条评论会在括号中标注其ID(例如
[12345678]
)。
如果返回零条评论,打印"未找到未回复评论"并直接跳转至第二阶段。

Step 3: Process Each Unanswered Comment

步骤3:处理每条未回复评论

For each comment from the expanded output, apply the appropriate evaluation based on whether the author is a bot or a human.
针对扩展输出中的每条评论,根据评论发布者是机器人还是人工采用对应的评估逻辑。

For Bot Comments

机器人评论

Read the referenced code and determine:
  1. TRUE POSITIVE - A real bug that needs fixing
  2. FALSE POSITIVE - Not actually a bug (intentional behavior, bot misunderstanding)
  3. UNCERTAIN - Not sure; ask the user
Likely TRUE POSITIVE:
  • Code obviously violates stated behavior
  • Missing null checks on potentially undefined values
  • Type mismatches or incorrect function signatures
  • Logic errors in conditionals
  • Missing error handling for documented failure cases
Likely FALSE POSITIVE:
  • Bot doesn't understand the framework/library patterns
  • Code is intentionally structured that way (with comments explaining why)
  • Bot is flagging style preferences, not bugs
  • The "bug" is actually a feature or intentional behavior
  • Bot misread the code flow
读取关联代码并判断属于以下哪类:
  1. 真阳性(TRUE POSITIVE):确实存在需要修复的Bug
  2. 假阳性(FALSE POSITIVE):实际不存在Bug(是预期行为、机器人理解错误)
  3. 不确定(UNCERTAIN):无法判断,询问用户
大概率为真阳性的情况:
  • 代码明显不符合约定的行为
  • 潜在的未定义值缺少空值检查
  • 类型不匹配或函数签名错误
  • 条件判断存在逻辑错误
  • 已文档化的失败场景缺少错误处理
大概率为假阳性的情况:
  • 机器人不理解所用框架/库的模式
  • 代码是有意这样设计的(有注释说明原因)
  • 机器人标记的是风格偏好问题,而非Bug
  • 所谓的"Bug"实际上是功能或预期行为
  • 机器人误读了代码流程

For Human Comments

人工评论

Read the referenced code and the reviewer's comment. Human reviewers are generally more accurate and context-aware than bots. Determine:
  1. ACTIONABLE - The reviewer identified a real issue or requested a concrete change
  2. DISCUSSION - The comment raises a valid point but the right approach is unclear
  3. ALREADY ADDRESSED - The concern has already been fixed or is no longer relevant
Likely ACTIONABLE:
  • Reviewer points out a bug or logic error
  • Reviewer requests a specific code change
  • Reviewer identifies missing edge cases or error handling
Likely DISCUSSION -- ask the user:
  • Reviewer suggests an architectural change you're unsure about
  • Comment involves a tradeoff (performance vs readability, etc.)
  • The feedback is subjective without team consensus
读取关联代码和评审者的评论。人工评审者通常比机器人更准确,上下文感知能力更强。判断属于以下哪类:
  1. 可执行(ACTIONABLE):评审者发现了真实问题,或要求进行具体的修改
  2. 待讨论(DISCUSSION):评论提出了有效观点,但最佳实现方案不明确
  3. 已处理(ALREADY ADDRESSED):相关问题已修复,或不再相关
大概率为可执行的情况:
  • 评审者指出了Bug或逻辑错误
  • 评审者要求进行具体的代码修改
  • 评审者发现了缺失的边界场景或错误处理
大概率为待讨论(需询问用户)的情况:
  • 评审者提出的架构改动你不确定是否合理
  • 评论涉及权衡取舍(比如性能 vs 可读性等)
  • 反馈是主观的,没有团队共识作为依据

When UNCERTAIN -- ask the user

不确定时的处理:询问用户

For both bot and human comments:
  • The fix would require architectural changes
  • You're genuinely unsure if the behavior is intentional
  • Multiple valid interpretations exist
  • The fix could have unintended side effects
针对机器人和人工评论,出现以下情况时均需询问用户:
  • 修复需要改动架构
  • 你真的不确定当前行为是否是预期内的
  • 存在多种合理解读
  • 修复可能产生意料之外的副作用

Act on Evaluation

基于评估结果执行操作

If TRUE POSITIVE / ACTIONABLE: Fix the code. Track the comment ID and a brief description of the fix.
If FALSE POSITIVE: Do NOT change the code. Track the comment ID and the reason it's not a real bug.
If DISCUSSION: Ask the user to consult the PR author. Apply their decision and track it.
If ALREADY ADDRESSED: Track the comment ID and note why.
If UNCERTAIN: Ask the user. If they say skip, track it as skipped.
Do NOT reply to comments yet. Replies happen after the commit (Step 5).
如果是真阳性/可执行: 修复代码。记录评论ID和修复内容的简要说明。
如果是假阳性: 不要修改代码。记录评论ID和不属于真实Bug的原因。
如果是待讨论: 请用户咨询PR作者。按照用户的决定执行并记录结果。
如果是已处理: 记录评论ID和相关说明。
如果是不确定: 询问用户。如果用户要求跳过,记录为已跳过。
暂时不要回复评论,所有回复会在提交之后(步骤5)统一处理。

Step 4: Commit and Push

步骤4:提交并推送

After evaluating and fixing ALL unanswered comments:
  1. Run your project's lint and type-check
  2. Stage, commit, and push:
    bash
    git add -A
    git commit -m "fix: address PR review findings
    
    {List of changes made, grouped by reviewer/bot}"
    git push
  3. Capture the commit hash from the output.
评估并修复完所有未回复评论后:
  1. 执行项目的lint和类型检查
  2. 暂存、提交并推送:
    bash
    git add -A
    git commit -m "fix: address PR review findings
    
    {按评审者/机器人分组的修改列表}"
    git push
  3. 从输出中获取提交哈希值。

Step 5: Reply to All Comments

步骤5:回复所有评论

Now that the commit hash exists, reply to every processed comment. The
--resolve
flag marks the review thread as resolved on GitHub.
For each TRUE POSITIVE / ACTIONABLE:
Run
npx agent-reviews --reply <comment_id> "Fixed in {hash}. {Brief description of the fix}" --resolve
For each FALSE POSITIVE:
Run
npx agent-reviews --reply <comment_id> "Won't fix: {reason}. {Explanation of why this is intentional or not applicable}" --resolve
For each DISCUSSION (after user decision):
Run
npx agent-reviews --reply <comment_id> "{Outcome}. {Explanation of the decision and any changes made}" --resolve
For each ALREADY ADDRESSED:
Run
npx agent-reviews --reply <comment_id> "Already addressed. {Explanation of when/how this was fixed}" --resolve
For each SKIPPED:
Run
npx agent-reviews --reply <comment_id> "Skipped per user request" --resolve
DO NOT start Phase 2 until all replies are posted.

现在已经有了提交哈希值,给每条处理过的评论回复。
--resolve
参数会在GitHub上将评审线程标记为已解决。
针对每条真阳性/可执行评论:
执行
npx agent-reviews --reply <comment_id> "Fixed in {hash}. {修复内容的简要说明}" --resolve
针对每条假阳性评论:
执行
npx agent-reviews --reply <comment_id> "Won't fix: {原因}. {说明为什么是预期行为或不适用}" --resolve
针对每条待讨论评论(用户作出决定后):
执行
npx agent-reviews --reply <comment_id> "{处理结果}. {说明决策原因和所作改动}" --resolve
针对每条已处理评论:
执行
npx agent-reviews --reply <comment_id> "Already addressed. {说明修复的时间/方式}" --resolve
针对每条已跳过评论:
执行
npx agent-reviews --reply <comment_id> "Skipped per user request" --resolve
所有回复发布完成前,不要开始第二阶段。

Phase 2: POLL FOR NEW COMMENTS (loop until quiet)

第二阶段:轮询新评论(循环直到无新内容)

The watcher exits immediately when new comments are found (after a 5s grace period to catch batch posts). This means you run it in a loop: start watcher, process any comments it returns, restart watcher, repeat until the watcher times out with no new comments.
当检测到新评论时,监听程序会立即退出(会有5秒的宽限期来接收批量发布的评论)。这意味着你需要循环运行它:启动监听程序,处理返回的所有评论,重启监听程序,重复直到监听程序超时且没有新评论产生。

Step 6: Start Watcher Loop

步骤6:启动监听循环

Repeat the following until the watcher exits with no new comments:
6a. Launch the watcher in the background:
Run
npx agent-reviews --watch
as a background task.
6b. Wait for the background command to complete (default 10 minutes; override with
--timeout
).
6c. Check the output:
  • If new comments were found (output contains
    EXITING WITH NEW COMMENTS
    ):
    1. Use
      --detail <id>
      to read each new comment's full detail
    2. Process them exactly as in Phase 1, Steps 3-5 (evaluate, fix, commit, push, reply)
    3. Go back to Step 6a to restart the watcher
  • If no new comments (output contains
    WATCH COMPLETE
    ): Stop looping and move to the Summary Report.

重复以下操作直到监听程序退出且无新评论:
6a. 在后台启动监听程序:
npx agent-reviews --watch
作为后台任务运行。
6b. 等待后台命令执行完成(默认10分钟,可通过
--timeout
参数覆盖)。
6c. 检查输出:
  • 如果发现新评论(输出包含
    EXITING WITH NEW COMMENTS
    ):
    1. 使用
      --detail <id>
      读取每条新评论的完整详情
    2. 完全按照第一阶段的步骤3-5处理(评估、修复、提交、推送、回复)
    3. 返回步骤6a重启监听程序
  • 如果没有新评论(输出包含
    WATCH COMPLETE
    ): 停止循环,进入总结报告环节。

Summary Report

总结报告

After both phases complete, provide a summary:
text
undefined
两个阶段都完成后,提供如下总结:
text
undefined

PR Review Resolution Summary

PR Review Resolution Summary

Results

Results

  • Fixed: X issues
  • Already addressed: X
  • Won't fix (false positives): X
  • Discussion resolved: X
  • Skipped per user: X
  • Fixed: X issues
  • Already addressed: X
  • Won't fix (false positives): X
  • Discussion resolved: X
  • Skipped per user: X

By Reviewer/Bot

By Reviewer/Bot

cursor[bot]

cursor[bot]

  • {description} - Fixed in {commit}
  • {description} - Won't fix: {reason}
  • {description} - Fixed in {commit}
  • {description} - Won't fix: {reason}

@reviewer-name

@reviewer-name

  • {description} - Fixed in {commit}
  • {description} - Fixed in {commit}

Status

Status

All findings addressed. Watch completed.
undefined
All findings addressed. Watch completed.
undefined

Important Notes

重要注意事项

Response Policy

回复规则

  • Every comment gets a response - No silent ignores
  • For bots: responses help train them and prevent re-raised false positives
  • For humans: replies keep reviewers informed and unblock approvals
  • 每条评论都必须回复 - 不要默默忽略
  • 对机器人的回复有助于训练它们,避免后续重复提出假阳性问题
  • 对人工的回复可以让评审者及时了解进度,消除审批阻塞

User Interaction

用户交互

  • Ask the user when uncertain about a finding
  • Don't guess on architectural or business logic questions
  • It's better to ask than to make a wrong fix or wrong dismissal
  • Human reviewers often have context you don't - defer to the author when unsure
  • 对评审结果不确定时要询问用户
  • 不要猜测架构或业务逻辑相关的问题
  • 询问用户好过做出错误的修复或驳回
  • 人工评审者通常拥有你不了解的上下文 - 不确定时请遵从PR作者的意见

Best Practices

最佳实践

  • Verify findings before fixing - bots have false positives, humans rarely do
  • Keep fixes minimal and focused - don't refactor unrelated code
  • Ensure type-check and lint pass before committing
  • Group related fixes into a single commit
  • Copilot
    suggestion
    blocks often contain ready-to-use fixes
  • If a human reviewer suggests a specific code change, prefer their version unless it introduces issues
  • 修复前验证问题的真实性 - 机器人会有误报,人工很少出现
  • 修复内容要最小化且聚焦 - 不要重构不相关的代码
  • 提交前确保类型检查和lint通过
  • 将相关的修复合并到单次提交中
  • Copilot的
    suggestion
    块通常包含可直接使用的修复方案
  • 如果人工评审者提出了具体的代码修改建议,优先采用他们的方案,除非该方案会引入问题