dev-loops 0.1.3 → 0.2.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 (76) hide show
  1. package/.claude/.claude-plugin/plugin.json +13 -0
  2. package/.claude/agents/dev-loop.md +69 -0
  3. package/.claude/agents/developer.md +35 -0
  4. package/.claude/agents/docs.md +31 -0
  5. package/.claude/agents/fixer.md +51 -0
  6. package/.claude/agents/quality.md +26 -0
  7. package/.claude/agents/refiner.md +85 -0
  8. package/.claude/agents/review.md +61 -0
  9. package/.claude/hooks/_hook-io.mjs +38 -0
  10. package/.claude/hooks/hooks.json +35 -0
  11. package/.claude/hooks/post-tool-use-merge.mjs +23 -0
  12. package/.claude/hooks/pre-tool-use-bash-gate.mjs +73 -0
  13. package/.claude/hooks/pre-tool-use-write-guard.mjs +55 -0
  14. package/.claude/skills/copilot-pr-followup/SKILL.md +376 -0
  15. package/.claude/skills/dev-loop/SKILL.md +140 -0
  16. package/.claude/skills/dev-loop/templates/bootstrap-agents.md +26 -0
  17. package/.claude/skills/dev-loop/templates/bootstrap-implementation-state.md +31 -0
  18. package/.claude/skills/dev-loop/templates/bootstrap-implementation-workflow.md +17 -0
  19. package/.claude/skills/dev-loop/templates/dev-mode-retrospective.md +15 -0
  20. package/.claude/skills/dev-loop/templates/dev-mode-review.md +17 -0
  21. package/.claude/skills/dev-loop/templates/dev-mode-skill-changes.md +11 -0
  22. package/.claude/skills/dev-loop/templates/merged-phase-plan.md +19 -0
  23. package/.claude/skills/dev-loop/templates/phase-doc.md +27 -0
  24. package/.claude/skills/dev-loop/templates/phase-summary.md +13 -0
  25. package/.claude/skills/dev-loop/templates/phase-variant.md +15 -0
  26. package/.claude/skills/dev-loop/templates/retrospective.md +11 -0
  27. package/.claude/skills/dev-loop/templates/review.md +32 -0
  28. package/.claude/skills/dev-loop/templates/ui-vision-review.md +55 -0
  29. package/.claude/skills/docs/acceptance-criteria-verification.md +21 -0
  30. package/.claude/skills/docs/anti-patterns.md +21 -0
  31. package/.claude/skills/docs/artifact-authority-contract.md +119 -0
  32. package/.claude/skills/docs/confirmation-rules.md +28 -0
  33. package/.claude/skills/docs/copilot-ci-status-contract.md +52 -0
  34. package/.claude/skills/docs/copilot-loop-operations.md +233 -0
  35. package/.claude/skills/docs/debt-remediation-contract.md +107 -0
  36. package/.claude/skills/docs/entrypoint-strategies.md +115 -0
  37. package/.claude/skills/docs/epic-tree-refinement-procedure.md +234 -0
  38. package/.claude/skills/docs/issue-intake-procedure.md +235 -0
  39. package/.claude/skills/docs/main-agent-contract.md +85 -0
  40. package/.claude/skills/docs/merge-preconditions.md +29 -0
  41. package/.claude/skills/docs/pr-lifecycle-contract.md +209 -0
  42. package/.claude/skills/docs/public-dev-loop-contract.md +497 -0
  43. package/.claude/skills/docs/retrospective-checkpoint-contract.md +159 -0
  44. package/.claude/skills/docs/stop-conditions.md +29 -0
  45. package/.claude/skills/docs/structural-quality.md +42 -0
  46. package/.claude/skills/docs/tracker-first-loop-state.md +281 -0
  47. package/.claude/skills/docs/validation-policy.md +27 -0
  48. package/.claude/skills/docs/workflow-handoff-contract.md +135 -0
  49. package/.claude/skills/final-approval/SKILL.md +18 -0
  50. package/.claude/skills/local-implementation/SKILL.md +636 -0
  51. package/.claude-plugin/marketplace.json +19 -0
  52. package/CHANGELOG.md +70 -0
  53. package/README.md +28 -0
  54. package/agents/dev-loop.agent.md +4 -0
  55. package/cli/index.mjs +5 -5
  56. package/extension/checks.ts +18 -29
  57. package/extension/harness-types.ts +47 -0
  58. package/extension/index.ts +10 -8
  59. package/extension/pi-extension-adapter.ts +64 -0
  60. package/extension/post-merge-update.ts +69 -190
  61. package/package.json +17 -9
  62. package/scripts/README.md +6 -3
  63. package/scripts/claude/generate-claude-assets.mjs +175 -0
  64. package/scripts/claude/headless-dev-loop.mjs +89 -0
  65. package/scripts/claude/headless-info-smoke.mjs +90 -0
  66. package/scripts/github/_review-thread-mutations.mjs +3 -0
  67. package/scripts/github/reply-resolve-review-threads.mjs +3 -3
  68. package/scripts/github/upsert-checkpoint-verdict.mjs +4 -3
  69. package/scripts/loop/_pr-runner-coordination.mjs +2 -1
  70. package/scripts/loop/copilot-pr-handoff.mjs +3 -2
  71. package/scripts/loop/detect-stale-runner.mjs +5 -7
  72. package/scripts/loop/info.mjs +3 -2
  73. package/scripts/loop/inspect-run-viewer/server.mjs +2 -1
  74. package/scripts/loop/outer-loop.mjs +2 -2
  75. package/scripts/loop/pr-runner-coordination.mjs +4 -4
  76. package/skills/docs/main-agent-contract.md +19 -6
@@ -0,0 +1,376 @@
1
+ ---
2
+ name: "copilot-pr-followup"
3
+ description: "Internal routed strategy behind `dev-loop` for GitHub-first Copilot-owned PR follow-up: inspect the canonical PR state, request or re-request Copilot when appropriate, wait deterministically for new review activity, run narrow Pi fix/reply/resolve passes, verify gate evidence, and stop for explicit human approval before merge."
4
+ allowed-tools: Read Bash Edit Write Agent
5
+ user-invocable: false
6
+ ---
7
+ <!-- GENERATED from skills/copilot-pr-followup/SKILL.md by scripts/claude/generate-claude-assets.mjs — do not edit; edit the source and regenerate. -->
8
+
9
+
10
+ # Copilot PR Follow-up
11
+
12
+ This skill is the canonical internal `copilot_pr_followup` route behind the public `dev-loop` façade.
13
+
14
+ It is also the canonical internal owner of the shared post-PR mechanics used by this repo:
15
+ PR discovery and interpretation, async watch behavior, fix / reply-resolve / re-request flow,
16
+ gate sequencing, final approval, and merge-ready preconditions.
17
+
18
+ ## Route ownership
19
+
20
+ Use this skill whenever the public router lands on any PR-follow-up path that shares the same
21
+ post-PR mechanics:
22
+ - `copilot_pr_followup`
23
+ - `external_pr_followup`
24
+ - `reviewer_fixer`
25
+ - `wait_watch`
26
+
27
+ Route-specific companion docs:
28
+ - routed `issue_intake` work is implemented through this skill plus [Copilot Loop Operations](../docs/copilot-loop-operations.md) and [Issue Intake Procedure](../docs/issue-intake-procedure.md)
29
+ - routed `final_approval` work is implemented through this skill's **Human approval checkpoint** section; [Final Approval](../final-approval/SKILL.md) is now a thin redirect to that canonical section
30
+ - the deterministic state-machine/operator guide lives in [Copilot Loop Operations](../docs/copilot-loop-operations.md)
31
+
32
+ ## Operational cookbook
33
+
34
+ All commands use the resolved skill scripts directory (see [Skill asset path resolution](#skill-asset-path-resolution) below).
35
+
36
+ **1. Detect current loop state**
37
+ ```sh
38
+ node <resolved-skill-scripts>/loop/detect-copilot-loop-state.mjs --repo <owner/name> --pr <number>
39
+ ```
40
+ Emits JSON including `{ ok: true, state, allowedTransitions, nextAction, snapshot }`. Follow `nextAction`.
41
+
42
+ **2. One-step detect → request → emit watch params (preferred handoff contract)**
43
+ ```sh
44
+ node <resolved-skill-scripts>/loop/copilot-pr-handoff.mjs --repo <owner/name> --pr <number>
45
+ ```
46
+ Use this helper output as source of truth for the normal routing seam. Interpret:
47
+ - `requestWatchContract.routingState` for request-vs-watch posture
48
+ - `requestWatchContract.requestStatus` and top-level `action` / `nextAction`
49
+ - `watchArgs` only when `action: "watch"` and `requestWatchContract.watchEntryConfirmed=true`
50
+ - `requestWatchContract.stopState` for explicit blocked/stop handling
51
+
52
+ **3. Preferred async wait-boundary helper**
53
+ ```sh
54
+ node <resolved-skill-scripts>/loop/run-watch-cycle.mjs --repo <owner/name> --pr <number>
55
+ ```
56
+ Persistent async watch/fix loop, not handoff-only behavior: `watch → detect → if threads found, fix + reply + resolve → re-request → watch again → … → pre_approval_gate → merge`. **PERSISTENCE MODEL: Subagents do bounded implementation tasks and exit on external wait. The main session drives the loop and re-dispatches when continuation is feasible.** A single returned watch cycle is never completion by itself. If `cycleDisposition` is `pending` and `terminal` is `false`, the subagent exits on the wait boundary; the main session re-dispatches another watch boundary. Max watch timeout: **30 minutes** (from `policy-constants.mjs` COPILOT_REVIEW_WAIT_TIMEOUT_MS); expired budget + still `waiting_for_copilot_review` = hard stop. If the user explicitly asks for async handoff-only behavior, say that out loud and stop after the handoff boundary.
57
+
58
+ **4. Low-level helpers**
59
+ ```sh
60
+ node <resolved-skill-scripts>/github/request-copilot-review.mjs --help
61
+ node <resolved-skill-scripts>/github/probe-copilot-review.mjs --help
62
+ node <resolved-skill-scripts>/loop/detect-copilot-loop-state.mjs --help
63
+ ```
64
+
65
+ For detailed machine guarantees, judgment calls, pre-follow-up planning rules, PR description rules, and timeout defaults, use [Copilot Loop Operations](../docs/copilot-loop-operations.md).
66
+
67
+ ## Required startup reads
68
+
69
+ Read the canonical entrypoint briefing first: [Entrypoint Strategies](../docs/entrypoint-strategies.md#copilot-pr-follow-up). Then read only the contract docs needed for the current step:
70
+
71
+ - [Agent Instructions](../../AGENTS.md) (repo constitution)
72
+ - [Public Dev Loop Contract](../docs/public-dev-loop-contract.md) (always)
73
+ - [Retrospective Checkpoint Contract](../docs/retrospective-checkpoint-contract.md) (when async state/resume applies)
74
+ - Active GitHub issue/PR
75
+ - Task-relevant source, tests, config, and CI
76
+
77
+ Route-dependent: see [Copilot Loop Operations](../docs/copilot-loop-operations.md) and [Issue Intake Procedure](../docs/issue-intake-procedure.md) when relevant.
78
+ Verify all material claims against source, tests, configuration, and CI.
79
+
80
+ ## Skill asset path resolution
81
+
82
+ When this skill refers to helper paths such as `scripts/...` or `docs/...`, resolve them from the actual skill installation layout you are running, not from the active target repository checkout.
83
+
84
+ Use this rule:
85
+ - if the skill is installed as a normalized standalone copy, the required bundled contract docs live under the shared `../docs/` directory next to the installed skill directories; do not assume helper scripts are bundled unless that installed layout actually contains them
86
+ - if you are working in the `dev-loops` source repository, this skill file lives under `skills/copilot-pr-followup/`, so source-repo helper scripts live two levels up at `../../scripts/`, while required bundled contract docs live one level up at `../docs/`
87
+ - when in doubt, resolve helper paths relative to this [skill file](./SKILL.md) first, then verify the target file exists before running it
88
+
89
+ Required bundled runtime contract docs for installed copies of this skill:
90
+ - [Public Dev Loop Contract](../docs/public-dev-loop-contract.md)
91
+ - [Retrospective Checkpoint Contract](../docs/retrospective-checkpoint-contract.md)
92
+ - [Issue Intake Procedure](../docs/issue-intake-procedure.md)
93
+ - [Copilot Loop Operations](../docs/copilot-loop-operations.md)
94
+
95
+ Read those bundled `../docs/` files from the installed skill layout instead of assuming the source repository checkout is present. If any required bundled contract doc is missing from the installed skill layout, treat that as a packaging/installer bug.
96
+ Do not assume `scripts/...` is repo-local to the target codebase you are operating on.
97
+
98
+ ## Authority and safety rules
99
+
100
+ Source code, tests, CI, and config are authoritative. Generated wiki is navigation aid only. See [Confirmation Rules](../docs/confirmation-rules.md), [Stop Conditions](../docs/stop-conditions.md), and [Merge Preconditions](../docs/merge-preconditions.md) for authorization boundaries.
101
+
102
+ ## Structural quality
103
+
104
+ Apply [Structural Quality](../docs/structural-quality.md) standards from the `deep` review angle during implementation and follow-up fixes.
105
+
106
+ ## Step 5: PR discovery and interpretation
107
+
108
+ Treat the PR as the main working artifact once it exists.
109
+
110
+ Inspect: PR body/title (must satisfy [PR description contract](../docs/copilot-loop-operations.md)), closing reference (operator-controlled; subagents must NOT modify), author, review summaries, unresolved comments, latest commits, CI results.
111
+
112
+ At the issue-assignment seam, use `detect-initial-copilot-pr-state.mjs` and keep waiting when `waiting_for_initial_copilot_implementation`.
113
+
114
+ When confirming whether Copilot is requested as a reviewer, do not rely solely on `gh pr view --json reviewRequests`. Use `request-copilot-review.mjs` (see [Operational cookbook](#operational-cookbook)). Do **not** request Copilot by posting literal `/copilot` or `/copilot re-review` PR comments. After draft→ready or fix push, explicitly decide whether another pass is desired; if yes, ensure green/credibly green posture first.
115
+
116
+ Branch on the `request-copilot-review.mjs` machine-readable result:
117
+ - `requested`: if another Copilot pass is actually desired, immediately re-baseline with `detect-copilot-loop-state.mjs` and follow its `nextAction` (enter persistent wait only through `dev-loops loop watch-cycle` or `gh run watch`)
118
+ - `already-requested`: apply the same detector-first rebasing and wait branching as `requested`
119
+ - `suppressed_same_head_clean`: report clean-converged state and stop unless `--force-rerequest-review` bypass is intentionally authorized
120
+ - `unavailable`: report the limitation and stop
121
+ - non-zero / unexpected failure: stop and report error
122
+
123
+ Do not treat an attempted request as equivalent to a confirmed request.
124
+
125
+ ### Re-attachment guard (check for existing loop state first)
126
+
127
+ Before entering issue-intake normalization or asking "what should we do" for a PR that
128
+ already has an outer-loop checkpoint, check whether the checkpoint implies an auto-resume:
129
+
130
+ 1. Read the existing outer-loop checkpoint from
131
+ `tmp/copilot-loop/<owner>/<repo>/pr-<n>/outer-loop-state.json`.
132
+ Do **not** run `outer-loop.mjs` for this guard — it always rewrites the checkpoint
133
+ (including `timestamp` and potentially incrementing `waitCycles`).
134
+ Read the on-disk artifact without mutating it.
135
+ 2. If `outerAction` is `continue_wait`:
136
+ - The loop was waiting. The subagent exits; the main session re-dispatches a fresh
137
+ `dev-loop` async subagent that resumes from the checkpoint.
138
+ 3. If `outerAction` is `reenter_copilot_loop`:
139
+ - The copilot inner loop needs action. Run `copilot-pr-handoff.mjs` to determine the
140
+ exact next step and proceed.
141
+ 4. If `outerAction` is `reenter_reviewer_loop`:
142
+ - The reviewer inner loop needs action. Enter the reviewer-loop path.
143
+ 5. If `outerAction` is `stop`:
144
+ - Report the `reason` field and ask for direction.
145
+ 6. If no checkpoint exists or `outerAction` is `done`:
146
+ - Continue with normal step sequencing.
147
+
148
+ Do not skip this guard when transitioning between async subagent runs on the same PR.
149
+ The outer-loop checkpoint is the canonical re-attachment artifact for the subagent.
150
+
151
+ ## Step 6: Async watch behavior
152
+
153
+ Start every wait seam with a detector refresh: `detect-copilot-loop-state.mjs --repo <owner/name> --pr <number>`.
154
+
155
+ Allowed wait tools: `detect-copilot-loop-state.mjs` (one-shot), `dev-loops loop watch-cycle` (persistent), `copilot-pr-handoff.mjs --watch-status` (refresh after timeout/idle), `gh run watch <run-id> --repo <owner/name>` (CI with known run id). Otherwise exit and resume later from fresh detector call.
156
+
157
+ Practical rules: do not poll manually. `waiting_for_copilot_review` → `run-watch-cycle.mjs` or report-and-resume. `waiting_for_ci` with pending/none CI → `gh run watch <run-id> --repo <owner/name>` (known run id) or report-and-resume. Bounded CI exception: zero current-head suites + previous-head green + local `npm run verify` passed → rerun detector with `--local-validation-head-sha` for `crediblyGreen` promotion. `ciStatus=failure` → stop/fix, never wait.
158
+
159
+ Preferred approach:
160
+ - route decisions through `copilot-pr-handoff.mjs` output; enter watcher only on `action: "watch"` with `watchEntryConfirmed=true`; prefer `dev-loops loop watch-cycle` for deterministic handoff → watch
161
+ - `changed` → re-enter Step 7 fix/reply-resolve/validate immediately; do not stop after one watch cycle
162
+ - `timeout`/`idle` → re-run `copilot-pr-handoff.mjs --watch-status <status>` once to refresh state; if still `waiting_for_copilot_review` after 30-minute watch budget exhausted, hard stop with `watch timeout — PR #<number> needs manual attention`
163
+ - zero-timeout `idle` probes are for explicit one-shot status/reattach checks only; they are not the normal async wait mechanism
164
+ - after a successful fix / reply-resolve / re-request cycle, returning to `waiting_for_copilot_review` is a persistence boundary: resume the watcher instead of reporting completion
165
+ - if a child async run exits and the refreshed state remains non-terminal (for example `waiting_for_copilot_review`) before merge and without a hard stop, treat that as early exit and the main session re-dispatches the same-PR follow-up path when feasible (the subagent exits on external wait)
166
+ - dispatch fix findings to `fixer` subagent; do not run inline fix passes in-watcher
167
+ - do not report completion while unresolved Copilot feedback remains
168
+
169
+ ### Canonical async dispatch wording
170
+
171
+ Every async dev-loop dispatch task body must include this clause verbatim so fresh-context subagents inherit the gate requirement:
172
+
173
+ > Before reporting merge-ready or stopping at the human approval checkpoint, you must complete the pre_approval_gate procedure and verify that a visible clean checkpoint verdict comment exists on the PR for the current head SHA. Do not stop or report completion without this evidence.
174
+
175
+ Key rules:
176
+ - helper-owned sleep inside `dev-loops loop watch-cycle`, `dev-loops gate probe-copilot`, or `dev-loops loop watch-initial` is allowed
177
+ - agent-authored shell polling is forbidden: do not use `nohup`, detached shell jobs, `tmux`, `screen`, or ad hoc `for i in $(seq ...)`, `while true`, `until ...; do sleep ...; done`, or `sleep`-retry bash loops
178
+ - do not wrap repeated `gh pr view`, `gh pr checks`, `gh api`, or `detect-copilot-loop-state.mjs` calls inside shell polling loops
179
+ - do not bypass session-based async notifications with detached shell automation
180
+ - if Pi async subagents or the designated async follow-up skill are not appropriate or available, stop and report rather than improvising a shell watcher
181
+ - the async-start contract is enforced in code: `outer-loop.mjs` fails closed without a visible Pi-managed async run id when `workflow.asyncStartMode: required`
182
+
183
+ ### Async delegation guard rules (#524)
184
+
185
+ See [Async delegation guard rules](../dev-loop/SKILL.md#async-delegation-guard-rules-524) in the public `dev-loop` skill. Those rules are authoritative and apply to all async subagent dispatch in the PR-followup pipeline. The dev-loop skill is the single source of truth; this section exists only to ensure the rules are visible when this skill is loaded standalone.
186
+
187
+ ## Step 7: Pi review/fix follow-up loop
188
+
189
+ This step covers four responsibilities: the draft gate right before `gh pr ready`, the narrower post-review follow-up loop once unresolved feedback exists, the pre-approval gate before calling the PR merge-ready, and the final approval / merge boundary.
190
+
191
+ ### Follow-up loop when unresolved feedback exists
192
+
193
+ When unresolved feedback exists, use a narrow follow-up loop:
194
+
195
+ 1. inspect unresolved comments/threads and failing checks
196
+ 2. before the first local file write in each fixer pass on a Copilot-assigned PR, run `node <resolved-skill-scripts>/loop/pre-write-remote-freshness-guard.mjs --branch <headRefName>` as a required fail-closed guard
197
+ - source `<headRefName>` from authoritative PR state (`headRefName`), not from a local branch guess
198
+ - if the guard exits non-zero (`remote_ahead`), stop writing locally, reconcile to the refreshed remote head, then restart the fixer pass
199
+ 3. classify findings:
200
+ - must-fix: blocks gate; always fixed
201
+ - worth-fixing-now: blocks gate when `blockCleanOnFindingSeverities` includes it; fixed when blocking
202
+ - defer / non-blocking / disagree
203
+ 4. apply only the accepted narrow fixes
204
+ 5. run the smallest validation that honestly proves the fix
205
+ 6. if files changed, run `node <resolved-skill-scripts>/loop/pre-commit-branch-guard.mjs --expected-branch <headRefName>` immediately before every `git add && git commit` sequence as a required fail-closed guard
206
+ - source `<headRefName>` from authoritative PR state (`headRefName`), not from a local branch guess
207
+ - if the guard exits non-zero (`branch_mismatch`), stop and realign to the expected branch before staging or committing
208
+ 7. if files changed, push the resolving commit before any thread reply claims the fix is present
209
+ 8. when a comment or thread is actually addressed, reply on GitHub with a short resolution note that references the resolving commit SHA or commit URL when applicable
210
+ - for one thread, must use the deterministic helper `reply-resolve-review-thread.mjs` from the resolved skill scripts directory
211
+ - when the same bounded resolution note applies to multiple matching unresolved threads, use `reply-resolve-review-threads.mjs` instead of ad hoc inline `gh api` / `gh api graphql` mutations
212
+ - when using the single-thread helper, pair `--comment-id` and `--thread-id` from the same fresh PR thread snapshot rather than mixing ids across review rounds
213
+ - use a body file under `tmp/` rather than inline shell text for the single-thread reply body; for the batch helper, prefer stdin from that same `tmp/` body file rather than inline shell text
214
+ - when the intent is GitHub linkability, keep commit SHAs and issue/PR refs as plain text (for example 3ee82fc and owner/repo#70) and do not wrap them in backticks
215
+ - keep backticks for actual code/path/CLI literals only
216
+ - if either helper was newly added or recently changed, smoke-check it against one real thread before assuming the rest of the loop can rely on it
217
+ 9. before resolving an addressed review thread, run a post-fix verification checkpoint
218
+ - confirm the GitHub reply actually exists on the intended thread/comment, not only in local notes or helper stdout
219
+ - confirm the pushed current-head diff genuinely addresses the reviewer concern on the flagged lines or pattern; if the concern is only partially addressed, leave the thread open and explain what remains
220
+ - refresh the API-backed thread snapshot via `dev-loops gate capture-threads` and use that refreshed data — including the unresolved thread count — for follow-up decisions rather than prose assumptions
221
+ - if any verification check fails, do **not** resolve the thread; leave it open, add a short explanation when needed, and re-enter the fix/reply loop
222
+ 10. resolve the addressed review thread only after the reply is attached successfully, the verification checkpoint passes, and the concern is genuinely addressed
223
+ - do not stop at a local fix if GitHub-side reply/resolve is authorized
224
+ 11. after completing reply/resolve for a pass, verify zero unresolved threads remain via `dev-loops gate capture-threads` before proceeding
225
+ - if the refreshed snapshot reports unresolved threads, re-enter the reply/resolve loop for the missed threads
226
+ 12. only after GitHub-side reply/resolve work is done for the addressed threads and the refreshed thread snapshot proves zero unresolved threads remain, decide whether another Copilot pass is desired
227
+ - resolve the review-round cap from config via `resolveRefinementConfig(config, "maxCopilotRounds")` from `@dev-loops/core/config`; default config ships `maxCopilotRounds: 5`
228
+ - use the completed Copilot review-round count from `detect-copilot-loop-state.mjs` / `copilot-pr-handoff.mjs` as the current PR's review-round count
229
+ - if completed review rounds have reached the maximum (default: 5), do **not** re-request Copilot review
230
+ - when the round limit is reached **and** the refreshed thread snapshot proves zero unresolved threads **and** current-head CI is green or credibly green, treat that clean state as eligible for `pre_approval_gate` fallback instead of deadlocking on another Copilot rerequest
231
+ - when using that fallback, add a short round-exhaustion note to the visible `pre_approval_gate` gate evidence so the PR records why no further Copilot rerequest occurred
232
+ - if the round cap is reached before the PR is thread-clean or before CI is green/credibly green, reply-resolve any remaining intentionally deferred threads with a short `deferred to follow-up` note, then stop and report that the Copilot round limit was reached
233
+ - **Signal-gated re-request suppression:** the `detect-copilot-loop-state.mjs` state machine classifies review-thread comments by signal level (High/Mid/Low). High-signal (bugs, security, contract violations) always re-requests; Low-signal (cosmetic nits) never re-requests. When low-signal detection is enabled and thresholds are met, the machine returns a low-signal-converged terminal state routing to `pre_approval_gate` without further re-requests. See [Copilot Loop Operations](../docs/copilot-loop-operations.md) for full signal-level semantics.
234
+ - if that local validation is still known red, continue remediation instead of re-requesting Copilot
235
+ - after a fix push advances the PR head SHA, re-run `detect-copilot-loop-state.mjs` for the new head and apply the [Copilot CI Status Contract](../docs/copilot-ci-status-contract.md). Previous-head CI is stale; only current-head results unblock CI-dependent steps. if GitHub CI/checks for the updated head are known red for a fixable issue, continue remediation instead of re-requesting Copilot. only once the updated head is green or credibly green, explicitly re-request Copilot review for the new head. Always use `request-copilot-review.mjs` — never `gh api POST repos/.../requested_reviewers` directly.
236
+ - only enter a wait/watch loop if the request result is confirmed as `requested` or `already-requested`
237
+ - for `requested` / `already-requested`, immediately re-baseline with `detect-copilot-loop-state.mjs`; if the returned state is `waiting_for_copilot_review`, use `dev-loops loop watch-cycle` or stop/resume later, and if the returned state is `waiting_for_ci`, use `gh run watch` for a known run id or stop/resume later after that single detector refresh
238
+ - if the request result is `unavailable`, report that limitation and stop unless the user explicitly wants passive waiting anyway
239
+ - if the request command fails unexpectedly, stop and report the error rather than sleeping and hoping for a new review
240
+ 13. after a confirmed re-requested Copilot pass, refresh PR thread state again before reporting completion; if fresh Copilot threads exist, return to this follow-up loop rather than stopping at `review requested`
241
+ 14. after a confirmed re-request returns the PR to `waiting_for_copilot_review`, jump back to Step 6 and keep the same session alive; do not exit on `review requested` alone
242
+ 15. if scope has broadened, stop and ask before continuing
243
+
244
+ Do not treat `fix applied locally` as the end of the loop when the workflow also requires GitHub-side reviewer follow-up. If comment/reply authorization is withheld, report explicitly that the code may be fixed while the PR conversation state remains unresolved.
245
+
246
+ ### Mandatory gate-comment command contract
247
+
248
+ For every `draft_gate` or `pre_approval_gate` comment, you MUST run:
249
+
250
+ ```sh
251
+ node <resolved-skill-scripts>/github/upsert-checkpoint-verdict.mjs \
252
+ --repo <owner/name> \
253
+ --pr <number> \
254
+ --gate <draft_gate|pre_approval_gate> \
255
+ --head-sha <current_head_sha> \
256
+ --verdict <clean|findings_present|blocked> \
257
+ --findings-summary "<summary>" \
258
+ --next-action "<next action>" --findings-severity-counts '{"must-fix":0,"worth-fixing-now":0,"defer":0}'
259
+ ```
260
+
261
+ Do NOT use `gh pr comment`, `gh api`, or `gh pr review` for gate comments.
262
+
263
+ `--force --force-reason` on `upsert-checkpoint-verdict.mjs` is a narrow operator-authorized CI override for the helper itself, not the default gate path. Use it only when the helper refuses gate entry solely because the current head is `blocked_needs_user_decision` with `ciStatus="failure"`, and only after the user explicitly authorizes ignoring that current-head CI failure for this one gate-comment upsert. It does **not** bypass stale-head checks, unresolved-thread / unsettled-review refusal, non-draft `draft_gate` refusal, merge conflicts, or other legality checks.
264
+
265
+ ### Draft gate contract (before marking PR ready for review)
266
+
267
+ The canonical checkpoint verdict comment contract is [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md). This section summarizes the procedural integration only.
268
+
269
+ - **Gate name:** Draft gate
270
+ - **Trigger / boundary:** right before running `gh pr ready` (draft → ready for review)
271
+ - **Skip rule:** before entering the draft gate, run `detect-pr-gate-coordination-state.mjs` and check `draftGateAlreadySatisfied`. If `true`, skip the draft gate entirely — the draft→ready transition was already recorded. `draft_gate` is a one-time gate; do not re-post on new heads once clean draft-gate evidence exists for the transition record. (While the PR is still draft, advancing the head SHA does require a new draft-gate comment for the new head.) This skip rule applies only to the draft boundary.
272
+ - **Execution directive:** run the checkpoint review chain defined in [Gate Review Sub-Loop Contract](../../docs/gate-review-sub-loop-contract.md) with the draft gate inspection angles resolved from config.
273
+ - **Review angles:** resolved at runtime from config via `resolveGateAngles(config, "draft")` from `@dev-loops/core/config`. Default config enables all configured draft gate angle families; consumer repos may opt out individual angles via `excludeAngles`. Do **not** apply angles from the other gate; each gate owns its own angle list from config.
274
+ - **CI prerequisite:** resolve the draft gate config first (`resolveGateConfig(config, "draft")`). When `requireCi=true` (default), wait for green current-head CI before entering `draft_gate`. When `requireCi=false`, the draft gate may proceed without green CI. This draft-only override does **not** relax `pre_approval_gate`; final approval and merge readiness still require green current-head CI.
275
+ - **Pass criteria:** all configured draft gate angles pass; all findings at severities in `blockCleanOnFindingSeverities` are addressed; validation passes; no unrelated files are included.
276
+ - **Next step after passing:** mark the PR ready for review.
277
+ - **Non-substitution rule:** a clean `draft_gate` comment only authorizes the draft → ready-for-review transition for that head SHA. It does **not** satisfy `pre_approval_gate`, final-approval readiness, or merge-ready requirements.
278
+ - **Required PR comment:** post a visible checkpoint verdict comment using the mandatory [Gate comment command](#mandatory-gate-comment-command-contract). Keep validation reporting concise: include command names with pass/fail status. Do **not** paste raw passing test output into the visible gate comment. If you include a failing validation excerpt, keep it focused and truncate it to a deterministic retained-prefix length before posting the comment. See [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md). Do not run `gh pr ready` unless a visible `clean` `draft_gate` checkpoint verdict comment exists for the current head SHA. A checkpoint verdict comment for an older head SHA does not satisfy this requirement for the current head. If findings exist, the PR stays draft and needs fixes before retry. If fixes advance the head SHA while still draft, post a new checkpoint verdict comment for the new head. If the checkpoint verdict comment cannot be posted, fail closed and do not run `gh pr ready`.
279
+
280
+ ### Pre-approval gate contract
281
+
282
+ This is the default pre-approval gate for this workflow boundary. The canonical checkpoint verdict comment contract is [Gate Review Comment Contract](../../docs/gate-review-comment-contract.md). This section summarizes the procedural integration only.
283
+
284
+ - **Gate name:** Pre-approval gate
285
+ - **Trigger / boundary:** right before calling a PR/branch review-complete, approval-ready, merge-ready, or ready for final handoff
286
+ - **Execution directive:** run the checkpoint review chain defined in [Gate Review Sub-Loop Contract](../../docs/gate-review-sub-loop-contract.md) with the pre-approval gate inspection angles resolved from config. Retry rule: in subsequent cycles, only re-run reviewers that produced `findings_present` in the previous pass.
287
+ - **Review angles:** resolved at runtime from config via `resolveGateAngles(config, "preApproval")` from `@dev-loops/core/config`. Default config enables all configured pre-approval gate angle families; consumer repos may opt out individual angles via `excludeAngles`.
288
+ - **Persona mapping:** each angle resolves to a reviewer persona via `resolveReviewerRole(config, angle)` from `@dev-loops/core/config`. Include this prompt in each reviewer's briefing so the reviewer knows exactly what to look for.
289
+ - **Pass criteria:** the sub-loop completes with verdict `clean`; all configured angles pass; if parallel execution is impractical, still run all configured lenses and explicitly record the limitation.
290
+ - **Acceptance criteria verification:** follow the canonical procedure in [Acceptance Criteria Verification](../docs/acceptance-criteria-verification.md) before posting the `pre_approval_gate` comment.
291
+ - **Next step after passing:** continue the Step 7 flow and then proceed to the human approval checkpoint below.
292
+ - **Non-substitution rule:** a clean `pre_approval_gate` comment is separate from `draft_gate` evidence. It governs final-approval readiness for that head SHA; it does **not** replace the required `draft_gate` evidence for leaving draft.
293
+ - **Required PR comment:** post a visible checkpoint verdict comment using the mandatory [Gate comment command](#mandatory-gate-comment-command-contract). Keep validation reporting concise: include command names with pass/fail status. Do **not** paste raw passing test output into the visible gate comment. If you include a failing validation excerpt, keep it focused and truncate it to a deterministic retained-prefix length before posting the comment. Do not declare final-approval readiness unless a visible `clean` `pre_approval_gate` checkpoint verdict comment exists for the current head SHA. Final-approval readiness must not rely only on local or hidden artifacts; the visible PR comment is the required auditable evidence. If the checkpoint verdict comment cannot be posted, fail closed and do not declare final-approval readiness. A checkpoint verdict comment for an older head SHA does not satisfy this requirement for the current head. If findings exist, follow-up fixes are required before final approval. The `pre_approval_gate` procedure must be entered and completed (visible comment posted) before any merge-ready or approval-ready declaration. Skipping the gate is not recoverable by asserting convergence. If fixes advance the head SHA, post a new checkpoint verdict comment for the new head.
294
+
295
+ ### Conflict-resolution gate
296
+
297
+ Before any merge-ready or final-approval claim, run `detect-pr-gate-coordination-state.mjs` for the current PR. If it reports `gateBoundary=conflict_resolution` or `mergeStateStatus` is conflicted, stop the normal gate path immediately and use this recovery flow:
298
+
299
+ 1. fetch fresh `origin/main`, confirm the current PR head SHA, and summarize the conflict scope from `mergeStateStatus` plus any reported `conflictFiles`
300
+ 2. ask for explicit authorization before any rebase or other branch-state-changing reconciliation command
301
+ 3. after authorization, reconcile locally on the PR branch; default to rebase onto latest `origin/main`, unless the operator explicitly chooses another conflict-resolution command
302
+ 4. auto-resolve simple conflicts when the correct fix is mechanical and clearly in scope; report complex conflicts explicitly and fix them manually only for in-scope files
303
+ 5. rerun the smallest honest local validation for the touched conflict slice
304
+ 6. rerun `detect-pr-gate-coordination-state.mjs` for the new head
305
+ 7. because the head changed, rerun `pre_approval_gate` for the new head before any approval-ready or merge-ready claim
306
+ 8. wait for current-head CI again before retrying merge evaluation
307
+ 9. if the chosen reconciliation rewrote branch history (for example rebase), ask for explicit authorization before `git push --force-with-lease`, then continue the loop on the updated head
308
+
309
+ `mergeStateStatus: CLEAN` alone is not enough to resume approval or merge claims. The existing merge-ready preconditions still apply: zero unresolved review threads, a clean current-head `pre_approval_gate`, and green current-head CI.
310
+
311
+ ### Merge-ready preconditions
312
+
313
+ See [Merge Preconditions](../docs/merge-preconditions.md). Verify: zero unresolved threads (via `dev-loops gate capture-threads`), visible clean `draft_gate` + current-head `pre_approval_gate`, green CI. Fresh-context review follows [Gate Review Sub-Loop Contract](../../docs/gate-review-sub-loop-contract.md).
314
+
315
+ ### Human approval checkpoint
316
+
317
+ After merge-ready preconditions pass, verify [Merge Preconditions](../docs/merge-preconditions.md) authoritatively before reporting merge-ready. Stop at the human approval checkpoint by default. Cross-check via `dev-loops gate capture-threads` (not prose assertion).
318
+ Follow [Merge Preconditions](../docs/merge-preconditions.md): stop at `waiting_for_merge_authorization` after approval unless merge explicitly authorized. Run pre-merge gate evidence check before any `gh pr merge`.
319
+
320
+ ### Mechanical pre-merge gate evidence check
321
+
322
+ Immediately before any `gh pr merge`, run:
323
+
324
+ ```sh
325
+ node <resolved-skill-scripts>/github/detect-checkpoint-evidence.mjs \
326
+ --repo <owner/name> \
327
+ --pr <number>
328
+ ```
329
+
330
+ This helper is always-on: it uses `gh api` to fetch visible PR issue comments and fails closed unless both required gate comments exist: a clean `draft_gate` comment for the one-time draft boundary and a clean current-head `pre_approval_gate` comment. Do not run `gh pr merge` if this command exits non-zero. There is no opt-out flag. Resolved threads, green CI, clean Copilot rereview, or local notes do not substitute for this successful helper output. If a final approval or merge boundary sees `gh pr merge` without a same-boundary successful check, treat that as a workflow violation and stop.
331
+
332
+ ### Mandatory post-merge retrospective checkpoint write
333
+
334
+ After a merge succeeds (or an explicit retrospective skip is authorized), write the durable retrospective checkpoint before exiting the subagent session:
335
+
336
+ ```sh
337
+ node <resolved-skill-scripts>/loop/checkpoint-contract.mjs --state complete --notes "<one-line retrospective summary>"
338
+ ```
339
+
340
+ For an explicit skip:
341
+
342
+ ```sh
343
+ node <resolved-skill-scripts>/loop/checkpoint-contract.mjs --state skipped --reason "<why retrospective is skipped>"
344
+ ```
345
+
346
+ Do not report completion or advance to the next PR queue item until `.pi/dev-loop-retrospective-checkpoint.json` is updated to `complete` or `skipped`.
347
+
348
+ ## Validation policy
349
+
350
+ Follow [Validation Policy](../docs/validation-policy.md). Default: `npm run verify` before PR creation, gate entry, and merge. For repo-local examples: `npm run test:dev-loop` for skill scripts, contract tests for templates, `git diff --check` for docs. When CI runs exist, use `gh run watch` or `detect-copilot-loop-state.mjs` instead of `sleep`-based polling. Distinguish: locally validated, full PR-equivalent checks, awaiting CI.
351
+
352
+ ## Confirmation checkpoints
353
+
354
+ See [Confirmation Rules](../docs/confirmation-rules.md). Stop and ask before GitHub mutations (edits, assignments, labels, comments, reviews, thread resolution, commits, pushes, merges, workflows) unless explicitly authorized.
355
+
356
+ ## Stop conditions
357
+
358
+ Follow [Stop Conditions](../docs/stop-conditions.md). Genuine stops: `blocked` state, `done`, `approval_ready` without merge auth, ambiguous state, scope drift. Non-stops: `waiting` watcher states, quiet observations.
359
+
360
+ ## Anti-patterns
361
+
362
+ See [Anti-patterns](../docs/anti-patterns.md). Key repo-specific additions:
363
+ - Use `reply-resolve-review-thread.mjs` / `reply-resolve-review-threads.mjs` helpers instead of ad hoc `gh api`/`gh api graphql` thread-mutation commands. Do NOT use `gh pr comment`, `gh api`, or `gh pr review` for gate comments (use `upsert-checkpoint-verdict.mjs`).
364
+ - Do not declare merge-ready without visible `pre_approval_gate` comment on current head SHA. Do not declare merge-ready based solely on `mergeable_state: clean` + CI green without gate evidence. CI green + resolved threads alone is insufficient.
365
+ - Do not blind-run `gh pr merge`/`gh pr update-branch`/unapproved rebase when conflicted. Do not dispatch async dev-loop tasks that omit the pre-approval gate requirement.
366
+ - Do not assume generated wiki is authoritative over code or CI.
367
+
368
+ ## Output expectations
369
+
370
+ When using this skill, keep user-facing summaries concise and operational.
371
+
372
+ A good status update should say:
373
+ - what issue or PR you inspected
374
+ - current state
375
+ - what the next recommended action is
376
+ - whether authorization is needed before taking it
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: "dev-loop"
3
+ description: "Single public dev-loop entrypoint. Resolve canonical current state first, then load only route-specific internal skills."
4
+ allowed-tools: Read Bash Edit Write Agent
5
+ user-invocable: true
6
+ ---
7
+ <!-- GENERATED from skills/dev-loop/SKILL.md by scripts/claude/generate-claude-assets.mjs — do not edit; edit the source and regenerate. -->
8
+
9
+
10
+ **No-implicit-start rule:** Never start implementation without explicit instruction.
11
+
12
+ **Work-origin rule:** All work must originate from a tracked artifact: a GitHub issue (tracker-first) or a persisted markdown plan file (local-planning). See [Artifact Authority Contract](../docs/artifact-authority-contract.md) for canonical mode definitions and settings. No work may originate from a PR or direct local change unless explicitly requested.
13
+
14
+ # Unified Dev Loop
15
+
16
+ This is the public `dev-loop` façade — a summary of the authoritative routing contract. The authoritative contract is [Public Dev Loop Contract](../docs/public-dev-loop-contract.md). Runtime evaluator: `@dev-loops/core/loop/public-dev-loop-routing`. For status/progress/readiness/merge-state/next-step queries, resolve authoritative artifact identity first; for issue targets, identity resolution is handled by the startup resolver. Fail closed to reconcile/unknown when unresolved. When an open linked PR exists, treat it as the single canonical artifact for the issue and reuse it instead of opening another PR.
17
+
18
+ ## Installed skill layout
19
+
20
+ Required installed runtime contract docs are shared bundled copies under `../docs/` from this skill directory. Read those bundled `../docs/` files from the installed skill layout — do not assume a source checkout. If a required bundled contract doc is missing, treat it as a packaging/installer bug.
21
+
22
+ ## Startup procedure
23
+
24
+ ### Main agent (read-only)
25
+
26
+ The main agent must **always** dispatch the `dev-loop` async subagent for any dev-loop work.
27
+ Do not run `dev-loops loop startup` or any startup resolver in the main agent.
28
+ The resolver requires `PI_SUBAGENT_RUN_ID` for async-required routes (the default `required` mode); the startup resolver can also run without it for non-async routes. Regardless, only the `dev-loop` async subagent runs it — never the main agent.
29
+
30
+ ### Dev-loop subagent (post-dispatch)
31
+
32
+ The subagent resolves authoritative state via the startup resolver (`npx dev-loops loop startup --issue <n>` for issues, `npx dev-loops loop startup --pr <n>` for PRs), then immediately builds the handoff envelope via `npx dev-loops loop build-envelope --input <resolver-output.json>`. The envelope determines `requiredReads`, `nextAction`, `stopRules`, and `acceptance` — load only those files, execute only that bounded task. It is the first handoff artifact consumed before loading any route pack. See [Workflow Handoff Contract](../docs/workflow-handoff-contract.md) for the derivation contract.
33
+
34
+ **Retrospective checkpoint gate:** the resolver reads `.pi/dev-loop-retrospective-checkpoint.json` and injects the state. When the checkpoint is `missing` and the repo config `workflow.requireRetrospective` (set via `.devloops` at repo root) is `true`, the resolver returns `needs_reconcile`. Complete or explicitly skip the retrospective before starting.
35
+
36
+ **Pre-delegation gate (mandatory — subagent only):** Before delegating async work targeting an existing PR, the dev-loop subagent must run `node scripts/loop/copilot-pr-handoff.mjs --repo <owner/name> --pr <number>` and abort if `action: "stop"`. When `terminal: true`, proceed inline. When `terminal: false`, resolve the blocking condition first.
37
+
38
+ **Worktree cwd (mandatory — subagent only):** Always use a worktree checkout for git operations, file reads/writes, and validation commands — never use the `main` checkout.
39
+
40
+ **Worktree fetch (mandatory — subagent only):** Always run `git fetch origin` before creating or reusing any worktree.
41
+
42
+ ### Resume from existing loop state
43
+
44
+ When the startup resolver returns a fresh-start routing but an existing outer-loop checkpoint
45
+ (`tmp/copilot-loop/<owner>/<repo>/pr-<n>/outer-loop-state.json`) is present on disk, the
46
+ subagent must check the checkpoint before treating the start as a fresh intake or follow-up:
47
+
48
+ 1. Read the outer-loop checkpoint (authored by `outer-loop.mjs`).
49
+ 2. If `outerAction` is `continue_wait`, `reenter_copilot_loop`, or `reenter_reviewer_loop`:
50
+ - Skip issue-intake normalization or fresh-intake routing.
51
+ - Route directly to the existing PR's follow-up path (the PR number is in the
52
+ checkpoint's `pr` field). For `reenter_copilot_loop`, enter the copilot-pr-followup
53
+ path. For `reenter_reviewer_loop`, enter the reviewer-loop path.
54
+ - Use the checkpoint's `copilotState` and `reviewerState` as last-known context for
55
+ re-attachment, then re-baseline with fresh detectors (`copilot-pr-handoff.mjs`
56
+ or `detect-copilot-loop-state.mjs`) before acting on the state.
57
+ 3. If `outerAction` is `stop`:
58
+ - Report the `reason` field and the authoritative state from the checkpoint.
59
+ - `stop` means the loop is blocked or needs a human decision; ask for direction
60
+ rather than guessing or starting fresh.
61
+ 4. If no checkpoint exists, or `outerAction` is `done`:
62
+ - Treat as normal fresh startup (the existing startup resolver path).
63
+
64
+ This eliminates the manual "report-and-resume" or "exit and resume later" pattern when the
65
+ deterministic state already knows the next action.
66
+
67
+ The outer-loop checkpoint is the canonical re-attachment artifact. Do not rely on chat
68
+ context, local notes, or prose recollection of "where we left off."
69
+
70
+ ## Route table
71
+
72
+ Load only the route-specific internal skill required by `selectedStrategy`:
73
+
74
+ | Strategy | Route pack to load |
75
+ | --- | --- |
76
+ | `local_implementation` | [Local Implementation Skill](../local-implementation/SKILL.md) |
77
+ | `issue_intake` | [Copilot PR Follow-up Skill](../copilot-pr-followup/SKILL.md) + [Copilot Loop Operations](../docs/copilot-loop-operations.md) + [Issue Intake Procedure](../docs/issue-intake-procedure.md) |
78
+ | `copilot_pr_followup` | [Copilot PR Follow-up Skill](../copilot-pr-followup/SKILL.md) + [Copilot Loop Operations](../docs/copilot-loop-operations.md) |
79
+ | `external_pr_followup` | same as `copilot_pr_followup` |
80
+ | `reviewer_fixer` | same as `copilot_pr_followup` |
81
+ | `wait_watch` | same as `copilot_pr_followup` |
82
+ | `final_approval` | same as `copilot_pr_followup` + [Final Approval Skill](../final-approval/SKILL.md) |
83
+
84
+ Do not preload route packs before the resolver selects the strategy.
85
+
86
+ ## Async dispatch
87
+
88
+ **Async dispatch rule (enforced):** the resolver enforces fail-closed for GitHub-first strategies when `canonicalStateSummary.requiresAsyncDispatch` is `true` (default `required` mode). Inline invocation without `PI_SUBAGENT_RUN_ID` is rejected only for those routes. See [Startup procedure](#startup-procedure).
89
+
90
+
91
+ ## Fallback gate-comment poster
92
+
93
+ When the `@dev-loops/core` package is not installed in the consumer repo, the full `scripts/github/upsert-checkpoint-verdict.mjs` helper (referenced from the copilot-pr-followup skill procedure) is unavailable. To keep the PR audit trail intact in that mode, the dev-loop skill ships a small gh-only fallback poster at `scripts/post-gate-verdict-fallback.mjs` (relative to the dev-loop skill root) that renders the same visible comment format and fails closed if posting cannot succeed.
94
+
95
+ Use the fallback poster only when the full helper cannot be reached:
96
+
97
+ 1. Detect the missing helper: try `node scripts/github/upsert-checkpoint-verdict.mjs --help` from the consumer repo. If the script is absent or imports fail, switch to the fallback path.
98
+ 2. Invoke the fallback from the installed dev-loop skill directory: `node <resolved-skill-scripts>/post-gate-verdict-fallback.mjs --repo <owner/name> --pr <number> --head-sha <sha> --verdict <clean|findings_present|blocked> (--findings-summary <text> | --findings-file <path>) --next-action <text> [--gate <draft_gate|pre_approval_gate>]`.
99
+ 3. Treat every successful fallback-posted gate comment as a one-shot create with no idempotent same-head update: if the agent reruns the gate on the same head, a duplicate comment will be created. Detect duplicates manually and update manually if needed.
100
+ 4. Treat every fallback-posted gate comment as a degraded audit-trail artifact: the visible body uses the same parser-stable shape as the full helper (gate name, head SHA, verdict, blocking severities when applicable, findings summary, next action), but the helper skips stale-head detection, gate-coordination validation, blocking-severity count enforcement, and the internal-only PR short-circuit.
101
+ 5. If the fallback helper exits non-zero, stop the gate and report the posting failure: do not mark the PR ready for review and do not proceed to merge readiness until the comment is posted.
102
+
103
+ When `@dev-loops/core` is available again, switch back to the full helper. The fallback poster is a degraded path, not a permanent replacement.
104
+
105
+ ## Read-only info shortcut
106
+
107
+ The main agent may handle info/handoff requests directly via `npx dev-loops loop info` without dispatching the async `dev-loop` subagent:
108
+ - `npx dev-loops loop info --issue <n>` — human-readable issue state summary (strategy, route, linked PR, next action)
109
+ - `npx dev-loops loop info --pr <n>` — human-readable PR state summary (branch, CI, threads, rounds, action)
110
+ - `npx dev-loops loop info --issue <n> --json` — machine-readable JSON output
111
+
112
+ ## Guard rules (subagent reference)
113
+
114
+ **Handoff envelope precedence:** The subagent builds the envelope immediately after authoritative-state resolution and treats it as the first handoff artifact. Read it first, load only `requiredReads`, execute `nextAction`. See [Dev-loop subagent](#dev-loop-subagent-post-dispatch). Derivation contract: [Workflow Handoff Contract](../docs/workflow-handoff-contract.md).
115
+
116
+ **Handoff contract rule:** When no envelope is present, use the `workflow-handoff-contract.md` contract. Never delegate with abbreviated task summaries. Include deterministic routing inputs, explicit `cwd`, bounded task scope, exit conditions.
117
+
118
+ **Inline-first rule:** Prefer inline commands over nested async delegation when managing a single PR. Use nested delegation only for parallel fan-out or when the parent needs to continue other work.
119
+
120
+ **Bounded async task contract:** Break work into discrete tasks with clear inputs, explicit outputs, bounded scope. No shell polling — use `run-watch-cycle.mjs` or `gh run watch`.
121
+
122
+ **Round-cap budget check (enforced):** After every watch cycle, fix pass, or reply-resolve, check whether completed Copilot review rounds have reached the maximum (default: 5). Stop re-requesting Copilot review when the limit is reached — never re-request after the cap.
123
+
124
+ ## Shorthand issue-based auto trigger contract
125
+
126
+ - `auto dev loop on issue <n>` → public `dev-loop` intent `auto_continue_current` after authoritative current-state resolution
127
+ - Continue through GitHub/Copilot loop until stop condition or human approval checkpoint
128
+ - Stop at the human approval checkpoint by default unless merge explicitly authorized
129
+
130
+ ## No gate exemptions
131
+
132
+ All PRs must pass the full gate pipeline before merge. No scope is exempt: docs-only, tooling, meta, configuration, internal-process — all require `draft_gate`, current-head `pre_approval_gate` evidence, and Copilot review (except internal-only PRs detected by path pattern, which skip the Copilot convergence requirement).
133
+
134
+ ## Authority boundary
135
+
136
+ - Source code, tests, config, CI, and shared contract docs are authoritative.
137
+ - Main-agent delegation contract: [Main Agent Contract](../docs/main-agent-contract.md) — absolute read-only boundary; all mutations flow through `dev-loop` async subagent.
138
+ - Before any state-changing action, get explicit confirmation unless already authorized.
139
+ - A question requires an answer, not an action.
140
+ - Stop and ask rather than guessing when facts don't agree.
@@ -0,0 +1,26 @@
1
+ # AGENTS.md
2
+
3
+ ## Project contract
4
+
5
+ This repository uses the `dev-loop` skill as the primary implementation workflow.
6
+
7
+ The skill may be provided repo-locally or globally; this contract does not assume a local skill path.
8
+
9
+ ## Working agreement
10
+
11
+ - Work test-first for all non-trivial logic.
12
+ - Maintain at least 90% coverage for lines, statements, functions, and branches.
13
+ - Implement one phase at a time.
14
+ - Use fan-out / fan-in / review / merge before implementing each phase.
15
+ - Keep logs under `tmp/` in deterministic phase-scoped paths.
16
+ - Use local branches and small commits only after local verification.
17
+ - Do not assume GitHub PR or issue workflows.
18
+
19
+ ## Core guard rails
20
+
21
+ - KISS
22
+ - SRP
23
+ - YAGNI
24
+ - strict TypeScript
25
+ - thin runtime glue
26
+ - no production reliance on Pi private internals
@@ -0,0 +1,31 @@
1
+ # Implementation state
2
+
3
+ ## Status
4
+
5
+ Preparation is in place. Implementation has not started.
6
+
7
+ ## Current source of truth
8
+
9
+ - Product plan: [Project Plan](../../../PLAN.md)
10
+ - Durable phase plans: [Phase Plan](../../../docs/phases/)
11
+ - Execution skill: `dev-loop`
12
+ - Repo contract: [Agent Instructions](../../../AGENTS.md)
13
+ - Workflow explainer: [Implementation Workflow](../../../docs/IMPLEMENTATION_WORKFLOW.md)
14
+ - tmp index for fresh-context inspection if present locally: `tmp/phases/index.json`
15
+
16
+ ## Next action for a fresh session
17
+
18
+ If the user says **"start implementation"**:
19
+
20
+ 1. read [Project Plan](../../../PLAN.md)
21
+ 2. load the `dev-loop` skill
22
+ 3. read [Agent Instructions](../../../AGENTS.md) if it exists
23
+ 4. read [Implementation Workflow](../../../docs/IMPLEMENTATION_WORKFLOW.md)
24
+ 5. read the current durable phase plan under `docs/phases/` if it exists
25
+ 6. inspect `tmp/phases/` only if it exists locally and is relevant
26
+ 7. read this file
27
+ 8. start with the next unfinished phase only
28
+
29
+ ## Next unfinished phase
30
+
31
+ Phase 0 — define the workflow convention, durable phase-plan format, and initial package boundary.
@@ -0,0 +1,17 @@
1
+ # Implementation workflow
2
+
3
+ This file is optional. The primary execution entrypoint is the `dev-loop` skill.
4
+
5
+ Use this file for repo-specific workflow notes that complement the skill.
6
+
7
+ ## Defaults
8
+
9
+ - one phase at a time
10
+ - [Project Plan](../../../PLAN.md) holds roadmap/product truth
11
+ - `docs/phases/phase-<n>.md` holds the durable plan for the active phase
12
+ - `tmp/phases/phase-<n>/` holds temporary local execution artifacts, reviews, and logs
13
+ - fan-out / fan-in / review / merge before coding
14
+ - test-first
15
+ - deterministic tmp logging
16
+ - local validation before phase completion
17
+ - local branches and small commits only after verification
@@ -0,0 +1,15 @@
1
+ # Phase {{phase}} dev-mode retrospective
2
+
3
+ ## Iteration reviewed
4
+
5
+ ## What the loop did well
6
+
7
+ ## What created friction or waste
8
+
9
+ ## Prompt follow-ups required
10
+
11
+ ## Prompt and workflow changes applied
12
+
13
+ ## Validation of the follow-up changes
14
+
15
+ ## Next dev-mode watchpoints