@atlashub/smartstack-cli 4.41.0 → 4.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/.documentation/apex.html +2 -2
  2. package/.documentation/business-analyse.html +26 -27
  3. package/.documentation/commands.html +6 -6
  4. package/dist/index.js +24 -13
  5. package/dist/index.js.map +1 -1
  6. package/package.json +2 -2
  7. package/templates/agents/ba-reader.md +2 -2
  8. package/templates/agents/ba-writer.md +44 -9
  9. package/templates/hooks/stop-hook.sh +6 -6
  10. package/templates/ralph/README.md +1 -1
  11. package/templates/scripts/setup-ralph-loop.sh +2 -2
  12. package/templates/skills/_resources/context-digest-template.md +1 -1
  13. package/templates/skills/_shared.md +13 -13
  14. package/templates/skills/apex/SKILL.md +14 -7
  15. package/templates/skills/apex/_shared.md +1 -1
  16. package/templates/skills/apex/references/challenge-questions.md +46 -13
  17. package/templates/skills/apex/references/core-seed-data.md +4 -4
  18. package/templates/skills/apex/references/error-classification.md +3 -3
  19. package/templates/skills/apex/references/smartstack-api.md +1 -1
  20. package/templates/skills/apex/references/smartstack-layers.md +1 -1
  21. package/templates/skills/apex/steps/step-00-init.md +46 -8
  22. package/templates/skills/apex/steps/step-01-analyze.md +1 -1
  23. package/templates/skills/apex/steps/step-02-plan.md +1 -1
  24. package/templates/skills/apex/steps/step-03-execute.md +1 -1
  25. package/templates/skills/business-analyse/SKILL.md +83 -22
  26. package/templates/skills/business-analyse/_shared.md +12 -9
  27. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +24 -9
  28. package/templates/skills/business-analyse/questionnaire/03-data-ui.md +33 -0
  29. package/templates/skills/business-analyse/questionnaire/04-risks-metrics.md +1 -1
  30. package/templates/skills/business-analyse/react/components.md +1 -22
  31. package/templates/skills/business-analyse/react/schema.md +1 -1
  32. package/templates/skills/business-analyse/references/acceptance-criteria.md +3 -3
  33. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +1 -1
  34. package/templates/skills/business-analyse/references/detection-strategies.md +2 -2
  35. package/templates/skills/business-analyse/references/entity-architecture-decision.md +1 -1
  36. package/templates/skills/business-analyse/references/naming-conventions.md +6 -6
  37. package/templates/skills/business-analyse/references/robustness-checks.md +4 -4
  38. package/templates/skills/business-analyse/references/spec-auto-inference.md +2 -2
  39. package/templates/skills/business-analyse/references/validation-checklist.md +3 -3
  40. package/templates/skills/business-analyse/schemas/feature-schema.json +1 -1
  41. package/templates/skills/business-analyse/schemas/sections/handoff-schema.json +2 -2
  42. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +3 -2
  43. package/templates/skills/business-analyse/steps/step-00-init.md +15 -5
  44. package/templates/skills/business-analyse/steps/step-01-cadrage.md +15 -6
  45. package/templates/skills/business-analyse/steps/step-02-structure.md +17 -1
  46. package/templates/skills/business-analyse/steps/step-03-specify.md +136 -26
  47. package/templates/skills/business-analyse/steps/step-04-consolidate.md +44 -8
  48. package/templates/skills/business-analyse/templates/tpl-handoff.md +5 -5
  49. package/templates/skills/business-analyse/templates/tpl-launch-displays.md +4 -4
  50. package/templates/skills/business-analyse/templates-frd.md +4 -4
  51. package/templates/skills/{ba-design-ui → business-analyse-design}/SKILL.md +9 -9
  52. package/templates/skills/{ba-design-ui → business-analyse-design}/steps/step-01-screens.md +9 -0
  53. package/templates/skills/{ba-design-ui → business-analyse-design}/steps/step-03-navigation.md +9 -2
  54. package/templates/skills/business-analyse-develop/SKILL.md +248 -0
  55. package/templates/skills/{ralph-loop → business-analyse-develop}/references/category-completeness.md +1 -1
  56. package/templates/skills/{ralph-loop → business-analyse-develop}/references/init-resume-recovery.md +8 -8
  57. package/templates/skills/{ralph-loop → business-analyse-develop}/references/multi-module-queue.md +1 -1
  58. package/templates/skills/business-analyse-develop/references/quality-gates.md +70 -0
  59. package/templates/skills/{ralph-loop → business-analyse-develop}/references/task-transform-legacy.md +1 -1
  60. package/templates/skills/{ralph-loop → business-analyse-develop}/steps/step-00-init.md +20 -4
  61. package/templates/skills/{ralph-loop → business-analyse-develop}/steps/step-01-task.md +3 -2
  62. package/templates/skills/business-analyse-develop/steps/step-01-v4-execute.md +131 -0
  63. package/templates/skills/business-analyse-develop/steps/step-02-v4-verify.md +156 -0
  64. package/templates/skills/{ralph-loop → business-analyse-develop}/steps/step-04-check.md +1 -1
  65. package/templates/skills/{ralph-loop → business-analyse-develop}/steps/step-05-report.md +1 -1
  66. package/templates/skills/{derive-prd → business-analyse-handoff}/SKILL.md +7 -7
  67. package/templates/skills/{derive-prd → business-analyse-handoff}/references/acceptance-criteria.md +5 -5
  68. package/templates/skills/{derive-prd → business-analyse-handoff}/references/handoff-file-templates.md +1 -1
  69. package/templates/skills/{derive-prd → business-analyse-handoff}/references/handoff-mappings.md +1 -1
  70. package/templates/skills/{derive-prd → business-analyse-handoff}/references/handoff-seeddata-generation.md +2 -2
  71. package/templates/skills/{derive-prd → business-analyse-handoff}/references/prd-generation.md +14 -14
  72. package/templates/skills/{derive-prd → business-analyse-handoff}/schemas/handoff-schema.json +2 -2
  73. package/templates/skills/{derive-prd → business-analyse-handoff}/steps/step-00-validate.md +7 -7
  74. package/templates/skills/{derive-prd → business-analyse-handoff}/steps/step-01-transform.md +50 -11
  75. package/templates/skills/{derive-prd → business-analyse-handoff}/steps/step-02-export.md +36 -16
  76. package/templates/skills/{ba-generate-html → business-analyse-html}/SKILL.md +4 -4
  77. package/templates/skills/{ba-generate-html → business-analyse-html}/html/ba-interactive.html +714 -286
  78. package/templates/skills/{ba-generate-html → business-analyse-html}/html/build-html.js +25 -3
  79. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/01-data-init.js +54 -0
  80. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/02-navigation.js +102 -12
  81. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/03-render-cadrage.js +8 -7
  82. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/04-render-modules.js +7 -7
  83. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/05-render-specs.js +188 -85
  84. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/06-render-consolidation.js +15 -14
  85. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/06-render-mockups.js +19 -19
  86. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/07-render-handoff.js +24 -4
  87. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/08-editing.js +6 -2
  88. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/09-export.js +27 -57
  89. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/10-comments.js +67 -45
  90. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/scripts/11-review-panel.js +15 -13
  91. package/templates/skills/business-analyse-html/html/src/styles/02-layout.css +216 -0
  92. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/05-modules.css +36 -0
  93. package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/template.html +22 -12
  94. package/templates/skills/{ba-generate-html → business-analyse-html}/references/data-build.md +1 -1
  95. package/templates/skills/{ba-generate-html → business-analyse-html}/references/data-mapping.md +5 -1
  96. package/templates/skills/{ba-generate-html → business-analyse-html}/references/output-modes.md +7 -7
  97. package/templates/skills/{ba-generate-html → business-analyse-html}/steps/step-01-collect.md +25 -1
  98. package/templates/skills/{ba-generate-html → business-analyse-html}/steps/step-02-build-data.md +33 -5
  99. package/templates/skills/{ba-generate-html → business-analyse-html}/steps/step-03-render.md +2 -2
  100. package/templates/skills/{ba-generate-html → business-analyse-html}/steps/step-04-verify.md +2 -2
  101. package/templates/skills/{ba-review → business-analyse-review}/SKILL.md +11 -10
  102. package/templates/skills/{ba-review → business-analyse-review}/references/review-data-mapping.md +2 -2
  103. package/templates/skills/business-analyse-review/steps/step-00-init.md +107 -0
  104. package/templates/skills/{ba-review → business-analyse-review}/steps/step-01-apply.md +19 -11
  105. package/templates/skills/business-analyse-status/SKILL.md +118 -0
  106. package/templates/skills/documentation/SKILL.md +2 -2
  107. package/templates/skills/sketch/SKILL.md +172 -0
  108. package/templates/skills/sketch/references/domain-heuristics.md +116 -0
  109. package/templates/skills/ba-generate-html/html/src/styles/02-layout.css +0 -101
  110. package/templates/skills/ralph-loop/SKILL.md +0 -240
  111. /package/templates/skills/{ba-design-ui → business-analyse-design}/steps/step-02-wireframes.md +0 -0
  112. /package/templates/skills/{ralph-loop → business-analyse-develop}/references/category-rules.md +0 -0
  113. /package/templates/skills/{ralph-loop → business-analyse-develop}/references/compact-loop.md +0 -0
  114. /package/templates/skills/{ralph-loop → business-analyse-develop}/references/module-transition.md +0 -0
  115. /package/templates/skills/{ralph-loop → business-analyse-develop}/references/parallel-execution.md +0 -0
  116. /package/templates/skills/{ralph-loop → business-analyse-develop}/references/section-splitting.md +0 -0
  117. /package/templates/skills/{ralph-loop → business-analyse-develop}/references/team-orchestration.md +0 -0
  118. /package/templates/skills/{ralph-loop → business-analyse-develop}/steps/step-02-execute.md +0 -0
  119. /package/templates/skills/{ralph-loop → business-analyse-develop}/steps/step-03-commit.md +0 -0
  120. /package/templates/skills/{derive-prd → business-analyse-handoff}/references/entity-domain-mapping.md +0 -0
  121. /package/templates/skills/{derive-prd → business-analyse-handoff}/references/readiness-scoring.md +0 -0
  122. /package/templates/skills/{derive-prd → business-analyse-handoff}/templates/tpl-progress.md +0 -0
  123. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/cadrage-context.html +0 -0
  124. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/cadrage-scope.html +0 -0
  125. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/cadrage-stakeholders.html +0 -0
  126. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/cadrage-success.html +0 -0
  127. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/consol-datamodel.html +0 -0
  128. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/consol-flows.html +0 -0
  129. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/consol-interactions.html +0 -0
  130. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/consol-permissions.html +0 -0
  131. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/decomp-dependencies.html +0 -0
  132. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/decomp-modules.html +0 -0
  133. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/handoff-summary.html +0 -0
  134. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/partials/module-spec-container.html +0 -0
  135. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/01-variables.css +0 -0
  136. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/03-navigation.css +0 -0
  137. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/04-cards.css +0 -0
  138. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/06-wireframes.css +0 -0
  139. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/07-comments.css +0 -0
  140. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/08-review-panel.css +0 -0
  141. /package/templates/skills/{ba-generate-html → business-analyse-html}/html/src/styles/09-mockups-html.css +0 -0
  142. /package/templates/skills/{ba-generate-html → business-analyse-html}/references/wireframe-svg-style-guide.md +0 -0
@@ -127,8 +127,15 @@ Write via ba-writer at project level (alongside master index.json). Update index
127
127
  | navigation.json | {project-path}/navigation.json |
128
128
 
129
129
  NEXT STEPS:
130
- 1. Run /ba-generate-html to produce the interactive HTML with mockups
130
+ 1. Run /business-analyse-html to produce the interactive HTML with mockups
131
131
  2. Client reviews the HTML (mockups, ERD, permission matrix)
132
- 3. Run /ba-review to apply corrections
132
+ 3. Run /business-analyse-review to apply corrections
133
133
  ================================================================
134
134
  ```
135
+
136
+ ## Status Update
137
+
138
+ After writing all screens and navigation, update the application status:
139
+ ```javascript
140
+ ba-writer.updateStatus({feature_id}, "designed")
141
+ ```
@@ -0,0 +1,248 @@
1
+ ---
2
+ name: business-analyse-develop
3
+ description: Autonomous development from PRD — implements the full application with MCP validation, quality gates, and completion guarantees.
4
+ argument-hint: "[-m N] [-c TEXT] [-v] <task description>"
5
+ ---
6
+
7
+ <objective>
8
+ Execute the Ralph Weegund technique — module orchestration with autonomous code generation. Ralph reads PRDs from `/business-analyse-handoff`, resolves dependencies, and delegates all code generation to `/apex -d`.
9
+
10
+ **Key principle:** Ralph ORCHESTRATES (module sequencing, quality gates, reporting). All code generation is delegated to `/apex`.
11
+ </objective>
12
+
13
+ <quick_start>
14
+
15
+ **From Business Analysis (RECOMMENDED):**
16
+ ```bash
17
+ /business-analyse MyFeature
18
+ # Then: /business-analyse-handoff
19
+ # Then: /business-analyse-develop -r
20
+ ```
21
+
22
+ **Manual start:**
23
+ ```bash
24
+ /business-analyse-develop implement user authentication
25
+ /business-analyse-develop -c "COMPLETE" -m 20 refactor cache layer
26
+ /business-analyse-develop -r # Resume previous
27
+ ```
28
+
29
+ **Flags:** `-m N` (max iterations), `-c TEXT` (completion promise), `-v` (verbose), `-r` (resume), `-p` (parallel)
30
+
31
+ </quick_start>
32
+
33
+ <parameters>
34
+ | Short | Long | Description |
35
+ |-------|------|-------------|
36
+ | `-m N` | `--max-iterations N` | Max iterations (default: 50, v4: adaptive) |
37
+ | `-c TEXT` | `--completion-promise TEXT` | Completion signal text |
38
+ | `-v` | `--verbose` | Detailed logging |
39
+ | `-r` | `--resume` | Resume from previous state |
40
+ | `-p` | `--parallel` | Teams mode: Phase 0 sequential, then parallel per module |
41
+ </parameters>
42
+
43
+ <prd_format_detection>
44
+
45
+ ## PRD Format Detection
46
+
47
+ Ralph supports two PRD formats:
48
+
49
+ | | PRD v3 (task-oriented) | PRD v4 (spec-oriented) |
50
+ |---|---|---|
51
+ | **Detection** | `$version === '3.0.0'` + `tasks[]` present | `$version === '4.0.0'` + `objectives[]` present |
52
+ | **Execution model** | Batch iterations (compact-loop) | Continuous session (compaction manages context) |
53
+ | **Context management** | Manual: "Read Once" rule, max 5 tasks/batch | Automatic: server-side compaction |
54
+ | **Progress tracking** | progress.txt as state machine | Optional checkpoints |
55
+ | **Splitting** | By token budget (>4 entities) | By logical feature (by section) |
56
+ | **Steps** | 6 steps + compact-loop.md | 3 steps: init → execute → verify |
57
+
58
+ **Backward compatibility:** v3 PRDs execute with the EXACT same behavior as before. v4 is opt-in via `/business-analyse-handoff --v4`.
59
+
60
+ </prd_format_detection>
61
+
62
+ <workflow>
63
+
64
+ ## v4 Workflow (spec-oriented — RECOMMENDED)
65
+
66
+ **Single module:**
67
+ 1. **Init** (step-00): parse flags, verify MCP, load PRD v4, detect modules
68
+ 2. **Execute** (step-01-v4): delegate entire module to `/apex -d` as one continuous session
69
+ - `/apex` reads the spec (architecture, objectives, acceptance criteria)
70
+ - `/apex` decides execution order (domain → infra → app → api → seed → frontend → tests)
71
+ - Ralph intercepts at natural checkpoints for quality gates
72
+ - Server-side compaction manages context automatically
73
+ 3. **Verify + Report** (step-02-v4): run ALL quality gates, generate report
74
+
75
+ **Multi-module:**
76
+ 1. Init: detect prd-*.json files, build topological order
77
+ 2. For each module in order → Execute (continuous session per module)
78
+ 3. Cross-module verify + final report
79
+
80
+ **Quality gates (same as v3):**
81
+ - `dotnet build` (BLOCKING)
82
+ - `dotnet test` (BLOCKING after build)
83
+ - `npm test` / `npm run typecheck` (BLOCKING for frontend)
84
+ - MCP `validate_security` + `validate_conventions`
85
+ - BR coverage check (each BR has implementation)
86
+ - File reconciliation (expectedFiles vs disk)
87
+ - Stub test detection (reject empty tests)
88
+
89
+ ## v3 Workflow (task-oriented — LEGACY)
90
+
91
+ **Single module:**
92
+ 1. Init: parse flags, verify MCP, setup .ralph/ (step-00)
93
+ 2. Load tasks from prd.json — unified v3 has pre-computed tasks (step-01, step FILE read once)
94
+ 3. Execute first task (step-02, step FILE read once)
95
+ 4. Commit + update progress (step-03, step FILE read once)
96
+ 5. Check completion → enter COMPACT LOOP (step-04)
97
+ 6. **COMPACT LOOP** (step-04 → references/compact-loop.md):
98
+ - Find eligible → batch by category (max 5) → execute → test → commit → loop
99
+ 7. Report (step-05)
100
+
101
+ **Multi-module with `-p` (parallel mode):**
102
+ 1. Init: detect prd-*.json, parse `-p` flag (step-00)
103
+ 2. **Phase 0 (Ralph sequential):** ALL entities from ALL modules via `/apex --foundation`
104
+ 3. **Phase 1-N (Teams parallel):** Spawn teammates per module
105
+ 4. Report with per-module aggregation (step-05)
106
+
107
+ **Multi-module WITHOUT `-p` (sequential — legacy):**
108
+ 1. Init: detect prd-*.json, read dependency layers (step-00)
109
+ 2. Compact loop per module in topological order
110
+ 3. Report with per-module aggregation (step-05)
111
+
112
+ </workflow>
113
+
114
+ <state_variables>
115
+ | Variable | Type | v3 | v4 | Description |
116
+ |----------|------|----|----|-------------|
117
+ | `{max_iterations}` | number | Yes | Adaptive | Max iterations |
118
+ | `{current_iteration}` | number | Yes | No | Current iteration counter |
119
+ | `{current_module}` | string | Yes | Yes | Current module being processed |
120
+ | `{modules_queue}` | object | Yes | Yes | Module queue (multi-module) |
121
+ | `{prd_version}` | '3.0.0' \| '4.0.0' | Yes | Yes | Detected PRD format |
122
+ | `{section_split_mode}` | boolean | Yes | No | v3 only: section splitting active |
123
+ | `{parallel_mode}` | boolean | Yes | Yes | Teams mode via `-p` |
124
+ </state_variables>
125
+
126
+ <mcp_requirements>
127
+ **MANDATORY before any work:**
128
+ 1. `mcp__smartstack__validate_conventions` — verify connectivity
129
+ 2. `mcp__context7__resolve-library-id` — verify connectivity
130
+
131
+ **During work:** All MCP tool calls are handled by `/apex` during delegation.
132
+ </mcp_requirements>
133
+
134
+ <execution_guarantee>
135
+
136
+ ## EXECUTION GUARANTEE — READ THIS FIRST
137
+
138
+ **Ralph-loop executes ALL work from start to finish. No exceptions.**
139
+
140
+ When the user invokes `/business-analyse-develop`, they are giving you the instruction to:
141
+ 1. Initialize (step-00)
142
+ 2. Execute ALL modules autonomously
143
+ 3. Run quality gates
144
+ 4. Generate the final report
145
+
146
+ **You MUST NOT:**
147
+ - Stop to "ask for confirmation"
148
+ - Set `max_iterations = 1` or any reduced value
149
+ - Ask the user to choose between supervised/autonomous mode
150
+ - Wait for user input between modules
151
+ - Delegate the loop to sub-agents (except team mode and /apex delegation)
152
+
153
+ **The ONLY valid stop conditions are:**
154
+ - ALL objectives met / ALL tasks completed (→ report)
155
+ - `max_iterations` reached (v3 only)
156
+ - Dead-end (all remaining blocked/failed after retries)
157
+ - User Ctrl+C
158
+
159
+ **If you stop for any other reason, you have VIOLATED this guarantee.**
160
+
161
+ </execution_guarantee>
162
+
163
+ <entry_point>
164
+ **FIRST ACTION:** Load `steps/step-00-init.md` — then execute ALL steps through to completion without stopping.
165
+ </entry_point>
166
+
167
+ <step_files>
168
+
169
+ ### v4 Steps (spec-oriented)
170
+ | Step | File | Purpose |
171
+ |------|------|---------|
172
+ | 00 | `steps/step-00-init.md` | Parse args, verify MCP, detect format, init state |
173
+ | 01-v4 | `steps/step-01-v4-execute.md` | Continuous execution: delegate to /apex, run gates |
174
+ | 02-v4 | `steps/step-02-v4-verify.md` | Final gates, file reconciliation, BR coverage, report |
175
+
176
+ ### v3 Steps (task-oriented — legacy)
177
+ | Step | File | Purpose |
178
+ |------|------|---------|
179
+ | 00 | `steps/step-00-init.md` | Parse args, verify MCP, init state |
180
+ | 01 | `steps/step-01-task.md` | Load/create tasks from prd.json |
181
+ | 02 | `steps/step-02-execute.md` | Delegate module to /apex -d |
182
+ | 03 | `steps/step-03-commit.md` | Commit, update prd.json/progress.txt |
183
+ | 04 | `steps/step-04-check.md` | Check completion, compact loop entry |
184
+ | 05 | `steps/step-05-report.md` | Generate final report |
185
+
186
+ **v3 "Read Once" rule:** Step files read once, compact-loop.md drives iterations 2+.
187
+ **v4:** No "Read Once" rule needed — compaction manages context automatically.
188
+
189
+ **Reference files (loaded conditionally):**
190
+ | File | Loaded when |
191
+ |------|-------------|
192
+ | `references/compact-loop.md` | v3 only: Step-04 section 5 |
193
+ | `references/section-splitting.md` | v3 only: >4 entities + >1 section |
194
+ | `references/category-completeness.md` | v3: step-01/step-04; v4: step-02-v4 |
195
+ | `references/init-resume-recovery.md` | Both: Step-00 section 4 (resume mode) |
196
+ | `references/multi-module-queue.md` | Both: multi-module initialization |
197
+ | `references/quality-gates.md` | v4: step-01-v4 and step-02-v4 |
198
+ </step_files>
199
+
200
+ <file_structure>
201
+ ```
202
+ .ralph/
203
+ ├── prd.json # v3: unified task list OR v4: spec document
204
+ ├── prd-{module}.json # Per-module PRDs (from business-analyse-handoff)
205
+ ├── progress.txt # v3: state machine; v4: optional checkpoints
206
+ ├── modules-queue.json # Multi-module tracking
207
+ ├── logs/
208
+ └── reports/
209
+ └── {feature}.md
210
+ ```
211
+ </file_structure>
212
+
213
+ <execution_rules>
214
+
215
+ ### NON-NEGOTIABLE — Autonomous Full Execution
216
+ - **EXECUTE ALL WORK** — from first module to last, no user interaction
217
+ - **NEVER ask the user** — no mode selection, no "shall I continue?"
218
+ - **NEVER stop prematurely** — only valid stops listed in execution_guarantee
219
+ - **VERIFY MCP FIRST** — never skip
220
+
221
+ ### Quality Gates (both v3 and v4)
222
+ - **BUILD GATE** — `dotnet build` must pass (BLOCKING)
223
+ - **BACKEND TEST GATE** — `dotnet test` must pass (BLOCKING)
224
+ - **FRONTEND TEST GATE** — `npm test` / `npm run typecheck` (BLOCKING)
225
+ - **STUB TEST DETECTION** — reject `Assert.True(true)` or empty test methods
226
+ - **MCP SECURITY** — validate_security + validate_conventions
227
+ - **BR COVERAGE** — every business rule has implementation + test
228
+ - **FILE RECONCILIATION** — expectedFiles vs actual files on disk
229
+ - **MIGRATION** — after EF configs, before tests
230
+
231
+ ### Error Recovery
232
+ - **v3:** Failed tasks retry up to 3 times, context NOT enriched
233
+ - **v4:** Failures handled in same session — Claude has full error context via compaction, retries naturally with different approach
234
+
235
+ </execution_rules>
236
+
237
+ <success_criteria>
238
+ - All objectives met (v4) / all tasks completed (v3)
239
+ - MCP validations pass (validate_security + validate_conventions)
240
+ - All quality gates pass (build, test, BR coverage, file reconciliation)
241
+ - Git commits atomic with commit_hash tracked
242
+ - Tests pass (dotnet test + npm test)
243
+ - Migrations created and applied
244
+ - Seed data complete (navigation, permissions, roles via MCP)
245
+ - Frontend in correct hierarchy (Context/App/Module)
246
+ - Report generated in .ralph/reports/
247
+ - Multi-module: all modules processed, cross-module report
248
+ </success_criteria>
@@ -159,7 +159,7 @@ After category check, verify artifacts actually exist for completed tasks.
159
159
  ```javascript
160
160
  const completedCats = new Set(prd.tasks.filter(t => t.status === 'completed').map(t => t.category));
161
161
 
162
- // Read custom patterns from PRD metadata (set by ss derive-prd based on project structure)
162
+ // Read custom patterns from PRD metadata (set by ss business-analyse-handoff based on project structure)
163
163
  const customPatterns = prd.metadata?.artifactPatterns || {};
164
164
 
165
165
  const artifactChecks = {
@@ -31,7 +31,7 @@ if (prd.$version === '3.0.0') {
31
31
  } else if (prd.project && prd.requirements && !prd.$version) {
32
32
  // FORMAT A deprecated — warn but transform
33
33
  console.warn('⚠ DEPRECATED: FORMAT A prd.json detected during resume');
34
- console.warn('Re-run `ss derive-prd` to generate v3 format');
34
+ console.warn('Re-run `ss business-analyse-handoff` to generate v3 format');
35
35
  // NOTE: Transformation happens in step-01, not here
36
36
  resumeValid = true;
37
37
  } else {
@@ -87,19 +87,19 @@ if (handoffStatus === 'handed-off') {
87
87
  // BA handoff completed — auto-derive PRDs
88
88
  console.log('BA artifacts detected without PRD — auto-recovering...');
89
89
 
90
- // Call ss derive-prd to generate PRD files
91
- // Flag: --feature (path to feature.json) — matches ss derive-prd CLI convention
92
- // See also: step-05c-ralph-readiness.md section 2 "Fix: ss derive-prd --feature {path} --output ..."
93
- const result = exec(`ss derive-prd --feature ${masterFeature}`);
90
+ // Call ss business-analyse-handoff to generate PRD files
91
+ // Flag: --feature (path to feature.json) — matches ss business-analyse-handoff CLI convention
92
+ // See also: step-05c-ralph-readiness.md section 2 "Fix: ss business-analyse-handoff --feature {path} --output ..."
93
+ const result = exec(`ss business-analyse-handoff --feature ${masterFeature}`);
94
94
 
95
95
  if (result.exitCode !== 0) {
96
- console.error('ss derive-prd failed — cannot auto-recover');
96
+ console.error('ss business-analyse-handoff failed — cannot auto-recover');
97
97
  STOP;
98
98
  }
99
99
 
100
100
  const newPrds = glob('.ralph/prd-*.json');
101
101
  if (newPrds.length === 0) {
102
- console.error('ss derive-prd did not create any PRD files');
102
+ console.error('ss business-analyse-handoff did not create any PRD files');
103
103
  STOP;
104
104
  }
105
105
 
@@ -109,7 +109,7 @@ if (handoffStatus === 'handed-off') {
109
109
  // BA handoff NOT complete
110
110
  console.warn(`⚠ BA handoff status: "${handoffStatus}" (expected "handed-off")`);
111
111
  console.warn('Cannot auto-recover PRD files without complete handoff');
112
- console.warn('Run /derive-prd to generate the handoff, then retry /ralph-loop');
112
+ console.warn('Run /business-analyse-handoff to generate the handoff, then retry /business-analyse-develop');
113
113
  STOP;
114
114
  }
115
115
  ```
@@ -147,7 +147,7 @@ if (fileExists(queuePath)) {
147
147
  }
148
148
  // LEGACY: FORMAT A
149
149
  else if (modulePrd.project && modulePrd.requirements && !modulePrd.$version) {
150
- console.warn('⚠ DEPRECATED: FORMAT A prd.json detected. Re-run `ss derive-prd` to generate v3 format.');
150
+ console.warn('⚠ DEPRECATED: FORMAT A prd.json detected. Re-run `ss business-analyse-handoff` to generate v3 format.');
151
151
  writeJSON(currentModule.prdFile, transformPrdJsonToRalphV2(modulePrd, currentModule.code));
152
152
  }
153
153
  // v2 legacy
@@ -0,0 +1,70 @@
1
+ # Quality Gates Reference (v4)
2
+
3
+ > **Used by:** step-01-v4-execute.md and step-02-v4-verify.md
4
+
5
+ ## Gate Definitions
6
+
7
+ | Gate | Command | Blocking | When |
8
+ |------|---------|----------|------|
9
+ | Backend build | `dotnet build --no-restore` | YES | After each module |
10
+ | Backend tests | `dotnet test --no-build` | YES | After build passes |
11
+ | Frontend typecheck | `npm run typecheck` | YES | After backend gates |
12
+ | Frontend tests | `npm test -- --run` | YES | After typecheck |
13
+ | MCP security | `validate_security` | YES | After all tests |
14
+ | MCP code review | `review_code` | YES (if perm mismatch) | After security |
15
+ | MCP conventions | `validate_conventions` | NO (report) | After code review |
16
+ | MCP test conventions | `validate_test_conventions` | NO (report) | After conventions |
17
+ | BR coverage | grep implementation | YES (100%) | After MCP gates |
18
+ | File reconciliation | compare expectedFiles vs disk | YES | After BR coverage |
19
+ | Stub test detection | grep stub patterns | YES | During test gate |
20
+
21
+ ## Stub Test Patterns (AUTO-REJECT)
22
+
23
+ ```
24
+ Assert.True(true)
25
+ Assert.Pass()
26
+ [Fact] + empty body
27
+ // TODO
28
+ throw new NotImplementedException
29
+ [Test] public void Test1() { }
30
+ ```
31
+
32
+ If any pattern found in test files → gate FAILS.
33
+
34
+ ## Gate Failure Recovery (v4)
35
+
36
+ In v4 mode, gate failures are handled IN THE SAME SESSION:
37
+
38
+ 1. Gate fails → error output captured
39
+ 2. Error shown to Claude (compaction preserves all prior context)
40
+ 3. `/apex -d "Fix: {error description}"` — Claude sees what it generated + the error
41
+ 4. Re-run gate
42
+ 5. Max 3 fix attempts per gate before marking as failed
43
+
44
+ **Key difference from v3:** No context loss between retry attempts. Claude knows exactly what code it wrote and what went wrong.
45
+
46
+ ## Gate Execution Order
47
+
48
+ ```
49
+ dotnet build
50
+ ↓ (pass)
51
+ dotnet test
52
+ ↓ (pass)
53
+ npm run typecheck
54
+ ↓ (pass)
55
+ npm test
56
+ ↓ (pass)
57
+ validate_security
58
+ ↓ (pass)
59
+ validate_conventions
60
+ ↓ (report)
61
+ review_code (semantic permission check)
62
+ ↓ (pass)
63
+ validate_test_conventions
64
+ ↓ (report)
65
+ BR coverage check
66
+ ↓ (100%)
67
+ File reconciliation
68
+ ↓ (all present)
69
+ MODULE COMPLETE
70
+ ```
@@ -1,7 +1,7 @@
1
1
  # Task Transform: Legacy PrdJson → Ralph v2 (DEPRECATED)
2
2
 
3
3
  > Reference for step-01-task.md — fallback transformation for old FORMAT A PRDs (pre-v3.9.0).
4
- > New PRDs generated by `ss derive-prd` use unified v3 format (`$version: "3.0.0"`)
4
+ > New PRDs generated by `ss business-analyse-handoff` use unified v3 format (`$version: "3.0.0"`)
5
5
  > with pre-computed tasks. The v3 fast path in sections 0 and 1 bypasses this entirely.
6
6
  > This function will be removed in a future release.
7
7
 
@@ -69,7 +69,7 @@ The loop runs autonomously until:
69
69
 
70
70
  If tests are slow (>30s in logs), display warning but **continue execution**:
71
71
  ```
72
- ⚠ Slow tests detected. Consider disabling E2E during ralph-loop.
72
+ ⚠ Slow tests detected. Consider disabling E2E during business-analyse-develop.
73
73
  ```
74
74
 
75
75
  ## 4. Resume or Initialize
@@ -78,7 +78,7 @@ See `references/init-resume-recovery.md` for complete Resume Mode and Auto-Recov
78
78
 
79
79
  **Quick:**
80
80
  - If `-r` flag: restore state from .ralph/prd.json
81
- - Else if BA artifacts exist: auto-recover PRDs via `ss derive-prd`
81
+ - Else if BA artifacts exist: auto-recover PRDs via `ss business-analyse-handoff`
82
82
  - Else: fresh start
83
83
 
84
84
  ---
@@ -147,14 +147,30 @@ PROJECT_PATH=$(pwd)
147
147
  }
148
148
  ```
149
149
 
150
+ ## 6b. Detect PRD Version
151
+
152
+ ```javascript
153
+ const prdFile = readJSON('.ralph/prd.json') || readJSON(glob('.ralph/prd-*.json')[0]);
154
+ const prd_version = prdFile?.$version || '3.0.0';
155
+
156
+ if (prd_version === '4.0.0') {
157
+ // v4 spec-oriented: continuous execution, compaction manages context
158
+ // → Load step-01-v4-execute.md instead of step-01-task.md
159
+ } else {
160
+ // v3 task-oriented: batch iterations, compact-loop
161
+ // → Load step-01-task.md (legacy)
162
+ }
163
+ ```
164
+
150
165
  ## 7. Show Summary
151
166
 
152
167
  ```
153
168
  RALPH LOOP INITIALIZED
154
169
  Task: {task_description} | Max: {max_iterations} | Promise: {completion_promise}
155
- MCP: Ready | Branch: {branch} | Schema: v3.0.0
170
+ MCP: Ready | Branch: {branch} | PRD: v{prd_version}
156
171
  {modules_queue ? `Modules: ${totalModules} (${module_codes.join(' → ')})` : 'Mode: single module'}
157
- -> Loading tasks...
172
+ {prd_version === '4.0.0' ? '→ v4 continuous mode (compaction-enabled)' : '→ v3 batch mode (compact-loop)'}
173
+ -> Loading spec...
158
174
  ```
159
175
 
160
176
  **Proceed directly to step-01-task.md**
@@ -79,7 +79,8 @@ If `{currentPrdPath}` does not exist: continue to section 1b.
79
79
 
80
80
  ```javascript
81
81
  const sourceFeatureJson = prd?.metadata?.sourceFeatureJson
82
- || findFile('docs/business/**/business-analyse/**/feature.json');
82
+ || findFile('docs/**/business-analyse/**/index.json')
83
+ || findFile('docs/business/**/business-analyse/**/feature.json'); // legacy fallback
83
84
 
84
85
  if (!sourceFeatureJson) {
85
86
  // Manual mode: no BA artifacts found — skip quality gate
@@ -93,7 +94,7 @@ if (!sourceFeatureJson) {
93
94
  if (handoff.status !== 'handed-off') {
94
95
  console.error(`BLOCKING: BA HANDOFF INCOMPLETE
95
96
  handoff.status = "${handoff.status || 'missing'}" (expected "handed-off")
96
- Run /derive-prd to generate the handoff, then re-run /ralph-loop.`);
97
+ Run /business-analyse-handoff to generate the handoff, then re-run /business-analyse-develop.`);
97
98
  STOP;
98
99
  }
99
100
 
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: step-01-v4-execute
3
+ description: Continuous execution — delegate full module to /apex with quality gates
4
+ model: opus
5
+ next_step: steps/step-02-v4-verify.md
6
+ ---
7
+
8
+ # Step 01-v4: Continuous Module Execution
9
+
10
+ ## YOUR TASK
11
+
12
+ For each module in topological order, delegate the ENTIRE module implementation to `/apex -d` in a continuous session. Run quality gates at natural checkpoints. Let server-side compaction manage context.
13
+
14
+ ---
15
+
16
+ ## EXECUTION SEQUENCE
17
+
18
+ ### 1. For Each Module in Queue
19
+
20
+ ```
21
+ FOR module in topologicalOrder(modules):
22
+ 1. Build apex delegation command
23
+ 2. Delegate to /apex -d
24
+ 3. Run quality gates after delegation completes
25
+ 4. If gates fail → /apex fixes in same session
26
+ 5. Module complete → advance to next
27
+ ```
28
+
29
+ ### 2. Build Apex Delegation
30
+
31
+ Pass the FULL spec to apex — objectives, architecture, gates:
32
+
33
+ ```
34
+ /apex -d .ralph/prd-{moduleCode}.json
35
+ ```
36
+
37
+ Apex receives the v4 PRD and works autonomously through:
38
+ 1. **Domain layer** — entities, value objects, enums
39
+ 2. **Infrastructure** — EF configurations, DbContext registration
40
+ 3. **Migration** — ONE migration per module
41
+ 4. **Application** — services, DTOs, validators (implement ALL business rules)
42
+ 5. **API** — controllers with correct permissions
43
+ 6. **Seed data** — core (navigation, permissions, roles) + business
44
+ 7. **Frontend** — pages via `/ui-components`, routes, translations
45
+ 8. **Tests** — unit + integration via `scaffold_tests` (backend) + `scaffold_frontend_tests` (frontend). NO stubs, NO `Assert.True(true)`
46
+
47
+ > Apex decides the order and approach. Ralph does NOT micro-manage.
48
+
49
+ ### 3. Quality Gates (Run After Apex Completes)
50
+
51
+ After `/apex -d` returns, run ALL gates:
52
+
53
+ ```bash
54
+ # Gate 1: Backend build (BLOCKING)
55
+ dotnet build --no-restore 2>&1
56
+
57
+ # Gate 2: Backend tests (BLOCKING)
58
+ dotnet test --no-build 2>&1
59
+
60
+ # Gate 3: Frontend checks (BLOCKING if frontend exists)
61
+ npm run typecheck 2>&1
62
+ npm test -- --run 2>&1
63
+ ```
64
+
65
+ **If any gate fails:**
66
+ 1. DO NOT advance to next module
67
+ 2. Show the error to Claude (same conversation — compaction preserves context)
68
+ 3. Ask `/apex -d` to fix: `/apex -d "Fix build/test failures for module {moduleCode}"`
69
+ 4. Re-run gates
70
+ 5. Repeat until ALL gates pass (max 3 fix attempts per gate)
71
+
72
+ ### 4. MCP Validation Gates
73
+
74
+ After build/test pass:
75
+
76
+ ```javascript
77
+ // Security validation
78
+ mcp__smartstack__validate_security({ projectPath: "." })
79
+
80
+ // Convention validation
81
+ mcp__smartstack__validate_conventions({ projectPath: "." })
82
+
83
+ // Code review (semantic permission check)
84
+ mcp__smartstack__review_code({ files: changedFiles, focus: "security" })
85
+ ```
86
+
87
+ **Semantic permission check:** Verify that write endpoints (POST/PUT/DELETE) do NOT use Read-only permissions. Fix if found.
88
+
89
+ ### 5. BR Coverage Check
90
+
91
+ For each business rule in `prd.brToCodeMapping`:
92
+ 1. Verify the target file exists on disk
93
+ 2. Grep for the rule implementation (method name or comment reference)
94
+ 3. If missing → delegate fix to apex: "Implement BR {ruleId} in {targetFile}"
95
+
96
+ ### 6. Stub Test Detection
97
+
98
+ Grep test files for stub patterns:
99
+ ```bash
100
+ grep -rn "Assert.True(true)\|Assert.Pass()\|// TODO\|throw new NotImplementedException" tests/ 2>/dev/null
101
+ ```
102
+
103
+ If found → delegate fix to apex: "Replace stub tests with real implementations"
104
+
105
+ ### 7. Module Complete
106
+
107
+ When ALL gates pass for a module:
108
+ 1. Log checkpoint: `"Module {moduleCode}: ALL GATES PASS"`
109
+ 2. Optionally append to progress.txt (human checkpoint)
110
+ 3. Advance to next module in queue
111
+
112
+ ---
113
+
114
+ ## ERROR RECOVERY (v4)
115
+
116
+ Unlike v3 (retry counter + re-delegation), v4 leverages compaction:
117
+
118
+ | Scenario | v3 behavior | v4 behavior |
119
+ |----------|-------------|-------------|
120
+ | Build fails | Inject fix task, re-iterate | Same session: Claude sees the error, fixes, re-builds |
121
+ | Test fails | Inject fix task, re-iterate | Same session: Claude reads failure, adjusts code, re-tests |
122
+ | MCP rejects | Mark task failed, retry 3x | Same session: Claude reads rejection reason, corrects |
123
+ | Apex crashes | State lost between batches | Compaction preserves context, resume from last point |
124
+
125
+ **Key advantage:** Claude has FULL context of what it just generated + the exact error. No context loss between retry attempts.
126
+
127
+ ---
128
+
129
+ ## NEXT STEP
130
+
131
+ After ALL modules complete → Load: `steps/step-02-v4-verify.md`