@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,118 @@
1
+ # Semantic Validation Matrix
2
+
3
+ > **Purpose:** Define all semantic validation checks and contract verification rules required before consolidation approval.
4
+ > These checks catch data integrity gaps and ensure downstream skills have complete information.
5
+
6
+ ## 13 Semantic Checks (Per Module)
7
+
8
+ Execute these checks for each completed module:
9
+
10
+ ```javascript
11
+ const semanticChecks = [
12
+ { check: "permission-orpheline", severity: "WARNING" },
13
+ { check: "uc-sans-fr", severity: "WARNING" },
14
+ { check: "entity-sans-endpoint", severity: "WARNING" },
15
+ { check: "uc-sans-scenario", severity: "WARNING" },
16
+ { check: "role-sans-permissions", severity: "WARNING" },
17
+ { check: "navigation-sans-traduction", severity: "ERROR" },
18
+ { check: "lifecycle-terminal", severity: "WARNING" },
19
+ { check: "schema-conformity", severity: "ERROR" },
20
+ { check: "wireframe-coverage", severity: "ERROR" },
21
+ { check: "entity-doublon", severity: "ERROR" },
22
+ { check: "permission-fantome", severity: "ERROR" },
23
+ { check: "dashboard-coverage", severity: "WARNING" },
24
+ { check: "permission-uc-alignment", severity: "WARNING" }
25
+ ];
26
+ ```
27
+
28
+ **Blocking rule:** 0 ERROR → PASS, ≥1 ERROR → BLOCK (user must fix before proceeding)
29
+
30
+ ## Contract Verification (Per Module)
31
+
32
+ Verify the data contract that downstream skills (`/business-analyse-handoff`, `/business-analyse-develop`) depend on.
33
+ These checks catch gaps that abstract semantic checks miss.
34
+
35
+ ```javascript
36
+ for (const module of completedModules) {
37
+ const ent = module.entities || [];
38
+ const brs = ba-reader.readSection(module.code, "rules")?.rules || [];
39
+ const ucs = ba-reader.readSection(module.code, "usecases")?.useCases || [];
40
+ const perms = ba-reader.readSection(module.code, "permissions");
41
+
42
+ // CHECK 1: BR-CALC must have formula (C13)
43
+ for (const br of brs) {
44
+ if (br.category === 'calculation' && !br.formula) {
45
+ errors.push({module: module.code, check: "br-calc-sans-formula",
46
+ details: `${br.id} is category:calculation but missing 'formula' field`});
47
+ }
48
+ }
49
+
50
+ // CHECK 2: Computed attributes must have corresponding BR-CALC (C11)
51
+ for (const entity of ent) {
52
+ for (const attr of (entity.attributes || [])) {
53
+ if (attr.computed === true) {
54
+ const hasBRCalc = brs.some(br =>
55
+ br.category === 'calculation' && (br.entities || []).includes(entity.name)
56
+ );
57
+ if (!hasBRCalc) {
58
+ errors.push({module: module.code, check: "computed-sans-br-calc",
59
+ details: `${entity.name}.${attr.name} is computed:true but no BR-CALC references ${entity.name}`});
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ // CHECK 3: UC count minimum (C6)
66
+ if (ucs.length < 4) {
67
+ errors.push({module: module.code, check: "uc-count-critical",
68
+ details: `Only ${ucs.length} use cases (minimum: 4)`});
69
+ } else if (ucs.length < 6) {
70
+ warnings.push({module: module.code, check: "uc-count-low",
71
+ details: `Only ${ucs.length} use cases (recommended: >= 6)`});
72
+ }
73
+
74
+ // CHECK 4: Permission path count (C7)
75
+ const permCount = perms?.permissionPaths?.length || 0;
76
+ if (permCount < 5) {
77
+ warnings.push({module: module.code, check: "permission-count-low",
78
+ details: `Only ${permCount} permission paths (recommended: >= 5 — check for missing Export/Import)`});
79
+ }
80
+
81
+ // CHECK 5: Versioned attributes detection (C15)
82
+ const sensitiveKeywords = ['salary', 'rate', 'grade', 'price', 'tarif'];
83
+ for (const entity of ent) {
84
+ for (const attr of (entity.attributes || [])) {
85
+ if (sensitiveKeywords.some(k => attr.name.toLowerCase().includes(k))) {
86
+ if (!entity.versionedAttributes?.length) {
87
+ warnings.push({module: module.code, check: "missing-versioned-attributes",
88
+ details: `${entity.name}.${attr.name} may need versioning but no versionedAttributes defined`});
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## Execution Logic
97
+
98
+ ```javascript
99
+ for (const module of completedModules) {
100
+ for (const check of semanticChecks) {
101
+ const result = executeSemanticCheck(module, check);
102
+ if (result.status === "ERROR") {
103
+ errors.push({module: module.code, check: check.check, details: result.details});
104
+ } else if (result.status === "WARNING") {
105
+ warnings.push({module: module.code, check: check.check, details: result.details});
106
+ }
107
+ }
108
+ }
109
+
110
+ // Blocking rule: 0 ERROR → PASS, ≥1 ERROR → BLOCK (ask user for each)
111
+ if (errors.length > 0) {
112
+ BLOCKING_ERROR("Semantic validation failed");
113
+ for (const error of errors) {
114
+ ERROR(` [${error.module}] ${error.check}: ${error.details}`);
115
+ }
116
+ STOP - User must fix before proceeding
117
+ }
118
+ ```
@@ -0,0 +1,234 @@
1
+ # Domain Research Playbook
2
+
3
+ > **Web research is the #1 quality differentiator.**
4
+ > An analysis WITHOUT research is a 2/10 regardless of structural quality.
5
+ > An analysis WITH multi-level research can be 8-10/10.
6
+ > This step takes 2-5 minutes per application and dramatically improves analysis quality.
7
+
8
+ ## MANDATORY — BLOCKING
9
+
10
+ Web research is **MANDATORY and BLOCKING**. This is NOT optional.
11
+
12
+ If WebSearch tool is unavailable:
13
+ 1. Display WARNING to user: "WebSearch indisponible. Qualite d'analyse degradee."
14
+ 2. AskUserQuestion: "Continuer sans recherche web ? (Non recommande — qualite 4/10 max)"
15
+ 3. IF user declines → STOP and recommend fixing WebSearch availability
16
+ 4. IF user confirms → proceed with `{domain_research}.source = "built-in-only"`
17
+ and flag EVERY module with `qualityFlag: "no-web-research"`
18
+ → Load `references/module-completeness-challenge.md` as primary fallback data source
19
+
20
+ ---
21
+
22
+ ## Level 1 : Recherche par APPLICATION (step-01 cadrage)
23
+
24
+ > **WHEN:** During step-01 Phase 1 (ECOUTE), BEFORE engaging the client.
25
+ > **WHO:** For EACH candidate application in a multi-app project, or the single app.
26
+
27
+ For EACH application:
28
+
29
+ ### 1a. Module Discovery Search (MANDATORY)
30
+
31
+ ```
32
+ Query: "{app_type} application modules features complete list"
33
+ ```
34
+
35
+ Examples:
36
+ - "billing invoicing application modules features complete list ERP"
37
+ - "HR human resources application modules features complete list"
38
+ - "CRM application modules features complete list"
39
+ - "project management application modules features complete list"
40
+
41
+ **EXTRACT:**
42
+ - Standard modules for this app type
43
+ - Which are CORE (always present) vs STANDARD vs OPTIONAL
44
+ - Common module names and their scope
45
+ - Module dependencies
46
+
47
+ ### 1b. Competitive Research (MANDATORY)
48
+
49
+ ```
50
+ Query: "best {app_type} software features comparison"
51
+ ```
52
+
53
+ Examples:
54
+ - "best invoicing software features comparison 2025"
55
+ - "best HR software absence management features"
56
+ - "best CRM software features comparison"
57
+ - "best project management software features"
58
+
59
+ **EXTRACT:**
60
+ - What do real commercial products offer? (BambooHR, Sage, Salesforce, etc.)
61
+ - Common features users expect as baseline
62
+ - Differentiating features that add value
63
+ - Features that are table stakes vs nice-to-have
64
+
65
+ ### 1c. Data Model Research (1 per app)
66
+
67
+ ```
68
+ Query: "{app_type} data model entities relationships best practices"
69
+ ```
70
+
71
+ **EXTRACT:**
72
+ - Standard entities and their relationships
73
+ - Common anti-patterns to avoid (e.g., "storing salary on Employee instead of salary history table")
74
+ - Industry-standard naming and cardinality
75
+
76
+ ### Storage Format
77
+
78
+ ```yaml
79
+ {domain_research}.applications[{app_code}]:
80
+ standardModules:
81
+ - name: "Invoices"
82
+ classification: "CORE" # CORE | STANDARD | OPTIONAL
83
+ description: "Invoice lifecycle management"
84
+ standardSections: ["list", "detail", "generate", "dashboard"]
85
+ - name: "CreditNotes"
86
+ classification: "CORE"
87
+ description: "Legally required for invoice corrections/cancellations"
88
+ standardSections: ["list", "detail"]
89
+ competitiveInsights:
90
+ - product: "Sage"
91
+ keyFeatures: ["auto-numbering", "multi-currency", "credit notes", "recurring invoices"]
92
+ - product: "Stripe Invoicing"
93
+ keyFeatures: ["payment tracking", "dunning", "tax calculation"]
94
+ dataModel:
95
+ entities: ["Invoice", "InvoiceLine", "CreditNote", "Payment", "PaymentTerm"]
96
+ relationships: ["Invoice → Client (N:1)", "Invoice → InvoiceLine (1:N)"]
97
+ antiPatterns: ["single invoice entity without credit notes"]
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Level 2 : Recherche par MODULE (step-03 specify)
103
+
104
+ > **WHEN:** During step-03 section A-bis, BEFORE entity specification.
105
+ > **WHO:** For EACH module with >= 2 entities. SKIP: Portal, pure config modules.
106
+
107
+ For EACH module:
108
+
109
+ ### 2a. Section/UX Research (MANDATORY)
110
+
111
+ ```
112
+ Query: "{module_domain} management system features screens views UX"
113
+ ```
114
+
115
+ Examples:
116
+ - "absence management system features screens views"
117
+ - "invoice management application features views UX"
118
+ - "CRM opportunity pipeline features screens"
119
+
120
+ **EXTRACT:**
121
+ - Standard sections/views (list, detail, calendar, kanban, etc.)
122
+ - **Contextual filtered views** — this is CRITICAL:
123
+ - Workflow modules: open-requests, rejected, history, my-{entity}
124
+ - Data modules: by-status, by-period, by-category
125
+ - Dashboard/reporting expectations
126
+ - Standard UX patterns (approval queue, batch actions, etc.)
127
+
128
+ ### 2b. Business Rules Research (MANDATORY for workflow modules)
129
+
130
+ ```
131
+ Query: "{module_domain} business rules validation constraints best practices"
132
+ ```
133
+
134
+ Examples:
135
+ - "absence leave management business rules HR constraints"
136
+ - "invoice billing business rules validation constraints"
137
+ - "CRM opportunity management business rules"
138
+
139
+ **EXTRACT:**
140
+ - **Domain-specific validation rules** (NOT just "date must be valid"):
141
+ - Half-day absences, notice periods, capacity limits
142
+ - Invoice sequential numbering, credit note linking
143
+ - Opportunity probability rules, stage-gate validation
144
+ - Calculation rules with formulas
145
+ - Workflow constraints and edge cases
146
+ - Regulatory/compliance requirements
147
+
148
+ ### 2c. Entity Design Research (1 per complex entity, OPTIONAL)
149
+
150
+ ```
151
+ Query: "{entity_name} entity design pattern ERP best practices"
152
+ ```
153
+
154
+ **EXTRACT:**
155
+ - Standard attributes for this entity type
156
+ - Versioned vs. inline data patterns (e.g., salary history)
157
+ - Common relationships and cardinality
158
+ - Known anti-patterns
159
+
160
+ ### Storage Format
161
+
162
+ ```yaml
163
+ {domain_research}.modules[{module_code}]:
164
+ sections:
165
+ standard: ["list", "detail", "approve", "calendar"]
166
+ contextualViews: ["open-requests", "rejected", "history", "my-balance"]
167
+ dashboard: ["absence-kpi", "team-calendar"]
168
+ businessRules:
169
+ domainSpecific:
170
+ - "Half-day absences (morning/afternoon)"
171
+ - "Minimum 48h notice for planned leave"
172
+ - "Max 30% of team absent simultaneously"
173
+ - "Carry-over days expire after March 31"
174
+ - "Medical certificate for absences > 3 days"
175
+ regulatory:
176
+ - "Minimum 25 days paid leave per year (France)"
177
+ entityPatterns:
178
+ Absence:
179
+ standardAttributes: ["employeeId", "typeId", "startDate", "endDate", "duration", "status", "halfDay"]
180
+ versionedData: []
181
+ workflowStates: ["Draft", "Submitted", "Approved", "Rejected", "Cancelled"]
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Level 3 : Recherche reglementaire (si applicable)
187
+
188
+ > **WHEN:** During step-01 for applicable domains, alongside Level 1 research.
189
+ > **WHO:** Billing/Finance, HR, any domain with legal requirements.
190
+
191
+ ### For Billing/Finance domains:
192
+ ```
193
+ Query: "{country} invoice legal requirements numbering format"
194
+ ```
195
+
196
+ **EXTRACT:** Sequential numbering, immutability of sent invoices, retention period, credit note requirements, VAT rules.
197
+
198
+ ### For HR domains:
199
+ ```
200
+ Query: "{country} absence leave legal requirements types"
201
+ ```
202
+
203
+ **EXTRACT:** Mandatory leave types, minimum days, carry-over rules, medical certificate requirements.
204
+
205
+ Store in: `{domain_research}.regulatory[]`
206
+
207
+ ---
208
+
209
+ ## Search Budget
210
+
211
+ | Project Type | Level 1 (per app) | Level 2 (per module) | Level 3 | Total |
212
+ |---|---|---|---|---|
213
+ | Single-app, 1-3 modules | 3 searches | 2/module = 4-6 | 0-2 | **7-11** |
214
+ | Single-app, 4-6 modules | 3 searches | 2/module = 8-12 | 0-2 | **11-17** |
215
+ | Multi-app (4 apps, ~10 modules) | 3/app = 12 | 2/module = 16-20 | 0-4 | **28-36** |
216
+
217
+ > **Token impact:** Each search returns ~500-1000 tokens. Total for a 4-app project: ~15K-30K tokens.
218
+ > This is a small price for dramatically improved analysis quality.
219
+
220
+ ---
221
+
222
+ ## Critical Notes
223
+
224
+ > **CRITICAL:** This research is INTERNAL context. Do NOT show raw search results to the client.
225
+ > Use the findings to:
226
+ > - **Challenge scope completeness** — flag CORE modules the user didn't mention
227
+ > - **Ground entity architecture** — use real-world data models, not guesswork
228
+ > - **Propose domain-specific business rules** — go beyond generic CRUD validation
229
+ > - **Anticipate contextual views** — workflow modules need filtered views
230
+ > - **Inform proactive suggestions** — "standard billing also includes credit notes because..."
231
+ > - **Prevent common anti-patterns** — catch mistakes before they become architecture
232
+
233
+ > **NEVER use research as an excuse to skip user validation.**
234
+ > Research INFORMS your proposals. The user VALIDATES them.
@@ -0,0 +1,166 @@
1
+ # Entity Sourcing Presentation (4-Phase Flow)
2
+
3
+ > **When the analysis detects a referenced entity/concept (e.g., "Projets" referenced by activities, "Clients" referenced by orders), ALWAYS analyze and recommend BEFORE asking the client.**
4
+ > This pattern detects potential new modules not mentioned in the original brief.
5
+
6
+ ## PHASE 1 — ULTRATHINK: Silent Architecture Analysis (NO output to client)
7
+
8
+ > **The AI reasons about the entity BEFORE presenting options. This is internal thinking only.**
9
+
10
+ ```
11
+ ULTRATHINK — Entity Architecture Analysis for {entity_name}:
12
+
13
+ 1. DOMAIN COHERENCE (from decision tree in reference)
14
+ - Application domain: {app_description}
15
+ - Entity fit: CORE | SUPPORT | PERIPHERAL
16
+ - Justification: {1 sentence — why this entity is/isn't core to the app}
17
+ - Example: "Projets" in a time management app = CORE (without projects, time entries have no target)
18
+ - Example: "Codes d'imputation" in a time management app = SUPPORT (useful for accounting, but not central)
19
+
20
+ 2. ENTITY SCORING (5 criteria, 0-3 each — from scoring grid in reference)
21
+ - Lifecycle: {score}/3 — {brief justification}
22
+ - Actors: {score}/3 — {brief justification}
23
+ - Relations: {score}/3 — {brief justification}
24
+ - Volume: {score}/3 — {brief justification}
25
+ - Autonomy: {score}/3 — {brief justification}
26
+ - TOTAL: {total}/15 → {classification: config_list | in_app | light_module | full_module}
27
+
28
+ 3. PRE-CLASSIFICATION CHECK (from entity patterns in reference)
29
+ - Does {entity_name} match a known pattern? → {yes: which one | no: use scoring}
30
+ - Override needed? → {yes: why | no}
31
+
32
+ 4. RECOMMENDATION
33
+ - Option: {config_list | in_app_section | new_module | external_system}
34
+ - Confidence: HIGH | MEDIUM | LOW
35
+ - Reasoning: {1-2 sentences}
36
+ - Risk if wrong choice: {what goes wrong if user picks a different option}
37
+
38
+ 5. IF recommendation = new_module → PRE-BUILD ARCHITECTURE
39
+ - Module code: {PascalCase}
40
+ - Section `list`: {main entity grid + create action + navigation to detail}
41
+ - Detail page tabs: [{tab_name: content}] (accessible by clicking a row in list)
42
+ - Additional sections: [{code: justification}] (ONLY functional sections: dashboard, approve, import, rapport...)
43
+ - Dependencies: [{which modules reference/are referenced by this entity}]
44
+ - Topological position: layer {N} (foundation if no dependencies)
45
+ ```
46
+
47
+ ## PHASE 2 — Present Analysis & Recommendation to Client
48
+
49
+ **BEFORE the AskUserQuestion, display the analysis as markdown:**
50
+
51
+ ```
52
+ ### {language == "fr" ? "Analyse" : "Analysis"} : {entity_plural}
53
+
54
+ {language == "fr"
55
+ ? "Les **{entity_plural}** sont référencés par {parent_module} ({relationship_description})."
56
+ : "**{entity_plural}** are referenced by {parent_module} ({relationship_description})."}
57
+
58
+ {language == "fr" ? "**Mon analyse :**" : "**My analysis:**"}
59
+ - {language == "fr" ? "Cohérence domaine" : "Domain coherence"} : **{CORE|SUPPORT|PERIPHERAL}** — {justification}
60
+ - {language == "fr" ? "Score de complexité" : "Complexity score"} : **{score}/15** ({classification})
61
+ - {language == "fr" ? "Recommandation" : "Recommendation"} : **{recommended_option}** — {reasoning}
62
+ ```
63
+
64
+ **IF recommendation = new_module AND confidence >= MEDIUM, ALSO display:**
65
+
66
+ ```
67
+ {language == "fr" ? "**Architecture proposée :**" : "**Proposed architecture:**"}
68
+
69
+ | {language == "fr" ? "Niveau" : "Level"} | {language == "fr" ? "Valeur" : "Value"} | {language == "fr" ? "Justification" : "Rationale"} |
70
+ |--------|--------|---------------|
71
+ | Application | `{app_code}` | {app_name} |
72
+ | Module | `{ModuleCode}` | {language == "fr" ? "{pourquoi ce découpage}" : "{why this decomposition}"} |
73
+
74
+ | Section | {language == "fr" ? "Justification" : "Rationale"} | Resources |
75
+ |---------|---------------|-----------|
76
+ | `list` | {language == "fr" ? "Page principale : grille, création, navigation vers détail" : "Main page: grid, create action, navigate to detail"} | {entity}-grid, {entity}-filters, {entity}-form |
77
+ | {additional_section} | {justification} | {resources} |
78
+
79
+ {language == "fr"
80
+ ? "**Page détail** (onglets accessibles depuis la liste) :"
81
+ : "**Detail page** (tabs accessible from list):"}
82
+
83
+ | {language == "fr" ? "Onglet" : "Tab"} | {language == "fr" ? "Contenu" : "Content"} |
84
+ |--------|---------|
85
+ | {language == "fr" ? "Informations" : "Information"} | {language == "fr" ? "Fiche principale" : "Main record"} |
86
+ | {tab_name} | {tab_content} |
87
+
88
+ {language == "fr"
89
+ ? "**Impact :** {ModuleName} deviendra une dépendance de {parent_module} (couche {N} du graphe)."
90
+ : "**Impact:** {ModuleName} will become a dependency of {parent_module} (layer {N} in the graph)."}
91
+ ```
92
+
93
+ ## PHASE 3 — Ask with Recommended Option First
94
+
95
+ **Order the options with the recommendation FIRST, marked "(Recommandé)" / "(Recommended)":**
96
+
97
+ ```
98
+ question: "{language == 'fr'
99
+ ? 'Comment souhaitez-vous gérer les {entity_plural} ?'
100
+ : 'How do you want to manage {entity_plural}?'}"
101
+ header: "{entity_name}"
102
+ options:
103
+ (ORDER: recommended option FIRST, then the 3 remaining options in logical order)
104
+
105
+ IF recommendation = new_module:
106
+ - label: "{language == 'fr' ? 'Nouveau module dédié (Recommandé)' : 'New dedicated module (Recommended)'}"
107
+ description: "{language == 'fr'
108
+ ? 'Module {ModuleCode} avec page liste, détail par onglets, permissions dédiées'
109
+ : '{ModuleCode} module with list page, tabbed detail, dedicated permissions'}"
110
+ - label: "{language == 'fr' ? 'Géré dans l\'app' : 'Managed in app'}"
111
+ description: "..."
112
+ - label: "{language == 'fr' ? 'Système externe' : 'External system'}"
113
+ description: "..."
114
+ - label: "{language == 'fr' ? 'Liste simple en config' : 'Simple config list'}"
115
+ description: "..."
116
+
117
+ IF recommendation = config_list:
118
+ - label: "{language == 'fr' ? 'Liste simple en config (Recommandé)' : 'Simple config list (Recommended)'}"
119
+ description: "{language == 'fr'
120
+ ? 'Table de référence administrable, pas de module dédié'
121
+ : 'Admin-managed reference table, no dedicated module'}"
122
+ - label: "{language == 'fr' ? 'Géré dans l\'app' : 'Managed in app'}"
123
+ description: "..."
124
+ - label: "{language == 'fr' ? 'Nouveau module dédié' : 'New dedicated module'}"
125
+ description: "..."
126
+ - label: "{language == 'fr' ? 'Système externe' : 'External system'}"
127
+ description: "..."
128
+
129
+ IF recommendation = in_app_section:
130
+ - label: "{language == 'fr' ? 'Géré dans l\'app (Recommandé)' : 'Managed in app (Recommended)'}"
131
+ description: "{language == 'fr'
132
+ ? 'Accessible via un onglet dans la page détail de {parent_module}'
133
+ : 'Accessible via a tab in {parent_module} detail page'}"
134
+ - label: "{language == 'fr' ? 'Nouveau module dédié' : 'New dedicated module'}"
135
+ description: "..."
136
+ - label: "{language == 'fr' ? 'Liste simple en config' : 'Simple config list'}"
137
+ description: "..."
138
+ - label: "{language == 'fr' ? 'Système externe' : 'External system'}"
139
+ description: "..."
140
+
141
+ IF recommendation = external_system:
142
+ - label: "{language == 'fr' ? 'Système externe (Recommandé)' : 'External system (Recommended)'}"
143
+ description: "{language == 'fr'
144
+ ? 'Les {entity_plural} viennent d\'un autre système (import ou API)'
145
+ : '{entity_plural} come from another system (import or API)'}"
146
+ - label: "{language == 'fr' ? 'Nouveau module dédié' : 'New dedicated module'}"
147
+ description: "..."
148
+ - label: "{language == 'fr' ? 'Géré dans l\'app' : 'Managed in app'}"
149
+ description: "..."
150
+ - label: "{language == 'fr' ? 'Liste simple en config' : 'Simple config list'}"
151
+ description: "..."
152
+
153
+ IF confidence = LOW (no clear recommendation):
154
+ (all 4 options in neutral order, NO "(Recommandé)" tag)
155
+ ```
156
+
157
+ ## PHASE 4 — Process Answer
158
+
159
+ | Choice | Action |
160
+ |--------|--------|
161
+ | **Géré dans l'app** | Entity becomes a sub-entity of the parent module. Add as a **tab in the detail page** of the referencing module. Note in coverageMatrix with `parentModule` field. |
162
+ | **Nouveau module dédié** | **Add new module to `{pre_analysis}.detected_modules[]`** with the proposed architecture (sections, detail tabs, dependencies). Add to `coverageMatrix` as inScope. The `list` section is ALWAYS the main section. Additional sections ONLY for distinct functional sections (dashboard, approve, import...). `create` and `edit` are ACTIONS within `list` and detail pages, NEVER standalone sections. |
163
+ | **Système externe** | Flag for integration specification. Add to `coverageMatrix` as integration. Load questionnaire materials on integrations if not already covered. |
164
+ | **Liste simple en config** | Entity becomes a lookup/reference table (no dedicated module, no section). Note in coverageMatrix as config data. |
165
+
166
+ > **CRITICAL:** The intelligence of this step is in the ULTRATHINK analysis. The AI must REASON about domain coherence, score the entity, and recommend — not just present 4 neutral options. The client can always override the recommendation, but they should benefit from expert architectural guidance.
@@ -0,0 +1,70 @@
1
+ # Initialize Resume Logic & Error Handling
2
+
3
+ > **Purpose:** Handle interruptions, resume previous workflows, and route based on status.
4
+ > Executed at the end of initialization to check if a workflow can be resumed.
5
+
6
+ ## Error Handling Matrix
7
+
8
+ | Error | Action |
9
+ |-------|--------|
10
+ | Config missing | Create fresh with defaults, continue |
11
+ | Directory creation fails | Check permissions, display error, EXIT |
12
+ | index.json creation fails | Validate ba-writer, retry or fallback |
13
+ | Feature ID not unique | Generate new ID, retry |
14
+
15
+ ## Resume After Interruption
16
+
17
+ If initialization was interrupted:
18
+
19
+ 1. Check `.business-analyse/config.json` for currentFeature or currentProject
20
+ 2. If project ID exists, search for project index.json in `docs/*/v*/` (or legacy `docs/business-analyse/`)
21
+ - If found with scope = "project": resume project mode (see Project Resume below)
22
+ 3. If feature ID exists, search for index.json in `docs/`
23
+ 4. If found, check status and `metadata.workflow.lastCompletedStep`
24
+
25
+ ## Status-Based Resume Routing (check in this order)
26
+
27
+ ### If status = `"handed-off"` or `"consolidated"`
28
+
29
+ → Display: "BA workflow complete. Use /business-analyse-html to generate HTML, /business-analyse-review for corrections."
30
+ → **STOP**
31
+
32
+ ### If status = `"specified"` AND `metadata.workflow.allModulesSpecified === true`
33
+
34
+ → Resume at `step-04-consolidate.md`
35
+ → Display: "All modules specified — resuming at consolidation..."
36
+
37
+ ### If status = `"specified"` AND `metadata.workflow.completedModules.length > 0` AND `metadata.workflow.completedModules.length < metadata.workflow.moduleOrder.length`
38
+
39
+ → Resume at `step-03-specify.md` (continue specifying remaining modules)
40
+ → Display: "Resuming module specification ({completedCount}/{totalCount})..."
41
+
42
+ ### Otherwise
43
+
44
+ → Offer to resume from last completed step
45
+
46
+ ### If not found
47
+
48
+ → Create fresh index.json
49
+
50
+ ## Project Resume (project mode)
51
+
52
+ If a project-level index.json is found (scope = "project"):
53
+
54
+ ### If status = `"draft"` or `"framed"`
55
+
56
+ → Resume at `step-01-cadrage.md`
57
+
58
+ ### If status = `"decomposed"`
59
+
60
+ → Check `metadata.workflow.currentApplicationIndex` and `completedApplications[]`
61
+ → Resume module specification for current application (step-02 or step-03)
62
+
63
+ ### If status = `"specified"`
64
+
65
+ → All applications specified → Resume at `step-04-consolidate.md`
66
+
67
+ ### If status = `"consolidated"`
68
+
69
+ → Display: "BA workflow complete. Use /business-analyse-html to generate HTML."
70
+ → **STOP**