@atlashub/smartstack-cli 4.74.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 (93) 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/skills/apex/_shared.md +1 -1
  9. package/templates/skills/apex/references/checks/backend-checks.sh +21 -7
  10. package/templates/skills/apex/references/checks/infrastructure-checks.sh +47 -10
  11. package/templates/skills/apex/references/frontend-route-wiring-app-tsx.md +3 -0
  12. package/templates/skills/apex/references/post-checks.md +5 -2
  13. package/templates/skills/apex/references/smartstack-frontend.md +53 -7
  14. package/templates/skills/apex/steps/step-00-init.md +74 -0
  15. package/templates/skills/apex/steps/step-03-execute.md +16 -4
  16. package/templates/skills/apex/steps/step-03b-layer1-seed.md +39 -6
  17. package/templates/skills/apex/steps/step-03c-layer2-backend.md +50 -5
  18. package/templates/skills/apex/steps/step-03d-layer3-frontend.md +102 -2
  19. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +3 -0
  20. package/templates/skills/business-analyse/SKILL.md +14 -0
  21. package/templates/skills/business-analyse/_shared.md +27 -0
  22. package/templates/skills/business-analyse/patterns/suggestion-catalog.md +34 -26
  23. package/templates/skills/business-analyse/questionnaire/01-context.md +13 -9
  24. package/templates/skills/business-analyse/questionnaire/02-stakeholders-scope.md +20 -27
  25. package/templates/skills/business-analyse/questionnaire.md +86 -9
  26. package/templates/skills/business-analyse/references/03-json-schemas.md +213 -0
  27. package/templates/skills/business-analyse/references/03-post-check-validation.md +144 -0
  28. package/templates/skills/business-analyse/references/03-smartstack-entity-guards.md +32 -0
  29. package/templates/skills/business-analyse/references/04-cross-module-validation.md +95 -0
  30. package/templates/skills/business-analyse/references/04-file-allocation.md +162 -0
  31. package/templates/skills/business-analyse/references/04-naming-audit-checks.md +174 -0
  32. package/templates/skills/business-analyse/references/04-semantic-validation-matrix.md +118 -0
  33. package/templates/skills/business-analyse/references/domain-research-playbook.md +234 -0
  34. package/templates/skills/business-analyse/references/entity-sourcing-presentation.md +166 -0
  35. package/templates/skills/business-analyse/references/init-resume-logic.md +70 -0
  36. package/templates/skills/business-analyse/references/module-completeness-challenge.md +174 -0
  37. package/templates/skills/business-analyse/references/multi-app-detection.md +149 -0
  38. package/templates/skills/business-analyse/references/portal-classification.md +52 -0
  39. package/templates/skills/business-analyse/references/validation-checklist.md +30 -1
  40. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +37 -4
  41. package/templates/skills/business-analyse/steps/step-00-init.md +22 -190
  42. package/templates/skills/business-analyse/steps/step-01-cadrage.md +365 -269
  43. package/templates/skills/business-analyse/steps/step-02-structure.md +98 -20
  44. package/templates/skills/business-analyse/steps/step-03-specify.md +652 -229
  45. package/templates/skills/business-analyse/steps/step-04-consolidate.md +308 -287
  46. package/templates/skills/business-analyse-design/SKILL.md +10 -0
  47. package/templates/skills/business-analyse-design/references/screens-post-check.md +221 -0
  48. package/templates/skills/business-analyse-design/references/screens-type-mapping.md +138 -0
  49. package/templates/skills/business-analyse-design/references/smartcomponents-templates.md +225 -0
  50. package/templates/skills/{business-analyse → business-analyse-design}/references/spec-auto-inference.md +117 -117
  51. package/templates/skills/business-analyse-design/steps/step-01-screens.md +36 -162
  52. package/templates/skills/business-analyse-design/steps/step-02-wireframes.md +8 -7
  53. package/templates/skills/business-analyse-design/steps/step-03-navigation.md +89 -42
  54. package/templates/skills/business-analyse-develop/references/compact-loop.md +9 -0
  55. package/templates/skills/business-analyse-develop/references/handoff-quality-gate.md +132 -0
  56. package/templates/skills/business-analyse-develop/references/prd-v3-transformation.md +326 -0
  57. package/templates/skills/business-analyse-develop/references/report-reconciliation.md +140 -0
  58. package/templates/skills/business-analyse-develop/references/report-template.md +142 -0
  59. package/templates/skills/business-analyse-develop/steps/step-01-task.md +5 -177
  60. package/templates/skills/business-analyse-develop/steps/step-02-execute.md +17 -4
  61. package/templates/skills/business-analyse-develop/steps/step-03-commit.md +6 -2
  62. package/templates/skills/business-analyse-develop/steps/step-04-check.md +6 -0
  63. package/templates/skills/business-analyse-develop/steps/step-05-report.md +3 -269
  64. package/templates/skills/business-analyse-handoff/SKILL.md +10 -0
  65. package/templates/skills/business-analyse-handoff/references/agent-handoff-transform-prompt.md +208 -0
  66. package/templates/skills/business-analyse-handoff/references/context-isolation-pattern.md +47 -0
  67. package/templates/skills/business-analyse-handoff/references/handoff-file-inventory.md +49 -0
  68. package/templates/skills/business-analyse-handoff/references/handoff-global-validation.md +142 -0
  69. package/templates/skills/business-analyse-handoff/references/prd-validation-checks.md +125 -0
  70. package/templates/skills/business-analyse-handoff/references/project-index-update.md +98 -0
  71. package/templates/skills/business-analyse-handoff/steps/step-01-transform.md +9 -160
  72. package/templates/skills/business-analyse-handoff/steps/step-02-export.md +10 -99
  73. package/templates/skills/business-analyse-html/SKILL.md +10 -0
  74. package/templates/skills/business-analyse-html/html/ba-interactive.html +306 -81
  75. package/templates/skills/business-analyse-html/html/src/scripts/01-data-init.js +15 -2
  76. package/templates/skills/business-analyse-html/html/src/scripts/02-navigation.js +6 -46
  77. package/templates/skills/business-analyse-html/html/src/scripts/06-render-mockups.js +88 -33
  78. package/templates/skills/business-analyse-html/html/src/scripts/12-render-diagrams.js +116 -0
  79. package/templates/skills/business-analyse-html/html/src/styles/10-diagrams.css +73 -0
  80. package/templates/skills/business-analyse-html/html/src/template.html +2 -0
  81. package/templates/skills/business-analyse-html/references/02-embedded-artifacts-building.md +144 -0
  82. package/templates/skills/business-analyse-html/references/02-feature-data-building.md +141 -0
  83. package/templates/skills/business-analyse-html/references/02-mapping-tables.md +442 -0
  84. package/templates/skills/business-analyse-html/references/02-normalization-helpers.md +139 -0
  85. package/templates/skills/business-analyse-html/references/02-screen-format-detection.md +283 -0
  86. package/templates/skills/business-analyse-html/references/02-self-check-validation.md +199 -0
  87. package/templates/skills/business-analyse-html/references/data-build.md +22 -1
  88. package/templates/skills/business-analyse-html/references/data-mapping.md +40 -5
  89. package/templates/skills/business-analyse-html/steps/step-02-build-data.md +12 -555
  90. package/templates/skills/business-analyse-review/SKILL.md +10 -0
  91. package/templates/skills/business-analyse-status/SKILL.md +8 -0
  92. package/templates/skills/dev-start/SKILL.md +143 -307
  93. package/templates/skills/efcore/SKILL.md +13 -0
@@ -0,0 +1,142 @@
1
+ # Handoff Global Validation
2
+
3
+ ## Overview
4
+
5
+ POST-CHECK GLOBAL validation (BLOCKING — ba-009 fix). Verifies overall handoff integrity across all modules, not just individual PRDs.
6
+
7
+ Blocks completion if expected files are missing.
8
+
9
+ ## Module-Level Integrity Checks
10
+
11
+ For each module:
12
+
13
+ ### handoff.json Presence (CRITICAL)
14
+
15
+ Check that handoff.json exists in module's docs directory.
16
+
17
+ This file was missing for 3/12 modules in ba-009 and is critical for handoff integrity.
18
+
19
+ ```javascript
20
+ if (!EXISTS(moduleDir + '/handoff.json'))
21
+ errors.push('MISSING: ' + moduleDir + '/handoff.json');
22
+ ```
23
+
24
+ ### PRD Master File
25
+
26
+ Check that main PRD file exists in .ralph/ directory.
27
+
28
+ ```javascript
29
+ if (!EXISTS('.ralph/prd-' + mod.code + '.json'))
30
+ errors.push('MISSING: .ralph/prd-' + mod.code + '.json');
31
+ ```
32
+
33
+ ### Companion Files
34
+
35
+ Check that all 5 companion specification files exist in .ralph/:
36
+ - entities
37
+ - rules
38
+ - usecases
39
+ - screens
40
+ - permissions
41
+
42
+ ```javascript
43
+ ['entities', 'rules', 'usecases', 'screens', 'permissions'].forEach(suffix => {
44
+ const path = '.ralph/prd-' + mod.code + '.' + suffix + '.json';
45
+ if (!EXISTS(path)) errors.push('MISSING: ' + path);
46
+ });
47
+ ```
48
+
49
+ ## Global File Checks
50
+
51
+ ### Multi-Module Queue
52
+
53
+ If processing 2+ modules, check that modules-queue.json exists.
54
+
55
+ ```javascript
56
+ if (modules.length >= 2 && !EXISTS('.ralph/modules-queue.json'))
57
+ errors.push('MISSING: .ralph/modules-queue.json');
58
+ ```
59
+
60
+ ### Progress Tracker
61
+
62
+ Check that progress.txt exists.
63
+
64
+ ```javascript
65
+ if (!EXISTS('.ralph/progress.txt'))
66
+ errors.push('MISSING: .ralph/progress.txt');
67
+ ```
68
+
69
+ ## Surplus File Detection
70
+
71
+ Check for unexpected files in .ralph/ that aren't part of the template.
72
+
73
+ ### Expected Files Set
74
+
75
+ Build set of all expected files:
76
+ - PRD masters: `prd-{moduleCode}.json` for each module
77
+ - Companion files: `prd-{moduleCode}.{suffix}.json` for each module and suffix
78
+ - Global files: `modules-queue.json`, `progress.txt`
79
+
80
+ ```javascript
81
+ const expectedFiles = new Set();
82
+ modules.forEach(m => {
83
+ expectedFiles.add('prd-' + m.code + '.json');
84
+ ['entities','rules','usecases','screens','permissions'].forEach(s =>
85
+ expectedFiles.add('prd-' + m.code + '.' + s + '.json'));
86
+ });
87
+ expectedFiles.add('modules-queue.json');
88
+ expectedFiles.add('progress.txt');
89
+ ```
90
+
91
+ ### Actual Files in .ralph/
92
+
93
+ Scan .ralph/ directory for all files (excluding logs/).
94
+
95
+ Flag any file not in expected set as surplus with warning message.
96
+
97
+ ```javascript
98
+ const actualFiles = GLOB('.ralph/*').filter(f => !f.includes('/logs/'));
99
+ actualFiles.forEach(f => {
100
+ const basename = f.split('/').pop();
101
+ if (!expectedFiles.has(basename))
102
+ warnings.push('SURPLUS: ' + f + ' — fichier non prevu par le template');
103
+ });
104
+ ```
105
+
106
+ ## Result Handling
107
+
108
+ ### Blocking Errors
109
+
110
+ If errors exist, display all errors and block completion.
111
+
112
+ ```javascript
113
+ if (errors.length > 0) {
114
+ Display('POST-CHECK GLOBAL FAILED (' + errors.length + ' errors):');
115
+ errors.forEach(e => Display(' X ' + e));
116
+ BLOCKING_ERROR('Fix all missing files before completing. See FICHIERS A CREER in step-01.');
117
+ }
118
+ ```
119
+
120
+ ### Warnings
121
+
122
+ Display any surplus files found (non-blocking).
123
+
124
+ ```javascript
125
+ if (warnings.length > 0) {
126
+ Display('POST-CHECK warnings (' + warnings.length + ' surplus files):');
127
+ warnings.forEach(w => Display(' ! ' + w));
128
+ }
129
+ ```
130
+
131
+ ### Success Message
132
+
133
+ Display final validation pass message with module count and expected file count.
134
+
135
+ ```javascript
136
+ Display('POST-CHECK GLOBAL PASS: ' + modules.length + ' modules, ' +
137
+ (modules.length * 7 + 2) + ' fichiers attendus');
138
+ ```
139
+
140
+ Formula: `modules.length * 7 + 2`
141
+ - Each module: 1 PRD master + 5 companions + 1 handoff.json = 7 files
142
+ - Global: modules-queue.json (if multi-module) + progress.txt = 2 files
@@ -0,0 +1,125 @@
1
+ # PRD Validation Checks
2
+
3
+ ## Overview
4
+
5
+ POST-CHECK PRD validation rules (BLOCKING). All checks must pass before proceeding to development.
6
+
7
+ ## Check 1: Version
8
+
9
+ PRD $version must be 3.0.0 or 4.0.0.
10
+
11
+ ```javascript
12
+ if (prd.$version !== "3.0.0" && prd.$version !== "4.0.0") {
13
+ BLOCKING_ERROR("PRD version must be 3.0.0 or 4.0.0, got: " + prd.$version);
14
+ }
15
+ ```
16
+
17
+ ## Check 2: File Manifest Location
18
+
19
+ PRD must contain file manifest in correct location:
20
+ - v3: `implementation.filesToCreate`
21
+ - v4: `expectedFiles`
22
+
23
+ ```javascript
24
+ const ftc = prd.$version === "4.0.0" ? prd.expectedFiles : prd.implementation?.filesToCreate;
25
+ if (!ftc) {
26
+ BLOCKING_ERROR("prd.json missing file manifest (v3: implementation.filesToCreate, v4: expectedFiles)");
27
+ STOP;
28
+ }
29
+ ```
30
+
31
+ ## Check 3: All 8 Categories Present
32
+
33
+ File manifest must contain all 8 categories:
34
+ - domain
35
+ - application
36
+ - infrastructure
37
+ - api
38
+ - frontend
39
+ - seedData
40
+ - tests
41
+ - documentation
42
+
43
+ ```javascript
44
+ const categories = ['domain', 'application', 'infrastructure', 'api', 'frontend', 'seedData', 'tests', 'documentation'];
45
+ const missingCategories = categories.filter(cat => !ftc[cat]);
46
+ if (missingCategories.length > 0) {
47
+ BLOCKING_ERROR("Missing categories: " + missingCategories.join(', '));
48
+ }
49
+ ```
50
+
51
+ ## Check 4: File Counts Match
52
+
53
+ File count for each category must match between PRD and feature handoff.
54
+
55
+ ```javascript
56
+ for (const cat of categories) {
57
+ const prdCount = ftc[cat]?.length ?? 0;
58
+ const featureCount = featureHandoff[cat]?.length ?? 0;
59
+ if (prdCount !== featureCount) {
60
+ BLOCKING_ERROR(`${cat}: prd=${prdCount} but feature=${featureCount}`);
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## Check 5: Specification Files (Companion Files)
66
+
67
+ PRD must contain all 5 companion file definitions:
68
+ - entities
69
+ - rules
70
+ - usecases
71
+ - screens
72
+ - permissions
73
+
74
+ Each companion file must exist and be non-empty (>10 bytes).
75
+
76
+ ```javascript
77
+ const specFiles = prd.specificationFiles;
78
+ if (!specFiles) {
79
+ BLOCKING_ERROR("specificationFiles missing from PRD");
80
+ }
81
+ const specKeys = ['entities', 'rules', 'usecases', 'screens', 'permissions'];
82
+ for (const key of specKeys) {
83
+ if (!specFiles[key]) {
84
+ BLOCKING_ERROR(`specificationFiles.${key} path missing`);
85
+ }
86
+ const companionPath = `.ralph/${specFiles[key]}`;
87
+ if (!fileExists(companionPath)) {
88
+ BLOCKING_ERROR(`Companion file not found: ${companionPath}`);
89
+ }
90
+ const companionSize = fileSize(companionPath);
91
+ if (companionSize < 10) {
92
+ BLOCKING_ERROR(`Companion file empty or too small: ${companionPath} (${companionSize} bytes)`);
93
+ }
94
+ }
95
+ ```
96
+
97
+ ## Check 6: C# Identifier Validity
98
+
99
+ File paths must be valid C# identifiers (no spaces, apostrophes, accents).
100
+
101
+ Error message pattern:
102
+ ```
103
+ File path contains illegal characters for C# identifier: "{filePath}"
104
+ — entity name must be canonicalized (see references/entity-canonicalization.md)
105
+ ```
106
+
107
+ Implementation:
108
+
109
+ ```javascript
110
+ for (const [cat, files] of Object.entries(ftc)) {
111
+ for (const file of (files || [])) {
112
+ const filePath = file.path || file;
113
+ // Extract filename without extension
114
+ const fileName = filePath.split('/').pop().replace(/\.(cs|tsx|ts|json)$/, '');
115
+ // Check for illegal characters in C# file names
116
+ if (/[\s'àâäéèêëïîôùûüçÀÂÄÉÈÊËÏÎÔÙÛÜÇ]/.test(fileName)) {
117
+ BLOCKING_ERROR(`${cat}: File path contains illegal characters for C# identifier: "${filePath}" — entity name must be canonicalized (see references/entity-canonicalization.md)`);
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ## Display Output
124
+
125
+ Display verification table showing all 8 categories match between module JSON files and prd.json.
@@ -0,0 +1,98 @@
1
+ # Project Index Update
2
+
3
+ ## Overview
4
+
5
+ Updates the project index with handoff status tracking after PRD generation.
6
+
7
+ Two-tier approach:
8
+ - **Primary (ba-006):** Project-level index in `{docs_dir}/index.json` (autonomous per project)
9
+ - **Legacy (pre-ba-006):** Global manifest in `docs/index.json` for backward compatibility
10
+
11
+ ## Primary Flow: Update Project-Level Index
12
+
13
+ For each processed module, update the project's own `{docs_dir}/index.json` manifest.
14
+
15
+ ### Update Logic
16
+
17
+ 1. Read `{docs_dir}/index.json` (project master index)
18
+ 2. Update status to `"handed-off"` for each processed module
19
+ 3. Update `metadata.lastModified` timestamp
20
+ 4. Write back to `{docs_dir}/index.json`
21
+ 5. Display confirmation: "Project index updated: {docs_dir}/index.json (status: handed-off)"
22
+
23
+ ## Legacy Flow: Update Global Manifest (if exists)
24
+
25
+ For backward compatibility with pre-ba-006 projects, if `docs/index.json` global manifest exists, also update it.
26
+
27
+ ### Structure
28
+
29
+ ```json
30
+ {
31
+ "version": "1.0",
32
+ "updatedAt": "{ISO timestamp}",
33
+ "analyses": [
34
+ {
35
+ "appCode": "{app_code}",
36
+ "appName": "{application_name}",
37
+ "moduleCode": null | "{module_code}",
38
+ "moduleName": "{module_name}",
39
+ "version": "{version}",
40
+ "status": "handed-off",
41
+ "featureDescription": "{description}",
42
+ "path": "{projectSlug}/v{version}/index.json",
43
+ "updatedAt": "{ISO timestamp}"
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ### Fields
50
+
51
+ | Field | Notes |
52
+ |-------|-------|
53
+ | `appCode` | Application identifier |
54
+ | `appName` | Human-readable application name |
55
+ | `moduleCode` | Module identifier (null if global module) |
56
+ | `moduleName` | Module name |
57
+ | `version` | Feature/module version |
58
+ | `status` | Always "handed-off" after update |
59
+ | `featureDescription` | Module description from BA |
60
+ | `path` | Reference path (format: `{projectSlug}/v{version}/index.json`) |
61
+ | `updatedAt` | ISO timestamp of last update |
62
+
63
+ ### Update Steps
64
+
65
+ 1. Read existing `docs/index.json` if present
66
+ 2. For each module, add or update entry in `analyses` array
67
+ 3. Set `status: "handed-off"`
68
+ 4. Update global `updatedAt` timestamp
69
+ 5. Write back to `docs/index.json`
70
+ 6. Display confirmation: "Legacy index updated: docs/index.json"
71
+
72
+ ## Execution Order
73
+
74
+ ```
75
+ 1. Update {docs_dir}/index.json (primary)
76
+ └─ Always execute for ba-006+
77
+
78
+ 2. IF docs/index.json exists
79
+ └─ Update with legacy structure (backward compat)
80
+ ```
81
+
82
+ ## Display Messages
83
+
84
+ ### Primary Update
85
+ ```
86
+ Project index updated: {docs_dir}/index.json (status: handed-off)
87
+ ```
88
+
89
+ ### Legacy Update (if applicable)
90
+ ```
91
+ Legacy index updated: docs/index.json ({count} modules)
92
+ ```
93
+
94
+ ## Key Notes
95
+
96
+ - **ba-006 Standard:** Projects are autonomous — no global manifest required
97
+ - **Backward Compatibility:** Legacy projects using global `docs/index.json` continue to work
98
+ - **No Global Dependency:** CLI does not maintain a global registry; each project is self-contained
@@ -21,6 +21,12 @@ next_step: steps/step-02-export.md
21
21
  - **ALWAYS** generate API endpoints from use cases + entities (BA does not produce apiEndpoints)
22
22
  - **ALWAYS** canonicalize entity names before generating file paths — see `references/entity-canonicalization.md`
23
23
 
24
+ ## FICHIERS A CREER — LISTE FERMEE (ba-009 fix)
25
+
26
+ > **Load** `references/handoff-file-inventory.md` for exhaustive file list, naming regex, and forbidden variants.
27
+
28
+ ---
29
+
24
30
  ## YOUR TASK
25
31
 
26
32
  Orchestrate the transform: determine module order, then delegate each module's transform to an Agent with isolated context. This prevents context accumulation across modules.
@@ -29,16 +35,7 @@ Orchestrate the transform: determine module order, then delegate each module's t
29
35
 
30
36
  ## CONTEXT ISOLATION ARCHITECTURE
31
37
 
32
- ```
33
- Main conversation (orchestrator):
34
- ├─ Determine topological order
35
- ├─ FOR each module:
36
- │ └─ Agent(ba-writer) ──► reads 5 files, builds handoff, writes result
37
- │ (isolated context: ~500-1000 lines per module)
38
- └─ Collect results, display summary
39
- ```
40
-
41
- **WHY:** 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.
38
+ > **Load** `references/context-isolation-pattern.md` for the orchestration pattern, agent delegation flow, and context budget rules.
42
39
 
43
40
  ---
44
41
 
@@ -57,157 +54,9 @@ Module processing order:
57
54
 
58
55
  ### 2. Process Each Module via Agent
59
56
 
60
- For **EACH module** in topological order, use the **Agent tool** (subagent_type: `ba-writer`) with the following prompt structure:
57
+ For **EACH module** in topological order, use the **Agent tool** (subagent_type: `ba-writer`) with:
61
58
 
62
- ```
63
- Transform module "{moduleCode}" for handoff.
64
-
65
- ## Input
66
- - Module BA directory: {moduleDir} // ba-006: {docs_dir}/{appKebab}/{moduleKebab}/
67
- - Application code: {appCode}
68
- - Application name: {appName}
69
- - Feature description: {featureDescription}
70
- - Module index: {moduleDir}/index.json
71
-
72
- ## Instructions
73
- Read the following 5 files from {moduleDir} (ba-006: docs/{projectSlug}/v{X.Y}/{appKebab}/{moduleKebab}/):
74
- 1. entities.json → entities[]
75
- 2. usecases.json → useCases[] (canonical key: "useCases", fallback: "usecases")
76
- 3. rules.json → rules[] (canonical key: "rules", fallback: "businessRules")
77
- 4. permissions.json → roles[], matrix[], permissionPaths[]
78
- 5. screens.json → sections[] (canonical key: "sections", fallback: "screens")
79
-
80
- ### Normalization Safety Net (BACKWARD COMPAT)
81
- When reading flat files, prefer canonical keys but fall back to alternatives:
82
- - useCases: `data.useCases || data.usecases || []`
83
- - primaryActor: `uc.primaryActor || uc.actor`
84
- - mainScenario: `uc.mainScenario || uc.steps` (if steps[] contains objects, extract `.action`)
85
- - rules: `data.rules || data.businessRules || []`
86
- - screens: `data.sections || data.screens` (if screens[] exists, treat each screen as a section with 1 resource)
87
- This safety net handles pre-4.52 BA outputs. It should become unnecessary once step-03-specify enforces canonical keys.
88
-
89
- Then build the handoff data following these rules:
90
-
91
- ### Complexity
92
- | Criteria | Simple | Medium | Complex |
93
- |----------|--------|--------|---------|
94
- | Entities | <=3 | <=6 | >6 |
95
- | Use Cases | <=5 | <=12 | >12 |
96
- | Business Rules | <=10 | <=20 | >20 |
97
-
98
- ### API Endpoints (generate from use cases)
99
- - UC "Create X" → POST /api/{app}/{module}
100
- - UC "List X" → GET /api/{app}/{module}
101
- - UC "Update X" → PUT /api/{app}/{module}/{id}
102
- - UC "Delete X" → DELETE /api/{app}/{module}/{id}
103
- - UC "Get X" → GET /api/{app}/{module}/{id}
104
- - Use permission paths from permissions.json
105
-
106
- ### Section UC/BR Enrichment
107
- Using sectionCode from usecases.json and rules.json, link each UC and BR to its section.
108
-
109
- ### Entity Name Canonicalization (MANDATORY)
110
- Before generating any file paths, canonicalize ALL entity names from `entities.json`:
111
- 1. Read `references/entity-canonicalization.md` for complete rules
112
- 2. For each entity in `entities.json > entities[]`:
113
- - If entity has `codeIdentifier` or `englishName` → use it directly
114
- - 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
115
- 3. Use the CANONICALIZED name in ALL file path templates (`{EntityName}`, `{ServiceName}`, `{DtoName}`, etc.)
116
- 4. Store the mapping `{ originalName: "Type d'absence", canonicalName: "TypeAbsence" }` in handoff metadata for traceability
117
-
118
- **Example:** Entity `"Type d'absence"` → canonicalized to `"TypeAbsence"` → path `src/Domain/Entities/App/Module/TypeAbsence.cs`
119
-
120
- **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.
121
-
122
- ### File Mapping (8 Categories)
123
- Read `references/handoff-file-templates.md` for complete JSON templates.
124
- All backend paths MUST include {ApplicationName}/ hierarchy.
125
-
126
- | Category | Source | Key rules |
127
- |----------|--------|-----------|
128
- | **Domain** | entities[] | Entities, ValueObjects, Enums |
129
- | **Application** | useCases[] | Services, DTOs, Validators |
130
- | **Infrastructure** | entities[] | EF Configurations, DbSet |
131
- | **API** | Generated from useCases + entities | Controllers |
132
- | **Frontend** | screens[] | Pages, Components, Hooks; split by file (NOT monolithic) |
133
- | **SeedData** | entities + permissions | CORE + business (include category field) |
134
- | **Tests** | All layers | Unit, Integration, Security |
135
- | **Documentation** | All layers | Technical docs (can be empty []) |
136
-
137
- Frontend: each page as separate entry, FK fields, ALL pages use /ui-components.
138
- Routes: PascalCase module codes → kebab-case (NEVER include /business/ prefix).
139
-
140
- ### BR-to-Code Mapping
141
- Read `references/handoff-mappings.md` for mapping rules.
142
- For each rule: ruleId, title, module, severity, implementationPoints[].
143
-
144
- ### personRoleConfig
145
- If entity has personRoleConfig, copy verbatim into handoff.
146
-
147
- ### SeedData
148
- Read `references/handoff-seeddata-generation.md` for core seed generation.
149
- - category: "core" → Navigation, Permissions, Roles
150
- - category: "business" → Domain-specific data
151
-
152
- ### Entity Domain Mapping
153
- Read `references/entity-domain-mapping.md` for mapping rules.
154
- - Entity → src/Domain/Entities/{App}/{Module}/{EntityName}.cs
155
- - ValueObject → src/Domain/{Module}/ValueObjects/{VOName}.cs
156
- - Enum → src/Domain/{Module}/Enums/{EnumName}.cs
157
-
158
- ### Dependencies per File Entry
159
- | Layer | Dependencies |
160
- |-------|-------------|
161
- | domain | [] |
162
- | infrastructure | ["domain"] |
163
- | application | ["domain"] |
164
- | api | ["application"] |
165
- | seedData | ["domain", "infrastructure"] |
166
- | frontend | ["api"] |
167
- | tests | ["domain", "application", "infrastructure", "api"] |
168
- | documentation | [] |
169
-
170
- ### Write Result
171
- Write via ba-writer.enrichModuleHandoff with the complete handoff payload:
172
- - complexity, filesToCreate (8 categories), brToCodeMapping, apiEndpointSummary
173
- - prdFile: ".ralph/prd-{moduleCode}.json"
174
- - totalFiles, totalTasks, handedOffAt (ISO timestamp)
175
- - featureDescription: {featureDescription}
176
-
177
- ### Specification Files (MANDATORY)
178
- After writing the handoff data, ALSO write 5 companion files:
179
- 1. `.ralph/prd-{moduleCode}.entities.json` = VERBATIM copy of `{moduleDir}/entities.json`
180
- 2. `.ralph/prd-{moduleCode}.rules.json` = VERBATIM copy of `{moduleDir}/rules.json`
181
- 3. `.ralph/prd-{moduleCode}.usecases.json` = VERBATIM copy of `{moduleDir}/usecases.json`
182
- 4. `.ralph/prd-{moduleCode}.screens.json` = VERBATIM copy of `{moduleDir}/screens.json`
183
- 5. `.ralph/prd-{moduleCode}.permissions.json` = VERBATIM copy of `{moduleDir}/permissions.json`
184
-
185
- Add `specificationFiles` to the PRD referencing these files (relative names, all in `.ralph/`):
186
- ```json
187
- "specificationFiles": {
188
- "entities": "prd-{moduleCode}.entities.json",
189
- "rules": "prd-{moduleCode}.rules.json",
190
- "usecases": "prd-{moduleCode}.usecases.json",
191
- "screens": "prd-{moduleCode}.screens.json",
192
- "permissions": "prd-{moduleCode}.permissions.json"
193
- }
194
- ```
195
-
196
- ### POST-CHECK (BLOCKING)
197
- After writing, verify:
198
- 1. Handoff not empty
199
- 2. All 8 categories present
200
- 3. brToCodeMapping non-empty
201
- 4. Section resources have entity field
202
- 5. SeedData contains CORE entries (NavigationModuleSeedData, NavigationSectionSeedData if sections exist, PermissionsSeedData, RolesSeedData)
203
- 6. For FIRST module only: SeedData contains APP-LEVEL CORE entries (NavigationApplicationSeedData, ApplicationRolesSeedData)
204
- 7. All 5 companion files exist in `.ralph/` and are non-empty
205
- 8. `specificationFiles` present in the PRD with all 5 paths
206
- 9. Entity count in companion matches source: `prd-{moduleCode}.entities.json` entities[] count = `{moduleDir}/entities.json` entities[] count
207
- 10. BR count in companion matches source: `prd-{moduleCode}.rules.json` rules[] count = `{moduleDir}/rules.json` rules[] count
208
- 11. Each `brToCodeMapping[].statement` is non-empty (not just a title paraphrase)
209
- Display: "POST-CHECK PASS: {moduleCode} -- 8 categories, {brCount} BRs mapped, {coreCount} core seeds, 5 companion files"
210
- ```
59
+ > → **Load** `references/agent-handoff-transform-prompt.md` as the complete agent prompt for each module transformation.
211
60
 
212
61
  ### 3. Display Progress
213
62
 
@@ -58,76 +58,9 @@ Generates `prd-{moduleCode}.json` with `$version: "4.0.0"` containing:
58
58
 
59
59
  ### 2. POST-CHECK PRD (BLOCKING)
60
60
 
61
- > **Reference:** See loaded context `prd-generation.md` for complete validation rules.
61
+ > **Reference:** See loaded context `prd-validation-checks.md` for complete validation rules (6 checks: version, file manifest, categories, counts, companions, C# identifiers).
62
62
 
63
- ```javascript
64
- const prd = readJSON(`.ralph/prd-${moduleCode}.json`);
65
- const featureHandoff = moduleFeature.handoff.filesToCreate;
66
-
67
- // Check 1: Version
68
- if (prd.$version !== "3.0.0" && prd.$version !== "4.0.0") {
69
- BLOCKING_ERROR("PRD version must be 3.0.0 or 4.0.0, got: " + prd.$version);
70
- }
71
-
72
- // Check 2: filesToCreate location (v3: implementation.filesToCreate, v4: expectedFiles)
73
- const ftc = prd.$version === "4.0.0" ? prd.expectedFiles : prd.implementation?.filesToCreate;
74
- if (!ftc) {
75
- BLOCKING_ERROR("prd.json missing file manifest (v3: implementation.filesToCreate, v4: expectedFiles)");
76
- STOP;
77
- }
78
-
79
- // Check 3: All 8 categories present
80
- const categories = ['domain', 'application', 'infrastructure', 'api', 'frontend', 'seedData', 'tests', 'documentation'];
81
- const missingCategories = categories.filter(cat => !ftc[cat]);
82
- if (missingCategories.length > 0) {
83
- BLOCKING_ERROR("Missing categories: " + missingCategories.join(', '));
84
- }
85
-
86
- // Check 4: File counts match
87
- for (const cat of categories) {
88
- const prdCount = ftc[cat]?.length ?? 0;
89
- const featureCount = featureHandoff[cat]?.length ?? 0;
90
- if (prdCount !== featureCount) {
91
- BLOCKING_ERROR(`${cat}: prd=${prdCount} but feature=${featureCount}`);
92
- }
93
- }
94
-
95
- // Check 5: Specification files (companion files)
96
- const specFiles = prd.specificationFiles;
97
- if (!specFiles) {
98
- BLOCKING_ERROR("specificationFiles missing from PRD");
99
- }
100
- const specKeys = ['entities', 'rules', 'usecases', 'screens', 'permissions'];
101
- for (const key of specKeys) {
102
- if (!specFiles[key]) {
103
- BLOCKING_ERROR(`specificationFiles.${key} path missing`);
104
- }
105
- const companionPath = `.ralph/${specFiles[key]}`;
106
- if (!fileExists(companionPath)) {
107
- BLOCKING_ERROR(`Companion file not found: ${companionPath}`);
108
- }
109
- const companionSize = fileSize(companionPath);
110
- if (companionSize < 10) {
111
- BLOCKING_ERROR(`Companion file empty or too small: ${companionPath} (${companionSize} bytes)`);
112
- }
113
- }
114
-
115
- // Check 6: File paths must be valid C# identifiers (no spaces, apostrophes, accents)
116
- // Reference: references/entity-canonicalization.md
117
- for (const [cat, files] of Object.entries(ftc)) {
118
- for (const file of (files || [])) {
119
- const filePath = file.path || file;
120
- // Extract filename without extension
121
- const fileName = filePath.split('/').pop().replace(/\.(cs|tsx|ts|json)$/, '');
122
- // Check for illegal characters in C# file names
123
- if (/[\s'àâäéèêëïîôùûüçÀÂÄÉÈÊËÏÎÔÙÛÜÇ]/.test(fileName)) {
124
- BLOCKING_ERROR(`${cat}: File path contains illegal characters for C# identifier: "${filePath}" — entity name must be canonicalized (see references/entity-canonicalization.md)`);
125
- }
126
- }
127
- }
128
- ```
129
-
130
- Display verification table showing all 8 categories match between module JSON files and prd.json.
63
+ Verify PRD structure against module handoff, display verification table showing all 8 categories match between module JSON files and prd.json.
131
64
 
132
65
  ### 3. Generate modules-queue.json (if 2+ modules)
133
66
 
@@ -170,37 +103,9 @@ Write to: `.ralph/progress.txt`
170
103
 
171
104
  ### 5. Update Project Index (status tracking)
172
105
 
173
- > **ba-006:** No global `docs/index.json` manifest. Projects are autonomous.
174
- > Update the project's own `{docs_dir}/index.json` with handoff status instead.
106
+ > **Reference:** See loaded context `project-index-update.md` for ba-006 primary flow and legacy pre-ba-006 fallback structure.
175
107
 
176
- **Update logic:**
177
-
178
- 1. Read `{docs_dir}/index.json` (project master index)
179
- 2. Update status to `"handed-off"` for each processed module
180
- 3. Update `metadata.lastModified` timestamp
181
- 4. Write back
182
- 5. Display: "Project index updated: {docs_dir}/index.json (status: handed-off)"
183
-
184
- **Legacy (pre-ba-006):** If `docs/index.json` global manifest exists, also update it for backward compatibility:
185
- ```json
186
- {
187
- "version": "1.0",
188
- "updatedAt": "{ISO timestamp}",
189
- "analyses": [
190
- {
191
- "appCode": "{app_code}",
192
- "appName": "{application_name}",
193
- "moduleCode": null | "{module_code}",
194
- "moduleName": "{module_name}",
195
- "version": "{version}",
196
- "status": "handed-off",
197
- "featureDescription": "{description}",
198
- "path": "{projectSlug}/v{version}/index.json",
199
- "updatedAt": "{ISO timestamp}"
200
- }
201
- ]
202
- }
203
- ```
108
+ Update the project's own `{docs_dir}/index.json` with handoff status. If legacy `docs/index.json` exists, update it for backward compatibility.
204
109
 
205
110
  ### 6. Display Completion Summary
206
111
 
@@ -256,3 +161,9 @@ Artifacts generated:
256
161
  9. Each companion file is non-empty (>10 bytes)
257
162
 
258
163
  **IF any check fails -> fix before completing.**
164
+
165
+ ## POST-CHECK GLOBAL (BLOCKING — ba-009 fix)
166
+
167
+ > **Reference:** See loaded context `handoff-global-validation.md` for module-level integrity, global file checks, surplus file detection, and result handling.
168
+
169
+ Verifies overall handoff integrity across all modules — blocks completion if expected files are missing.