resolve-human-reviews

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Automatically resolve human review comments on the current PR. Fetches unanswered human feedback, evaluates each comment, applies fixes where appropriate, and replies to every comment with the outcome.
自动解决当前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 Human Comments (Expanded)

步骤1:获取所有人工评论(扩展模式)

Run
npx agent-reviews --humans-only --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 only unanswered human comments 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 human comments found" and skip to Phase 2.
运行
npx agent-reviews --humans-only --unanswered --expanded
该CLI会自动检测当前分支,找到关联的PR,并通过
gh
CLI或环境变量进行身份验证。如果任何环节失败(无token、无PR、CLI未安装),它会返回清晰的错误信息并退出。
该命令只会展示未回复的人工评论的完整详情:完整的评论内容(无截断)、diff片段(代码上下文)以及所有回复。每条评论都会在括号中展示其ID(例如
[12345678]
)。
如果返回的评论数量为0,打印“未找到未回复的人工评论”并直接跳转到第二阶段。

Step 3: Process Each Unanswered Comment

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

For each comment from the expanded output:
针对扩展输出中的每条评论:

A. Evaluate the Feedback

A. 评估反馈

Read the referenced code and the reviewer's comment. Human reviewers are generally more accurate and context-aware than bots. Treat their feedback with appropriate weight. 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
  • Reviewer flags a naming, API, or architectural concern with a clear fix
  • Reviewer suggests a better approach with justification
Likely DISCUSSION -- ask the user:
  • Reviewer suggests an architectural change you're unsure about
  • Comment involves a tradeoff (performance vs readability, etc.)
  • Reviewer's suggestion conflicts with patterns used elsewhere in the codebase
  • The feedback is subjective (style, naming preferences) without team consensus
  • You disagree with the feedback and want the author to weigh in
Likely ALREADY ADDRESSED:
  • The code has been changed since the review was posted
  • Another commit already fixed the issue
  • The comment refers to code that no longer exists
阅读引用的代码和评审者的评论。人工评审者通常比机器人更准确、上下文感知能力更强。请适当重视他们的反馈,判断属于以下哪种类型:
  1. 可执行:评审者指出了真实存在的问题,或提出了具体的更改要求
  2. 待讨论:评论提出了合理的观点,但合适的处理方式尚不明确
  3. 已解决:相关问题已经被修复,或不再具有相关性
大概率属于可执行的情况:
  • 评审者指出了bug或逻辑错误
  • 评审者要求进行具体的代码更改
  • 评审者指出了缺失的边界 case 或错误处理
  • 评审者标记了命名、API或架构方面的问题,且有明确的修复方案
  • 评审者提出了有依据的更优实现方案
大概率属于待讨论的情况——需要询问用户:
  • 评审者提出了你不确定是否合理的架构更改
  • 评论涉及权衡问题(比如性能 vs 可读性等)
  • 评审者的建议与代码库其他地方使用的模式冲突
  • 反馈是主观的(风格、命名偏好),且没有团队共识支撑
  • 你不认同该反馈,需要PR作者介入判断
大概率属于已解决的情况:
  • 评审提交后代码已经被更改
  • 另一次提交已经修复了该问题
  • 评论引用的代码已经不存在

B. Act on Evaluation

B. 根据评估结果执行操作

If ACTIONABLE: Fix the code. Track the comment ID and a brief description of the fix.
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.
Do NOT reply to comments yet. Replies happen after the commit (Step 5).
如果是可执行: 修复代码。记录评论ID和修复内容的简要说明。
如果是待讨论: 请用户咨询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 feedback
    
    {List of changes made, grouped by reviewer}"
    git push
  3. Capture the commit hash from the output.
在评估并修复完所有未回复评论后:
  1. 运行项目的lint和类型检查
  2. 暂存、提交并推送:
    bash
    git add -A
    git commit -m "fix: address PR review feedback
    
    {按评审者分组的更改列表}"
    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 ACTIONABLE:
Run
npx agent-reviews --reply <comment_id> "Fixed in {hash}. {Brief description of the fix}" --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
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> "{处理结果}. {决策说明以及做出的相关更改}" --resolve
针对已解决的评论:
运行
npx agent-reviews --reply <comment_id> "Already addressed. {该问题何时/如何被修复的说明}" --resolve
在所有回复发布前,不要开始第二阶段。

Phase 2: POLL FOR FOLLOW-UP 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 --humans-only
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 --humans-only
作为后台任务运行。
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评审处理总结

Results

结果

  • Fixed: X issues
  • Already addressed: X
  • Discussion resolved: X
  • Skipped per user: X
  • 已修复:X个问题
  • 已解决:X个
  • 讨论已处理:X个
  • 按用户要求跳过:X个

By Reviewer

按评审者分组

@reviewer-name

@reviewer-name

  • {description} - Fixed in {commit}
  • {description} - Already addressed
  • {描述} - 已在{commit哈希}中修复
  • {描述} - 已解决

Status

状态

All review comments addressed. Watch completed.
undefined
所有评审评论已处理。监听已完成。
undefined

Important Notes

重要说明

Response Policy

回复规则

  • Every comment gets a response - No silent ignores
  • Replies keep reviewers informed and unblock approvals
  • Even "already addressed" comments deserve acknowledgement
  • 每条评论都要有回复 - 不要静默忽略
  • 回复可以让评审者及时了解情况,不会阻塞审批流程
  • 即使是“已解决”的评论也应该收到确认

User Interaction

用户交互

  • Ask the user when the right approach is unclear
  • Human reviewers often have context you don't - defer to the author when unsure
  • It's better to ask than to make a change the author wouldn't approve
  • 当合适的处理方式不明确时,询问用户
  • 人工评审者通常有你不了解的上下文——不确定时遵从PR作者的意见
  • 询问比做出作者不会同意的更改更好

Best Practices

最佳实践

  • Human reviewers are generally more accurate than bots - default to trusting their feedback
  • 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
  • If a reviewer suggests a specific code change, prefer their version unless it introduces issues
  • 人工评审者通常比机器人更准确——默认信任他们的反馈
  • 保持修复的最小化和针对性——不要重构不相关的代码
  • 提交前确保类型检查和lint都通过
  • 将相关的修复合并到单次提交中
  • 如果评审者提出了具体的代码更改方案,优先采用他们的版本,除非该方案会引入问题