@atlashub/smartstack-cli 3.8.0 → 3.10.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 (130) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +2 -1
  4. package/templates/agents/action.md +1 -0
  5. package/templates/agents/ba-writer.md +211 -0
  6. package/templates/agents/explore-codebase.md +1 -0
  7. package/templates/agents/explore-docs.md +1 -0
  8. package/templates/agents/fix-grammar.md +1 -0
  9. package/templates/agents/snipper.md +1 -0
  10. package/templates/skills/admin/SKILL.md +6 -0
  11. package/templates/skills/ai-prompt/SKILL.md +32 -136
  12. package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
  13. package/templates/skills/apex/SKILL.md +120 -0
  14. package/templates/skills/apex/_shared.md +86 -0
  15. package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
  16. package/templates/skills/apex/references/smartstack-layers.md +173 -0
  17. package/templates/skills/apex/steps/step-00-init.md +156 -0
  18. package/templates/skills/apex/steps/step-01-analyze.md +169 -0
  19. package/templates/skills/apex/steps/step-02-plan.md +160 -0
  20. package/templates/skills/apex/steps/step-03-execute.md +166 -0
  21. package/templates/skills/apex/steps/step-04-validate.md +138 -0
  22. package/templates/skills/apex/steps/step-05-examine.md +124 -0
  23. package/templates/skills/apex/steps/step-06-resolve.md +105 -0
  24. package/templates/skills/apex/steps/step-07-tests.md +130 -0
  25. package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
  26. package/templates/skills/application/SKILL.md +10 -0
  27. package/templates/skills/application/references/application-roles-template.md +227 -0
  28. package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
  29. package/templates/skills/application/references/backend-entity-seeding.md +72 -0
  30. package/templates/skills/application/references/backend-verification.md +88 -0
  31. package/templates/skills/application/references/frontend-verification.md +111 -0
  32. package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
  33. package/templates/skills/application/references/provider-template.md +158 -0
  34. package/templates/skills/application/references/test-frontend.md +73 -0
  35. package/templates/skills/application/references/test-prerequisites.md +72 -0
  36. package/templates/skills/application/steps/step-01-navigation.md +7 -198
  37. package/templates/skills/application/steps/step-03-roles.md +45 -7
  38. package/templates/skills/application/steps/step-03b-provider.md +15 -132
  39. package/templates/skills/application/steps/step-04-backend.md +20 -350
  40. package/templates/skills/application/steps/step-05-frontend.md +12 -101
  41. package/templates/skills/application/steps/step-07-tests.md +12 -132
  42. package/templates/skills/business-analyse/SKILL.md +67 -6
  43. package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
  44. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
  45. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
  46. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
  47. package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
  48. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
  49. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
  50. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
  51. package/templates/skills/business-analyse/html/src/template.html +1 -0
  52. package/templates/skills/business-analyse/references/agent-pooling-best-practices.md +477 -0
  53. package/templates/skills/business-analyse/references/cache-warming-strategy.md +578 -0
  54. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  55. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  56. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  57. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  58. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  59. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  60. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  61. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  62. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  63. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  64. package/templates/skills/business-analyse/references/robustness-checks.md +538 -0
  65. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  66. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  67. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  68. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  69. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +33 -1
  70. package/templates/skills/business-analyse/steps/step-00-init.md +186 -53
  71. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  72. package/templates/skills/business-analyse/steps/step-03a-data.md +42 -49
  73. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  74. package/templates/skills/business-analyse/steps/step-03c-compile.md +71 -2
  75. package/templates/skills/business-analyse/steps/step-03d-validate.md +277 -48
  76. package/templates/skills/business-analyse/steps/step-04-consolidation.md +175 -104
  77. package/templates/skills/business-analyse/steps/step-05a-handoff.md +66 -438
  78. package/templates/skills/business-analyse/steps/step-05b-deploy.md +35 -184
  79. package/templates/skills/business-analyse/steps/step-05c-ralph-readiness.md +526 -0
  80. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  81. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  82. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  83. package/templates/skills/check-version/SKILL.md +7 -0
  84. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  85. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  86. package/templates/skills/controller/steps/step-03-generate.md +166 -158
  87. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  88. package/templates/skills/controller/templates.md +11 -2
  89. package/templates/skills/debug/SKILL.md +7 -0
  90. package/templates/skills/explore/SKILL.md +6 -0
  91. package/templates/skills/feature-full/SKILL.md +39 -142
  92. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  93. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  94. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  95. package/templates/skills/gitflow/references/plan-template.md +69 -0
  96. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  97. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  98. package/templates/skills/gitflow/steps/step-init.md +18 -289
  99. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  100. package/templates/skills/gitflow/steps/step-start.md +16 -126
  101. package/templates/skills/mcp/SKILL.md +9 -213
  102. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  103. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  104. package/templates/skills/notification/SKILL.md +7 -0
  105. package/templates/skills/quick-search/SKILL.md +5 -0
  106. package/templates/skills/ralph-loop/SKILL.md +99 -381
  107. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  108. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  109. package/templates/skills/ralph-loop/references/core-seed-data.md +173 -21
  110. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  111. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  112. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  113. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  114. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  115. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  116. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  117. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  118. package/templates/skills/refactor/SKILL.md +12 -176
  119. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  120. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  121. package/templates/skills/review-code/SKILL.md +19 -257
  122. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  123. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  124. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  125. package/templates/skills/ui-components/SKILL.md +7 -0
  126. package/templates/skills/utils/SKILL.md +6 -0
  127. package/templates/skills/validate/SKILL.md +6 -0
  128. package/templates/skills/validate-feature/SKILL.md +8 -0
  129. package/templates/skills/workflow/SKILL.md +40 -118
  130. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: step-05-examine
3
+ description: Adversarial code review of changes — find issues before they reach production
4
+ model: opus
5
+ prev_step: steps/step-04-validate.md
6
+ next_step: steps/step-06-resolve.md
7
+ ---
8
+
9
+ # Step 5: Examine (if -x)
10
+
11
+ **Goal:** Review the code as an adversarial external reviewer. Find bugs, security issues, and convention violations that automated checks missed.
12
+
13
+ ---
14
+
15
+ ## 1. Gather Changed Files
16
+
17
+ ```bash
18
+ git diff --name-only HEAD~{commit_count}
19
+ ```
20
+
21
+ List all files modified during this APEX session.
22
+
23
+ ---
24
+
25
+ ## 2. MCP Code Review
26
+
27
+ ```
28
+ Call: mcp__smartstack__review_code
29
+ scope: "changed" # Only review files changed in this session
30
+
31
+ Call: mcp__smartstack__analyze_code_quality
32
+ scope: "changed"
33
+ ```
34
+
35
+ ---
36
+
37
+ ## 3. Manual Adversarial Review
38
+
39
+ For each changed file, check:
40
+
41
+ **Security (OWASP):**
42
+ - [ ] `[RequirePermission]` on every endpoint (not `[Authorize]`)
43
+ - [ ] No SQL injection (parameterized queries, EF Core only)
44
+ - [ ] No XSS (React auto-escapes, but check dangerouslySetInnerHTML)
45
+ - [ ] Multi-tenant isolation (IHasData filter applied)
46
+ - [ ] No secrets in code
47
+
48
+ **Architecture:**
49
+ - [ ] Entities in correct Domain folder
50
+ - [ ] Configs in correct Infrastructure folder
51
+ - [ ] Services follow CQRS pattern
52
+ - [ ] DTOs separate from domain entities
53
+ - [ ] Controllers return DTOs, not entities
54
+ - [ ] Frontend in correct hierarchy (Context/App/Module)
55
+
56
+ **SmartStack conventions:**
57
+ - [ ] Deterministic GUIDs in seed data (not Guid.NewGuid())
58
+ - [ ] 4 languages in translations
59
+ - [ ] CSS variables (not hardcoded colors)
60
+ - [ ] SmartTable/SmartForm (not raw HTML tables/forms)
61
+ - [ ] Correct Layout wrapper per context
62
+
63
+ ---
64
+
65
+ ## 4. Produce Findings
66
+
67
+ For each issue found, classify:
68
+
69
+ ```
70
+ [BLOCKING] — Must fix before completion
71
+ [SUGGESTION] — Should fix, quality improvement
72
+ [NIT] — Minor style/preference issue
73
+ ```
74
+
75
+ **Findings format:**
76
+
77
+ ```markdown
78
+ ### Finding F01 [BLOCKING]
79
+ **File:** {path}:{line}
80
+ **Issue:** {description}
81
+ **Fix:** {recommended fix}
82
+
83
+ ### Finding F02 [SUGGESTION]
84
+ **File:** {path}:{line}
85
+ **Issue:** {description}
86
+ **Fix:** {recommended fix}
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 5. Summary
92
+
93
+ ```
94
+ **APEX SmartStack - Examine Complete**
95
+
96
+ **Files reviewed:** {count}
97
+ **Findings:** {blocking} BLOCKING, {suggestions} SUGGESTION, {nits} NIT
98
+
99
+ {findings table}
100
+ ```
101
+
102
+ ---
103
+
104
+ ## 6. Save Output (if save_mode)
105
+
106
+ Write to `{output_dir}/05-examine.md` with all findings.
107
+
108
+ ---
109
+
110
+ ## 7. Route to Next Step
111
+
112
+ ```
113
+ IF BLOCKING findings exist:
114
+ → Load steps/step-06-resolve.md
115
+
116
+ ELSE IF test_mode = true:
117
+ → Load steps/step-07-tests.md
118
+
119
+ ELSE IF pr_mode = true:
120
+ → Create PR and show final summary
121
+
122
+ ELSE:
123
+ → Show final summary and exit
124
+ ```
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: step-06-resolve
3
+ description: Fix BLOCKING findings from adversarial review
4
+ model: opus
5
+ prev_step: steps/step-05-examine.md
6
+ next_step: steps/step-07-tests.md
7
+ ---
8
+
9
+ # Step 6: Resolve (if BLOCKING findings)
10
+
11
+ **Goal:** Fix all BLOCKING findings from step-05. Re-validate after fixes.
12
+
13
+ ---
14
+
15
+ ## 1. Process BLOCKING Findings
16
+
17
+ For each BLOCKING finding from step-05:
18
+
19
+ ```
20
+ Finding: {F01, F02, ...}
21
+ File: {path}
22
+ Issue: {description}
23
+ Fix approach: {use appropriate skill/MCP tool}
24
+ ```
25
+
26
+ **Fixing rules:**
27
+ - Use the SAME skill/MCP that created the original code
28
+ - If the finding is in a controller → use /controller or MCP scaffold_extension
29
+ - If the finding is in seed data → use MCP generate_permissions
30
+ - If the finding is in frontend → use /ui-components or MCP scaffold_routes
31
+ - NEVER fix by writing raw SmartStack code
32
+
33
+ ---
34
+
35
+ ## 2. Apply Fixes
36
+
37
+ For each finding:
38
+
39
+ ```
40
+ 1. Read the file to understand current state
41
+ 2. Apply fix via appropriate skill/MCP
42
+ 3. Verify fix addresses the finding
43
+ 4. Mark finding as RESOLVED
44
+ ```
45
+
46
+ ---
47
+
48
+ ## 3. Re-Validate
49
+
50
+ After all BLOCKING findings are fixed:
51
+
52
+ ```
53
+ 1. MCP validate_conventions → 0 errors
54
+ 2. dotnet build --no-restore → PASS
55
+ 3. npm run typecheck → PASS (if frontend)
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 4. Commit Fixes
61
+
62
+ ```
63
+ fix({module}): resolve review findings {F01, F02, ...}
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 5. Resolution Summary
69
+
70
+ ```
71
+ **APEX SmartStack - Resolve Complete**
72
+
73
+ **BLOCKING findings:** {count}
74
+ **Resolved:** {count}
75
+ **Remaining:** {count} (should be 0)
76
+
77
+ | Finding | Status | Fix Applied |
78
+ |---------|--------|-------------|
79
+ | F01 | RESOLVED | {description} |
80
+ | F02 | RESOLVED | {description} |
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 6. Save Output (if save_mode)
86
+
87
+ Write to `{output_dir}/06-resolve.md` with resolution log.
88
+
89
+ ---
90
+
91
+ ## 7. Route to Next Step
92
+
93
+ ```
94
+ IF remaining BLOCKING > 0:
95
+ → Loop: fix remaining, re-validate
96
+
97
+ IF test_mode = true:
98
+ → Load steps/step-07-tests.md
99
+
100
+ ELSE IF pr_mode = true:
101
+ → Create PR and show final summary
102
+
103
+ ELSE:
104
+ → Show final summary and exit
105
+ ```
@@ -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,227 @@
1
+ # Application Roles Seed Data Template
2
+
3
+ > Referenced from `core-seed-data.md` and `step-03-roles.md` — C# template for application-scoped roles in client projects.
4
+
5
+ ---
6
+
7
+ ## Problem Statement
8
+
9
+ When using `IClientSeedDataProvider` (client projects with `seeding_strategy = "provider"`), role-permission mappings reference roles by their `Code`:
10
+
11
+ ```csharp
12
+ var role = roles.FirstOrDefault(r => r.Code == mapping.RoleCode); // "admin", "manager", "contributor", "viewer"
13
+ ```
14
+
15
+ **However**, the current templates do NOT create these application-scoped roles. They assume:
16
+ - System roles (SuperAdmin, PlatformAdmin, TenantAdmin, StandardUser) exist in Core
17
+ - Application-scoped roles (Admin, Manager, Contributor, Viewer) already exist with valid `Code` values
18
+
19
+ **Result:** Role-permission mappings fail silently when `role == null`.
20
+
21
+ ---
22
+
23
+ ## Solution: Application Roles Seed Data
24
+
25
+ Create application-scoped roles with deterministic GUIDs and valid `Code` values.
26
+
27
+ ---
28
+
29
+ ## File Location
30
+
31
+ **Path:** `Infrastructure/Persistence/Seeding/Data/ApplicationRolesSeedData.cs`
32
+
33
+ This file should be created **ONCE per application** (not per module).
34
+
35
+ ---
36
+
37
+ ## Template
38
+
39
+ ```csharp
40
+ using SmartStack.Domain.Platform.Administration.Roles;
41
+
42
+ namespace {BaseNamespace}.Infrastructure.Persistence.Seeding.Data;
43
+
44
+ /// <summary>
45
+ /// Application-scoped role seed data for {AppLabel}.
46
+ /// Defines the 4 standard application roles: Admin, Manager, Contributor, Viewer.
47
+ /// Consumed by IClientSeedDataProvider at application startup.
48
+ /// </summary>
49
+ public static class ApplicationRolesSeedData
50
+ {
51
+ // Deterministic GUIDs for application roles
52
+ // Generated from: "role-{applicationId}-{roleType}"
53
+ private static readonly Guid ApplicationId = {ApplicationGuid}; // From NavigationApplicationSeedData
54
+
55
+ public static readonly Guid AdminRoleId = GenerateRoleGuid("admin");
56
+ public static readonly Guid ManagerRoleId = GenerateRoleGuid("manager");
57
+ public static readonly Guid ContributorRoleId = GenerateRoleGuid("contributor");
58
+ public static readonly Guid ViewerRoleId = GenerateRoleGuid("viewer");
59
+
60
+ /// <summary>
61
+ /// Returns application-scoped role entries for seeding into core.auth_Roles.
62
+ /// </summary>
63
+ public static IEnumerable<ApplicationRoleSeedEntry> GetRoleEntries()
64
+ {
65
+ yield return new ApplicationRoleSeedEntry
66
+ {
67
+ Id = AdminRoleId,
68
+ Code = "admin",
69
+ Name = "{AppLabel} Admin",
70
+ Description = "Full administrative access to {AppLabel}",
71
+ ApplicationId = ApplicationId,
72
+ IsSystem = false,
73
+ IsActive = true,
74
+ DisplayOrder = 1
75
+ };
76
+
77
+ yield return new ApplicationRoleSeedEntry
78
+ {
79
+ Id = ManagerRoleId,
80
+ Code = "manager",
81
+ Name = "{AppLabel} Manager",
82
+ Description = "Management access to {AppLabel} (Create, Read, Update)",
83
+ ApplicationId = ApplicationId,
84
+ IsSystem = false,
85
+ IsActive = true,
86
+ DisplayOrder = 2
87
+ };
88
+
89
+ yield return new ApplicationRoleSeedEntry
90
+ {
91
+ Id = ContributorRoleId,
92
+ Code = "contributor",
93
+ Name = "{AppLabel} Contributor",
94
+ Description = "Contributor access to {AppLabel} (Create, Read)",
95
+ ApplicationId = ApplicationId,
96
+ IsSystem = false,
97
+ IsActive = true,
98
+ DisplayOrder = 3
99
+ };
100
+
101
+ yield return new ApplicationRoleSeedEntry
102
+ {
103
+ Id = ViewerRoleId,
104
+ Code = "viewer",
105
+ Name = "{AppLabel} Viewer",
106
+ Description = "Read-only access to {AppLabel}",
107
+ ApplicationId = ApplicationId,
108
+ IsSystem = false,
109
+ IsActive = true,
110
+ DisplayOrder = 4
111
+ };
112
+ }
113
+
114
+ private static Guid GenerateRoleGuid(string roleType)
115
+ {
116
+ using var sha256 = System.Security.Cryptography.SHA256.Create();
117
+ var hash = sha256.ComputeHash(System.Text.Encoding.UTF8.GetBytes($"role-{ApplicationId}-{roleType}"));
118
+ return new Guid(hash.Take(16).ToArray());
119
+ }
120
+ }
121
+
122
+ /// <summary>Seed entry DTO for application role.</summary>
123
+ public class ApplicationRoleSeedEntry
124
+ {
125
+ public Guid Id { get; init; }
126
+ public string Code { get; init; } = null!;
127
+ public string Name { get; init; } = null!;
128
+ public string Description { get; init; } = null!;
129
+ public Guid ApplicationId { get; init; }
130
+ public bool IsSystem { get; init; }
131
+ public bool IsActive { get; init; }
132
+ public int DisplayOrder { get; init; }
133
+ }
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Placeholder Replacement
139
+
140
+ | Placeholder | Description | Example |
141
+ |-------------|-------------|---------|
142
+ | `{BaseNamespace}` | Root namespace of the client project | `SmartStack.Modules.RessourcesHumaines` |
143
+ | `{AppLabel}` | Human-readable application label (EN) | `Human Resources` |
144
+ | `{ApplicationGuid}` | GUID of the application (from NavigationApplicationSeedData) | `30f1fbba-e8c3-4879-9a49-d18deaa70a83` |
145
+
146
+ ---
147
+
148
+ ## Integration into IClientSeedDataProvider
149
+
150
+ Add a new method `SeedRolesAsync()` to the provider:
151
+
152
+ ```csharp
153
+ public async Task SeedRolesAsync(ICoreDbContext context, CancellationToken ct)
154
+ {
155
+ // Check idempotence
156
+ var exists = await context.Roles
157
+ .AnyAsync(r => r.ApplicationId == ApplicationRolesSeedData.ApplicationId, ct);
158
+ if (exists) return;
159
+
160
+ // Create application-scoped roles using factory method
161
+ foreach (var entry in ApplicationRolesSeedData.GetRoleEntries())
162
+ {
163
+ var role = Role.Create(
164
+ entry.Code,
165
+ entry.Name,
166
+ entry.Description,
167
+ entry.ApplicationId,
168
+ entry.IsSystem);
169
+
170
+ context.Roles.Add(role);
171
+ }
172
+
173
+ await ((DbContext)context).SaveChangesAsync(ct);
174
+ }
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Execution Order in Provider
180
+
181
+ **CRITICAL:** Roles must be created BEFORE role-permission mappings.
182
+
183
+ ```
184
+ 1. SeedNavigationAsync() → Creates application + modules + translations
185
+ 2. SeedRolesAsync() → Creates application-scoped roles (NEW)
186
+ 3. SeedPermissionsAsync() → Creates permissions
187
+ 4. SeedRolePermissionsAsync() → Maps roles to permissions (now succeeds because roles exist)
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Verification Checklist
193
+
194
+ Before marking the task as completed, verify:
195
+
196
+ - [ ] `ApplicationRolesSeedData.cs` created in `Infrastructure/Persistence/Seeding/Data/`
197
+ - [ ] Deterministic GUIDs used (NEVER `Guid.NewGuid()`)
198
+ - [ ] 4 roles defined: Admin, Manager, Contributor, Viewer
199
+ - [ ] Each role has a valid `Code` value ("admin", "manager", "contributor", "viewer")
200
+ - [ ] Each role has `ApplicationId` set to the application GUID
201
+ - [ ] `SeedRolesAsync()` method added to `IClientSeedDataProvider`
202
+ - [ ] `SeedRolesAsync()` is idempotent (checks existence before inserting)
203
+ - [ ] `Role.Create()` factory method used (NEVER `new Role()`)
204
+ - [ ] `SaveChangesAsync()` called after role creation
205
+ - [ ] Execution order: Navigation → Roles → Permissions → RolePermissions
206
+ - [ ] `dotnet build` passes after generation
207
+
208
+ ---
209
+
210
+ ## Notes
211
+
212
+ - **Application ID source:** Read from the navigation application created in `SeedNavigationAsync()` or from `{AppPascal}NavigationSeedData.cs`
213
+ - **Role factory method:** Use `Role.Create(code, name, description, applicationId, isSystem)` from SmartStack.Domain
214
+ - **Code uniqueness:** Role codes must be unique within the application scope
215
+ - **System roles:** These are NOT system roles (IsSystem = false) - they are application-scoped roles
216
+ - **Tenant isolation:** Application-scoped roles are automatically tenant-isolated via the Core authorization system
217
+
218
+ ---
219
+
220
+ ## Migration Impact
221
+
222
+ **For existing projects without application roles:**
223
+ 1. Generate `ApplicationRolesSeedData.cs` using this template
224
+ 2. Add `SeedRolesAsync()` method to the existing `IClientSeedDataProvider`
225
+ 3. Update the provider's execution to call `SeedRolesAsync()` BEFORE `SeedRolePermissionsAsync()`
226
+ 4. Run the application - roles will be created on next startup
227
+ 5. Role-permission mappings will now succeed