specsmd 0.0.0-dev.8 → 0.0.0-dev.80

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 (77) hide show
  1. package/README.md +175 -231
  2. package/flows/aidlc/commands/construction-agent.md +5 -1
  3. package/flows/aidlc/commands/inception-agent.md +4 -0
  4. package/flows/aidlc/commands/master-agent.md +4 -0
  5. package/flows/aidlc/commands/operations-agent.md +4 -0
  6. package/flows/aidlc/memory-bank.yaml +2 -1
  7. package/{scripts/artifact-validator.js → flows/aidlc/scripts/artifact-validator.cjs} +3 -3
  8. package/{scripts/bolt-complete.js → flows/aidlc/scripts/bolt-complete.cjs} +36 -5
  9. package/{scripts/status-integrity.js → flows/aidlc/scripts/status-integrity.cjs} +5 -5
  10. package/flows/aidlc/skills/construction/bolt-list.md +1 -1
  11. package/flows/aidlc/skills/construction/bolt-start.md +3 -3
  12. package/flows/aidlc/skills/construction/bolt-status.md +1 -1
  13. package/flows/aidlc/skills/construction/prototype-apply.md +311 -0
  14. package/flows/aidlc/skills/inception/bolt-plan.md +2 -0
  15. package/flows/aidlc/skills/inception/vibe-to-spec.md +410 -0
  16. package/flows/aidlc/skills/master/analyze-context.md +1 -1
  17. package/flows/aidlc/templates/construction/bolt-template.md +2 -2
  18. package/flows/aidlc/templates/construction/bolt-types/ddd-construction-bolt.md +73 -11
  19. package/flows/aidlc/templates/standards/decision-index-template.md +32 -0
  20. package/flows/fire/README.md +19 -0
  21. package/flows/fire/agents/builder/agent.md +260 -0
  22. package/flows/fire/agents/builder/skills/code-review/SKILL.md +257 -0
  23. package/flows/fire/agents/builder/skills/code-review/references/auto-fix-rules.md +218 -0
  24. package/flows/fire/agents/builder/skills/code-review/references/review-categories.md +154 -0
  25. package/flows/fire/agents/builder/skills/code-review/templates/review-report.md.hbs +120 -0
  26. package/flows/fire/agents/builder/skills/run-execute/SKILL.md +705 -0
  27. package/flows/fire/agents/builder/skills/run-execute/scripts/complete-run.cjs +781 -0
  28. package/flows/fire/agents/builder/skills/run-execute/scripts/init-run.cjs +457 -0
  29. package/flows/fire/agents/builder/skills/run-execute/scripts/update-phase.cjs +239 -0
  30. package/flows/fire/agents/builder/skills/run-execute/templates/plan.md.hbs +61 -0
  31. package/flows/fire/agents/builder/skills/run-execute/templates/test-report.md.hbs +81 -0
  32. package/flows/fire/agents/builder/skills/run-plan/SKILL.md +378 -0
  33. package/flows/fire/agents/builder/skills/run-status/SKILL.md +96 -0
  34. package/flows/fire/agents/builder/skills/walkthrough-generate/SKILL.md +264 -0
  35. package/flows/fire/agents/builder/skills/walkthrough-generate/templates/walkthrough.md.hbs +176 -0
  36. package/flows/fire/agents/orchestrator/agent.md +144 -0
  37. package/flows/fire/agents/orchestrator/skills/project-init/SKILL.md +226 -0
  38. package/flows/fire/agents/orchestrator/skills/project-init/templates/coding-standards.md.hbs +149 -0
  39. package/flows/fire/agents/orchestrator/skills/project-init/templates/constitution.md.hbs +43 -0
  40. package/flows/fire/agents/orchestrator/skills/project-init/templates/system-architecture.md.hbs +101 -0
  41. package/flows/fire/agents/orchestrator/skills/project-init/templates/tech-stack.md.hbs +136 -0
  42. package/flows/fire/agents/orchestrator/skills/project-init/templates/testing-standards.md.hbs +94 -0
  43. package/flows/fire/agents/orchestrator/skills/route/SKILL.md +146 -0
  44. package/flows/fire/agents/orchestrator/skills/status/SKILL.md +696 -0
  45. package/flows/fire/agents/planner/agent.md +143 -0
  46. package/flows/fire/agents/planner/skills/design-doc-generate/SKILL.md +156 -0
  47. package/flows/fire/agents/planner/skills/design-doc-generate/templates/design.md.hbs +124 -0
  48. package/flows/fire/agents/planner/skills/intent-capture/SKILL.md +125 -0
  49. package/flows/fire/agents/planner/skills/intent-capture/templates/brief.md.hbs +40 -0
  50. package/flows/fire/agents/planner/skills/work-item-decompose/SKILL.md +166 -0
  51. package/flows/fire/agents/planner/skills/work-item-decompose/templates/work-item.md.hbs +40 -0
  52. package/flows/fire/commands/fire-builder.md +56 -0
  53. package/flows/fire/commands/fire-planner.md +48 -0
  54. package/flows/fire/commands/fire.md +46 -0
  55. package/flows/fire/memory-bank.yaml +240 -0
  56. package/flows/fire/quick-start.md +146 -0
  57. package/flows/simple/README.md +190 -0
  58. package/flows/simple/agents/agent.md +404 -0
  59. package/flows/simple/commands/agent.md +60 -0
  60. package/flows/simple/context-config.yaml +34 -0
  61. package/flows/simple/memory-bank.yaml +66 -0
  62. package/flows/simple/quick-start.md +231 -0
  63. package/flows/simple/skills/design.md +96 -0
  64. package/flows/simple/skills/execute.md +190 -0
  65. package/flows/simple/skills/requirements.md +94 -0
  66. package/flows/simple/skills/tasks.md +136 -0
  67. package/flows/simple/templates/design-template.md +138 -0
  68. package/flows/simple/templates/requirements-template.md +85 -0
  69. package/flows/simple/templates/tasks-template.md +104 -0
  70. package/lib/analytics/tracker.js +6 -2
  71. package/lib/constants.js +20 -8
  72. package/lib/installer.js +19 -15
  73. package/lib/installers/KiroInstaller.js +55 -0
  74. package/lib/installers/OpenCodeInstaller.js +9 -1
  75. package/lib/installers/ToolInstaller.js +4 -1
  76. package/lib/installers/WindsurfInstaller.js +0 -54
  77. package/package.json +3 -52
@@ -0,0 +1,705 @@
1
+ ---
2
+ name: run-execute
3
+ description: Execute work items based on their assigned mode (autopilot, confirm, validate). Supports single-item and multi-item (batch/wide) runs.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ <objective>
8
+ Execute work items based on their assigned mode (autopilot, confirm, validate).
9
+ Supports both single-item and multi-item (batch/wide) runs.
10
+ </objective>
11
+
12
+ <progress_display>
13
+ Show current position in workflow:
14
+
15
+ ```text
16
+ ### Run Progress
17
+ - [ ] Run initialized (init-run.cjs)
18
+ - [ ] Context loaded
19
+ - [ ] Plan generated ← {current_step}
20
+ - [ ] Implementation
21
+ - [ ] Tests passing
22
+ - [ ] Code review
23
+ - [ ] Run completed (complete-run.cjs)
24
+ - [ ] Walkthrough generated
25
+ ```
26
+
27
+ Update markers as you progress: [x] = done, ← current = active step
28
+ </progress_display>
29
+
30
+ <prerequisites>
31
+ Before executing scripts, ensure required dependencies are installed:
32
+
33
+ <step n="1" title="Check yaml Package">
34
+ <action>Run: npm list yaml --depth=0 2>/dev/null || echo "NOT_FOUND"</action>
35
+ <check if="output contains NOT_FOUND">
36
+ <output>Installing required dependency: yaml</output>
37
+ <action>Run: npm install yaml</action>
38
+ </check>
39
+ </step>
40
+
41
+ | Package | Purpose | Install Command |
42
+ |---------|---------|-----------------|
43
+ | `yaml` | Parse/stringify state.yaml | `npm install yaml` |
44
+
45
+ </prerequisites>
46
+
47
+ <triggers>
48
+ - Pending work item ready for execution
49
+ - Resumed from interrupted run
50
+ - Batch of work items passed from run-plan
51
+ </triggers>
52
+
53
+ <resume_detection critical="true">
54
+ Before starting execution, check if resuming an interrupted run:
55
+
56
+ <step n="0" title="Check for Active Run">
57
+ <action>Check state.yaml for runs.active[] array</action>
58
+
59
+ <check if="runs.active is empty">
60
+ <goto step="1">No active run, start fresh</goto>
61
+ </check>
62
+
63
+ <check if="runs.active has entries">
64
+ <action>Load active run from state.yaml runs.active[0]</action>
65
+ <action>Read scope (single/batch/wide) and work_items array</action>
66
+
67
+ <substep n="0a" title="Enumerate Work Item Status">
68
+ <action>For EACH work item in runs.active[0].work_items, classify by status:</action>
69
+ <action>Build status summary from state.yaml (NOT from artifact files):</action>
70
+ <format>
71
+ [DONE] {item-id} — completed
72
+ [WORKING] {item-id} (phase: {current_phase}) — in_progress
73
+ [PENDING] {item-id} — pending
74
+ </format>
75
+ <action>Count: completed={X}, in_progress={Y}, pending={Z}</action>
76
+ </substep>
77
+
78
+ <substep n="0b" title="Determine Resume Point for Current Item">
79
+ <action>Get current_item from state.yaml</action>
80
+ <action>Read current_phase from the current item's entry in work_items</action>
81
+
82
+ <determine_resume_point>
83
+ Use current_phase from state.yaml to determine resume point:
84
+
85
+ | current_phase | Resume At |
86
+ |---------------|-----------|
87
+ | plan (or unset) | Step 3 (Generate Plan) |
88
+ | execute | Step 5 (Implementation) |
89
+ | test | Step 6 (Run Tests) |
90
+ | review | Step 6b (Code Review) |
91
+ </determine_resume_point>
92
+ </substep>
93
+
94
+ <llm critical="true">
95
+ <mandate>NEVER call --complete-item for items with status "completed" — they are already done</mandate>
96
+ <mandate>NEVER re-execute steps (plan, implement, test) for completed items</mandate>
97
+ <mandate>ONLY work on the current_item identified in state.yaml</mandate>
98
+ <mandate>Use current_phase from state.yaml — do NOT infer phase from artifact file existence</mandate>
99
+ </llm>
100
+
101
+ <output>
102
+ Resuming run {run-id} ({scope}) for work item {current_item}.
103
+ Mode: {mode}
104
+ Phase: {current_phase}
105
+ Status: {completed_count} done, {in_progress_count} working, {pending_count} pending
106
+ Resuming at: Step {step_number}
107
+ </output>
108
+ </check>
109
+ </step>
110
+ </resume_detection>
111
+
112
+ <degrees_of_freedom>
113
+ Varies by mode:
114
+
115
+ - **Autopilot**: LOW — Execute standard patterns decisively
116
+ - **Confirm**: MEDIUM — Present plan, adjust based on feedback
117
+ - **Validate**: LOW — Follow approved design precisely
118
+ </degrees_of_freedom>
119
+
120
+ <llm critical="true">
121
+ <mandate>USE SCRIPTS — NEVER bypass init-run.cjs or complete-run.cjs</mandate>
122
+ <mandate>ALWAYS CREATE plan.md — Create plan BEFORE implementation starts (ALL modes)</mandate>
123
+ <mandate>ALWAYS CREATE test-report.md — Create test report AFTER tests complete</mandate>
124
+ <mandate>ALWAYS RUN code-review — Invoke code-review skill after tests pass</mandate>
125
+ <mandate>TRACK ALL FILE OPERATIONS — Every create, modify MUST be recorded</mandate>
126
+ <mandate>NEVER skip tests — Tests are mandatory, not optional</mandate>
127
+ <mandate>FOLLOW BROWNFIELD RULES — Read before write, match existing patterns</mandate>
128
+ </llm>
129
+
130
+ <artifact_timing critical="true">
131
+ Artifacts MUST be created at these points:
132
+
133
+ | Artifact | When Created | Created By |
134
+ |----------|--------------|------------|
135
+ | run.md | Start of run | init-run.cjs script |
136
+ | plan.md | BEFORE implementation (Step 4) | Agent using template |
137
+ | test-report.md | AFTER tests pass (Step 6) | Agent using template |
138
+ | review-report.md | AFTER test report (Step 6b) | code-review skill |
139
+ | walkthrough.md | After run completes (Step 8) | walkthrough-generate skill |
140
+
141
+ For batch runs: Append each work item's section to plan.md and test-report.md.
142
+ </artifact_timing>
143
+
144
+ <flow>
145
+ <step n="1" title="Initialize Run">
146
+ <hard_gate>
147
+ ⛔ HARD GATE - SCRIPT EXECUTION REQUIRED
148
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
149
+ You MUST call init-run.cjs script.
150
+ DO NOT use mkdir or create files directly.
151
+ The script creates BOTH the folder AND run.md file.
152
+ If you skip this, state.yaml will be inconsistent.
153
+ </hard_gate>
154
+
155
+ <action>Prepare work items JSON array:</action>
156
+ <code>
157
+ # For single item:
158
+ node scripts/init-run.cjs {rootPath} {workItemId} {intentId} {mode}
159
+
160
+ # For batch/wide (multiple items):
161
+ node scripts/init-run.cjs {rootPath} --batch '[
162
+ {"id": "item-1", "intent": "intent-1", "mode": "autopilot"},
163
+ {"id": "item-2", "intent": "intent-1", "mode": "confirm"}
164
+ ]' --scope=batch
165
+ </code>
166
+
167
+ <action>Parse script output for runId and runPath</action>
168
+ <action>Verify run.md was created in .specs-fire/runs/{run-id}/</action>
169
+
170
+ <check if="run.md not found">
171
+ <error>init-run.cjs failed to create run.md. Check script output.</error>
172
+ </check>
173
+ </step>
174
+
175
+ <step n="2" title="Load Work Item Context">
176
+ <note>For batch runs, repeat steps 2-6b for each work item</note>
177
+
178
+ <action>Get current_item from state.yaml runs.active[0]</action>
179
+ <action>Load work item from .specs-fire/intents/{intent}/work-items/{id}.md</action>
180
+ <action>Read intent brief for broader context</action>
181
+ <action>Load project standards using hierarchical resolution:</action>
182
+
183
+ <standards_resolution critical="true">
184
+ <substep n="2a" title="Discover Standards Locations">
185
+ <action>Scan repository for: **/.specs-fire/standards/</action>
186
+ <action>Build list sorted by path depth (root = depth 0)</action>
187
+ <example>
188
+ depth 0: .specs-fire/standards/
189
+ depth 2: packages/api/.specs-fire/standards/
190
+ depth 2: apps/mobile/.specs-fire/standards/
191
+ </example>
192
+ </substep>
193
+
194
+ <substep n="2b" title="Load Constitution (Root Only)">
195
+ <action>Load .specs-fire/standards/constitution.md from ROOT</action>
196
+ <critical>IGNORE any constitution.md in nested directories</critical>
197
+ <critical>Constitution is ALWAYS inherited, NEVER overridden</critical>
198
+ <note>If constitution.md doesn't exist, skip gracefully</note>
199
+ </substep>
200
+
201
+ <substep n="2c" title="Resolve Module Standards">
202
+ <action>For each discovered standards location (excluding root):</action>
203
+
204
+ <resolution_algorithm>
205
+ FOR each standard_file IN [tech-stack.md, coding-standards.md,
206
+ testing-standards.md, system-architecture.md]:
207
+
208
+ IF {location}/standards/{standard_file} EXISTS:
209
+ → USE this file for scope {location.parent_path}/**
210
+ ELSE:
211
+ → Walk UP to find nearest ancestor with this file
212
+ → USE ancestor's file (ultimately root if none found)
213
+ </resolution_algorithm>
214
+ </substep>
215
+
216
+ <substep n="2d" title="Present Standards with Scoping">
217
+ <action>Present loaded standards with clear path-based scoping:</action>
218
+
219
+ <output_format>
220
+ ## Constitution (applies to ALL files)
221
+ [content of root constitution.md]
222
+
223
+ ## Standards for {module_path}/** files
224
+ When editing files under {module_path}/, apply:
225
+ - Tech Stack: [resolved tech-stack.md for this scope]
226
+ - Coding Standards: [resolved coding-standards.md for this scope]
227
+ - Testing Standards: [resolved testing-standards.md for this scope]
228
+
229
+ ## Default Standards (paths without specific scope)
230
+ For all other files, apply root standards.
231
+ </output_format>
232
+ </substep>
233
+ </standards_resolution>
234
+
235
+ <action>Determine execution mode from work item</action>
236
+ </step>
237
+
238
+ <step n="3a" title="Autopilot Mode" if="mode == autopilot">
239
+ <output>
240
+ Executing in Autopilot mode (0 checkpoints).
241
+ Work item: {title}
242
+ </output>
243
+ <goto step="4"/>
244
+ </step>
245
+
246
+ <step n="3b" title="Confirm Mode" if="mode == confirm">
247
+ <action>Generate implementation plan</action>
248
+ <action>Save plan IMMEDIATELY using template: templates/plan.md.hbs</action>
249
+ <action>Write to: .specs-fire/runs/{run-id}/plan.md</action>
250
+ <output>Plan saved to: .specs-fire/runs/{run-id}/plan.md</output>
251
+
252
+ <checkpoint>
253
+ <template_output section="plan">
254
+ ## Implementation Plan for "{title}"
255
+
256
+ ### Approach
257
+ {describe approach}
258
+
259
+ ### Files to Create
260
+ {list files}
261
+
262
+ ### Files to Modify
263
+ {list files}
264
+
265
+ ### Tests
266
+ {list test files}
267
+
268
+ ---
269
+ Approve plan? [Y/n/edit]
270
+ </template_output>
271
+ </checkpoint>
272
+
273
+ <check if="response == edit">
274
+ <ask>What changes to the plan?</ask>
275
+ <action>Adjust plan</action>
276
+ <action>Update plan.md with changes</action>
277
+ <goto step="3b"/>
278
+ </check>
279
+ <goto step="5"/>
280
+ </step>
281
+
282
+ <step n="3c" title="Validate Mode" if="mode == validate">
283
+ <action>Load design doc from .specs-fire/intents/{intent}/work-items/{id}-design.md</action>
284
+ <action>Generate implementation plan based on design</action>
285
+ <action>Save plan IMMEDIATELY using template: templates/plan.md.hbs</action>
286
+ <action>Write to: .specs-fire/runs/{run-id}/plan.md</action>
287
+ <action>Include reference to design doc in plan</action>
288
+ <output>Plan saved to: .specs-fire/runs/{run-id}/plan.md</output>
289
+
290
+ <checkpoint>
291
+ <template_output section="plan">
292
+ ## Implementation Plan for "{title}"
293
+
294
+ Based on approved design document.
295
+
296
+ ### Implementation Checklist
297
+ {from design doc}
298
+
299
+ ### Files to Create
300
+ {list files}
301
+
302
+ ### Files to Modify
303
+ {list files}
304
+
305
+ ---
306
+ This is Checkpoint 2 of Validate mode.
307
+ Approve implementation plan? [Y/n/edit]
308
+ </template_output>
309
+ </checkpoint>
310
+
311
+ <check if="response == edit">
312
+ <ask>What changes to the plan?</ask>
313
+ <action>Adjust plan</action>
314
+ <action>Update plan.md with changes</action>
315
+ <goto step="3c"/>
316
+ </check>
317
+ <goto step="5"/>
318
+ </step>
319
+
320
+ <step n="4" title="Generate Plan (Autopilot Only)" if="mode == autopilot">
321
+ <note>Confirm and Validate modes already saved plan in Step 3b/3c</note>
322
+
323
+ <batch_handling critical="true">
324
+ <check if="batch/wide run AND plan.md already exists">
325
+ <action>Read existing plan.md content</action>
326
+ <action>Append new section for current work item:</action>
327
+ <format>
328
+ ---
329
+
330
+ ## Work Item: {work_item_id}
331
+
332
+ ### Approach
333
+ {describe approach for this specific work item}
334
+
335
+ ### Files to Create
336
+ {list files}
337
+
338
+ ### Files to Modify
339
+ {list files}
340
+
341
+ ### Tests
342
+ {list test files}
343
+ </format>
344
+ <action>Write updated plan.md (preserving previous sections)</action>
345
+ </check>
346
+
347
+ <check if="plan.md does not exist OR single run">
348
+ <action>Generate implementation plan</action>
349
+ <action>Save plan using template: templates/plan.md.hbs</action>
350
+ <action>Write to: .specs-fire/runs/{run-id}/plan.md</action>
351
+ </check>
352
+ </batch_handling>
353
+
354
+ <output>
355
+ Plan saved to: .specs-fire/runs/{run-id}/plan.md
356
+ (Autopilot mode - continuing without checkpoint)
357
+ </output>
358
+ <note>No checkpoint in autopilot - human can review plan.md while agent works</note>
359
+ </step>
360
+
361
+ <step n="5" title="Execute Implementation">
362
+ <action>Update phase to 'execute':</action>
363
+ <code>node scripts/update-phase.cjs {rootPath} {runId} execute</code>
364
+
365
+ <action>For each planned change:</action>
366
+ <substep n="5a">Implement the change</substep>
367
+ <substep n="5b">Track file operation (create/modify)</substep>
368
+ <substep n="5c">Record decisions made</substep>
369
+
370
+ <standards_application critical="true">
371
+ When editing a file at path X:
372
+ 1. Find the LONGEST matching standards scope (most specific)
373
+ 2. Apply those standards to the file
374
+ 3. If no specific scope matches, apply root standards
375
+
376
+ <example>
377
+ Editing packages/api/src/handler.go
378
+ → Apply "Standards for packages/api/**"
379
+
380
+ Editing scripts/deploy.sh
381
+ → Apply "Default Standards" (root)
382
+ </example>
383
+ </standards_application>
384
+
385
+ <brownfield_rules>
386
+ <rule>READ existing code before modifying</rule>
387
+ <rule>MATCH existing naming conventions</rule>
388
+ <rule>FOLLOW existing patterns in the codebase</rule>
389
+ <rule>PRESERVE existing tests</rule>
390
+ <rule>USE module-specific standards when editing module files</rule>
391
+ </brownfield_rules>
392
+ </step>
393
+
394
+ <step n="6" title="Run Tests">
395
+ <action>Update phase to 'test':</action>
396
+ <code>node scripts/update-phase.cjs {rootPath} {runId} test</code>
397
+
398
+ <action>Load testing standards from .specs-fire/standards/testing-standards.md</action>
399
+ <action>Write tests following testing standards:</action>
400
+ <substep>Unit tests for new/modified functions</substep>
401
+ <substep>Integration tests for API endpoints or workflows</substep>
402
+ <substep>Follow test naming and structure conventions</substep>
403
+
404
+ <action>Run test suite</action>
405
+ <check if="tests fail">
406
+ <output>Tests failed. Fixing issues...</output>
407
+ <action>Fix failing tests</action>
408
+ <action>Re-run tests</action>
409
+ </check>
410
+
411
+ <action>Validate acceptance criteria from work item</action>
412
+
413
+ <critical>Create test report AFTER tests pass</critical>
414
+
415
+ <batch_handling critical="true">
416
+ <check if="batch/wide run AND test-report.md already exists">
417
+ <action>Read existing test-report.md content</action>
418
+ <action>Append new section for current work item:</action>
419
+ <format>
420
+ ---
421
+
422
+ ## Work Item: {work_item_id}
423
+
424
+ ### Test Results
425
+ - Passed: {passed_count}
426
+ - Failed: {failed_count}
427
+ - Skipped: {skipped_count}
428
+
429
+ ### Acceptance Criteria Validation
430
+ {validation_results}
431
+ </format>
432
+ <action>Write updated test-report.md (preserving previous sections)</action>
433
+ </check>
434
+
435
+ <check if="test-report.md does not exist OR single run">
436
+ <action>Generate test report using template: templates/test-report.md.hbs</action>
437
+ <action>Write to: .specs-fire/runs/{run-id}/test-report.md</action>
438
+ </check>
439
+ </batch_handling>
440
+
441
+ <action>Include in test report:</action>
442
+ <substep>Test results summary (passed/failed/skipped)</substep>
443
+ <substep>Code coverage percentage</substep>
444
+ <substep>Acceptance criteria validation results</substep>
445
+ <substep>Any test warnings or notes</substep>
446
+ <output>Test report saved to: .specs-fire/runs/{run-id}/test-report.md</output>
447
+ </step>
448
+
449
+ <step n="6b" title="Code Review">
450
+ <action>Update phase to 'review':</action>
451
+ <code>node scripts/update-phase.cjs {rootPath} {runId} review</code>
452
+
453
+ <critical>ALWAYS run code review after tests pass</critical>
454
+ <output>Running code review...</output>
455
+
456
+ <action>Invoke code-review skill with context:</action>
457
+ <code>
458
+ invoke-skill: code-review
459
+ context:
460
+ files_created: {files_created}
461
+ files_modified: {files_modified}
462
+ run_id: {run_id}
463
+ intent_id: {intent_id}
464
+ </code>
465
+
466
+ <invoke_skill>code-review</invoke_skill>
467
+
468
+ <note>
469
+ Code review skill will:
470
+ 1. Review all files created/modified in this work item
471
+ 2. Auto-fix no-brainer issues (unused imports, console.log, etc.)
472
+ 3. Present suggestions requiring approval
473
+ 4. Create review-report.md artifact
474
+ </note>
475
+
476
+ <check if="code-review returns suggestions">
477
+ <note>User interaction happens within code-review skill</note>
478
+ <action>Wait for code-review skill to complete</action>
479
+ </check>
480
+
481
+ <check if="code-review applied fixes">
482
+ <action>Re-run tests to verify fixes didn't break anything</action>
483
+ <check if="tests fail">
484
+ <output>Code review fixes caused test failure. Reverting...</output>
485
+ <action>Revert code review changes</action>
486
+ <action>Re-run tests to confirm passing</action>
487
+ </check>
488
+ </check>
489
+
490
+ <output>
491
+ Code review complete.
492
+ Review report: .specs-fire/runs/{run-id}/review-report.md
493
+ </output>
494
+ </step>
495
+
496
+ <step n="7" title="Complete Current Work Item">
497
+ <hard_gate>
498
+ ⛔ HARD GATE - SCRIPT EXECUTION REQUIRED
499
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
500
+ You MUST call complete-run.cjs script.
501
+ DO NOT manually update state.yaml or run.md.
502
+ Use --complete-item for batch runs with remaining items.
503
+ Use --complete-run only when ALL items are done.
504
+ If you skip this, state becomes inconsistent.
505
+ </hard_gate>
506
+
507
+ <llm critical="true">
508
+ <mandate>BATCH RUNS: You MUST loop until ALL items are done</mandate>
509
+ <mandate>NEVER call --complete-run until ALL items have artifacts</mandate>
510
+ <mandate>ALWAYS check pending count BEFORE deciding which flag to use</mandate>
511
+ </llm>
512
+
513
+ <substep n="7a" title="Check Batch Status">
514
+ <action>Read state.yaml runs.active[{runId}]</action>
515
+ <action>Get scope value: single, batch, or wide</action>
516
+ <action>Count work_items where status == "pending"</action>
517
+ <action>Store pending_count for decision</action>
518
+ </substep>
519
+
520
+ <substep n="7b" title="Route Based on Batch Status">
521
+ <check if="scope in [batch, wide] AND pending_count > 0">
522
+ <critical>DO NOT call --complete-run yet - more items remain!</critical>
523
+ <action>Call complete-run.cjs with --complete-item flag:</action>
524
+ <code>
525
+ node scripts/complete-run.cjs {rootPath} {runId} --complete-item
526
+ </code>
527
+ <action>Parse output JSON for nextItem and remainingItems</action>
528
+ <output>
529
+ Completed: {current_item}
530
+ Next item: {nextItem}
531
+ Remaining: {remainingItems} items
532
+ </output>
533
+ <goto step="2">MUST continue with next work item - loop back NOW</goto>
534
+ </check>
535
+
536
+ <check if="scope == single OR pending_count == 0">
537
+ <action>All items complete - finalize the run</action>
538
+ <action>Call complete-run.cjs with --complete-run flag:</action>
539
+ <code>
540
+ node scripts/complete-run.cjs {rootPath} {runId} --complete-run \
541
+ --files-created='[{"path":"...","purpose":"..."}]' \
542
+ --files-modified='[{"path":"...","changes":"..."}]' \
543
+ --tests=5 --coverage=85
544
+ </code>
545
+ <goto step="8"/>
546
+ </check>
547
+ </substep>
548
+ </step>
549
+
550
+ <step n="8" title="Generate Walkthrough">
551
+ <invoke_skill>walkthrough-generate</invoke_skill>
552
+ </step>
553
+
554
+ <step n="9" title="Report Completion">
555
+ <output>
556
+ Run {run-id} completed.
557
+
558
+ Work items completed: {count}
559
+ Files created: {count}
560
+ Files modified: {count}
561
+ Tests added: {count}
562
+
563
+ Artifacts:
564
+ - Run Log: .specs-fire/runs/{run-id}/run.md
565
+ - Plan: .specs-fire/runs/{run-id}/plan.md
566
+ - Test Report: .specs-fire/runs/{run-id}/test-report.md
567
+ - Code Review: .specs-fire/runs/{run-id}/review-report.md
568
+ - Walkthrough: .specs-fire/runs/{run-id}/walkthrough.md
569
+ </output>
570
+ </step>
571
+ </flow>
572
+
573
+ <scripts>
574
+ | Script | Purpose | Usage |
575
+ |--------|---------|-------|
576
+ | `scripts/init-run.cjs` | Initialize run record and folder | Creates run.md with all work items |
577
+ | `scripts/update-phase.cjs` | Update current work item's phase | `node scripts/update-phase.cjs {rootPath} {runId} {phase}` |
578
+ | `scripts/complete-run.cjs` | Finalize run and update state | `--complete-item` or `--complete-run` |
579
+
580
+ <script name="init-run.cjs">
581
+ ```bash
582
+ # Single work item
583
+ node scripts/init-run.cjs /project work-item-id intent-id autopilot
584
+
585
+ # Batch/wide (multiple items)
586
+ node scripts/init-run.cjs /project --batch '[
587
+ {"id": "wi-1", "intent": "int-1", "mode": "autopilot"},
588
+ {"id": "wi-2", "intent": "int-1", "mode": "confirm"}
589
+ ]' --scope=batch
590
+ ```
591
+
592
+ <output_format>
593
+ ```json
594
+ {
595
+ "success": true,
596
+ "runId": "run-001",
597
+ "runPath": "/project/.specs-fire/runs/run-001",
598
+ "scope": "batch",
599
+ "workItems": [...],
600
+ "currentItem": "wi-1"
601
+ }
602
+ ```
603
+ </output_format>
604
+ </script>
605
+
606
+ <script name="complete-run.cjs">
607
+ ```bash
608
+ # Complete current item (batch runs - moves to next item)
609
+ node scripts/complete-run.cjs /project run-001 --complete-item
610
+
611
+ # Complete entire run (single runs or final item in batch)
612
+ node scripts/complete-run.cjs /project run-001 --complete-run \
613
+ --files-created='[{"path":"src/new.ts","purpose":"New feature"}]' \
614
+ --files-modified='[{"path":"src/old.ts","changes":"Added import"}]' \
615
+ --tests=5 --coverage=85
616
+ ```
617
+
618
+ <complete_item_output>
619
+ ```json
620
+ {
621
+ "success": true,
622
+ "runId": "run-001",
623
+ "completedItem": "wi-1",
624
+ "nextItem": "wi-2",
625
+ "remainingItems": 1,
626
+ "allItemsCompleted": false
627
+ }
628
+ ```
629
+ </complete_item_output>
630
+
631
+ <complete_run_output>
632
+ ```json
633
+ {
634
+ "success": true,
635
+ "runId": "run-001",
636
+ "scope": "batch",
637
+ "workItemsCompleted": 2,
638
+ "completedAt": "2026-01-20T..."
639
+ }
640
+ ```
641
+ </complete_run_output>
642
+ </script>
643
+ </scripts>
644
+
645
+ <file_tracking_format>
646
+
647
+ ```yaml
648
+ files_created:
649
+ - path: src/auth/login.ts
650
+ purpose: Login endpoint handler
651
+
652
+ files_modified:
653
+ - path: src/routes/index.ts
654
+ changes: Added login route
655
+
656
+ decisions:
657
+ - decision: Use JWT for tokens
658
+ rationale: Stateless, works with load balancer
659
+ ```
660
+
661
+ </file_tracking_format>
662
+
663
+ <run_folder_structure>
664
+ After init-run.cjs creates a run:
665
+
666
+ ```
667
+ .specs-fire/runs/run-001/
668
+ ├── run.md # Created by init-run.cjs, updated by complete-run.cjs
669
+ ├── plan.md # Created BEFORE implementation (ALL modes - required)
670
+ ├── test-report.md # Created AFTER tests pass (required)
671
+ ├── review-report.md # Created by code-review skill (Step 6b)
672
+ └── walkthrough.md # Created by walkthrough-generate skill
673
+ ```
674
+
675
+ <timeline>
676
+ 1. `run.md` — Created at run start by init-run.cjs
677
+ 2. `plan.md` — Created BEFORE implementation begins (Step 4)
678
+ 3. `test-report.md` — Created AFTER tests pass (Step 6)
679
+ 4. `review-report.md` — Created by code-review skill (Step 6b)
680
+ 5. `walkthrough.md` — Created after run completes (Step 8)
681
+ </timeline>
682
+
683
+ The run.md contains:
684
+
685
+ - All work items with their statuses
686
+ - Current item being executed
687
+ - Files created/modified (after completion)
688
+ - Decisions made (after completion)
689
+ - Summary (after completion)
690
+ </run_folder_structure>
691
+
692
+ <success_criteria>
693
+ <criterion>Run initialized via init-run.cjs script</criterion>
694
+ <criterion>Standards loaded with hierarchical resolution</criterion>
695
+ <criterion>Constitution loaded from root (if exists)</criterion>
696
+ <criterion>Module-specific standards applied to module files</criterion>
697
+ <criterion>plan.md created BEFORE implementation</criterion>
698
+ <criterion>All work items implemented</criterion>
699
+ <criterion>All tests pass</criterion>
700
+ <criterion>test-report.md created AFTER tests pass</criterion>
701
+ <criterion>code-review skill invoked and completed</criterion>
702
+ <criterion>review-report.md created</criterion>
703
+ <criterion>Run completed via complete-run.cjs script</criterion>
704
+ <criterion>walkthrough.md generated</criterion>
705
+ </success_criteria>