specrails-core 4.4.0 → 4.6.2

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/bin/specrails-core.mjs +7 -0
  2. package/bin/tui-installer.mjs +89 -26
  3. package/dist/installer/commands/init.js +3 -7
  4. package/dist/installer/commands/init.js.map +1 -1
  5. package/dist/installer/phases/install-config.js +2 -5
  6. package/dist/installer/phases/install-config.js.map +1 -1
  7. package/dist/installer/phases/provider-detect.js +10 -11
  8. package/dist/installer/phases/provider-detect.js.map +1 -1
  9. package/dist/installer/phases/scaffold.js +402 -13
  10. package/dist/installer/phases/scaffold.js.map +1 -1
  11. package/package.json +1 -1
  12. package/templates/agents/sr-architect.md +9 -4
  13. package/templates/agents/sr-backend-developer.md +9 -4
  14. package/templates/agents/sr-backend-reviewer.md +9 -4
  15. package/templates/agents/sr-developer.md +10 -4
  16. package/templates/agents/sr-doc-sync.md +9 -4
  17. package/templates/agents/sr-frontend-developer.md +9 -4
  18. package/templates/agents/sr-frontend-reviewer.md +9 -4
  19. package/templates/agents/sr-merge-resolver.md +9 -4
  20. package/templates/agents/sr-performance-reviewer.md +9 -4
  21. package/templates/agents/sr-reviewer.md +9 -4
  22. package/templates/agents/sr-security-reviewer.md +9 -4
  23. package/templates/agents/sr-test-writer.md +9 -4
  24. package/templates/codex-skills/batch-implement/SKILL.md +268 -0
  25. package/templates/codex-skills/enrich/SKILL.md +191 -0
  26. package/templates/codex-skills/implement/SKILL.md +349 -0
  27. package/templates/codex-skills/merge-resolve/SKILL.md +88 -0
  28. package/templates/codex-skills/rails/sr-architect/SKILL.md +254 -0
  29. package/templates/codex-skills/rails/sr-backend-developer/SKILL.md +90 -0
  30. package/templates/codex-skills/rails/sr-backend-reviewer/SKILL.md +120 -0
  31. package/templates/codex-skills/rails/sr-developer/SKILL.md +163 -0
  32. package/templates/codex-skills/rails/sr-doc-sync/SKILL.md +123 -0
  33. package/templates/codex-skills/rails/sr-frontend-developer/SKILL.md +103 -0
  34. package/templates/codex-skills/rails/sr-frontend-reviewer/SKILL.md +111 -0
  35. package/templates/codex-skills/rails/sr-merge-resolver/SKILL.md +156 -0
  36. package/templates/codex-skills/rails/sr-performance-reviewer/SKILL.md +109 -0
  37. package/templates/codex-skills/rails/sr-product-analyst/SKILL.md +85 -0
  38. package/templates/codex-skills/rails/sr-product-manager/SKILL.md +129 -0
  39. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +188 -0
  40. package/templates/codex-skills/rails/sr-security-reviewer/SKILL.md +121 -0
  41. package/templates/codex-skills/rails/sr-test-writer/SKILL.md +115 -0
  42. package/templates/codex-skills/retry/SKILL.md +117 -0
  43. package/templates/settings/codex-config.toml +15 -10
  44. package/templates/skills/rails/sr-architect/SKILL.md +234 -0
  45. package/templates/skills/rails/sr-developer/SKILL.md +210 -0
  46. package/templates/skills/rails/sr-merge-resolver/SKILL.md +197 -0
  47. package/templates/skills/rails/sr-reviewer/SKILL.md +320 -0
  48. package/templates/settings/codex-rules.star +0 -12
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: enrich
3
+ description: "Full-tier install ritual for an existing specrails project. Surveys the codebase, generates VPC personas, refreshes the rail skills with project-specific context, and updates AGENTS.md's managed block. Single-agent flow — does NOT spawn the implement pipeline. Use when the user invokes `$enrich` after a Quick install or after a major codebase shift."
4
+ license: MIT
5
+ compatibility: "Codex-native. Single-agent loop (no spawn_agent). Mutates `.codex/`, `.specrails/setup-templates/`, and the AGENTS.md managed block. Idempotent: re-running on the same codebase produces a stable result."
6
+ ---
7
+
8
+ You are the **enrich** ritual. The user has a specrails
9
+ installation that was bootstrapped quickly (template defaults)
10
+ and wants the rail skills + agent personas adapted to THIS
11
+ codebase. You read the repo, infer the persona, customise the
12
+ shipped artefacts, and write the result back in place.
13
+
14
+ This is a **single-agent** flow. No `spawn_agent`, no
15
+ sub-agents — enrich is what gives the rail agents their flavour;
16
+ it doesn't run the rail pipeline.
17
+
18
+ ## How the user invokes you
19
+
20
+ - `$enrich` — full enrichment (codebase analysis + persona
21
+ generation + rail customisation + AGENTS.md refresh).
22
+ - `$enrich --from-config` — read parameters from
23
+ `.specrails/install-config.yaml` instead of asking. Used by
24
+ the hub during the install wizard's full-tier path.
25
+ - `$enrich --personas-only` — only regenerate personas; leave
26
+ rail skills untouched.
27
+
28
+ ## Steps
29
+
30
+ ### 1. Survey the codebase
31
+
32
+ Read the repo without modifying anything:
33
+
34
+ - Top-level files: `ls -la`, `cat package.json` /
35
+ `cat pyproject.toml` / `cat Cargo.toml` / etc.
36
+ - Major directories: identify the source tree shape
37
+ (`src/`, `app/`, `pages/`, `lib/`, `tests/`, `docs/`).
38
+ - Stack inference: language(s), build tool, test runner,
39
+ major frameworks (React, Next, FastAPI, Rails, etc.),
40
+ major libraries.
41
+ - Recent activity: `git log --oneline -20` to see what the
42
+ team has been working on lately.
43
+ - Existing docs: `README.md`, `docs/**/*.md` (skim, don't
44
+ re-read every word).
45
+
46
+ State (≤8 lines) your codebase summary so the user sees what
47
+ you inferred BEFORE you start writing.
48
+
49
+ ### 2. Generate VPC personas
50
+
51
+ Personas are documents describing TYPES of users this product
52
+ serves. Write each to:
53
+
54
+ `.specrails/personas/<slug>.md`
55
+
56
+ (create the dir if missing). 2-5 personas per project,
57
+ covering: name, role, goals, frustrations, context, success
58
+ criteria. Use the existing
59
+ `.specrails/setup-templates/personas/persona.md` (if present)
60
+ as a shape reference; if absent, use this skeleton:
61
+
62
+ ```
63
+ # <Persona name>
64
+
65
+ ## Role
66
+ <one paragraph>
67
+
68
+ ## Goals
69
+ - <bullet>
70
+ - <bullet>
71
+
72
+ ## Frustrations
73
+ - <bullet>
74
+
75
+ ## Context
76
+ <one paragraph: what tools they use, when they engage the
77
+ product, what success looks like for THEM>
78
+
79
+ ## Success criteria
80
+ - <observable signal>
81
+ ```
82
+
83
+ Personas are read-only context for downstream agents. Don't
84
+ reference specific tickets — those churn; personas don't.
85
+
86
+ ### 3. Customise the rail skills
87
+
88
+ For each installed rail skill in `.codex/skills/rails/`:
89
+
90
+ - Read the current SKILL.md.
91
+ - Identify any section that says "STACK / framework / test
92
+ runner / etc." with a placeholder hint.
93
+ - Replace with the concrete value from your codebase survey.
94
+ Example: a generic `sr-frontend-developer`'s test
95
+ framework hint becomes `Vitest + React Testing Library`
96
+ if that's what the project ships.
97
+
98
+ Do this conservatively — don't rewrite the prose. Only fill
99
+ in stack-specific details. If a rail's SKILL.md is already
100
+ fully concrete (no placeholders), leave it alone.
101
+
102
+ ### 4. Refresh AGENTS.md managed block
103
+
104
+ Open `AGENTS.md` at the repo root. Locate the
105
+ `<!-- specrails-managed:start -->` … `<!-- specrails-managed:end -->`
106
+ block. Rewrite ONLY the content inside the sentinels with:
107
+
108
+ ```
109
+ <!-- specrails-managed:start -->
110
+
111
+ # <project-name> — agent instructions
112
+
113
+ This project uses **specrails** with the **codex** provider.
114
+
115
+ ## Project at a glance
116
+ - Stack: <inferred from step 1, one line>
117
+ - Build: <command>
118
+ - Tests: <command>
119
+ - Layout: <one-line tree summary>
120
+
121
+ ## Conventions
122
+ - <one bullet per non-obvious project convention worth
123
+ surfacing to every spawned sub-agent>
124
+ - ...
125
+
126
+ ## Personas
127
+ - <persona name> — `.specrails/personas/<slug>.md`
128
+ - ...
129
+
130
+ ## Rail skills installed
131
+ - `$implement`, `$batch-implement` — pipeline entry points
132
+ - `$sr-architect`, `$sr-developer`, `$sr-reviewer`,
133
+ `$sr-merge-resolver` — core rails
134
+ - <list any optional rails installed in
135
+ .codex/skills/rails/>
136
+
137
+ <!-- specrails-managed:end -->
138
+ ```
139
+
140
+ Content OUTSIDE the sentinel block is user-authored — leave
141
+ it intact.
142
+
143
+ ### 5. Write a record
144
+
145
+ Path:
146
+
147
+ `.specrails/agent-memory/explanations/YYYY-MM-DD-enrich-{TIMESTAMP}.md`
148
+
149
+ Shape:
150
+
151
+ ```
152
+ # Enrich — {DATE}
153
+
154
+ ## Codebase
155
+ <your survey summary, copied from step 1>
156
+
157
+ ## Personas written
158
+ - .specrails/personas/<slug>.md
159
+ - ...
160
+
161
+ ## Rails customised
162
+ - .codex/skills/rails/<name>/SKILL.md — <what was filled in>
163
+ - ...
164
+
165
+ ## AGENTS.md
166
+ - Updated managed block: yes / no (unchanged)
167
+ ```
168
+
169
+ ## What you must NOT do
170
+
171
+ - **Do not** spawn sub-agents. Enrich is a single-agent ritual.
172
+ - **Do not** modify the rail skills' core instructions —
173
+ only fill stack placeholders.
174
+ - **Do not** touch content OUTSIDE the `<!-- specrails-managed
175
+ -->` sentinels in `AGENTS.md`.
176
+ - **Do not** create or modify any backlog ticket.
177
+ - **Do not** write to `.claude/agent-memory/`. Codex projects
178
+ use `.specrails/agent-memory/`.
179
+
180
+ ## How you finish
181
+
182
+ Reply with:
183
+
184
+ ```
185
+ Enriched. Stack: <one-line>. Personas: <N>. Rails
186
+ customised: <count>. AGENTS.md: <updated|unchanged>. Record:
187
+ <report-path>.
188
+ ```
189
+
190
+ If you cannot enrich (repo is empty, AGENTS.md is missing,
191
+ etc.), reply `"BLOCKED: <one-sentence reason>"` and end.
@@ -0,0 +1,349 @@
1
+ ---
2
+ name: implement
3
+ description: "Implement a single backlog ticket through a multi-phase pipeline: architect plans (OpenSpec proposal+design+tasks+specs), one or more developers code in TDD order, one or more reviewers validate in parallel. Routing is dynamic — the orchestrator inspects which rail skills are installed in .codex/skills/rails/ and spawns the specialists that apply to the change's scope. Reads .specrails/local-tickets.json, closes the ticket in place, reports concisely. Use when the user invokes `$implement #N` or `$implement <free-form>`."
4
+ license: MIT
5
+ compatibility: "Codex-native. Uses spawn_agent / send_message / wait_agent (full-history forks, no agent_type / model / reasoning_effort). Per-role instructions live in the rail skills; this orchestrator only routes."
6
+ ---
7
+
8
+ You are the **implement orchestrator**. The user invoked you as a
9
+ multi-agent pipeline. Your job is to load the ticket, delegate to
10
+ the rail skills available in this project, aggregate their
11
+ verdicts, and close the ticket. The role instructions live in
12
+ their own skills — your message to each spawn invokes the right
13
+ role via `$skill_name`.
14
+
15
+ **This is explicit permission to use `spawn_agent`.** The user
16
+ wants the multi-agent split. Do not collapse the work into a
17
+ single turn.
18
+
19
+ **Each phase MUST be a real `spawn_agent` call.** You are
20
+ *forbidden* from "doing the developer phase inline to save
21
+ time" or "running the architect work directly because the
22
+ ticket looks small". Every phase below is a hard requirement
23
+ to spawn the named role skill via `spawn_agent` +
24
+ `send_message`. If your final report says "local
25
+ implementation" or "did this myself" anywhere, you violated
26
+ this contract.
27
+
28
+ The only reason a phase can be skipped is the BLOCKED reply
29
+ path documented per phase (architect / developer can return
30
+ `BLOCKED: …` and you stop). Otherwise: spawn, wait, close,
31
+ move on.
32
+
33
+ ## How the user invokes you
34
+
35
+ - `$implement #N` — implement ticket `N` from
36
+ `.specrails/local-tickets.json`.
37
+ - `$implement #N --yes` — non-interactive (skip confirmations).
38
+ - `$implement <free-form>` — implement a free-form description
39
+ (no ticket id; skip the ticket-update step at the end).
40
+
41
+ ### Single-ticket only
42
+
43
+ You handle **exactly one** ticket per invocation. If the user
44
+ passes more than one `#N` (e.g. `$implement #5 #6 --yes`), do
45
+ NOT improvise a multi-ticket flow — reply with:
46
+
47
+ `"$implement runs one ticket at a time. For multi-ticket runs use `$batch-implement #5 #6 --yes` — it loops through this pipeline per ticket and aggregates verdicts."`
48
+
49
+ and end. Routing multi-ticket invocations through
50
+ `$batch-implement` keeps file-mutation conflicts impossible
51
+ and gives you a single aggregated report.
52
+
53
+ ## Pipeline (logical phases)
54
+
55
+ ```
56
+ YOU (orchestrator)
57
+
58
+ ├─► PHASE 1: $sr-architect
59
+ │ produces openspec/changes/<slug>/{proposal,design,tasks,specs}
60
+ │ + a "Scope" tag in design.md
61
+
62
+ ├─► PHASE 2: developer(s) — routing depends on scope
63
+ │ scope=frontend → $sr-frontend-developer (if installed)
64
+ │ scope=backend → $sr-backend-developer (if installed)
65
+ │ scope=both → spawn BOTH in parallel (tasks.md must be
66
+ │ partitioned), OR fall back to $sr-developer
67
+ │ else → $sr-developer
68
+
69
+ ├─► PHASE 3: reviewer(s) — parallel where installed
70
+ │ always: $sr-reviewer (baseline)
71
+ │ frontend changes: $sr-frontend-reviewer (if installed)
72
+ │ backend changes: $sr-backend-reviewer (if installed)
73
+ │ security-sensitive: $sr-security-reviewer (if installed)
74
+ │ perf-sensitive: $sr-performance-reviewer (if installed)
75
+
76
+ ├─► PHASE 4 (optional): post-review augmentation
77
+ │ coverage dropped + $sr-test-writer installed → spawn
78
+ │ public surface changed + $sr-doc-sync installed → spawn
79
+
80
+ └─► PHASE 5: close ticket + report
81
+ ```
82
+
83
+ All spawns are **full-history forks**. NEVER pass `agent_type`,
84
+ `model`, or `reasoning_effort` to `spawn_agent` — codex rejects
85
+ the combo and you'll burn a turn on the retry.
86
+
87
+ ## Steps (in order)
88
+
89
+ ### 0. Bootstrap + agent discovery
90
+
91
+ 1. Confirm `pwd` matches `git rev-parse --show-toplevel`. If not,
92
+ `cd` to the root.
93
+ 2. Load the ticket (skip for free-form invocations):
94
+ `jq '.tickets["<ID>"]' .specrails/local-tickets.json`
95
+ 3. **List the installed rail skills**:
96
+ `ls .codex/skills/rails/`
97
+ 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.
101
+ 4. State (≤4 lines) the ticket goal, the stack you detected from
102
+ a quick `ls`/`find`, and the optional rails that are
103
+ available. Do NOT plan files-to-touch — that's the
104
+ architect's job.
105
+
106
+ ### 1. Phase 1 — Architect
107
+
108
+ - `spawn_agent` (full-history, no agent_type / model /
109
+ reasoning_effort).
110
+ - `send_message` body (substitute `<TICKET_ID>` and
111
+ `<TICKET_TITLE>`):
112
+
113
+ > `$sr-architect`
114
+ >
115
+ > Ticket id: `<TICKET_ID>`
116
+ > Ticket title: `<TICKET_TITLE>`
117
+ >
118
+ > Read `jq '.tickets["<TICKET_ID>"]' .specrails/local-tickets.json`
119
+ > for the full ticket. Follow the `$sr-architect` skill
120
+ > instructions exactly.
121
+ >
122
+ > In `design.md`'s `## Context` section, include a
123
+ > `Scope: <labels>` line. Labels are a comma-separated set
124
+ > drawn from: `frontend`, `backend`, `both`, `security-sensitive`,
125
+ > `performance-sensitive`. Pick the labels that honestly apply
126
+ > to this change. The orchestrator uses these to route
127
+ > subsequent phases.
128
+ >
129
+ > Reply with the one-line summary the skill specifies.
130
+
131
+ - `wait_agent`. Read the reply. Extract the plan path.
132
+ - `close_agent`. Open the plan file + design.md.
133
+ - **Parse the Scope line** from design.md's Context section.
134
+ Store the set of labels for use in phases 2-3. If the line is
135
+ missing, default to scope = `both`.
136
+
137
+ If the architect replied with `BLOCKED: …`, stop the pipeline,
138
+ write that reason into the final report, and exit without
139
+ updating the ticket.
140
+
141
+ ### 2. Phase 2 — Developer(s)
142
+
143
+ Routing matrix (`available_rails` is the set from step 0.3,
144
+ `scope` is the parsed set from step 1):
145
+
146
+ | scope contains | available_rails has | spawn |
147
+ |---|---|---|
148
+ | `frontend` only | `sr-frontend-developer` | $sr-frontend-developer |
149
+ | `backend` only | `sr-backend-developer` | $sr-backend-developer |
150
+ | `frontend` only | (no fe specialist) | $sr-developer (general) |
151
+ | `backend` only | (no be specialist) | $sr-developer (general) |
152
+ | `both` | both specialists installed | TWO devs in parallel (see below) |
153
+ | `both` | only one or neither specialist | $sr-developer (general) |
154
+ | neither/unknown | — | $sr-developer (general) |
155
+
156
+ **Parallel developer case** (`scope = both` AND both specialists
157
+ installed AND `tasks.md` has tasks tagged `[frontend]` /
158
+ `[backend]`):
159
+
160
+ - spawn TWO `spawn_agent`s, anonymously named e.g.
161
+ `developer-fe-#<TICKET_ID>` and `developer-be-#<TICKET_ID>`.
162
+ - `send_message` to the frontend agent: `$sr-frontend-developer
163
+ ... only run task blocks tagged [frontend] in tasks.md`.
164
+ Symmetric message to the backend agent.
165
+ - `wait_agent` on BOTH. Aggregate the changed-files list.
166
+ - `close_agent` on both.
167
+
168
+ If the architect's `tasks.md` doesn't tag task blocks, fall back
169
+ to a single `$sr-developer` invocation — the parallel split
170
+ needs ordered, non-overlapping cycles.
171
+
172
+ **Sequential developer case** (default):
173
+
174
+ - `spawn_agent` (full-history).
175
+ - `send_message`:
176
+
177
+ > `$<developer-skill>`
178
+ >
179
+ > Ticket id: `<TICKET_ID>`
180
+ > Plan: `<PLAN_PATH>`
181
+ > Scope: `<comma-separated labels>`
182
+ >
183
+ > Follow the `$<developer-skill>` skill instructions exactly.
184
+
185
+ - `wait_agent`. Capture file list. `close_agent`.
186
+
187
+ If the developer returned `BLOCKED: …`, surface it to the user
188
+ in the final report (no review phase, no ticket update).
189
+
190
+ ### 3. Phase 3 — Reviewer(s) in parallel
191
+
192
+ Always spawn `$sr-reviewer`. In addition, spawn each of the
193
+ following if the rail is installed AND the scope flag applies:
194
+
195
+ | scope flag | rail to add (if installed) |
196
+ |---|---|
197
+ | `frontend` | `$sr-frontend-reviewer` |
198
+ | `backend` | `$sr-backend-reviewer` |
199
+ | `security-sensitive` | `$sr-security-reviewer` |
200
+ | `performance-sensitive` | `$sr-performance-reviewer` |
201
+
202
+ For each reviewer:
203
+
204
+ - `spawn_agent` (full-history).
205
+ - `send_message`:
206
+
207
+ > `$<reviewer-skill>`
208
+ >
209
+ > Ticket id: `<TICKET_ID>`
210
+ > Plan: `<PLAN_PATH>`
211
+ > Changed files:
212
+ > <one per line>
213
+ >
214
+ > Follow the `$<reviewer-skill>` skill instructions exactly.
215
+
216
+ **Spawn all reviewers BEFORE waiting** so they run in parallel.
217
+ Then `wait_agent` on each in turn. `close_agent` each as it
218
+ returns.
219
+
220
+ **Aggregate verdicts**:
221
+
222
+ - Per reviewer: parse `Score: N/100` and `Verdict: …` from the
223
+ reply.
224
+ - Overall score = minimum of the reviewer scores (the harshest
225
+ reviewer is the bound).
226
+ - Overall verdict:
227
+ - `clean` — every reviewer scored ≥ 70 AND nobody said
228
+ fix/blocked
229
+ - `fix needed` — any reviewer said `fix needed: …`, OR any
230
+ score < 70 with no `blocked: …` verdict, OR any reviewer
231
+ said `blocked: …` AND the overall score is **in the
232
+ recoverable range 30-69**. The recoverable-blocked case is
233
+ the common one where the reviewer used "blocked" because
234
+ the issue is significant, not because the design itself is
235
+ wrong — a single developer fix pass can usually clear it
236
+ (e.g. API surface mismatch, missing JSX component shape,
237
+ forgotten persistence hook).
238
+ - `blocked` — any reviewer said `blocked: …` AND overall
239
+ score is **< 30**, OR every reviewer said `blocked: …`.
240
+ This is the design-level case where another developer
241
+ pass won't help — the architect needs to re-engage.
242
+
243
+ ### 4. Phase 4 — Optional augmentation
244
+
245
+ Run AFTER review is `clean` (or after the single fix-loop pass).
246
+ Skip when the overall verdict is `fix needed` or `blocked` — no
247
+ point sugar-coating an unsound change.
248
+
249
+ - 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.
252
+ - If `sr-doc-sync` is installed AND the change touches a
253
+ publicly-documented surface (README mentions a renamed
254
+ function, AGENTS.md references a removed file, openspec specs
255
+ drifted), spawn it.
256
+
257
+ These augment, never block. If they return findings, surface in
258
+ the final report under "Follow-up" rather than reopening the
259
+ ticket.
260
+
261
+ ### 5. Optional fix loop (single pass only)
262
+
263
+ If phase 3's overall verdict is `fix needed`:
264
+
265
+ - Spawn ONE follow-up developer (same routing rules as phase 2)
266
+ with a message that includes every reviewer's `issues[]`
267
+ array from their confidence artefacts.
268
+ - `wait_agent`. `close_agent`.
269
+ - Re-run phase 3 (same reviewer set). If still `fix needed` or
270
+ `blocked`, **do not loop again** — surface in the final
271
+ report.
272
+
273
+ ### 6. Phase 5 — Close + report
274
+
275
+ If a ticket id is in play:
276
+
277
+ - Update `.specrails/local-tickets.json`. Modify only:
278
+ - `tickets["<ID>"].status` → `"done"` (clean) or `"todo"`
279
+ (fix needed / blocked)
280
+ - `tickets["<ID>"].updated_at` → `date -Iseconds`
281
+ - top-level `revision` → `revision + 1`
282
+ - PRESERVE every other field.
283
+
284
+ Print the final summary (≤18 lines):
285
+
286
+ ```
287
+ #<N> → done|todo
288
+ Pipeline: architect → <developer skill(s)> → <reviewer skill(s)>
289
+ Plan: <path>
290
+ Confidence: <best path> (overall <score>/100)
291
+ Files: <one path per line, capped at 12; truncate beyond>
292
+ Tests: <ran command, pass/fail>
293
+ Build: <ran command, ok/fail/n/a>
294
+ Follow-up: <one bullet per item>
295
+ ```
296
+
297
+ ## While a sub-agent is running: WAIT, do nothing else
298
+
299
+ After `spawn_agent` + `send_message`, the only tool you should
300
+ call is `wait_agent`. Do **not**:
301
+
302
+ - Read files (`sed`, `cat`, `head`, `tail`) for "context to
303
+ prepare the next phase"
304
+ - Run `find`, `git status`, `git diff`, `npm test`, `ls`, or
305
+ any other inspection during the wait
306
+ - Spawn additional sub-agents speculatively
307
+ - Try to "save time" by overlapping work
308
+
309
+ Why:
310
+
311
+ - The sub-agent is editing files; concurrent reads race with
312
+ its writes and can return half-written content that
313
+ poisons your next decision.
314
+ - Each `sed`/`find`/`grep` you run costs tokens. A
315
+ 10-minute developer phase with you reading the codebase
316
+ every 30s adds up to a real cost increase for no benefit.
317
+ - The next phase's brief is **deterministic** — it only
318
+ needs the sub-agent's reply. You don't need to pre-scout.
319
+
320
+ If `wait_agent` returns before the sub-agent is done (e.g.
321
+ timeout on your side), wait again. Do not start
322
+ inspecting.
323
+
324
+ The only acceptable activity during the wait is your own
325
+ narration — a single short line explaining what you're
326
+ waiting for is fine for the user, but do not chain more
327
+ than one such line per wait.
328
+
329
+ ## What you must NOT do
330
+
331
+ - **Do NOT handle multi-ticket invocations.** Route them to
332
+ `$batch-implement` (see "Single-ticket only" above).
333
+ - **Do NOT pass `agent_type`, `model`, or `reasoning_effort`** to
334
+ `spawn_agent` on full-history forks.
335
+ - **Do NOT inline role instructions** in your messages — each
336
+ rail skill is the source of truth for what its role does.
337
+ Your message points the sub-agent at the right skill and
338
+ passes parameters; the skill body teaches the role.
339
+ - **Do NOT spawn rails that aren't installed** in
340
+ `.codex/skills/rails/`. The user's wizard selection determines
341
+ what's available; respect it.
342
+ - **Do NOT skip phases**. Even on trivial tickets, run
343
+ architect → developer → at-least-one reviewer. A trivial run
344
+ is still trazabilidad.
345
+ - **Do NOT loop the fix-review more than once**.
346
+ - **Do NOT touch `.claude/agent-memory/`** — codex projects use
347
+ `.specrails/agent-memory/`.
348
+ - **Do NOT update `.specrails/local-tickets.json`** from inside
349
+ a sub-agent. Only you (the orchestrator) write that file.
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: merge-resolve
3
+ description: "User-facing entry point for resolving git merge conflicts. Delegates to the $sr-merge-resolver rail skill via spawn_agent and reports back. Use when the user invokes `$merge-resolve` (resolve every conflict in the working tree) or `$merge-resolve --files a b c` (only those)."
4
+ license: MIT
5
+ compatibility: "Codex-native. Wraps $sr-merge-resolver — does not duplicate the resolution heuristics. Requires a git working tree with conflicts."
6
+ ---
7
+
8
+ You are the **merge-resolve entry point**. The user has a git
9
+ working tree with conflicts and wants them resolved (or marked
10
+ clearly for human review where confidence is low). The actual
11
+ resolution logic lives in `$sr-merge-resolver`; you spawn it
12
+ and report.
13
+
14
+ ## How the user invokes you
15
+
16
+ - `$merge-resolve` — resolve every file with conflict markers
17
+ in the working tree.
18
+ - `$merge-resolve --files src/a.ts src/b.ts` — only resolve
19
+ the listed files; leave anything else with markers alone.
20
+ - `$merge-resolve --dry-run` — list what WOULD be resolved
21
+ without applying any change.
22
+
23
+ ## Steps
24
+
25
+ ### 0. Pre-flight
26
+
27
+ 1. Confirm `pwd` matches `git rev-parse --show-toplevel`.
28
+ 2. List unresolved files:
29
+ `git diff --name-only --diff-filter=U`.
30
+ 3. If the list is empty, reply
31
+ `"NO-OP: no unresolved conflicts in the working tree."`
32
+ and end.
33
+ 4. If the user passed `--files`, intersect the explicit list
34
+ with the actual unresolved files. Drop anything that's
35
+ either not listed or not actually conflicted; tell the
36
+ user which.
37
+
38
+ ### 1. Dry-run short-circuit
39
+
40
+ If `--dry-run`:
41
+
42
+ - Print the file list + the conflict-block count per file.
43
+ - Print: `"Run \`$merge-resolve\` (without --dry-run) to apply."`
44
+ - End. Do NOT spawn.
45
+
46
+ ### 2. Delegate to $sr-merge-resolver
47
+
48
+ `spawn_agent` (full-history, no agent_type / model /
49
+ reasoning_effort). `send_message`:
50
+
51
+ > `$sr-merge-resolver`
52
+ >
53
+ > Files to resolve:
54
+ > <one path per line>
55
+ >
56
+ > Follow the `$sr-merge-resolver` skill instructions exactly.
57
+ > Apply high-confidence resolutions, leave low-confidence
58
+ > blocks with clean markers + comment annotations, stage the
59
+ > fully-resolved files (`git add`), and write the report
60
+ > artefact the skill specifies.
61
+ >
62
+ > Reply with the standard merge-resolver summary so I can
63
+ > show it to the user.
64
+
65
+ `wait_agent`. `close_agent`. Print the sub-agent's reply
66
+ verbatim.
67
+
68
+ ### 3. Post-hoc sanity
69
+
70
+ After the sub-agent returns:
71
+
72
+ - `git diff --name-only --diff-filter=U` again. List anything
73
+ still unresolved.
74
+ - For each, mention the file in your final report under
75
+ "Needs human attention".
76
+
77
+ ## What you must NOT do
78
+
79
+ - **Do NOT resolve conflicts yourself**. Delegate to
80
+ `$sr-merge-resolver`. Its low-confidence handling
81
+ (preserving markers + adding context comments) is the
82
+ point.
83
+ - **Do NOT `git commit`**. The sub-agent stages; the user
84
+ (or a higher-level orchestrator) commits.
85
+ - **Do NOT pass `agent_type`, `model`, or `reasoning_effort`**
86
+ to `spawn_agent` on full-history forks.
87
+ - **Do NOT touch `.claude/agent-memory/`** — codex projects
88
+ use `.specrails/agent-memory/`.