specrails-core 4.12.1 → 5.1.0

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 (97) hide show
  1. package/README.md +103 -339
  2. package/bin/specrails-core.mjs +20 -98
  3. package/bin/tui-installer.mjs +22 -105
  4. package/commands/doctor.md +1 -1
  5. package/dist/installer/cli.js +16 -2
  6. package/dist/installer/cli.js.map +1 -1
  7. package/dist/installer/commands/doctor.js +3 -5
  8. package/dist/installer/commands/doctor.js.map +1 -1
  9. package/dist/installer/commands/framework.js +64 -49
  10. package/dist/installer/commands/framework.js.map +1 -1
  11. package/dist/installer/commands/init.js +122 -82
  12. package/dist/installer/commands/init.js.map +1 -1
  13. package/dist/installer/commands/update.js +90 -83
  14. package/dist/installer/commands/update.js.map +1 -1
  15. package/dist/installer/commands/v5-migration.js +133 -0
  16. package/dist/installer/commands/v5-migration.js.map +1 -0
  17. package/dist/installer/phases/framework-lifecycle.js +2 -0
  18. package/dist/installer/phases/framework-lifecycle.js.map +1 -1
  19. package/dist/installer/phases/install-config.js +3 -6
  20. package/dist/installer/phases/install-config.js.map +1 -1
  21. package/dist/installer/phases/manifest.js +2 -6
  22. package/dist/installer/phases/manifest.js.map +1 -1
  23. package/dist/installer/phases/prereqs.js +0 -1
  24. package/dist/installer/phases/prereqs.js.map +1 -1
  25. package/dist/installer/phases/scaffold.js +228 -405
  26. package/dist/installer/phases/scaffold.js.map +1 -1
  27. package/dist/installer/runtime/pipeline-state.js +801 -0
  28. package/dist/installer/runtime/pipeline-state.js.map +1 -0
  29. package/dist/installer/util/install-transaction.js +246 -0
  30. package/dist/installer/util/install-transaction.js.map +1 -0
  31. package/dist/installer/util/registry.js +20 -0
  32. package/dist/installer/util/registry.js.map +1 -1
  33. package/docs/ci-cd.md +57 -0
  34. package/docs/user-docs/codex-vs-claude-code.md +23 -151
  35. package/docs/user-docs/core-updates.md +70 -0
  36. package/docs/user-docs/provider-pipelines.md +53 -0
  37. package/integration-contract.json +179 -66
  38. package/package.json +5 -2
  39. package/schemas/profile.v1.json +1 -1
  40. package/templates/agents/sr-architect.md +30 -0
  41. package/templates/agents/sr-developer.md +30 -19
  42. package/templates/agents/sr-reviewer.md +70 -64
  43. package/templates/codex-skills/batch-implement/SKILL.md +58 -267
  44. package/templates/codex-skills/implement/SKILL.md +136 -420
  45. package/templates/codex-skills/rails/sr-architect/SKILL.md +45 -20
  46. package/templates/codex-skills/rails/sr-developer/SKILL.md +42 -10
  47. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +60 -15
  48. package/templates/codex-skills/retry/SKILL.md +37 -117
  49. package/templates/commands/specrails/batch-implement.md +16 -288
  50. package/templates/commands/specrails/doctor.md +1 -1
  51. package/templates/commands/specrails/implement.md +94 -1260
  52. package/templates/commands/specrails/memory-inspect.md +6 -4
  53. package/templates/commands/specrails/propose-spec.md +1 -1
  54. package/templates/commands/specrails/refactor-recommender.md +8 -51
  55. package/templates/commands/specrails/retry.md +22 -350
  56. package/templates/commands/specrails/telemetry.md +1 -1
  57. package/templates/gemini-commands/batch-implement.toml +28 -40
  58. package/templates/gemini-commands/implement.toml +55 -105
  59. package/templates/gemini-commands/retry.toml +21 -0
  60. package/templates/kimi/specrails/run-skill.mjs +51 -2
  61. package/templates/profiles/default.json +5 -18
  62. package/templates/runtime/provider-pipeline.md +55 -0
  63. package/commands/enrich.md +0 -1456
  64. package/templates/agents/sr-backend-developer.md +0 -91
  65. package/templates/agents/sr-backend-reviewer.md +0 -152
  66. package/templates/agents/sr-doc-sync.md +0 -247
  67. package/templates/agents/sr-frontend-developer.md +0 -85
  68. package/templates/agents/sr-frontend-reviewer.md +0 -145
  69. package/templates/agents/sr-merge-resolver.md +0 -195
  70. package/templates/agents/sr-performance-reviewer.md +0 -186
  71. package/templates/agents/sr-product-analyst.md +0 -36
  72. package/templates/agents/sr-product-manager.md +0 -148
  73. package/templates/agents/sr-security-reviewer.md +0 -191
  74. package/templates/agents/sr-test-writer.md +0 -176
  75. package/templates/codex-skills/enrich/SKILL.md +0 -191
  76. package/templates/codex-skills/merge-resolve/SKILL.md +0 -88
  77. package/templates/codex-skills/rails/sr-backend-developer/SKILL.md +0 -93
  78. package/templates/codex-skills/rails/sr-backend-reviewer/SKILL.md +0 -120
  79. package/templates/codex-skills/rails/sr-doc-sync/SKILL.md +0 -124
  80. package/templates/codex-skills/rails/sr-frontend-developer/SKILL.md +0 -106
  81. package/templates/codex-skills/rails/sr-frontend-reviewer/SKILL.md +0 -111
  82. package/templates/codex-skills/rails/sr-merge-resolver/SKILL.md +0 -156
  83. package/templates/codex-skills/rails/sr-performance-reviewer/SKILL.md +0 -109
  84. package/templates/codex-skills/rails/sr-product-analyst/SKILL.md +0 -85
  85. package/templates/codex-skills/rails/sr-product-manager/SKILL.md +0 -131
  86. package/templates/codex-skills/rails/sr-security-reviewer/SKILL.md +0 -121
  87. package/templates/codex-skills/rails/sr-test-writer/SKILL.md +0 -115
  88. package/templates/commands/specrails/auto-propose-backlog-specs.md +0 -312
  89. package/templates/commands/specrails/enrich.md +0 -1456
  90. package/templates/commands/specrails/get-backlog-specs.md +0 -226
  91. package/templates/commands/specrails/merge-resolve.md +0 -172
  92. package/templates/commands/specrails/reconfig.md +0 -80
  93. package/templates/commands/specrails/vpc-drift.md +0 -405
  94. package/templates/commands/test.md +0 -58
  95. package/templates/personas/persona.md +0 -43
  96. package/templates/personas/the-maintainer.md +0 -98
  97. package/templates/settings/perf-thresholds.yml +0 -25
@@ -5,6 +5,19 @@ license: MIT
5
5
  compatibility: "Codex-native. Designed to run as a full-history sub-agent fork of the implement orchestrator."
6
6
  ---
7
7
 
8
+ **Execution scope.** The orchestrator's explicit frozen handoff or execution-context
9
+ file is authoritative. Use all selected repository IDs/paths for source work and
10
+ `context.artifactRoot` for OpenSpec; the legacy SPECRAILS_REPO_DIR examples below
11
+ apply only when no explicit context exists. Preserve the aggregate change slug for
12
+ a batch. Do not reload mutable tickets to replace frozen descriptions. Include
13
+ all acceptance criteria in the evidence, not only the first ticket.
14
+
15
+ **Deterministic repo map.** If `SPECRAILS_REPO_MAP_PATH` is set
16
+ and readable, read that file FIRST — a zero-AI map of the repo
17
+ (packages, ecosystems, sizes) generated by the spawner. Use it to
18
+ orient; do not spend turns on top-level discovery. Unset ⇒ explore
19
+ as normal.
20
+
8
21
  You are the **architect** in the specrails implement pipeline. The
9
22
  orchestrator already loaded the ticket and surveyed the repo before
10
23
  spawning you. Your turn is short, focused, and ends with TWO
@@ -87,18 +100,6 @@ writing code.
87
100
  <one paragraph: the system state today, the constraints the
88
101
  change must respect, the assumptions you are making.>
89
102
 
90
- Scope: <comma-separated labels — pick honestly from:
91
- frontend, backend, both, security-sensitive,
92
- performance-sensitive>
93
- Examples:
94
- - "Scope: frontend"
95
- - "Scope: backend, security-sensitive"
96
- - "Scope: both, performance-sensitive"
97
- The implement orchestrator parses this line to route
98
- the developer + reviewer phases. A missing or wrong
99
- label means the wrong specialists get spawned (or
100
- none at all).
101
-
102
103
  ## Goal
103
104
  <one sentence: what observable behaviour you are adding /
104
105
  changing.>
@@ -155,12 +156,13 @@ the table.
155
156
 
156
157
  ## 1. <First testable behaviour>
157
158
  - [ ] 1.1 Write a failing test in `<test-path>` that asserts
158
- <behaviour>. Run the test runner; the new test MUST fail.
159
+ <behaviour>. Run that test file (scoped); the new test
160
+ MUST fail.
159
161
  - [ ] 1.2 Implement the minimum production code in `<src-path>`
160
- to make the test pass. Run the test runner; ALL tests
161
- MUST pass.
162
- - [ ] 1.3 Refactor if needed without changing behaviour. Run
163
- the test runner; all tests still pass.
162
+ to make the test pass. Re-run that test file (scoped);
163
+ it MUST pass.
164
+ - [ ] 1.3 Refactor if needed without changing behaviour. Re-run
165
+ the test files covering the touched files; still green.
164
166
 
165
167
  ## 2. <Next testable behaviour>
166
168
  - [ ] 2.1 Write a failing test...
@@ -272,13 +274,36 @@ written:
272
274
  If validation reports structural errors, fix the offending
273
275
  artefact and re-run until it passes. Do not hand off a change
274
276
  that fails `openspec validate`.
275
- 2. Reply with two lines:
277
+ 2. **Emit design confidence** (mandatory). Write
278
+ `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<slug>/design-confidence.json`:
279
+ ```json
280
+ {
281
+ "schema_version": "1",
282
+ "change": "<slug>",
283
+ "agent": "architect",
284
+ "scored_at": "<ISO 8601>",
285
+ "confidence": "high | medium | low",
286
+ "reason": "<1-2 concrete sentences>",
287
+ "blocking_question": "<one focused question when low, else null>"
288
+ }
289
+ ```
290
+ Rubric — **high**: evidence conclusive, exact files/identifiers
291
+ located, design unambiguous. **medium**: likely correct but one
292
+ non-obvious assumption remains (name it in `reason`). **low**:
293
+ multiple plausible designs and you cannot choose without
294
+ information you don't have — `blocking_question` is the SINGLE
295
+ most blocking unknown, phrased so a human can answer it. Never
296
+ inflate: a `low` with a sharp question is a successful output —
297
+ it saves the whole implementation cost of building the wrong
298
+ thing.
299
+ 3. Reply with three lines:
276
300
  ```
277
301
  OpenSpec change: openspec/changes/<slug>/
278
302
  Plan written to <plan-path>; files to touch: <comma-separated list>
303
+ Design confidence: <high|medium|low>[ — blocking question: <question>]
279
304
  ```
280
- 3. End your turn. The orchestrator will read your plan + the
281
- tasks.md and spawn the developer next.
305
+ 4. End your turn. The orchestrator will read your plan + the
306
+ tasks.md and spawn the developer next (or halt on `low`).
282
307
 
283
308
  If you cannot produce a plan (ticket is too ambiguous, repo
284
309
  state is corrupt, etc.), instead reply with:
@@ -5,6 +5,13 @@ license: MIT
5
5
  compatibility: "Codex-native. Designed to run as a full-history sub-agent fork of the implement orchestrator."
6
6
  ---
7
7
 
8
+ **Execution scope.** The orchestrator's explicit frozen handoff or execution-context
9
+ file is authoritative. Use all selected repository IDs/paths for source work and
10
+ `context.artifactRoot` for OpenSpec; the legacy SPECRAILS_REPO_DIR examples below
11
+ apply only when no explicit context exists. Preserve the aggregate change slug for
12
+ a batch. Do not reload mutable tickets to replace frozen descriptions. Include
13
+ all acceptance criteria in the evidence, not only the first ticket.
14
+
8
15
  **Repository location.** Your working directory may NOT be the source
9
16
  repo. `openspec/**` and the source files named in `tasks.md` (repo-relative
10
17
  paths like `src/foo.ts`) live under `${SPECRAILS_REPO_DIR:-.}` — unset ⇒ `.`
@@ -72,9 +79,10 @@ note it in your reply — do not block on the architect.
72
79
  a. **RED — write the failing test (step N.1).**
73
80
  - Open the test file the task names. Create it if missing.
74
81
  - Add the test asserting the behaviour the task names.
75
- - Run the test runner. The new test MUST fail. If it
76
- unexpectedly passes, your test is wrong (it isn't
77
- actually asserting the new behaviour) — rewrite it.
82
+ - Run **only that test file** (scoped run — e.g.
83
+ `npx vitest run <file>`, `pytest <file>`). The new test
84
+ MUST fail. If it unexpectedly passes, your test is wrong
85
+ (it isn't actually asserting the new behaviour) — rewrite it.
78
86
  - Tick `- [x] N.1` in `tasks.md` only when you have
79
87
  observed the test fail.
80
88
 
@@ -83,16 +91,27 @@ note it in your reply — do not block on the architect.
83
91
  modify it.
84
92
  - Write the minimum code to make the failing test pass.
85
93
  Resist adding code unrelated to the test.
86
- - Run the test runner. ALL tests must pass — the new
87
- one AND every prior one.
94
+ - Re-run **only that test file** (`npx vitest run
95
+ <file>`, `pytest <file>`, …). It must pass. The full
96
+ suite runs once, at the validation gate — not after
97
+ every task.
88
98
  - Tick `- [x] N.2`.
89
99
 
90
100
  c. **REFACTOR — clean up (step N.3, if present).**
91
101
  - If the production code can be clearer without changing
92
102
  behaviour, refactor it now.
93
- - Re-run the test runner. All tests still pass.
103
+ - Re-run the test files covering the files you touched.
104
+ Still green.
94
105
  - Tick `- [x] N.3`.
95
106
 
107
+ **Test-execution economy (MANDATORY):** the full project
108
+ suite runs exactly ONCE — at the validation gate below.
109
+ Never run it inside a task cycle. When a scoped run fails,
110
+ carry forward only the failing test names and the relevant
111
+ error excerpt (≤50 lines), never a full runner log. If you
112
+ run the same command 3 times with no intervening code
113
+ change, STOP re-running and change the code or the test.
114
+
96
115
  3. **Honour the design's invariants and edge cases.** When the
97
116
  design's `Public API / surface` says a function takes `(x, y)`
98
117
  and returns `Result<Z>`, your code must match that signature
@@ -111,19 +130,32 @@ note it in your reply — do not block on the architect.
111
130
 
112
131
  ## Validation gate
113
132
 
133
+ Run the gate through the installed pipeline helper `verify --request <json>` so
134
+ its actual command exits and repository fingerprints become a reusable receipt.
135
+ The request lists all required commands with repositoryId, executable, argv and
136
+ cwd; use the frozen handoff repositories. Never invent a receipt or reuse one
137
+ whose status is invalid. Save the receipt path with the developer outcome.
138
+
114
139
  The final task block in `tasks.md` is always the validation gate
115
140
  (`## N. Validation gate`). Run it:
116
141
 
117
142
  - Full project test suite (e.g. `npm test`, `pytest`,
118
- `cargo test`). MUST pass.
143
+ `cargo test`). MUST pass. This is the pipeline's SINGLE
144
+ full pass — the per-task loop stayed scoped so this one
145
+ can be exhaustive.
119
146
  - Project build if present (e.g. `npm run build`,
120
147
  `cargo build`). MUST succeed.
121
148
  - A grep for debug breadcrumbs (`console.log`, `print(`, etc.)
122
149
  in the files you touched — none should remain.
123
150
 
124
- If the gate fails, the offending file is your responsibility:
125
- fix it before handing off. Do not push the gate problem onto
126
- the reviewer.
151
+ If the gate fails, the offending file is your responsibility.
152
+ Fix it, re-running **only the failing test files** between
153
+ fixes — you have a budget of 2 fix cycles, then ONE final
154
+ full-suite run to confirm. If failures persist after that,
155
+ reply `"BLOCKED: validation gate failing — <failing tests,
156
+ verbatim>"` and end your turn. Never keep looping, never
157
+ weaken or skip tests to force green, never hand a known
158
+ failure silently to the reviewer.
127
159
 
128
160
  ## What you must NOT do
129
161
 
@@ -5,6 +5,13 @@ license: MIT
5
5
  compatibility: "Codex-native. Designed to run as a full-history sub-agent fork of the implement orchestrator."
6
6
  ---
7
7
 
8
+ **Execution scope.** The orchestrator's explicit frozen handoff or execution-context
9
+ file is authoritative. Use all selected repository IDs/paths for source work and
10
+ `context.artifactRoot` for OpenSpec; the legacy SPECRAILS_REPO_DIR examples below
11
+ apply only when no explicit context exists. Preserve the aggregate change slug for
12
+ a batch. Do not reload mutable tickets to replace frozen descriptions. Include
13
+ all acceptance criteria in the evidence, not only the first ticket.
14
+
8
15
  You are the **reviewer** in the specrails implement pipeline. The
9
16
  architect produced an OpenSpec change package, and the developer
10
17
  implemented it. Your job is to validate the **whole** implementation
@@ -101,37 +108,67 @@ For each `## N.` task block in `tasks.md`:
101
108
 
102
109
  ### 4. Walk the ticket's acceptance criteria
103
110
 
104
- Load `.specrails/local-tickets.json`, read
105
- `tickets["<ID>"].description`. Map each acceptance criterion
111
+ Read every frozen ticket description/acceptance criterion from the handoff or
112
+ execution context; only legacy runs consult the explicitly resolved ticket store. Map each acceptance criterion
106
113
  to evidence in the changed files. Every criterion must have
107
114
  at least one of: a passing test, an observable code path, or
108
115
  a screenshot/manual-check note in the design's
109
116
  "Open questions". A criterion with **no** mapping is a
110
117
  blocker finding.
111
118
 
112
- ### 5. Re-run the full validation gate
113
-
114
- Use the command from the design's `Validation` section in the
115
- plan artefact (or the final block of `tasks.md`):
116
-
117
- - Project test suite (`npm test`, `pytest`, `cargo test`, …).
118
- Confirm it passes. Capture the count.
119
- - Project build if present (`npm run build`, …). Confirm it
120
- succeeds.
121
- - If neither runner exists, run whatever fallback the design
119
+ ### 5. Verify the gate — scoped-first
120
+
121
+ The developer's validation gate already ran the full suite
122
+ green; re-running the whole thing on an untouched tree
123
+ re-buys information the pipeline already has. So:
124
+
125
+ - Run the tests SCOPED to the diff — the test files covering
126
+ every changed source file, per-file (`npx vitest run
127
+ <file>`, `pytest <file>`, `cargo test <name>`, …). Confirm
128
+ green; capture the count.
129
+ - Run the full suite yourself ONLY when: you modified
130
+ production code in this review, the diff touches
131
+ build/config/test infrastructure, or a scoped failure has
132
+ an unclear blast radius. Then finish with ONE clean full
133
+ pass (plus the build if present) — never repeated full
134
+ passes between fixes.
135
+ - If you changed nothing and the scoped runs are green,
136
+ record the developer's gate as the pass of record — in the
137
+ confidence artefact set `tests.ran` to the scoped command
138
+ and say so in `tests.details`.
139
+ - If no test runner exists, run whatever fallback the design
122
140
  named (`node --check`, etc.).
123
141
 
124
142
  ### 6. Write the confidence artefact
125
143
 
126
144
  Path:
127
145
 
128
- `.specrails/agent-memory/explanations/YYYY-MM-DD-reviewer-ticket-{TICKET_ID}.confidence-score.json`
146
+ `<context.artifactRoot>/openspec/changes/<slug>/confidence-score.json`
147
+
148
+ This canonical report is required by the pipeline gate. An optional copy may be
149
+ kept in `.specrails/agent-memory/explanations/` for human history. Score the five
150
+ aspects independently from actual findings; never fill them mechanically from
151
+ the overall score. Keep `overall_score` as a legacy summary alias of `overall`.
129
152
 
130
153
  (today's date; create parent dir if missing). Shape:
131
154
 
132
155
  ```json
133
156
  {
157
+ "schema_version": "1",
158
+ "change": "<slug>",
159
+ "agent": "reviewer",
160
+ "scored_at": "<ISO timestamp>",
161
+ "overall": 0-100,
134
162
  "overall_score": 0-100,
163
+ "aspects": {
164
+ "type_correctness": 0-100,
165
+ "pattern_adherence": 0-100,
166
+ "test_coverage": 0-100,
167
+ "security": 0-100,
168
+ "architectural_alignment": 0-100
169
+ },
170
+ "notes": { "<aspect>": "<concrete evidence and concerns>" },
171
+ "flags": [],
135
172
  "summary": "<one paragraph>",
136
173
  "openspec_artefacts": {
137
174
  "proposal_ok": true,
@@ -184,11 +221,18 @@ Scoring guide:
184
221
 
185
222
  ### 7. Archive the OpenSpec change when authorized
186
223
 
224
+ Authorization requires a successful shared pipeline `archive-check` after the
225
+ orchestrator recorded semantic reviewer done. Ordinary review records findings
226
+ and confidence only; it never archives before that combined gate.
227
+
187
228
  Archiving is mandatory for a clean close, but only safe after the
188
229
  orchestrator has aggregated all reviewer verdicts. Therefore:
189
230
 
190
231
  - If the orchestrator prompt includes both `ARCHIVE_ONLY=true` and
191
- `ARCHIVE_AUTHORIZED=true`, skip Steps 2-5 of the code review. You are
232
+ `ARCHIVE_AUTHORIZED=true`, skip Steps 2-6 of the code review. Preserve the
233
+ canonical confidence report byte-for-byte: the gate authorizes its exact hash.
234
+ Do not rescore or rewrite archive_status; report archive outcomes through the
235
+ journal and final reply only. You are
192
236
  being invoked only to perform the final OpenSpec close. You must still
193
237
  run Step 1, confirm all tasks are checked, run `openspec archive`, and
194
238
  verify the archive landed.
@@ -223,7 +267,8 @@ OpenSpec archive failed`.
223
267
  ## What you must NOT do
224
268
 
225
269
  - **Do not** edit any source or test file.
226
- - **Do not** edit OpenSpec files by hand. The only allowed OpenSpec
270
+ - **Do not** edit OpenSpec design/tasks/specs by hand. Writing the required
271
+ canonical confidence report during ordinary review is allowed. Lifecycle
227
272
  mutation is `openspec archive "<slug>" -y` during Step 7 when
228
273
  `ARCHIVE_AUTHORIZED=true` and the verdict is clean.
229
274
  - **Do not** update `.specrails/local-tickets.json`. The
@@ -1,122 +1,42 @@
1
1
  ---
2
2
  name: retry
3
- description: "Resume a previously-attempted $implement pipeline for a ticket. Detects what's already on disk (OpenSpec change package, partial code, ticked tasks.md) and re-invokes $implement so the architect/developer/reviewer agents skip work that's already correct and pick up where the prior run left off. Use when the user invokes `$retry #N` after a $implement run that ended in `todo` or `blocked`."
3
+ description: "Resume the first invalid implement phase using the durable pipeline journal and explicit role handoffs."
4
4
  license: MIT
5
- compatibility: "Codex-native. Thin wrapper around $implement — relies on the implement pipeline's existing idempotence rather than tracking its own state."
5
+ compatibility: "Codex-native root-level role delegation; no nested implement or assumed provider conversation memory."
6
6
  ---
7
7
 
8
- You are the **retry orchestrator**. The user wants to continue a
9
- prior `$implement` run for a single ticket without redoing work
10
- that's already correct on disk.
11
-
12
- You are NOT a separate pipeline. You inspect what `$implement`
13
- left behind, summarise the current state, and re-invoke
14
- `$implement` with a hint about what's already in place. The
15
- implement skill is idempotent — architect reuses an existing
16
- `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<slug>/`, developer detects ticked tasks and
17
- already-correct files, reviewer re-validates from scratch.
18
-
19
- **Repository location.** `openspec/**` and `.git` live under
20
- `${SPECRAILS_REPO_DIR:-.}` (unset ⇒ `.` ⇒ classic in-repo run); inspect change
21
- artefacts there. The ticket store and `.specrails/agent-memory/` are run-state,
22
- relative to the working directory.
23
-
24
- ## How the user invokes you
25
-
26
- - `$retry #N` — retry the implement run for ticket `N`.
27
- - `$retry #N --yes` — same, non-interactive.
28
-
29
- ## Steps
30
-
31
- ### 0. Locate the prior run's artefacts
32
-
33
- 1. Confirm the repo root with `git -C "${SPECRAILS_REPO_DIR:-.}" rev-parse --show-toplevel`.
34
- 2. Load the ticket (run-state, relative to the working directory):
35
- `jq '.tickets["<ID>"]' .specrails/local-tickets.json`. If
36
- the ticket doesn't exist, stop and report.
37
- 3. Inspect what's already on disk for this ticket:
38
- - **Architect artefacts**: any matching plan file under
39
- `.specrails/agent-memory/explanations/` named
40
- `*-architect-ticket-<ID>.md`. List the latest.
41
- - **OpenSpec change package**: any
42
- `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<slug>/` whose proposal.md mentions
43
- the ticket title or whose tasks.md has tasks scoped to
44
- the ticket. Find the slug.
45
- - **tasks.md progress**: count `[x]` vs `[ ]` boxes in
46
- `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<slug>/tasks.md`.
47
- - **Reviewer verdict**: latest matching
48
- `*-reviewer-ticket-<ID>.confidence-score.json`. Read
49
- the issues list and overall score.
50
-
51
- ### 1. Summarise (≤6 lines)
52
-
53
- Print a concise state summary so the user sees what you
54
- detected:
55
-
56
- ```
57
- Prior run for #<ID>:
58
- Plan: <path or "missing">
59
- Change pkg: openspec/changes/<slug>/ (<found / missing>)
60
- Tasks: <X>/<N> ticked
61
- Last review: <score>/100 — <verdict>
62
- Open issues: <count> (top: "<first issue note, truncated>")
63
- ```
64
-
65
- If no prior artefacts exist, say so explicitly — `$retry` on a
66
- ticket that was never attempted is just `$implement`, and you
67
- fall through to step 2 anyway.
68
-
69
- ### 2. Re-invoke $implement
70
-
71
- `spawn_agent` (full-history fork, no agent_type / model /
72
- reasoning_effort). `send_message`:
73
-
74
- > `$implement`
75
- >
76
- > Ticket id: `<TICKET_ID>`
77
- > Mode: **retry**
78
- >
79
- > A prior run left:
80
- > - plan at `<plan-path-or-none>`
81
- > - change package at `openspec/changes/<slug>/` (<found|missing>)
82
- > - tasks.md progress: <X>/<N> ticked
83
- > - last reviewer score: <N>/100 with <K> open issues
84
- >
85
- > Open issues from the last review (verbatim):
86
- > - <issue 1 from confidence-score.json>
87
- > - <issue 2>
88
- > - ...
89
- >
90
- > Honour these on this retry:
91
- > 1. If the change package exists and proposal.md is sane,
92
- > REUSE it. The architect should refine design.md / tasks.md
93
- > if the issues call for it, not start from scratch.
94
- > 2. The developer should pick up at the first un-ticked task
95
- > box. Already-ticked boxes whose files match the intended
96
- > state should NOT be redone.
97
- > 3. The reviewer re-runs from scratch — no caching of prior
98
- > verdict.
99
- >
100
- > Follow the $implement skill instructions exactly. Reply
101
- > with the standard implement summary.
102
-
103
- `wait_agent`. `close_agent`. Print the sub-agent's reply
104
- verbatim as your own final report.
105
-
106
- ## What you must NOT do
107
-
108
- - **Do NOT re-implement the pipeline**. You only inspect +
109
- delegate. The implement skill owns the actual work.
110
- - **Do NOT modify any file directly** — neither the OpenSpec
111
- package nor the ticket. The spawned `$implement` does that.
112
- - **Do NOT skip the "open issues" passthrough**. If the last
113
- review listed fixes, the next pipeline needs to see them
114
- verbatim — that's what makes retry produce a different
115
- result than a fresh `$implement`.
116
- - **Do NOT loop on retry**. If the user wants a second retry,
117
- they invoke `$retry #N` again themselves. One retry per
118
- invocation.
119
- - **Do NOT pass `agent_type`, `model`, or `reasoning_effort`**
120
- to `spawn_agent` on full-history forks.
121
- - **Do NOT touch `.claude/agent-memory/`** — codex projects
122
- use `.specrails/agent-memory/`.
8
+ You are the retry orchestrator. Accept `$retry #N`, `$retry <change>`, and `--yes`.
9
+ Resolve `${SPECRAILS_REPO_DIR:-.}` only as the legacy source default; the installed
10
+ pipeline helper and SPECRAILS_EXECUTION_CONTEXT provide the authoritative roots.
11
+ Call `status` for the existing run/change. Report its completed phases and
12
+ `resumePhase`. Do not search other projects or guess a change from a matching title.
13
+ When there is no journal, report the missing run/context and require explicit new
14
+ admission; do not silently initialize a replacement retry scope. Never erase existing
15
+ code or use a checked task alone as proof of implementation.
16
+
17
+ Read `.codex/skills/implement/SKILL.md` as the phase definition; execute its remaining
18
+ roles DIRECTLY from this root agent. Do not spawn `$implement` as a sub-agent.
19
+ Use `spawn_agent`, `send_message` and `wait_agent` only for `$sr-architect`,
20
+ `$sr-developer`, `$sr-reviewer` or explicitly configured installed custom roles.
21
+ Preserve the configured provider model; do not pass model/reasoning_effort on
22
+ full-history forks. Give every role the bounded explicit handoff from the shared
23
+ contract, including unchanged frozen acceptance criteria and exact prior findings.
24
+
25
+ - Architect resumes only if status says design is invalid/missing/blocked.
26
+ - Developer resumes the first incomplete or stale task; do not repeat valid design.
27
+ - Reviewer resumes semantic review with the actual candidate and verification
28
+ receipts. If findings require code changes, record developer running and invoke
29
+ developer with those exact findings, then reviewer again (at most one fix round).
30
+ - Never assume a `MAX_TURNS` or successful process exit completed a phase. Save the
31
+ checkpoint and invoke the same role with the pending work; two continuations
32
+ without file/task/evidence progress stop as blocked with the outstanding action.
33
+ - Archive uses `archive-check`, followed by reviewer archive-only authorization;
34
+ missing/low confidence or stale checks never become success through retry.
35
+ - Ship resumes only missing authorized Core-owned delivery; CI checks existing
36
+ delivery without shipping again. Host-owned ship/ci record skipped; backlog and
37
+ worktrees remain with their owner. Backlog closure also compares live requirements
38
+ with frozen scope at context.backlogPath, as implement requires.
39
+
40
+ Record each outcome with the helper. A blocked phase is resumable, never an
41
+ intentionally skipped phase. Report the run, change, resumed roles, verification,
42
+ archive outcome and any remaining blocker. No recursive retry loops.