Add copilot-pr-autopilot skill (#1944)

* Add copilot-pr-autopilot skill

Skill that drives any GitHub pull request through repeated rounds of
Copilot Code Review until the agent has either resolved every thread
or explicitly escalated it to the human. Triggered via GraphQL (no
@copilot mention needed), triages every open thread with a fix /
decline / escalate rubric, replies and resolves each thread citing
the pushed SHA, then re-triggers until HEAD is reviewed with zero
threads awaiting the agent's reply.

Includes step scripts (01 request-review, 02 check-review-status,
03 list-open-threads, 08 reply-and-resolve, 10 cleanup-outdated),
shared library (_lib.ps1) with gh-CLI wrappers (Invoke-Gh,
Invoke-GhGraphQL, ConvertFrom-GhJson, Assert-GhReady), reply
templates, and reference docs for each step.

Repo-agnostic. Requires gh CLI on PATH and repo Triage/Write for
full autopilot; external PR authors get single-iteration mode with
manual re-trigger via the UI re-request button or a substantive
push.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address review: split per-step references + add recap-gate circuit breaker

- Fix #1: give steps 1/7/10 their own reference files
  (01-request-review.md, 07-commit-push.md, 10-cleanup.md); trim the
  inline bodies out of orchestration.md so it stays cross-cutting only.
- Fix #3: add a recurring round-cap & recap gate to 09-convergence.md —
  default STOP every 10th round, recap all prior rounds, detect drift
  (out-of-scope / over-engineering / wrong-direction / belongs-in-separate-PR)
  with CONTINUE / REVERT-AND-SHIP / HAND-OFF verdicts. Agent reasoning,
  no new script.
- Surface the gate from SKILL.md and orchestration.md; regenerate
  docs/README.skills.md. Markdown-only change; scripts unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(copilot-pr-autopilot): surface recap gate in decision pseudo-code; clarify Copilot+human convergence and round definition

- Inject the round-cap recap gate into the '## Decision: loop back or exit'
  pseudo-code else-branch so an agent following the code block (not just the
  prose) runs the STOP-every-10th-round check before looping.
- Broaden the 'never terminal' paragraph: non-convergence is driven by a
  Copilot finding OR a human review comment (this skill handles both); the
  loop ends only when there are no new comments from either source AND every
  open thread (Copilot or human) has an agent reply/escalation.
- Define a 'round' explicitly as one execution of step 1 (01-request-review),
  i.e. one Copilot-review trigger — the cap counts review rounds, not tool
  calls or fix edits.

Markdown-only; no script changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* copilot-pr-autopilot: make recap-gate round count deterministic

Add 09-review-round.ps1: counts Copilot Code Review submissions straight
from the PR's API history (full GraphQL pagination), so the recap-gate
trigger is a derived number, not a fallible agent mental tally. This
removes the exact failure mode the skill exists to survive — a count
drifting across a long run (the real 156-round case).

The script reports Round + RecapDue (Round % RecapInterval == 0) only;
it never stops the loop or picks the verdict. CONTINUE / REVERT-AND-SHIP
/ HAND-OFF stays agent reasoning. 09-convergence.md updated to reference
the deterministic count while preserving 'no script stops the loop' and
'non-convergence = Copilot finding OR human comment'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Regenerate docs/README.skills.md for copilot-pr-autopilot (add 09-review-round.ps1)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Gordon Lam
2026-07-01 09:09:58 +08:00
committed by GitHub
parent 79cda6bb19
commit d47a6c93b7
25 changed files with 3124 additions and 0 deletions
@@ -0,0 +1,21 @@
# Reply: declined with rationale
Use when triage decided `decline`. The reply must explain WHY
declining is the right call — not just that you considered it. Always
resolve the thread after replying; an open thread with no reply
signals avoidance.
```
Considered this, but declining: <concrete reason rooted in code or
design>. <Optional: the interleaving / scenario you ruled out, or
the alternative cost>. Happy to revisit if <specific trigger>.
```
Example (domain-neutral):
> Considered extending the lock into the initialization path, but
> declining: initialization runs to completion before any concurrent
> caller can reach this code, so the race window only opens after
> the init callback has returned. Sharing the lock across modules
> costs more in coupling than the actual exposure justifies. Happy
> to revisit if telemetry shows a real interleaving.
@@ -0,0 +1,8 @@
# Reply: documentation / test-plan drift
Use when Copilot points out the PR description, a comment, or the
test plan no longer matches the code.
```
Good catch — updated the <PR description | comment in `<file>` | test plan> to match the implemented behavior: <one-line summary of the now-correct statement>.
```
@@ -0,0 +1,25 @@
# Reply: accepted fix
Use after the loop has committed and pushed a fix for the finding. Cite
the pushed commit SHA from step 7.
```
<one sentence acknowledging the finding>.
<one or two sentences describing the fix>.
Fixed in <commit-sha>.
```
Example (language-neutral):
> The lock did not cover the install side of the path, so two
> parallel writers could read the same baseline and clobber each
> other. Promoted the per-instance lock to a process-wide
> function-local static so all read-modify-write paths share it.
> Fixed in abc1234.
When the fix is in a tested area, add a one-line test confirmation:
> Replaced the platform UUID dependency with a PID + monotonic-clock
> + atomic counter so the test target no longer pulls in the
> platform UUID library. All 42 tests in the affected suite still
> pass. Fixed in abc1234.
@@ -0,0 +1,9 @@
# Reply: partial fix with deferred follow-up
Use when the finding has both an immediate fix and a deeper
structural concern — address the immediate part now and acknowledge
the rest.
```
Fixed the immediate <X> in <commit-sha>. The broader <Y> would benefit from <larger change>, which I'd prefer to land separately because <reason>. Tracking as <issue-link-or-todo>.
```