@atlashub/smartstack-cli 4.73.0 → 4.75.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 (95) hide show
  1. package/dist/index.js +111 -36
  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/project/Dockerfile.backend.template +2 -2
  9. package/templates/project/docker-compose.yml.template +20 -0
  10. package/templates/skills/apex/_shared.md +1 -1
  11. package/templates/skills/apex/references/checks/backend-checks.sh +21 -7
  12. package/templates/skills/apex/references/checks/infrastructure-checks.sh +47 -10
  13. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +3 -0
  14. package/templates/skills/apex/references/post-checks.md +5 -2
  15. package/templates/skills/apex/references/smartstack-frontend.md +53 -7
  16. package/templates/skills/apex/steps/step-00-init.md +74 -0
  17. package/templates/skills/apex/steps/step-03-execute.md +16 -4
  18. package/templates/skills/apex/steps/step-03b-layer1-seed.md +39 -6
  19. package/templates/skills/apex/steps/step-03c-layer2-backend.md +50 -5
  20. package/templates/skills/apex/steps/step-03d-layer3-frontend.md +102 -2
  21. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +3 -0
  22. package/templates/skills/business-analyse/SKILL.md +14 -0
  23. package/templates/skills/business-analyse/_shared.md +27 -0
  24. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +34 -26
  25. package/templates/skills/business-analyse/questionnaire/01-context.md +13 -9
  26. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +20 -27
  27. package/templates/skills/business-analyse/questionnaire.md +86 -9
  28. package/templates/skills/business-analyse/references/03-json-schemas.md +213 -0
  29. package/templates/skills/business-analyse/references/03-post-check-validation.md +144 -0
  30. package/templates/skills/business-analyse/references/03-smartstack-entity-guards.md +32 -0
  31. package/templates/skills/business-analyse/references/04-cross-module-validation.md +95 -0
  32. package/templates/skills/business-analyse/references/04-file-allocation.md +162 -0
  33. package/templates/skills/business-analyse/references/04-naming-audit-checks.md +174 -0
  34. package/templates/skills/business-analyse/references/04-semantic-validation-matrix.md +118 -0
  35. package/templates/skills/business-analyse/references/domain-research-playbook.md +234 -0
  36. package/templates/skills/business-analyse/references/entity-sourcing-presentation.md +166 -0
  37. package/templates/skills/business-analyse/references/init-resume-logic.md +70 -0
  38. package/templates/skills/business-analyse/references/module-completeness-challenge.md +174 -0
  39. package/templates/skills/business-analyse/references/multi-app-detection.md +149 -0
  40. package/templates/skills/business-analyse/references/portal-classification.md +52 -0
  41. package/templates/skills/business-analyse/references/validation-checklist.md +30 -1
  42. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +37 -4
  43. package/templates/skills/business-analyse/steps/step-00-init.md +22 -190
  44. package/templates/skills/business-analyse/steps/step-01-cadrage.md +365 -269
  45. package/templates/skills/business-analyse/steps/step-02-structure.md +98 -20
  46. package/templates/skills/business-analyse/steps/step-03-specify.md +652 -229
  47. package/templates/skills/business-analyse/steps/step-04-consolidate.md +308 -287
  48. package/templates/skills/business-analyse-design/SKILL.md +10 -0
  49. package/templates/skills/business-analyse-design/references/screens-post-check.md +221 -0
  50. package/templates/skills/business-analyse-design/references/screens-type-mapping.md +138 -0
  51. package/templates/skills/business-analyse-design/references/smartcomponents-templates.md +225 -0
  52. package/templates/skills/{business-analyse → business-analyse-design}/references/spec-auto-inference.md +117 -117
  53. package/templates/skills/business-analyse-design/steps/step-01-screens.md +36 -162
  54. package/templates/skills/business-analyse-design/steps/step-02-wireframes.md +8 -7
  55. package/templates/skills/business-analyse-design/steps/step-03-navigation.md +89 -42
  56. package/templates/skills/business-analyse-develop/references/compact-loop.md +9 -0
  57. package/templates/skills/business-analyse-develop/references/handoff-quality-gate.md +132 -0
  58. package/templates/skills/business-analyse-develop/references/prd-v3-transformation.md +326 -0
  59. package/templates/skills/business-analyse-develop/references/report-reconciliation.md +140 -0
  60. package/templates/skills/business-analyse-develop/references/report-template.md +142 -0
  61. package/templates/skills/business-analyse-develop/steps/step-01-task.md +5 -177
  62. package/templates/skills/business-analyse-develop/steps/step-02-execute.md +17 -4
  63. package/templates/skills/business-analyse-develop/steps/step-03-commit.md +6 -2
  64. package/templates/skills/business-analyse-develop/steps/step-04-check.md +6 -0
  65. package/templates/skills/business-analyse-develop/steps/step-05-report.md +3 -269
  66. package/templates/skills/business-analyse-handoff/SKILL.md +10 -0
  67. package/templates/skills/business-analyse-handoff/references/agent-handoff-transform-prompt.md +208 -0
  68. package/templates/skills/business-analyse-handoff/references/context-isolation-pattern.md +47 -0
  69. package/templates/skills/business-analyse-handoff/references/handoff-file-inventory.md +49 -0
  70. package/templates/skills/business-analyse-handoff/references/handoff-global-validation.md +142 -0
  71. package/templates/skills/business-analyse-handoff/references/prd-validation-checks.md +125 -0
  72. package/templates/skills/business-analyse-handoff/references/project-index-update.md +98 -0
  73. package/templates/skills/business-analyse-handoff/steps/step-01-transform.md +9 -160
  74. package/templates/skills/business-analyse-handoff/steps/step-02-export.md +10 -99
  75. package/templates/skills/business-analyse-html/SKILL.md +10 -0
  76. package/templates/skills/business-analyse-html/html/ba-interactive.html +306 -81
  77. package/templates/skills/business-analyse-html/html/src/scripts/01-data-init.js +15 -2
  78. package/templates/skills/business-analyse-html/html/src/scripts/02-navigation.js +6 -46
  79. package/templates/skills/business-analyse-html/html/src/scripts/06-render-mockups.js +88 -33
  80. package/templates/skills/business-analyse-html/html/src/scripts/12-render-diagrams.js +116 -0
  81. package/templates/skills/business-analyse-html/html/src/styles/10-diagrams.css +73 -0
  82. package/templates/skills/business-analyse-html/html/src/template.html +2 -0
  83. package/templates/skills/business-analyse-html/references/02-embedded-artifacts-building.md +144 -0
  84. package/templates/skills/business-analyse-html/references/02-feature-data-building.md +141 -0
  85. package/templates/skills/business-analyse-html/references/02-mapping-tables.md +442 -0
  86. package/templates/skills/business-analyse-html/references/02-normalization-helpers.md +139 -0
  87. package/templates/skills/business-analyse-html/references/02-screen-format-detection.md +283 -0
  88. package/templates/skills/business-analyse-html/references/02-self-check-validation.md +199 -0
  89. package/templates/skills/business-analyse-html/references/data-build.md +22 -1
  90. package/templates/skills/business-analyse-html/references/data-mapping.md +40 -5
  91. package/templates/skills/business-analyse-html/steps/step-02-build-data.md +12 -555
  92. package/templates/skills/business-analyse-review/SKILL.md +10 -0
  93. package/templates/skills/business-analyse-status/SKILL.md +8 -0
  94. package/templates/skills/dev-start/SKILL.md +143 -307
  95. package/templates/skills/efcore/SKILL.md +13 -0
@@ -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,208 @@
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
+ - `screens`: `data.sections || data.screens` (if `screens[]` exists, treat each screen as a section with 1 resource)
51
+
52
+ This safety net handles pre-4.52 BA outputs. It should become unnecessary once step-03-specify enforces canonical keys.
53
+
54
+ ### 3. Determine Complexity
55
+
56
+ | Criteria | Simple | Medium | Complex |
57
+ |----------|--------|--------|---------|
58
+ | Entities | ≤3 | ≤6 | >6 |
59
+ | Use Cases | ≤5 | ≤12 | >12 |
60
+ | Business Rules | ≤10 | ≤20 | >20 |
61
+
62
+ Classify the module based on these thresholds.
63
+
64
+ ### 4. Generate API Endpoints
65
+
66
+ From use cases and entities, auto-generate REST endpoints:
67
+
68
+ - UC "Create X" → `POST /api/{app}/{module}`
69
+ - UC "List X" → `GET /api/{app}/{module}`
70
+ - UC "Update X" → `PUT /api/{app}/{module}/{id}`
71
+ - UC "Delete X" → `DELETE /api/{app}/{module}/{id}`
72
+ - UC "Get X" → `GET /api/{app}/{module}/{id}`
73
+
74
+ Use permission paths from `permissions.json` as-is.
75
+
76
+ ### 5. Enrich Section UC/BR
77
+
78
+ Using `sectionCode` from `usecases.json` and `rules.json`, link each UC and BR to its section.
79
+
80
+ ### 6. Entity Name Canonicalization (MANDATORY)
81
+
82
+ Before generating any file paths, canonicalize ALL entity names from `entities.json`:
83
+
84
+ 1. Load `references/entity-canonicalization.md` for complete rules
85
+ 2. For each entity in `entities.json > entities[]`:
86
+ - If entity has `codeIdentifier` or `englishName` → use it directly
87
+ - 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
88
+ 3. Use the CANONICALIZED name in ALL file path templates (`{EntityName}`, `{ServiceName}`, `{DtoName}`, etc.)
89
+ 4. Store the mapping `{ originalName: "Type d'absence", canonicalName: "TypeAbsence" }` in handoff metadata for traceability
90
+
91
+ **Example:** Entity `"Type d'absence"` → canonicalized to `"TypeAbsence"` → path `src/Domain/Entities/App/Module/TypeAbsence.cs`
92
+
93
+ **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.
94
+
95
+ ### 7. Build Handoff Data (8 Categories)
96
+
97
+ Load `references/handoff-file-templates.md` for complete JSON templates.
98
+
99
+ All backend paths MUST include `{ApplicationName}/` hierarchy.
100
+
101
+ | Category | Source | Key rules |
102
+ |----------|--------|-----------|
103
+ | **Domain** | `entities[]` | Entities, ValueObjects, Enums |
104
+ | **Application** | `useCases[]` | Services, DTOs, Validators |
105
+ | **Infrastructure** | `entities[]` | EF Configurations, DbSet |
106
+ | **API** | Generated from useCases + entities | Controllers |
107
+ | **Frontend** | `screens[]` | Pages, Components, Hooks; split by file (NOT monolithic) |
108
+ | **SeedData** | entities + permissions | CORE + business (include category field) |
109
+ | **Tests** | All layers | Unit, Integration, Security |
110
+ | **Documentation** | All layers | Technical docs (can be empty `[]`) |
111
+
112
+ **Frontend specifics:** Each page as separate entry, FK fields, ALL pages use `/ui-components`.
113
+
114
+ **Routes specifics:** PascalCase module codes → kebab-case (NEVER include `/business/` prefix).
115
+
116
+ ### 8. Map Business Rules to Code
117
+
118
+ Load `references/handoff-mappings.md` for mapping rules.
119
+
120
+ For each rule: `ruleId`, `title`, `module`, `severity`, `implementationPoints[]`.
121
+
122
+ ### 9. Handle personRoleConfig
123
+
124
+ If any entity has `personRoleConfig`, copy it verbatim into handoff.
125
+
126
+ ### 10. Generate Seed Data
127
+
128
+ Load `references/handoff-seeddata-generation.md` for core seed generation.
129
+
130
+ - `category: "core"` → Navigation, Permissions, Roles
131
+ - `category: "business"` → Domain-specific data
132
+
133
+ ### 11. Map Entity to Domain
134
+
135
+ Load `references/entity-domain-mapping.md` for mapping rules.
136
+
137
+ - Entity → `src/Domain/Entities/{App}/{Module}/{EntityName}.cs`
138
+ - ValueObject → `src/Domain/{Module}/ValueObjects/{VOName}.cs`
139
+ - Enum → `src/Domain/{Module}/Enums/{EnumName}.cs`
140
+
141
+ ### 12. Declare Dependencies per File Entry
142
+
143
+ | Layer | Dependencies |
144
+ |-------|-------------|
145
+ | domain | `[]` |
146
+ | infrastructure | `["domain"]` |
147
+ | application | `["domain"]` |
148
+ | api | `["application"]` |
149
+ | seedData | `["domain", "infrastructure"]` |
150
+ | frontend | `["api"]` |
151
+ | tests | `["domain", "application", "infrastructure", "api"]` |
152
+ | documentation | `[]` |
153
+
154
+ ### 13. Write Result
155
+
156
+ Write via `ba-writer.enrichModuleHandoff` with the complete handoff payload:
157
+ - `complexity`, `filesToCreate` (8 categories), `brToCodeMapping`, `apiEndpointSummary`
158
+ - `prdFile`: `".ralph/prd-{moduleCode}.json"`
159
+ - `totalFiles`, `totalTasks`, `handedOffAt` (ISO timestamp)
160
+ - `featureDescription`: `{featureDescription}`
161
+
162
+ ### 14. Write Specification Files (MANDATORY)
163
+
164
+ After writing the handoff data, ALSO write 5 companion files:
165
+
166
+ 1. `.ralph/prd-{moduleCode}.entities.json` = VERBATIM copy of `{moduleDir}/entities.json`
167
+ 2. `.ralph/prd-{moduleCode}.rules.json` = VERBATIM copy of `{moduleDir}/rules.json`
168
+ 3. `.ralph/prd-{moduleCode}.usecases.json` = VERBATIM copy of `{moduleDir}/usecases.json`
169
+ 4. `.ralph/prd-{moduleCode}.screens.json` = VERBATIM copy of `{moduleDir}/screens.json`
170
+ 5. `.ralph/prd-{moduleCode}.permissions.json` = VERBATIM copy of `{moduleDir}/permissions.json`
171
+
172
+ Add `specificationFiles` to the PRD referencing these files (relative names, all in `.ralph/`):
173
+
174
+ ```json
175
+ "specificationFiles": {
176
+ "entities": "prd-{moduleCode}.entities.json",
177
+ "rules": "prd-{moduleCode}.rules.json",
178
+ "usecases": "prd-{moduleCode}.usecases.json",
179
+ "screens": "prd-{moduleCode}.screens.json",
180
+ "permissions": "prd-{moduleCode}.permissions.json"
181
+ }
182
+ ```
183
+
184
+ ### 15. POST-CHECK (BLOCKING)
185
+
186
+ After writing, verify:
187
+
188
+ 1. Handoff not empty
189
+ 2. All 8 categories present
190
+ 3. `brToCodeMapping` non-empty
191
+ 4. Section resources have `entity` field
192
+ 5. `SeedData` contains CORE entries: NavigationModuleSeedData, NavigationSectionSeedData (if sections exist), PermissionsSeedData, RolesSeedData
193
+ 6. For FIRST module only: `SeedData` contains APP-LEVEL CORE entries (NavigationApplicationSeedData, ApplicationRolesSeedData)
194
+ 7. All 5 companion files exist in `.ralph/` and are non-empty
195
+ 8. `specificationFiles` present in the PRD with all 5 paths
196
+ 9. Entity count in companion matches source: `prd-{moduleCode}.entities.json` `entities[]` count = `{moduleDir}/entities.json` `entities[]` count
197
+ 10. BR count in companion matches source: `prd-{moduleCode}.rules.json` `rules[]` count = `{moduleDir}/rules.json` `rules[]` count
198
+ 11. Each `brToCodeMapping[].statement` is non-empty (not just a title paraphrase)
199
+
200
+ Display: `"POST-CHECK PASS: {moduleCode} -- 8 categories, {brCount} BRs mapped, {coreCount} core seeds, 5 companion files"`
201
+
202
+ ## RETURN VALUE
203
+
204
+ Return a single JSON line:
205
+
206
+ ```json
207
+ { "moduleCode": "{moduleCode}", "filesCreated": 7, "errors": [], "complexity": "simple|medium|complex" }
208
+ ```
@@ -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.