@olegkoval/agent-skills 1.50.0 → 1.51.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.github/copilot-instructions.md +1 -0
  2. package/.github/prompts/coderabbitloop.prompt.md +90 -15
  3. package/.github/prompts/codexloop.prompt.md +40 -6
  4. package/.github/prompts/copilotloop.prompt.md +302 -0
  5. package/.github/prompts/geminiloop.prompt.md +34 -6
  6. package/.github/prompts/qodoloop.prompt.md +18 -0
  7. package/.kiro/steering/coderabbitloop.md +90 -15
  8. package/.kiro/steering/codexloop.md +40 -6
  9. package/.kiro/steering/copilotloop.md +301 -0
  10. package/.kiro/steering/geminiloop.md +34 -6
  11. package/.kiro/steering/qodoloop.md +18 -0
  12. package/.windsurf/rules/coderabbitloop.md +90 -15
  13. package/.windsurf/rules/codexloop.md +40 -6
  14. package/.windsurf/rules/copilotloop.md +300 -0
  15. package/.windsurf/rules/geminiloop.md +34 -6
  16. package/.windsurf/rules/qodoloop.md +18 -0
  17. package/README.md +1 -0
  18. package/adapters/claude/olko-github-pr/skills/coderabbitloop/SKILL.md +91 -16
  19. package/adapters/claude/olko-github-pr/skills/coderabbitloop/references/graphql-queries.md +41 -9
  20. package/adapters/claude/olko-github-pr/skills/codexloop/SKILL.md +42 -8
  21. package/adapters/claude/olko-github-pr/skills/copilotloop/SKILL.md +309 -0
  22. package/adapters/claude/olko-github-pr/skills/geminiloop/SKILL.md +36 -8
  23. package/adapters/claude/olko-github-pr/skills/lekker-review/references/output-format.md +5 -1
  24. package/adapters/claude/olko-github-pr/skills/lekker-review/references/pricing.json +5 -1
  25. package/adapters/claude/olko-github-pr/skills/lekker-review/references/revmux/profiles/lekker-deep-codex.md +2 -2
  26. package/adapters/claude/olko-github-pr/skills/lekker-review/references/revmux/profiles/lekker-medium-codex.md +2 -2
  27. package/adapters/claude/olko-github-pr/skills/qodoloop/SKILL.md +19 -1
  28. package/adapters/claude/olko-github-pr/skills/qodoloop/references/graphql-queries.md +19 -2
  29. package/adapters/codex/olko-github-pr/README.md +1 -0
  30. package/adapters/cursor/olko-github-pr/skills/coderabbitloop/SKILL.md +91 -16
  31. package/adapters/cursor/olko-github-pr/skills/coderabbitloop/references/graphql-queries.md +41 -9
  32. package/adapters/cursor/olko-github-pr/skills/codexloop/SKILL.md +42 -8
  33. package/adapters/cursor/olko-github-pr/skills/copilotloop/SKILL.md +309 -0
  34. package/adapters/cursor/olko-github-pr/skills/geminiloop/SKILL.md +36 -8
  35. package/adapters/cursor/olko-github-pr/skills/qodoloop/SKILL.md +19 -1
  36. package/adapters/cursor/olko-github-pr/skills/qodoloop/references/graphql-queries.md +19 -2
  37. package/adapters/grok/olko-github-pr/skills/coderabbitloop/SKILL.md +91 -16
  38. package/adapters/grok/olko-github-pr/skills/coderabbitloop/references/graphql-queries.md +41 -9
  39. package/adapters/grok/olko-github-pr/skills/codexloop/SKILL.md +42 -8
  40. package/adapters/grok/olko-github-pr/skills/copilotloop/SKILL.md +309 -0
  41. package/adapters/grok/olko-github-pr/skills/geminiloop/SKILL.md +36 -8
  42. package/adapters/grok/olko-github-pr/skills/qodoloop/SKILL.md +19 -1
  43. package/adapters/grok/olko-github-pr/skills/qodoloop/references/graphql-queries.md +19 -2
  44. package/catalog/skills.json +23 -0
  45. package/package.json +1 -1
  46. package/plugins/olko-apple-kit/.claude-plugin/plugin.json +1 -1
  47. package/plugins/olko-creative/.claude-plugin/plugin.json +1 -1
  48. package/plugins/olko-garmin-kit/.claude-plugin/plugin.json +1 -1
  49. package/plugins/olko-git-tools/.claude-plugin/plugin.json +1 -1
  50. package/plugins/olko-github-pr/.claude-plugin/plugin.json +1 -1
  51. package/plugins/olko-github-pr/skills/coderabbitloop/SKILL.md +91 -16
  52. package/plugins/olko-github-pr/skills/coderabbitloop/references/graphql-queries.md +41 -9
  53. package/plugins/olko-github-pr/skills/codexloop/SKILL.md +42 -8
  54. package/plugins/olko-github-pr/skills/copilotloop/SKILL.md +308 -0
  55. package/plugins/olko-github-pr/skills/geminiloop/SKILL.md +36 -8
  56. package/plugins/olko-github-pr/skills/lekker-review/references/output-format.md +5 -1
  57. package/plugins/olko-github-pr/skills/lekker-review/references/pricing.json +5 -1
  58. package/plugins/olko-github-pr/skills/lekker-review/references/revmux/profiles/lekker-deep-codex.md +2 -2
  59. package/plugins/olko-github-pr/skills/lekker-review/references/revmux/profiles/lekker-medium-codex.md +2 -2
  60. package/plugins/olko-github-pr/skills/qodoloop/SKILL.md +19 -1
  61. package/plugins/olko-github-pr/skills/qodoloop/references/graphql-queries.md +19 -2
  62. package/plugins/olko-obsidian/.claude-plugin/plugin.json +1 -1
  63. package/plugins/olko-product/.claude-plugin/plugin.json +1 -1
  64. package/plugins/olko-reflection/.claude-plugin/plugin.json +1 -1
  65. package/plugins/olko-release/.claude-plugin/plugin.json +1 -1
  66. package/plugins/olko-skill-meta/.claude-plugin/plugin.json +1 -1
  67. package/plugins/olko-web-ops/.claude-plugin/plugin.json +1 -1
  68. package/scripts/lib/catalog.mjs +1 -1
@@ -18,6 +18,7 @@ Available reusable prompt files:
18
18
  - qodoloop: .github/prompts/qodoloop.prompt.md
19
19
  - coderabbitloop: .github/prompts/coderabbitloop.prompt.md
20
20
  - codexloop: .github/prompts/codexloop.prompt.md
21
+ - copilotloop: .github/prompts/copilotloop.prompt.md
21
22
  - geminiloop: .github/prompts/geminiloop.prompt.md
22
23
  - ci-fix-loop: .github/prompts/ci-fix-loop.prompt.md
23
24
  - dependabot-triage: .github/prompts/dependabot-triage.prompt.md
@@ -38,13 +38,30 @@ CodeRabbit has slash commands (official, `docs.coderabbit.ai/reference/review-co
38
38
  gh pr view --json number,headRefName,headRefOid -q '{number, branch: .headRefName, sha: .headRefOid}'
39
39
  ```
40
40
 
41
- Check out the branch if not already on it.
41
+ Check out the branch if not already on it, **then require a clean working tree**
42
+ (`git status --porcelain` empty) before touching anything:
43
+
44
+ ```bash
45
+ [ -z "$(git status --porcelain)" ] || { echo "working tree not clean, refusing to start: would risk committing unrelated changes"; exit 1; }
46
+ ```
47
+
48
+ This is the precondition step E's scoped `git add <file>` depends on: staging only the files a fix
49
+ touched is safe *because* the tree started clean. Skip it and a file with pre-existing local edits
50
+ gets those edits swept into the fix commit right along with it.
42
51
 
43
52
  ### 2. Loop (max 5 iterations)
44
53
 
45
- #### A. Push and wait
54
+ Keep an explicit iteration counter and stop at 5: the cap is a real bound to enforce, not a figure
55
+ of speech. Each pass through A–F is one iteration; on hitting the cap, go straight to the report.
56
+
57
+ #### A. Wait for a review of the current head
58
+
59
+ On **iteration 1**, if there is nothing to push yet (you haven't fixed anything in this loop), don't
60
+ wait for a brand-new review: use whatever CodeRabbit has already posted as your starting point and
61
+ go straight to step B. Otherwise:
46
62
 
47
63
  ```bash
64
+ SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
48
65
  git push
49
66
  ```
50
67
 
@@ -54,11 +71,27 @@ If this repo doesn't auto-review on push, nudge it:
54
71
  gh pr comment <PR_NUMBER> --body "@coderabbitai review"
55
72
  ```
56
73
 
57
- Poll (every ~10s, timeout ~5min) for CodeRabbit's next formal review to land: a new entry in `gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/reviews` from `coderabbitai[bot]` created after this push. If you instead see a rate-limit comment ("review limit"), **stop the loop now** and go to Report with `blocked: rate-limited`.
74
+ Poll (every ~10s, timeout ~5min) for CodeRabbit's next formal review to land: a new entry in
75
+ `gh api --paginate repos/{owner}/{repo}/pulls/<PR_NUMBER>/reviews` from `coderabbitai[bot]`
76
+ (REST spelling carries the `[bot]` suffix) created after `$SINCE`. Follow pagination so a review
77
+ that lands on page two is not missed. If you instead see a rate-limit comment ("review limit"),
78
+ **stop the loop now** and go to Report with `blocked: rate-limited`. If no review arrives within
79
+ the timeout after one retry, stop and report the timeout honestly; do not claim success.
58
80
 
59
81
  #### B. Fetch unresolved findings
60
82
 
61
- Run the `unresolvedQodoThreads`-shaped query in `references/graphql-queries.md` (filter `author.login == "coderabbitai[bot]"` instead of Qodo's login). For each unresolved thread, parse the finding text and the **Prompt for AI Agents** block (heading text is `🤖 Prompt for AI Agents`, not `Agent Prompt`: match case/emoji-insensitively).
83
+ Run the `unresolvedQodoThreads`-shaped query in `references/graphql-queries.md` (filter `author.login`
84
+ on GraphQL's bare `coderabbitai`, **not** REST's `coderabbitai[bot]`: see the reference's login-spelling
85
+ note, and follow `pageInfo.hasNextPage`/`endCursor` until exhausted). For each unresolved thread,
86
+ parse the finding text, its `databaseId`, and the **Prompt for AI Agents** block (heading text is
87
+ `🤖 Prompt for AI Agents`, not `Agent Prompt`: match case/emoji-insensitively).
88
+
89
+ Mark each thread as seen with an 👀 reaction on its first comment (`databaseId` from the query), so
90
+ the bot and a watching human can tell it is being worked:
91
+
92
+ ```bash
93
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<DATABASE_ID>/reactions -f content=eyes
94
+ ```
62
95
 
63
96
  #### C. Check exit conditions
64
97
 
@@ -66,26 +99,68 @@ Stop if there are zero unresolved CodeRabbit threads, or max iterations reached.
66
99
 
67
100
  #### D. Fix each finding
68
101
 
69
- For each thread, in order: read the Prompt for AI Agents block in full: it names the issue and the fix. Apply it, staying inside its stated scope. If the suggestion is wrong, unsafe, or needs a product decision, don't force it: note that in step E instead.
102
+ For each thread, in order: read the Prompt for AI Agents block in full: it names the issue and the fix. Apply it, staying inside its stated scope. If the suggestion is wrong, unsafe, or needs a product decision, don't force it: note that in step F instead. Track two lists as you go: **fixed** (thread id + the exact files you touched) and **skipped** (thread id + why). Do not resolve anything yet.
103
+
104
+ #### E. Commit and push FIRST, before resolving anything
70
105
 
71
- #### E. Answer and resolve
106
+ Order matters. A resolved thread is a claim that the fix is on the branch, so the push has to succeed
107
+ before the claim is made: otherwise a failed commit or push leaves the PR unfixed with the finding
108
+ marked resolved, and nobody looks at it again.
72
109
 
73
- **Reply to the thread first, then resolve it**, the "answer to the comments" half of the job:
110
+ If step D changed code:
74
111
 
75
112
  ```bash
76
- gh api graphql -f query='mutation { addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: "<THREAD_ID>", body: "<REPLY>"}) { comment { id } } }'
113
+ # Stage ONLY the files your fixes touched: never `git add -A`, which sweeps up
114
+ # unrelated work and untracked secrets sitting in the worktree.
115
+ git status --short # look before you stage
116
+ git add <path> [<path>...] # the files named in the findings you fixed
117
+ git commit -m "address CodeRabbit review feedback (coderabbitloop iteration N)"
118
+ git push
77
119
  ```
78
120
 
79
- Reply body: one or two sentences, what you changed and why, or exactly why you didn't fix it. Then resolve (`resolveReviewThread`). A finding you deliberately skip still gets a reply and gets resolved.
121
+ Confirm the push actually landed before continuing:
80
122
 
81
- #### F. Commit and push
123
+ ```bash
124
+ git rev-parse HEAD
125
+ gh pr view <PR_NUMBER> --json headRefOid -q .headRefOid # must match
126
+ ```
127
+
128
+ If they differ, stop: the fix is not on the PR, so nothing may be resolved yet.
129
+
130
+ #### F. Reply to each finding, react, then resolve
131
+
132
+ Only now, with the fixes pushed, reply and resolve. **Reply to the thread first, then react, then
133
+ resolve it**, the "answer to the comments" half of the job:
82
134
 
83
135
  ```bash
84
- git add -A
85
- git commit -m "address CodeRabbit review feedback (coderabbitloop iteration N)"
86
- git push
136
+ gh api graphql -f query='
137
+ mutation($threadId: ID!, $body: String!) {
138
+ addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: $threadId, body: $body}) {
139
+ comment { id }
140
+ }
141
+ }' -f threadId="$THREAD_ID" -f body="$REPLY_TEXT"
87
142
  ```
88
143
 
144
+ Pass the thread id and reply text as GraphQL **variables** (`-f threadId=... -f body=...`), never
145
+ interpolated into the query string: a reply containing a quote, backtick, or newline breaks (or
146
+ injects into) a hand-built query.
147
+
148
+ Reply body: one or two sentences, what you changed and why, or exactly why you didn't fix it. A
149
+ finding you deliberately skip still gets a reply and gets resolved.
150
+
151
+ Then record the disposition as a reaction on the thread's first comment: the learning signal, and a
152
+ visible marker for a human scanning the PR. 👍 (`+1`) for fixed, 👎 (`-1`) for skipped/rebutted.
153
+ CodeRabbit reads a 👎 as feedback that the finding was wrong.
154
+
155
+ ```bash
156
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<DATABASE_ID>/reactions -f content=+1
157
+ # skipped/rebutted finding:
158
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<DATABASE_ID>/reactions -f content=-1
159
+ ```
160
+
161
+ Then resolve (`resolveReviewThread`). Reply first, react, then resolve: a reaction never replaces
162
+ the reply, and a resolved thread with no reply loses the reasoning.
163
+
89
164
  Go back to step A.
90
165
 
91
166
  ### 3. Report
@@ -96,7 +171,7 @@ Go back to step A.
96
171
  | Findings resolved | N |
97
172
  | Findings skipped | N (with reasons) |
98
173
  | Remaining | N (if any) |
99
- | Blocked | rate-limited / max-iterations / none |
174
+ | Blocked | rate-limited / timeout / max-iterations / none |
100
175
 
101
176
  ```
102
177
  Coderabbitloop complete.
@@ -107,4 +182,4 @@ Coderabbitloop complete.
107
182
 
108
183
  ## References
109
184
 
110
- - `references/graphql-queries.md`: shared with `qodoloop`: the exact `reviewThreads` query and the `resolveReviewThread` / `addPullRequestReviewThreadReply` mutations. Swap the author-login filter to `coderabbitai[bot]` and the prompt-heading match to `Prompt for AI Agents`.
185
+ - `references/graphql-queries.md`: shared with `qodoloop`: the exact `reviewThreads` query (including the `databaseId` the reaction step needs) and the `resolveReviewThread` / `addPullRequestReviewThreadReply` mutations. Filter `author.login` on GraphQL's bare `coderabbitai` (never `coderabbitai[bot]`) and match the prompt heading `Prompt for AI Agents`.
@@ -30,7 +30,7 @@ suggestion applied is worse than the comment itself.
30
30
  ## Not for
31
31
 
32
32
  - GitLab / Perforce (Codex code review is a GitHub app). For other review bots this catalog ships
33
- `geminiloop`, `coderabbitloop`, and `qodoloop`; for CI failures rather than review comments, use
33
+ `copilotloop`, `geminiloop`, `coderabbitloop`, and `qodoloop`; for CI failures rather than review comments, use
34
34
  `ci-fix-loop`.
35
35
 
36
36
  ## 0. Resolve the Codex bot login (do this first, do not hardcode)
@@ -77,9 +77,13 @@ report and list what is still unresolved rather than starting a sixth.
77
77
 
78
78
  ```bash
79
79
  HEAD_SHA=$(gh pr view <PR> --json headRefOid -q .headRefOid)
80
- # Only trigger if no Codex review already exists for this exact SHA:
81
- HAVE=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate \
82
- --jq "[.[] | select(.user.login==\"$BOT\" and .commit_id==\"$HEAD_SHA\")] | length")
80
+ # Only trigger if no Codex review already exists for this exact SHA.
81
+ # gh cannot combine --slurp with --jq, so pipe to `jq -s`: it folds every page
82
+ # into one array. Without it the filter runs once per page and HAVE becomes a
83
+ # multi-line count that never equals "0", silently skipping the trigger.
84
+ HAVE=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
85
+ jq -s --arg bot "$BOT" --arg head "$HEAD_SHA" \
86
+ '[.[][] | select(.user.login==$bot and .commit_id==$head)] | length')
83
87
  if [ "$HAVE" = "0" ]; then gh pr comment <PR> --body "@codex review"; fi
84
88
  ```
85
89
 
@@ -93,8 +97,9 @@ an honest timeout, not hang it.
93
97
  wait_for_review() { # $1 = attempt label
94
98
  local deadline=$(( SECONDS + 600 ))
95
99
  while [ "$SECONDS" -lt "$deadline" ]; do
96
- R=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate \
97
- --jq "[.[] | select(.user.login==\"$BOT\" and .commit_id==\"$HEAD_SHA\")] | last")
100
+ R=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
101
+ jq -s --arg bot "$BOT" --arg head "$HEAD_SHA" \
102
+ '[.[][] | select(.user.login==$bot and .commit_id==$head)] | sort_by(.submitted_at, .id) | last')
98
103
  if [ -n "$R" ] && [ "$R" != "null" ]; then return 0; fi
99
104
  echo "waiting for Codex review of $HEAD_SHA ($1)..."; sleep 15
100
105
  done
@@ -128,6 +133,13 @@ gh api repos/{owner}/{repo}/pulls/<PR>/comments --paginate \
128
133
  Also pull the review threads + their resolved state via GraphQL (see step F) so you only act on
129
134
  unresolved ones.
130
135
 
136
+ Mark each unresolved comment as seen, so the bot and a watching human can tell it is being handled.
137
+ GitHub's reaction set is fixed; `eyes` is the only "looking at it" value:
138
+
139
+ ```bash
140
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=eyes
141
+ ```
142
+
131
143
  ### C. Critically evaluate EACH comment (the core of this skill)
132
144
 
133
145
  For every comment, **verify the claim against the actual code and repo conventions before touching
@@ -216,6 +228,13 @@ while : ; do
216
228
  }
217
229
  }')
218
230
  echo "$PAGE" # collect nodes from every page before deciding the PR is clean
231
+ # GitHub GraphQL returns transient 502/504s (no .data). An empty page reads as
232
+ # "no next page", so retry it a bounded number of times instead of treating it as clean.
233
+ if ! echo "$PAGE" | jq -e '.data' >/dev/null 2>&1; then
234
+ RETRIES=$(( ${RETRIES:-0} + 1 ))
235
+ [ "$RETRIES" -le 3 ] || { echo "GraphQL still failing after 3 retries; threads unknown, not clean"; exit 1; }
236
+ sleep 5; continue
237
+ fi
219
238
  PI='.data.repository.pullRequest.reviewThreads.pageInfo'
220
239
  [ "$(echo "$PAGE" | jq -r "$PI.hasNextPage")" = "true" ] || break
221
240
  CURSOR=$(echo "$PAGE" | jq -r "$PI.endCursor")
@@ -229,6 +248,21 @@ then resolve:
229
248
  gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'
230
249
  ```
231
250
 
251
+ Then record the disposition as a reaction on the bot's own comment: the learning signal, and a
252
+ visible marker for a human scanning the PR:
253
+
254
+ - 👍 (`+1`): the finding was accepted and fixed.
255
+ - 👎 (`-1`): the finding was rebutted as a false positive. **This is the correction signal.**
256
+
257
+ ```bash
258
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=+1
259
+ # rebutted finding:
260
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=-1
261
+ ```
262
+
263
+ Reply first, then react, then resolve: the reaction is not a substitute for the reply, and a
264
+ resolved thread with no reply loses the reasoning.
265
+
232
266
  Resolve a thread only for comments authored by `$BOT` that you have fixed or rebutted: never
233
267
  blanket-resolve, and never resolve a human reviewer's thread. For each fixed comment, verify the
234
268
  push first, reply with the change made, then resolve the thread and verify `isResolved: true`.
@@ -0,0 +1,302 @@
1
+ <!-- Generated by scripts/build-adapters.sh. Do not edit directly. -->
2
+
3
+ ---
4
+ description: "Iteratively drives a GitHub PR to zero unresolved GitHub Copilot review comments, verifying every finding against the real code first, fixes only the correct ones, and rebuts false positives without changing correct code."
5
+ ---
6
+
7
+ Use the olko:copilotloop skill.
8
+
9
+ # Copilotloop
10
+
11
+ Drive a GitHub PR until Copilot has no unresolved review comments, **but do not cargo-cult its
12
+ suggestions.** Every comment is a *claim to verify*, not an instruction to obey. A wrong
13
+ suggestion applied is worse than the comment itself.
14
+
15
+ ## How Copilot differs from other review bots
16
+
17
+ - **No check-run, no score.** Copilot posts an overview comment and a PR review with inline review
18
+ comments. Detection is by polling the reviews endpoint and paginated review threads. "Satisfied"
19
+ means zero unresolved Copilot threads and zero unaddressed body findings after each finding is
20
+ fixed or rebutted with a recorded reply.
21
+ - **Request through the reviewers API.** Copilot does not use a reliable slash-command trigger.
22
+ Request `copilot-pull-request-reviewer[bot]` through the pull request reviewers endpoint. A
23
+ repository may also be configured to review new pushes automatically.
24
+ - **Copilot may repeat comments.** A re-review can repeat comments that were resolved or downvoted,
25
+ so match findings to the current head and prior replies before reopening work, including body
26
+ findings that have no inline thread.
27
+ - **Copilot is concise and can reason from the diff alone.** Its characteristic failure is
28
+ confidently asserting a bug based only on the changed hunk, without the surrounding file or the
29
+ call sites. That makes "read the whole file before believing it" the single highest-value check.
30
+
31
+ ## Not for
32
+
33
+ - GitLab / Perforce. For other review bots this catalog ships `codexloop`, `geminiloop`,
34
+ `coderabbitloop`, and `qodoloop`; for CI failures rather than review comments, use
35
+ `ci-fix-loop`.
36
+
37
+ ## 0. Resolve the Copilot bot login (do this first)
38
+
39
+ The bot login is normally stable, but confirm it from the PR rather than assuming it:
40
+
41
+ ```bash
42
+ gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate --jq '.[].user.login' | sort -u
43
+ gh api repos/{owner}/{repo}/pulls/<PR>/comments --paginate --jq '.[].user.login' | sort -u
44
+ ```
45
+
46
+ Use `copilot-pull-request-reviewer[bot]` as `BOT`. Confirm it appears after the first requested
47
+ review; if GitHub uses a different login for the installation, use the exact Copilot-looking login
48
+ returned by the probe rather than guessing.
49
+
50
+ **Finding nothing here is NOT a stop condition.** On a PR Copilot has never reviewed there is no bot
51
+ login to find yet. Fall through to step 2A, request the reviewer, and re-run this probe once a
52
+ review lands. Only conclude Copilot is unavailable after the bounded wait expires with no review.
53
+
54
+ ## 1. Identify the PR
55
+
56
+ ```bash
57
+ gh pr view --json number,headRefName,headRefOid -q '{number,branch:.headRefName,head:.headRefOid}'
58
+ ```
59
+
60
+ Switch to the PR branch if not already on it. Capture `OWNER`/`REPO` (`gh repo view --json owner,name`).
61
+
62
+ ## 2. The loop (max 5 iterations)
63
+
64
+ Keep an explicit iteration counter and stop at 5: the cap is a real bound to enforce, not a
65
+ figure of speech. Each pass through A–G is one iteration; on hitting the cap, go straight to the
66
+ report and list what is still unresolved rather than starting a sixth.
67
+
68
+ ### A. Ensure a fresh Copilot review on the current head
69
+
70
+ ```bash
71
+ HEAD_SHA=$(gh pr view <PR> --json headRefOid -q .headRefOid)
72
+ # Only trigger if no Copilot review exists for this exact SHA:
73
+ HAVE=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
74
+ jq -s --arg bot "$BOT" --arg head "$HEAD_SHA" \
75
+ '[.[][] | select(.user.login==$bot and .commit_id==$head)] | length')
76
+ if [ "$HAVE" = "0" ]; then
77
+ gh api --method POST repos/{owner}/{repo}/pulls/<PR>/requested_reviewers \
78
+ -f 'reviewers[]=copilot-pull-request-reviewer[bot]'
79
+ fi
80
+ ```
81
+
82
+ Poll for the review of THIS head to land. No check-run exists, so poll the reviews endpoint, and
83
+ poll it on a **deadline**, never `while true`: a review that never arrives must end the skill with
84
+ an honest timeout, not hang it.
85
+
86
+ ```bash
87
+ # 10-minute deadline, one retry, then give up. DEADLINE/RETRIES are the
88
+ # enforcement of the bounds this skill claims: do not drop them.
89
+ wait_for_review() { # $1 = attempt label
90
+ local deadline=$(( SECONDS + 600 ))
91
+ while [ "$SECONDS" -lt "$deadline" ]; do
92
+ R=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
93
+ jq -s --arg bot "$BOT" --arg head "$HEAD_SHA" \
94
+ '[.[][] | select(.user.login==$bot and .commit_id==$head)] | sort_by(.submitted_at, .id) | last')
95
+ if [ -n "$R" ] && [ "$R" != "null" ]; then return 0; fi
96
+ echo "waiting for Copilot review of $HEAD_SHA ($1)..."; sleep 15
97
+ done
98
+ return 1
99
+ }
100
+
101
+ if ! wait_for_review "first wait"; then
102
+ echo "no Copilot review after 10m, retrying once" # say the retry out loud
103
+ gh api --method POST repos/{owner}/{repo}/pulls/<PR>/requested_reviewers \
104
+ -f 'reviewers[]=copilot-pull-request-reviewer[bot]'
105
+ if ! wait_for_review "after retry"; then
106
+ echo "Copilot did not review $HEAD_SHA after a retry; stopping and reporting."
107
+ exit 1 # honest timeout, never a success claim
108
+ fi
109
+ fi
110
+ ```
111
+
112
+ Copilot usually reviews quickly, but large diffs can take longer; the deadline is bounded. Report the
113
+ retry in the final summary; two silent timeouts are the failure mode this guard exists to prevent.
114
+
115
+ ### B. Fetch the findings
116
+
117
+ - **Summary**: read the Copilot overview comment and review `.body`, including all matching reviews
118
+ for the current head. Extract and classify actionable claims even when they have no inline thread;
119
+ an approval assessment or lack of inline comments does not make those findings complete.
120
+ Track each body finding across iterations by source review/comment ID and item, with its
121
+ classification, fix commit or evidence-based rebuttal, PR-level reply URL, and completion status.
122
+ Link duplicates to the same finding so they are counted once; retain pending findings after a push.
123
+ - **Unresolved inline comments** on the current head:
124
+
125
+ ```bash
126
+ gh api repos/{owner}/{repo}/pulls/<PR>/comments --paginate \
127
+ --jq ".[] | select(.user.login==\"$BOT\") | {id, path, line, body}"
128
+ ```
129
+
130
+ Also pull the review threads + their resolved state via GraphQL (see step F) so you only act on
131
+ unresolved ones.
132
+
133
+ Mark each unresolved inline comment as seen, so the bot and a watching human can tell it is being
134
+ handled. GitHub's reaction set is fixed; `eyes` is the only "looking at it" value:
135
+
136
+ ```bash
137
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=eyes
138
+ ```
139
+
140
+ Body findings (no inline thread) have no comment to react to; track them in step B's register and
141
+ give each a PR-level reply in step F instead.
142
+
143
+ ### C. Critically evaluate EACH finding (the core of this skill)
144
+
145
+ For every inline or body finding, **verify the claim against the actual code and repo conventions
146
+ before touching anything.** Read the whole file, not just the diff hunk Copilot saw, plus the types
147
+ and the call sites. Then classify:
148
+
149
+ 1. **CORRECT + actionable**: the finding is real and the fix improves the code. → fix it (step D).
150
+ 2. **FALSE POSITIVE / technically wrong**: the claim doesn't hold. → do **NOT** change code; write a
151
+ specific, evidence-based reply (cite the exact code/line/behavior that disproves it), then resolve
152
+ its thread or record completion for a body finding (step F).
153
+ 3. **Valid but out-of-scope / stylistic nit** that conflicts with repo convention or the PR's intent
154
+ → briefly decline with evidence of that convention or scope, then resolve its thread or record
155
+ completion for a body finding (step F). Do not expand the PR's scope to satisfy a nit.
156
+
157
+ **Hard rules:**
158
+ - **Never modify correct code just to silence Copilot.** Prefer a reasoned rebuttal.
159
+ - When uncertain whether a claim holds, **investigate** (read more code, run the type-checker / tests)
160
+ rather than assume Copilot is right. Default to skepticism.
161
+ - If a suggested change would break other call sites, alter public behavior, or contradict a verified
162
+ repo convention, it is a category-2 rebuttal, not a fix.
163
+ - Never fabricate identifiers to satisfy a comment (e.g. a Linear/ticket prefix). If Copilot asks for a
164
+ ticket reference and none exists, say so; do not invent one.
165
+
166
+ **Copilot's common failure modes to watch for (default these to category 2):**
167
+ - Diff-local reasoning: asserts a bug that the unchanged surrounding code already handles.
168
+ - "This can be null/undefined here" where the type or an earlier guard already rules it out.
169
+ - Invented race conditions or error paths with no actual trigger.
170
+ - Suggestions that compile-break or break other callers.
171
+ - Security/perf warnings with no exploit path or measurable cost.
172
+ - Restating library/framework semantics incorrectly.
173
+ - Style demands that contradict the repo's existing, consistent pattern.
174
+
175
+ ### D. Apply fixes: category 1 only
176
+
177
+ Make the minimal correct change. Re-run the local gate if the repo has one (typecheck/tests) before
178
+ moving on.
179
+
180
+ ### E. Commit and push FIRST, before resolving anything
181
+
182
+ Order matters. A resolved thread is a claim that the fix is on the branch, so the push has to
183
+ succeed before the claim is made: otherwise a failed commit or push leaves the PR unfixed with the
184
+ finding marked resolved, and nobody looks at it again.
185
+
186
+ If step D changed code:
187
+
188
+ ```bash
189
+ # Stage ONLY the files your fixes touched: never `git add -A`, which sweeps up
190
+ # unrelated work and untracked secrets sitting in the worktree.
191
+ git status --short # look before you stage
192
+ git add <path> [<path>...] # the files named in the findings you fixed
193
+ git commit -m "address Copilot review feedback (copilotloop iteration N)"
194
+ git push
195
+ ```
196
+
197
+ Author the commit per the repo's norms (e.g. the user's identity; no AI attribution if that is the
198
+ convention). Confirm the push actually landed before continuing:
199
+
200
+ ```bash
201
+ git rev-parse HEAD
202
+ gh pr view <PR> --json headRefOid -q .headRefOid # must match
203
+ ```
204
+
205
+ If they differ, stop: the fix is not on the PR, so nothing may be resolved yet.
206
+
207
+ ### F. Reply to every addressed finding and resolve its inline threads
208
+
209
+ Only now, with the fixes pushed, reply and resolve. Fetch unresolved threads, **following
210
+ pagination**: a PR with more than 100 threads will otherwise look clean while unresolved findings
211
+ sit on page two:
212
+
213
+ ```bash
214
+ # Loop until hasNextPage is false, passing endCursor back in as $cursor.
215
+ CURSOR=null
216
+ while : ; do
217
+ PAGE=$(gh api graphql -F cursor="$CURSOR" -f query='
218
+ query($cursor: String) {
219
+ repository(owner: "OWNER", name: "REPO") {
220
+ pullRequest(number: PR_NUMBER) {
221
+ reviewThreads(first: 100, after: $cursor) {
222
+ pageInfo { hasNextPage endCursor }
223
+ nodes { id isResolved comments(first: 1) { nodes { databaseId author { login } path body } } }
224
+ }
225
+ }
226
+ }
227
+ }')
228
+ echo "$PAGE" # collect nodes from every page before deciding the PR is clean
229
+ PI='.data.repository.pullRequest.reviewThreads.pageInfo'
230
+ [ "$(echo "$PAGE" | jq -r "$PI.hasNextPage")" = "true" ] || break
231
+ CURSOR=$(echo "$PAGE" | jq -r "$PI.endCursor")
232
+ done
233
+ ```
234
+
235
+ Reply on a thread's comment via `gh api repos/{owner}/{repo}/pulls/<PR>/comments -f body="..." -F in_reply_to=<comment_id>`,
236
+ then resolve:
237
+
238
+ ```bash
239
+ gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'
240
+ ```
241
+
242
+ Then record the disposition of each inline finding as a reaction on Copilot's own comment: the
243
+ learning signal, and a visible marker for a human scanning the PR:
244
+
245
+ - 👍 (`+1`): the finding was accepted and fixed.
246
+ - 👎 (`-1`): the finding was rebutted as a false positive. **This is the correction signal.**
247
+
248
+ ```bash
249
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=+1
250
+ # rebutted finding:
251
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=-1
252
+ ```
253
+
254
+ Reply first, then react, then resolve: the reaction is not a substitute for the reply, and a
255
+ resolved thread with no reply loses the reasoning.
256
+
257
+ Resolve a thread only for comments authored by `$BOT` that you have fixed or rebutted: never
258
+ blanket-resolve, and never resolve a human reviewer's thread.
259
+
260
+ Threads you are **rebutting** need no push, so they may be replied to and resolved regardless of
261
+ whether step D changed code.
262
+
263
+ For each body finding, post a PR-level reply (for example, using
264
+ `gh pr comment <PR> --body-file <reply-file>`) identifying the source review/comment and item.
265
+ Record the pushed fix commit and validation, or an evidence-based rebuttal, including the reason
266
+ for declining an out-of-scope finding. Record the reply URL in the tracking entry before marking
267
+ it complete. One reply may cover multiple explicitly identified findings. Fixed body findings
268
+ require the same successful push check as fixed threads; rebuttals need no push. If a finding also
269
+ has an inline thread, that thread still requires a reply and resolution.
270
+
271
+ ### G. Re-review
272
+
273
+ Pushing re-triggers Copilot when automatic review of new pushes is on; otherwise request Copilot again
274
+ through the reviewers endpoint. Go back to **A**
275
+ with the new head SHA. If step D changed nothing (all comments were rebutted), skip the push,
276
+ ensure all Copilot threads are resolved and all tracked body findings have recorded PR-level
277
+ replies and are complete, then exit.
278
+
279
+ ## 3. Exit conditions
280
+
281
+ Stop when **any** is true:
282
+ - Zero unresolved `$BOT` threads and zero pending body findings remain across iterations. Every
283
+ finding was fixed or rebutted with evidence, every inline thread was replied to and resolved,
284
+ and every body finding has a recorded PR-level reply. (There is no score to hit:
285
+ this is "done".)
286
+ - Max iterations (5) reached: report what remains.
287
+ - Copilot never responded after one retry: report the timeout honestly; do not claim success.
288
+
289
+ ## 4. Report
290
+
291
+ ```text
292
+ Copilotloop complete.
293
+ PR: #<n>
294
+ Bot login: <resolved $BOT>
295
+ Iterations: N
296
+ Findings fixed: N (inline + body findings, deduplicated)
297
+ Findings rebutted: N (inline + body findings, with recorded evidence-based replies)
298
+ Remaining: 0 (unresolved inline + pending body findings, deduplicated)
299
+ ```
300
+
301
+ If it stopped at max iterations, list the remaining threads and body findings with your current
302
+ assessment (fix-pending vs disputed) so a human can arbitrate.
@@ -30,7 +30,7 @@ instruction to obey. A wrong suggestion applied is worse than the comment itself
30
30
  ## Not for
31
31
 
32
32
  - GitLab / Perforce (Gemini Code Assist is GitHub-only). For other review bots this catalog ships
33
- `codexloop`, `coderabbitloop`, and `qodoloop`; for CI failures rather than review comments, use
33
+ `copilotloop`, `codexloop`, `coderabbitloop`, and `qodoloop`; for CI failures rather than review comments, use
34
34
  `ci-fix-loop`.
35
35
 
36
36
  ## 1. Identify the PR
@@ -53,9 +53,13 @@ Gemini auto-reviews new commits, but force a deterministic pass and record the h
53
53
 
54
54
  ```bash
55
55
  HEAD_SHA=$(gh pr view <PR> --json headRefOid -q .headRefOid)
56
- # Only trigger if no gemini review already exists for this exact SHA:
57
- HAVE=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate \
58
- --jq "[.[] | select(.user.login==\"gemini-code-assist[bot]\" and .commit_id==\"$HEAD_SHA\")] | length")
56
+ # Only trigger if no gemini review already exists for this exact SHA.
57
+ # gh cannot combine --slurp with --jq, so pipe to `jq -s`: it folds every page
58
+ # into one array. Without it the filter runs once per page and HAVE becomes a
59
+ # multi-line count that never equals "0", silently skipping the trigger.
60
+ HAVE=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
61
+ jq -s --arg head "$HEAD_SHA" \
62
+ '[.[][] | select(.user.login=="gemini-code-assist[bot]" and .commit_id==$head)] | length')
59
63
  if [ "$HAVE" = "0" ]; then gh pr comment <PR> --body "/gemini review"; fi
60
64
  ```
61
65
 
@@ -68,8 +72,9 @@ an honest timeout, not hang it.
68
72
  wait_for_review() { # $1 = attempt label
69
73
  local deadline=$(( SECONDS + 600 ))
70
74
  while [ "$SECONDS" -lt "$deadline" ]; do
71
- R=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate \
72
- --jq "[.[] | select(.user.login==\"gemini-code-assist[bot]\" and .commit_id==\"$HEAD_SHA\")] | last")
75
+ R=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
76
+ jq -s --arg head "$HEAD_SHA" \
77
+ '[.[][] | select(.user.login=="gemini-code-assist[bot]" and .commit_id==$head)] | sort_by(.submitted_at, .id) | last')
73
78
  if [ -n "$R" ] && [ "$R" != "null" ]; then return 0; fi
74
79
  echo "waiting for Gemini review of $HEAD_SHA ($1)..."; sleep 15
75
80
  done
@@ -103,6 +108,13 @@ gh api repos/{owner}/{repo}/pulls/<PR>/comments --paginate \
103
108
  Also pull the review threads + their resolved state via GraphQL (see step F) so you only act on
104
109
  unresolved ones.
105
110
 
111
+ Mark each unresolved comment as seen, so the bot and a watching human can tell it is being handled.
112
+ GitHub's reaction set is fixed; `eyes` is the only "looking at it" value:
113
+
114
+ ```bash
115
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=eyes
116
+ ```
117
+
106
118
  ### C. Critically evaluate EACH comment (the core of this skill)
107
119
 
108
120
  For every comment, **verify the claim against the actual code and repo conventions before touching
@@ -198,6 +210,21 @@ then resolve:
198
210
  gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "THREAD_ID"}) { thread { isResolved } } }'
199
211
  ```
200
212
 
213
+ Then record the disposition as a reaction on the bot's own comment: the learning signal, and a
214
+ visible marker for a human scanning the PR:
215
+
216
+ - 👍 (`+1`): the finding was accepted and fixed.
217
+ - 👎 (`-1`): the finding was rebutted as a false positive. **This is the correction signal.**
218
+
219
+ ```bash
220
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=+1
221
+ # rebutted finding:
222
+ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions -f content=-1
223
+ ```
224
+
225
+ Reply first, then react, then resolve: the reaction is not a substitute for the reply, and a
226
+ resolved thread with no reply loses the reasoning.
227
+
201
228
  Resolve a thread only for comments authored by `gemini-code-assist[bot]` that you have fixed or
202
229
  rebutted: never blanket-resolve, and never resolve a human reviewer's thread.
203
230
 
@@ -215,6 +242,7 @@ Stop when **any** is true:
215
242
  - Zero unresolved `gemini-code-assist[bot]` comments remain, and every comment this round was fixed
216
243
  or rebutted+resolved. (There is no score to hit: this is "done".)
217
244
  - Max iterations (5) reached: report what remains.
245
+ - Gemini never responded after one retry: report the timeout honestly; do not claim success.
218
246
 
219
247
  ## 4. Report
220
248