specrails-core 5.0.0 → 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 (48) hide show
  1. package/README.md +103 -310
  2. package/bin/specrails-core.mjs +3 -1
  3. package/dist/installer/cli.js +4 -0
  4. package/dist/installer/cli.js.map +1 -1
  5. package/dist/installer/commands/framework.js +64 -49
  6. package/dist/installer/commands/framework.js.map +1 -1
  7. package/dist/installer/commands/init.js +102 -66
  8. package/dist/installer/commands/init.js.map +1 -1
  9. package/dist/installer/commands/update.js +80 -74
  10. package/dist/installer/commands/update.js.map +1 -1
  11. package/dist/installer/commands/v5-migration.js +14 -0
  12. package/dist/installer/commands/v5-migration.js.map +1 -1
  13. package/dist/installer/phases/framework-lifecycle.js +2 -0
  14. package/dist/installer/phases/framework-lifecycle.js.map +1 -1
  15. package/dist/installer/phases/scaffold.js +191 -258
  16. package/dist/installer/phases/scaffold.js.map +1 -1
  17. package/dist/installer/runtime/pipeline-state.js +801 -0
  18. package/dist/installer/runtime/pipeline-state.js.map +1 -0
  19. package/dist/installer/util/exec.js +6 -1
  20. package/dist/installer/util/exec.js.map +1 -1
  21. package/dist/installer/util/fs.js +11 -2
  22. package/dist/installer/util/fs.js.map +1 -1
  23. package/dist/installer/util/install-transaction.js +246 -0
  24. package/dist/installer/util/install-transaction.js.map +1 -0
  25. package/dist/installer/util/registry.js +20 -0
  26. package/dist/installer/util/registry.js.map +1 -1
  27. package/docs/ci-cd.md +57 -0
  28. package/docs/user-docs/codex-vs-claude-code.md +23 -151
  29. package/docs/user-docs/core-updates.md +70 -0
  30. package/docs/user-docs/provider-pipelines.md +53 -0
  31. package/integration-contract.json +179 -66
  32. package/package.json +5 -2
  33. package/templates/agents/sr-developer.md +9 -11
  34. package/templates/agents/sr-reviewer.md +26 -33
  35. package/templates/codex-skills/batch-implement/SKILL.md +58 -244
  36. package/templates/codex-skills/implement/SKILL.md +136 -338
  37. package/templates/codex-skills/rails/sr-architect/SKILL.md +7 -0
  38. package/templates/codex-skills/rails/sr-developer/SKILL.md +13 -0
  39. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +39 -5
  40. package/templates/codex-skills/retry/SKILL.md +37 -117
  41. package/templates/commands/specrails/batch-implement.md +16 -288
  42. package/templates/commands/specrails/implement.md +62 -1057
  43. package/templates/commands/specrails/retry.md +22 -314
  44. package/templates/gemini-commands/batch-implement.toml +28 -40
  45. package/templates/gemini-commands/implement.toml +55 -114
  46. package/templates/gemini-commands/retry.toml +21 -0
  47. package/templates/kimi/specrails/run-skill.mjs +51 -2
  48. package/templates/runtime/provider-pipeline.md +55 -0
@@ -1,249 +1,63 @@
1
1
  ---
2
2
  name: batch-implement
3
- description: "Run the implement pipeline over multiple backlog tickets in one session. Per ticket: spawn architect → spawn developer → spawn reviewer (the same three-phase pipeline $implement runs), then move to the next. Sequential by default; parallel only when the user explicitly opts in AND the tickets are independent. Reports an aggregated verdict at the end. Use when the user invokes `$batch-implement #N #M #K` or `$batch-implement --status todo`."
3
+ description: "Implement the frozen batch in one OpenSpec change and journal, with aggregate verification, review and archive gates."
4
4
  license: MIT
5
- compatibility: "Codex-native. Fully headless / non-interactive. Drives architect/developer/reviewer spawns at the ROOT agent level — does NOT spawn a nested $implement sub-agent per ticket (codex's nested-spawn reliability degrades at depth 2, causing sub-agents to skip phases silently). Sub-agents are full-history forks (no agent_type / model / reasoning_effort)."
5
+ compatibility: "Codex-native root-level role delegation. One aggregate change per run; hosted worktrees stay under host ownership."
6
6
  ---
7
7
 
8
- You are the **batch-implement orchestrator**. The user invoked
9
- you to apply the implement pipeline to multiple tickets in one
10
- session.
11
-
12
- **This skill is fully headless / non-interactive.** Every
13
- sub-agent invocation must include `--yes` semantics. There is
14
- no "interactive mode". If you find yourself thinking "the
15
- batch skill is interactive by design, let me run inline
16
- instead", you're misreading.
17
-
18
- ## Why this skill drives the pipeline directly
19
-
20
- An earlier design spawned a `$implement` sub-agent per ticket
21
- that itself spawned architect/developer/reviewer sub-sub-agents.
22
- That worked technically but was **unreliable in practice**:
23
- codex's nested-spawn at depth 2 frequently dropped the reviewer
24
- phase (and sometimes the architect), leaving tickets reported as
25
- "done" with no confidence artefact and stale backlog state.
26
-
27
- This skill therefore runs the **same three-phase pipeline
28
- `$implement` runs**, but it drives the spawns from the root
29
- agent (you) instead of nesting. Per ticket you spawn architect,
30
- developer, and reviewer at depth 1 — three real sub-agents per
31
- ticket, no more nesting. The contract that `$implement` enforces
32
- (every phase MUST be a real spawn) applies here too.
33
-
34
- ## How the user invokes you
35
-
36
- - `$batch-implement #1 #2 #3 --yes` — sequential.
37
- - `$batch-implement --status todo` — every todo ticket, ascending
38
- id order.
39
- - `$batch-implement --status todo --priority high` — combined
40
- filter.
41
- - `$batch-implement #1 #2 --parallel` — opt-in parallel, with a
42
- disjoint-file safety check (see Step 2.b).
43
-
44
- Default execution mode is sequential.
45
-
46
- ## Desktop rail execution context
47
-
48
- When the working directory is a specrails-desktop isolated rail worktree (path contains `/worktrees/`, typically on a `feat/...` branch), you are the ASSIGNED executor of that rail: implement every ticket sequentially in THIS worktree on THIS branch — the desktop assembles it into a batch PR afterwards, nothing needs to land on the integration branch first. The desktop's own bookkeeping (ticket-ownership rows in its `jobs.sqlite`, state under `~/.specrails/`) describes this very launch — never read those internals, and never stop to ask which process should run the batch.
49
-
50
- ## Steps
51
-
52
- ### 0. Bootstrap
53
-
54
- 1. Confirm `pwd` matches `git rev-parse --show-toplevel`.
55
- 2. Parse argv: collect `#N` tokens + filter flags (`--status`,
56
- `--priority`, `--parallel`).
57
- 3. Build the target list:
58
- - Explicit ids → use them in given order.
59
- - Otherwise filter `.specrails/local-tickets.json` by
60
- `--status`/`--priority` and sort numeric id ascending.
61
- 4. If empty target list, reply
62
- `"NO-OP: no tickets match the filter"` and end.
63
- 5. **List installed rails** once:
64
- `ls .codex/skills/rails/`. Cache the set; you'll reuse it
65
- for routing each ticket's developer + reviewer phase.
66
- 6. State (≤4 lines) which tickets you're processing, in what
67
- mode, and the available rails.
68
-
69
- ### 1. Sequential pipeline (default)
70
-
71
- For each ticket id in order, run the three-phase pipeline at
72
- ROOT level (do NOT spawn `$implement` as a sub-agent — drive
73
- the pipeline yourself):
74
-
75
- #### 1.a Architect phase (per ticket)
76
-
77
- - `spawn_agent` (full-history, no agent_type / model /
78
- reasoning_effort).
79
- - `send_message`:
80
-
81
- > `$sr-architect`
82
- >
83
- > Ticket id: `<TICKET_ID>`
84
- > Ticket title: `<TICKET_TITLE>`
85
- >
86
- > Read `jq '.tickets["<TICKET_ID>"]' .specrails/local-tickets.json`
87
- > for the full ticket. Follow the `$sr-architect` skill
88
- > instructions exactly.
89
-
90
- - `wait_agent`. Parse reply for the plan path. `close_agent`.
91
- - Open the plan + design.md.
92
- - If the architect returned `BLOCKED: …`, mark this ticket
93
- as failed for the batch report and **continue to the next
94
- ticket** — do not stop the batch.
95
-
96
- #### 1.b Developer phase (per ticket)
97
-
98
- One developer rail. Unless a profile routes the ticket to a
99
- listed `custom-*` developer, spawn `$sr-developer`.
100
-
101
- - `spawn_agent`. `send_message`:
102
-
103
- > `$sr-developer`
104
- >
105
- > Ticket id: `<TICKET_ID>`
106
- > Plan: `<PLAN_PATH>`
107
- >
108
- > Follow the `$sr-developer` skill instructions exactly.
109
-
110
- - `wait_agent`. Capture file list. `close_agent`.
111
- - If `BLOCKED: …` → mark ticket as failed in the batch report
112
- and move to next ticket.
113
-
114
- #### 1.c Reviewer phase (per ticket)
115
-
116
- Spawn the single `$sr-reviewer` — it covers correctness, tests,
117
- security, and performance. `wait_agent`, then `close_agent`.
118
-
119
- Verdict (same matrix as `$implement`):
120
-
121
- - `clean` — every reviewer ≥70, no fix/blocked verdicts.
122
- - `fix needed` — any "fix needed", OR score <70 with no
123
- blocked, OR blocked with score 30-69 (recoverable case).
124
- - `blocked` — blocked with score <30, OR all reviewers blocked.
125
-
126
- #### 1.d Optional fix loop (single pass per ticket)
127
-
128
- If the verdict is `fix needed`, run ONE follow-up developer
129
- pass with the reviewer's issues list, then re-run the
130
- reviewer set. If still `fix needed` or `blocked`, do NOT
131
- loop again — record the failure in the batch report and
132
- continue.
133
-
134
- #### 1.e Close the ticket (per ticket)
135
-
136
- If the final verdict is `clean`:
137
- - Update `.specrails/local-tickets.json` — set
138
- `tickets["<ID>"].status = "done"`, bump `revision`, set
139
- `updated_at` to `date -Iseconds`. Preserve every other
140
- field.
141
-
142
- If the verdict is `fix needed` or `blocked`:
143
- - Leave status as `todo`. Still bump `revision` and set
144
- `updated_at` so the file reflects the run. Record the
145
- blocker in the batch report's Follow-up section.
146
-
147
- **Important**: only YOU (the root orchestrator) ever writes
148
- to `.specrails/local-tickets.json`. None of the sub-agents
149
- (architect, developer, reviewer) should touch it — the rail
150
- skills already enforce that on their side.
151
-
152
- ### 2. Parallel pipeline (opt-in via `--parallel`)
153
-
154
- When the user passed `--parallel`:
155
-
156
- a. **Pre-spawn architect-only pass**. For each ticket, spawn
157
- `$sr-architect` in parallel via `spawn_agents_on_csv`
158
- (cap at 10 concurrent). Wait for each to produce its
159
- `tasks.md` + plan path.
160
- b. **Disjoint-file check**. Collect every file path mentioned
161
- across all `tasks.md` files. If ANY file appears in more
162
- than one ticket's list, abort parallel mode for the
163
- overlapping tickets — process them sequentially after the
164
- non-overlapping batch. State in your reply which tickets
165
- were re-routed and why.
166
- c. For the non-overlapping tickets, run their developer +
167
- reviewer phases (and optional fix-loop) in parallel
168
- per-ticket. Each ticket is still a sequence
169
- internally — only the outer per-ticket processing is
170
- concurrent.
171
-
172
- The safety net exists because two developer pipelines editing
173
- the same file would race. If unsure, fall back to sequential.
174
-
175
- ### 3. Aggregate the batch
176
-
177
- For each ticket, collect:
178
-
179
- - `ticket_id`
180
- - `verdict`: `done` | `todo` | `blocked` | `arch_blocked`
181
- - `score`: overall (or `n/a` if no reviewer ran)
182
- - `plan_path`, `confidence_path` (omit if `n/a`)
183
- - `files_changed`: list (or `n/a`)
184
- - `tests_summary`, `build_summary`
185
- - Any Follow-up bullets
186
-
187
- ### 4. Report
188
-
189
- Print ONE consolidated summary (≤30 lines for typical
190
- batches):
191
-
192
- ```
193
- batch-implement — <N> tickets attempted
194
-
195
- Outcomes:
196
- done: #<id> #<id> ...
197
- todo: #<id> (reason: …) ...
198
- blocked: #<id> (reason: …) ...
199
-
200
- Per-ticket details:
201
- #<id> → <verdict> (score <N>/100)
202
- plan: <path>
203
- confidence: <path>
204
- files: <count> (<one path>, +N more)
205
- tests: <pass/fail summary>
206
-
207
- Aggregate stats:
208
- Files touched: <total unique count>
209
- Tests run: <total>, pass <count>, fail <count>
210
- Build: <count where ran, count ok, count failed>
211
-
212
- Follow-up across batch:
213
- - <bullet> (#<id>)
214
- - ...
215
- ```
216
-
217
- If every ticket ended in `done`, also print:
218
-
219
- ```
220
- ✓ Batch complete: <N>/<N> tickets done.
221
- ```
222
-
223
- If some ended in `todo` or `blocked`, finish with the
224
- re-launch hint:
225
-
226
- ```
227
- Re-run with: $batch-implement #<id> [#<id> ...] --yes
228
- ```
229
-
230
- ## What you must NOT do
231
-
232
- - **Do NOT spawn `$implement` as a sub-agent** to handle a
233
- ticket. Drive the architect/developer/reviewer pipeline
234
- yourself, at depth 1 (root → role-skill). Nested spawning
235
- at depth 2 drops phases silently and produces "done"
236
- tickets with no confidence artefact.
237
- - **Do NOT pass `agent_type`, `model`, or `reasoning_effort`**
238
- to `spawn_agent` on full-history forks.
239
- - **Do NOT proceed in parallel mode** without the
240
- disjoint-file check.
241
- - **Do NOT exceed 10 parallel sub-agents** in one fan-out.
242
- - **Do NOT do speculative work** (sed/find/grep/etc.) while
243
- a sub-agent is running. Wait silently for `wait_agent`.
244
- - **Do NOT touch `.claude/agent-memory/`** — codex projects
245
- use `.specrails/agent-memory/`.
246
- - **Do NOT skip a phase**. Every ticket gets architect →
247
- developer → reviewer (+ fix loop if needed). A ticket
248
- reported as "done" without a confidence artefact is a
249
- contract violation.
8
+ You coordinate one batch run. Explicit #IDs retain their order; filters resolve
9
+ against the shared backlog. Freeze the full ticket descriptions, acceptance criteria
10
+ and repository IDs once. With host context use its complete specs unchanged.
11
+
12
+ Initialize ONE stable aggregate change slug and journal for the batch. Do not
13
+ initialize another change with the same runId or create child per-ticket journals.
14
+ Resolve source via context.repositories, OpenSpec via context.artifactRoot, and
15
+ backlog via context.backlogPath/backlogRoot; cwd can be an external workspace.
16
+
17
+ Read the single implement role instructions, but execute the following aggregate
18
+ pipeline DIRECTLY from this root. Do NOT spawn `$implement` as a sub-agent.
19
+ Each role receives the explicit bounded handoff including ALL frozen specs and
20
+ repository paths, aggregate change slug and already completed task groups.
21
+
22
+ 1. Architect: one `$sr-architect` creates and validates one change covering every
23
+ ticket, grouping tasks by ticket and repository and recording dependency order.
24
+ Record architect running/done via the helper. Require high/medium design
25
+ confidence. Missing or low confidence blocks development; never infer a pass.
26
+ 2. Developer: one `$sr-developer` applies the task groups sequentially, preserving
27
+ preceding groups and all repositories. Persist per-group progress in tasks.md
28
+ before yielding. Scoped checks run per group; the full verification gate runs
29
+ once for the aggregate candidate through the helper. Only then record developer
30
+ done. Incomplete groups block downstream review and remain retriable.
31
+ 3. Reviewer: one `$sr-reviewer` semantically checks every ticket/criterion and
32
+ cross-ticket interaction. Include the full receipt and changed-file inventory.
33
+ Ordinary review does NOT archive. If recoverable findings need changes, invoke
34
+ developer once with the exact findings and re-review. Missing/ambiguous verdicts
35
+ and stale receipts never become done; record blocked/failed with a next action.
36
+ 4. Archive: after semantic reviewer done and canonical confidence thresholds from
37
+ implement pass (including security), run `archive-check`. Only success permits
38
+ `$sr-reviewer` with ARCHIVE_ONLY=true and ARCHIVE_AUTHORIZED=true. Validate the
39
+ archive exists and active change is absent; record archive done. Failure leaves
40
+ EVERY batch ticket open.
41
+ 5. Delivery/CI: follow implement ownership exactly. Host-owned Git records ship/ci
42
+ skipped and returns evidence; Core-owned authorized delivery records each selected
43
+ repository outcome and required CI. Partial delivery keeps the batch incomplete.
44
+ 6. Backlog: only Core-owned backlog may close participating tickets at
45
+ context.backlogPath after required delivery and live-vs-frozen requirements match.
46
+ Preserve unrelated data and revisions. Host-owned backlog stays untouched.
47
+
48
+ Before any role, inspect status.resumePhase; reuse every still-valid phase without
49
+ respawning. Use available worker capabilities and capability-aware cleanup from
50
+ implement; never invent close_agent or native model override support.
51
+
52
+ On a provider turn limit, continue the same role from explicit saved progress;
53
+ never launch a nested coordinator or repeat valid earlier stages. Retry resumes
54
+ this same aggregate change/journal. Two continuations without progress block.
55
+
56
+ `--parallel` is a preference, not permission to create unmanaged worktrees or
57
+ assume ten available agent slots. The aggregate pipeline is sequential by default;
58
+ keep hosted worktrees in the supplied repositories. Do not claim parallel work
59
+ when it did not run. Do not override models on a full-history fork.
60
+
61
+ Report one table with every ticket and actual implemented/reviewed outcome, the
62
+ aggregate verification receipt, archive result and outstanding groups. No ticket
63
+ is done until the whole aggregate close succeeds.