@atlashub/smartstack-cli 3.37.0 → 3.39.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 (228) hide show
  1. package/dist/index.js +16 -24
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +235 -265
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/scripts/extract-api-endpoints.ts +5 -5
  7. package/scripts/generate-doc-with-mock-ui.ts +10 -17
  8. package/templates/agents/ba-reader.md +9 -9
  9. package/templates/agents/ba-writer.md +12 -15
  10. package/templates/agents/code-reviewer.md +1 -1
  11. package/templates/agents/docs-context-reader.md +1 -1
  12. package/templates/agents/efcore/scan.md +3 -1
  13. package/templates/agents/gitflow/commit.md +74 -0
  14. package/templates/agents/gitflow/finish.md +5 -2
  15. package/templates/agents/gitflow/init-clone.md +3 -3
  16. package/templates/agents/gitflow/init-validate.md +3 -2
  17. package/templates/agents/gitflow/merge.md +5 -4
  18. package/templates/agents/gitflow/pr.md +5 -4
  19. package/templates/agents/gitflow/start.md +37 -5
  20. package/templates/hooks/hooks.json +11 -0
  21. package/templates/hooks/wsl-dotnet-cleanup.sh +24 -0
  22. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +20 -20
  23. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +16 -24
  24. package/templates/mcp-scaffolding/migrations/seed-roles.cs.hbs +2 -2
  25. package/templates/skills/_resources/mcp-validate-documentation-spec.md +3 -3
  26. package/templates/skills/_shared.md +15 -17
  27. package/templates/skills/ai-prompt/SKILL.md +1 -1
  28. package/templates/skills/ai-prompt/steps/step-00-init.md +47 -0
  29. package/templates/skills/apex/SKILL.md +3 -4
  30. package/templates/skills/apex/_shared.md +10 -20
  31. package/templates/skills/apex/references/analysis-methods.md +141 -0
  32. package/templates/skills/apex/references/challenge-questions.md +1 -21
  33. package/templates/skills/apex/references/core-seed-data.md +35 -58
  34. package/templates/skills/apex/references/examine-build-validation.md +82 -0
  35. package/templates/skills/apex/references/execution-frontend-gates.md +177 -0
  36. package/templates/skills/apex/references/execution-frontend-patterns.md +105 -0
  37. package/templates/skills/apex/references/execution-layer1-rules.md +96 -0
  38. package/templates/skills/apex/references/initialization-challenge-flow.md +110 -0
  39. package/templates/skills/apex/references/planning-layer-mapping.md +151 -0
  40. package/templates/skills/apex/references/post-checks.md +145 -40
  41. package/templates/skills/apex/references/smartstack-api.md +35 -51
  42. package/templates/skills/apex/references/smartstack-frontend.md +18 -18
  43. package/templates/skills/apex/references/smartstack-layers.md +38 -62
  44. package/templates/skills/apex/steps/step-00-init.md +14 -26
  45. package/templates/skills/apex/steps/step-01-analyze.md +10 -143
  46. package/templates/skills/apex/steps/step-02-plan.md +10 -92
  47. package/templates/skills/apex/steps/step-03-execute.md +45 -252
  48. package/templates/skills/apex/steps/step-04-examine.md +14 -78
  49. package/templates/skills/apex/steps/step-05-deep-review.md +2 -2
  50. package/templates/skills/apex/steps/step-08-run-tests.md +1 -0
  51. package/templates/skills/application/SKILL.md +241 -242
  52. package/templates/skills/application/references/backend-controller-hierarchy.md +16 -16
  53. package/templates/skills/application/references/backend-seeding-and-dto-output.md +83 -0
  54. package/templates/skills/application/references/backend-table-prefix-mapping.md +79 -0
  55. package/templates/skills/application/references/backend-verification.md +1 -1
  56. package/templates/skills/application/references/frontend-i18n-and-output.md +67 -0
  57. package/templates/skills/application/references/frontend-route-naming.md +117 -0
  58. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +107 -0
  59. package/templates/skills/application/references/frontend-verification.md +12 -12
  60. package/templates/skills/application/references/init-parameter-detection.md +121 -0
  61. package/templates/skills/application/references/migration-checklist-troubleshooting.md +100 -0
  62. package/templates/skills/application/references/nav-fallback-procedure.md +199 -200
  63. package/templates/skills/application/references/provider-template.md +2 -6
  64. package/templates/skills/application/references/roles-client-project-handling.md +55 -0
  65. package/templates/skills/application/references/roles-fallback-procedure.md +149 -0
  66. package/templates/skills/application/references/test-coverage-requirements.md +213 -0
  67. package/templates/skills/application/references/test-frontend.md +3 -3
  68. package/templates/skills/application/steps/step-00-init.md +130 -260
  69. package/templates/skills/application/steps/step-01-navigation.md +170 -170
  70. package/templates/skills/application/steps/step-02-permissions.md +196 -196
  71. package/templates/skills/application/steps/step-03-roles.md +182 -339
  72. package/templates/skills/application/steps/step-03b-provider.md +133 -134
  73. package/templates/skills/application/steps/step-04-backend.md +174 -265
  74. package/templates/skills/application/steps/step-05-frontend.md +18 -144
  75. package/templates/skills/application/steps/step-06-migration.md +12 -60
  76. package/templates/skills/application/steps/step-07-tests.md +9 -76
  77. package/templates/skills/application/templates-backend.md +29 -27
  78. package/templates/skills/application/templates-frontend.md +49 -49
  79. package/templates/skills/application/templates-seed.md +57 -131
  80. package/templates/skills/business-analyse/SKILL.md +27 -30
  81. package/templates/skills/business-analyse/_architecture.md +6 -6
  82. package/templates/skills/business-analyse/_shared.md +60 -88
  83. package/templates/skills/business-analyse/questionnaire/04-data.md +3 -3
  84. package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
  85. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +1 -1
  86. package/templates/skills/business-analyse/react/application-viewer.md +12 -12
  87. package/templates/skills/business-analyse/react/components.md +8 -12
  88. package/templates/skills/business-analyse/react/schema.md +836 -836
  89. package/templates/skills/business-analyse/references/agent-module-prompt.md +2 -3
  90. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +190 -0
  91. package/templates/skills/business-analyse/references/cache-warming-strategy.md +2 -2
  92. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +41 -0
  93. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +74 -0
  94. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +69 -0
  95. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +1 -1
  96. package/templates/skills/business-analyse/references/compilation-structure-cards.md +297 -0
  97. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +2 -2
  98. package/templates/skills/business-analyse/references/deploy-modes.md +5 -5
  99. package/templates/skills/business-analyse/references/detection-strategies.md +7 -7
  100. package/templates/skills/business-analyse/references/handoff-file-templates.md +14 -22
  101. package/templates/skills/business-analyse/references/handoff-mappings.md +4 -4
  102. package/templates/skills/business-analyse/references/handoff-seeddata-generation.md +312 -0
  103. package/templates/skills/business-analyse/references/init-schema-deployment.md +3 -3
  104. package/templates/skills/business-analyse/references/naming-conventions.md +22 -24
  105. package/templates/skills/business-analyse/references/prd-generation.md +2 -2
  106. package/templates/skills/business-analyse/references/review-data-mapping.md +2 -2
  107. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  108. package/templates/skills/business-analyse/references/spec-auto-inference.md +3 -3
  109. package/templates/skills/business-analyse/references/team-orchestration.md +49 -6
  110. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  111. package/templates/skills/business-analyse/references/ui-resource-cards.md +18 -18
  112. package/templates/skills/business-analyse/references/validate-incremental-html.md +2 -2
  113. package/templates/skills/business-analyse/references/validation-checklist.md +2 -2
  114. package/templates/skills/business-analyse/schemas/application-schema.json +4 -5
  115. package/templates/skills/business-analyse/schemas/project-schema.json +1 -6
  116. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -3
  117. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +4 -4
  118. package/templates/skills/business-analyse/steps/step-00-init.md +8 -17
  119. package/templates/skills/business-analyse/steps/step-01-cadrage.md +35 -198
  120. package/templates/skills/business-analyse/steps/step-01b-applications.md +16 -20
  121. package/templates/skills/business-analyse/steps/step-02-decomposition.md +1 -1
  122. package/templates/skills/business-analyse/steps/step-03a1-setup.md +4 -4
  123. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +1 -1
  124. package/templates/skills/business-analyse/steps/step-03b-ui.md +4 -4
  125. package/templates/skills/business-analyse/steps/step-03c-compile.md +66 -140
  126. package/templates/skills/business-analyse/steps/step-03d-validate.md +2 -2
  127. package/templates/skills/business-analyse/steps/step-04a-collect.md +2 -2
  128. package/templates/skills/business-analyse/steps/step-04b-analyze.md +42 -160
  129. package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
  130. package/templates/skills/business-analyse/steps/step-05a-handoff.md +74 -104
  131. package/templates/skills/business-analyse/steps/step-05b-deploy.md +13 -11
  132. package/templates/skills/business-analyse/steps/step-06-review.md +3 -3
  133. package/templates/skills/business-analyse/templates/tpl-frd.md +13 -13
  134. package/templates/skills/business-analyse/templates/tpl-handoff.md +12 -12
  135. package/templates/skills/business-analyse/templates/tpl-progress.md +1 -1
  136. package/templates/skills/business-analyse/templates-frd.md +25 -25
  137. package/templates/skills/business-analyse/templates-react.md +15 -21
  138. package/templates/skills/controller/SKILL.md +1 -1
  139. package/templates/skills/controller/postman-templates.md +1 -1
  140. package/templates/skills/controller/references/controller-code-templates.md +2 -2
  141. package/templates/skills/controller/references/mcp-scaffold-workflow.md +209 -0
  142. package/templates/skills/controller/references/permission-sync-templates.md +13 -16
  143. package/templates/skills/controller/steps/step-00-init.md +11 -11
  144. package/templates/skills/controller/steps/step-03-generate.md +64 -103
  145. package/templates/skills/controller/templates.md +67 -71
  146. package/templates/skills/debug/SKILL.md +13 -218
  147. package/templates/skills/debug/steps/step-00-init.md +57 -0
  148. package/templates/skills/debug/steps/step-01-analyze.md +219 -0
  149. package/templates/skills/debug/steps/step-02-resolve.md +85 -0
  150. package/templates/skills/documentation/SKILL.md +49 -345
  151. package/templates/skills/documentation/data-schema.md +11 -8
  152. package/templates/skills/documentation/steps/step-00-init.md +70 -0
  153. package/templates/skills/documentation/steps/step-01-scan.md +113 -0
  154. package/templates/skills/documentation/steps/step-02-generate.md +231 -0
  155. package/templates/skills/documentation/steps/step-03-validate.md +238 -0
  156. package/templates/skills/documentation/templates.md +480 -322
  157. package/templates/skills/efcore/SKILL.md +1 -1
  158. package/templates/skills/efcore/references/both-contexts.md +32 -0
  159. package/templates/skills/efcore/references/database-operations.md +67 -0
  160. package/templates/skills/efcore/references/destructive-operations.md +38 -0
  161. package/templates/skills/efcore/references/reset-operations.md +81 -0
  162. package/templates/skills/efcore/references/seed-methods.md +86 -0
  163. package/templates/skills/efcore/references/shared-init-functions.md +250 -0
  164. package/templates/skills/efcore/references/sql-objects-injection.md +61 -0
  165. package/templates/skills/efcore/references/troubleshooting.md +81 -0
  166. package/templates/skills/efcore/steps/db/step-deploy.md +1 -32
  167. package/templates/skills/efcore/steps/db/step-reset.md +7 -103
  168. package/templates/skills/efcore/steps/db/step-seed.md +10 -132
  169. package/templates/skills/efcore/steps/db/step-status.md +5 -44
  170. package/templates/skills/efcore/steps/migration/step-02-create.md +1 -14
  171. package/templates/skills/efcore/steps/migration/step-03-validate.md +8 -62
  172. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +1 -57
  173. package/templates/skills/efcore/steps/shared/step-00-init.md +11 -254
  174. package/templates/skills/efcore/steps/squash/step-03-create.md +1 -58
  175. package/templates/skills/feature-full/SKILL.md +1 -1
  176. package/templates/skills/feature-full/steps/step-00-init.md +57 -0
  177. package/templates/skills/feature-full/steps/step-01-implementation.md +1 -1
  178. package/templates/skills/gitflow/SKILL.md +28 -5
  179. package/templates/skills/gitflow/_shared.md +109 -12
  180. package/templates/skills/gitflow/phases/abort.md +4 -0
  181. package/templates/skills/gitflow/phases/cleanup.md +4 -0
  182. package/templates/skills/gitflow/references/commit-message-generation.md +58 -0
  183. package/templates/skills/gitflow/references/commit-migration-validation.md +49 -0
  184. package/templates/skills/gitflow/references/finish-cleanup.md +55 -0
  185. package/templates/skills/gitflow/references/finish-version-bumping.md +45 -0
  186. package/templates/skills/gitflow/references/init-environment-detection.md +41 -0
  187. package/templates/skills/gitflow/references/init-questions.md +185 -0
  188. package/templates/skills/gitflow/references/init-structure-creation.md +75 -0
  189. package/templates/skills/gitflow/references/init-version-detection.md +21 -0
  190. package/templates/skills/gitflow/references/init-workspace-detection.md +43 -0
  191. package/templates/skills/gitflow/references/merge-ci-status.md +36 -0
  192. package/templates/skills/gitflow/references/merge-execution.md +62 -0
  193. package/templates/skills/gitflow/references/merge-pr-context.md +76 -0
  194. package/templates/skills/gitflow/references/pr-build-checks.md +60 -0
  195. package/templates/skills/gitflow/references/pr-generation.md +58 -0
  196. package/templates/skills/gitflow/references/start-branch-normalization.md +28 -0
  197. package/templates/skills/gitflow/references/start-worktree-creation.md +50 -0
  198. package/templates/skills/gitflow/references/sync-push-verify.md +44 -0
  199. package/templates/skills/gitflow/references/sync-rebase-conflicts.md +38 -0
  200. package/templates/skills/gitflow/steps/step-commit.md +12 -91
  201. package/templates/skills/gitflow/steps/step-finish.md +15 -159
  202. package/templates/skills/gitflow/steps/step-init.md +24 -326
  203. package/templates/skills/gitflow/steps/step-merge.md +17 -176
  204. package/templates/skills/gitflow/steps/step-pr.md +10 -116
  205. package/templates/skills/gitflow/steps/step-start.md +16 -109
  206. package/templates/skills/gitflow/steps/step-sync.md +6 -69
  207. package/templates/skills/ralph-loop/SKILL.md +6 -0
  208. package/templates/skills/ralph-loop/references/category-completeness.md +185 -0
  209. package/templates/skills/ralph-loop/references/compact-loop.md +1 -1
  210. package/templates/skills/ralph-loop/references/init-resume-recovery.md +127 -0
  211. package/templates/skills/ralph-loop/references/module-transition.md +151 -0
  212. package/templates/skills/ralph-loop/references/multi-module-queue.md +171 -0
  213. package/templates/skills/ralph-loop/references/parallel-execution.md +246 -0
  214. package/templates/skills/ralph-loop/references/task-transform-legacy.md +6 -9
  215. package/templates/skills/ralph-loop/references/team-orchestration.md +45 -3
  216. package/templates/skills/ralph-loop/steps/step-00-init.md +36 -109
  217. package/templates/skills/ralph-loop/steps/step-01-task.md +15 -163
  218. package/templates/skills/ralph-loop/steps/step-02-execute.md +8 -154
  219. package/templates/skills/ralph-loop/steps/step-04-check.md +20 -73
  220. package/templates/skills/review-code/references/owasp-api-top10.md +5 -5
  221. package/templates/skills/review-code/references/smartstack-conventions.md +568 -568
  222. package/templates/skills/validate-feature/references/api-smoke-tests.md +140 -0
  223. package/templates/skills/validate-feature/references/db-validation-checks.md +180 -0
  224. package/templates/skills/validate-feature/steps/step-01-compile.md +1 -3
  225. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +34 -145
  226. package/templates/skills/validate-feature/steps/step-05-db-validation.md +74 -260
  227. package/templates/skills/workflow/SKILL.md +1 -1
  228. package/templates/skills/workflow/steps/step-00-init.md +57 -0
@@ -1,339 +1,182 @@
1
- ---
2
- name: step-03-roles
3
- description: Generate application roles and role-permission mappings using MCP scaffold_role_permissions (with fallback)
4
- prev_step: steps/step-02-permissions.md
5
- next_step: steps/step-03b-provider.md
6
- ---
7
-
8
- # Step 3: Application Roles & Role-Permission Mapping
9
-
10
- ## MANDATORY EXECUTION RULES
11
-
12
- - For **client projects** (`seeding_strategy = "provider"`): Generate ApplicationRolesSeedData.cs and module role mappings
13
- - For **core projects** (`seeding_strategy = "hasdata"`): Use RolePermissionConfiguration.cs
14
- - PREFER MCP `scaffold_role_permissions` tool as the primary method
15
- - If MCP is unavailable or the call fails, use the FALLBACK PROCEDURE below
16
- - ALWAYS assign permissions to default roles
17
- - NEVER leave permissions without role assignments
18
- - ALWAYS WRITE generated code to the actual files
19
-
20
- ## YOUR TASK
21
-
22
- For **client projects**:
23
- 1. **ApplicationRolesSeedData.cs** (once per application) — defines the 4 application-scoped roles
24
- 2. **{Module}RolePermissionSeedData.cs** (per module) — maps permissions to roles by Code
25
-
26
- For **core projects**:
27
- 1. RolePermissionConfiguration.cs HasData() entries
28
- 2. Default role assignments (SuperAdmin, PlatformAdmin, TenantAdmin, StandardUser)
29
- 3. Application-scoped role assignments (Admin, Manager, Contributor, Viewer)
30
-
31
- ---
32
-
33
- ## AVAILABLE STATE
34
-
35
- From previous steps:
36
-
37
- | Variable | Description |
38
- |----------|-------------|
39
- | `{full_path}` | Complete navigation path (navRoute) |
40
- | `{level}` | context, application, module, or section |
41
- | `{permission_guids}` | GUIDs for generated permissions |
42
- | `{mcp_available}` | Boolean - MCP connectivity status |
43
- | `{project_type}` | "core" or "client" |
44
- | `{seeding_strategy}` | "hasdata" or "provider" |
45
-
46
- ---
47
-
48
- ## EXECUTION SEQUENCE (MCP Primary)
49
-
50
- ### 1. Determine Default Role Assignments
51
-
52
- Based on navigation context, apply default role mappings:
53
-
54
- | Context | PlatformAdmin | TenantAdmin | StandardUser |
55
- |---------|---------------|-------------|--------------|
56
- | `platform.*` | Full CRUD | Read only | None |
57
- | `business.*` | Full CRUD | Full CRUD | Read only |
58
- | `personal.*` | None | Full CRUD | Full CRUD |
59
-
60
- ### 2. Call MCP scaffold_role_permissions
61
-
62
- ```
63
- Tool: mcp__smartstack__scaffold_role_permissions
64
- Args:
65
- navRoute: "{full_path}"
66
- roles:
67
- platformAdmin: ["read", "create", "update", "delete"] # Adjust based on context
68
- tenantAdmin: ["read", "create", "update"] # Adjust based on context
69
- standardUser: ["read"] # Adjust based on context
70
- includeWildcard: true
71
- ```
72
-
73
- ### 3. Parse MCP Response
74
-
75
- The tool returns:
76
- - RolePermissionConfiguration.cs HasData() entries
77
- - Permission ID variable references
78
- - Role ID variable references
79
-
80
- ### 4. Write Code to Files
81
-
82
- **CRITICAL:** WRITE the generated code to the actual RolePermissionConfiguration.cs file.
83
-
84
- ### 5. Present Summary
85
-
86
- ```markdown
87
- ## Role-Permission Mappings
88
-
89
- | Role | Permissions |
90
- |------|-------------|
91
- | SuperAdmin | `{full_path}.*` (via wildcard) |
92
- | PlatformAdmin | `{full_path}.read`, `.create`, `.update`, `.delete` |
93
- | TenantAdmin | `{full_path}.read`, `.create`, `.update` |
94
- | StandardUser | `{full_path}.read` |
95
- ```
96
-
97
- ### 6. Confirm with User (Optional)
98
-
99
- ```yaml
100
- questions:
101
- - header: "Role Access"
102
- question: "Adjust role permissions for {full_path}?"
103
- options:
104
- - label: "Keep defaults (Recommended)"
105
- description: "PlatformAdmin: CRUD, TenantAdmin: CRU, StandardUser: R"
106
- - label: "All roles full access"
107
- description: "All roles get full CRUD access"
108
- - label: "Custom"
109
- description: "I'll specify custom permissions"
110
- multiSelect: false
111
- ```
112
-
113
- ---
114
-
115
- ## MCP RESPONSE HANDLING
116
-
117
- ### Success Case
118
-
119
- If MCP returns successfully:
120
- - Write RolePermission HasData code to file
121
- - Show role-permission summary table
122
- - Proceed to step-04-backend.md
123
-
124
- ### Error Case
125
-
126
- If MCP call fails or `{mcp_available}` = false:
127
- - Log the error for reference
128
- - Proceed to FALLBACK PROCEDURE below
129
- - Do NOT stop the workflow
130
-
131
- ---
132
-
133
- ## CLIENT PROJECT HANDLING
134
-
135
- > **Condition:** `{seeding_strategy}` = "provider"
136
-
137
- **For core (`{seeding_strategy}` = "hasdata"):** Write in RolePermissionConfiguration.cs (existing pattern)
138
-
139
- **For client (`{seeding_strategy}` = "provider"):** DO NOT write in RolePermissionConfiguration.cs (does not exist in client projects).
140
-
141
- Instead, create TWO files:
142
-
143
- ### 1. ApplicationRolesSeedData.cs (ONCE per application)
144
-
145
- **File:** `Infrastructure/Persistence/Seeding/Data/ApplicationRolesSeedData.cs`
146
-
147
- **Purpose:** Defines the 4 standard application-scoped roles (Admin, Manager, Contributor, Viewer) with valid `Code` values.
148
-
149
- **CRITICAL:** Without this file, role-permission mappings in `SeedRolePermissionsAsync()` will fail silently because `roles.FirstOrDefault(r => r.Code == mapping.RoleCode)` will return null.
150
-
151
- See [references/application-roles-template.md](../references/application-roles-template.md) for the complete template.
152
-
153
- **Key requirements:**
154
- - Deterministic GUIDs based on `role-{applicationId}-{roleType}`
155
- - 4 roles: Admin, Manager, Contributor, Viewer
156
- - Each role has a valid `Code` property ("admin", "manager", "contributor", "viewer")
157
- - `ApplicationId` references the navigation application GUID
158
- - `IsSystem = false` (application-scoped, not system roles)
159
-
160
- **Detection:** Check if ApplicationRolesSeedData.cs exists. If yes, skip creation (already exists from Module 1). If no, create it.
161
-
162
- ### 2. {Module}RolePermissionSeedData.cs (PER module)
163
-
164
- **File:** `Infrastructure/Persistence/Seeding/Data/{Domain}/{Module}RolePermissionSeedData.cs`
165
-
166
- **Purpose:** Maps permissions to roles by Code (e.g., "admin" → "{navRoute}.*").
167
-
168
- Content: static class with method `GetRolePermissionEntries()` that returns the role-permission mapping data.
169
- These entries will be consumed by the `IClientSeedDataProvider` at step 03b.
170
-
171
- **After creating both files:** Proceed to step-03b-provider.md (which will skip for core projects).
172
-
173
- ---
174
-
175
- ## FALLBACK PROCEDURE (When MCP Unavailable)
176
-
177
- > This procedure generates role-permission HasData entries following SmartStack.app patterns.
178
-
179
- ### F1. Read Existing RolePermissionConfiguration.cs
180
-
181
- ```
182
- Glob: **/Persistence/Configurations/Authorization/RolePermissionConfiguration.cs
183
- ```
184
-
185
- Read the file to determine:
186
- - Existing role-permission mappings
187
- - The GetSeedData() method structure
188
- - Which roles already have which permissions
189
- - The GUID generation method used (deterministic or hardcoded)
190
-
191
- ### F2. Read Role GUIDs
192
-
193
- **System-level roles** (well-known GUIDs):
194
-
195
- | Role | GUID |
196
- |------|------|
197
- | SuperAdmin | `11111111-1111-1111-1111-111111111111` |
198
- | PlatformAdmin | `22222222-2222-2222-2222-222222222222` |
199
- | TenantAdmin | `33333333-3333-3333-3333-333333333333` |
200
- | StandardUser | `44444444-4444-4444-4444-444444444444` |
201
-
202
- **IMPORTANT:** Read the actual `RoleSeedData.cs` or `RoleConfiguration.cs` in the target project to confirm the actual role GUIDs. The above are defaults; the project may use different values.
203
-
204
- **Application-scoped roles** (deterministic GUIDs based on application):
205
-
206
- ```csharp
207
- // Read the existing GenerateDeterministicGuid method in RolePermissionConfiguration.cs
208
- // Typically uses MD5 hash:
209
- private static Guid GenerateDeterministicGuid(Guid applicationId, string roleType)
210
- {
211
- using var md5 = System.Security.Cryptography.MD5.Create();
212
- var input = $"{applicationId}-{roleType}";
213
- var hash = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(input));
214
- return new Guid(hash);
215
- }
216
- // roleType values: "admin", "manager", "contributor", "viewer"
217
- ```
218
-
219
- Find the `applicationId` from `NavigationApplicationSeedData.cs` matching `{full_path}`.
220
-
221
- ### F3. Determine Context-Based Default Mappings
222
-
223
- Based on `{full_path}` prefix:
224
-
225
- | Context Prefix | SuperAdmin | PlatformAdmin | App Admin | App Manager | App Contributor | App Viewer |
226
- |----------------|------------|---------------|-----------|-------------|-----------------|------------|
227
- | `platform.*` | wildcard | Full CRUD | Full CRUD | CRU | CR | R |
228
- | `business.*` | wildcard | Full CRUD | Full CRUD | CRU | CR | R |
229
- | `personal.*` | wildcard | None | Full CRUD | CRU | CR | R |
230
-
231
- ### F4. Generate RolePermission HasData Entries
232
-
233
- Using `{permission_guids}` from step-02:
234
-
235
- ```csharp
236
- // In RolePermissionConfiguration.cs - GetSeedData() method
237
- var seedDate = SeedConstants.SeedDate;
238
-
239
- // ============================================================
240
- // {MODULE_NAME} PERMISSIONS
241
- // ============================================================
242
-
243
- // SuperAdmin: already has *.* wildcard - no individual entries needed
244
-
245
- // PlatformAdmin (for platform.* context)
246
- rolePermissions.Add(new { RoleId = platformAdminRoleId, PermissionId = {permission_guids.read}, AssignedAt = seedDate });
247
- rolePermissions.Add(new { RoleId = platformAdminRoleId, PermissionId = {permission_guids.create}, AssignedAt = seedDate });
248
- rolePermissions.Add(new { RoleId = platformAdminRoleId, PermissionId = {permission_guids.update}, AssignedAt = seedDate });
249
- rolePermissions.Add(new { RoleId = platformAdminRoleId, PermissionId = {permission_guids.delete}, AssignedAt = seedDate });
250
-
251
- // Application-scoped: Admin → wildcard
252
- rolePermissions.Add(new { RoleId = appAdminRoleId, PermissionId = {permission_guids.wildcard}, AssignedAt = seedDate });
253
-
254
- // Application-scoped: Manager → CRU (read + create + update — no delete)
255
- rolePermissions.Add(new { RoleId = appManagerRoleId, PermissionId = {permission_guids.read}, AssignedAt = seedDate });
256
- rolePermissions.Add(new { RoleId = appManagerRoleId, PermissionId = {permission_guids.create}, AssignedAt = seedDate });
257
- rolePermissions.Add(new { RoleId = appManagerRoleId, PermissionId = {permission_guids.update}, AssignedAt = seedDate });
258
-
259
- // Application-scoped: Contributor → CR
260
- rolePermissions.Add(new { RoleId = appContributorRoleId, PermissionId = {permission_guids.read}, AssignedAt = seedDate });
261
- rolePermissions.Add(new { RoleId = appContributorRoleId, PermissionId = {permission_guids.create}, AssignedAt = seedDate });
262
-
263
- // Application-scoped: Viewer → R
264
- rolePermissions.Add(new { RoleId = appViewerRoleId, PermissionId = {permission_guids.read}, AssignedAt = seedDate });
265
- ```
266
-
267
- ### F5. Write Code to RolePermissionConfiguration.cs
268
-
269
- **CRITICAL:** Do NOT just display code. WRITE it to the actual file.
270
-
271
- 1. Open `RolePermissionConfiguration.cs`
272
- 2. Find the `GetSeedData()` method
273
- 3. Add the new role-permission entries to the list
274
- 4. Add necessary permission GUID references (import from PermissionConfiguration or use inline)
275
- 5. Add comments grouping the new entries: `// {MODULE_NAME} PERMISSIONS`
276
-
277
- ### F6. Present Summary
278
-
279
- ```markdown
280
- ## Role-Permission Mappings Generated (Fallback)
281
-
282
- | Role | Permissions |
283
- |------|-------------|
284
- | SuperAdmin | Already has wildcard access |
285
- | PlatformAdmin | {full_path}.read, .create, .update, .delete |
286
- | App Admin | {full_path}.* (wildcard) |
287
- | App Manager | {full_path}.read, .create, .update |
288
- | App Contributor | {full_path}.read, .create |
289
- | App Viewer | {full_path}.read |
290
-
291
- Written to: RolePermissionConfiguration.cs
292
- ```
293
-
294
- ### F7. Offer User Adjustment
295
-
296
- ```yaml
297
- questions:
298
- - header: "Role Access"
299
- question: "Default role-permission mappings have been applied. Adjust?"
300
- options:
301
- - label: "Keep defaults (Recommended)"
302
- description: "Standard role hierarchy applied"
303
- - label: "Custom adjustments"
304
- description: "I want to change specific role permissions"
305
- multiSelect: false
306
- ```
307
-
308
- If user selects "Custom adjustments", ask which roles/permissions to change and update the file accordingly.
309
-
310
- ---
311
-
312
- ## SUCCESS METRICS
313
-
314
- **For client projects:**
315
- - ApplicationRolesSeedData.cs created (once per application)
316
- - {Module}RolePermissionSeedData.cs created with role-permission mappings
317
- - All 4 application roles defined with valid Code values
318
- - Proceeded to step-03b-provider.md
319
-
320
- **For core projects:**
321
- - Role-permission mappings generated (via MCP or fallback)
322
- - RolePermissionConfiguration.cs WRITTEN with new entries
323
- - All default roles have appropriate access
324
- - Proceeded to step-04-backend.md
325
-
326
- ## FAILURE MODES
327
-
328
- - Permission GUIDs not available from step-02 (return to step-02)
329
- - Role GUIDs not found in project (ask user, use well-known defaults)
330
- - Invalid navRoute format (return to step-00)
331
-
332
- ---
333
-
334
- ## NEXT STEP
335
-
336
- After role-permission mappings are generated (via MCP or fallback) and written to files,
337
- proceed to `./step-03b-provider.md`
338
-
339
- > **Note:** step-03b will automatically skip if `{seeding_strategy}` = "hasdata" and proceed directly to step-04-backend.
1
+ ---
2
+ name: step-03-roles
3
+ description: Generate application roles and role-permission mappings using MCP scaffold_role_permissions (with fallback)
4
+ prev_step: steps/step-02-permissions.md
5
+ next_step: steps/step-03b-provider.md
6
+ ---
7
+
8
+ # Step 3: Application Roles & Role-Permission Mapping
9
+
10
+ ## MANDATORY EXECUTION RULES
11
+
12
+ - For **client projects** (`seeding_strategy = "provider"`): Generate ApplicationRolesSeedData.cs and module role mappings
13
+ - For **core projects** (`seeding_strategy = "hasdata"`): Use RolePermissionConfiguration.cs
14
+ - PREFER MCP `scaffold_role_permissions` tool as the primary method
15
+ - If MCP is unavailable or the call fails, use the FALLBACK PROCEDURE below
16
+ - ALWAYS assign permissions to default roles
17
+ - NEVER leave permissions without role assignments
18
+ - ALWAYS WRITE generated code to the actual files
19
+
20
+ ## YOUR TASK
21
+
22
+ For **client projects**:
23
+ 1. **ApplicationRolesSeedData.cs** (once per application) — defines the 4 application-scoped roles
24
+ 2. **{Module}RolePermissionSeedData.cs** (per module) — maps permissions to roles by Code
25
+
26
+ For **core projects**:
27
+ 1. RolePermissionConfiguration.cs HasData() entries
28
+ 2. Default role assignments (SuperAdmin, PlatformAdmin, TenantAdmin, StandardUser)
29
+ 3. Application-scoped role assignments (Admin, Manager, Contributor, Viewer)
30
+
31
+ ---
32
+
33
+ ## AVAILABLE STATE
34
+
35
+ From previous steps:
36
+
37
+ | Variable | Description |
38
+ |----------|-------------|
39
+ | `{full_path}` | Complete navigation path (navRoute) |
40
+ | `{level}` | application, module, section, or resource |
41
+ | `{permission_guids}` | GUIDs for generated permissions |
42
+ | `{mcp_available}` | Boolean - MCP connectivity status |
43
+ | `{project_type}` | "core" or "client" |
44
+ | `{seeding_strategy}` | "hasdata" or "provider" |
45
+
46
+ ---
47
+
48
+ ## EXECUTION SEQUENCE (MCP Primary)
49
+
50
+ ### 1. Determine Default Role Assignments
51
+
52
+ See [references/roles-client-project-handling.md](../references/roles-client-project-handling.md) for:
53
+ - Default role mapping table by application prefix
54
+ - ApplicationRolesSeedData.cs requirements (once per application)
55
+ - {Module}RolePermissionSeedData.cs requirements (per module)
56
+
57
+ ### 2. Call MCP scaffold_role_permissions
58
+
59
+ ```
60
+ Tool: mcp__smartstack__scaffold_role_permissions
61
+ Args:
62
+ navRoute: "{full_path}"
63
+ roles:
64
+ platformAdmin: ["read", "create", "update", "delete"] # Adjust based on context
65
+ tenantAdmin: ["read", "create", "update"] # Adjust based on context
66
+ standardUser: ["read"] # Adjust based on context
67
+ includeWildcard: true
68
+ ```
69
+
70
+ ### 3. Parse MCP Response
71
+
72
+ The tool returns:
73
+ - RolePermissionConfiguration.cs HasData() entries
74
+ - Permission ID variable references
75
+ - Role ID variable references
76
+
77
+ ### 4. Write Code to Files
78
+
79
+ **CRITICAL:** WRITE the generated code to the actual RolePermissionConfiguration.cs file.
80
+
81
+ ### 5. Present Summary
82
+
83
+ ```markdown
84
+ ## Role-Permission Mappings
85
+
86
+ | Role | Permissions |
87
+ |------|-------------|
88
+ | SuperAdmin | `{full_path}.*` (via wildcard) |
89
+ | PlatformAdmin | `{full_path}.read`, `.create`, `.update`, `.delete` |
90
+ | TenantAdmin | `{full_path}.read`, `.create`, `.update` |
91
+ | StandardUser | `{full_path}.read` |
92
+ ```
93
+
94
+ ### 6. Confirm with User (Optional)
95
+
96
+ ```yaml
97
+ questions:
98
+ - header: "Role Access"
99
+ question: "Adjust role permissions for {full_path}?"
100
+ options:
101
+ - label: "Keep defaults (Recommended)"
102
+ description: "PlatformAdmin: CRUD, TenantAdmin: CRU, StandardUser: R"
103
+ - label: "All roles full access"
104
+ description: "All roles get full CRUD access"
105
+ - label: "Custom"
106
+ description: "I'll specify custom permissions"
107
+ multiSelect: false
108
+ ```
109
+
110
+ ---
111
+
112
+ ## MCP RESPONSE HANDLING
113
+
114
+ ### Success Case
115
+
116
+ If MCP returns successfully:
117
+ - Write RolePermission HasData code to file
118
+ - Show role-permission summary table
119
+ - Proceed to step-04-backend.md
120
+
121
+ ### Error Case
122
+
123
+ If MCP call fails or `{mcp_available}` = false:
124
+ - Log the error for reference
125
+ - Proceed to FALLBACK PROCEDURE below
126
+ - Do NOT stop the workflow
127
+
128
+ ---
129
+
130
+ ## CLIENT PROJECT HANDLING
131
+
132
+ > **Condition:** `{seeding_strategy}` = "provider"
133
+
134
+ See [references/roles-client-project-handling.md](../references/roles-client-project-handling.md) for:
135
+ - ApplicationRolesSeedData.cs creation (once per application)
136
+ - {Module}RolePermissionSeedData.cs creation (per module)
137
+ - Role code naming and GUID generation rules
138
+ - Detection of existing ApplicationRolesSeedData.cs
139
+
140
+ ---
141
+
142
+ ## FALLBACK PROCEDURE (When MCP Unavailable)
143
+
144
+ See [references/roles-fallback-procedure.md](../references/roles-fallback-procedure.md) for the complete 7-step fallback:
145
+ - **F1:** Read existing RolePermissionConfiguration.cs to determine state
146
+ - **F2:** Read role GUIDs (system-level and application-scoped)
147
+ - **F3:** Determine default mappings based on application prefix
148
+ - **F4:** Generate RolePermission HasData entries using permission GUIDs
149
+ - **F5:** Write code to RolePermissionConfiguration.cs (CRITICAL: WRITE not display)
150
+ - **F6:** Present summary
151
+ - **F7:** Offer user adjustment option
152
+
153
+ ---
154
+
155
+ ## SUCCESS METRICS
156
+
157
+ **For client projects:**
158
+ - ApplicationRolesSeedData.cs created (once per application)
159
+ - {Module}RolePermissionSeedData.cs created with role-permission mappings
160
+ - All 4 application roles defined with valid Code values
161
+ - Proceeded to step-03b-provider.md
162
+
163
+ **For core projects:**
164
+ - Role-permission mappings generated (via MCP or fallback)
165
+ - RolePermissionConfiguration.cs WRITTEN with new entries
166
+ - All default roles have appropriate access
167
+ - Proceeded to step-04-backend.md
168
+
169
+ ## FAILURE MODES
170
+
171
+ - Permission GUIDs not available from step-02 (return to step-02)
172
+ - Role GUIDs not found in project (ask user, use well-known defaults)
173
+ - Invalid navRoute format (return to step-00)
174
+
175
+ ---
176
+
177
+ ## NEXT STEP
178
+
179
+ After role-permission mappings are generated (via MCP or fallback) and written to files,
180
+ proceed to `./step-03b-provider.md`
181
+
182
+ > **Note:** step-03b will automatically skip if `{seeding_strategy}` = "hasdata" and proceed directly to step-04-backend.