resolve-comments
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResolve Comments
处理评审意见
You are assisting with resolving PR review comments. Follow these steps:
你正在协助处理PR评审意见,请遵循以下步骤:
1. Fetch Review Comments
1. 获取评审意见
First, get PR info and review comments:
bash
gh pr view --json number,headRepositoryOwner
gh api /repos/{owner}/{repo}/pulls/{number}/commentsFormat and display comments showing: author, file path, line number, diff hunk, and comment body.
Then, for actions that require thread IDs (reply/resolve), fetch via GraphQL:
bash
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: NUMBER) {
reviewThreads(first: 50) {
nodes {
id
isResolved
comments(first: 10) {
nodes {
databaseId
body
path
line
}
}
}
}
}
}
}'首先,获取PR信息和评审意见:
bash
gh pr view --json number,headRepositoryOwner
gh api /repos/{owner}/{repo}/pulls/{number}/comments格式化并展示意见,包含:作者、文件路径、行号、代码差异块和意见内容。
对于需要线程ID的操作(回复/处理),通过GraphQL获取:
bash
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: NUMBER) {
reviewThreads(first: 50) {
nodes {
id
isResolved
comments(first: 10) {
nodes {
databaseId
body
path
line
}
}
}
}
}
}
}'2. Analyze and Propose Response
2. 分析并提出回复方案
For each unresolved comment, analyze the feedback and make a professional judgment:
- Assess validity: Is the feedback technically correct? Does it improve the code?
- Evaluate trade-offs: Consider complexity, scope, and practical impact
- Propose action: Recommend either fixing or explaining why no change is needed
Present your analysis and recommendation to the user for each comment. The user makes the final decision, but you should provide clear reasoning for your recommendation.
针对每条未处理的意见,分析反馈并做出专业判断:
- 评估有效性:反馈在技术上是否正确?是否能改进代码?
- 评估权衡:考虑复杂度、范围和实际影响
- 提出行动建议:建议修复或解释无需修改的原因
为每条意见向用户展示你的分析和建议。最终决定权在用户,但你需要为建议提供清晰的理由。
3. Handle Response
3. 处理回复
If fix required:
- Make the necessary code changes
- Reply to acknowledge the fix (e.g., "Done")
- Resolve the thread
- Inform user to use or
/fixupafter all fixes are complete/commit
If no action needed:
- Draft a reply with clear rationale (e.g., "Won't fix because...", "Intentional design because...")
- Match the language of the original comment (e.g., reply in Japanese if the comment is in Japanese)
- Reply to the last comment in the thread (use its as
databaseId)comment_id - Post the reply:
gh api /repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies -X POST -f body="..." - Resolve the thread:
bash
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread { isResolved }
}
}'若需要修复:
- 进行必要的代码修改
- 回复确认已修复(例如:“已完成”)
- 处理该线程
- 告知用户在所有修复完成后使用或
/fixup命令/commit
若无需操作:
- 撰写带有清晰理由的回复(例如:“暂不修复,原因是...”, “有意如此设计,因为...”)
- 匹配原始意见的语言(例如:如果原始意见是日语,回复也用日语)
- 回复线程中的最后一条意见(使用其作为
databaseId)comment_id - 发布回复:
gh api /repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies -X POST -f body="..." - 处理该线程:
bash
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread { isResolved }
}
}'4. Summary
4. 总结
After processing all comments:
- List what was fixed (if any)
- List what was resolved without changes (if any)
- Suggest next steps (e.g., to amend,
/fixupto push)/publish
处理完所有意见后:
- 列出已修复的内容(如有)
- 列出无需修改已处理的内容(如有)
- 建议下一步操作(例如:使用修正提交,使用
/fixup推送)/publish