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
@@ -122,12 +122,14 @@ If `AGENT_FILTER` is set (single-agent mode), show the full content of each file
122
122
 
123
123
  ## Phase 4: Orphan Detection
124
124
 
125
- An **orphaned** memory directory is one whose agent name does not correspond to a known sr-agent persona.
125
+ An **orphaned** memory directory is one whose agent name does not correspond to a known agent.
126
126
 
127
- Known sr-agent names (check for exact match):
128
- `sr-architect`, `sr-developer`, `sr-test-writer`, `sr-reviewer`, `sr-frontend-reviewer`, `sr-backend-reviewer`, `sr-security-reviewer`, `sr-doc-sync`, `sr-product-manager`
127
+ Known agent names (check for exact match):
128
+ `sr-architect`, `sr-developer`, `sr-reviewer`
129
129
 
130
- For each directory in `AGENT_DIRS`, check whether its `AGENT_NAME` is in the known list. Collect non-matching directories as `ORPHANED_DIRS`.
130
+ Any directory whose name begins with `custom-` is a user- or profile-owned agent and is **never** orphaned — treat the `custom-` prefix as known.
131
+
132
+ For each directory in `AGENT_DIRS`, check whether its `AGENT_NAME` is in the known list (or carries the `custom-` prefix). Collect non-matching directories as `ORPHANED_DIRS`.
131
133
 
132
134
  If `ORPHANED_DIRS` is non-empty, print:
133
135
 
@@ -66,7 +66,7 @@ Set the following fields:
66
66
  - `priority`: Map Estimated Complexity — Low → `"low"`, Medium → `"medium"`, High/Very High → `"high"`
67
67
  - `labels`: `["spec-proposal"]`
68
68
  - `source`: `"propose-spec"`
69
- - `created_by`: `"sr-product-engineer"`
69
+ - `created_by`: `"sr-architect"`
70
70
 
71
71
  Print: `Created local ticket #{id}: {title}`
72
72
 
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: "Refactor Recommender"
3
- description: "Scan the codebase for refactoring opportunities ranked by impact/effort ratio and VPC persona value. Analyzes code for duplicates, long functions, large files, dead code, outdated patterns, and complex logic. Optionally creates GitHub Issues for tracking."
3
+ description: "Scan the codebase for refactoring opportunities ranked by impact/effort ratio. Analyzes code for duplicates, long functions, large files, dead code, outdated patterns, and complex logic. Optionally creates GitHub Issues for tracking."
4
4
  category: Workflow
5
- tags: [workflow, refactoring, code-quality, tech-debt, vpc]
5
+ tags: [workflow, refactoring, code-quality, tech-debt]
6
6
  ---
7
7
 
8
- Scan the codebase for refactoring opportunities, score each by impact/effort ratio and VPC persona value, and optionally create GitHub Issues for the top findings in {{BACKLOG_PROVIDER_NAME}}.
8
+ Scan the codebase for refactoring opportunities, score each by impact/effort ratio, and optionally create GitHub Issues for the top findings in {{BACKLOG_PROVIDER_NAME}}.
9
9
 
10
10
  **Input:** `$ARGUMENTS` — optional: comma-separated paths to scope the analysis. Flags: `--dry-run` (print findings without creating issues).
11
11
 
@@ -38,27 +38,6 @@ Always exclude the following from all analysis:
38
38
 
39
39
  ---
40
40
 
41
- ## Phase 1.5: VPC Context
42
-
43
- Check whether persona files exist at `.claude/agents/personas/`. This path is present in any repo that has run `/specrails:enrich`.
44
-
45
- ```bash
46
- ls .claude/agents/personas/ 2>/dev/null
47
- ```
48
-
49
- If the directory exists and contains persona files, set `VPC_AVAILABLE=true`. Otherwise set `VPC_AVAILABLE=false` and skip all VPC steps (they are optional enrichment, not blockers).
50
-
51
- When `VPC_AVAILABLE=true`, read each persona file and extract a compact VPC summary. For each persona record:
52
-
53
- - **name** — persona display name (e.g. "Alex — The Lead Dev")
54
- - **top_jobs** — up to 3 functional jobs relevant to code quality and maintainability
55
- - **critical_pains** — up to 3 pains marked Critical or High related to code reliability, complexity, or developer experience
56
- - **high_gains** — up to 3 gains marked High related to code clarity, speed, or confidence
57
-
58
- Store these as an in-memory `VPC_PROFILES` list. You will use it in Phase 3 to score persona fit.
59
-
60
- ---
61
-
62
41
  ## Phase 2: Analysis
63
42
 
64
43
  Analyze the scoped files across six categories. For each finding record:
@@ -97,24 +76,12 @@ Find deeply nested conditionals (more than 3 levels) and functions with high cyc
97
76
 
98
77
  ## Phase 3: Score and Rank
99
78
 
100
- Score every finding on three dimensions (1–5 each):
79
+ Score every finding on two dimensions (1–5 each):
101
80
 
102
81
  - **Impact** — how much the refactoring improves code quality, readability, or maintainability
103
82
  - **Effort** — how hard the refactoring is to implement (1 = trivial, 5 = major)
104
- - **VPC Value** — how directly this refactoring addresses persona jobs, pains, or gains (1 = no relevance, 5 = resolves a critical persona pain or delivers a high-value gain). Set to 3 when `VPC_AVAILABLE=false`.
105
-
106
- **Scoring VPC Value** (only when `VPC_AVAILABLE=true`):
107
-
108
- For each finding, reason over `VPC_PROFILES`:
109
83
 
110
- - Does fixing this reduce a **Critical/High pain** for any persona? (e.g. complex logic → harder to trust AI output → Alex's "agents go off the rails" pain) → score 4–5
111
- - Does fixing this deliver a **High gain** for any persona? (e.g. extracting a function → cleaner API surface → easier onboarding → Sara's gain) → score 3–4
112
- - Is there indirect persona value? (e.g. dead code removal → smaller codebase → easier contributor review → Kai) → score 2–3
113
- - No clear persona relevance → score 1–2
114
-
115
- Assign one `vpc_value` integer per finding, and note the **primary persona** and **rationale** (one sentence).
116
-
117
- **Composite score**: `impact * 2 + (6 - effort) + vpc_value`. Higher is better.
84
+ **Composite score**: `impact * 2 + (6 - effort)`. Higher is better.
118
85
 
119
86
  Sort all findings by composite score descending. If the same code block was flagged by multiple categories, keep only the highest-scored entry and discard the duplicates.
120
87
 
@@ -144,7 +111,6 @@ For each of the **top 5** findings (by composite score) that does not already ha
144
111
  **Category**: {category}
145
112
  **File**: {file}:{line_range}
146
113
  **Impact**: {impact}/5 | **Effort**: {effort}/5 | **Score**: {composite}
147
- {vpc_line}
148
114
 
149
115
  ### Current Code
150
116
  ```{lang}
@@ -163,9 +129,6 @@ For each of the **top 5** findings (by composite score) that does not already ha
163
129
  _Generated by `/specrails:refactor-recommender` in {{PROJECT_NAME}}_
164
130
  ```
165
131
 
166
- Where `{vpc_line}` is included only when `VPC_AVAILABLE=true`:
167
- `**VPC Value**: {vpc_value}/5 — {vpc_persona}: {vpc_rationale}`
168
-
169
132
  ---
170
133
 
171
134
  ## Phase 5: Output Summary
@@ -176,11 +139,10 @@ Print the following report:
176
139
  ## Refactoring Opportunities — {{PROJECT_NAME}}
177
140
 
178
141
  {N} opportunities found | Sorted by composite score
179
- {vpc_header}
180
142
 
181
- | # | Category | File | Impact | Effort | VPC | Score | Description |
182
- |---|----------|------|--------|--------|-----|-------|-------------|
183
- | 1 | {category} | {file}:{line_range} | {impact}/5 | {effort}/5 | {vpc_value}/5 | {composite} | {description} |
143
+ | # | Category | File | Impact | Effort | Score | Description |
144
+ |---|----------|------|--------|--------|-------|-------------|
145
+ | 1 | {category} | {file}:{line_range} | {impact}/5 | {effort}/5 | {composite} | {description} |
184
146
  ...
185
147
 
186
148
  ### Top 3 Detailed Recommendations
@@ -188,7 +150,6 @@ Print the following report:
188
150
  #### 1. {description}
189
151
  **File**: {file}:{line_range}
190
152
  **Category**: {category} | **Score**: {composite}
191
- {vpc_detail}
192
153
 
193
154
  **Current:**
194
155
  ```{lang}
@@ -206,7 +167,3 @@ Print the following report:
206
167
 
207
168
  Issues created: {N} (or "dry-run: no issues created")
208
169
  ```
209
-
210
- Where:
211
- - `{vpc_header}` is `VPC personas loaded: {persona names}` when `VPC_AVAILABLE=true`, or `VPC personas: not found (run /specrails:enrich to enable)` otherwise.
212
- - `{vpc_detail}` is `**VPC Value**: {vpc_value}/5 — {vpc_persona}: {vpc_rationale}` when `VPC_AVAILABLE=true`, omitted otherwise.
@@ -1,366 +1,38 @@
1
- ---
2
- name: "Smart Failure Recovery"
3
- description: "Resume a failed /specrails:implement pipeline from the last successful phase without restarting from scratch."
4
- category: Workflow
5
- tags: [workflow, recovery, retry, resilience]
6
- phases:
7
- - key: load
8
- label: Load State
9
- description: "Read pipeline state from disk and identify the resume point"
10
- - key: resume
11
- label: Resume
12
- description: "Execute remaining phases starting from the failed phase"
13
- - key: report
14
- label: Report
15
- description: "Print a final status report with outcomes and next steps"
16
- ---
1
+ # Retry an Implementation Pipeline
17
2
 
18
- Resume a failed `/specrails:implement` run for **{{PROJECT_NAME}}**. Reads pipeline state written by the implement pipeline to identify which phases completed and which failed, then re-executes only the remaining phases.
3
+ **Input:** $ARGUMENTS — existing change and optional --from <phase>.
19
4
 
20
- **MANDATORY: Follow this pipeline exactly. Do NOT skip phases or re-run phases that already succeeded. Read all context from the pipeline state file — do not rely on memory. Do not re-implement anything yourself; delegate to the same agents used by `/specrails:implement`.**
5
+ ## Resolve the exact run
21
6
 
22
- **Repository location.** Your working directory may NOT be the user's source repository. Repo-resident things — `openspec/**`, source, `.git`, the GitHub remote — live under **`${SPECRAILS_REPO_DIR:-.}`** (set by the spawner; unset ⇒ `.` ⇒ byte-identical to a classic in-repo run). The pipeline-state file itself is **run-state**, read from `.claude/pipeline-state/` relative to the working directory — do NOT prefix it. The `openspec_artifacts` value stored in that file is a repo-relative path (`openspec/changes/<name>/`); prefix it with `${SPECRAILS_REPO_DIR:-.}/` when you read those files on disk. All git/PR operations are delegated to `/specrails:implement` Phase 4c, which already runs them against the repo.
23
-
24
- **Input:** $ARGUMENTS — accepted forms:
25
-
26
- 1. `<feature-name>` — kebab-case feature name matching a `.claude/pipeline-state/<feature-name>.json` file
27
- 2. `--list` — list all available pipeline state files and their current status, then exit
28
- 3. `<feature-name> --from <phase>` — force resume from a specific phase (overrides auto-detection)
29
- 4. `<feature-name> --dry-run` — override to resume in dry-run mode (no git/PR operations)
30
-
31
- ---
32
-
33
- ## Phase 0: Parse Input
34
-
35
- Scan `$ARGUMENTS` for flags:
36
-
37
- - `--list`: if present, set `LIST_ONLY=true`.
38
- - `--from <phase>`: if present, set `RESUME_FROM_OVERRIDE=<phase>`. Valid values: `architect`, `developer`, `test-writer`, `doc-sync`, `reviewer`, `ship`, `ci`.
39
- - `--dry-run`: if present, set `DRY_RUN_OVERRIDE=true`.
40
-
41
- Extract the first positional argument (not starting with `--`) as `FEATURE_NAME`.
42
-
43
- **If `--list`:** scan `.claude/pipeline-state/*.json`. For each file found, parse and print:
44
-
45
- ```
46
- ## Available Pipeline States
47
-
48
- | Feature | Last Successful Phase | Failed Phase | Updated At |
49
- |---------|----------------------|--------------|------------|
50
- | <name> | <phase or —> | <phase or —> | <ISO time> |
51
- ```
52
-
53
- If no files found: print `No pipeline state files found. Run /specrails:implement first.`
54
-
55
- Exit after printing — do not proceed.
56
-
57
- **If no positional argument and no `--list`:** print the following usage and exit:
58
-
59
- ```
60
- Usage: /specrails:retry <feature-name> [--from <phase>] [--dry-run]
61
- /specrails:retry --list
62
-
63
- Phases: architect | developer | test-writer | doc-sync | reviewer | ship | ci
64
- ```
65
-
66
- ---
67
-
68
- ## Phase 1: Load Pipeline State
69
-
70
- Read: `.claude/pipeline-state/<FEATURE_NAME>.json`
71
-
72
- If the file does not exist:
73
-
74
- ```
75
- [retry] Error: no pipeline state found for "<FEATURE_NAME>".
76
-
77
- Run /specrails:retry --list to see available states, or start a new run:
78
- /specrails:implement <your input>
79
- ```
80
-
81
- Exit.
82
-
83
- Parse the state file and set the following variables:
84
-
85
- - `LAST_SUCCESSFUL_PHASE` ← `last_successful_phase` (may be `null`)
86
- - `FAILED_PHASE` ← `failed_phase` (may be `null`)
87
- - `ERROR_CONTEXT` ← `error_context` (may be `null`)
88
- - `OPENSPEC_ARTIFACTS` ← `openspec_artifacts` (e.g. `openspec/changes/<name>/`)
89
- - `IMPLEMENTED_FILES` ← `implemented_files` (array, may be empty)
90
- - `ORIGINAL_ISSUES` ← `input.issues` (array of issue numbers, may be `null`)
91
- - `ORIGINAL_INPUT_FLAGS` ← `input.flags` object
92
- - `SINGLE_MODE` ← `input.flags.single_mode` (default `true`)
93
- - `DRY_RUN` ← if `DRY_RUN_OVERRIDE=true` then `true`, else `input.flags.dry_run` (default `false`)
94
- - `PHASE_STATUSES` ← `phases` map (`architect`, `developer`, `test-writer`, `doc-sync`, `reviewer`, `ship`, `ci` → `"done"`, `"failed"`, `"skipped"`, or `"pending"`)
95
-
96
- **Validation:**
97
-
98
- - If all phases are `"pending"`: the pipeline never reached any execution. Print:
99
- ```
100
- [retry] Warning: all phases are pending — the pipeline may not have started.
101
- Recommend running /specrails:implement instead.
102
- ```
103
- Prompt: `Proceed anyway? [y/N]`. If `n` or no response: exit.
104
-
105
- ---
106
-
107
- ## Phase 2: Status Report
108
-
109
- Print the pipeline status:
110
-
111
- ```
112
- ## Pipeline State: <FEATURE_NAME>
113
-
114
- | Phase | Status | Notes |
115
- |--------------|---------|-------------------------------------|
116
- | architect | done | |
117
- | developer | done | |
118
- | test-writer | FAILED | <ERROR_CONTEXT or "no details"> |
119
- | doc-sync | pending | |
120
- | reviewer | pending | |
121
- | ship | pending | |
122
- | ci | pending | |
123
-
124
- Last successful phase : <LAST_SUCCESSFUL_PHASE or "none">
125
- Failed phase : <FAILED_PHASE or "—">
126
- Error context : <ERROR_CONTEXT or "no details recorded">
127
- OpenSpec artifacts : <OPENSPEC_ARTIFACTS>
128
- Implemented files : <count> file(s) tracked
129
- Original input : <issues list or "text description">
130
- ```
131
-
132
- ---
133
-
134
- ## Phase 3: Determine Resume Point
135
-
136
- **Phase execution order (canonical):**
137
-
138
- ```
139
- architect → developer → test-writer → doc-sync → reviewer → ship → ci
140
- ```
141
-
142
- **If `RESUME_FROM_OVERRIDE` is set:** use it as `RESUME_PHASE`. Validate it is one of the canonical values; if not, print an error and exit.
143
-
144
- **Otherwise, auto-detect:**
145
-
146
- 1. If `FAILED_PHASE` is set: `RESUME_PHASE = FAILED_PHASE`.
147
- 2. Else if `LAST_SUCCESSFUL_PHASE` is set: `RESUME_PHASE` = the next phase after `LAST_SUCCESSFUL_PHASE` in canonical order.
148
- 3. Else: `RESUME_PHASE = architect` (no phases completed).
149
-
150
- Print the resume plan:
151
-
152
- ```
153
- ## Resume Plan
154
-
155
- Resuming from phase: <RESUME_PHASE>
156
-
157
- Phases to skip (already done):
158
- ✓ <phase> (done)
159
- ✓ <phase> (done)
160
-
161
- Phases to execute:
162
- ► <RESUME_PHASE> (resuming here)
163
- · <next-phase>
164
- · <next-phase>
165
- ...
166
- ```
167
-
168
- Prompt the user:
169
-
170
- ```
171
- Proceed? [Y/n]
172
- ```
173
-
174
- If `n` or no response: exit without changes.
175
-
176
- ---
177
-
178
- ## Phase 4: Execute Remaining Phases
179
-
180
- Execute phases in canonical order starting from `RESUME_PHASE`. For each phase:
181
-
182
- - If its status in `PHASE_STATUSES` is `"skipped"`: **skip** — the agent was not installed at the original run (e.g. an optional sr-test-writer / sr-doc-sync). Never launch a phase that was skipped, regardless of its position relative to `RESUME_PHASE`.
183
- - If its status in `PHASE_STATUSES` is `"done"` AND it precedes `RESUME_PHASE` in canonical order: **skip** — do not re-run.
184
- - If it equals `RESUME_PHASE` or comes after (and is not `"skipped"`): **run** it.
185
-
186
- After each phase completes (or fails), update `.claude/pipeline-state/<FEATURE_NAME>.json`:
187
- 1. Read the current file.
188
- 2. Set `phases.<phase-key>` to `"done"` or `"failed"`.
189
- 3. If `"done"`: update `last_successful_phase`.
190
- 4. If `"failed"`: update `failed_phase` and `error_context`.
191
- 5. Update `updated_at` to current ISO 8601 timestamp.
192
- 6. Overwrite the file.
193
-
194
- ---
195
-
196
- ### 4a. Phase: architect
197
-
198
- **Only runs if `RESUME_PHASE=architect`.**
199
-
200
- Verify that `ORIGINAL_ISSUES` is non-empty or a text description is recoverable. If neither is available: print an error and stop — the original input is required to re-run the architect.
201
-
202
- Launch **sr-architect** agent(s) exactly as described in Phase 3a of the implement pipeline. Pass:
203
- - Original issue numbers from `ORIGINAL_ISSUES` (or text description if stored in state)
204
- - Same OpenSpec output directory: `OPENSPEC_ARTIFACTS`
205
-
206
- Wait for all architects to complete.
207
-
208
- **Pipeline state update:** `architect` → `done` or `failed`.
209
-
210
- ---
211
-
212
- ### 4b. Phase: developer
213
-
214
- **Runs if `RESUME_PHASE` is `architect` or `developer`.**
215
-
216
- Before launching, verify architect artifacts exist:
7
+ Use the same absolute SPECRAILS_PIPELINE_RUNTIME and SPECRAILS_EXECUTION_CONTEXT. The managed fallback is .specrails/runtime/pipeline.mjs; the standalone workspace pointer is only discovery. Do not initialize another run, choose the newest change, replace frozen tickets from mutable backlog, or trust old ad-hoc pipeline state.
217
8
 
218
9
  ```bash
219
- ls "${SPECRAILS_REPO_DIR:-.}/<OPENSPEC_ARTIFACTS>tasks.md" "${SPECRAILS_REPO_DIR:-.}/<OPENSPEC_ARTIFACTS>context-bundle.md"
220
- ```
221
-
222
- If missing and `RESUME_PHASE=developer`: print:
223
-
224
- ```
225
- [retry] Error: architect artifacts not found at <OPENSPEC_ARTIFACTS>.
226
- Retry from the architect phase: /specrails:retry <FEATURE_NAME> --from architect
10
+ node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" status --json
227
11
  ```
228
12
 
229
- Stop.
230
-
231
- Launch **sr-developer** agent(s) exactly as described in Phase 3b of the implement pipeline.
232
-
233
- - If `SINGLE_MODE=true`: launch in main repo, foreground.
234
- - If `SINGLE_MODE=false`: launch in isolated worktrees, background.
235
- - If `DRY_RUN=true`: use the dry-run redirect instructions from Phase 3b.
236
-
237
- Wait for all developers to complete. Collect the list of files created or modified.
238
-
239
- **Pipeline state update:** `developer` → `done` (also update `implemented_files` in state with the collected file list) or `failed`.
240
-
241
- ---
242
-
243
- ### 4c. Phase: test-writer
244
-
245
- **Runs if `RESUME_PHASE` is `architect`, `developer`, or `test-writer`.**
246
-
247
- If `IMPLEMENTED_FILES` is empty: warn but continue — the sr-test-writer will discover files from git diff.
248
-
249
- Launch **sr-test-writer** agent(s) exactly as in Phase 3c of the implement pipeline. Pass:
250
- - `IMPLEMENTED_FILES_LIST`: the `implemented_files` array from state
251
- - `TASK_DESCRIPTION`: derived from `ORIGINAL_ISSUES` or architect artifacts
252
-
253
- Wait for completion. Failure is **non-blocking** — record `FAILED` and continue to next phase.
254
-
255
- **Pipeline state update:** `test-writer` → `done` or `failed`.
256
-
257
- ---
258
-
259
- ### 4d. Phase: doc-sync
260
-
261
- **Runs if `RESUME_PHASE` is any phase up to and including `doc-sync`.**
13
+ Verify runId/change match. Preserve context.specs, selected roots, backlog identity and ownership. The artifact compatibility root is `${SPECRAILS_REPO_DIR:-.}`, not necessarily the framework workspace.
262
14
 
263
- Launch **sr-doc-sync** agent(s) exactly as in Phase 3d of the implement pipeline. Pass:
264
- - `IMPLEMENTED_FILES_LIST`: the `implemented_files` array from state
265
- - `TASK_DESCRIPTION`: derived from `ORIGINAL_ISSUES` or architect artifacts
15
+ ## Resume earliest invalid evidence
266
16
 
267
- Wait for completion. Failure is **non-blocking** — record `FAILED` and continue.
268
-
269
- **Pipeline state update:** `doc-sync` → `done` or `failed`.
270
-
271
- ---
272
-
273
- ### 4e. Phase: reviewer
274
-
275
- **Runs if `RESUME_PHASE` is any phase up to and including `reviewer`.**
276
-
277
- Launch layer reviewers and the generalist sr-reviewer exactly as in Phase 4b of the implement pipeline. Pass:
278
- - `MODIFIED_FILES_LIST`: the `implemented_files` array from state
279
- - `PIPELINE_CONTEXT`: brief description from original input and issue titles
280
- - Layer reports from sr-frontend-reviewer, sr-backend-reviewer, sr-security-reviewer
281
-
282
- Wait for all to complete. Parse `SECURITY_BLOCKED`, `FRONTEND_STATUS`, `BACKEND_STATUS`.
283
-
284
- **Run the Confidence Gate (Phase 4b-conf)** exactly as defined in the implement pipeline.
285
-
286
- **Pipeline state update:** `reviewer` → `done` or `failed`.
287
-
288
- ---
289
-
290
- ### 4f. Phase: ship
291
-
292
- **Runs if `RESUME_PHASE` is `ship` or `ci`.**
293
-
294
- If `DRY_RUN=true`: skip git operations. Record skipped operations, print dry-run summary, proceed to Phase 5.
295
-
296
- Otherwise, run Phase 4c (ship) of the implement pipeline exactly as defined:
297
- - Security gate check (`SECURITY_BLOCKED`)
298
- - Conflict pre-check (Phase 4c.0)
299
- - Git branch creation, commit, push, PR creation
300
- - Backlog updates
301
-
302
- **Pipeline state update:** `ship` → `done` or `failed`.
303
-
304
- ---
305
-
306
- ### 4g. Phase: ci
307
-
308
- **Runs if ship succeeded and code was pushed.**
309
-
310
- Run Phase 4d (CI monitoring) of the implement pipeline exactly as defined. Check CI status, fix failures (up to 2 retries).
311
-
312
- **Pipeline state update:** `ci` → `done` or `failed`.
313
-
314
- ---
315
-
316
- ## Phase 5: Report
317
-
318
- Print the final report:
319
-
320
- ```
321
- ## Retry Complete: <FEATURE_NAME>
322
-
323
- Resumed from: <RESUME_PHASE>
324
- Phases executed this run: <comma-separated list>
325
-
326
- | Phase | Status |
327
- |--------------|---------|
328
- | architect | done |
329
- | developer | done |
330
- | test-writer | done |
331
- | doc-sync | done |
332
- | reviewer | done |
333
- | ship | done |
334
- | ci | done |
335
- ```
336
-
337
- Include PR URL if ship ran successfully.
338
-
339
- **If any phase failed**, add:
17
+ Follow resumePhase and receipt reasons. Completed valid phases require no model call. Blocked/failed is resumable; never convert dependent implementation into skipped. Explicit --from can reopen an earlier phase, but runtime prerequisite checks still apply.
340
18
 
19
+ ```bash
20
+ node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" phase --phase <phase> --status running
341
21
  ```
342
- ## Failures
343
22
 
344
- | Phase | Error Context |
345
- |-------------|------------------------|
346
- | <phase> | <error_context> |
23
+ | Phase | Resume action |
24
+ |-------|---------------|
25
+ | architect | Repair official design artifacts/confidence; unblock development only after actual gate passes. |
26
+ | developer | Continue unchecked tasks, retain completed code; scoped repairs followed by one full receipt. |
27
+ | reviewer | Review acceptance/confidence; reuse current full evidence, refresh after edits. Do not redo valid architecture because review was blocked. |
28
+ | archive | Fresh archive-check, then authorized official archive/sync only; preserve approved confidence bytes. |
29
+ | ship | Only Core-owned and authorized; resume missing repository delivery without duplicating successful commits/PRs. |
30
+ | ci | Check existing delivery; never reship merely because CI needs retry. |
347
31
 
348
- Next steps:
349
- - To retry from the failed phase: /specrails:retry <FEATURE_NAME> --from <failed-phase>
350
- - To see all pipeline states: /specrails:retry --list
351
- - To restart from scratch: /specrails:implement <original-input>
352
- ```
32
+ Only host-owned ship/ci may skip. Actual done clears old reason; failed/blocked records concrete remaining work. Reopening invalidates dependent completion.
353
33
 
354
- ---
34
+ ## Evidence and report
355
35
 
356
- ## Error Handling
36
+ Use the implement contracts for command receipts, foreground worker completion and exact repository routing. Receipt validity plus required command coverage permits reuse; baseline-only or stale evidence does not. Preview apply must check base/cache and execute checks on actual applied source.
357
37
 
358
- | Phase | Blocking? | On failure |
359
- |-------|-----------|------------|
360
- | architect | **Yes** | Stop — cannot proceed without OpenSpec artifacts |
361
- | developer | **Yes** | Stop — cannot proceed without implemented files |
362
- | test-writer | No | Record FAILED, continue to doc-sync |
363
- | doc-sync | No | Record FAILED, continue to reviewer |
364
- | reviewer | No | Report findings, continue to ship |
365
- | ship | **Yes** | Stop — report failure with git/PR context |
366
- | ci | **Yes** | Stop — report failure with CI log and fix suggestions |
38
+ Confidence, acceptance and archive approval precede delivery. Preserve host-owned Git/worktrees/backlog. Return current state, reused/new evidence and per-repository outcomes. If all phases remain valid, report completion without rerunning.
@@ -153,7 +153,7 @@ A valid telemetry record has the following structure (fields may be absent — t
153
153
  - Infer `agent` name from:
154
154
  1. The `agent` field directly (if present).
155
155
  2. The source log file path (if the path contains `sr-<name>`, extract it).
156
- 3. A `system_prompt` field snippet (if present): match against known agent persona names (`sr-architect`, `sr-developer`, `sr-test-writer`, `sr-reviewer`, `sr-security-reviewer`, `sr-doc-sync`, `sr-product-analyst`, `sr-product-manager`).
156
+ 3. A `system_prompt` field snippet (if present): match against known agent names (`sr-architect`, `sr-developer`, `sr-reviewer`) or any `custom-*` agent declared by an active profile.
157
157
  4. If agent cannot be determined: assign to the bucket `"unknown"`.
158
158
  - Apply time filter: if `PERIOD_START` is not null, skip records where `timestamp < PERIOD_START`.
159
159
  - If `AGENT_FILTER` is set, skip records where the resolved agent name does not match.
@@ -1,43 +1,31 @@
1
- description = "Batch Implementation Orchestrator — runs the implement pipeline over multiple tickets, headless."
1
+ description = "Aggregate batch implementation with one durable journal and final candidate gates."
2
2
 
3
3
  prompt = '''
4
- You are the **batch-implement orchestrator**. The user invoked you to apply the
5
- implement pipeline to multiple tickets in one session. This is fully headless /
6
- non-interactive — every phase runs with `--yes` semantics.
7
-
8
- How the user invokes you:
9
- - `/specrails:batch-implement #1 #2 #3 --yes` — sequential.
10
- - `/specrails:batch-implement --status todo` — every todo ticket, ascending id.
11
- - `/specrails:batch-implement #1 #2 --parallel` — opt-in parallel, only when the
12
- tickets touch disjoint files (run a safety check first; fall back to sequential).
13
-
14
- ## Desktop rail execution context
15
-
16
- 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.
17
-
18
- ## Why this drives the spawns at the ROOT level
19
-
20
- Do NOT delegate to a nested `/specrails:implement` subagent per ticket that then
21
- delegates to architect/developer/reviewer. Subagents are FLAT — a subagent
22
- cannot invoke another subagent (and nested depth-2 delegation is unreliable,
23
- silently dropping the reviewer phase). Instead, YOU (the root orchestrator) drive
24
- the three `invoke_agent` calls — `sr-architect`, `sr-developer`, `sr-reviewer` —
25
- directly, at depth 1, per ticket. Three real subagent calls per ticket, no
26
- nesting. The same delegation contract as `/specrails:implement` applies: every
27
- phase MUST be a real `invoke_agent` call; never inline the work.
28
-
29
- ## Steps
30
-
31
- 0. **Bootstrap.** Confirm `pwd` is the git repo root. Resolve the ticket list
32
- (explicit ids, or `--status`/`--priority` filters over `.specrails/local-tickets.json`).
33
-
34
- 1. **Per ticket, in order, run the three-phase pipeline at depth 1:**
35
- a. `invoke_agent` `sr-architect` → creates + validates the OpenSpec change.
36
- If `BLOCKED`, record the failure and move to the next ticket.
37
- b. `invoke_agent` `sr-developer` → applies the change (implements + checks off tasks).
38
- c. `invoke_agent` `sr-reviewer` → validates; on pass, `openspec archive <id> -y`.
39
- d. Update the ticket to `done` (or record the failure verdict).
40
-
41
- 2. **Aggregate.** After all tickets, report a single table: ticket, change id,
42
- verdict (done / blocked / failed), with a one-line reason for non-done ones.
4
+ Resolve all target IDs or filters and freeze their complete descriptions,
5
+ acceptance criteria and repository IDs. With a host context preserve context.specs
6
+ unchanged. Resolve source/artifact/backlog roots explicitly; cwd can be external.
7
+
8
+ Initialize ONE aggregate OpenSpec change and journal for this runId. Never create
9
+ per-ticket child changes/journals with the same context. Read
10
+ `.gemini/commands/specrails/implement.toml` and apply its capability preflight,
11
+ explicit invoke_agent(agent_name,prompt) handoff, progress-bound continuation and
12
+ gates to the whole batch:
13
+
14
+ 1. One architect designs all tickets, groups tasks by ticket/repository and
15
+ dependency order, validates OpenSpec and high/medium design confidence.
16
+ 2. One developer implements groups sequentially, persisting progress in tasks.md.
17
+ Use scoped checks per group and one full helper verification for the aggregate
18
+ candidate before developer done. Incomplete groups remain retriable.
19
+ 3. One reviewer checks every acceptance criterion and cross-ticket interaction;
20
+ pass all frozen specs, changed paths and the full receipt. Ordinary review
21
+ never archives. At most one exact-findings developer repair plus re-review.
22
+ 4. After clean semantic reviewer done, run archive-check; only success authorizes
23
+ reviewer archive-only mode. Verify the archive and record archive done. Only
24
+ then close ALL Core-owned tickets, or report results to the owning host.
25
+
26
+ Run these roles directly at root, no nested implement coordinator. Retry resumes
27
+ this aggregate journal without repeating valid phases. A --parallel preference
28
+ never overrides host ownership, unknown capacity or overlapping mutation paths;
29
+ use sequential execution and report it honestly. Final output lists each ticket,
30
+ aggregate verification/archive status and unresolved task groups; no partial done.
43
31
  '''