@atlashub/smartstack-cli 3.1.0 → 3.3.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 (39) hide show
  1. package/.documentation/prd-json-v2.0.0.md +396 -0
  2. package/.documentation/testing-ba-e2e.md +462 -0
  3. package/dist/index.js +605 -25
  4. package/dist/index.js.map +1 -1
  5. package/package.json +6 -2
  6. package/templates/agents/ba-reader.md +1 -1
  7. package/templates/agents/ba-writer.md +8 -1
  8. package/templates/skills/business-analyse/SKILL.md +46 -31
  9. package/templates/skills/business-analyse/_architecture.md +123 -0
  10. package/templates/skills/business-analyse/_elicitation.md +206 -0
  11. package/templates/skills/business-analyse/_module-loop.md +56 -0
  12. package/templates/skills/business-analyse/_shared.md +75 -531
  13. package/templates/skills/business-analyse/_suggestions.md +34 -0
  14. package/templates/skills/business-analyse/html/ba-interactive.html +146 -57
  15. package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
  16. package/templates/skills/business-analyse/questionnaire.md +22 -17
  17. package/templates/skills/business-analyse/react/components.md +1 -1
  18. package/templates/skills/business-analyse/react/schema.md +1 -1
  19. package/templates/skills/business-analyse/references/html-data-mapping.md +294 -0
  20. package/templates/skills/business-analyse/schemas/feature-schema.json +1 -1
  21. package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +1 -1
  22. package/templates/skills/business-analyse/schemas/sections/handoff-schema.json +1 -1
  23. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +1 -1
  24. package/templates/skills/business-analyse/steps/step-00-init.md +85 -59
  25. package/templates/skills/business-analyse/steps/step-01-cadrage.md +2 -0
  26. package/templates/skills/business-analyse/steps/step-02-decomposition.md +5 -3
  27. package/templates/skills/business-analyse/steps/{step-03-specify.md → step-03a-specify.md} +16 -606
  28. package/templates/skills/business-analyse/steps/step-03b-compile.md +670 -0
  29. package/templates/skills/business-analyse/steps/step-04-consolidation.md +7 -5
  30. package/templates/skills/business-analyse/steps/step-05a-handoff.md +727 -0
  31. package/templates/skills/business-analyse/steps/step-05b-deploy.md +479 -0
  32. package/templates/skills/business-analyse/steps/step-06-extract.md +134 -4
  33. package/templates/skills/business-analyse/templates/tpl-frd.md +1 -1
  34. package/templates/skills/business-analyse/templates/tpl-launch-displays.md +161 -0
  35. package/templates/skills/business-analyse/templates/tpl-progress.md +171 -0
  36. package/templates/skills/ralph-loop/SKILL.md +138 -20
  37. package/templates/skills/ralph-loop/steps/step-01-task.md +75 -18
  38. package/templates/skills/ralph-loop/steps/step-04-check.md +72 -5
  39. package/templates/skills/business-analyse/steps/step-05-handoff.md +0 -1414
@@ -0,0 +1,161 @@
1
+ # Skill Launch Display Templates (templates/tpl-launch-displays.md)
2
+
3
+ > **Used by:** step-05b-deploy (section 5-bis: Execute User Choice)
4
+ > **Purpose:** User-facing display templates for development approach choices
5
+ > **Note:** No emojis - uses text markers per Claude Code conventions
6
+
7
+ ---
8
+
9
+ ## 1. Ralph Loop Launch Display
10
+
11
+ Display when user selects "Ralph Loop" development approach:
12
+
13
+ ```
14
+ [LAUNCH] Lancement de Ralph Loop - Développement itératif automatique
15
+
16
+ ╔══════════════════════════════════════════════════════════════╗
17
+ ║ CYCLE RALPH LOOP - Comment ça fonctionne ? ║
18
+ ╠══════════════════════════════════════════════════════════════╣
19
+ ║ ║
20
+ ║ Ralph Loop exécute un cycle itératif jusqu'à 100% tests: ║
21
+ ║ ║
22
+ ║ 1. ANALYSE --> Charger task suivante du prd.json ║
23
+ ║ 2. DÉVELOPPEMENT --> Générer le code demandé ║
24
+ ║ • Backend (Entities, Services, Controllers, Repos) ║
25
+ ║ • Tests unitaires (xUnit) + non-régression ║
26
+ ║ • Frontend (Pages, Components, Hooks) ║
27
+ ║ • Tests frontend (React Testing Library) ║
28
+ ║ • SeedData (Core RBAC + business data) ║
29
+ ║ • Documentation utilisateur (inline + tooltips) ║
30
+ ║ 3. VALIDATION --> Commit + MCP conventions check ║
31
+ ║ 4. TEST --> Exécuter dotnet test + npm test ║
32
+ ║ 5. CORRECTION --> Si échec, analyser et corriger ║
33
+ ║ 6. BOUCLE --> Répéter 4-5 jusqu'à 100% tests pass ║
34
+ ║ 7. NEXT TASK --> Passer à la task suivante (retour à 1) ║
35
+ ║ ║
36
+ ║ [TARGET] Objectif: ZÉRO ERREUR avant de passer à la task suivante║
37
+ ║ [STATS] Couverture: 95-100% (tests générés automatiquement) ║
38
+ ║ ║
39
+ ╚══════════════════════════════════════════════════════════════╝
40
+
41
+ Configuration du projet:
42
+ ┌────────────────────────────────────────────────────────────┐
43
+ │ Modules: {modules_list}
44
+ │ Stratégie: {implementation_strategy}
45
+ │ PRD: {prd_file_path}
46
+ │ Progress: .ralph/progress.txt
47
+ │ Ordre: {module_order}
48
+ │ └────────────────────────────────────────────────────────────┘
49
+
50
+ Modules à traiter (dans l'ordre):
51
+ {modules_numbered_list}
52
+
53
+ [DIR] Fichiers générés par le BA (inputs pour Ralph):
54
+ ├─ feature.json (master + modules) --> Spécification source
55
+ ├─ prd.json (ou prd-{module}.json) --> Task breakdown avec UC/FR/BR
56
+ ├─ progress.txt --> Tracker hiérarchique (module --> layer --> tasks)
57
+ └─ ba-interactive.html --> Revue client (mockups, wireframes)
58
+
59
+ [LOOP] Ralph Loop va maintenant:
60
+ 1. Détecter les prd-*.json par module (si multi-module)
61
+ 2. Créer modules-queue.json avec l'ordre de traitement
62
+ 3. Traiter module par module dans l'ordre topologique
63
+ 4. Pour chaque module: parcourir les tasks (domain --> seeddata --> application --> infrastructure --> api --> frontend --> i18n --> tests)
64
+ 5. Pour chaque task: générer code --> commit --> tests --> correction si échec --> re-test --> next task
65
+ 6. Passer au module suivant quand 100% tasks du module actuel = completed
66
+ 7. Générer rapport final avec métriques de couverture
67
+
68
+ ═══════════════════════════════════════════════════════════════
69
+
70
+ --> Transition vers Ralph Loop...
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 2. Feature Full Launch Display
76
+
77
+ Display when user selects "Feature Full" development approach:
78
+
79
+ ```
80
+ [LAUNCH] Lancement de Feature Full...
81
+
82
+ Configuration:
83
+ - Mode: Parallel generation
84
+ - Couverture: 70-80%
85
+ - Durée estimée: ~{estimated_hours} heures
86
+
87
+ ═══════════════════════════════════════════════════════════════
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 3. Manual Development Complete Display
93
+
94
+ Display when user selects "Terminer le BA" (end Business Analysis):
95
+
96
+ ```
97
+ [OK] Business Analysis terminée.
98
+
99
+ Les équipes peuvent commencer le développement manuel.
100
+ Tous les artefacts sont prêts pour l'implémentation.
101
+
102
+ [DIR] Fichiers générés:
103
+ - feature.json (master + modules) - Spécification complète
104
+ - .ralph/prd.json (ou prd-{module}.json) - Task breakdown
105
+ - .ralph/progress.txt - Tracker de progression
106
+ - ba-interactive.html - Document de revue client
107
+
108
+ [STATS] Métriques:
109
+ - Modules: {modules_count}
110
+ - Entités: {total_entities}
111
+ - Use cases: {total_use_cases}
112
+ - Business rules: {total_business_rules}
113
+ - Fichiers à créer: {total_files}
114
+
115
+ [TARGET] Prochaines étapes recommandées:
116
+ 1. Ouvrir ba-interactive.html dans le navigateur
117
+ 2. Partager avec les stakeholders pour validation finale
118
+ 3. Utiliser progress.txt comme guide de développement
119
+ 4. Implémenter module par module selon l'ordre topologique
120
+
121
+ [TIP] Pour lancer le développement assisté plus tard:
122
+ - Ralph Loop: /ralph-loop (détecte automatiquement .ralph/prd.json)
123
+ - Feature Full: /feature-full
124
+
125
+ ═══════════════════════════════════════════════════════════════
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 4. Error Handling Display
131
+
132
+ Display when skill launch fails:
133
+
134
+ ```
135
+ [!] Échec du lancement automatique de Ralph Loop
136
+
137
+ Veuillez lancer manuellement:
138
+ /ralph-loop
139
+
140
+ Si le problème persiste:
141
+ 1. Vérifier que la skill ralph-loop est installée
142
+ 2. Vérifier les permissions Claude Code
143
+ 3. Consulter les logs: .ralph/logs/
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Text Marker Legend
149
+
150
+ | Marker | Replaces | Usage |
151
+ |--------|----------|-------|
152
+ | `-->` | `➡️` or `→` | Directional flow, transitions |
153
+ | `[OK]` | `✅` | Success, completion |
154
+ | `[!]` | `⚠️` | Warning, caution |
155
+ | `[LAUNCH]` | `🚀` | Skill launch, startup |
156
+ | `[DIR]` | `📂` | Files, directories, structure |
157
+ | `[STATS]` | `📊` | Metrics, statistics, coverage |
158
+ | `[TIP]` | `💡` | Advice, suggestions |
159
+ | `[TARGET]` | `🎯` | Goals, objectives |
160
+ | `[LOOP]` | `🔄` | Iteration, cycles, processing |
161
+ | `1.`, `2.`, etc. | `1️⃣`, `2️⃣`, etc. | Numbered lists |
@@ -0,0 +1,171 @@
1
+ # Progress Tracker Template (templates/tpl-progress.md)
2
+
3
+ > **Used by:** step-05b-deploy (section 2: Initialize Progress Tracker)
4
+ > **Purpose:** Template structure for .ralph/progress.txt - populate with module-specific data
5
+
6
+ ## Template
7
+
8
+ ```
9
+ ═════════════════════════════════════════════════════════════════
10
+ SMARTSTACK RALPH LOOP - PROGRESS TRACKER
11
+ Project: {project_name} | Application: {app_name}
12
+ Modules: {count} ({moduleOrder.join(', ')})
13
+ Strategy: {implementation_strategy}
14
+ Created: {timestamp}
15
+ Status: HANDED-OFF
16
+ ═════════════════════════════════════════════════════════════════
17
+
18
+ {For each module in topological order:}
19
+ [MODULE: {module_name}] ({complexity})
20
+ Status: NOT STARTED
21
+ Dependencies: {list of module dependencies or "FOUNDATION"}
22
+
23
+ [DOMAIN] Entity & Value Object Definitions
24
+ □ Define {Entity1} entity with properties and validation
25
+ □ Define {Entity2} entity with relationships
26
+ □ Define {ValueObject1} value object
27
+ □ Define domain exceptions
28
+ □ Total: X tasks
29
+
30
+ [SEEDDATA-CORE] Core Configuration (MANDATORY)
31
+ □ NavigationModuleConfiguration - Module navigation structure
32
+ □ PermissionsConfiguration - RBAC permissions setup
33
+ □ RolesConfiguration - Predefined roles
34
+ □ TenantConfiguration - Test tenants
35
+ □ UserConfiguration - Test users
36
+ Total: 5 CORE tasks
37
+
38
+ [SEEDDATA] Business Reference Data
39
+ □ Seed {Entity1} reference data
40
+ □ Seed {Entity2} lookup values
41
+ □ Total: Y business seed tasks
42
+
43
+ [APPLICATION] Services & Business Logic
44
+ □ Create {ServiceName}Service for {UC1}
45
+ □ Create {DtoName}Dto for API contracts
46
+ □ Create {ValidatorName}Validator for input validation
47
+ □ Implement query handlers
48
+ Total: Z tasks
49
+
50
+ [INFRASTRUCTURE] Repositories & Persistence
51
+ □ Create {Entity1}Repository with CRUD + custom queries
52
+ □ Create {Entity2}Repository
53
+ □ Configure DbContext for module
54
+ □ Setup specifications for complex queries
55
+ □ Create IClientSeedDataProvider (client projects ONLY - injects core seeds at runtime)
56
+ □ Create DevDataSeeder + SeedConstants (if first module)
57
+ □ Total: A tasks
58
+
59
+ [API] REST Endpoints & Controllers
60
+ □ Create {ModuleNameController} GET endpoints (List, GetById)
61
+ □ Create {ModuleNameController} POST endpoint (Create)
62
+ □ Create {ModuleNameController} PUT endpoint (Update)
63
+ □ Create {ModuleNameController} DELETE endpoint (Delete)
64
+ □ Implement error handling and validation responses
65
+ Total: B tasks
66
+
67
+ [FRONTEND] UI Components & Pages (wireframe-driven)
68
+ □ Create {ModuleName}Page for listing [wireframe: {module}-list]
69
+ □ Create {ModuleName}DetailPage for viewing [wireframe: {module}-detail]
70
+ □ Create {ModuleName}Form component for creation/edit [wireframe: {module}-create]
71
+ □ Create custom hook use{ModuleName}
72
+ □ Implement pagination, filtering, sorting
73
+ □ Validate all pages match their wireframe layout
74
+ □ ⚠️ Routes MUST be INSIDE Layout wrapper (AdminLayout/BusinessLayout/UserLayout)
75
+ Total: C tasks
76
+
77
+ [I18N] Internationalization Keys
78
+ □ Define i18n keys for {Module} UI labels
79
+ □ Setup translations for locales: fr, en, it, de
80
+ Total: D keys
81
+
82
+ [TESTS] Unit & Integration Tests
83
+ □ Unit tests for {Entity} domain logic
84
+ □ Unit tests for {ServiceName}Service
85
+ □ Integration tests for {ModuleNameController}
86
+ □ Security tests for authorization & tenant isolation
87
+ □ E2E tests for critical user flows
88
+ Total: E unit + F integration + G security = H tests
89
+
90
+ [QA] Quality Assurance
91
+ □ Code review against SmartStack conventions
92
+ □ Test coverage minimum 80%
93
+ □ Security scan for OWASP vulnerabilities
94
+ □ Performance testing under load
95
+ Total: 4 QA tasks
96
+
97
+ Module Total: X + 5 + Y + Z + A + B + C + D + H + 4 = {module_total} tasks
98
+ Estimated Effort: {simple/medium/complex} - {1-3/3-8/8-15} days
99
+
100
+ {If multi-module:}
101
+ [CROSS-MODULE] Integration Tasks
102
+ Status: NOT STARTED
103
+ Dependencies: All modules COMPLETED
104
+
105
+ □ Verify cross-module entity relationships
106
+ □ Test cross-module API dependencies
107
+ □ Validate permission matrix across modules
108
+ □ E2E flow tests spanning multiple modules
109
+ □ Cross-module data consistency checks
110
+ □ Integration test suite for module interactions
111
+ Total: 6 CROSS-MODULE tasks
112
+
113
+ ═════════════════════════════════════════════════════════════════
114
+ SUMMARY
115
+ ═════════════════════════════════════════════════════════════════
116
+ Total Modules: {count}
117
+ Total Tasks: {total_count}
118
+ - CORE SeedData: {count} × 5 = {total_core}
119
+ - Business Tasks: {total_biz}
120
+ - Development: {total_dev}
121
+ - Tests: {total_tests}
122
+ - QA: {total_qa}
123
+ - Cross-Module: {cross_module_count or 0}
124
+
125
+ Strategy: {strategy}
126
+ Module Order: {topological order with dependencies noted}
127
+
128
+ Complexity Distribution:
129
+ Simple: {count} modules ({estimate} days each)
130
+ Medium: {count} modules ({estimate} days each)
131
+ Complex: {count} modules ({estimate} days each)
132
+
133
+ Total Effort Estimate: {total_days} days ({total_hours} hours)
134
+ Per Developer (2): {total_days / 2} days
135
+ Parallel Potential: {strategy_efficiency_percent}%
136
+
137
+ ═════════════════════════════════════════════════════════════════
138
+ LEGEND
139
+ ═════════════════════════════════════════════════════════════════
140
+ □ = Task not started
141
+ ✓ = Task completed
142
+ ⚠ = Task in progress
143
+ ✗ = Task failed / blocked
144
+
145
+ COLORS:
146
+ [DOMAIN] = Domain Model & Business Logic
147
+ [SEEDDATA-CORE] = MANDATORY core configuration (5 entries)
148
+ [SEEDDATA] = Business reference & lookup data
149
+ [APPLICATION] = Services, DTOs, Validators
150
+ [INFRASTRUCTURE] = Repositories, DbContext, ORM
151
+ [API] = REST controllers & endpoints
152
+ [FRONTEND] = React pages, components, hooks
153
+ [I18N] = Internationalization
154
+ [TESTS] = Unit, Integration, Security, E2E
155
+ [QA] = Code quality, coverage, security
156
+ [CROSS-MODULE] = Multi-module integration (if applicable)
157
+
158
+ ═════════════════════════════════════════════════════════════════
159
+ ```
160
+
161
+ ## Progress Tracker Rules
162
+
163
+ - One section per module, in topological order (dependencies first)
164
+ - CORE SeedData ALWAYS 5 entries (mandatory)
165
+ - Business SeedData varies by module
166
+ - Hierarchical task structure (module → layer → tasks)
167
+ - Each task is independent, assignable checkbox
168
+ - Effort estimate per module (simple/medium/complex)
169
+ - Summary with totals across all modules
170
+ - Identified dependencies for parallel execution
171
+ - Cross-module tasks only if multi-module
@@ -10,27 +10,38 @@ Execute the Ralph Weegund technique - an iterative development methodology where
10
10
  </objective>
11
11
 
12
12
  <quick_start>
13
- **Basic usage:**
14
-
15
- ```bash
16
- /ralph-loop implement user authentication
17
- ```
18
-
19
- **With completion promise:**
13
+ **Three ways to start Ralph Loop:**
14
+
15
+ 1. **From Business Analysis (RECOMMENDED - NEW v6.1):**
16
+ ```bash
17
+ /business-analyse MyFeature
18
+ # At the end, choose "Ralph Loop" → automatic launch
19
+ # No arguments needed - prd.json already generated
20
+ ```
21
+
22
+ 2. **Manual start with existing prd.json:**
23
+ ```bash
24
+ /ralph-loop
25
+ # Ralph detects .ralph/prd.json and resumes automatically
26
+ # Works after BA handoff or previous Ralph session
27
+ ```
28
+
29
+ 3. **Direct task (no BA):**
30
+ ```bash
31
+ /ralph-loop implement user authentication
32
+ # Ralph creates prd.json on the fly
33
+ ```
34
+
35
+ **With options:**
20
36
 
21
37
  ```bash
38
+ # Completion promise
22
39
  /ralph-loop -c "COMPLETE" refactor the cache layer
23
- ```
24
40
 
25
- **With max iterations:**
26
-
27
- ```bash
41
+ # Max iterations
28
42
  /ralph-loop -m 20 -c "TESTS PASS" add comprehensive tests
29
- ```
30
43
 
31
- **Verbose mode:**
32
-
33
- ```bash
44
+ # Verbose mode
34
45
  /ralph-loop -v -c "DONE" fix all linting errors
35
46
  ```
36
47
 
@@ -39,6 +50,7 @@ Execute the Ralph Weegund technique - an iterative development methodology where
39
50
  - `-m N` (max): Maximum iterations before auto-stop
40
51
  - `-c TEXT` (complete): Completion promise text
41
52
  - `-v` (verbose): Detailed logging
53
+ - `-r` (resume): Resume from previous state
42
54
 
43
55
  See `<parameters>` for complete flag list.
44
56
  </quick_start>
@@ -99,12 +111,75 @@ The same prompt is fed to Claude repeatedly. The "self-referential" aspect comes
99
111
  5. Claude sees previous work in the files
100
112
  6. Iteratively improves until completion promise is output
101
113
 
114
+ **Iterative Development Cycle (per task):**
115
+ ```
116
+ ┌─────────────────────────────────────────────────────────────┐
117
+ │ RALPH LOOP - CYCLE │
118
+ ├─────────────────────────────────────────────────────────────┤
119
+ │ │
120
+ │ 1. ANALYSE → Load next task from prd.json │
121
+ │ (UC, FR, BR, wireframes, acceptance) │
122
+ │ │
123
+ │ 2. DÉVELOPPEMENT → Generate code for task │
124
+ │ ├─ Backend: Entity, Service, Repository, Controller │
125
+ │ ├─ Tests: Unit tests (xUnit) + non-regression │
126
+ │ ├─ Frontend: Page, Component, Hook (match wireframe) │
127
+ │ ├─ Tests: Frontend tests (React Testing Library) │
128
+ │ ├─ SeedData: CORE RBAC (5 entries) + business data │
129
+ │ └─ Docs: Inline comments + tooltips + i18n keys │
130
+ │ │
131
+ │ 3. VALIDATION → Commit changes + MCP conventions check │
132
+ │ (validate_conventions, check_migrations) │
133
+ │ │
134
+ │ 4. TEST → Run tests (dotnet test + npm test) │
135
+ │ ├─ Unit tests │
136
+ │ ├─ Integration tests │
137
+ │ ├─ Security tests (tenant isolation) │
138
+ │ └─ E2E tests (critical flows) │
139
+ │ │
140
+ │ 5. CORRECTION → If tests fail: │
141
+ │ ├─ Analyze error logs │
142
+ │ ├─ Fix root cause │
143
+ │ ├─ Commit fix │
144
+ │ └─ Return to step 4 │
145
+ │ │
146
+ │ 6. NEXT TASK → Mark task as completed, loop to step 1 │
147
+ │ │
148
+ │ 🎯 Goal: 100% tests pass before moving to next task │
149
+ │ 📊 Coverage: 95-100% (tests auto-generated) │
150
+ │ │
151
+ └─────────────────────────────────────────────────────────────┘
152
+ ```
153
+
102
154
  **Completion signal:**
103
155
  ```
104
156
  <promise>{completion_promise}</promise>
105
157
  ```
106
158
 
107
159
  The loop only stops when this exact tag is output or max iterations reached.
160
+
161
+ **What Ralph generates per task:**
162
+ - **Backend code**: Entities (Domain), Services (Application), Repositories (Infrastructure), Controllers (API)
163
+ - **Unit tests**: xUnit tests for domain logic, services, repositories
164
+ - **Integration tests**: Controller tests with WebApplicationFactory
165
+ - **Frontend code**: React pages, components, custom hooks (matching BA wireframes)
166
+ - **Frontend tests**: React Testing Library for components and pages
167
+ - **SeedData**: 5 CORE entries (Navigation, Permissions, Roles, Tenants, Users) + business reference data
168
+ - **Documentation**: Inline code comments, user-facing tooltips, i18n translation keys
169
+ - **Security tests**: Tenant isolation, permission checks, OWASP validations
170
+
171
+ **prd.json structure (input from BA):**
172
+ The prd.json is generated by `/business-analyse` via `ss derive-prd` command. It contains:
173
+ - **feature**: Feature description (from BA)
174
+ - **tasks[]**: Task breakdown by category (domain, application, infrastructure, api, frontend, i18n, test, validation)
175
+ - Each task has: id, description, category, dependencies, acceptance_criteria, linkedFRs, linkedUCs, linkedBRs
176
+ - Frontend tasks include: linkedWireframes (screen IDs from BA mockups), wireframeAcceptanceCriteria
177
+ - SeedData tasks specify: category (core|business), source (specification.seedDataCore or seedDataBusiness)
178
+ - **source**: Traceability to feature.json path (source of truth)
179
+ - **metadata**: Project context (branch, namespace, module order)
180
+ - **config**: max_iterations, completion_promise, current_iteration
181
+
182
+ Ralph reads prd.json to know WHAT to generate, then generates it, tests it, fixes it, and moves to the next task.
108
183
  </ralph_concept>
109
184
 
110
185
  <workflow>
@@ -118,19 +193,62 @@ The loop only stops when this exact tag is output or max iterations reached.
118
193
  7. Check completion → enter COMPACT LOOP (step-04)
119
194
  8. **COMPACT LOOP** (step-04 section 5, NO re-reading step files):
120
195
  - Find eligible tasks → batch by category (max 5)
121
- - Execute batch inline
122
- - Commit batch
196
+ - Execute batch inline (generate code)
197
+ - Run tests (dotnet test + npm test)
198
+ - If tests fail: analyze → fix → re-test (loop until 100% pass)
199
+ - Commit batch (only when tests pass)
123
200
  - Re-check completion → loop or finish
124
201
  9. When complete: generate final report (step-05)
125
202
 
126
- **Multi-module flow (from BA handoff):**
127
- 1-3. Same as standard flow
203
+ **Multi-module flow (from BA handoff - NEW v6.1: automatic launch):**
204
+ 1-3. Same as standard flow (or launched automatically from `/business-analyse`)
128
205
  4. Detect `prd-*.json` files → create `modules-queue.json`
129
206
  5. Copy current module's prd to `prd.json`
130
- 6. Execute all tasks for current module via COMPACT LOOP
207
+ 6. Execute all tasks for current module via COMPACT LOOP:
208
+ - Process tasks by category (domain → seeddata → application → infrastructure → api → frontend → i18n → tests)
209
+ - For each task: generate → test → fix (if needed) → re-test → commit (when pass)
210
+ - Each task generates: backend code + tests + frontend code + tests + seeddata + docs
211
+ - Each frontend task respects wireframes from BA (specification.uiWireframes[])
212
+ - Continue until ALL tasks of module = completed
131
213
  7. When module complete: advance to next module in queue (step-04 section 3)
132
214
  8. Repeat steps 5-7 for each module (step-01 is re-read ONLY for module transitions)
133
215
  9. When all modules done: generate cross-module report
216
+
217
+ **Note:** When launched from `/business-analyse` (v6.1+), Ralph Loop receives:
218
+ - `.ralph/prd-{module}.json` for each module (generated by `ss derive-prd`)
219
+ - Each prd contains: tasks breakdown with UC/FR/BR/wireframes/acceptance criteria
220
+ - Task categories: domain, application, infrastructure, api, frontend, i18n, test, validation
221
+ - Each task linked to: functional requirements (FR), use cases (UC), business rules (BR)
222
+ - Frontend tasks include: linkedWireframes[] (screen IDs from BA mockups)
223
+ - SeedData tasks specify: category (core 5 entries MANDATORY + business data)
224
+ - `.ralph/progress.txt` with comprehensive task tracker (hierarchical: module → layer → tasks)
225
+ - Module order from BA's topological dependency graph (dependencies first)
226
+ - No arguments needed - fully configured by BA handoff
227
+
228
+ **Task execution cycle (per task):**
229
+ ```
230
+ LOAD TASK → GENERATE CODE → COMMIT → RUN TESTS → [FAIL?] → ANALYZE ERROR → FIX → RE-TEST → [PASS!] → NEXT TASK
231
+ ↑___________________________________________|
232
+ (loop until 100% tests pass)
233
+ ```
234
+
235
+ **What gets generated per module:**
236
+ 1. **Domain layer**: Entities, Value Objects, Enums, Domain Exceptions
237
+ 2. **SeedData layer**: 5 CORE entries (Navigation, Permissions, Roles, Tenants, Users) + business reference data
238
+ 3. **Application layer**: Services, DTOs, Validators, Query Handlers
239
+ 4. **Infrastructure layer**: Repositories, DbContext, Specifications
240
+ 5. **API layer**: Controllers, Error Handlers, Validation Responses
241
+ 6. **Frontend layer**: Pages (matching wireframes), Components, Custom Hooks, Forms
242
+ 7. **I18n layer**: Translation keys (fr, en, it, de) for UI labels
243
+ 8. **Tests layer**: Unit tests (Domain, Application), Integration tests (API), Security tests (tenant isolation), E2E tests (critical flows)
244
+
245
+ **Acceptance criteria per task:**
246
+ - Code compiles (dotnet build + npm build)
247
+ - Tests pass (dotnet test + npm test)
248
+ - MCP conventions validated (validate_conventions)
249
+ - Wireframes respected (frontend pages match BA mockups from specification.uiWireframes[])
250
+ - Business rules implemented (BR-to-code mapping from BA)
251
+ - Security enforced (tenant isolation, RBAC permissions)
134
252
  </workflow>
135
253
 
136
254
  <state_variables>
@@ -6,11 +6,35 @@ next_step: steps/step-02-execute.md
6
6
 
7
7
  # Step 1: Load Task
8
8
 
9
- > **CONTEXT OPTIMIZATION:** This file is only read ONCE (first iteration).
9
+ > **MODULE TRANSITION CHECK (MANDATORY):**
10
+ > Before applying the "Only Read Once" rule, check for module transition marker:
11
+
12
+ ```javascript
13
+ const moduleChangedPath = '.ralph/module-changed.json';
14
+ const moduleTransition = fileExists(moduleChangedPath);
15
+
16
+ if (moduleTransition) {
17
+ const transitionData = readJSON(moduleChangedPath);
18
+ console.log(`🔄 Module transition detected: ${transitionData.fromModule} → ${transitionData.toModule}`);
19
+ console.log(` Reloading step-01 to initialize new module...`);
20
+
21
+ // Delete flag (consume it)
22
+ deleteFile(moduleChangedPath);
23
+
24
+ // PROCEED with step-01 execution (skip "Only Read Once" rule below)
25
+ // This is the EXCEPTION case for multi-module workflows
26
+ }
27
+ ```
28
+
29
+ > **CONTEXT OPTIMIZATION:** This file is normally read ONCE per module (first iteration).
10
30
  > After the first full iteration (step-01 → step-02 → step-03 → step-04),
11
- > ALL subsequent iterations MUST use the COMPACT LOOP in step-04-check.md section 5.
12
- > **DO NOT re-read this file for iterations > 1.**
13
- > If you are re-reading this file on iteration > 1, STOP and go to step-04 section 5 instead.
31
+ > ALL subsequent iterations within the SAME module MUST use the COMPACT LOOP in step-04-check.md section 5.
32
+ > **DO NOT re-read this file for iterations > 1 of the same module.**
33
+ >
34
+ > **EXCEPTION:** When transitioning between modules (multi-module workflows), step-01 MUST be re-read
35
+ > to load the next module's PRD. This is signaled by `.ralph/module-changed.json` file (checked above).
36
+ >
37
+ > If you are re-reading this file on iteration > 1 AND no module transition detected, STOP and go to step-04 section 5 instead.
14
38
 
15
39
  ## YOUR TASK:
16
40
 
@@ -24,7 +48,10 @@ Load the current task from prd.json or create initial task breakdown with catego
24
48
 
25
49
  ### 0. Multi-Module Queue Check
26
50
 
27
- **Before any other logic, check for modules-queue.json:**
51
+ **✅ ALWAYS check for modules-queue.json, even on iteration > 1:**
52
+
53
+ > **CRITICAL:** This section MUST execute even when step-01 is re-read for module transitions.
54
+ > The module-changed.json flag (checked above) ensures this section runs when needed.
28
55
 
29
56
  ```javascript
30
57
  const queuePath = '.ralph/modules-queue.json';
@@ -34,22 +61,52 @@ if (hasQueue) {
34
61
  const queue = readJSON(queuePath);
35
62
  const currentModule = queue.modules[queue.currentIndex];
36
63
 
37
- console.log(`Module ${queue.currentIndex + 1}/${queue.totalModules}: ${currentModule.code}`);
38
-
39
- // Copy current module's prd file to prd.json (overwrite)
40
- const modulePrd = readJSON(currentModule.prdFile);
41
-
42
- // Transform PrdJson format to Ralph v2 if needed
43
- if (modulePrd.project && modulePrd.requirements && !modulePrd.$version) {
44
- // This is a PrdJson format from ss derive-prd → transform to Ralph v2
45
- const transformedPrd = transformPrdJsonToRalphV2(modulePrd, currentModule.code);
46
- writeJSON('.ralph/prd.json', transformedPrd);
64
+ console.log(`
65
+ ╔══════════════════════════════════════════════════════════════════╗
66
+ Multi-Module Workflow Detected ║
67
+ ╠══════════════════════════════════════════════════════════════════╣
68
+ ║ Current Module: ${currentModule.code} (${queue.currentIndex + 1}/${queue.totalModules}) ║
69
+ Status: ${currentModule.status} ║
70
+ PRD File: ${currentModule.prdFile} ║
71
+ ╚══════════════════════════════════════════════════════════════════╝
72
+ `);
73
+
74
+ // ✅ FIX #3: RESTORE multi-module state variables
75
+ // These variables persist across step files and are critical for multi-module coordination
76
+ {modules_queue} = queue;
77
+ {current_module} = currentModule.code;
78
+
79
+ // ✅ Load or verify current module's PRD is in .ralph/prd.json
80
+ // On module transition, step-04 already loaded it, but we verify here
81
+ const currentPrd = readJSON('.ralph/prd.json');
82
+
83
+ // Verify PRD matches current module (sanity check)
84
+ if (currentPrd.metadata && currentPrd.metadata.moduleCode !== currentModule.code) {
85
+ console.log(`⚠️ PRD mismatch detected. Loading correct PRD for module ${currentModule.code}...`);
86
+
87
+ // Load current module's PRD
88
+ const modulePrd = readJSON(currentModule.prdFile);
89
+
90
+ // Transform PrdJson format to Ralph v2 if needed
91
+ if (modulePrd.project && modulePrd.requirements && !modulePrd.$version) {
92
+ // This is a PrdJson format from ss derive-prd → transform to Ralph v2
93
+ const transformedPrd = transformPrdJsonToRalphV2(modulePrd, currentModule.code);
94
+ writeJSON('.ralph/prd.json', transformedPrd);
95
+ console.log(`✅ Transformed and loaded PRD for module: ${currentModule.code}`);
96
+ } else {
97
+ // Already Ralph v2 format
98
+ writeJSON('.ralph/prd.json', modulePrd);
99
+ console.log(`✅ Loaded PRD for module: ${currentModule.code}`);
100
+ }
47
101
  } else {
48
- // Already Ralph v2 format
49
- writeJSON('.ralph/prd.json', modulePrd);
102
+ console.log(`✅ PRD already loaded for module: ${currentModule.code}`);
50
103
  }
51
104
 
52
- console.log(`Loaded PRD for module: ${currentModule.code}`);
105
+ console.log(`State restored: modules_queue and current_module set`);
106
+ } else {
107
+ // Single-module workflow
108
+ {modules_queue} = null;
109
+ {current_module} = null;
53
110
  }
54
111
  ```
55
112