@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,396 @@
1
+ # PRD JSON v2.0.0 - Référence Complète
2
+
3
+ ## Vue d'ensemble
4
+
5
+ Le `prd.json` est généré **programmatiquement** par `ss derive-prd` à partir du `feature.json` (section handoff).
6
+
7
+ **Garanties** :
8
+ - ✅ Zéro hallucination LLM (extraction déterministe TypeScript)
9
+ - ✅ Traçabilité complète (`source.featureJson` path)
10
+ - ✅ Validation stricte (status + contenu obligatoire)
11
+ - ✅ Reproductibilité parfaite (même input = même output)
12
+
13
+ **Code source** :
14
+ - Types : [src/types/prd-json.d.ts](../src/types/prd-json.d.ts)
15
+ - Extraction : [src/utils/prd-extractor.ts](../src/utils/prd-extractor.ts)
16
+ - CLI : [src/commands/derive-prd.ts](../src/commands/derive-prd.ts)
17
+
18
+ ---
19
+
20
+ ## Commande CLI
21
+
22
+ ```bash
23
+ # Module unique
24
+ ss derive-prd --feature docs/business/MyApp/Orders/business-analyse/v1.0/feature.json
25
+
26
+ # Application complète (tous les modules)
27
+ ss derive-prd --application docs/business/MyApp/business-analyse/v1.0/feature.json
28
+
29
+ # Mode strict (fail on warnings)
30
+ ss derive-prd --feature <path> --strict
31
+
32
+ # Output custom
33
+ ss derive-prd --feature <path> --output .ralph/custom-prd.json
34
+ ```
35
+
36
+ **Output par défaut** : `.ralph/prd-{module}.json`
37
+
38
+ ---
39
+
40
+ ## Structure Complète
41
+
42
+ ```typescript
43
+ {
44
+ // VERSION
45
+ version: "2.0.0",
46
+
47
+ // SOURCE (traçabilité)
48
+ source: {
49
+ type: "ba-handoff-programmatic",
50
+ featureJson: "docs/business/MyApp/Orders/business-analyse/v1.0/feature.json",
51
+ extractedAt: "2024-01-15T10:30:00Z"
52
+ },
53
+
54
+ // PROJECT
55
+ project: {
56
+ application: "MyApp",
57
+ module: "Orders",
58
+ namespace: "MyCompany.MyApp" // Optionnel, depuis .smartstack/config.json
59
+ },
60
+
61
+ // REQUIREMENTS
62
+ requirements: {
63
+ useCases: [{
64
+ id: "UC-001",
65
+ name: "Create Order",
66
+ actor: "Sales Manager",
67
+ permission: "business.myapp.orders.create",
68
+ steps: ["Select products", "Validate cart", "Create order"],
69
+ linkedRules: ["BR-VAL-001"]
70
+ }],
71
+ functionalRequirements: [{
72
+ id: "FR-001",
73
+ statement: "System must allow creating orders",
74
+ priority: "high",
75
+ linkedUCs: ["UC-001"]
76
+ }]
77
+ },
78
+
79
+ // BUSINESS RULES
80
+ businessRules: [{
81
+ id: "BR-VAL-001",
82
+ name: "Order total validation",
83
+ category: "validation",
84
+ statement: "Order total must equal sum of item prices",
85
+ priority: "critical"
86
+ }],
87
+
88
+ // ARCHITECTURE
89
+ architecture: {
90
+ entities: [{
91
+ name: "Order",
92
+ type: "aggregate-root",
93
+ attributes: [{
94
+ name: "Reference",
95
+ type: "string",
96
+ required: true,
97
+ unique: true
98
+ }],
99
+ relationships: [{
100
+ target: "Customer",
101
+ type: "many-to-one"
102
+ }]
103
+ }],
104
+ apiEndpoints: [{
105
+ method: "POST",
106
+ route: "/api/business/myapp/orders",
107
+ operation: "CreateOrder",
108
+ permission: "business.myapp.orders.create",
109
+ requestSchema: "CreateOrderDto",
110
+ responseSchema: "OrderDto",
111
+ errorCodes: ["400", "401", "403", "422"],
112
+ linkedUC: "UC-001"
113
+ }],
114
+ permissionMatrix: {
115
+ permissions: [{
116
+ path: "business.myapp.orders.create",
117
+ description: "Create new orders",
118
+ scope: "tenant"
119
+ }],
120
+ roleAssignments: [{
121
+ role: "MyApp Manager",
122
+ level: "full",
123
+ permissions: ["business.myapp.orders.*"]
124
+ }]
125
+ },
126
+ sections: [{
127
+ code: "orders-list",
128
+ name: "Orders List",
129
+ route: "/business/myapp/orders",
130
+ permission: "business.myapp.orders.read",
131
+ resources: [{
132
+ code: "orders-grid",
133
+ type: "DataGrid",
134
+ entity: "Order",
135
+ columns: ["reference", "customer", "total", "status"]
136
+ }]
137
+ }],
138
+ lifeCycles: [{
139
+ entity: "Order",
140
+ field: "status",
141
+ initialState: "draft",
142
+ states: [
143
+ { id: "draft", allowedTransitions: ["submitted"] },
144
+ { id: "submitted", allowedTransitions: ["approved", "rejected"] }
145
+ ]
146
+ }]
147
+ },
148
+
149
+ // IMPLEMENTATION
150
+ implementation: {
151
+ strategy: "module-by-module",
152
+ filesToCreate: {
153
+ domain: [{
154
+ path: "src/Domain/Business/MyApp/Orders/Order.cs",
155
+ type: "Entity",
156
+ linkedFRs: ["FR-001"],
157
+ linkedUCs: ["UC-001"]
158
+ }],
159
+ application: [/* DTOs, Services, Validators */],
160
+ infrastructure: [/* Repositories, DbContext */],
161
+ api: [/* Controllers */],
162
+ frontend: [{
163
+ path: "src/pages/MyApp/OrdersPage.tsx",
164
+ type: "Page",
165
+ linkedUCs: ["UC-001"],
166
+ linkedWireframes: ["orders-list"]
167
+ }],
168
+ seedData: [{
169
+ path: "src/Infrastructure/Persistence/Seeding/Data/Orders/NavigationModuleSeedData.cs",
170
+ type: "SeedData",
171
+ category: "core"
172
+ }],
173
+ tests: [/* Unit, Integration, Security tests */]
174
+ },
175
+ brToCodeMapping: [{
176
+ ruleId: "BR-VAL-001",
177
+ targetFile: "src/Domain/Business/MyApp/Orders/Order.cs",
178
+ targetMethod: "CalculateTotal()",
179
+ implementationType: "domain-validation"
180
+ }]
181
+ },
182
+
183
+ // SEED DATA
184
+ seedData: {
185
+ core: [
186
+ { entity: "NavigationModule", count: 1 },
187
+ { entity: "Permission", count: 8 }
188
+ ],
189
+ business: [
190
+ { entity: "OrderStatus", samples: ["Draft", "Submitted"], count: 5 }
191
+ ]
192
+ }
193
+ }
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Mapping feature.json → prd.json
199
+
200
+ | Champ prd.json | Source feature.json | Transformation |
201
+ |----------------|---------------------|----------------|
202
+ | `requirements.useCases[]` | `specification.useCases[]` | Direct (id, name, actor, permission, steps, linkedRules) |
203
+ | `requirements.functionalRequirements[]` | `specification.functionalRequirements[]` | Direct (id, statement, priority, linkedUCs) |
204
+ | `businessRules[]` | `analysis.businessRules[]` | Direct (id, name, category, statement, priority) |
205
+ | `architecture.entities[]` | `analysis.entities[]` | Direct (name, type, attributes, relationships) |
206
+ | `architecture.apiEndpoints[]` | `specification.apiEndpoints[]` | Direct (method, route, operation, permission) |
207
+ | `architecture.permissionMatrix` | `specification.permissionMatrix` | Direct (permissions, roleAssignments) |
208
+ | `architecture.sections[]` | `specification.sections[]` | Direct (code, name, route, resources) |
209
+ | `architecture.lifeCycles[]` | `specification.lifeCycles[]` | Direct (entity, states, transitions) |
210
+ | `implementation.strategy` | `handoff.implementationStrategy` | Direct ("module-by-module", "layer-by-layer", "hybrid") |
211
+ | `implementation.filesToCreate` | `handoff.filesToCreate` | Direct (7 categories: domain, application, infrastructure, api, frontend, seedData, tests) |
212
+ | `implementation.brToCodeMapping[]` | `handoff.brToCodeMapping[]` | Direct (ruleId, targetFile, targetMethod) |
213
+ | `seedData.core` | `specification.seedDataCore` | Direct |
214
+ | `seedData.business` | `specification.seedDataBusiness` | Direct |
215
+
216
+ **Aucune transformation complexe** : Le prd.json est une copie structurée du feature.json.
217
+
218
+ ---
219
+
220
+ ## Validation (Pre-Extraction)
221
+
222
+ ### Pré-requis MANDATORY
223
+
224
+ ```typescript
225
+ // Code: src/utils/prd-extractor.ts:validateForPrdExtraction()
226
+
227
+ function validateForPrdExtraction(feature: ModuleFeatureJson): string[] {
228
+ const errors: string[] = [];
229
+
230
+ if (!feature.id) errors.push('Missing feature ID');
231
+ if (!feature.metadata?.application) errors.push('Missing metadata.application');
232
+ if (!feature.metadata?.module) errors.push('Missing metadata.module');
233
+
234
+ if (feature.status !== 'handed-off' &&
235
+ feature.status !== 'approved' &&
236
+ feature.status !== 'consolidated') {
237
+ errors.push(`Feature status is "${feature.status}" — expected "handed-off", "approved", or "consolidated"`);
238
+ }
239
+
240
+ if (!feature.specification?.useCases?.length) {
241
+ errors.push('No use cases found in specification');
242
+ }
243
+
244
+ if (!feature.analysis?.businessRules?.length) {
245
+ errors.push('No business rules found in analysis');
246
+ }
247
+
248
+ if (!feature.handoff?.filesToCreate) {
249
+ errors.push('No filesToCreate found in handoff');
250
+ }
251
+
252
+ return errors;
253
+ }
254
+ ```
255
+
256
+ ### Mode Strict
257
+
258
+ En mode `--strict`, les warnings bloquent l'extraction :
259
+
260
+ ```bash
261
+ ss derive-prd --feature <path> --strict
262
+ # Échoue si : warnings.length > 0
263
+ ```
264
+
265
+ ---
266
+
267
+ ## Exemples Annotés
268
+
269
+ ### Simple Module (CRUD basique)
270
+
271
+ **Contexte** : Module Orders avec 1 entity, 2 UCs, 3 BRs
272
+
273
+ **Commande** :
274
+ ```bash
275
+ ss derive-prd --feature docs/business/MyApp/Orders/business-analyse/v1.0/feature.json
276
+ ```
277
+
278
+ **Output** : `.ralph/prd-Orders.json` (voir [examples/prd-simple.json](examples/prd-simple.json))
279
+
280
+ **Métriques** :
281
+ - UCs: 2
282
+ - FRs: 3
283
+ - BRs: 3
284
+ - Endpoints: 5 (CRUD + List)
285
+ - Files to create: 15
286
+ - SeedData core: 5 (MANDATORY)
287
+
288
+ ---
289
+
290
+ ### Medium Module (Avec Lifecycle)
291
+
292
+ **Contexte** : Module Invoices avec 4 entities, 6 UCs, 12 BRs, lifecycle states
293
+
294
+ **Commande** :
295
+ ```bash
296
+ ss derive-prd --feature docs/business/MyApp/Invoices/business-analyse/v1.0/feature.json
297
+ ```
298
+
299
+ **Output** : `.ralph/prd-Invoices.json` (voir [examples/prd-medium.json](examples/prd-medium.json))
300
+
301
+ **Métriques** :
302
+ - UCs: 6
303
+ - FRs: 10
304
+ - BRs: 12
305
+ - Endpoints: 12
306
+ - Files to create: 35
307
+ - LifeCycles: 1 (Invoice.status: draft → submitted → paid)
308
+
309
+ ---
310
+
311
+ ### Complex Module (Cross-Dependencies)
312
+
313
+ **Contexte** : Module Orders dépendant de Customers + Products
314
+
315
+ **Commande** :
316
+ ```bash
317
+ ss derive-prd --application docs/business/MyApp/business-analyse/v1.0/feature.json
318
+ # Génère prd-Orders.json + prd-Customers.json + prd-Products.json
319
+ ```
320
+
321
+ **Output** : 3 fichiers prd.json (voir [examples/prd-complex/](examples/prd-complex/))
322
+
323
+ **Métriques** :
324
+ - Modules: 3
325
+ - Total UCs: 15
326
+ - Total BRs: 25
327
+ - Cross-module relationships: Order → Customer, Order → Product
328
+
329
+ ---
330
+
331
+ ## Consommation par Ralph Loop
332
+
333
+ Ralph Loop lit le prd.json pour :
334
+
335
+ 1. **Générer les fichiers** (`implementation.filesToCreate`) :
336
+ - Domain entities (BaseEntity + IAuditableEntity)
337
+ - Application services (DTOs, Validators)
338
+ - Infrastructure (Repositories, DbContext)
339
+ - API controllers (RequirePermission)
340
+ - Frontend pages (SmartTable, EntityForm)
341
+ - SeedData (5 CORE + business)
342
+ - Tests (Unit, Integration, Security)
343
+
344
+ 2. **Implémenter les business rules** (`implementation.brToCodeMapping`) :
345
+ - Injection dans les layers appropriées (Domain, Application, API)
346
+
347
+ 3. **Créer les SeedData** (`seedData.core` + `seedData.business`) :
348
+ - NavigationModule, Permissions, Roles (CORE)
349
+ - Lookup tables, test fixtures (business)
350
+
351
+ 4. **Valider la couverture** :
352
+ - Tous les UCs ont des endpoints
353
+ - Tous les BRs sont mappés au code
354
+ - Toutes les permissions sont définies
355
+
356
+ ---
357
+
358
+ ## Dépannage
359
+
360
+ ### Erreur : "Feature status is X — expected handed-off"
361
+
362
+ **Cause** : Le feature.json n'a pas été finalisé par step-05-handoff.md
363
+
364
+ **Solution** :
365
+ ```bash
366
+ # Vérifier le status
367
+ jq '.status' docs/business/MyApp/Orders/business-analyse/v1.0/feature.json
368
+
369
+ # Doit retourner : "handed-off"
370
+ ```
371
+
372
+ ### Erreur : "No filesToCreate found in handoff"
373
+
374
+ **Cause** : La section handoff est vide (`handoff: {}`) ou manquante
375
+
376
+ **Solution** : Relancer step-05-handoff.md pour générer le handoff complet avec les 7 catégories de fichiers.
377
+
378
+ ### Erreur : "No use cases found"
379
+
380
+ **Cause** : `specification.useCases[]` est vide ou manquant
381
+
382
+ **Solution** : Relancer step-03-specify.md pour spécifier les use cases.
383
+
384
+ ### Avertissement : Module feature.json mais status = "approved"
385
+
386
+ **Cause** : Feature validée mais pas encore en mode handoff
387
+
388
+ **Solution** : Acceptable en mode non-strict. Pour strict, relancer step-05.
389
+
390
+ ---
391
+
392
+ ## Voir aussi
393
+
394
+ - [feature.json Schema](../templates/skills/business-analyse/schemas/feature-schema.json)
395
+ - [Step 05 Handoff](../templates/skills/business-analyse/steps/step-05-handoff.md)
396
+ - [Ralph Loop Documentation](../templates/skills/ralph-loop/SKILL.md)