@ydtb/specsmd 0.1.22

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