resolve-agent-reviews
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAutomatically resolve findings from PR review bots (Copilot, Cursor Bugbot, CodeRabbit, etc.) on the current PR. Uses a two-phase workflow: fix all existing issues, then poll for new ones until bots go quiet.
自动处理当前PR上来自PR审查机器人(Copilot、Cursor Bugbot、CodeRabbit等)发现的问题。采用两阶段工作流:先修复所有现有问题,再轮询新问题直到机器人不再输出新内容。
Prerequisites
前置要求
All commands below use . If the project uses a different package manager, substitute the appropriate runner (e.g., for pnpm, for Yarn, for Bun). Honor the user's package manager preference throughout.
npx agent-reviewspnpm dlx agent-reviewsyarn dlx agent-reviewsbunx agent-reviewsCloud environments only (e.g., Codespaces, remote agents): verify git author identity so CI checks can map commits to the user. Run and if empty or a placeholder, set it manually. Skip this check in local environments.
git config --global --get user.email以下所有命令均使用。如果项目使用其他包管理器,请替换为对应的运行命令(例如pnpm使用,Yarn使用,Bun使用)。全程遵循用户的包管理器偏好。
npx agent-reviewspnpm dlx agent-reviewsyarn dlx agent-reviewsbunx agent-reviews仅云环境(例如Codespaces、远程Agent):需要验证git提交者身份,以便CI检查可以将提交映射到对应使用者。运行,如果返回为空或者是占位符,请手动设置。本地环境可跳过此检查。
git config --global --get user.emailPhase 1: FETCH & FIX (synchronous)
阶段1:拉取与修复(同步执行)
Step 1: Fetch All Bot Comments (Expanded)
步骤1:拉取所有机器人评论(扩展模式)
Run
npx agent-reviews --bots-only --unanswered --expandedThe CLI auto-detects the current branch, finds the associated PR, and authenticates via CLI or environment variables. If anything fails (no token, no PR, CLI not installed), it exits with a clear error message.
ghThis shows only unanswered bot 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 bot comments found" and skip to Phase 2.
运行
npx agent-reviews --bots-only --unanswered --expanded该CLI会自动检测当前分支,查找关联的PR,并通过 CLI或环境变量完成鉴权。如果任何环节出错(无token、无对应PR、CLI未安装),会返回清晰的错误信息并退出。
gh该命令仅返回未回复的机器人评论的完整详情:完整评论内容(无截断)、差异片段(代码上下文)以及所有回复。每条评论会在括号中显示其ID(例如)。
[12345678]如果返回零条评论,打印“未找到未回复的机器人评论”并直接跳转到阶段2。
Step 3: Process Each Unanswered Comment
步骤3:处理每条未回复评论
For each comment from the expanded output:
针对扩展输出中的每条评论:
A. Evaluate the Finding
A. 评估发现的问题
Read the referenced code and determine:
- TRUE POSITIVE - A real bug that needs fixing
- FALSE POSITIVE - Not actually a bug (intentional behavior, bot misunderstanding)
- 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
When UNCERTAIN -- ask the user:
- The fix would require architectural changes
- You're genuinely unsure if the behavior is intentional
- The "bug" relates to business logic you don't fully understand
- Multiple valid interpretations exist
- The fix could have unintended side effects
阅读引用的代码并判定问题类型:
- 真阳性(TRUE POSITIVE) - 确实需要修复的真实bug
- 假阳性(FALSE POSITIVE) - 实际不是bug(预期行为、机器人理解错误)
- 不确定(UNCERTAIN) - 无法判定,询问用户
大概率为真阳性的情况:
- 代码明显违反了既定行为
- 潜在未定义值缺少空值检查
- 类型不匹配或函数签名错误
- 条件判断存在逻辑错误
- 已文档化的失败场景缺少错误处理
大概率为假阳性的情况:
- 机器人不理解所使用的框架/库的模式
- 代码是有意这样设计的(有注释说明原因)
- 机器人标记的是风格偏好,而非bug
- 所谓的“bug”实际上是功能或预期行为
- 机器人误读了代码流程
不确定时需询问用户的情况:
- 修复需要进行架构调整
- 你真的不确定该行为是否是预期设计
- 所谓的“bug”涉及你不完全理解的业务逻辑
- 存在多种合理的解读
- 修复可能会产生意外的副作用
B. Act on Evaluation
B. 根据评估结果执行操作
If TRUE POSITIVE: 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 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的原因。
如果是不确定: 询问用户。如果用户要求跳过,则标记为已跳过。
暂时不要回复评论,回复操作会在提交后执行(步骤5)。
Step 4: Commit and Push
步骤4:提交并推送
After evaluating and fixing ALL unanswered comments:
- Run your project's lint and type-check
- Stage, commit, and push:
bash
git add -A git commit -m "fix: address PR review bot findings {List of bugs fixed, grouped by bot}" git push - Capture the commit hash from the output.
在评估并修复所有未回复评论后:
- 运行项目的lint和类型检查
- 暂存、提交并推送:
bash
git add -A git commit -m "fix: address PR review bot findings {List of bugs fixed, grouped by bot}" git push - 捕获输出中的提交哈希值。
Step 5: Reply to All Comments
步骤5:回复所有评论
Now that the commit hash exists, reply to every processed comment. The flag marks the review thread as resolved on GitHub.
--resolveFor each TRUE POSITIVE:
Run
npx agent-reviews --reply <comment_id> "Fixed in {hash}. {Brief description of the fix}" --resolveFor each FALSE POSITIVE:
Run
npx agent-reviews --reply <comment_id> "Won't fix: {reason}. {Explanation of why this is intentional or not applicable}" --resolveFor each SKIPPED:
Run
npx agent-reviews --reply <comment_id> "Skipped per user request" --resolveDO NOT start Phase 2 until all replies are posted.
现在提交哈希已生成,回复所有处理过的评论。参数会将GitHub上的审查线程标记为已解决。
--resolve针对每个真阳性问题:
运行
npx agent-reviews --reply <comment_id> "Fixed in {hash}. {Brief description of the fix}" --resolve针对每个假阳性问题:
运行
npx agent-reviews --reply <comment_id> "Won't fix: {reason}. {Explanation of why this is intentional or not applicable}" --resolve针对每个已跳过的问题:
运行
npx agent-reviews --reply <comment_id> "Skipped per user request" --resolve所有回复发布前不要开始阶段2。
Phase 2: POLL FOR NEW COMMENTS (loop until quiet)
阶段2:轮询新评论(循环直到无新输出)
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 as a background task.
npx agent-reviews --watch --bots-only6b. Wait for the background command to complete (default 10 minutes; override with ).
--timeout6c. Check the output:
-
If new comments were found (output contains):
EXITING WITH NEW COMMENTS- Use to read each new comment's full detail
--detail <id> - Process them exactly as in Phase 1, Steps 3-5 (evaluate, fix, commit, push, reply)
- Go back to Step 6a to restart the watcher
- Use
-
If no new comments (output contains): Stop looping and move to the Summary Report.
WATCH COMPLETE
重复以下操作直到监控程序退出且无新评论:
6a. 后台启动监控程序:
后台运行。
npx agent-reviews --watch --bots-only6b. 等待后台命令执行完成(默认10分钟;可通过参数覆盖)。
--timeout6c. 检查输出:
-
如果发现新评论(输出包含):
EXITING WITH NEW COMMENTS- 使用读取每条新评论的完整详情
--detail <id> - 完全按照阶段1的步骤3-5处理(评估、修复、提交、推送、回复)
- 回到步骤6a重启监控程序
- 使用
-
如果无新评论(输出包含): 停止循环,进入总结报告环节。
WATCH COMPLETE
Summary Report
总结报告
After both phases complete, provide a summary:
text
undefined两个阶段都完成后,提供如下总结:
text
undefinedPR Review Bot Resolution Summary
PR Review Bot Resolution Summary
Results
Results
- Fixed: X bugs
- Already fixed: X bugs
- Won't fix (false positives): X
- Skipped per user: X
- Fixed: X bugs
- Already fixed: X bugs
- Won't fix (false positives): X
- Skipped per user: X
By Bot
By Bot
cursor[bot]
cursor[bot]
- BUG-001: {description} - Fixed in {commit}
- BUG-002: {description} - Won't fix: {reason}
- BUG-001: {description} - Fixed in {commit}
- BUG-002: {description} - Won't fix: {reason}
Copilot
Copilot
- {description} - Fixed in {commit}
- {description} - Fixed in {commit}
Status
Status
All findings addressed. Watch completed.
undefinedAll findings addressed. Watch completed.
undefinedImportant Notes
重要注意事项
Response Policy
回复规则
- Every finding gets a response - No silent ignores
- Responses help train bots and document decisions
- "Won't fix" responses prevent the same false positive from being re-raised
- 每条发现的问题都要有回复 - 不要静默忽略
- 回复有助于训练机器人并记录决策
- “不予修复”的回复可以避免相同的假阳性问题被再次提出
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
- 对问题不确定时要询问用户
- 不要猜测架构或业务逻辑相关的问题
- 询问好过做出错误的修复或错误的驳回
Best Practices
最佳实践
- Verify findings before fixing - bots have false positives
- 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 blocks often contain ready-to-use fixes
suggestion
- 修复前先验证问题 - 机器人也会有误报
- 保持修复最小化且聚焦 - 不要重构不相关的代码
- 提交前确保类型检查和lint通过
- 将相关的修复合并到单次提交中
- Copilot 块通常包含可直接使用的修复方案
suggestion