@atlashub/smartstack-cli 3.35.0 → 3.36.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlashub/smartstack-cli",
3
- "version": "3.35.0",
3
+ "version": "3.36.0",
4
4
  "description": "SmartStack Claude Code automation toolkit - GitFlow, EF Core migrations, prompts and more",
5
5
  "author": {
6
6
  "name": "SmartStack",
@@ -39,6 +39,7 @@ Execute incremental SmartStack development using the APEX methodology. This skil
39
39
  | `-r` | Resume: continue from previous state |
40
40
  | `-pr` | PR mode: create pull request at end |
41
41
  | `-d {path}` | Delegate mode: read context from PRD file at `{path}`. Implies `-a -e`. Used by `/ralph-loop`. |
42
+ | `--foundation` | Foundation mode: generate ONLY entities + EF configs + migration. No services/controllers/frontend. Used by ralph-loop Phase 0. |
42
43
 
43
44
  </parameters>
44
45
 
@@ -55,6 +56,7 @@ Execute incremental SmartStack development using the APEX methodology. This skil
55
56
  | `{pr_mode}` | boolean | Create PR at end |
56
57
  | `{delegate_mode}` | boolean | Delegated by `/ralph-loop` via `-d` flag |
57
58
  | `{delegate_prd_path}` | string? | Path to PRD file (`.ralph/prd.json` or `.ralph/prd-{module}.json`) |
59
+ | `{foundation_mode}` | boolean | Foundation mode: entities-only (no services/controllers/frontend). Used by ralph-loop Phase 0. |
58
60
  | `{context_code}` | string | "business", "platform", "personal" |
59
61
  | `{app_name}` | string | Application name |
60
62
  | `{module_code}` | string | Module code |
@@ -131,6 +133,7 @@ Execute incremental SmartStack development using the APEX methodology. This skil
131
133
  - **Save outputs** if `{save_mode}` = true
132
134
  - **Commits per layer** - Atomic commits after each execution layer
133
135
  - **Delegate mode** (`-d`): Read PRD context, skip challenge questions, auto+economy mode implied. Used when `/ralph-loop` delegates code generation to `/apex`.
136
+ - **Foundation mode** (`--foundation`): Generate ONLY entities + EF configs + migration (domain + infrastructure layers). Skip application/api/frontend/tests. Used by ralph-loop Phase 0 to create database foundation before spawning parallel teammates.
134
137
 
135
138
  </execution_rules>
136
139
 
@@ -28,7 +28,7 @@ Extract flags from the raw input:
28
28
  ```
29
29
  Input: "{raw_input}"
30
30
 
31
- Flags to detect: -a, -x, -s, -e, -r, -pr, -d {path}
31
+ Flags to detect: -a, -x, -s, -e, -r, -pr, -d {path}, --foundation
32
32
  Remaining text after flag removal = {task_description}
33
33
  ```
34
34
 
@@ -43,10 +43,13 @@ pr_mode: false
43
43
  resume_mode: false
44
44
  delegate_mode: false
45
45
  delegate_prd_path: null
46
+ foundation_mode: false
46
47
  ```
47
48
 
48
49
  **If `-d {path}` detected:** set `delegate_mode = true`, `delegate_prd_path = {path}`, force `auto_mode = true`, `economy_mode = true`.
49
50
 
51
+ **If `--foundation` detected:** set `foundation_mode = true`, force `auto_mode = true`. Foundation mode generates ONLY entities + EF configs + migration (domain + infrastructure layers). Skip application/api/frontend/tests.
52
+
50
53
  ---
51
54
 
52
55
  ## 1b. Delegate Mode Fast Path (if -d)
@@ -22,6 +22,28 @@ All code goes through skills (/controller, /application, /ui-components, /efcore
22
22
 
23
23
  ---
24
24
 
25
+ ## Foundation Mode Detection
26
+
27
+ **IF `{foundation_mode}` == true:**
28
+
29
+ This is a foundation-only execution (called by ralph-loop Phase 0). Execute ONLY:
30
+ - Layer 0: Domain entities + EF configs + Migration
31
+
32
+ **SKIP ALL OTHER LAYERS:**
33
+ - Layer 1: Application + API + Seed Data → SKIP
34
+ - Layer 2: Frontend → SKIP
35
+ - Layer 3: Tests → SKIP
36
+
37
+ After Layer 0 completes and builds successfully:
38
+ - Commit with message: `chore(foundation): entities for {module_code}`
39
+ - Jump to step-04 for POST-CHECKs (domain + infrastructure only)
40
+ - End execution
41
+
42
+ **IF `{foundation_mode}` == false:**
43
+ Execute ALL layers normally (Layer 0 → Layer 1 → Layer 2 → Layer 3).
44
+
45
+ ---
46
+
25
47
  ## Layer 0 — Domain + Infrastructure (sequential, agent principal)
26
48
 
27
49
  ### Domain Entities
@@ -81,7 +81,68 @@ Identify the specific name:
81
81
 
82
82
  ### STEP 3: EXECUTION
83
83
 
84
- **For NEW documentation (type = user|developer|database|testing):**
84
+ **For NEW documentation (type = user) - AUTOMATIC MOCK UI GENERATION:**
85
+
86
+ Use the automated generator script that creates complete documentation with Mock UI components:
87
+
88
+ ```bash
89
+ npx tsx scripts/generate-doc-with-mock-ui.ts \
90
+ --module {module} \
91
+ --context {context} \
92
+ --application {application} \
93
+ --app-path "D:/01 - projets/SmartStack.app/02-Develop"
94
+ ```
95
+
96
+ **What it does automatically:**
97
+
98
+ 1. **Find & Extract Entity** (e.g., users → User.cs)
99
+ - Locates Domain entity file
100
+ - Extracts all properties with types
101
+
102
+ 2. **Extract API Endpoints** (via `extract-api-endpoints.ts`)
103
+ - Scans controller for all endpoints
104
+ - Parses `[HttpGet]`, `[HttpPost]`, `[NavRoute]`, `[RequirePermission]`
105
+ - Resolves permission constants
106
+ - Output: JSON array of endpoints with method, path, handler, permission
107
+
108
+ 3. **Extract Business Rules** (via `extract-business-rules.ts`)
109
+ - Scans Domain entity for guard clauses and DomainExceptions
110
+ - Scans unit tests for edge case scenarios
111
+ - Auto-assigns BR-XXX IDs and categorizes rules
112
+ - Output: JSON array of business rules with id, name, category, statement
113
+
114
+ 4. **Generate Mock UI Components**
115
+ - **KPIs**: Automatic stats based on entity properties
116
+ - Total count
117
+ - Active/Inactive (if IsActive property)
118
+ - Status breakdown (if Status property)
119
+ - Time-based stats (if DateTime property)
120
+ - **Table**: Smart column selection (6 most relevant properties)
121
+ - Filters out: Hash, Token, *Id (FK), normalized, internal fields
122
+ - Prioritizes: name/title → email → status → date
123
+ - **Form**: Create form with intelligent field types
124
+ - Email → type="email" with placeholder
125
+ - Bool → checkbox
126
+ - DateTime → type="date"
127
+ - Description/Notes → textarea
128
+ - Default → type="text"
129
+
130
+ 5. **Generate Complete TSX File**
131
+ - Full React component with breadcrumb, sections, mock data
132
+ - Section 1: Introduction
133
+ - Section 2: Access (navigation path + URL)
134
+ - Section 3: Interface Overview (KPIs + Table Mock UI)
135
+ - Section 4: Create Form (generated form fields)
136
+ - Section 5: API Reference (endpoints table)
137
+
138
+ 6. **Manual Steps (Post-Generation)**
139
+ - Save generated TSX to `docs/business/{context}/{application}/{module}/index.tsx`
140
+ - Update docs-manifest.json
141
+ - Update App.tsx routing
142
+ - Update DocPanelContext.tsx mapping
143
+ - Generate i18n FR file (if needed)
144
+
145
+ **For NEW documentation (type = developer|database|testing):**
85
146
 
86
147
  Follow the data-driven workflow from [templates.md](templates.md):
87
148
 
@@ -92,22 +153,127 @@ Follow the data-driven workflow from [templates.md](templates.md):
92
153
  4. Generate i18n FR file (source language only)
93
154
  5. Update docs-manifest.json
94
155
  6. Update App.tsx routing and parent indexes
95
- 7. Update DocPanelContext.tsx mapping (contextual doc panel)
96
156
  ```
97
157
 
98
158
  **For UPDATE documentation (type = update):**
99
159
 
160
+ Re-run the generator script to refresh automatically extracted data:
161
+
100
162
  ```
101
- 1. Read docs-manifest.jsonfind target module
102
- 2. Invoke docs-context-reader agent get current doc state
103
- 3. Identify code changes since last doc update (git diff)
104
- 4. Map changes to documentation sections (see data-schema.md)
105
- 5. Update doc-data.ts with new/modified data
106
- 6. Update i18n FR file if labels changed
107
- 7. Update docs-manifest.json timestamps
163
+ 1. Run generate-doc-with-mock-ui.tsregenerates with latest API/rules
164
+ 2. Update i18n FR file if labels changed
165
+ 3. Update docs-manifest.json timestamps
108
166
  ```
109
167
 
110
168
  > **i18n simplifié:** Seul FR (source) est généré. EN/IT/DE sont déférés à un pipeline de traduction séparé.
169
+
170
+ ---
171
+
172
+ ## EXTRACTION SCRIPTS REFERENCE
173
+
174
+ ### extract-api-endpoints.ts
175
+
176
+ **Purpose:** Extract all API endpoints from SmartStack controllers
177
+
178
+ **Input:**
179
+ - `--module {module}` - Module name (e.g., users, tenants)
180
+ - `--app-path {path}` - Path to SmartStack.app
181
+
182
+ **What it extracts:**
183
+ - Controller file path (e.g., `UsersController.cs`)
184
+ - HTTP method (`[HttpGet]`, `[HttpPost]`, `[HttpPut]`, `[HttpDelete]`, `[HttpPatch]`)
185
+ - Route suffix (e.g., `{id:guid}`, `activate`)
186
+ - Base path from `[NavRoute("platform.administration.users")]`
187
+ - Permission from `[RequirePermission(Permissions.Admin.Users.View)]`
188
+ - Handler method name
189
+
190
+ **Output:** JSON array
191
+ ```json
192
+ [
193
+ {
194
+ "method": "GET",
195
+ "path": "/api/platform/administration/users",
196
+ "handler": "GetUsers",
197
+ "permission": "platform.administration.users.read"
198
+ }
199
+ ]
200
+ ```
201
+
202
+ **Permission resolution:**
203
+ - Loads `Permissions.cs` constants
204
+ - Maps `Permissions.Admin.Users.View` → `"platform.administration.users.read"`
205
+
206
+ ---
207
+
208
+ ### extract-business-rules.ts
209
+
210
+ **Purpose:** Extract business rules from Domain entities and unit tests
211
+
212
+ **Input:**
213
+ - `--module {module}` - Module name (e.g., users, tenants)
214
+ - `--app-path {path}` - Path to SmartStack.app
215
+
216
+ **Phase 1: Domain Entity Extraction**
217
+ - Scans Domain entity (e.g., `User.cs`)
218
+ - Looks for guard clauses: `if (...) throw new DomainException("...")`
219
+ - Looks for validation in Create/Update methods
220
+ - Extracts exception messages and context
221
+
222
+ **Phase 2: Unit Tests Extraction**
223
+ - Scans unit test file (e.g., `UserTests.cs`)
224
+ - Looks for test methods with `[Fact]` attribute
225
+ - Extracts test names and scenarios (edge cases)
226
+ - Maps to business rule statements
227
+
228
+ **Output:** JSON array
229
+ ```json
230
+ [
231
+ {
232
+ "id": "BR-001",
233
+ "name": "Email requis",
234
+ "category": "Validation",
235
+ "statement": "Un utilisateur doit avoir une adresse email valide et non vide"
236
+ }
237
+ ]
238
+ ```
239
+
240
+ **Auto-categorization:**
241
+ - Validation: Required fields, format checks
242
+ - Security: Password rules, access control
243
+ - Business Logic: State transitions, calculations
244
+
245
+ ---
246
+
247
+ ### generate-doc-with-mock-ui.ts
248
+
249
+ **Purpose:** Main generator - creates complete documentation TSX with Mock UI
250
+
251
+ **Input:**
252
+ - `--module {module}` - Module name (e.g., users)
253
+ - `--context {context}` - Context (e.g., platform)
254
+ - `--application {application}` - Application (e.g., administration)
255
+ - `--app-path {path}` - Path to SmartStack.app
256
+
257
+ **Workflow:**
258
+ 1. Find Domain entity file (users → User.cs via singularize)
259
+ 2. Extract entity properties (name, type, nullable, required)
260
+ 3. Call `extract-api-endpoints.ts`
261
+ 4. Call `extract-business-rules.ts`
262
+ 5. Generate mock data (5 sample records with realistic values)
263
+ 6. Generate KPI stats (Total, Active/Inactive, Status breakdown)
264
+ 7. Generate table UI (smart column selection - 6 most relevant)
265
+ 8. Generate form UI (intelligent field types based on property)
266
+ 9. Output complete TSX file to stdout
267
+
268
+ **Smart Features:**
269
+ - **Singularize**: users → User.cs, tenants → Tenant.cs
270
+ - **Property filtering**: Excludes hash, token, *Id, normalized, internal
271
+ - **Priority selection**: name/title > email > status > date
272
+ - **Field type detection**: email → email input, bool → checkbox
273
+ - **Mock value generation**: Realistic emails, names, dates, GUIDs
274
+
275
+ **Output:** Complete React TSX component (400-500 lines)
276
+
111
277
  </workflow>
112
278
 
113
279
  <execution_rules>
@@ -55,10 +55,11 @@ echo "DbContext Type: $DBCONTEXT_TYPE"
55
55
 
56
56
  const result = await mcp__smartstack__suggest_migration({
57
57
  description: DESCRIPTION,
58
- context: DBCONTEXT_TYPE // NEVER hardcode!
58
+ context: DBCONTEXT_TYPE, // NEVER hardcode!
59
+ squash: true // Squash format: {context}_v{version} (no sequence/description)
59
60
  });
60
61
 
61
- // Result example: core_v1.9.0_001_MultitenantConsolidated
62
+ // Result example: core_v1.9.0 (squash — just version, no _001_Description)
62
63
  MIGRATION_NAME = result.migrationName;
63
64
  ```
64
65
 
@@ -66,11 +67,12 @@ MIGRATION_NAME = result.migrationName;
66
67
  - Calculating name manually
67
68
  - Hardcoding context as "core"
68
69
  - Using underscores instead of dots in version
70
+ - Adding sequence/description to squash migrations
69
71
 
70
72
  ### 3. Create Migration with EF Core
71
73
 
72
74
  ```bash
73
- # MIGRATION_NAME = result from MCP (e.g., core_v1.9.0_001_MultitenantConsolidated)
75
+ # MIGRATION_NAME = result from MCP (e.g., core_v1.9.0)
74
76
  # DBCONTEXT = CoreDbContext or ExtensionsDbContext (from detect_dbcontext)
75
77
 
76
78
  echo ""
@@ -211,7 +213,7 @@ After step-03-create:
211
213
 
212
214
  | Variable | Description |
213
215
  |----------|-------------|
214
- | `{migration_name}` | Name from MCP (e.g., core_v1.9.0_001_...) |
216
+ | `{migration_name}` | Name from MCP (e.g., core_v1.9.0) |
215
217
  | `{migration_file}` | Full path to .cs file |
216
218
  | `{designer_file}` | Full path to .Designer.cs file |
217
219
 
@@ -462,7 +462,9 @@ GitFlow configuration JSON template v2.1.0 (aligned with `templates/config.json`
462
462
  "enabled": true,
463
463
  "validateOnCommit": true,
464
464
  "blockDestructive": true,
465
- "migrationNaming": "{context}_v{version}_{sequence}_{Description}"
465
+ "migrationNaming": "{context}_v{version}_{sequence}_{Description}",
466
+ "migrationNamingSquash": "{context}_v{version}",
467
+ "squashBeforePR": true
466
468
  },
467
469
  "workflow": {
468
470
  "push": {
@@ -122,6 +122,40 @@ else
122
122
  fi
123
123
  ```
124
124
 
125
+ ### 4b. Enforce Migration Squash (Feature Branches)
126
+
127
+ **BLOCKING**: Feature branches must have at most 1 migration before creating a PR.
128
+
129
+ ```bash
130
+ if [ "$BRANCH_TYPE" = "feature" ]; then
131
+ MIGRATION_DIR=$(find . -path "*/Persistence/Migrations" -type d 2>/dev/null | head -1)
132
+ if [ -n "$MIGRATION_DIR" ]; then
133
+ # Count migration .cs files added by this feature (not in target branch)
134
+ NEW_MIGRATIONS=$(git diff --name-only "origin/$TARGET_BRANCH...HEAD" -- "$MIGRATION_DIR" \
135
+ | grep -E '\.cs$' \
136
+ | grep -v 'Designer\|ModelSnapshot' \
137
+ | wc -l)
138
+
139
+ if [ "$NEW_MIGRATIONS" -gt 1 ]; then
140
+ echo ""
141
+ echo "❌ MULTIPLE MIGRATIONS DETECTED ($NEW_MIGRATIONS migrations)"
142
+ echo "→ Feature branches must have exactly 1 migration (squashed) before PR"
143
+ echo "→ Run: /efcore squash"
144
+ echo ""
145
+ echo "Migrations found:"
146
+ git diff --name-only "origin/$TARGET_BRANCH...HEAD" -- "$MIGRATION_DIR" \
147
+ | grep -E '\.cs$' \
148
+ | grep -v 'Designer\|ModelSnapshot'
149
+ STOP
150
+ elif [ "$NEW_MIGRATIONS" -eq 1 ]; then
151
+ echo "✓ Single migration detected (squashed)"
152
+ else
153
+ echo "✓ No migrations in this feature"
154
+ fi
155
+ fi
156
+ fi
157
+ ```
158
+
125
159
  ### 5. Generate PR Content
126
160
 
127
161
  **Title:**
@@ -36,6 +36,7 @@ Execute the Ralph Weegund technique — iterative module orchestration. Ralph re
36
36
  | `-c TEXT` | `--completion-promise TEXT` | Completion signal text |
37
37
  | `-v` | `--verbose` | Detailed logging |
38
38
  | `-r` | `--resume` | Resume from previous state |
39
+ | `-p` | `--parallel` | Teams mode: Phase 0 (entities) sequential, then spawn parallel teammates per application/module |
39
40
  </parameters>
40
41
 
41
42
  <workflow>
@@ -50,9 +51,30 @@ Execute the Ralph Weegund technique — iterative module orchestration. Ralph re
50
51
  - Find eligible → batch by category (max 5) → execute → test → commit → loop
51
52
  7. Report (step-05)
52
53
 
53
- **Multi-module (2+ modules, from BA handoff):**
54
+ **Multi-module (2+ modules) with `-p` (parallel mode):**
55
+ 1. Init: detect prd-*.json, parse `-p` flag (step-00)
56
+ 2. **Phase 0 (Ralph sequential):**
57
+ - Ralph generates ALL entities from ALL modules via `/apex --foundation`
58
+ - Creates ONE migration with all entities
59
+ - Commits: `chore(foundation): entities for all modules`
60
+ 3. **Phase 1-N (Teams parallel):**
61
+ ```
62
+ Team Lead → TeamCreate("smartstack-{project}")
63
+ Spawn teammates (1 per application OR 1 per module if app > 3 modules):
64
+ - Task(subagent_type: "apex", name: "apex-hr")
65
+ - Task(subagent_type: "apex", name: "apex-crm")
66
+ - Task(subagent_type: "apex", name: "apex-pm")
67
+ Each teammate generates:
68
+ - Services + Controllers + Seed data + Frontend + Tests
69
+ - NO entities (already done in Phase 0)
70
+ - NO migrations (ModelSnapshot already complete)
71
+ → Teammates work in parallel → Ralph collects results → TeamDelete
72
+ ```
73
+ 4. Report with per-module aggregation (step-05)
74
+
75
+ **Multi-module (2+ modules) WITHOUT `-p` (sequential mode — legacy):**
54
76
  1. Init: detect prd-*.json, read dependency layers (step-00)
55
- 2. **IF dependency graph available:** Agent Teams (parallel)
77
+ 2. **IF dependency graph available:** Agent Teams (parallel, legacy)
56
78
  ```
57
79
  Team Lead → TeamCreate("ralph-{app}")
58
80
  Layer 0: Spawn "mod-employees" (foundation) → wait LAYER_READY
@@ -81,6 +103,8 @@ LOAD → DELEGATE TO /apex -d → VERIFY PRD STATE → COMMIT PRD → NEXT MODUL
81
103
  | `{modules_queue}` | object\|null | Module queue (multi-module) |
82
104
  | `{section_split_mode}` | boolean | Section splitting active for current module (>4 entities + >1 section) |
83
105
  | `{section_phases}` | SectionPhase[] | Phase execution plan (Phase 0: foundation, Phase 1..N: per-section) |
106
+ | `{parallel_mode}` | boolean | Teams mode enabled via `-p` flag. Ralph generates Phase 0 (entities) sequentially, then spawns parallel teammates. |
107
+ | `{team_name}` | string\|null | Team name for parallel mode (e.g., "smartstack-hr") |
84
108
  </state_variables>
85
109
 
86
110
  <mcp_requirements>