greploop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGreploop
Greploop
Iteratively fix a PR until Greptile gives a perfect review: 5/5 confidence, zero unresolved comments.
迭代修复PR,直到Greptile给出完美评审结果:5/5置信度,零未解决评论。
Inputs
输入项
- PR number (optional): If not provided, detect the PR for the current branch.
- PR编号(可选):如果未提供,将自动检测当前分支对应的PR。
Instructions
操作步骤
1. Identify the PR
1. 识别PR
bash
gh pr view --json number,headRefName -q '{number: .number, branch: .headRefName}'Switch to the PR branch if not already on it.
bash
gh pr view --json number,headRefName -q '{number: .number, branch: .headRefName}'如果当前不在PR分支上,切换到该分支。
2. Loop
2. 循环流程
Repeat the following cycle. Max 5 iterations to avoid runaway loops.
重复以下循环,最多5次迭代以避免无限循环。
A. Trigger Greptile review
A. 触发Greptile评审
Push the latest changes (if any) and wait for Greptile's review check to appear:
bash
git pushThen poll for the Greptile check to complete:
bash
gh pr checks <PR_NUMBER> --watch推送最新更改(如有)并等待Greptile的评审检查出现:
bash
git push然后轮询Greptile检查是否完成:
bash
gh pr checks <PR_NUMBER> --watchB. Fetch Greptile review results
B. 获取Greptile评审结果
Get the latest review from Greptile:
bash
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/reviewsLook for the most recent review from or .
greptile-apps[bot]greptile-apps-staging[bot]Parse the review body for:
- Confidence score: Greptile includes a score like or
3/5in its review summary.5/5 - Comment count: Number of inline review comments.
Also fetch all unresolved inline comments:
bash
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/commentsFilter to comments from Greptile that are on the latest commit.
获取Greptile的最新评审:
bash
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/reviews查找来自或的最新评审。
greptile-apps[bot]greptile-apps-staging[bot]解析评审内容以获取:
- 置信度评分:Greptile会在评审摘要中包含类似或
3/5的评分。5/5 - 评论数量:行内评审评论的数量。
同时获取所有未解决的行内评论:
bash
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments筛选出Greptile在最新提交上的评论。
C. Check exit conditions
C. 检查退出条件
Stop the loop if any of these are true:
- Confidence score is 5/5 AND there are zero unresolved comments
- Max iterations reached (report current state)
如果满足以下任一条件,停止循环:
- 置信度评分为5/5 且 无未解决评论
- 达到最大迭代次数(报告当前状态)
D. Fix actionable comments
D. 修复可操作评论
For each unresolved Greptile comment:
- Read the file and understand the comment in context.
- Determine if it's actionable (code change needed) or informational.
- If actionable, make the fix.
- If informational or a false positive, note it but still resolve the thread.
针对每条未解决的Greptile评论:
- 读取文件并结合上下文理解评论内容。
- 判断评论是否为可操作(需要修改代码)或仅为信息性提示。
- 如果是可操作评论,进行代码修复。
- 如果是信息性提示或误报,记录下来并标记该线程为已解决。
E. Resolve threads
E. 标记线程为已解决
Fetch unresolved review threads and resolve all that have been addressed (see GraphQL reference):
bash
gh api graphql -f query='
query($cursor: String) {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100, after: $cursor) {
pageInfo { hasNextPage endCursor }
nodes {
id
isResolved
comments(first: 1) {
nodes { body path author { login } }
}
}
}
}
}
}'Resolve addressed threads:
bash
gh api graphql -f query='
mutation {
t1: resolveReviewThread(input: {threadId: "ID1"}) { thread { isResolved } }
t2: resolveReviewThread(input: {threadId: "ID2"}) { thread { isResolved } }
}'获取所有未解决的评审线程,并标记已处理的线程为已解决(参考GraphQL参考文档):
bash
gh api graphql -f query='
query($cursor: String) {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100, after: $cursor) {
pageInfo { hasNextPage endCursor }
nodes {
id
isResolved
comments(first: 1) {
nodes { body path author { login } }
}
}
}
}
}
}'标记已处理的线程为已解决:
bash
gh api graphql -f query='
mutation {
t1: resolveReviewThread(input: {threadId: "ID1"}) { thread { isResolved } }
t2: resolveReviewThread(input: {threadId: "ID2"}) { thread { isResolved } }
}'F. Commit and push
F. 提交并推送代码
bash
git add -A
git commit -m "address greptile review feedback (greploop iteration N)"
git pushThen go back to step A.
bash
git add -A
git commit -m "address greptile review feedback (greploop iteration N)"
git push然后回到步骤A。
3. Report
3. 生成报告
After exiting the loop, summarize:
| Field | Value |
|---|---|
| Iterations | N |
| Final confidence | X/5 |
| Comments resolved | N |
| Remaining comments | N (if any) |
If the loop exited due to max iterations, list any remaining unresolved comments and suggest next steps.
退出循环后,生成总结报告:
| 字段 | 值 |
|---|---|
| 迭代次数 | N |
| 最终置信度 | X/5 |
| 已解决评论数 | N |
| 剩余未解决评论数 | N(如有) |
如果因达到最大迭代次数而退出循环,列出所有剩余未解决评论并给出下一步建议。
Output format
输出格式
Greploop complete.
Iterations: 2
Confidence: 5/5
Resolved: 7 comments
Remaining: 0If not fully resolved:
Greploop stopped after 5 iterations.
Confidence: 4/5
Resolved: 12 comments
Remaining: 2
Remaining issues:
- src/auth.ts:45 — "Consider rate limiting this endpoint"
- src/db.ts:112 — "Missing index on user_id column"Greploop 执行完成。
迭代次数: 2
置信度: 5/5
已解决评论: 7条
剩余评论: 0如果未完全解决:
Greploop 在5次迭代后停止。
置信度: 4/5
已解决评论: 12条
剩余评论: 2条
剩余问题:
- src/auth.ts:45 — "建议对此端点添加速率限制"
- src/db.ts:112 — "缺少user_id列的索引"