@atlashub/smartstack-cli 4.17.1 → 4.19.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 (167) hide show
  1. package/package.json +1 -1
  2. package/templates/agents/ba-reader.md +86 -80
  3. package/templates/agents/ba-writer.md +321 -413
  4. package/templates/agents/docs-context-reader.md +3 -3
  5. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +133 -0
  6. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +126 -0
  7. package/templates/skills/apex/SKILL.md +29 -16
  8. package/templates/skills/apex/_shared.md +62 -9
  9. package/templates/skills/apex/references/analysis-methods.md +8 -6
  10. package/templates/skills/apex/references/challenge-questions.md +5 -5
  11. package/templates/skills/apex/references/core-seed-data.md +68 -45
  12. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +26 -21
  13. package/templates/skills/apex/references/parallel-execution.md +156 -0
  14. package/templates/skills/apex/references/person-extension-pattern.md +12 -12
  15. package/templates/skills/apex/references/post-checks.md +1748 -1726
  16. package/templates/skills/apex/references/smartstack-api.md +63 -57
  17. package/templates/skills/apex/references/smartstack-frontend-compliance.md +594 -0
  18. package/templates/skills/apex/references/smartstack-frontend.md +1246 -1842
  19. package/templates/skills/apex/references/smartstack-layers.md +98 -145
  20. package/templates/skills/apex/steps/step-00-init.md +30 -6
  21. package/templates/skills/apex/steps/step-01-analyze.md +27 -23
  22. package/templates/skills/apex/steps/step-02-plan.md +12 -12
  23. package/templates/skills/apex/steps/step-03-execute.md +198 -143
  24. package/templates/skills/apex/steps/step-04-examine.md +24 -93
  25. package/templates/skills/apex/steps/step-05-deep-review.md +16 -16
  26. package/templates/skills/apex/steps/step-06-resolve.md +9 -9
  27. package/templates/skills/apex/steps/step-07-tests.md +3 -1
  28. package/templates/skills/apex/steps/step-08-run-tests.md +1 -1
  29. package/templates/skills/business-analyse/SKILL.md +182 -301
  30. package/templates/skills/business-analyse/_shared.md +119 -336
  31. package/templates/skills/business-analyse/html/ba-interactive.html +703 -82
  32. package/templates/skills/business-analyse/html/build-html.js +41 -3
  33. package/templates/skills/business-analyse/html/src/partials/cadrage-context.html +34 -0
  34. package/templates/skills/business-analyse/html/src/partials/cadrage-risks.html +48 -0
  35. package/templates/skills/business-analyse/html/src/partials/cadrage-scope.html +49 -0
  36. package/templates/skills/business-analyse/html/src/partials/cadrage-stakeholders.html +55 -0
  37. package/templates/skills/business-analyse/html/src/partials/cadrage-success.html +34 -0
  38. package/templates/skills/business-analyse/html/src/partials/consol-datamodel.html +8 -0
  39. package/templates/skills/business-analyse/html/src/partials/consol-flows.html +29 -0
  40. package/templates/skills/business-analyse/html/src/partials/consol-interactions.html +8 -0
  41. package/templates/skills/business-analyse/html/src/partials/consol-permissions.html +8 -0
  42. package/templates/skills/business-analyse/html/src/partials/decomp-dependencies.html +38 -0
  43. package/templates/skills/business-analyse/html/src/partials/decomp-modules.html +51 -0
  44. package/templates/skills/business-analyse/html/src/partials/handoff-summary.html +24 -0
  45. package/templates/skills/business-analyse/html/src/partials/module-spec-container.html +4 -0
  46. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +17 -1
  47. package/templates/skills/business-analyse/html/src/scripts/02-navigation.js +31 -5
  48. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +100 -63
  49. package/templates/skills/business-analyse/html/src/scripts/06-render-mockups.js +372 -0
  50. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +41 -13
  51. package/templates/skills/business-analyse/html/src/styles/09-mockups-html.css +136 -0
  52. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +7 -5
  53. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +142 -0
  54. package/templates/skills/business-analyse/questionnaire/03-data-ui.md +94 -0
  55. package/templates/skills/business-analyse/questionnaire/04-risks-metrics.md +150 -0
  56. package/templates/skills/business-analyse/questionnaire/05-cross-module.md +69 -0
  57. package/templates/skills/business-analyse/questionnaire.md +23 -280
  58. package/templates/skills/business-analyse/react/application-viewer.md +2 -2
  59. package/templates/skills/business-analyse/react/components.md +4 -4
  60. package/templates/skills/business-analyse/react/i18n-template.md +1 -1
  61. package/templates/skills/business-analyse/react/schema.md +14 -14
  62. package/templates/skills/business-analyse/references/acceptance-criteria.md +25 -25
  63. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +3 -3
  64. package/templates/skills/business-analyse/references/compilation-structure-cards.md +1 -1
  65. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +7 -7
  66. package/templates/skills/business-analyse/references/deploy-data-build.md +14 -12
  67. package/templates/skills/business-analyse/references/deploy-modes.md +10 -10
  68. package/templates/skills/business-analyse/references/detection-strategies.md +6 -6
  69. package/templates/skills/business-analyse/references/html-data-mapping.md +15 -15
  70. package/templates/skills/business-analyse/references/naming-conventions.md +4 -4
  71. package/templates/skills/business-analyse/references/review-data-mapping.md +29 -29
  72. package/templates/skills/business-analyse/references/robustness-checks.md +36 -33
  73. package/templates/skills/business-analyse/references/spec-auto-inference.md +2 -2
  74. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  75. package/templates/skills/business-analyse/references/ui-resource-cards.md +1 -1
  76. package/templates/skills/business-analyse/references/validation-checklist.md +9 -6
  77. package/templates/skills/business-analyse/references/wireframe-svg-style-guide.md +2 -2
  78. package/templates/skills/business-analyse/schemas/application-schema.json +8 -8
  79. package/templates/skills/business-analyse/schemas/feature-schema.json +3 -3
  80. package/templates/skills/business-analyse/schemas/index-schema.json +47 -0
  81. package/templates/skills/business-analyse/schemas/project-schema.json +6 -6
  82. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +1 -1
  83. package/templates/skills/business-analyse/schemas/sections/handoff-schema.json +5 -3
  84. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +4 -4
  85. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +1 -1
  86. package/templates/skills/business-analyse/schemas/shared/common-defs.json +4 -3
  87. package/templates/skills/business-analyse/steps/step-00-init.md +93 -134
  88. package/templates/skills/business-analyse/steps/step-01-cadrage.md +136 -172
  89. package/templates/skills/business-analyse/steps/step-02-structure.md +175 -0
  90. package/templates/skills/business-analyse/steps/step-03-specify.md +198 -0
  91. package/templates/skills/business-analyse/steps/step-04-consolidate.md +478 -0
  92. package/templates/skills/business-analyse/steps/step-05-deploy.md +220 -0
  93. package/templates/skills/business-analyse/steps/step-06-review.md +51 -69
  94. package/templates/skills/business-analyse/templates/tpl-frd.md +1 -1
  95. package/templates/skills/business-analyse/templates/tpl-handoff.md +20 -17
  96. package/templates/skills/business-analyse/templates/tpl-launch-displays.md +2 -2
  97. package/templates/skills/business-analyse/templates-react.md +2 -2
  98. package/templates/skills/derive-prd/SKILL.md +92 -0
  99. package/templates/skills/derive-prd/references/acceptance-criteria.md +169 -0
  100. package/templates/skills/derive-prd/references/entity-domain-mapping.md +115 -0
  101. package/templates/skills/{business-analyse → derive-prd}/references/handoff-file-templates.md +131 -120
  102. package/templates/skills/{business-analyse → derive-prd}/references/handoff-mappings.md +95 -95
  103. package/templates/skills/{business-analyse → derive-prd}/references/handoff-seeddata-generation.md +312 -312
  104. package/templates/skills/{business-analyse → derive-prd}/references/prd-generation.md +262 -258
  105. package/templates/skills/derive-prd/references/readiness-scoring.md +104 -0
  106. package/templates/skills/derive-prd/schemas/handoff-schema.json +95 -0
  107. package/templates/skills/derive-prd/steps/step-00-validate.md +130 -0
  108. package/templates/skills/derive-prd/steps/step-01-transform.md +206 -0
  109. package/templates/skills/derive-prd/steps/step-02-export.md +181 -0
  110. package/templates/skills/{business-analyse → derive-prd}/templates/tpl-progress.md +172 -172
  111. package/templates/skills/ralph-loop/SKILL.md +10 -4
  112. package/templates/skills/ralph-loop/references/category-completeness.md +20 -4
  113. package/templates/skills/ralph-loop/references/compact-loop.md +80 -48
  114. package/templates/skills/ralph-loop/references/init-resume-recovery.md +4 -2
  115. package/templates/skills/ralph-loop/references/parallel-execution.md +27 -27
  116. package/templates/skills/ralph-loop/steps/step-00-init.md +19 -9
  117. package/templates/skills/ralph-loop/steps/step-01-task.md +12 -4
  118. package/templates/skills/ralph-loop/steps/step-02-execute.md +9 -4
  119. package/templates/skills/ralph-loop/steps/step-03-commit.md +1 -1
  120. package/templates/skills/ralph-loop/steps/step-04-check.md +5 -21
  121. package/templates/skills/ralph-loop/steps/step-05-report.md +6 -1
  122. package/templates/skills/apex/references/agent-teams-protocol.md +0 -203
  123. package/templates/skills/business-analyse/_architecture.md +0 -124
  124. package/templates/skills/business-analyse/_elicitation.md +0 -206
  125. package/templates/skills/business-analyse/_module-loop.md +0 -115
  126. package/templates/skills/business-analyse/_suggestions.md +0 -34
  127. package/templates/skills/business-analyse/questionnaire/00-application.md +0 -160
  128. package/templates/skills/business-analyse/questionnaire/00b-project.md +0 -85
  129. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +0 -189
  130. package/templates/skills/business-analyse/questionnaire/03-scope.md +0 -164
  131. package/templates/skills/business-analyse/questionnaire/04-data.md +0 -88
  132. package/templates/skills/business-analyse/questionnaire/05-integrations.md +0 -58
  133. package/templates/skills/business-analyse/questionnaire/06-security.md +0 -68
  134. package/templates/skills/business-analyse/questionnaire/07-ui.md +0 -76
  135. package/templates/skills/business-analyse/questionnaire/08-performance.md +0 -42
  136. package/templates/skills/business-analyse/questionnaire/09-constraints.md +0 -45
  137. package/templates/skills/business-analyse/questionnaire/10-documentation.md +0 -43
  138. package/templates/skills/business-analyse/questionnaire/11-data-lifecycle.md +0 -59
  139. package/templates/skills/business-analyse/questionnaire/12-migration.md +0 -58
  140. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +0 -69
  141. package/templates/skills/business-analyse/questionnaire/14-risk-assumptions.md +0 -135
  142. package/templates/skills/business-analyse/questionnaire/15-success-metrics.md +0 -136
  143. package/templates/skills/business-analyse/references/agent-module-prompt.md +0 -362
  144. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +0 -557
  145. package/templates/skills/business-analyse/references/cache-warming-strategy.md +0 -566
  146. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +0 -41
  147. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +0 -74
  148. package/templates/skills/business-analyse/references/cadrage-pre-analysis.md +0 -115
  149. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +0 -68
  150. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +0 -85
  151. package/templates/skills/business-analyse/references/team-orchestration.md +0 -1022
  152. package/templates/skills/business-analyse/references/validate-incremental-html.md +0 -121
  153. package/templates/skills/business-analyse/steps/step-01b-applications.md +0 -419
  154. package/templates/skills/business-analyse/steps/step-02-decomposition.md +0 -387
  155. package/templates/skills/business-analyse/steps/step-03a-data.md +0 -16
  156. package/templates/skills/business-analyse/steps/step-03a1-setup.md +0 -506
  157. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +0 -301
  158. package/templates/skills/business-analyse/steps/step-03b-ui.md +0 -425
  159. package/templates/skills/business-analyse/steps/step-03c-compile.md +0 -611
  160. package/templates/skills/business-analyse/steps/step-03d-validate.md +0 -783
  161. package/templates/skills/business-analyse/steps/step-04-consolidation.md +0 -17
  162. package/templates/skills/business-analyse/steps/step-04a-collect.md +0 -415
  163. package/templates/skills/business-analyse/steps/step-04b-analyze.md +0 -163
  164. package/templates/skills/business-analyse/steps/step-04c-decide.md +0 -186
  165. package/templates/skills/business-analyse/steps/step-05a-handoff.md +0 -840
  166. package/templates/skills/business-analyse/steps/step-05b-deploy.md +0 -522
  167. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +0 -703
@@ -63,7 +63,7 @@ git commit -m "chore(foundation): entities for all modules
63
63
 
64
64
  $(allModules.map(m => m.code).join(' + ')) — ${allEntities.length} entities
65
65
 
66
- Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"
66
+ Co-Authored-By: Claude AI <noreply@anthropic.com>"
67
67
  ```
68
68
 
69
69
  Result: ModelSnapshot contains all entities. Database ready for application layers.
@@ -159,7 +159,8 @@ DO NOT:
159
159
  - Modify DbContext (already done in Phase 0)
160
160
 
161
161
  EXECUTE:
162
- For each PRD file: invoke /apex -d {prdFile}
162
+ For each PRD file:
163
+ **INVOKE `/apex -d {prdFile}`**
163
164
  Apex will detect existing entities and skip domain/infrastructure layers.
164
165
 
165
166
  When done, send a message to team lead with results:
@@ -177,33 +178,32 @@ When done, send a message to team lead with results:
177
178
 
178
179
  ### 4. Wait for Teammates
179
180
 
180
- Ralph waits for all teammates to send completion messages:
181
+ Ralph waits for all teammates to send completion messages via `TaskOutput`.
181
182
 
182
- ```javascript
183
- const MAX_WAIT = 3600; // 1 hour timeout
184
- const POLL_INTERVAL = 5; // 5 seconds
185
-
186
- const teamMateResults = [];
187
- const deadline = Date.now() + MAX_WAIT * 1000;
188
-
189
- while (teamMateResults.length < teammates.length && Date.now() < deadline) {
190
- // Check for new messages from teammates
191
- const messages = getTeamMessages();
192
- for (const msg of messages) {
193
- if (msg.type === 'completion') {
194
- teamMateResults.push(msg);
195
- console.log(` ✅ ${msg.teammate}: ${msg.status}`);
196
- }
197
- }
198
- if (teamMateResults.length < teammates.length) {
199
- sleep(POLL_INTERVAL * 1000);
200
- }
201
- }
183
+ > **How messaging works in Claude Code Agent Teams:**
184
+ > - Teammates communicate by calling `SendMessage({ recipient: "team-lead", content: ... })`
185
+ > - Ralph (team lead) receives messages automatically — there is NO polling loop
186
+ > - Each message delivery triggers a new turn for Ralph
187
+ > - Ralph stays idle between messages — this is normal behavior (not a hang)
188
+ > - An idle notification does NOT mean the teammate has finished or failed
202
189
 
203
- if (teamMateResults.length < teammates.length) {
204
- console.error(`TIMEOUT: ${teammates.length - teamMateResults.length} teammates did not complete`);
205
- // Set status to 'partial'
206
- }
190
+ ```javascript
191
+ // Track expected completions (set before spawning)
192
+ const expectedCount = teammates.length;
193
+ const results = []; // populated as SendMessage notifications arrive
194
+
195
+ // Ralph's response to each incoming message:
196
+ // - Parse content: "complete" | "failed"
197
+ // - Push to results[]
198
+ // - If results.length === expectedCount → proceed to section 5
199
+ // - If "failed": log error, continue waiting for other teammates
200
+
201
+ // If a teammate goes silent > 30 min:
202
+ // → Send it a wake-up message (idle is normal, silence is not)
203
+ // → If no response after 2 retries: mark as "timed-out" and continue
204
+
205
+ console.log(`Waiting for ${expectedCount} teammates...`);
206
+ // (Ralph is idle here — woken up by each incoming SendMessage)
207
207
  ```
208
208
 
209
209
  ### 5. Collect & Validate Results
@@ -91,21 +91,31 @@ Quick: `glob('.ralph/prd-*.json').length > 1` → create modules-queue.json
91
91
 
92
92
  ---
93
93
 
94
- ## 4c. Team Orchestration (multi-module, 2+ modules)
94
+ ## 4c. Team Orchestration (multi-module LEGACY — dependency layer mode only)
95
+
96
+ > **MANDATORY:** Load `references/team-orchestration.md` BEFORE creating any team.
97
+ > The full spawn protocol (teammate prompts, wait logic, layer coordination, cleanup)
98
+ > is defined there. Creating a team without loading it results in an empty team with no teammates.
99
+
100
+ > **PARALLEL MODE (`-p`):** Team creation does NOT happen here. It happens in step-02 section 3a,
101
+ > after step-01 loads the tasks. Sections 5-7 below (completion promise, metadata, summary) must
102
+ > still be executed. Do NOT return early when `{parallel_mode}` is true.
95
103
 
96
104
  ```javascript
97
105
  if (PRD_COUNT > 1) {
98
- // Read references/team-orchestration.md for full protocol
106
+ // STEP 1: Load references/team-orchestration.md NOW (before any TeamCreate call)
107
+ // This file contains: mode selection, Phase 0 protocol (parallel), layer protocol (legacy), cleanup.
108
+
99
109
  const layers = master.metadata?.workflow?.dependencyGraph?.layers;
100
110
 
101
- if (layers) {
102
- // PARALLEL MODE: Use Agent Teams
103
- TeamCreate({ team_name: `ralph-${appName}` });
104
- // Spawn teammates per layer (see reference)
105
- // STOP here — team orchestration takes over
111
+ if (layers && !{parallel_mode}) {
112
+ // DEPENDENCY LAYER MODE (legacy, no -p flag): team orchestration takes over here.
113
+ // TeamCreate + spawn logic are defined in references/team-orchestration.md section "Dependency Layer Mode".
114
+ // STOP here legacy team orchestration handles everything from this point.
106
115
  return;
107
116
  }
108
- // If no layers: fall through to sequential mode
117
+ // PARALLEL MODE (-p): fall through to sections 5-7, team created later in step-02 section 3a.
118
+ // NO -p, NO layers: fall through to sequential mode (compact loop per module).
109
119
  }
110
120
  ```
111
121
 
@@ -123,7 +133,7 @@ if (!completion_promise) {
123
133
  ## 6. Collect Metadata
124
134
 
125
135
  ```bash
126
- CLI_VERSION=$(node -e "console.log(require('package.json').version)" 2>/dev/null || echo "unknown")
136
+ CLI_VERSION=$(node -e "try{console.log(require('./package.json').version)}catch(e){console.log('unknown')}" 2>/dev/null || echo "unknown")
127
137
  CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
128
138
  PROJECT_PATH=$(pwd)
129
139
  ```
@@ -58,16 +58,24 @@ If `.ralph/prd.json` exists:
58
58
 
59
59
  If `.ralph/prd.json` does not exist: continue to section 1b.
60
60
 
61
- ### 1b. BA Handoff Quality Gate (BLOCKING)
61
+ ### 1b. BA Handoff Quality Gate (BLOCKING when BA artifacts present)
62
62
 
63
63
  > **CRITICAL:** Before generating ANY tasks, verify the BA handoff is complete.
64
64
  > A missing handoff means no frontend files, no test plan, no BR-to-code mapping.
65
65
 
66
+ > **INTENTIONAL SKIP:** If `sourceFeatureJson` is null (manual start via `{task_description}`, no BA run),
67
+ > this quality gate is **intentionally skipped** — the loop proceeds in "manual mode" and generates tasks
68
+ > from the task description. This is by design, not a bug. Inform the user in the summary (section 6 of step-00).
69
+
66
70
  ```javascript
67
71
  const sourceFeatureJson = prd?.metadata?.sourceFeatureJson
68
72
  || findFile('docs/business/**/business-analyse/**/feature.json');
69
73
 
70
- if (sourceFeatureJson) {
74
+ if (!sourceFeatureJson) {
75
+ // Manual mode: no BA artifacts found — skip quality gate
76
+ console.log('Manual mode: no BA artifacts detected — tasks will be generated from task description');
77
+ // Continue to section 2 (Analyze Task Description)
78
+ } else {
71
79
  const feature = readJSON(sourceFeatureJson);
72
80
  const handoff = feature.handoff || {};
73
81
 
@@ -75,13 +83,13 @@ if (sourceFeatureJson) {
75
83
  if (handoff.status !== 'handed-off') {
76
84
  console.error(`BLOCKING: BA HANDOFF INCOMPLETE
77
85
  handoff.status = "${handoff.status || 'missing'}" (expected "handed-off")
78
- Run /business-analyse to complete the handoff, then re-run /ralph-loop.`);
86
+ Run /derive-prd to generate the handoff, then re-run /ralph-loop.`);
79
87
  STOP;
80
88
  }
81
89
 
82
90
  // CHECK 2: filesToCreate must have all categories
83
91
  const filesToCreate = handoff.filesToCreate || {};
84
- const requiredCategories = ['domain', 'application', 'infrastructure', 'api', 'frontend', 'seedData', 'tests'];
92
+ const requiredCategories = ['domain', 'application', 'infrastructure', 'api', 'frontend', 'seedData', 'tests', 'documentation'];
85
93
  const missingInHandoff = requiredCategories.filter(c => !filesToCreate[c] || filesToCreate[c].length === 0);
86
94
 
87
95
  if (missingInHandoff.length > 0) {
@@ -93,11 +93,16 @@ if (prd._sectionSplit?.enabled) {
93
93
  : `Phase ${nextPhase.phase}: Section "${nextPhase.sectionCode}" (services + controllers + pages + tests)`;
94
94
  console.log(`SECTION SPLIT: ${phaseLabel}`);
95
95
 
96
- // INVOKE /apex -d {nextPhase.prdFile}
97
- // Apex sees a normal (smaller) PRD and executes normally
96
+ // MANDATORY: invoke apex now (not pseudo-code — execute this skill call)
97
+ ```
98
+
99
+ **INVOKE `/apex -d {nextPhase.prdFile}`**
98
100
 
99
- // After apex returns: merge results into master PRD
100
- // Read references/section-splitting.md sections 7-9 (execution, merging, failure handling)
101
+ Apex sees a focused (smaller) PRD covering only this phase's scope and executes normally.
102
+ After apex returns: merge results into master PRD.
103
+ Read `references/section-splitting.md` sections 7-9 for execution, merging, and failure handling.
104
+
105
+ ```javascript
101
106
 
102
107
  nextPhase.status = 'completed';
103
108
  prd._sectionSplit.currentPhase = nextPhase.phase;
@@ -52,7 +52,7 @@ chore(ralph): PRD state — iteration {iteration}, {completed}/{total} tasks
52
52
 
53
53
  Module: {current_module}
54
54
 
55
- Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55
+ Co-Authored-By: Claude AI <noreply@anthropic.com>
56
56
  EOF
57
57
  )"
58
58
 
@@ -47,9 +47,12 @@ fi
47
47
 
48
48
  ### 1.7. Category Completeness Check (RUNS EVERY ITERATION)
49
49
 
50
- See `references/category-completeness.md` for detailed implementation.
50
+ > **Implementation:** See `references/category-completeness.md` for the full `checkCategoryCompleteness()` function and artifact verification logic.
51
+ > Do NOT duplicate the implementation here — load and execute the reference.
51
52
 
52
53
  ```javascript
54
+ // Load references/category-completeness.md — execute checkCategoryCompleteness() as defined there
55
+ // (includes guardrail injection AND artifact verification)
53
56
  const { missing, guardrailsNeeded } = checkCategoryCompleteness(prd);
54
57
 
55
58
  if (guardrailsNeeded.length > 0) {
@@ -57,26 +60,7 @@ if (guardrailsNeeded.length > 0) {
57
60
  writeJSON('.ralph/prd.json', prd);
58
61
  console.log(`PRD updated: +${guardrailsNeeded.length} guardrails, ${prd.tasks.filter(t => t.status === 'pending').length} pending tasks`);
59
62
  }
60
-
61
- // Artifact verification (check if completed tasks have files)
62
- const completedCats = new Set(prd.tasks.filter(t => t.status === 'completed').map(t => t.category));
63
- const artifactChecks = {
64
- 'frontend': () => glob.sync('**/src/pages/**/*.tsx').length > 0,
65
- 'test': () => glob.sync('tests/**/*Tests.cs').length > 0,
66
- 'api': () => glob.sync('src/*/Controllers/**/*Controller.cs').length > 0
67
- };
68
- for (const [cat, check] of Object.entries(artifactChecks)) {
69
- if (completedCats.has(cat) && !check()) {
70
- console.warn(`ARTIFACT MISSING: ${cat} tasks marked completed but no files found — resetting to pending`);
71
- prd.tasks.filter(t => t.category === cat && t.status === 'completed')
72
- .forEach(t => {
73
- t.status = 'pending';
74
- t.error = 'Artifacts missing — re-execute';
75
- t.completed_at = null;
76
- });
77
- writeJSON('.ralph/prd.json', prd);
78
- }
79
- }
63
+ // Artifact verification is handled inside checkCategoryCompleteness() — see reference file.
80
64
  ```
81
65
 
82
66
  ## 2. Check Iteration Limit
@@ -131,13 +131,18 @@ Write to `.ralph/reports/{feature-slug}.md`:
131
131
 
132
132
  ```javascript
133
133
  // Clean up section-split temporary files
134
- if (prd._sectionSplit?.enabled) {
134
+ // GUARD: only delete if the overall PRD status is 'completed'.
135
+ // If status is 'partial' or 'failed', keep temporary PRD files so the user
136
+ // can resume with `-r` — deleting them here would make recovery impossible.
137
+ if (prd._sectionSplit?.enabled && prd.status === 'completed') {
135
138
  for (const phase of prd._sectionSplit.phases) {
136
139
  if (fileExists(phase.prdFile) && phase.prdFile !== '.ralph/prd.json') {
137
140
  deleteFile(phase.prdFile);
138
141
  }
139
142
  }
140
143
  delete prd._sectionSplit;
144
+ } else if (prd._sectionSplit?.enabled && prd.status !== 'completed') {
145
+ console.log(`Section-split temp files preserved (status: ${prd.status}) — use /ralph-loop -r to resume`);
141
146
  }
142
147
 
143
148
  prd.updated_at = new Date().toISOString();
@@ -1,203 +0,0 @@
1
- # Agent Teams Protocol — APEX
2
-
3
- > **Loaded by:** step-01 (analysis scan) and step-03 (parallel execution)
4
- > **Condition:** NOT economy_mode
5
- > **Purpose:** Reusable protocol for TeamCreate, coordination, and shutdown.
6
-
7
- ---
8
-
9
- ## Team Creation (T08)
10
-
11
- ```yaml
12
- TeamCreate:
13
- team_name: "apex-{phase}" # e.g., "apex-analyze", "apex-layer2", "apex-layer3"
14
- description: "{phase purpose}" # e.g., "Scan SmartStack project for existing code"
15
- ```
16
-
17
- Always provide both `team_name` and `description`.
18
-
19
- ---
20
-
21
- ## Teammate Spawning (T12)
22
-
23
- ```yaml
24
- Task:
25
- subagent_type: "Explore" | "general-purpose" # See assignment table below
26
- team_name: "apex-{phase}" # Must match TeamCreate
27
- name: "{teammate-name}" # e.g., "scan-backend", "entity-employee"
28
- model: "sonnet" | "opus" # sonnet for scan, opus for dev (T02/T06)
29
- mode: "bypassPermissions"
30
- prompt: "{detailed task prompt}"
31
- ```
32
-
33
- ### Model & Agent Assignment (T02/T03/T06)
34
-
35
- | Task Type | subagent_type | Model | Justification |
36
- |-----------|---------------|-------|---------------|
37
- | Scan/read files | Explore | Sonnet | Read-only (Glob, Grep, Read) |
38
- | Read context (PRD, feature.json) | Explore | Sonnet | Read-only extraction |
39
- | Code development | general-purpose | Opus | Full tools via skills/MCP |
40
- | Fix/resolve | general-purpose | Opus | Requires reasoning + editing |
41
-
42
- ---
43
-
44
- ## Task List Coordination (T10)
45
-
46
- ### Task Creation (by team lead, BEFORE spawning teammates)
47
-
48
- Tasks MUST be created upfront for the full layer scope:
49
-
50
- ```
51
- FOR EACH entity in layer:
52
- TaskCreate(
53
- subject: "Layer {N}: {Entity} {layer_type}",
54
- description: "{detailed scope: files, skills, MCP tools}",
55
- activeForm: "{Building/Creating} {Entity} {layer_type}"
56
- )
57
- ```
58
-
59
- ### Task Assignment (by team lead, WHEN spawning)
60
-
61
- Include task ID and metadata context in teammate prompt:
62
-
63
- ```
64
- "Your assigned task ID is {task_id}.
65
- Your metadata context: entities={entities}, layer={layer}, tools={tools}.
66
- Call TaskUpdate(taskId: '{task_id}', status: 'in_progress') before starting.
67
- Call TaskUpdate(taskId: '{task_id}', status: 'completed', metadata: { files_created: [...] }) after ENTITY_COMPLETE message."
68
- ```
69
-
70
- ### Task Monitoring (by team lead)
71
-
72
- ```
73
- 1. TaskList() — check progress after each teammate message
74
- 2. All tasks completed → proceed to build gate
75
- 3. Any task stuck → investigate, reassign if needed
76
- ```
77
-
78
- ---
79
-
80
- ## Communication (T09)
81
-
82
- **Default:** Direct messages (DM) between specific agents.
83
-
84
- ```yaml
85
- SendMessage:
86
- type: "message" # DM, not broadcast
87
- recipient: "{teammate-name}" # By name, not UUID
88
- content: "{message}"
89
- summary: "{5-10 word preview}"
90
- ```
91
-
92
- **Broadcast:** ONLY for emergency (all-stop, critical blocker).
93
-
94
- ```yaml
95
- SendMessage:
96
- type: "broadcast" # Expensive: N teammates = N deliveries
97
- content: "{urgent message}"
98
- summary: "{critical issue summary}"
99
- ```
100
-
101
- ---
102
-
103
- ## Team Decomposition (C01)
104
-
105
- ### Step-01 Analyze: Split by scan scope
106
-
107
- ```
108
- scan-backend : Domain/ + Infrastructure/ + Application/ + Api/
109
- scan-frontend : src/pages/ + src/components/ + src/locales/
110
- scan-context : .ralph/ + docs/business/
111
- ```
112
-
113
- ### Step-03 Execute: Split by entity WITHIN a layer
114
-
115
- > **Cross-layer parallelism is FORBIDDEN.** Layers execute sequentially: 0 → 1 → 2 → 3 → 4.
116
- > Agent teams parallelize **multi-entity work within a single layer.**
117
-
118
- ```
119
- Layer 2 (Backend) — if multiple entities:
120
- entity-{name1} : Service + DTO + Controller for Entity1
121
- entity-{name2} : Service + DTO + Controller for Entity2
122
- ...
123
-
124
- Layer 3 (Frontend) — if multiple entities:
125
- entity-{name1} : Pages + i18n + routes for Entity1
126
- entity-{name2} : Pages + i18n + routes for Entity2
127
- ...
128
- ```
129
-
130
- Each teammate has an **isolated scope** (C02): handles one entity end-to-end within the layer.
131
-
132
- ---
133
-
134
- ## Coordination (C03)
135
-
136
- ### Step-01: Lead aggregates scan results
137
-
138
- ```
139
- 1. Spawn 3 scan teammates
140
- 2. Each reports findings via DM to lead
141
- 3. Lead merges into unified analysis
142
- ```
143
-
144
- ### Step-03: Lead verifies between ALL 5 layers
145
-
146
- ```
147
- 1. Layer 0: lead executes (domain + infra + migration)
148
- 2. Build gate: dotnet build → MUST PASS
149
- 3. Layer 1: lead executes (seed data — sequential, no teams)
150
- 4. Build gate: dotnet build → MUST PASS
151
- 5. Layer 2: spawn entity teammates (if multi-entity) OR lead executes (if single entity)
152
- 6. Build gate: dotnet build → MUST PASS
153
- 7. Backend tests inline (scaffold + run + fix max 3)
154
- 8. Layer 3: spawn entity teammates (if multi-entity) OR lead executes (if single entity)
155
- 9. Compliance gate: 5 frontend checks → MUST PASS
156
- 10. Frontend tests inline (scaffold + run + fix max 3)
157
- 11. Layer 4 (optional): lead executes DevData
158
- ```
159
-
160
- ---
161
-
162
- ## Idle Handling (T13)
163
-
164
- Teammates go idle after every turn — this is **normal**.
165
- - Idle does NOT mean done or unavailable
166
- - Sending a message to an idle teammate wakes them up
167
- - Do NOT treat idle as an error
168
-
169
- ---
170
-
171
- ## Graceful Shutdown (T11)
172
-
173
- After phase completes:
174
-
175
- ```yaml
176
- # For each teammate:
177
- SendMessage:
178
- type: "shutdown_request"
179
- recipient: "{teammate-name}"
180
- content: "Phase complete, shutting down"
181
-
182
- # Teammate responds:
183
- SendMessage:
184
- type: "shutdown_response"
185
- request_id: "{from_request}"
186
- approve: true
187
-
188
- # After all confirmations:
189
- TeamDelete
190
- ```
191
-
192
- ---
193
-
194
- ## Decision Matrix
195
-
196
- | Condition | Action |
197
- |-----------|--------|
198
- | economy_mode = true | NO teams, all sequential |
199
- | Single entity (any layer) | NO teams, agent principal handles all |
200
- | Multiple entities, Layer 2 | Teams: one teammate per entity (service + controller) |
201
- | Multiple entities, Layer 3 | Teams: one teammate per entity (pages + i18n) |
202
- | Layer 0, Layer 1, Layer 4 | NO teams (sequential by nature) |
203
- | Analysis phase (step-01) | Teams: scan-backend + scan-frontend + scan-context |
@@ -1,124 +0,0 @@
1
- # Business Analysis - SmartStack Architecture Reference (_architecture.md)
2
-
3
- > **Loaded by:** step-01-cadrage, step-03a-data, step-05a-handoff
4
- > **Purpose:** Provide architectural context for relevant questions and aligned recommendations
5
-
6
- ---
7
-
8
- ## 5 Couches (Clean Architecture)
9
-
10
- | Couche | Projet | Contenu | Impact BA |
11
- |--------|--------|---------|-----------|
12
- | **Domain** | `SmartStack.Domain` | Entites, enums, interfaces | Entites identifiees en discovery |
13
- | **Application** | `SmartStack.Application` | CQRS (Commands/Queries), validations, DTOs | Use cases de la specification |
14
- | **Infrastructure** | `SmartStack.Infrastructure` | EF Core, services externes, jobs | Integrations et contraintes techniques |
15
- | **API** | `SmartStack.API` | Controllers REST, permissions | Endpoints et securite |
16
- | **Web** | `smartstack-web` | React 19, pages, composants | UI/UX et navigation |
17
-
18
- ---
19
-
20
- ## Classes de Base des Entites
21
-
22
- | Classe | Interface | Champs auto-inclus | Quand utiliser |
23
- |--------|-----------|---------------------|----------------|
24
- | `BaseEntity` | - | `Id` (Guid), `TenantId`, `CreatedAt`, `UpdatedAt` | **Defaut pour toute entite metier** |
25
- | `BaseEntity` | `IAuditableEntity` | + `CreatedBy`, `UpdatedBy` | Entite avec audit complet |
26
- | `SystemEntity` | - | `Id` (Guid), `CreatedAt` (pas de TenantId) | Entites systeme (navigation, permissions) |
27
- | `BaseEntity` | `ISoftDeletable` | + `IsDeleted`, `DeletedBy`, `DeletedAt` | Entite avec suppression logique |
28
- | `HierarchicalEntity` | - | + `ParentId`, `Level`, `Path` | Arborescences (categories, menus) |
29
- | `BaseEntity + UserId FK` | `ITenantEntity` | + `UserId` (Guid FK to User) | Person Role Extension — entity represents a person linked to User. Use `isPersonRole: true` in scaffold_extension. |
30
-
31
- > **IMPORTANT :** Ne JAMAIS proposer `CreatedBy`, `UpdatedBy`, `IsDeleted`, `TenantId` comme champs explicites — ils sont AUTOMATIQUES via la classe de base ou l'interface.
32
-
33
- ---
34
-
35
- ## Services d'Integration Disponibles
36
-
37
- | Service | Interface | Quand le proposer |
38
- |---------|-----------|-------------------|
39
- | Notifications in-app | `INotificationService` | Alertes, evenements, rappels |
40
- | Workflow automatise | `IWorkflowService` | Emails transactionnels, webhooks, actions chainees |
41
- | Completion IA | `IAICompletionService` | Suggestions, classification, generation contenu |
42
- | SignalR temps reel | `IHubContext<BusinessHub>` | Mises a jour en temps reel |
43
- | Jobs planifies | Hangfire `IBackgroundJobClient` | Traitements differes, purges, imports |
44
-
45
- ---
46
-
47
- ## Conventions Base de Donnees
48
-
49
- | Aspect | Convention | Exemple |
50
- |--------|------------|---------|
51
- | Schema | `core` (socle SmartStack) vs `extensions` (entites client/metier) | `core.auth_Roles`, `nav_Applications`, `supp_Tickets` |
52
- | Tables | `{prefix}_{EntityPlural}` (prefixe domaine + PascalCase pluriel) | `auth_Users`, `nav_Applications`, `supp_Tickets` |
53
- | Prefixes domaine | `auth_`, `nav_`, `cfg_`, `ref_`, `wkf_`, `ai_`, `loc_`, `lic_`, `tenant_`, `support_` | Pour un nouveau module metier : choisir un prefixe court (3-5 chars) |
54
- | FK | `{Entity}Id` (ex: `ClientId`, `OrderId`) | |
55
- | Index | `IX_{Table}_{Column}` | `IX_bik_FreeBickes_TenantId_Code` |
56
- | Migration | 1 migration par feature, nommee via MCP (`suggest_migration`) | `extensions_v1.0.0_001_AddFreeBicke` |
57
-
58
- ---
59
-
60
- ## Conventions de Dossiers (Clean Architecture)
61
-
62
- | Couche | Pattern de dossiers | Exemple (module FreeBicke dans business > operations) |
63
- |--------|--------------------|---------------------------------------------------------|
64
- | **Domain** | `{Project}.Domain/Business/{Application}/{Module}/` | `Domain/Business/Operations/FreeBicke/FreeBicke.cs` |
65
- | **Application/DTOs** | `{Project}.Application/Business/{Application}/{Module}/DTOs/` | `Application/Business/Operations/FreeBicke/DTOs/FreeBickeDto.cs` |
66
- | **Application/Interfaces** | `{Project}.Application/Common/Interfaces/` | `Application/Common/Interfaces/IFreeBickeService.cs` |
67
- | **Infrastructure/Config** | `{Project}.Infrastructure/Persistence/Configurations/{Application}/{Module}/` | `Configurations/Operations/FreeBicke/FreeBickeConfiguration.cs` |
68
- | **Infrastructure/Services** | `{Project}.Infrastructure/Services/{Application}/{Module}/` | `Services/Operations/FreeBicke/FreeBickeService.cs` |
69
- | **Infrastructure/SeedData** | `{Project}.Infrastructure/Persistence/Seeding/Data/{Application}/{Module}/` | `Seeding/Data/Operations/FreeBicke/FreeBickeSeedData.cs` |
70
- | **API/Controllers** | `{Project}.Api/Controllers/Business/{Application}/` | `Controllers/Business/Operations/FreeBickeController.cs` |
71
- | **Frontend/Pages** | `web/src/pages/{application}/{module}/` | `pages/operations/freebicke/page.tsx` |
72
- | **Frontend/i18n** | `web/src/i18n/locales/{lang}/{module}.json` | `locales/fr/freebicke.json` |
73
-
74
- > **IMPORTANT :** Chaque module a son **propre sous-dossier** dans chaque couche. Ne JAMAIS mettre tous les fichiers a la racine d'une couche.
75
-
76
- ---
77
-
78
- ## SeedData Core (Obligatoire pour chaque feature)
79
-
80
- > **Chaque nouvelle feature necessite des SeedData dans 5 fichiers core** pour etre fonctionnelle (navigation visible, permissions actives, roles assignes).
81
-
82
- | # | Fichier | Contenu | Mecanisme |
83
- |---|---------|---------|-----------|
84
- | 1 | `NavigationModuleConfiguration.cs` | Entree module dans `nav_Modules` (HasData) | EF Core Migration |
85
- | 2 | `NavigationTranslationConfiguration.cs` | Traductions du module (4 langues x chaque entite nav) | EF Core Migration |
86
- | 3 | `PermissionConfiguration.cs` | Permissions CRUD + wildcards dans `nav_Permissions` (HasData) | EF Core Migration |
87
- | 4 | `Permissions.cs` (Application layer) | Constantes compile-time pour `[RequirePermission]` | Code |
88
- | 5 | `RolePermissionConfiguration.cs` | Associations role-permission dans `auth_RolePermissions` (HasData) | EF Core Migration |
89
-
90
- **Roles par defaut pour chaque application (4 niveaux) :**
91
-
92
- | Role | Permissions | Description |
93
- |------|-------------|-------------|
94
- | **{App} Admin** | `{app}.*` (wildcard) | Acces complet a l'application |
95
- | **{App} Manager** | `read`, `create`, `update`, `assign` | Gestion complete sans suppression |
96
- | **{App} Contributor** | `read`, `create`, `update` | Contribution active |
97
- | **{App} Viewer** | `read` uniquement | Consultation seule |
98
-
99
- > **CRITIQUE :** Si les SeedData ne sont pas crees, le module sera invisible dans la navigation et les permissions retourneront 403.
100
-
101
- ---
102
-
103
- ## Contraintes Non-Negociables
104
-
105
- | Contrainte | Detail |
106
- |------------|--------|
107
- | **Multi-tenant** | `TenantId` sur toute entite metier, isolation automatique |
108
- | **RBAC** | Permissions `{app}.{module}.{action}`, HasData pattern |
109
- | **CQRS** | Commands (write) et Queries (read) separes via MediatR |
110
- | **Validation** | FluentValidation pour toute commande |
111
- | **i18n** | 4 langues obligatoires (fr, en, it, de) |
112
- | **Soft Delete** | Pas de DELETE physique sauf purge RGPD planifiee |
113
-
114
- ---
115
-
116
- ## Outils MCP Pertinents pour le BA
117
-
118
- | Phase BA | Outil MCP | Usage |
119
- |----------|-----------|-------|
120
- | Pre-research (01) | `analyze_extension_points` | Decouvrir modules/entites existants |
121
- | Pre-research (01) | `api_docs` | Consulter la documentation API existante |
122
- | Analyse (02) | `validate_conventions` | Verifier les noms d'entites proposes |
123
- | Specification (03) | `generate_permissions` | Generer la matrice de permissions |
124
- | Handoff (05) | `scaffold_extension` | Preparer le scaffolding |