specrails-core 4.6.4 → 4.6.6

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 (29) hide show
  1. package/commands/enrich.md +109 -214
  2. package/dist/installer/phases/scaffold.js +152 -153
  3. package/dist/installer/phases/scaffold.js.map +1 -1
  4. package/docs/deployment.md +1 -1
  5. package/package.json +1 -2
  6. package/schemas/profile.v1.json +1 -9
  7. package/templates/agents/sr-architect.md +13 -9
  8. package/templates/agents/sr-developer.md +2 -2
  9. package/templates/agents/sr-reviewer.md +8 -2
  10. package/templates/codex-skills/enrich/SKILL.md +3 -3
  11. package/templates/codex-skills/implement/SKILL.md +75 -8
  12. package/templates/codex-skills/rails/sr-architect/SKILL.md +33 -7
  13. package/templates/codex-skills/rails/sr-developer/SKILL.md +6 -3
  14. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +57 -5
  15. package/templates/commands/specrails/enrich.md +36 -213
  16. package/templates/commands/specrails/implement.md +22 -10
  17. package/templates/commands/specrails/reconfig.md +1 -10
  18. package/templates/commands/specrails/retry.md +2 -1
  19. package/templates/skills/rails/sr-architect/SKILL.md +0 -234
  20. package/templates/skills/rails/sr-developer/SKILL.md +0 -210
  21. package/templates/skills/rails/sr-merge-resolver/SKILL.md +0 -197
  22. package/templates/skills/rails/sr-reviewer/SKILL.md +0 -320
  23. package/templates/skills/sr-auto-propose-backlog-specs/SKILL.md +0 -275
  24. package/templates/skills/sr-batch-implement/SKILL.md +0 -292
  25. package/templates/skills/sr-compat-check/SKILL.md +0 -275
  26. package/templates/skills/sr-get-backlog-specs/SKILL.md +0 -199
  27. package/templates/skills/sr-implement/SKILL.md +0 -1205
  28. package/templates/skills/sr-refactor-recommender/SKILL.md +0 -216
  29. package/templates/skills/sr-why/SKILL.md +0 -106
@@ -121,11 +121,17 @@ After running CI checks, also review for:
121
121
  - Search for any lines matching `- [ ]` (hyphen, space, open-bracket, space, close-bracket)
122
122
  - **If any `- [ ]` lines are found**: BLOCK archive. List every incomplete task title. Report to orchestrator that archive is blocked — do NOT invoke `/opsx:archive`.
123
123
  - **If no `- [ ]` lines remain** (all tasks are `- [x]`): gate passes — proceed to Step 6.
124
- 6. **Archive** — Only reachable when Step 5 gate passes. Invoke the archive skill via the Skill tool:
124
+ 6. **Archive** — Only reachable when Step 5 gate passes. Your archive action MUST be a real call to the archive skill via the Skill tool (not a manual directory move, not an emulation):
125
125
  ```
126
126
  Skill("opsx:archive", specName)
127
127
  ```
128
- Run non-interactively. Do NOT prompt the user or ask for confirmation.
128
+ `opsx:archive` must **sync the delta specs** from `openspec/changes/<specName>/specs/` into the main specs under `openspec/specs/` AND move the change to `openspec/changes/archive/`. Pass `specName` so it runs non-interactively; do NOT prompt the user.
129
+
130
+ **Verify the archive landed** after the skill returns:
131
+ - `openspec/changes/<specName>/` no longer exists (the change was moved), and
132
+ - the delta-spec changes are now present under `openspec/specs/`.
133
+
134
+ If either is false, the archive did NOT complete (a common symptom of a *simulated* archive is delta specs that were never synced) — report `archive incomplete` to the orchestrator and do NOT treat the change as done.
129
135
 
130
136
  ## Write Failure Records
131
137
 
@@ -129,10 +129,10 @@ This project uses **specrails** with the **codex** provider.
129
129
 
130
130
  ## Rail skills installed
131
131
  - `$implement`, `$batch-implement` — pipeline entry points
132
- - `$sr-architect`, `$sr-developer`, `$sr-reviewer`,
133
- `$sr-merge-resolver` — core rails
132
+ - `$sr-architect`, `$sr-developer`, `$sr-reviewer` — core rails
134
133
  - <list any optional rails installed in
135
- .codex/skills/rails/>
134
+ .codex/skills/rails/ — e.g. `$sr-merge-resolver`, layer
135
+ specialists>
136
136
 
137
137
  <!-- specrails-managed:end -->
138
138
  ```
@@ -30,6 +30,12 @@ path documented per phase (architect / developer can return
30
30
  `BLOCKED: …` and you stop). Otherwise: spawn, wait, close,
31
31
  move on.
32
32
 
33
+ **A `clean` run is NOT finished until the change is archived.**
34
+ Archiving (`openspec archive`) is a hard obligation, not an
35
+ optional epilogue — see Phase 5. If you mark a ticket `done`
36
+ without an archived change under `openspec/changes/archive/`,
37
+ you violated this contract.
38
+
33
39
  ## How the user invokes you
34
40
 
35
41
  - `$implement #N` — implement ticket `N` from
@@ -95,9 +101,10 @@ the combo and you'll burn a turn on the retry.
95
101
  3. **List the installed rail skills**:
96
102
  `ls .codex/skills/rails/`
97
103
  The output drives routing in phases 2-4. Skills that aren't
98
- listed are not installed — never spawn them. The four core
99
- rails (`sr-architect`, `sr-developer`, `sr-reviewer`,
100
- `sr-merge-resolver`) are always present.
104
+ listed are not installed — never spawn them. The three core
105
+ rails (`sr-architect`, `sr-developer`, `sr-reviewer`) are
106
+ always present. `sr-merge-resolver` and every layer specialist
107
+ are optional — spawn them only when listed.
101
108
  4. State (≤4 lines) the ticket goal, the stack you detected from
102
109
  a quick `ls`/`find`, and the optional rails that are
103
110
  available. Do NOT plan files-to-touch — that's the
@@ -247,8 +254,11 @@ Skip when the overall verdict is `fix needed` or `blocked` — no
247
254
  point sugar-coating an unsound change.
248
255
 
249
256
  - If `sr-test-writer` is installed AND the reviewer's confidence
250
- artefact reports a coverage decrease, spawn it with the
251
- changed files list. It writes more tests, runs them, reports.
257
+ artefact reports a coverage gap (`tdd_evidence.all_tasks_have_tests`
258
+ is `false`, or `tdd_evidence.tests_are_non_trivial` is `false`),
259
+ spawn it with the changed files list. It writes more tests, runs
260
+ them, reports. (These are the fields the `$sr-reviewer` skill
261
+ actually writes — do not key on a non-existent "coverage" field.)
252
262
  - If `sr-doc-sync` is installed AND the change touches a
253
263
  publicly-documented surface (README mentions a renamed
254
264
  function, AGENTS.md references a removed file, openspec specs
@@ -270,9 +280,65 @@ If phase 3's overall verdict is `fix needed`:
270
280
  `blocked`, **do not loop again** — surface in the final
271
281
  report.
272
282
 
273
- ### 6. Phase 5 — Close + report
274
-
275
- If a ticket id is in play:
283
+ ### 6. Phase 5 — Archive FIRST, then close + report
284
+
285
+ > **INVARIANT.** A ticket may be marked `done` ONLY if its change is
286
+ > archived (`openspec/changes/archive/<slug>/` exists). A `clean`
287
+ > verdict with an unarchived change is `todo` + `fix needed`, never
288
+ > `done`. Archiving the change and closing the ticket are a single
289
+ > atomic obligation — you cannot satisfy one and skip the other.
290
+
291
+ **Step A — Archive the OpenSpec change through `$sr-reviewer`
292
+ (mandatory when the verdict is `clean`). Run this BEFORE touching the
293
+ ticket or writing the report.** A change is not done until it is
294
+ archived — this is the codex equivalent of `opsx:archive`, and it MUST
295
+ run. When the overall verdict is `clean`, delegate the final OpenSpec
296
+ close to the reviewer rail so the same agent that validated the change
297
+ performs the lifecycle close:
298
+
299
+ 1. Spawn `$sr-reviewer` one final time (full-history fork).
300
+ 2. Send this exact close prompt:
301
+
302
+ > `$sr-reviewer`
303
+ >
304
+ > ARCHIVE_ONLY=true
305
+ > ARCHIVE_AUTHORIZED=true
306
+ > Ticket id: `<TICKET_ID>`
307
+ > Plan: `<PLAN_PATH>`
308
+ > Change slug: `<slug>`
309
+ >
310
+ > The aggregated reviewer verdict is clean. Follow the
311
+ > `$sr-reviewer` archive-only instructions exactly: validate the
312
+ > OpenSpec change, confirm every task is checked, perform the
313
+ > OpenSpec archive command, and verify the archive landed.
314
+
315
+ 3. `wait_agent`, parse the two-line `Score:` / `Verdict:` reply, and
316
+ `close_agent`.
317
+ 4. Treat any non-clean archive reply as archive failure.
318
+
319
+ The reviewer rail's archive-only mode must run these checks:
320
+
321
+ 1. Re-confirm every task box in `openspec/changes/<slug>/tasks.md`
322
+ is ticked (`- [x]`) and the change validates:
323
+ `openspec validate "<slug>" --strict`.
324
+ 2. Archive it: `openspec archive "<slug>" -y` — this updates the
325
+ main specs and moves the change to `openspec/changes/archive/`.
326
+ 3. **Verify the archive landed — do NOT assume success.** Confirm
327
+ `openspec/changes/archive/` now contains the slug
328
+ (`ls -d openspec/changes/archive/*<slug>* 2>/dev/null`) AND that
329
+ `openspec/changes/<slug>/` is gone. If the archive directory is
330
+ absent, archiving FAILED.
331
+ 4. If `openspec validate`, `openspec archive`, or the step-3
332
+ verification fails: do NOT mark the ticket `done`. Treat the run
333
+ as `fix needed`, surface the error in the final report, set the
334
+ report's `Archive:` line to `FAILED`, and leave the ticket
335
+ `todo`.
336
+
337
+ Skip archiving only when the verdict is `fix needed` or `blocked` —
338
+ an unsound change must never be archived. In that case set the
339
+ report's `Archive:` line to `skipped (<verdict>)`.
340
+
341
+ **Step B — Close the ticket + report.** If a ticket id is in play:
276
342
 
277
343
  - Update `.specrails/local-tickets.json`. Modify only:
278
344
  - `tickets["<ID>"].status` → `"done"` (clean) or `"todo"`
@@ -288,6 +354,7 @@ Print the final summary (≤18 lines):
288
354
  Pipeline: architect → <developer skill(s)> → <reviewer skill(s)>
289
355
  Plan: <path>
290
356
  Confidence: <best path> (overall <score>/100)
357
+ Archive: archived → openspec/changes/archive/<slug> | skipped (<verdict>) | FAILED
291
358
  Files: <one path per line, capped at 12; truncate beyond>
292
359
  Tests: <ran command, pass/fail>
293
360
  Build: <ran command, ok/fail/n/a>
@@ -19,16 +19,35 @@ source files outside `openspec/` and `.specrails/agent-memory/`.
19
19
 
20
20
  ### A. OpenSpec change package
21
21
 
22
- Create a directory at:
22
+ **Scaffold the change with the OpenSpec CLI — this is mandatory.**
23
+ Do NOT hand-create the change directory; the `openspec` CLI owns
24
+ scaffolding so the change is registered with a workflow schema and
25
+ stays trackable by `openspec status`. Run:
23
26
 
24
- `openspec/changes/<slug>/`
27
+ ```
28
+ openspec new change "<slug>" --schema spec-driven
29
+ ```
25
30
 
26
31
  where `<slug>` is a kebab-case derivation of the ticket title
27
32
  (e.g. ticket "Build a Playable Tetris Game" → `add-tetris-game`).
28
- If `openspec/` doesn't exist yet, create it. If the change
29
- directory already exists from a prior run, **reuse** it (idempotent).
33
+ This creates `openspec/changes/<slug>/.openspec.yaml`.
34
+
35
+ - If the command fails because OpenSpec isn't initialised in this
36
+ repo, run `openspec init . --tools codex --force` once, then
37
+ re-run `openspec new change …`.
38
+ - If the change directory already exists from a prior run,
39
+ **reuse** it (idempotent) — skip the `new change` call.
30
40
 
31
- Inside that directory, write four files:
41
+ Then fill the change's artefacts **in the dependency order
42
+ OpenSpec enforces** (proposal first; then design + specs; then
43
+ tasks). Check the order and what's still outstanding at any time
44
+ with:
45
+
46
+ ```
47
+ openspec status --change "<slug>" --json
48
+ ```
49
+
50
+ Write these four artefacts into `openspec/changes/<slug>/`:
32
51
 
33
52
  **`proposal.md`** — the change's executive summary:
34
53
 
@@ -237,12 +256,19 @@ on the touched files as a fallback.>
237
256
  When BOTH the OpenSpec change package and the plan artefact are
238
257
  written:
239
258
 
240
- 1. Reply with two lines:
259
+ 1. **Validate the change with the OpenSpec CLI** (mandatory):
260
+ ```
261
+ openspec validate "<slug>"
262
+ ```
263
+ If validation reports structural errors, fix the offending
264
+ artefact and re-run until it passes. Do not hand off a change
265
+ that fails `openspec validate`.
266
+ 2. Reply with two lines:
241
267
  ```
242
268
  OpenSpec change: openspec/changes/<slug>/
243
269
  Plan written to <plan-path>; files to touch: <comma-separated list>
244
270
  ```
245
- 2. End your turn. The orchestrator will read your plan + the
271
+ 3. End your turn. The orchestrator will read your plan + the
246
272
  tasks.md and spawn the developer next.
247
273
 
248
274
  If you cannot produce a plan (ticket is too ambiguous, repo
@@ -7,9 +7,12 @@ compatibility: "Codex-native. Designed to run as a full-history sub-agent fork o
7
7
 
8
8
  You are the **developer** in the specrails implement pipeline. The
9
9
  architect produced an OpenSpec change package (proposal + design +
10
- tasks + spec deltas) and a plan artefact. Your job is to walk the
11
- `tasks.md` TDD cycles in order, leave a minimal but cohesive set
12
- of changes, and hand off to the reviewer.
10
+ tasks + spec deltas) and a plan artefact. Your job is to **apply**
11
+ that OpenSpec change — walk its `tasks.md` TDD cycles in order,
12
+ leave a minimal but cohesive set of changes, and hand off to the
13
+ reviewer. The change's `tasks.md` is the single source of truth for
14
+ what to build; do not invent work outside it. You may only hand off
15
+ once **every** task box is ticked `- [x]` (see "How you finish").
13
16
 
14
17
  ## Your scope
15
18
 
@@ -14,15 +14,26 @@ the code. You emit a structured verdict and never touch the code.
14
14
  ## Your scope
15
15
 
16
16
  You **validate**. You read every artefact, you re-run every check,
17
- and you emit a structured judgement. Findings only you do not
18
- edit any source, test, or OpenSpec file.
17
+ and you emit a structured judgement. You do not edit source or test
18
+ files. You may write the confidence artefact and, when the review is
19
+ clean and archiving is authorized by the orchestrator, you must archive
20
+ the completed OpenSpec change with the `openspec` CLI.
19
21
 
20
22
  ## What you do, in order
21
23
 
22
24
  ### 1. Validate the OpenSpec change package
23
25
 
24
26
  Load `openspec/changes/<slug>/` (the orchestrator gave you the
25
- slug). Confirm the four artefacts exist and are well-formed:
27
+ slug). **Run the OpenSpec validator first** it is the canonical
28
+ structural check and is mandatory:
29
+
30
+ ```
31
+ openspec validate "<slug>" --strict --json
32
+ ```
33
+
34
+ A non-empty error list is a blocker finding: record each under
35
+ `issues` and bound `overall_score < 70`. Then confirm by hand the
36
+ four artefacts exist and are well-formed:
26
37
 
27
38
  - **`proposal.md`** — has `## Why`, `## What changes`, and
28
39
  `## Impact` sections.
@@ -146,6 +157,7 @@ Path:
146
157
  "ran": "npm run build | … | n/a",
147
158
  "passed": true
148
159
  },
160
+ "archive_status": "not_authorized | archived:<path> | skipped:<verdict> | failed",
149
161
  "issues": [
150
162
  {
151
163
  "severity": "blocker" | "major" | "minor",
@@ -164,10 +176,50 @@ Scoring guide:
164
176
  multiple minor ones
165
177
  - **< 50** — blocker: at least one blocker finding
166
178
 
179
+ ### 7. Archive the OpenSpec change when authorized
180
+
181
+ Archiving is mandatory for a clean close, but only safe after the
182
+ orchestrator has aggregated all reviewer verdicts. Therefore:
183
+
184
+ - If the orchestrator prompt includes both `ARCHIVE_ONLY=true` and
185
+ `ARCHIVE_AUTHORIZED=true`, skip Steps 2-5 of the code review. You are
186
+ being invoked only to perform the final OpenSpec close. You must still
187
+ run Step 1, confirm all tasks are checked, run `openspec archive`, and
188
+ verify the archive landed.
189
+ - If the orchestrator prompt includes `ARCHIVE_AUTHORIZED=true` and your
190
+ verdict is `clean`, you must archive the change yourself using
191
+ OpenSpec. Do not ask the user for confirmation.
192
+ - If `ARCHIVE_AUTHORIZED=true` is absent, set
193
+ `"archive_status": "not_authorized"` in the confidence artefact and
194
+ report the clean verdict without archiving. The orchestrator must then
195
+ invoke you again for the archive-only close step or perform its own
196
+ archive step.
197
+ - If your verdict is `fix needed` or `blocked`, do not archive. Set
198
+ `"archive_status": "skipped:<verdict>"`.
199
+
200
+ When archiving is authorized and the verdict is clean, run these exact
201
+ checks in order:
202
+
203
+ 1. Re-run `openspec validate "<slug>" --strict`.
204
+ 2. Read `openspec/changes/<slug>/tasks.md` and search for unchecked
205
+ tasks (`- [ ]`). If any remain, do not archive; change the verdict to
206
+ `fix needed: OpenSpec tasks remain unchecked`.
207
+ 3. Run `openspec archive "<slug>" -y`.
208
+ 4. Verify the archive landed: confirm `openspec/changes/<slug>/` is gone
209
+ and `openspec/changes/archive/` contains a directory whose name
210
+ includes `<slug>`.
211
+
212
+ If validation, archive, or verification fails, do not report `clean`.
213
+ Record the command/error under `issues`, set `"archive_status": "failed"`
214
+ in the confidence artefact, and finish with `fix needed:
215
+ OpenSpec archive failed`.
216
+
167
217
  ## What you must NOT do
168
218
 
169
- - **Do not** edit any source, test, OpenSpec, or ticket file.
170
- You are findings-only.
219
+ - **Do not** edit any source or test file.
220
+ - **Do not** edit OpenSpec files by hand. The only allowed OpenSpec
221
+ mutation is `openspec archive "<slug>" -y` during Step 7 when
222
+ `ARCHIVE_AUTHORIZED=true` and the verdict is clean.
171
223
  - **Do not** update `.specrails/local-tickets.json`. The
172
224
  orchestrator writes that after reading your verdict.
173
225
  - **Do not** spawn further sub-agents.