@atlashub/smartstack-cli 2.7.3 → 2.7.4
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/.documentation/agents.html +0 -4
- package/.documentation/business-analyse.html +0 -4
- package/.documentation/cli-commands.html +0 -4
- package/.documentation/commands.html +0 -77
- package/.documentation/css/styles.css +0 -8
- package/.documentation/efcore.html +0 -4
- package/.documentation/gitflow.html +0 -4
- package/.documentation/hooks.html +0 -4
- package/.documentation/index.html +2 -28
- package/.documentation/init.html +8 -14
- package/.documentation/installation.html +0 -11
- package/.documentation/js/app.js +2 -16
- package/.documentation/ralph-loop.html +0 -4
- package/.documentation/test-web.html +0 -4
- package/README.md +0 -1
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/templates/agents/docs-sync-checker.md +2 -2
- package/templates/hooks/docs-drift-check.md +4 -5
- package/templates/skills/_resources/context-digest-template.md +2 -2
- package/templates/skills/_resources/doc-context-cache.md +0 -2
- package/templates/skills/_resources/docs-manifest-schema.md +1 -3
- package/templates/skills/_resources/mcp-validate-documentation-spec.md +1 -3
- package/templates/skills/_shared.md +24 -25
- package/templates/skills/application/steps/step-04-backend.md +185 -11
- package/templates/skills/application/steps/step-06-migration.md +41 -2
- package/templates/skills/application/templates-seed.md +151 -0
- package/templates/skills/business-analyse/steps/step-05-handoff.md +59 -17
- package/templates/skills/controller/steps/step-01-analyze.md +1 -1
- package/templates/skills/ralph-loop/steps/step-01-task.md +21 -1
- package/templates/skills/ralph-loop/steps/step-02-execute.md +75 -3
- package/.documentation/apex.html +0 -1027
- package/templates/skills/apex/SKILL.md +0 -297
- package/templates/skills/apex/steps/step-00-init.md +0 -212
- package/templates/skills/apex/steps/step-01-analyze.md +0 -263
- package/templates/skills/apex/steps/step-02-plan.md +0 -255
- package/templates/skills/apex/steps/step-03-execute.md +0 -217
- package/templates/skills/apex/steps/step-04-validate.md +0 -273
- package/templates/skills/apex/steps/step-04b-doc-sync.md +0 -162
- package/templates/skills/apex/steps/step-05-examine.md +0 -214
- package/templates/skills/apex/steps/step-06-resolve.md +0 -181
- package/templates/skills/apex/steps/step-07-tests.md +0 -206
- package/templates/skills/apex/steps/step-08-run-tests.md +0 -207
- package/templates/skills/apex/templates/00-context.md +0 -46
- package/templates/skills/apex/templates/01-analyze.md +0 -63
- package/templates/skills/apex/templates/02-plan.md +0 -63
- package/templates/skills/apex/templates/03-execute.md +0 -34
- package/templates/skills/apex/templates/04-validate.md +0 -61
- package/templates/skills/apex/templates/04b-doc-sync.md +0 -31
- package/templates/skills/apex/templates/05-examine.md +0 -58
- package/templates/skills/apex/templates/06-resolve.md +0 -39
- package/templates/skills/apex/templates/07-tests.md +0 -56
- package/templates/skills/apex/templates/08-run-tests.md +0 -41
- package/templates/skills/apex/templates/README.md +0 -69
- package/templates/skills/apex/templates/context-digest.md +0 -35
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlashub/smartstack-cli",
|
|
3
|
-
"version": "2.7.
|
|
4
|
-
"description": "SmartStack Claude Code automation toolkit - GitFlow,
|
|
3
|
+
"version": "2.7.4",
|
|
4
|
+
"description": "SmartStack Claude Code automation toolkit - GitFlow, EF Core migrations, prompts and more",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SmartStack",
|
|
7
7
|
"email": "contact@smartstack.app",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"claude",
|
|
42
42
|
"claude-code",
|
|
43
43
|
"gitflow",
|
|
44
|
-
"apex",
|
|
45
44
|
"efcore",
|
|
46
45
|
"entity-framework",
|
|
47
46
|
"migrations",
|
|
@@ -93,11 +93,11 @@ For each drifted module, identify the type of changes:
|
|
|
93
93
|
- `src/.../CreateSlaCommand.cs` → Use Cases section
|
|
94
94
|
|
|
95
95
|
### Recommended Action
|
|
96
|
-
Run `/
|
|
96
|
+
Run `/documentation:update business/support/sla` to sync documentation
|
|
97
97
|
|
|
98
98
|
## Actions Required
|
|
99
99
|
|
|
100
|
-
1. **DRIFT modules ({count}):** Run `/
|
|
100
|
+
1. **DRIFT modules ({count}):** Run `/documentation` to update
|
|
101
101
|
2. **MISSING modules ({count}):** Run `/business-analyse` to create documentation
|
|
102
102
|
3. **SYNCED modules ({count}):** No action needed
|
|
103
103
|
```
|
|
@@ -60,7 +60,7 @@ if [ "$DRIFT_FOUND" = true ]; then
|
|
|
60
60
|
echo "Documentation drift detected:"
|
|
61
61
|
echo -e "$DRIFT_MODULES"
|
|
62
62
|
echo ""
|
|
63
|
-
echo "Consider running /
|
|
63
|
+
echo "Consider running /documentation to update."
|
|
64
64
|
echo ""
|
|
65
65
|
fi
|
|
66
66
|
|
|
@@ -85,13 +85,12 @@ exit 0
|
|
|
85
85
|
## Integration
|
|
86
86
|
|
|
87
87
|
This hook integrates with:
|
|
88
|
-
- `docs-manifest.json` (created by BA step-06
|
|
89
|
-
- `/
|
|
90
|
-
- `/documentation` skill for manual documentation updates
|
|
88
|
+
- `docs-manifest.json` (created by BA step-06)
|
|
89
|
+
- `/documentation` skill for documentation updates
|
|
91
90
|
|
|
92
91
|
## Notes
|
|
93
92
|
|
|
94
93
|
- **Non-blocking by design:** Documentation drift should never prevent commits
|
|
95
|
-
- The warning suggests running `/
|
|
94
|
+
- The warning suggests running `/documentation` to update
|
|
96
95
|
- If `jq` is not installed, the hook silently exits (graceful degradation)
|
|
97
96
|
- Cross-platform: Works on Linux, macOS, and Windows (Git Bash/WSL)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
Reduces token usage between multi-step skill executions (
|
|
5
|
+
Reduces token usage between multi-step skill executions (BA, ralph-loop) by compressing step outputs into compact summaries.
|
|
6
6
|
|
|
7
7
|
## How It Works
|
|
8
8
|
|
|
@@ -41,8 +41,8 @@ Step N+1 reads:
|
|
|
41
41
|
|
|
42
42
|
## Applies To
|
|
43
43
|
|
|
44
|
-
- APEX skill (all step transitions)
|
|
45
44
|
- BA skill (between phases)
|
|
45
|
+
- Ralph-loop skill (between tasks)
|
|
46
46
|
- Any future multi-step skill
|
|
47
47
|
|
|
48
48
|
## Resume Exception
|
|
@@ -56,7 +56,5 @@ Caches the output of `docs-context-reader` agent to avoid redundant documentatio
|
|
|
56
56
|
|
|
57
57
|
| Consumer | Check Cache? |
|
|
58
58
|
|----------|-------------|
|
|
59
|
-
| APEX step-01 (analyze) | Yes |
|
|
60
|
-
| APEX step-04b (doc-sync) | Yes |
|
|
61
59
|
| BA step-01 (discover) | Yes |
|
|
62
60
|
| docs-sync-checker agent | No (always fresh) |
|
|
@@ -72,7 +72,7 @@ The `docs-manifest.json` file maps code modules to their documentation artifacts
|
|
|
72
72
|
| Status | Meaning | Action |
|
|
73
73
|
|--------|---------|--------|
|
|
74
74
|
| `synced` | Documentation matches code | No action needed |
|
|
75
|
-
| `drift` | Code changed after last doc update | Run `/
|
|
75
|
+
| `drift` | Code changed after last doc update | Run `/documentation` to update |
|
|
76
76
|
| `missing` | Module exists in code but has no documentation | Run `/business-analyse` or `/documentation` to create |
|
|
77
77
|
|
|
78
78
|
## Usage
|
|
@@ -84,13 +84,11 @@ The `docs-manifest.json` file maps code modules to their documentation artifacts
|
|
|
84
84
|
### Read by
|
|
85
85
|
- `docs-context-reader` agent (for context injection)
|
|
86
86
|
- `docs-sync-checker` agent (for drift detection)
|
|
87
|
-
- APEX step-04b (doc-sync) to identify affected modules
|
|
88
87
|
- BA step-04 (validate) for freshness check
|
|
89
88
|
- Drift hook (pre-commit) for commit warnings
|
|
90
89
|
|
|
91
90
|
### Updated by
|
|
92
91
|
- BA step-06 (on doc generation)
|
|
93
|
-
- APEX step-04b (on doc sync)
|
|
94
92
|
- Documentation skill (on doc update)
|
|
95
93
|
|
|
96
94
|
## Drift Detection Logic
|
|
@@ -159,7 +159,7 @@ FOR each module:
|
|
|
159
159
|
}
|
|
160
160
|
],
|
|
161
161
|
"recommendations": [
|
|
162
|
-
"Run `/
|
|
162
|
+
"Run `/documentation` for business/support/sla to sync documentation",
|
|
163
163
|
"Run `/business-analyse` for business/support/tickets to create documentation"
|
|
164
164
|
]
|
|
165
165
|
}
|
|
@@ -169,9 +169,7 @@ FOR each module:
|
|
|
169
169
|
|
|
170
170
|
| Consumer | When | Fallback |
|
|
171
171
|
|----------|------|----------|
|
|
172
|
-
| APEX step-04b (doc-sync) | After code validation | `docs-sync-checker` agent |
|
|
173
172
|
| BA step-04 (validate) | During specification validation | Read manifest + git log |
|
|
174
|
-
| APEX step-05 (examine) | During adversarial review | Manual checklist |
|
|
175
173
|
| Drift hook (pre-commit) | Before commit | Bash script reading manifest |
|
|
176
174
|
|
|
177
175
|
## Implementation Notes
|
|
@@ -160,7 +160,6 @@ If MCP is not available, display this message and **STOP the skill immediately**
|
|
|
160
160
|
| business-analyse | **YES** | Analysis, specification, validation |
|
|
161
161
|
| application | **YES** | Navigation + code generation |
|
|
162
162
|
| controller | **YES** | Controller scaffolding |
|
|
163
|
-
| apex | **YES** | Generation + validation |
|
|
164
163
|
| ralph-loop | **YES** | Iterative code generation |
|
|
165
164
|
| validate | **YES** | Convention validation |
|
|
166
165
|
| efcore | **YES** | Migration management |
|
|
@@ -173,38 +172,38 @@ If MCP is not available, display this message and **STOP the skill immediately**
|
|
|
173
172
|
|
|
174
173
|
### Outils Core
|
|
175
174
|
|
|
176
|
-
| Tool | Usage |
|
|
177
|
-
|
|
178
|
-
| `mcp__smartstack__validate_conventions` | Valider conventions SmartStack (tables, migrations, services, namespaces, entities, tenants, controllers) |
|
|
179
|
-
| `mcp__smartstack__scaffold_extension` | Génération code (feature, entity, service, controller, component, dto, validator, repository) |
|
|
180
|
-
| `mcp__smartstack__check_migrations` | Analyser migrations EF Core (conflits, ordre, ModelSnapshot) |
|
|
181
|
-
| `mcp__smartstack__api_docs` | Documentation API depuis Swagger/OpenAPI ou controllers |
|
|
182
|
-
| `mcp__smartstack__suggest_migration` | Suggérer nom migration ({context}_v{version}_{sequence}_{Description}) |
|
|
183
|
-
| `mcp__smartstack__generate_permissions` | Générer permissions RBAC depuis NavRoute |
|
|
175
|
+
| Tool | Usage | Used By |
|
|
176
|
+
|------|-------|---------|
|
|
177
|
+
| `mcp__smartstack__validate_conventions` | Valider conventions SmartStack (tables, migrations, services, namespaces, entities, tenants, controllers) | application, controller, ralph-loop |
|
|
178
|
+
| `mcp__smartstack__scaffold_extension` | Génération code (feature, entity, service, controller, component, dto, validator, repository) | application, ralph-loop |
|
|
179
|
+
| `mcp__smartstack__check_migrations` | Analyser migrations EF Core (conflits, ordre, ModelSnapshot) | application, ralph-loop |
|
|
180
|
+
| `mcp__smartstack__api_docs` | Documentation API depuis Swagger/OpenAPI ou controllers | controller |
|
|
181
|
+
| `mcp__smartstack__suggest_migration` | Suggérer nom migration ({context}_v{version}_{sequence}_{Description}) | application, ralph-loop |
|
|
182
|
+
| `mcp__smartstack__generate_permissions` | Générer permissions RBAC depuis NavRoute | application, ralph-loop |
|
|
184
183
|
|
|
185
184
|
### Outils Tests
|
|
186
185
|
|
|
187
|
-
| Tool | Usage |
|
|
188
|
-
|
|
189
|
-
| `mcp__smartstack__scaffold_tests` | Générer tests unitaires/intégration/sécurité |
|
|
190
|
-
| `mcp__smartstack__analyze_test_coverage` | Analyser couverture de tests du projet |
|
|
191
|
-
| `mcp__smartstack__validate_test_conventions` | Valider conventions de nommage des tests |
|
|
192
|
-
| `mcp__smartstack__suggest_test_scenarios` | Suggérer scénarios de test basés sur le code |
|
|
186
|
+
| Tool | Usage | Used By |
|
|
187
|
+
|------|-------|---------|
|
|
188
|
+
| `mcp__smartstack__scaffold_tests` | Générer tests unitaires/intégration/sécurité | application, ralph-loop |
|
|
189
|
+
| `mcp__smartstack__analyze_test_coverage` | Analyser couverture de tests du projet | ralph-loop |
|
|
190
|
+
| `mcp__smartstack__validate_test_conventions` | Valider conventions de nommage des tests | ralph-loop |
|
|
191
|
+
| `mcp__smartstack__suggest_test_scenarios` | Suggérer scénarios de test basés sur le code | ralph-loop |
|
|
193
192
|
|
|
194
193
|
### Outils Frontend
|
|
195
194
|
|
|
196
|
-
| Tool | Usage |
|
|
197
|
-
|
|
198
|
-
| `mcp__smartstack__scaffold_api_client` | Générer client TypeScript avec NavRoute |
|
|
199
|
-
| `mcp__smartstack__scaffold_routes` | Générer React Router depuis NavRoute backend |
|
|
200
|
-
| `mcp__smartstack__validate_frontend_routes` | Valider synchronisation routes frontend/backend |
|
|
201
|
-
| `mcp__smartstack__scaffold_frontend_extension` | Générer infrastructure extension frontend |
|
|
202
|
-
| `mcp__smartstack__analyze_extension_points` | Analyser points d'extension dans les pages React |
|
|
195
|
+
| Tool | Usage | Used By |
|
|
196
|
+
|------|-------|---------|
|
|
197
|
+
| `mcp__smartstack__scaffold_api_client` | Générer client TypeScript avec NavRoute | application, ralph-loop |
|
|
198
|
+
| `mcp__smartstack__scaffold_routes` | Générer React Router depuis NavRoute backend | application, ralph-loop |
|
|
199
|
+
| `mcp__smartstack__validate_frontend_routes` | Valider synchronisation routes frontend/backend | application, ralph-loop |
|
|
200
|
+
| `mcp__smartstack__scaffold_frontend_extension` | Générer infrastructure extension frontend | application |
|
|
201
|
+
| `mcp__smartstack__analyze_extension_points` | Analyser points d'extension dans les pages React | application |
|
|
203
202
|
|
|
204
203
|
### Outils Documentation
|
|
205
204
|
|
|
206
|
-
| Tool | Usage |
|
|
207
|
-
|
|
208
|
-
| `mcp__smartstack__validate_documentation` | Valider fraîcheur, complétude et exactitude de la documentation (FUTURE - voir `_resources/mcp-validate-documentation-spec.md`) |
|
|
205
|
+
| Tool | Usage | Used By |
|
|
206
|
+
|------|-------|---------|
|
|
207
|
+
| `mcp__smartstack__validate_documentation` | Valider fraîcheur, complétude et exactitude de la documentation (FUTURE - voir `_resources/mcp-validate-documentation-spec.md`) | documentation |
|
|
209
208
|
|
|
210
209
|
> **Fallback** : En attendant l'implémentation MCP, utiliser l'agent `docs-sync-checker` pour la détection de drift et l'agent `docs-context-reader` pour l'injection de contexte documentation.
|
|
@@ -49,16 +49,18 @@ code: "order-items" → entityName: "OrderItem"
|
|
|
49
49
|
code: "user-profiles" → entityName: "UserProfile"
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
### 2. Determine Table Prefix
|
|
52
|
+
### 2. Determine Table Prefix and Controller Folder
|
|
53
53
|
|
|
54
54
|
Based on navigation context:
|
|
55
55
|
|
|
56
|
-
| Context | Prefix |
|
|
57
|
-
|
|
58
|
-
| platform.administration | `auth_` or `cfg_` |
|
|
59
|
-
| platform.support | `support_` |
|
|
60
|
-
| business.* | `ref_` or domain-specific |
|
|
61
|
-
| personal.* | `usr_` |
|
|
56
|
+
| Context | Table Prefix | Controller Folder |
|
|
57
|
+
|---------|--------|-------------------|
|
|
58
|
+
| platform.administration | `auth_` or `cfg_` | `Admin` |
|
|
59
|
+
| platform.support | `support_` | `Support` |
|
|
60
|
+
| business.* | `ref_` or domain-specific | `Business` |
|
|
61
|
+
| personal.* | `usr_` | `User` |
|
|
62
|
+
|
|
63
|
+
Store: `{controller_folder}` = the Controller Folder from the table above.
|
|
62
64
|
|
|
63
65
|
### 3. Call MCP scaffold_extension
|
|
64
66
|
|
|
@@ -85,7 +87,7 @@ The tool generates (paths organized by navRoute hierarchy `{context}.{applicatio
|
|
|
85
87
|
- `Infrastructure/Persistence/Configurations/{Module}/{EntityName}Configuration.cs` - EF Config
|
|
86
88
|
- `Application/Common/Interfaces/I{EntityName}Service.cs` - Service Interface
|
|
87
89
|
- `Infrastructure/Services/{Module}/{EntityName}Service.cs` - Service Implementation
|
|
88
|
-
- `Api/Controllers/{
|
|
90
|
+
- `Api/Controllers/{controller_folder}/{Application}/{EntityName}Controller.cs` - REST Controller
|
|
89
91
|
- `Application/{Context}/{Application}/{Module}/DTOs/{EntityName}ResponseDto.cs` - Response DTO
|
|
90
92
|
- `Application/{Context}/{Application}/{Module}/DTOs/Create{EntityName}Dto.cs` - Create request
|
|
91
93
|
- `Application/{Context}/{Application}/{Module}/DTOs/Update{EntityName}Dto.cs` - Update request
|
|
@@ -109,7 +111,7 @@ The tool generates (paths organized by navRoute hierarchy `{context}.{applicatio
|
|
|
109
111
|
- `{Context}/{Application}/{Module}/DTOs/Update{EntityName}Dto.cs`
|
|
110
112
|
|
|
111
113
|
### API Layer
|
|
112
|
-
- `Controllers/{
|
|
114
|
+
- `Controllers/{controller_folder}/{Application}/{EntityName}Controller.cs`
|
|
113
115
|
- NavRoute: `{full_path}`
|
|
114
116
|
- Endpoints:
|
|
115
117
|
- GET /api/{code} - List all
|
|
@@ -240,7 +242,38 @@ Store entity information for frontend generation:
|
|
|
240
242
|
|
|
241
243
|
---
|
|
242
244
|
|
|
243
|
-
## CONTROLLER NAVROUTE
|
|
245
|
+
## CONTROLLER NAVROUTE AND FOLDER HIERARCHY
|
|
246
|
+
|
|
247
|
+
### Controller File Location
|
|
248
|
+
|
|
249
|
+
Controllers are organized by **context short name** and **application** (matching SmartStack.app pattern):
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
Api/Controllers/
|
|
253
|
+
├── Admin/ ← platform.administration
|
|
254
|
+
│ ├── {Application}/ ← Application sub-folder (e.g., AI/, Communications/, Tenants/)
|
|
255
|
+
│ │ └── {EntityName}Controller.cs
|
|
256
|
+
│ └── {EntityName}Controller.cs ← Direct controllers (no application sub-folder)
|
|
257
|
+
├── Business/ ← business.*
|
|
258
|
+
│ └── {EntityName}Controller.cs
|
|
259
|
+
├── Support/ ← platform.support
|
|
260
|
+
│ └── {EntityName}Controller.cs
|
|
261
|
+
├── User/ ← personal.*
|
|
262
|
+
│ └── {EntityName}Controller.cs
|
|
263
|
+
└── {SharedControllers}.cs ← Root-level (Auth, Config, Navigation, etc.)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Context-to-Folder Mapping
|
|
267
|
+
|
|
268
|
+
| NavRoute Context | Controller Folder | Example |
|
|
269
|
+
|-----------------|-------------------|---------|
|
|
270
|
+
| `platform.administration` | `Admin` | `Controllers/Admin/TenantsController.cs` |
|
|
271
|
+
| `platform.administration.{app}` | `Admin/{App}` | `Controllers/Admin/AI/AiPromptsController.cs` |
|
|
272
|
+
| `platform.support` | `Support` | `Controllers/Support/TicketsController.cs` |
|
|
273
|
+
| `business.*` | `Business` | `Controllers/Business/MyTicketsController.cs` |
|
|
274
|
+
| `personal.*` | `User` | `Controllers/User/PreferencesController.cs` |
|
|
275
|
+
|
|
276
|
+
### Controller Attributes
|
|
244
277
|
|
|
245
278
|
The generated controller uses NavRoute attribute:
|
|
246
279
|
|
|
@@ -262,6 +295,7 @@ This ensures:
|
|
|
262
295
|
- API route is derived from navigation path
|
|
263
296
|
- Permissions use the constants from Permissions.cs
|
|
264
297
|
- Frontend can discover API path from NavRoute registry
|
|
298
|
+
- Controller file is in the correct context/application folder
|
|
265
299
|
|
|
266
300
|
---
|
|
267
301
|
|
|
@@ -357,6 +391,146 @@ Verify:
|
|
|
357
391
|
|
|
358
392
|
IF configuration is incomplete: Fix it before continuing.
|
|
359
393
|
|
|
394
|
+
### Check 5b: Seeding Infrastructure (BLOCKING - first entity only)
|
|
395
|
+
|
|
396
|
+
**If this is the FIRST entity created in this project (no existing DevDataSeeder):**
|
|
397
|
+
|
|
398
|
+
Scaffold the full seeding infrastructure following the SmartStack.app architecture:
|
|
399
|
+
|
|
400
|
+
1. **Create `Infrastructure/Persistence/Seeding/Data/SeedConstants.cs`**
|
|
401
|
+
|
|
402
|
+
```csharp
|
|
403
|
+
namespace {BaseNamespace}.Infrastructure.Persistence.Seeding.Data;
|
|
404
|
+
|
|
405
|
+
/// <summary>
|
|
406
|
+
/// Shared constants for seed data across all modules.
|
|
407
|
+
/// </summary>
|
|
408
|
+
public static class SeedConstants
|
|
409
|
+
{
|
|
410
|
+
public static readonly DateTime SeedDate = new(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
2. **Create `Infrastructure/Persistence/Seeding/DevDataSeeder.cs`**
|
|
415
|
+
|
|
416
|
+
```csharp
|
|
417
|
+
using Microsoft.EntityFrameworkCore;
|
|
418
|
+
using Microsoft.Extensions.Logging;
|
|
419
|
+
using SmartStack.Application.Common.Interfaces;
|
|
420
|
+
|
|
421
|
+
namespace {BaseNamespace}.Infrastructure.Persistence.Seeding;
|
|
422
|
+
|
|
423
|
+
/// <summary>
|
|
424
|
+
/// Seeds development/demo data at application startup.
|
|
425
|
+
/// Only runs when EnableDevSeeding = true.
|
|
426
|
+
/// </summary>
|
|
427
|
+
public class DevDataSeeder : IDevDataSeeder
|
|
428
|
+
{
|
|
429
|
+
private readonly ExtensionsDbContext _context;
|
|
430
|
+
private readonly ILogger<DevDataSeeder> _logger;
|
|
431
|
+
|
|
432
|
+
public DevDataSeeder(ExtensionsDbContext context, ILogger<DevDataSeeder> logger)
|
|
433
|
+
{
|
|
434
|
+
_context = context;
|
|
435
|
+
_logger = logger;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
public async Task SeedAsync(CancellationToken cancellationToken = default)
|
|
439
|
+
{
|
|
440
|
+
_logger.LogInformation("Starting development data seeding...");
|
|
441
|
+
// Add Seed{Entity}sAsync calls here as entities are created
|
|
442
|
+
_logger.LogInformation("Development data seeding complete.");
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
3. **Register DevDataSeeder in `Infrastructure/DependencyInjection.cs`:**
|
|
448
|
+
```csharp
|
|
449
|
+
services.AddScoped<IDevDataSeeder, DevDataSeeder>();
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**If DevDataSeeder already exists:** Skip this check.
|
|
453
|
+
|
|
454
|
+
### Check 5c: SqlObjects Directory (BLOCKING - first entity only)
|
|
455
|
+
|
|
456
|
+
**If this is the FIRST entity in the project (no existing SqlObjectHelper):**
|
|
457
|
+
|
|
458
|
+
Scaffold the SQL objects infrastructure:
|
|
459
|
+
|
|
460
|
+
1. **Create `Infrastructure/Persistence/SqlObjects/SqlObjectHelper.cs`**
|
|
461
|
+
|
|
462
|
+
```csharp
|
|
463
|
+
using System.Reflection;
|
|
464
|
+
using Microsoft.EntityFrameworkCore.Migrations;
|
|
465
|
+
|
|
466
|
+
namespace {BaseNamespace}.Infrastructure.Persistence.SqlObjects;
|
|
467
|
+
|
|
468
|
+
/// <summary>
|
|
469
|
+
/// Helper for applying SQL objects (Functions, Views, Stored Procedures) from embedded resources.
|
|
470
|
+
/// SQL files use CREATE OR ALTER for idempotency — safe to re-run on any migration or squash.
|
|
471
|
+
/// </summary>
|
|
472
|
+
public static class SqlObjectHelper
|
|
473
|
+
{
|
|
474
|
+
private static readonly Assembly Assembly = typeof(SqlObjectHelper).Assembly;
|
|
475
|
+
private const string ResourcePrefix = "{BaseNamespace}.Infrastructure.Persistence.SqlObjects.";
|
|
476
|
+
|
|
477
|
+
public static void ApplyAll(MigrationBuilder migrationBuilder)
|
|
478
|
+
{
|
|
479
|
+
ApplyAllFunctions(migrationBuilder);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
public static void ApplyAllFunctions(MigrationBuilder migrationBuilder)
|
|
483
|
+
{
|
|
484
|
+
ApplyCategory(migrationBuilder, "Functions");
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
public static void ApplyOne(MigrationBuilder migrationBuilder, string resourceName)
|
|
488
|
+
{
|
|
489
|
+
var sql = ReadSqlObject(resourceName);
|
|
490
|
+
migrationBuilder.Sql(sql);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
public static string ReadSqlObject(string resourceName)
|
|
494
|
+
{
|
|
495
|
+
var fullName = ResourcePrefix + resourceName;
|
|
496
|
+
using var stream = Assembly.GetManifestResourceStream(fullName)
|
|
497
|
+
?? throw new InvalidOperationException(
|
|
498
|
+
$"SQL object resource '{fullName}' not found. " +
|
|
499
|
+
$"Ensure the .sql file is marked as EmbeddedResource in the .csproj.");
|
|
500
|
+
using var reader = new StreamReader(stream);
|
|
501
|
+
return reader.ReadToEnd();
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
private static void ApplyCategory(MigrationBuilder migrationBuilder, string category)
|
|
505
|
+
{
|
|
506
|
+
var prefix = ResourcePrefix + category + ".";
|
|
507
|
+
var resources = Assembly.GetManifestResourceNames()
|
|
508
|
+
.Where(n => n.StartsWith(prefix, StringComparison.Ordinal)
|
|
509
|
+
&& n.EndsWith(".sql", StringComparison.Ordinal))
|
|
510
|
+
.OrderBy(n => n, StringComparer.Ordinal);
|
|
511
|
+
|
|
512
|
+
foreach (var resource in resources)
|
|
513
|
+
{
|
|
514
|
+
using var stream = Assembly.GetManifestResourceStream(resource)!;
|
|
515
|
+
using var reader = new StreamReader(stream);
|
|
516
|
+
migrationBuilder.Sql(reader.ReadToEnd());
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
2. **Create empty directory `Infrastructure/Persistence/SqlObjects/Functions/`**
|
|
523
|
+
- Where `.sql` files for TVFs and scalar functions will be stored
|
|
524
|
+
|
|
525
|
+
3. **Ensure `.csproj` has EmbeddedResource glob for SQL files:**
|
|
526
|
+
```xml
|
|
527
|
+
<ItemGroup>
|
|
528
|
+
<EmbeddedResource Include="Persistence\SqlObjects\**\*.sql" />
|
|
529
|
+
</ItemGroup>
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**If SqlObjectHelper already exists:** Skip this check.
|
|
533
|
+
|
|
360
534
|
---
|
|
361
535
|
|
|
362
536
|
## SUCCESS METRICS
|
|
@@ -367,7 +541,7 @@ IF configuration is incomplete: Fix it before continuing.
|
|
|
367
541
|
- NavRoute attribute included
|
|
368
542
|
- Entity seeding offered to user (SeedData.cs + DevDataSeeder if accepted)
|
|
369
543
|
- Entity info stored for frontend
|
|
370
|
-
- Post-generation verification passed (all 5
|
|
544
|
+
- Post-generation verification passed (all 7 checks: 5 original + 5b Seeding + 5c SqlObjects)
|
|
371
545
|
- Proceeded to step-05-frontend.md
|
|
372
546
|
|
|
373
547
|
## FAILURE MODES
|
|
@@ -66,24 +66,56 @@ IF build fails:
|
|
|
66
66
|
Tool: mcp__smartstack__suggest_migration
|
|
67
67
|
Args:
|
|
68
68
|
description: "Add {entity_name} with navigation and permissions"
|
|
69
|
-
context: "core"
|
|
69
|
+
context: "{db_context}" # "core" or "extensions" based on project type
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
Response example:
|
|
72
|
+
Response example (core project):
|
|
73
73
|
```
|
|
74
74
|
Migration name: core_v1.2.0_003_Add{EntityName}WithNavigationAndPermissions
|
|
75
75
|
Command: dotnet ef migrations add core_v1.2.0_003_Add{EntityName}WithNavigationAndPermissions --context CoreDbContext -o Persistence/Migrations
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
Response example (client project):
|
|
79
|
+
```
|
|
80
|
+
Migration name: extensions_v1.0.0_001_Add{EntityName}ModuleEntities
|
|
81
|
+
Command: dotnet ef migrations add extensions_v1.0.0_001_Add{EntityName}ModuleEntities --context ExtensionsDbContext -o Persistence/Migrations
|
|
82
|
+
```
|
|
83
|
+
|
|
78
84
|
### 2. Create Migration
|
|
79
85
|
|
|
80
86
|
Use the /efcore:migration skill or direct command:
|
|
81
87
|
|
|
88
|
+
**For core projects:**
|
|
82
89
|
```bash
|
|
83
90
|
cd Infrastructure
|
|
84
91
|
dotnet ef migrations add {suggested_migration_name} --context CoreDbContext -o Persistence/Migrations
|
|
85
92
|
```
|
|
86
93
|
|
|
94
|
+
**For client projects (ExtensionsDbContext):**
|
|
95
|
+
```bash
|
|
96
|
+
cd Infrastructure
|
|
97
|
+
dotnet ef migrations add {suggested_migration_name} --context ExtensionsDbContext -o Persistence/Migrations
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> **CRITICAL:** Always use `-o Persistence/Migrations` to ensure ALL migrations are in the SAME directory.
|
|
101
|
+
> NEVER create subdirectories under `Migrations/` (e.g., `Migrations/Extensions/`).
|
|
102
|
+
> All migrations for a given DbContext MUST share the same namespace to avoid EF Core errors.
|
|
103
|
+
|
|
104
|
+
### 2b. Inject SQL Objects (if any exist)
|
|
105
|
+
|
|
106
|
+
Check if any SQL object files exist:
|
|
107
|
+
```
|
|
108
|
+
Glob: **/Persistence/SqlObjects/Functions/*.sql
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
If SQL files are found, the migration's `Up()` method should include a call to re-apply all SQL objects:
|
|
112
|
+
```csharp
|
|
113
|
+
// At the end of the Up() method:
|
|
114
|
+
SqlObjectHelper.ApplyAll(migrationBuilder);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This ensures SQL functions/views are re-applied with each migration (`CREATE OR ALTER` = idempotent).
|
|
118
|
+
|
|
87
119
|
### 3. Verify Migration Content
|
|
88
120
|
|
|
89
121
|
The migration should include:
|
|
@@ -93,13 +125,20 @@ The migration should include:
|
|
|
93
125
|
- RolePermissions (role assignments)
|
|
94
126
|
- Domain entity table
|
|
95
127
|
- Indexes and constraints
|
|
128
|
+
- SQL Objects injection (if any .sql files exist)
|
|
96
129
|
|
|
97
130
|
### 4. Apply Migration
|
|
98
131
|
|
|
132
|
+
**For core projects:**
|
|
99
133
|
```bash
|
|
100
134
|
dotnet ef database update --context CoreDbContext
|
|
101
135
|
```
|
|
102
136
|
|
|
137
|
+
**For client projects:**
|
|
138
|
+
```bash
|
|
139
|
+
dotnet ef database update --context ExtensionsDbContext
|
|
140
|
+
```
|
|
141
|
+
|
|
103
142
|
### 5. Present Final Checklist
|
|
104
143
|
|
|
105
144
|
```markdown
|