@atlashub/smartstack-cli 4.74.0 → 4.76.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 (121) hide show
  1. package/dist/index.js +152 -31
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +14 -3
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/templates/agents/ba-reader.md +17 -15
  7. package/templates/agents/ba-writer.md +49 -51
  8. package/templates/skills/apex/SKILL.md +2 -2
  9. package/templates/skills/apex/_shared.md +1 -1
  10. package/templates/skills/apex/references/checks/backend-checks.sh +21 -7
  11. package/templates/skills/apex/references/checks/frontend-checks.sh +26 -0
  12. package/templates/skills/apex/references/checks/infrastructure-checks.sh +47 -10
  13. package/templates/skills/apex/references/checks/seed-checks.sh +47 -7
  14. package/templates/skills/apex/references/core-seed-data.md +20 -18
  15. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +3 -0
  16. package/templates/skills/apex/references/post-checks.md +23 -3
  17. package/templates/skills/apex/references/smartstack-api.md +4 -4
  18. package/templates/skills/apex/references/smartstack-frontend.md +54 -8
  19. package/templates/skills/apex/references/smartstack-layers.md +6 -6
  20. package/templates/skills/apex/steps/step-00-init.md +75 -1
  21. package/templates/skills/apex/steps/step-03-execute.md +16 -4
  22. package/templates/skills/apex/steps/step-03b-layer1-seed.md +65 -6
  23. package/templates/skills/apex/steps/step-03c-layer2-backend.md +50 -5
  24. package/templates/skills/apex/steps/step-03d-layer3-frontend.md +226 -4
  25. package/templates/skills/apex/steps/step-04-examine.md +163 -0
  26. package/templates/skills/apex-verify/SKILL.md +110 -0
  27. package/templates/skills/apex-verify/references/audit-rules.md +50 -0
  28. package/templates/skills/apex-verify/steps/step-00-init.md +119 -0
  29. package/templates/skills/apex-verify/steps/step-01-nav-audit.md +92 -0
  30. package/templates/skills/apex-verify/steps/step-02-crud-audit.md +127 -0
  31. package/templates/skills/apex-verify/steps/step-03-perm-audit.md +119 -0
  32. package/templates/skills/apex-verify/steps/step-04-route-audit.md +98 -0
  33. package/templates/skills/apex-verify/steps/step-05-report.md +110 -0
  34. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +3 -0
  35. package/templates/skills/application/templates-frontend.md +2 -2
  36. package/templates/skills/business-analyse/SKILL.md +17 -3
  37. package/templates/skills/business-analyse/_shared.md +64 -0
  38. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +34 -26
  39. package/templates/skills/business-analyse/questionnaire/01-context.md +13 -9
  40. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +20 -27
  41. package/templates/skills/business-analyse/questionnaire.md +86 -9
  42. package/templates/skills/business-analyse/references/03-json-schemas.md +221 -0
  43. package/templates/skills/business-analyse/references/03-post-check-validation.md +208 -0
  44. package/templates/skills/business-analyse/references/03-smartstack-entity-guards.md +32 -0
  45. package/templates/skills/business-analyse/references/04-cross-module-validation.md +95 -0
  46. package/templates/skills/business-analyse/references/04-file-allocation.md +162 -0
  47. package/templates/skills/business-analyse/references/04-naming-audit-checks.md +174 -0
  48. package/templates/skills/business-analyse/references/04-semantic-validation-matrix.md +118 -0
  49. package/templates/skills/business-analyse/references/canonical-json-formats.md +7 -3
  50. package/templates/skills/business-analyse/references/domain-research-playbook.md +234 -0
  51. package/templates/skills/business-analyse/references/entity-sourcing-presentation.md +166 -0
  52. package/templates/skills/business-analyse/references/init-resume-logic.md +70 -0
  53. package/templates/skills/business-analyse/references/module-completeness-challenge.md +174 -0
  54. package/templates/skills/business-analyse/references/multi-app-detection.md +149 -0
  55. package/templates/skills/business-analyse/references/portal-classification.md +52 -0
  56. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  57. package/templates/skills/business-analyse/references/validation-checklist.md +35 -6
  58. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +50 -6
  59. package/templates/skills/business-analyse/steps/step-00-init.md +22 -190
  60. package/templates/skills/business-analyse/steps/step-01-cadrage.md +365 -269
  61. package/templates/skills/business-analyse/steps/step-02-structure.md +98 -20
  62. package/templates/skills/business-analyse/steps/step-03-specify.md +810 -229
  63. package/templates/skills/business-analyse/steps/step-04-consolidate.md +509 -278
  64. package/templates/skills/business-analyse-design/SKILL.md +10 -0
  65. package/templates/skills/business-analyse-design/references/screens-post-check.md +221 -0
  66. package/templates/skills/business-analyse-design/references/screens-type-mapping.md +138 -0
  67. package/templates/skills/business-analyse-design/references/smartcomponents-templates.md +225 -0
  68. package/templates/skills/{business-analyse → business-analyse-design}/references/spec-auto-inference.md +117 -117
  69. package/templates/skills/business-analyse-design/steps/step-01-screens.md +36 -162
  70. package/templates/skills/business-analyse-design/steps/step-02-wireframes.md +8 -7
  71. package/templates/skills/business-analyse-design/steps/step-03-navigation.md +89 -42
  72. package/templates/skills/business-analyse-develop/references/compact-loop.md +9 -0
  73. package/templates/skills/business-analyse-develop/references/handoff-quality-gate.md +132 -0
  74. package/templates/skills/business-analyse-develop/references/prd-v3-transformation.md +326 -0
  75. package/templates/skills/business-analyse-develop/references/report-reconciliation.md +140 -0
  76. package/templates/skills/business-analyse-develop/references/report-template.md +142 -0
  77. package/templates/skills/business-analyse-develop/steps/step-01-task.md +5 -177
  78. package/templates/skills/business-analyse-develop/steps/step-02-execute.md +17 -4
  79. package/templates/skills/business-analyse-develop/steps/step-03-commit.md +6 -2
  80. package/templates/skills/business-analyse-develop/steps/step-04-check.md +6 -0
  81. package/templates/skills/business-analyse-develop/steps/step-05-report.md +3 -269
  82. package/templates/skills/business-analyse-handoff/SKILL.md +10 -0
  83. package/templates/skills/business-analyse-handoff/references/agent-handoff-transform-prompt.md +211 -0
  84. package/templates/skills/business-analyse-handoff/references/context-isolation-pattern.md +47 -0
  85. package/templates/skills/business-analyse-handoff/references/handoff-file-inventory.md +49 -0
  86. package/templates/skills/business-analyse-handoff/references/handoff-global-validation.md +142 -0
  87. package/templates/skills/business-analyse-handoff/references/prd-validation-checks.md +125 -0
  88. package/templates/skills/business-analyse-handoff/references/project-index-update.md +98 -0
  89. package/templates/skills/business-analyse-handoff/steps/step-01-transform.md +9 -160
  90. package/templates/skills/business-analyse-handoff/steps/step-02-export.md +10 -99
  91. package/templates/skills/business-analyse-html/SKILL.md +10 -0
  92. package/templates/skills/business-analyse-html/html/ba-interactive.html +504 -97
  93. package/templates/skills/business-analyse-html/html/src/scripts/01-data-init.js +79 -2
  94. package/templates/skills/business-analyse-html/html/src/scripts/02-navigation.js +6 -46
  95. package/templates/skills/business-analyse-html/html/src/scripts/05-render-specs.js +80 -11
  96. package/templates/skills/business-analyse-html/html/src/scripts/06-render-consolidation.js +2 -2
  97. package/templates/skills/business-analyse-html/html/src/scripts/06-render-mockups.js +94 -36
  98. package/templates/skills/business-analyse-html/html/src/scripts/12-render-diagrams.js +162 -0
  99. package/templates/skills/business-analyse-html/html/src/styles/10-diagrams.css +73 -0
  100. package/templates/skills/business-analyse-html/html/src/template.html +2 -0
  101. package/templates/skills/business-analyse-html/references/02-embedded-artifacts-building.md +144 -0
  102. package/templates/skills/business-analyse-html/references/02-feature-data-building.md +143 -0
  103. package/templates/skills/business-analyse-html/references/02-mapping-tables.md +442 -0
  104. package/templates/skills/business-analyse-html/references/02-normalization-helpers.md +139 -0
  105. package/templates/skills/business-analyse-html/references/02-screen-format-detection.md +283 -0
  106. package/templates/skills/business-analyse-html/references/02-self-check-validation.md +199 -0
  107. package/templates/skills/business-analyse-html/references/data-build.md +24 -1
  108. package/templates/skills/business-analyse-html/references/data-mapping.md +119 -17
  109. package/templates/skills/business-analyse-html/steps/step-02-build-data.md +18 -555
  110. package/templates/skills/business-analyse-html/steps/step-04-verify.md +92 -3
  111. package/templates/skills/business-analyse-quick/SKILL.md +807 -0
  112. package/templates/skills/{sketch → business-analyse-quick}/references/domain-heuristics.md +59 -3
  113. package/templates/skills/business-analyse-quick/references/prd-schema.md +268 -0
  114. package/templates/skills/business-analyse-review/SKILL.md +10 -0
  115. package/templates/skills/business-analyse-review/references/review-data-mapping.md +6 -0
  116. package/templates/skills/business-analyse-status/SKILL.md +8 -0
  117. package/templates/skills/dev-start/SKILL.md +143 -307
  118. package/templates/skills/efcore/SKILL.md +13 -0
  119. package/templates/skills/sketch/SKILL.md +15 -153
  120. package/templates/skills/ui-components/SKILL.md +1 -1
  121. package/templates/skills/ui-components/patterns/data-table.md +1 -1
@@ -65,137 +65,8 @@ if (fileExists(queuePath)) {
65
65
 
66
66
  ### 1d. Handoff Reconciliation (Post-Execution Validation)
67
67
 
68
- > **LESSON LEARNED (audit ba-002):** Simple "missing files" warnings were ignored.
69
- > Structured reconciliation tables make gaps impossible to miss.
68
+ See `report-reconciliation.md` for reconciliation logic (file coverage, business rule coverage, API endpoint coverage, and build/test verification).
70
69
 
71
- ```javascript
72
- // === RECONCILIATION 1: Handoff File Coverage ===
73
- const filesToCreate = prd.implementation?.filesToCreate || {};
74
- const handoffReconciliation = { categories: [], totalDeclared: 0, totalPresent: 0, missingFiles: [] };
75
-
76
- for (const [cat, files] of Object.entries(filesToCreate)) {
77
- let declared = 0, present = 0;
78
- for (const file of (files || [])) {
79
- declared++;
80
- const filePath = file.path || file;
81
- if (fileExists(filePath)) {
82
- present++;
83
- } else {
84
- handoffReconciliation.missingFiles.push({ category: cat, path: filePath });
85
- }
86
- }
87
- handoffReconciliation.categories.push({
88
- category: cat, declared, present, missing: declared - present,
89
- coverage: declared > 0 ? Math.round((present / declared) * 100) : 100
90
- });
91
- handoffReconciliation.totalDeclared += declared;
92
- handoffReconciliation.totalPresent += present;
93
- }
94
-
95
- const totalHandoffCoverage = handoffReconciliation.totalDeclared > 0
96
- ? Math.round((handoffReconciliation.totalPresent / handoffReconciliation.totalDeclared) * 100)
97
- : 100;
98
-
99
- // === RECONCILIATION 2: Business Rule Coverage ===
100
- const brMapping = prd.implementation?.brToCodeMapping || [];
101
- const brReconciliation = { total: brMapping.length, implemented: 0, missing: [], notTested: [] };
102
-
103
- for (const br of brMapping) {
104
- const componentFile = br.component || br.file;
105
- const methodName = br.method || br.function;
106
-
107
- if (!componentFile || !fileExists(componentFile)) {
108
- brReconciliation.missing.push({ id: br.id, rule: br.rule, reason: 'file not found' });
109
- continue;
110
- }
111
- if (methodName) {
112
- const content = readFile(componentFile);
113
- if (!content.includes(methodName)) {
114
- brReconciliation.missing.push({ id: br.id, rule: br.rule, reason: `method ${methodName} not found` });
115
- continue;
116
- }
117
- }
118
- brReconciliation.implemented++;
119
-
120
- if (br.testFile && !fileExists(br.testFile)) {
121
- brReconciliation.notTested.push({ id: br.id, rule: br.rule });
122
- }
123
- }
124
-
125
- // === RECONCILIATION 3: API Endpoint Coverage ===
126
- const apiEndpoints = prd.implementation?.apiEndpointSummary || [];
127
- const apiReconciliation = { total: apiEndpoints.length, found: 0, missing: [] };
128
-
129
- const ctrlFilesForReconciliation = glob('src/**/Controllers/**/*Controller.cs');
130
- for (const ep of apiEndpoints) {
131
- const opName = ep.operation || ep.name;
132
- let found = false;
133
- for (const f of ctrlFilesForReconciliation) {
134
- const content = readFile(f);
135
- if (content.includes(opName)) { found = true; break; }
136
- }
137
- if (found) {
138
- apiReconciliation.found++;
139
- } else {
140
- apiReconciliation.missing.push({ operation: opName, method: ep.method, path: ep.path });
141
- }
142
- }
143
-
144
- // Log summary
145
- console.log(`Handoff files: ${handoffReconciliation.totalPresent}/${handoffReconciliation.totalDeclared} (${totalHandoffCoverage}%)`);
146
- console.log(`Business rules: ${brReconciliation.implemented}/${brReconciliation.total} implemented`);
147
- console.log(`API endpoints: ${apiReconciliation.found}/${apiReconciliation.total} found`);
148
- ```
149
-
150
- ### 1e. Final Build & Test Verification (TRUTH CHECK)
151
-
152
- > **LESSON LEARNED (audit ba-002):** "92/92 COMPLETE" + "Build PASS" was reported but the code
153
- > had compilation errors and critical security flaws. The report MUST reflect actual build/test
154
- > state, not just PRD task statuses.
155
-
156
- ```bash
157
- # REAL build verification — overrides any previous "Build PASS" claim
158
- dotnet build --no-restore --verbosity quiet
159
- FINAL_BUILD_RC=$?
160
-
161
- FINAL_TEST_RC=-1
162
- if [ $FINAL_BUILD_RC -eq 0 ]; then
163
- dotnet test --no-build --verbosity quiet
164
- FINAL_TEST_RC=$?
165
- fi
166
- ```
167
-
168
- ```javascript
169
- // Override PRD-based build/test status with REAL results
170
- const buildStatus = FINAL_BUILD_RC === 0 ? 'PASS' : 'FAIL';
171
- const testStatus = FINAL_TEST_RC === 0 ? 'PASS' : (FINAL_TEST_RC === -1 ? 'SKIPPED (build failed)' : 'FAIL');
172
-
173
- // CRITICAL: If build fails despite all tasks "completed", flag this prominently
174
- if (FINAL_BUILD_RC !== 0 && stats.tasks.completed === stats.tasks.total) {
175
- console.error('INTEGRITY WARNING: All tasks marked COMPLETE but build FAILS');
176
- console.error('This indicates phantom task completion — review code quality');
177
- stats.buildIntegrityWarning = true;
178
- }
179
- ```
180
-
181
- ### 1f. MCP Security Scan (Final Gate)
182
-
183
- ```javascript
184
- // Quick MCP security validation on the final codebase
185
- const securityScan = await mcp__smartstack__validate_security();
186
- const conventionScan = await mcp__smartstack__validate_conventions();
187
-
188
- // Check for write endpoints with Read permissions (semantic permission check)
189
- const permissionWarnings = [];
190
- const ctrlFiles = glob('src/**/Controllers/**/*Controller.cs');
191
- for (const f of ctrlFiles) {
192
- const content = readFile(f);
193
- const writeWithRead = content.matchAll(/\[(HttpPost|HttpPut|HttpDelete|HttpPatch)[^\]]*\][^[]*\[RequirePermission\([^\)]*\.Read\)\]/gs);
194
- for (const m of writeWithRead) {
195
- permissionWarnings.push(`${f}: ${m[1]} uses Read permission`);
196
- }
197
- }
198
- ```
199
70
 
200
71
  ### 1c. Test Metrics (from PRD)
201
72
 
@@ -209,146 +80,9 @@ const testsFailed = testTasks.filter(t => t.status === 'failed').length;
209
80
 
210
81
  ## 2. Generate Report
211
82
 
212
- Write to `.ralph/reports/{feature-slug}.md`:
213
-
214
- ```markdown
215
- # Feature Report: {feature}
216
-
217
- ## Summary
218
- | Field | Value |
219
- |-------|-------|
220
- | Status | {status} |
221
- | Iterations | {iterations_used} / {max} |
222
- | Branch | {branch} |
223
- | Duration | {totalDuration}s ({min} min) |
224
- | Execution | Delegated to /apex |
225
-
226
- ## Tasks
227
- | # | Task | Category | Status | Commit |
228
- |---|------|----------|--------|--------|
229
- {for each task:}
230
- | {id} | {description} | {category} | {status_emoji} | {commit_hash} |
231
-
232
- **{completed}/{total} completed, {failed} failed, {blocked} blocked**
233
-
234
- {if moduleStats:}
235
- ## Modules
236
- | Module | Status | Tasks | Completed | Failed | Files | Commits |
237
- |--------|--------|-------|-----------|--------|-------|---------|
238
- {for each mod:}
239
- | {code} | {status} | {total} | {completed} | {failed} | {filesCreated} | {commits} |
240
-
241
- **{completedModules}/{totalModules} modules completed**
242
- {end if}
243
-
244
- {if prd._sectionSplit?.enabled:}
245
- ## Section Split Execution
246
- | Phase | Type | Section | Entities | Status |
247
- |-------|------|---------|----------|--------|
248
- {for each phase:}
249
- | {phase} | {type} | {sectionCode || '-'} | {entities.length} | {status} |
250
-
251
- {end if}
252
-
253
- {if handoffReconciliation.totalDeclared > 0:}
254
- ## Handoff Reconciliation
255
-
256
- ### File Coverage by Category
257
- | Category | Declared | Present | Missing | Coverage |
258
- |----------|----------|---------|---------|----------|
259
- {for each cat in handoffReconciliation.categories:}
260
- | {category} | {declared} | {present} | {missing} | {coverage}% |
261
- {end for}
262
-
263
- **Total: {totalPresent}/{totalDeclared} ({totalHandoffCoverage}%)**
83
+ Write to `.ralph/reports/{feature-slug}.md` using the template structure from `report-template.md`.
264
84
 
265
- {if handoffReconciliation.missingFiles.length > 0:}
266
- ### Missing Files
267
- {for each mf in handoffReconciliation.missingFiles:}
268
- - **{mf.category}**: `{mf.path}`
269
- {end for}
270
- {end if}
271
- {end if}
272
-
273
- {if brReconciliation.total > 0:}
274
- ### Business Rule Coverage
275
- | Metric | Value |
276
- |--------|-------|
277
- | Total Rules | {brReconciliation.total} |
278
- | Implemented | {brReconciliation.implemented} |
279
- | Missing | {brReconciliation.missing.length} |
280
- | Not Tested | {brReconciliation.notTested.length} |
281
-
282
- {if brReconciliation.missing.length > 0:}
283
- **Missing BR implementations:**
284
- {for each br in brReconciliation.missing:}
285
- - `{br.id}`: {br.rule} — {br.reason}
286
- {end for}
287
- {end if}
288
- {end if}
289
-
290
- {if apiReconciliation.total > 0:}
291
- ### API Endpoint Coverage
292
- | Metric | Value |
293
- |--------|-------|
294
- | Total Endpoints | {apiReconciliation.total} |
295
- | Found | {apiReconciliation.found} |
296
- | Missing | {apiReconciliation.missing.length} |
297
-
298
- {if apiReconciliation.missing.length > 0:}
299
- **Missing API endpoints:**
300
- {for each ep in apiReconciliation.missing:}
301
- - `{ep.method} {ep.path}` — operation: `{ep.operation}`
302
- {end for}
303
- {end if}
304
- {end if}
305
-
306
- ## Build & Test Verification (Actual)
307
-
308
- > These results come from REAL `dotnet build` and `dotnet test` execution,
309
- > not from PRD task statuses.
310
-
311
- | Check | Result |
312
- |-------|--------|
313
- | `dotnet build` | {buildStatus} |
314
- | `dotnet test` | {testStatus} |
315
- | MCP validate_security | {securityScan.status} |
316
- | MCP validate_conventions | {conventionScan.status} |
317
- | Permission semantic check | {permissionWarnings.length === 0 ? 'PASS' : `${permissionWarnings.length} issues`} |
318
-
319
- {if stats.buildIntegrityWarning:}
320
- > **INTEGRITY WARNING:** All tasks marked COMPLETE but the build FAILS.
321
- > This means some generated code references types or methods that don't exist.
322
- > Review the build output and fix before considering this feature done.
323
- {end if}
324
-
325
- {if permissionWarnings.length > 0:}
326
- > **PERMISSION WARNINGS:** Write endpoints using Read permissions detected:
327
- {for each warning:}
328
- > - {warning}
329
- {end for}
330
- {end if}
331
-
332
- ## Test Metrics (PRD-based)
333
- | Metric | Value |
334
- |--------|-------|
335
- | Test Tasks | {testTasks.length} |
336
- | Passed | {testsPassed} |
337
- | Failed | {testsFailed} |
338
-
339
- ## Failed Tasks
340
- {table of failed tasks with error messages, or "None"}
341
-
342
- ## Files
343
- - Created: {filesCreated.length}
344
- - Modified: {filesModified.length}
345
-
346
- ## Commits
347
- {unique commits list}
348
-
349
- ---
350
- *Auto-generated by Ralph Loop — SmartStack CLI*
351
- ```
85
+ Populate all variables from loaded data (stats, moduleStats, handoffReconciliation, brReconciliation, apiReconciliation, buildStatus, testStatus, permissionWarnings, testTasks, filesCreated, filesModified).
352
86
 
353
87
  ## 3. Finalize
354
88
 
@@ -89,3 +89,13 @@ Transforms consolidated BA data into structured handoff and PRD files.
89
89
  ## Entry Point
90
90
 
91
91
  **FIRST ACTION:** Load `steps/step-00-validate.md`
92
+
93
+ <success_criteria>
94
+ - Feature BA validee et statut "consolidated" confirme
95
+ - Handoff data genere avec 8 categories (domain, application, infrastructure, api, frontend, seedData, tests, documentation)
96
+ - handoff.json enrichi par module avec BR-to-code et API summary
97
+ - PRD files generes : .ralph/prd-{moduleCode}.json par module
98
+ - progress.txt cree avec task breakdown
99
+ - modules-queue.json cree avec ordre topologique
100
+ - Manifeste BA mis a jour avec statut "handed-off"
101
+ </success_criteria>
@@ -0,0 +1,211 @@
1
+ # Agent Transform Prompt for ba-writer (Module Handoff Generation)
2
+
3
+ ## MANDATORY CONSTRAINTS
4
+
5
+ **INTERDICTION:** You must create EXACTLY 7 files and NOTHING ELSE. No README, SUMMARY, MANIFEST, INDEX, CHECKLIST.
6
+
7
+ ## YOUR TASK
8
+
9
+ Transform module "{moduleCode}" for handoff.
10
+
11
+ ## Output EXACT (7 files)
12
+
13
+ 1. WRITE `{moduleDir}/handoff.json` (8 categories, brMapping, apiEndpoints, specificationFiles)
14
+ 2. COPY VERBATIM `.ralph/prd-{moduleCode}.entities.json`
15
+ 3. COPY VERBATIM `.ralph/prd-{moduleCode}.rules.json`
16
+ 4. COPY VERBATIM `.ralph/prd-{moduleCode}.usecases.json`
17
+ 5. COPY VERBATIM `.ralph/prd-{moduleCode}.screens.json`
18
+ 6. COPY VERBATIM `.ralph/prd-{moduleCode}.permissions.json`
19
+ 7. GENERATE `.ralph/prd-{moduleCode}.json` (PRD v3.0.0)
20
+
21
+ Return: `{ "moduleCode": "{moduleCode}", "filesCreated": 7, "errors": [], "complexity": "..." }`
22
+
23
+ ## INPUT
24
+
25
+ - Module BA directory: `{moduleDir}` (ba-006: `docs/{projectSlug}/v{X.Y}/{appKebab}/{moduleKebab}/`)
26
+ - Application code: `{appCode}`
27
+ - Application name: `{appName}`
28
+ - Feature description: `{featureDescription}`
29
+ - Module index: `{moduleDir}/index.json`
30
+
31
+ ## INSTRUCTIONS
32
+
33
+ ### 1. Read Input Files
34
+
35
+ Read these 5 files from `{moduleDir}` (ba-006 location: `docs/{projectSlug}/v{X.Y}/{appKebab}/{moduleKebab}/`):
36
+
37
+ 1. **entities.json** → `entities[]`
38
+ 2. **usecases.json** → `useCases[]` (canonical key: `"useCases"`, fallback: `"usecases"`)
39
+ 3. **rules.json** → `rules[]` (canonical key: `"rules"`, fallback: `"businessRules"`)
40
+ 4. **permissions.json** → `roles[]`, `matrix[]`, `permissionPaths[]`
41
+ 5. **screens.json** → `sections[]` (canonical key: `"sections"`, fallback: `"screens"`)
42
+
43
+ ### 2. Normalization Safety Net (BACKWARD COMPAT)
44
+
45
+ When reading flat files, prefer canonical keys but fall back to alternatives:
46
+ - `useCases`: `data.useCases || data.usecases || []`
47
+ - `primaryActor`: `uc.primaryActor || uc.actor`
48
+ - `mainScenario`: `uc.mainScenario || uc.steps` (if `steps[]` contains objects, extract `.action`)
49
+ - `rules`: `data.rules || data.businessRules || []`
50
+ - `rules[].examples`: prefer `rule.examples[]` (`{input, expected}`); fallback: wrap `rule.example` string as `[{input: rule.example, expected: ""}]`
51
+ - `rules[].statement`: prefer `rule.statement`; fallback: `rule.description`
52
+ - `rules[].id`: prefer `rule.id`; fallback: `rule.code`
53
+ - `screens`: `data.sections || data.screens` (if `screens[]` exists, treat each screen as a section with 1 resource)
54
+
55
+ This safety net handles pre-4.52 BA outputs. It should become unnecessary once step-03-specify enforces canonical keys.
56
+
57
+ ### 3. Determine Complexity
58
+
59
+ | Criteria | Simple | Medium | Complex |
60
+ |----------|--------|--------|---------|
61
+ | Entities | ≤3 | ≤6 | >6 |
62
+ | Use Cases | ≤5 | ≤12 | >12 |
63
+ | Business Rules | ≤10 | ≤20 | >20 |
64
+
65
+ Classify the module based on these thresholds.
66
+
67
+ ### 4. Generate API Endpoints
68
+
69
+ From use cases and entities, auto-generate REST endpoints:
70
+
71
+ - UC "Create X" → `POST /api/{app}/{module}`
72
+ - UC "List X" → `GET /api/{app}/{module}`
73
+ - UC "Update X" → `PUT /api/{app}/{module}/{id}`
74
+ - UC "Delete X" → `DELETE /api/{app}/{module}/{id}`
75
+ - UC "Get X" → `GET /api/{app}/{module}/{id}`
76
+
77
+ Use permission paths from `permissions.json` as-is.
78
+
79
+ ### 5. Enrich Section UC/BR
80
+
81
+ Using `sectionCode` from `usecases.json` and `rules.json`, link each UC and BR to its section.
82
+
83
+ ### 6. Entity Name Canonicalization (MANDATORY)
84
+
85
+ Before generating any file paths, canonicalize ALL entity names from `entities.json`:
86
+
87
+ 1. Load `references/entity-canonicalization.md` for complete rules
88
+ 2. For each entity in `entities.json > entities[]`:
89
+ - If entity has `codeIdentifier` or `englishName` → use it directly
90
+ - Otherwise → apply canonicalization: strip diacritics, remove apostrophes/spaces, remove French articles (d, de, du, l, la, le, les, un, une, des, a, au, aux, en), PascalCase
91
+ 3. Use the CANONICALIZED name in ALL file path templates (`{EntityName}`, `{ServiceName}`, `{DtoName}`, etc.)
92
+ 4. Store the mapping `{ originalName: "Type d'absence", canonicalName: "TypeAbsence" }` in handoff metadata for traceability
93
+
94
+ **Example:** Entity `"Type d'absence"` → canonicalized to `"TypeAbsence"` → path `src/Domain/Entities/App/Module/TypeAbsence.cs`
95
+
96
+ **BLOCKING:** If ANY entity name after canonicalization is not a valid C# identifier (`/^[A-Za-z_][A-Za-z0-9_]*$/`), STOP and report the error.
97
+
98
+ ### 7. Build Handoff Data (8 Categories)
99
+
100
+ Load `references/handoff-file-templates.md` for complete JSON templates.
101
+
102
+ All backend paths MUST include `{ApplicationName}/` hierarchy.
103
+
104
+ | Category | Source | Key rules |
105
+ |----------|--------|-----------|
106
+ | **Domain** | `entities[]` | Entities, ValueObjects, Enums |
107
+ | **Application** | `useCases[]` | Services, DTOs, Validators |
108
+ | **Infrastructure** | `entities[]` | EF Configurations, DbSet |
109
+ | **API** | Generated from useCases + entities | Controllers |
110
+ | **Frontend** | `screens[]` | Pages, Components, Hooks; split by file (NOT monolithic) |
111
+ | **SeedData** | entities + permissions | CORE + business (include category field) |
112
+ | **Tests** | All layers | Unit, Integration, Security |
113
+ | **Documentation** | All layers | Technical docs (can be empty `[]`) |
114
+
115
+ **Frontend specifics:** Each page as separate entry, FK fields, ALL pages use `/ui-components`.
116
+
117
+ **Routes specifics:** PascalCase module codes → kebab-case (NEVER include `/business/` prefix).
118
+
119
+ ### 8. Map Business Rules to Code
120
+
121
+ Load `references/handoff-mappings.md` for mapping rules.
122
+
123
+ For each rule: `ruleId`, `title`, `module`, `severity`, `implementationPoints[]`.
124
+
125
+ ### 9. Handle personRoleConfig
126
+
127
+ If any entity has `personRoleConfig`, copy it verbatim into handoff.
128
+
129
+ ### 10. Generate Seed Data
130
+
131
+ Load `references/handoff-seeddata-generation.md` for core seed generation.
132
+
133
+ - `category: "core"` → Navigation, Permissions, Roles
134
+ - `category: "business"` → Domain-specific data
135
+
136
+ ### 11. Map Entity to Domain
137
+
138
+ Load `references/entity-domain-mapping.md` for mapping rules.
139
+
140
+ - Entity → `src/Domain/Entities/{App}/{Module}/{EntityName}.cs`
141
+ - ValueObject → `src/Domain/{Module}/ValueObjects/{VOName}.cs`
142
+ - Enum → `src/Domain/{Module}/Enums/{EnumName}.cs`
143
+
144
+ ### 12. Declare Dependencies per File Entry
145
+
146
+ | Layer | Dependencies |
147
+ |-------|-------------|
148
+ | domain | `[]` |
149
+ | infrastructure | `["domain"]` |
150
+ | application | `["domain"]` |
151
+ | api | `["application"]` |
152
+ | seedData | `["domain", "infrastructure"]` |
153
+ | frontend | `["api"]` |
154
+ | tests | `["domain", "application", "infrastructure", "api"]` |
155
+ | documentation | `[]` |
156
+
157
+ ### 13. Write Result
158
+
159
+ Write via `ba-writer.enrichModuleHandoff` with the complete handoff payload:
160
+ - `complexity`, `filesToCreate` (8 categories), `brToCodeMapping`, `apiEndpointSummary`
161
+ - `prdFile`: `".ralph/prd-{moduleCode}.json"`
162
+ - `totalFiles`, `totalTasks`, `handedOffAt` (ISO timestamp)
163
+ - `featureDescription`: `{featureDescription}`
164
+
165
+ ### 14. Write Specification Files (MANDATORY)
166
+
167
+ After writing the handoff data, ALSO write 5 companion files:
168
+
169
+ 1. `.ralph/prd-{moduleCode}.entities.json` = VERBATIM copy of `{moduleDir}/entities.json`
170
+ 2. `.ralph/prd-{moduleCode}.rules.json` = VERBATIM copy of `{moduleDir}/rules.json`
171
+ 3. `.ralph/prd-{moduleCode}.usecases.json` = VERBATIM copy of `{moduleDir}/usecases.json`
172
+ 4. `.ralph/prd-{moduleCode}.screens.json` = VERBATIM copy of `{moduleDir}/screens.json`
173
+ 5. `.ralph/prd-{moduleCode}.permissions.json` = VERBATIM copy of `{moduleDir}/permissions.json`
174
+
175
+ Add `specificationFiles` to the PRD referencing these files (relative names, all in `.ralph/`):
176
+
177
+ ```json
178
+ "specificationFiles": {
179
+ "entities": "prd-{moduleCode}.entities.json",
180
+ "rules": "prd-{moduleCode}.rules.json",
181
+ "usecases": "prd-{moduleCode}.usecases.json",
182
+ "screens": "prd-{moduleCode}.screens.json",
183
+ "permissions": "prd-{moduleCode}.permissions.json"
184
+ }
185
+ ```
186
+
187
+ ### 15. POST-CHECK (BLOCKING)
188
+
189
+ After writing, verify:
190
+
191
+ 1. Handoff not empty
192
+ 2. All 8 categories present
193
+ 3. `brToCodeMapping` non-empty
194
+ 4. Section resources have `entity` field
195
+ 5. `SeedData` contains CORE entries: NavigationModuleSeedData, NavigationSectionSeedData (if sections exist), PermissionsSeedData, RolesSeedData
196
+ 6. For FIRST module only: `SeedData` contains APP-LEVEL CORE entries (NavigationApplicationSeedData, ApplicationRolesSeedData)
197
+ 7. All 5 companion files exist in `.ralph/` and are non-empty
198
+ 8. `specificationFiles` present in the PRD with all 5 paths
199
+ 9. Entity count in companion matches source: `prd-{moduleCode}.entities.json` `entities[]` count = `{moduleDir}/entities.json` `entities[]` count
200
+ 10. BR count in companion matches source: `prd-{moduleCode}.rules.json` `rules[]` count = `{moduleDir}/rules.json` `rules[]` count
201
+ 11. Each `brToCodeMapping[].statement` is non-empty (not just a title paraphrase)
202
+
203
+ Display: `"POST-CHECK PASS: {moduleCode} -- 8 categories, {brCount} BRs mapped, {coreCount} core seeds, 5 companion files"`
204
+
205
+ ## RETURN VALUE
206
+
207
+ Return a single JSON line:
208
+
209
+ ```json
210
+ { "moduleCode": "{moduleCode}", "filesCreated": 7, "errors": [], "complexity": "simple|medium|complex" }
211
+ ```
@@ -0,0 +1,47 @@
1
+ # Context Isolation Architecture
2
+
3
+ ## Pattern Overview
4
+
5
+ ```
6
+ Main conversation (orchestrator):
7
+ ├─ Determine topological order
8
+ ├─ FOR each module:
9
+ │ └─ Agent(ba-writer) ──► reads 5 files, writes 7 files, returns 1-line JSON
10
+ │ (isolated context: ~500-1000 lines per module)
11
+ └─ Collect 1-line results only, display summary
12
+ ```
13
+
14
+ ## Why Context Isolation is CRITICAL
15
+
16
+ A 10-module project has ~10K lines of JSON data. Loading all at once exceeds Sonnet's effective context. Processing one module per Agent keeps each invocation under ~2K lines.
17
+
18
+ ## Orchestration Pattern (ba-009 fix)
19
+
20
+ The orchestrator does NOT read detailed agent results.
21
+
22
+ Each Agent returns a single compact JSON confirmation:
23
+
24
+ ```json
25
+ {
26
+ "moduleCode": "Employees",
27
+ "filesCreated": 7,
28
+ "errors": [],
29
+ "complexity": "simple"
30
+ }
31
+ ```
32
+
33
+ The orchestrator stores ONLY this summary (1 line per module).
34
+
35
+ **Orchestrator context budget:** ~200 lines max (12 modules × ~15 lines each).
36
+
37
+ ## Execution Flow
38
+
39
+ 1. **Determine topological order** from step-00 data
40
+ 2. **For EACH module in topological order:**
41
+ - Call Agent(ba-writer) with isolated context
42
+ - Receive 1-line JSON confirmation
43
+ - Store only the confirmation
44
+ 3. **Collect all confirmations** and display summary
45
+ 4. **Never load detailed agent results** back into main conversation
46
+
47
+ This pattern prevents context accumulation across modules and enables processing of large multi-module projects.
@@ -0,0 +1,49 @@
1
+ # Handoff File Inventory
2
+
3
+ ## FICHIERS A CREER — LISTE FERMEE (ba-009 fix)
4
+
5
+ Exhaustive inventory. ONLY these files must be created. ABSOLUTE PROHIBITION on creating README, SUMMARY, MANIFEST, INDEX, CHECKLIST, ARTIFACTS, EXECUTION-SUMMARY, etc.
6
+
7
+ ## Per-Module Files (Created 7 times, once per module {M})
8
+
9
+ | # | Filename | Location |
10
+ |---|----------|----------|
11
+ | 1 | `handoff.json` | `{moduleDir}/handoff.json` (in docs/) |
12
+ | 2 | `prd-{M}.json` | `.ralph/prd-{M}.json` (PRD master v3.0.0) |
13
+ | 3 | `prd-{M}.entities.json` | `.ralph/` (VERBATIM copy) |
14
+ | 4 | `prd-{M}.rules.json` | `.ralph/` (VERBATIM copy) |
15
+ | 5 | `prd-{M}.usecases.json` | `.ralph/` (VERBATIM copy) |
16
+ | 6 | `prd-{M}.screens.json` | `.ralph/` (VERBATIM copy) |
17
+ | 7 | `prd-{M}.permissions.json` | `.ralph/` (VERBATIM copy) |
18
+
19
+ **Subtotal per module:** 7 files
20
+
21
+ ## Global Files (Created once)
22
+
23
+ | # | Filename | Location |
24
+ |---|----------|----------|
25
+ | 8 | `modules-queue.json` | `.ralph/modules-queue.json` |
26
+ | 9 | `progress.txt` | `.ralph/progress.txt` |
27
+
28
+ **Subtotal:** 2 files
29
+
30
+ ## Total
31
+
32
+ **TOTAL: (7 × N modules) + 2 global files**
33
+
34
+ For a 3-module project: 7×3 + 2 = 23 files exactly.
35
+
36
+ ## Companion File Naming — REGEX CANONIQUE
37
+
38
+ Each companion MUST match: `prd-{ModuleCode}.{suffix}.json`
39
+
40
+ where `suffix ∈ { entities | rules | usecases | screens | permissions }`
41
+
42
+ ### FORBIDDEN VARIANTS (ABSOLUTE PROHIBITION)
43
+
44
+ - ✗ `prd-Module.useCases.json` (wrong casing — must be `usecases`)
45
+ - ✗ `prd-Module.businessRules.json` (wrong name — must be `rules`)
46
+ - ✗ `prd-Module.api-spec.json` (not planned)
47
+ - ✗ `prd-Module.summary.json` (not planned)
48
+
49
+ All companion filenames must use **lowercase** suffixes and EXACTLY the 5 defined names.