@atlashub/smartstack-cli 3.8.0 → 3.9.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/dist/index.js +365 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/templates/agents/action.md +1 -0
- package/templates/agents/ba-writer.md +33 -0
- package/templates/agents/explore-codebase.md +1 -0
- package/templates/agents/explore-docs.md +1 -0
- package/templates/agents/fix-grammar.md +1 -0
- package/templates/agents/snipper.md +1 -0
- package/templates/skills/admin/SKILL.md +6 -0
- package/templates/skills/ai-prompt/SKILL.md +32 -136
- package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
- package/templates/skills/apex/SKILL.md +120 -0
- package/templates/skills/apex/_shared.md +86 -0
- package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
- package/templates/skills/apex/references/smartstack-layers.md +173 -0
- package/templates/skills/apex/steps/step-00-init.md +156 -0
- package/templates/skills/apex/steps/step-01-analyze.md +169 -0
- package/templates/skills/apex/steps/step-02-plan.md +160 -0
- package/templates/skills/apex/steps/step-03-execute.md +166 -0
- package/templates/skills/apex/steps/step-04-validate.md +138 -0
- package/templates/skills/apex/steps/step-05-examine.md +124 -0
- package/templates/skills/apex/steps/step-06-resolve.md +105 -0
- package/templates/skills/apex/steps/step-07-tests.md +130 -0
- package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
- package/templates/skills/application/SKILL.md +10 -0
- package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
- package/templates/skills/application/references/backend-entity-seeding.md +72 -0
- package/templates/skills/application/references/backend-verification.md +88 -0
- package/templates/skills/application/references/frontend-verification.md +111 -0
- package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
- package/templates/skills/application/references/provider-template.md +134 -0
- package/templates/skills/application/references/test-frontend.md +73 -0
- package/templates/skills/application/references/test-prerequisites.md +72 -0
- package/templates/skills/application/steps/step-01-navigation.md +7 -198
- package/templates/skills/application/steps/step-03b-provider.md +4 -128
- package/templates/skills/application/steps/step-04-backend.md +20 -350
- package/templates/skills/application/steps/step-05-frontend.md +12 -101
- package/templates/skills/application/steps/step-07-tests.md +12 -132
- package/templates/skills/business-analyse/SKILL.md +11 -2
- package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
- package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
- package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
- package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
- package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
- package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
- package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
- package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
- package/templates/skills/business-analyse/html/src/template.html +1 -0
- package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
- package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
- package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
- package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
- package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
- package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
- package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
- package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
- package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
- package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
- package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
- package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
- package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
- package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
- package/templates/skills/business-analyse/steps/step-00-init.md +35 -68
- package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
- package/templates/skills/business-analyse/steps/step-03a-data.md +6 -49
- package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
- package/templates/skills/business-analyse/steps/step-03d-validate.md +3 -48
- package/templates/skills/business-analyse/steps/step-04-consolidation.md +9 -104
- package/templates/skills/business-analyse/steps/step-05a-handoff.md +25 -441
- package/templates/skills/business-analyse/steps/step-05b-deploy.md +19 -187
- package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
- package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
- package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
- package/templates/skills/check-version/SKILL.md +7 -0
- package/templates/skills/controller/references/controller-code-templates.md +159 -0
- package/templates/skills/controller/references/permission-sync-templates.md +152 -0
- package/templates/skills/controller/steps/step-03-generate.md +6 -158
- package/templates/skills/controller/steps/step-04-perms.md +5 -144
- package/templates/skills/debug/SKILL.md +7 -0
- package/templates/skills/explore/SKILL.md +6 -0
- package/templates/skills/feature-full/SKILL.md +39 -142
- package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
- package/templates/skills/gitflow/references/init-config-template.md +135 -0
- package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
- package/templates/skills/gitflow/references/plan-template.md +69 -0
- package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
- package/templates/skills/gitflow/references/start-local-config.md +110 -0
- package/templates/skills/gitflow/steps/step-init.md +18 -289
- package/templates/skills/gitflow/steps/step-plan.md +6 -63
- package/templates/skills/gitflow/steps/step-start.md +16 -126
- package/templates/skills/mcp/SKILL.md +9 -213
- package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
- package/templates/skills/mcp/steps/step-02-tools.md +73 -0
- package/templates/skills/notification/SKILL.md +7 -0
- package/templates/skills/quick-search/SKILL.md +5 -0
- package/templates/skills/ralph-loop/SKILL.md +99 -381
- package/templates/skills/ralph-loop/references/category-rules.md +259 -0
- package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
- package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
- package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
- package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
- package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
- package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
- package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
- package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
- package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
- package/templates/skills/refactor/SKILL.md +12 -176
- package/templates/skills/refactor/steps/step-01-discover.md +60 -0
- package/templates/skills/refactor/steps/step-02-execute.md +67 -0
- package/templates/skills/review-code/SKILL.md +19 -257
- package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
- package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
- package/templates/skills/review-code/steps/step-03-react.md +44 -0
- package/templates/skills/ui-components/SKILL.md +7 -0
- package/templates/skills/utils/SKILL.md +6 -0
- package/templates/skills/validate/SKILL.md +6 -0
- package/templates/skills/validate-feature/SKILL.md +8 -0
- package/templates/skills/workflow/SKILL.md +40 -118
- package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: step-07-tests
|
|
3
|
+
description: Scaffold tests via MCP for all modified layers
|
|
4
|
+
model: opus
|
|
5
|
+
prev_step: steps/step-06-resolve.md
|
|
6
|
+
next_step: steps/step-08-run-tests.md
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Step 7: Tests (if -t)
|
|
10
|
+
|
|
11
|
+
**Goal:** Scaffold comprehensive tests using MCP tools. Target: >= 80% coverage.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Ensure Test Project Exists
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Check for existing test project
|
|
19
|
+
TEST_PROJECT=$(find tests/ -name "*.Tests.Unit.csproj" 2>/dev/null | head -1)
|
|
20
|
+
|
|
21
|
+
if [ -z "$TEST_PROJECT" ]; then
|
|
22
|
+
# Create test project
|
|
23
|
+
PROJECT_NAME=$(basename *.sln .sln)
|
|
24
|
+
dotnet new xunit -n "${PROJECT_NAME}.Tests.Unit" -o "tests/${PROJECT_NAME}.Tests.Unit"
|
|
25
|
+
dotnet add "tests/${PROJECT_NAME}.Tests.Unit" package Moq
|
|
26
|
+
dotnet add "tests/${PROJECT_NAME}.Tests.Unit" package FluentAssertions
|
|
27
|
+
for proj in src/*/*.csproj; do
|
|
28
|
+
dotnet add "tests/${PROJECT_NAME}.Tests.Unit" reference "$proj"
|
|
29
|
+
done
|
|
30
|
+
dotnet sln add "tests/${PROJECT_NAME}.Tests.Unit/${PROJECT_NAME}.Tests.Unit.csproj"
|
|
31
|
+
fi
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 2. Scaffold Tests via MCP
|
|
37
|
+
|
|
38
|
+
For each layer that was modified:
|
|
39
|
+
|
|
40
|
+
### Domain Tests
|
|
41
|
+
```
|
|
42
|
+
Call: mcp__smartstack__scaffold_tests
|
|
43
|
+
target_layer: "domain"
|
|
44
|
+
module: "{module_code}"
|
|
45
|
+
test_type: "unit"
|
|
46
|
+
|
|
47
|
+
Tests: entity creation, validation, domain events, value objects
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Application Tests
|
|
51
|
+
```
|
|
52
|
+
Call: mcp__smartstack__scaffold_tests
|
|
53
|
+
target_layer: "application"
|
|
54
|
+
module: "{module_code}"
|
|
55
|
+
test_type: "unit"
|
|
56
|
+
|
|
57
|
+
Tests: service logic, CQRS handlers, FluentValidation
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### API Tests
|
|
61
|
+
```
|
|
62
|
+
Call: mcp__smartstack__scaffold_tests
|
|
63
|
+
target_layer: "api"
|
|
64
|
+
module: "{module_code}"
|
|
65
|
+
test_type: "integration"
|
|
66
|
+
|
|
67
|
+
Tests: controller endpoints, authorization, response DTOs
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Security Tests
|
|
71
|
+
```
|
|
72
|
+
Call: mcp__smartstack__scaffold_tests
|
|
73
|
+
module: "{module_code}"
|
|
74
|
+
test_type: "security"
|
|
75
|
+
|
|
76
|
+
Tests: RequirePermission enforcement, multi-tenant isolation
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 3. Suggest Additional Scenarios
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Call: mcp__smartstack__suggest_test_scenarios
|
|
85
|
+
module: "{module_code}"
|
|
86
|
+
|
|
87
|
+
Review suggestions and add relevant test cases.
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 4. Analyze Coverage
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Call: mcp__smartstack__analyze_test_coverage
|
|
96
|
+
module: "{module_code}"
|
|
97
|
+
|
|
98
|
+
Target: >= 80% coverage
|
|
99
|
+
If under 80%: identify uncovered paths, scaffold additional tests
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 5. Test Summary
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
**APEX SmartStack - Tests Scaffolded**
|
|
108
|
+
|
|
109
|
+
| Layer | Tests Created | Coverage |
|
|
110
|
+
|-------|--------------|----------|
|
|
111
|
+
| Domain | {count} | {%} |
|
|
112
|
+
| Application | {count} | {%} |
|
|
113
|
+
| API | {count} | {%} |
|
|
114
|
+
| Security | {count} | {%} |
|
|
115
|
+
|
|
116
|
+
**Total tests:** {count}
|
|
117
|
+
**Estimated coverage:** {%}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 6. Save Output (if save_mode)
|
|
123
|
+
|
|
124
|
+
Write to `{output_dir}/07-tests.md` with test scaffolding results.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## NEXT STEP
|
|
129
|
+
|
|
130
|
+
Load `steps/step-08-run-tests.md`
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: step-08-run-tests
|
|
3
|
+
description: Run tests until 100% pass — fix CODE not tests
|
|
4
|
+
model: opus
|
|
5
|
+
prev_step: steps/step-07-tests.md
|
|
6
|
+
next_step: COMPLETE
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Step 8: Run Tests (if -t)
|
|
10
|
+
|
|
11
|
+
**CRITICAL:** Fix the CODE, not the tests. Tests represent expected behavior.
|
|
12
|
+
100% pass required for Sonar quality gate.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Build
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
dotnet build --no-restore
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**MUST PASS before running tests.**
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. Run Full Test Suite
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
dotnet test --no-build --verbosity normal
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 3. Analyze Results
|
|
35
|
+
|
|
36
|
+
**If ALL PASS:** Skip to step 5 (Summary).
|
|
37
|
+
|
|
38
|
+
**If FAILURES:** For each failing test:
|
|
39
|
+
|
|
40
|
+
```markdown
|
|
41
|
+
### Failing Test: {test_name}
|
|
42
|
+
**File:** {test_file}:{line}
|
|
43
|
+
**Error:** {error_message}
|
|
44
|
+
|
|
45
|
+
**Root Cause Analysis:**
|
|
46
|
+
- [ ] Code bug: implementation doesn't match expected behavior
|
|
47
|
+
- [ ] Missing dependency: service/mock not configured
|
|
48
|
+
- [ ] Data issue: test data setup incomplete
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 4. Fix Loop (max 5 iterations)
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
WHILE tests failing AND iteration < 5:
|
|
57
|
+
1. Identify root cause (ALWAYS code bug, not test bug)
|
|
58
|
+
2. Fix the production CODE via appropriate skill/MCP
|
|
59
|
+
3. dotnet build --no-restore
|
|
60
|
+
4. dotnet test --no-build
|
|
61
|
+
5. Log result
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Rules:**
|
|
65
|
+
- Fix CODE, never modify test assertions
|
|
66
|
+
- Use the same skill/MCP that created the original code
|
|
67
|
+
- After fix, rebuild before retesting
|
|
68
|
+
- If stuck after 3 iterations on same test, ask user
|
|
69
|
+
|
|
70
|
+
**If stuck (auto_mode = false):**
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
questions:
|
|
74
|
+
- header: "Test Fix"
|
|
75
|
+
question: "Test is still failing after multiple attempts. How should we proceed?"
|
|
76
|
+
options:
|
|
77
|
+
- label: "Try alternative fix (Recommended)"
|
|
78
|
+
description: "Attempt a different approach to fix the code"
|
|
79
|
+
- label: "Skip this test"
|
|
80
|
+
description: "Mark as skipped with TODO comment"
|
|
81
|
+
- label: "Discuss the issue"
|
|
82
|
+
description: "Need help understanding the failure"
|
|
83
|
+
multiSelect: false
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 5. Frontend Typecheck (if applicable)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm run typecheck
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**MUST PASS.**
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 6. Commit Tests
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
test({module}): add unit and integration tests
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 7. Save + Summary
|
|
107
|
+
|
|
108
|
+
If save_mode: write to `{output_dir}/08-run-tests.md`.
|
|
109
|
+
|
|
110
|
+
Display: total tests, passing count, iterations to green, fixes applied, coverage %.
|
|
111
|
+
|
|
112
|
+
## 8. Route to Next Step
|
|
113
|
+
|
|
114
|
+
If pr_mode: create PR via `gh pr create`, show URL.
|
|
115
|
+
Otherwise: show final summary (task, context, files, quality checks, commits, next steps).
|
|
@@ -230,3 +230,13 @@ await _workflowService.TriggerAsync("{entity}.created", new Dictionary<string, o
|
|
|
230
230
|
- [templates-frontend.md](templates-frontend.md) - Frontend patterns reference
|
|
231
231
|
- [templates-i18n.md](templates-i18n.md) - i18n structure reference
|
|
232
232
|
- [templates-seed.md](templates-seed.md) - Seed data patterns reference
|
|
233
|
+
|
|
234
|
+
<success_criteria>
|
|
235
|
+
- Navigation entries created with correct hierarchy (Context/Application/Module)
|
|
236
|
+
- Permissions generated via MCP with 2-file pattern (constants + seed)
|
|
237
|
+
- Roles assigned with appropriate permission sets
|
|
238
|
+
- Backend layers follow SmartStack conventions (validated by MCP)
|
|
239
|
+
- Frontend pages in correct path structure with i18n
|
|
240
|
+
- EF Core migration created and applied successfully
|
|
241
|
+
- Test suite generated and passing
|
|
242
|
+
</success_criteria>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Controller NavRoute and Folder Hierarchy
|
|
2
|
+
|
|
3
|
+
> Referenced from `steps/step-04-backend.md` — Controller file organization and NavRoute conventions.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Controller File Location
|
|
8
|
+
|
|
9
|
+
Controllers are organized by **context short name** and **application** (matching SmartStack.app pattern):
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Api/Controllers/
|
|
13
|
+
├── Admin/ ← platform.administration
|
|
14
|
+
│ ├── {Application}/ ← Application sub-folder (e.g., AI/, Communications/, Tenants/)
|
|
15
|
+
│ │ └── {EntityName}Controller.cs
|
|
16
|
+
│ └── {EntityName}Controller.cs ← Direct controllers (no application sub-folder)
|
|
17
|
+
├── Business/ ← business.*
|
|
18
|
+
│ └── {EntityName}Controller.cs
|
|
19
|
+
├── Support/ ← platform.support
|
|
20
|
+
│ └── {EntityName}Controller.cs
|
|
21
|
+
├── User/ ← personal.*
|
|
22
|
+
│ └── {EntityName}Controller.cs
|
|
23
|
+
└── {SharedControllers}.cs ← Root-level (Auth, Config, Navigation, etc.)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Context-to-Folder Mapping
|
|
27
|
+
|
|
28
|
+
| NavRoute Context | Controller Folder | Example |
|
|
29
|
+
|-----------------|-------------------|---------|
|
|
30
|
+
| `platform.administration` | `Admin` | `Controllers/Admin/TenantsController.cs` |
|
|
31
|
+
| `platform.administration.{app}` | `Admin/{App}` | `Controllers/Admin/AI/AiPromptsController.cs` |
|
|
32
|
+
| `platform.support` | `Support` | `Controllers/Support/TicketsController.cs` |
|
|
33
|
+
| `business.*` | `Business` | `Controllers/Business/MyTicketsController.cs` |
|
|
34
|
+
| `personal.*` | `User` | `Controllers/User/PreferencesController.cs` |
|
|
35
|
+
|
|
36
|
+
## Controller Attributes
|
|
37
|
+
|
|
38
|
+
The generated controller uses NavRoute attribute:
|
|
39
|
+
|
|
40
|
+
```csharp
|
|
41
|
+
[NavRoute("{full_path}")]
|
|
42
|
+
[ApiController]
|
|
43
|
+
[Authorize]
|
|
44
|
+
public class {EntityName}Controller : ControllerBase
|
|
45
|
+
{
|
|
46
|
+
[HttpGet]
|
|
47
|
+
[RequirePermission(Permissions.{Context}.{Application}.{Module}.Read)]
|
|
48
|
+
public async Task<ActionResult<IEnumerable<{EntityName}Dto>>> GetAll() { ... }
|
|
49
|
+
|
|
50
|
+
// ... other CRUD methods
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This ensures:
|
|
55
|
+
- API route is derived from navigation path
|
|
56
|
+
- Permissions use the constants from Permissions.cs
|
|
57
|
+
- Frontend can discover API path from NavRoute registry
|
|
58
|
+
- Controller file is in the correct context/application folder
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Entity Seeding Pattern
|
|
2
|
+
|
|
3
|
+
> Reference: See `templates-seed.md` section "TEMPLATE: ENTITY SEED DATA (SeedData Provider)"
|
|
4
|
+
|
|
5
|
+
## SeedData File
|
|
6
|
+
|
|
7
|
+
**`Infrastructure/Persistence/Seeding/Data/{Domain}/{EntityName}SeedData.cs`**
|
|
8
|
+
|
|
9
|
+
Follow SmartStack.app pattern:
|
|
10
|
+
- Static class with `internal static IEnumerable<{EntityName}SeedItem> GetAll{EntityName}s()`
|
|
11
|
+
- Use deterministic GUIDs (NEVER `Guid.NewGuid()`)
|
|
12
|
+
- Include 3-5 sample entities with varied, realistic data
|
|
13
|
+
- For multi-tenant: organize by tenant using `GetTenant1{EntityName}s()` helpers
|
|
14
|
+
|
|
15
|
+
```csharp
|
|
16
|
+
public static class {EntityName}SeedData
|
|
17
|
+
{
|
|
18
|
+
public static readonly Guid Sample1Id = Guid.Parse("...");
|
|
19
|
+
public static readonly Guid Sample2Id = Guid.Parse("...");
|
|
20
|
+
public static readonly Guid Sample3Id = Guid.Parse("...");
|
|
21
|
+
|
|
22
|
+
internal static IEnumerable<{EntityName}SeedItem> GetAll{EntityName}s()
|
|
23
|
+
{
|
|
24
|
+
return new[]
|
|
25
|
+
{
|
|
26
|
+
new {EntityName}SeedItem { Id = Sample1Id, /* ... */ },
|
|
27
|
+
new {EntityName}SeedItem { Id = Sample2Id, /* ... */ },
|
|
28
|
+
new {EntityName}SeedItem { Id = Sample3Id, /* ... */ }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
internal class {EntityName}SeedItem
|
|
34
|
+
{
|
|
35
|
+
public Guid Id { get; init; }
|
|
36
|
+
// ... all required entity properties
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## DevDataSeeder Update
|
|
41
|
+
|
|
42
|
+
Add to `Infrastructure/Persistence/Seeding/DevDataSeeder.cs`:
|
|
43
|
+
- `using` for the new SeedData namespace
|
|
44
|
+
- `await Seed{EntityName}sAsync(cancellationToken);` in `SeedAsync()` method
|
|
45
|
+
|
|
46
|
+
```csharp
|
|
47
|
+
private async Task Seed{EntityName}sAsync(CancellationToken cancellationToken)
|
|
48
|
+
{
|
|
49
|
+
_logger.LogInformation("Seeding demo {EntityName}s...");
|
|
50
|
+
|
|
51
|
+
var existingCount = await _context.{EntityName}s.CountAsync(cancellationToken);
|
|
52
|
+
if (existingCount > 0)
|
|
53
|
+
{
|
|
54
|
+
_logger.LogWarning("{EntityName}s already seeded ({Count} exist), skipping.", existingCount);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var createdCount = 0;
|
|
59
|
+
foreach (var seedItem in {EntityName}SeedData.GetAll{EntityName}s())
|
|
60
|
+
{
|
|
61
|
+
var entity = {EntityName}.Create(/* map seedItem properties */);
|
|
62
|
+
typeof({EntityName}).GetProperty("Id")?.SetValue(entity, seedItem.Id);
|
|
63
|
+
_context.{EntityName}s.Add(entity);
|
|
64
|
+
createdCount++;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (createdCount > 0)
|
|
68
|
+
await _context.SaveChangesAsync(cancellationToken);
|
|
69
|
+
|
|
70
|
+
_logger.LogInformation("Created {Count} demo {EntityName}s.", createdCount);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Backend Post-Generation Verification
|
|
2
|
+
|
|
3
|
+
**Run ALL checks before proceeding to next step.**
|
|
4
|
+
|
|
5
|
+
## Check 1: Backend Build (BLOCKING)
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
dotnet build {SolutionName}.sln --no-restore
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
IF build fails: Read errors, fix compilation issues, re-run until success.
|
|
12
|
+
|
|
13
|
+
## Check 2: DbSet Registration (BLOCKING)
|
|
14
|
+
|
|
15
|
+
Search for `DbSet<{EntityName}>` in `I{DbContextName}.cs` or `{DbContextName}.cs`.
|
|
16
|
+
|
|
17
|
+
IF NOT found, add:
|
|
18
|
+
```csharp
|
|
19
|
+
public DbSet<{EntityName}> {EntityName}s => Set<{EntityName}>();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Check 3: DI Registration (BLOCKING)
|
|
23
|
+
|
|
24
|
+
Search for `I{EntityName}Service` in `DependencyInjection.cs`.
|
|
25
|
+
|
|
26
|
+
IF NOT found, add:
|
|
27
|
+
```csharp
|
|
28
|
+
services.AddScoped<I{EntityName}Service, {EntityName}Service>();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Check 4: RequirePermission Attributes (BLOCKING)
|
|
32
|
+
|
|
33
|
+
Each HTTP action MUST have `[RequirePermission(Permissions.{Context}.{Application}.{Module}.{Action})]`.
|
|
34
|
+
|
|
35
|
+
## Check 5: Entity Configuration (BLOCKING)
|
|
36
|
+
|
|
37
|
+
Verify:
|
|
38
|
+
- `builder.ToTable("{table_prefix}{EntityName}s")` uses correct prefix
|
|
39
|
+
- `builder.HasKey(e => e.Id)` present
|
|
40
|
+
- `builder.HasIndex` for unique fields
|
|
41
|
+
|
|
42
|
+
## Check 5b: Seeding Infrastructure (first entity only)
|
|
43
|
+
|
|
44
|
+
**If this is the FIRST entity (no existing DevDataSeeder):**
|
|
45
|
+
|
|
46
|
+
1. **`Infrastructure/Persistence/Seeding/Data/SeedConstants.cs`**
|
|
47
|
+
```csharp
|
|
48
|
+
namespace {BaseNamespace}.Infrastructure.Persistence.Seeding.Data;
|
|
49
|
+
public static class SeedConstants
|
|
50
|
+
{
|
|
51
|
+
public static readonly DateTime SeedDate = new(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. **`Infrastructure/Persistence/Seeding/DevDataSeeder.cs`**
|
|
56
|
+
```csharp
|
|
57
|
+
public class DevDataSeeder : IDevDataSeeder
|
|
58
|
+
{
|
|
59
|
+
private readonly ExtensionsDbContext _context;
|
|
60
|
+
private readonly ILogger<DevDataSeeder> _logger;
|
|
61
|
+
public DevDataSeeder(ExtensionsDbContext context, ILogger<DevDataSeeder> logger) { _context = context; _logger = logger; }
|
|
62
|
+
public async Task SeedAsync(CancellationToken cancellationToken = default)
|
|
63
|
+
{
|
|
64
|
+
_logger.LogInformation("Starting development data seeding...");
|
|
65
|
+
// Add Seed{Entity}sAsync calls here
|
|
66
|
+
_logger.LogInformation("Development data seeding complete.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. Register: `services.AddScoped<IDevDataSeeder, DevDataSeeder>();`
|
|
72
|
+
|
|
73
|
+
## Check 5c: SqlObjects Directory (first entity only)
|
|
74
|
+
|
|
75
|
+
**If no existing SqlObjectHelper:**
|
|
76
|
+
|
|
77
|
+
1. **`Infrastructure/Persistence/SqlObjects/SqlObjectHelper.cs`** - Helper for embedded SQL resources
|
|
78
|
+
2. Create `Infrastructure/Persistence/SqlObjects/Functions/` directory
|
|
79
|
+
3. Ensure `.csproj` has: `<EmbeddedResource Include="Persistence\SqlObjects\**\*.sql" />`
|
|
80
|
+
|
|
81
|
+
## Check 6: Convention Validation (RECOMMENDED)
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Tool: mcp__smartstack__validate_conventions
|
|
85
|
+
Args: target: "backend", scope: "{entity_name}"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Verifies naming conventions, architecture layers, required attributes, DTO patterns.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Frontend: Routing Rules & Post-Generation Verification
|
|
2
|
+
|
|
3
|
+
> Reference for step-05-frontend.md — routing rules and mandatory verification checks.
|
|
4
|
+
|
|
5
|
+
## Routing Rules
|
|
6
|
+
|
|
7
|
+
### Rule 1: Routes MUST be inside Layout wrappers
|
|
8
|
+
|
|
9
|
+
**CRITICAL:** All routes MUST be nested inside the appropriate context layout. This is what provides the SmartStack shell (header with AvatarMenu, sidebar, navigation).
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// CORRECT - Inside BusinessLayout (shell renders: header + AvatarMenu + sidebar)
|
|
13
|
+
<Route path="/business" element={<BusinessLayout />}>
|
|
14
|
+
<Route path="sales/products" element={<ProductsPage />} />
|
|
15
|
+
</Route>
|
|
16
|
+
|
|
17
|
+
// FORBIDDEN - Outside layout (NO shell, NO header, NO AvatarMenu!)
|
|
18
|
+
<Route path="/business/sales/products" element={<ProductsPage />} />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Rule 2: Use nested routes (not flat)
|
|
22
|
+
|
|
23
|
+
**CRITICAL:** SmartStack requires NESTED routes within the layout:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
// CORRECT - Nested routes inside layout
|
|
27
|
+
<Route path="/business" element={<BusinessLayout />}>
|
|
28
|
+
<Route path="sales">
|
|
29
|
+
<Route index element={<Navigate to="products" replace />} />
|
|
30
|
+
<Route path="products" element={<ProductsPage />} />
|
|
31
|
+
<Route path="orders" element={<OrdersPage />} />
|
|
32
|
+
</Route>
|
|
33
|
+
</Route>
|
|
34
|
+
|
|
35
|
+
// FORBIDDEN - Flat routes (cause redirect issues + bypass layout)
|
|
36
|
+
<Route path="/business/sales" element={<Navigate to="products" />} />
|
|
37
|
+
<Route path="/business/sales/products" element={<ProductsPage />} />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Post-Generation Verification (MANDATORY)
|
|
41
|
+
|
|
42
|
+
**Before proceeding to step-06, run these checks on ALL generated frontend files:**
|
|
43
|
+
|
|
44
|
+
### 1. CSS Variables Check (BLOCKING)
|
|
45
|
+
|
|
46
|
+
Scan all generated `.tsx` files for hardcoded Tailwind colors:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
FORBIDDEN patterns: bg-blue-, bg-red-, bg-green-, bg-gray-, bg-amber-,
|
|
50
|
+
text-blue-, text-red-, text-green-, text-gray-, text-amber-,
|
|
51
|
+
border-blue-, border-red-, border-green-, border-gray-
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If ANY hardcoded color is found → **FIX IT** using CSS variables from style-guide.md before continuing.
|
|
55
|
+
|
|
56
|
+
### 2. API Client Check (BLOCKING)
|
|
57
|
+
|
|
58
|
+
Verify all API service files use the configured client:
|
|
59
|
+
- **CORRECT:** `import { api } from '@/services/api/apiClient'` or `import api from '../api'`
|
|
60
|
+
- **FORBIDDEN:** `import axios from 'axios'`
|
|
61
|
+
|
|
62
|
+
### 3. EntityCard Check
|
|
63
|
+
|
|
64
|
+
If a grid/card view is generated, verify it uses `EntityCard` component (not custom divs).
|
|
65
|
+
|
|
66
|
+
### 4. i18n Check (BLOCKING)
|
|
67
|
+
|
|
68
|
+
Verify exactly **4 language files** exist with identical key structures:
|
|
69
|
+
- `fr/{entityCode}.json`
|
|
70
|
+
- `en/{entityCode}.json`
|
|
71
|
+
- `it/{entityCode}.json`
|
|
72
|
+
- `de/{entityCode}.json`
|
|
73
|
+
|
|
74
|
+
### 5. Route Check (BLOCKING)
|
|
75
|
+
|
|
76
|
+
Verify routes are:
|
|
77
|
+
- **INSIDE** the Layout wrapper (`BusinessLayout`, `AdminLayout`, or `UserLayout`)
|
|
78
|
+
- **NESTED** (not flat)
|
|
79
|
+
- Following path convention: `/{context}/{application}/{module}`
|
|
80
|
+
|
|
81
|
+
### 6. States Check
|
|
82
|
+
|
|
83
|
+
Verify the list page includes:
|
|
84
|
+
- Loading state (spinner)
|
|
85
|
+
- Error state (icon + message + retry button)
|
|
86
|
+
- Empty state (icon + message)
|
|
87
|
+
|
|
88
|
+
### 7. TypeScript Build Check (BLOCKING)
|
|
89
|
+
|
|
90
|
+
Run the frontend type check to verify all generated files compile:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
cd web && npx tsc --noEmit 2>&1 | head -50
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
OR if the project uses a build script:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
cd web && npm run build 2>&1 | head -80
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
IF type errors exist **in generated files**: Fix them before proceeding.
|
|
103
|
+
Common issues: missing imports, wrong interface names, incorrect prop types, missing hook return types.
|
|
104
|
+
|
|
105
|
+
IF type errors exist **in other pre-existing files**: NON-BLOCKING. Note them but proceed.
|
|
106
|
+
|
|
107
|
+
**Focus only on errors in files generated by this step:**
|
|
108
|
+
- `pages/{context}/{application}/{module}/*.tsx`
|
|
109
|
+
- `services/api/{entityCode}Api.ts`
|
|
110
|
+
- `types/{entityName}.types.ts`
|
|
111
|
+
- `hooks/use{EntityName}*.ts`
|