@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,152 @@
1
+ # Permission Synchronization Templates
2
+
3
+ > Referenced from `steps/step-04-perms.md` — C# code templates for Permissions.cs, PermissionConfiguration.cs, and Postman tests.
4
+
5
+ ---
6
+
7
+ ## Permissions.cs Template
8
+
9
+ **Target file:** `src/SmartStack.Application/Common/Authorization/Permissions.cs`
10
+
11
+ **Find the correct parent class based on `{permission_path}`:**
12
+
13
+ | Permission Path | Parent Class |
14
+ |-----------------|--------------|
15
+ | `platform.administration.*` | `Platform.Administration` |
16
+ | `platform.support.*` | `Platform.Support` |
17
+ | `business.*` | `Business` |
18
+ | `personal.myspace.*` | `Personal.MySpace` |
19
+
20
+ **Add nested class:**
21
+
22
+ ```csharp
23
+ public static class {module}
24
+ {
25
+ public const string View = "{permission_path}.read";
26
+ public const string Create = "{permission_path}.create";
27
+ public const string Update = "{permission_path}.update";
28
+ public const string Delete = "{permission_path}.delete";
29
+ }
30
+ ```
31
+
32
+ **Example for platform.support.tickets:**
33
+
34
+ ```csharp
35
+ public static partial class Permissions
36
+ {
37
+ public static class Platform
38
+ {
39
+ public static class Support
40
+ {
41
+ // Existing classes...
42
+
43
+ public static class Tickets // NEW
44
+ {
45
+ public const string View = "platform.support.tickets.read";
46
+ public const string Create = "platform.support.tickets.create";
47
+ public const string Update = "platform.support.tickets.update";
48
+ public const string Delete = "platform.support.tickets.delete";
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ ---
56
+
57
+ ## PermissionConfiguration.cs Template
58
+
59
+ **Target file:** `src/SmartStack.Infrastructure/Persistence/Configurations/PermissionConfiguration.cs`
60
+
61
+ **Find HasData section and add seeds:**
62
+
63
+ ```csharp
64
+ builder.HasData(
65
+ // Existing permissions...
66
+
67
+ // {module} permissions
68
+ new Permission
69
+ {
70
+ Id = Guid.NewGuid(), // Generate new GUID
71
+ Code = "{permission_path}.read",
72
+ Name = "View {module}",
73
+ Description = "Allows viewing {module_lowercase} list and details",
74
+ Category = "{area}",
75
+ IsSystem = true,
76
+ CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
77
+ },
78
+ new Permission
79
+ {
80
+ Id = Guid.NewGuid(),
81
+ Code = "{permission_path}.create",
82
+ Name = "Create {module}",
83
+ Description = "Allows creating new {module_lowercase}",
84
+ Category = "{area}",
85
+ IsSystem = true,
86
+ CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
87
+ },
88
+ new Permission
89
+ {
90
+ Id = Guid.NewGuid(),
91
+ Code = "{permission_path}.update",
92
+ Name = "Update {module}",
93
+ Description = "Allows updating existing {module_lowercase}",
94
+ Category = "{area}",
95
+ IsSystem = true,
96
+ CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
97
+ },
98
+ new Permission
99
+ {
100
+ Id = Guid.NewGuid(),
101
+ Code = "{permission_path}.delete",
102
+ Name = "Delete {module}",
103
+ Description = "Allows deleting {module_lowercase}",
104
+ Category = "{area}",
105
+ IsSystem = true,
106
+ CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
107
+ }
108
+ );
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Postman Test Templates
114
+
115
+ **If `{postman_mode}` = true, generate API tests:**
116
+
117
+ ```json
118
+ {
119
+ "name": "{module} API Tests",
120
+ "item": [
121
+ {
122
+ "name": "GET {module} - SuperAdmin (200)",
123
+ "request": {
124
+ "method": "GET",
125
+ "url": "{{baseUrl}}/api/{area}/{module}"
126
+ },
127
+ "event": [
128
+ {
129
+ "listen": "test",
130
+ "script": {
131
+ "exec": ["pm.test('Status 200', () => pm.response.to.have.status(200));"]
132
+ }
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ "name": "GET {module} - No Permission (403)",
138
+ "request": { "method": "GET", "url": "{{baseUrl}}/api/{area}/{module}" },
139
+ "event": [
140
+ {
141
+ "listen": "prerequest",
142
+ "script": { "exec": ["// Use NoPermUser token"] }
143
+ },
144
+ {
145
+ "listen": "test",
146
+ "script": { "exec": ["pm.test('Status 403', () => pm.response.to.have.status(403));"] }
147
+ }
148
+ ]
149
+ }
150
+ ]
151
+ }
152
+ ```
@@ -1,199 +1,188 @@
1
1
  ---
2
2
  name: step-03-generate
3
- description: Generate controller file and DTOs
3
+ description: Generate controller using MCP scaffold_extension with NavRoute
4
4
  next_step: steps/step-04-perms.md
5
5
  ---
6
6
 
7
7
  # Step 3: Generate Controller
8
8
 
9
- ## YOUR TASK:
9
+ ## MANDATORY EXECUTION RULES
10
10
 
11
- Generate the controller file following SmartStack conventions. Use templates from `templates.md`.
11
+ - ALWAYS use MCP `scaffold_extension` tool - NEVER use templates
12
+ - ALWAYS generate Controller + DTOs as a unit
13
+ - ALWAYS include NavRoute attribute for frontend/backend sync
14
+ - YOU ARE AN ORCHESTRATOR calling MCP, not a generator
15
+ - MCP is the SOURCE OF TRUTH for code generation
12
16
 
13
- **ULTRA THINK about security and patterns.**
17
+ ## YOUR TASK
18
+
19
+ Call the SmartStack MCP `scaffold_extension` tool with type "controller" to generate:
20
+ 1. API Controller with NavRoute attribute
21
+ 2. DTOs (Response, Create, Update)
14
22
 
15
23
  ---
16
24
 
17
- ## EXECUTION SEQUENCE:
25
+ ## AVAILABLE STATE
18
26
 
19
- ### 1. Load Templates
27
+ From previous steps:
20
28
 
21
- **Read template file:**
29
+ | Variable | Description |
30
+ |----------|-------------|
31
+ | `{area}` | Controller folder (Admin, Business, Support, User) |
32
+ | `{module}` | kebab-case module identifier |
33
+ | `{entity}` | Entity name (PascalCase) |
34
+ | `{permission_path}` | Complete navigation path (navRoute) |
35
+ | `{controller_type}` | crud, readonly, custom, auth |
22
36
 
23
- ```
24
- Read: templates/templates.md
25
- ```
37
+ ---
26
38
 
27
- **Select appropriate template based on {controller_type}:**
28
- - CRUD Controller template
29
- - Auth Controller template
30
- - ReadOnly Controller template
39
+ ## EXECUTION SEQUENCE
31
40
 
32
- ### 2. Generate Controller File
41
+ ### 1. Derive Entity Name
42
+
43
+ Convert `{module}` to PascalCase for entity name:
33
44
 
34
- **Target path:**
35
- ```
36
- src/SmartStack.Api/Controllers/{ContextShort}/{Application}/{entity}Controller.cs
37
45
  ```
38
- > Context mapping: `business` `Business`, `platform` → `Admin`, `personal` → `User`
39
-
40
- **Apply template with variables:**
41
-
42
- ```csharp
43
- using Microsoft.AspNetCore.Mvc;
44
- using Microsoft.AspNetCore.Http;
45
- using SmartStack.Application.Common.Authorization;
46
- using SmartStack.Application.Common.Interfaces;
47
- using SmartStack.Domain.Entities;
48
-
49
- namespace SmartStack.Api.Controllers.{area};
50
-
51
- [ApiController]
52
- [Route("api/{area_lowercase}/[controller]")]
53
- [Authorize]
54
- public class {module}Controller : ControllerBase
55
- {
56
- private readonly IApplicationDbContext _context;
57
- private readonly ICurrentUserService _currentUser;
58
- private readonly ILogger<{module}Controller> _logger;
59
-
60
- public {module}Controller(
61
- IApplicationDbContext context,
62
- ICurrentUserService currentUser,
63
- ILogger<{module}Controller> logger)
64
- {
65
- _context = context;
66
- _currentUser = currentUser;
67
- _logger = logger;
68
- }
69
-
70
- // Endpoints generated based on plan...
71
- }
46
+ module: "products" entityName: "Product"
47
+ module: "order-items" → entityName: "OrderItem"
48
+ module: "user-profiles" → entityName: "UserProfile"
72
49
  ```
73
50
 
74
- ### 3. Generate Endpoints
75
-
76
- **For each planned endpoint, generate with:**
77
-
78
- 1. **Attributes:**
79
- - `[HttpGet]`, `[HttpPost]`, etc.
80
- - `[RequirePermission(Permissions.{module}.View)]`
81
- - `[ProducesResponseType(typeof(...), StatusCodes.Status200OK)]`
82
- - `[ProducesResponseType(StatusCodes.Status401Unauthorized)]`
83
- - `[ProducesResponseType(StatusCodes.Status403Forbidden)]`
84
-
85
- 2. **Method body:**
86
- - Parameter validation
87
- - Entity operation
88
- - Logging
89
- - Response mapping
90
-
91
- **Example GET endpoint:**
92
-
93
- ```csharp
94
- [HttpGet]
95
- [RequirePermission(Permissions.{module}.View)]
96
- [ProducesResponseType(typeof(PagedResult<{entity}ResponseDto>), StatusCodes.Status200OK)]
97
- [ProducesResponseType(StatusCodes.Status401Unauthorized)]
98
- [ProducesResponseType(StatusCodes.Status403Forbidden)]
99
- public async Task<IActionResult> GetAll(
100
- [FromQuery] int page = 1,
101
- [FromQuery] int pageSize = 20,
102
- CancellationToken ct = default)
103
- {
104
- var query = _context.{module}
105
- .AsNoTracking()
106
- .OrderByDescending(x => x.CreatedAt);
107
-
108
- var total = await query.CountAsync(ct);
109
- var items = await query
110
- .Skip((page - 1) * pageSize)
111
- .Take(pageSize)
112
- .Select(x => new {entity}ResponseDto(x))
113
- .ToListAsync(ct);
114
-
115
- return Ok(new PagedResult<{entity}ResponseDto>(items, total, page, pageSize));
116
- }
117
- ```
51
+ ### 2. Determine Table Prefix
52
+
53
+ Based on navigation context extracted from `{permission_path}`:
54
+
55
+ | Context | Table Prefix | Controller Folder |
56
+ |---------|--------------|-------------------|
57
+ | platform.administration | `auth_` or `cfg_` | `Admin` |
58
+ | platform.support | `support_` | `Support` |
59
+ | business.* | `ref_` or domain-specific | `Business` |
60
+ | personal.* | `usr_` | `User` |
118
61
 
119
- ### 4. Generate DTOs (if dto_mode)
62
+ ### 3. Call MCP scaffold_extension (TWO CALLS)
63
+
64
+ **First call: Generate DTOs**
120
65
 
121
- **Target paths:**
122
66
  ```
123
- src/SmartStack.Application/DTOs/{module}/{entity}CreateDto.cs
124
- src/SmartStack.Application/DTOs/{module}/{entity}UpdateDto.cs
125
- src/SmartStack.Application/DTOs/{module}/{entity}ResponseDto.cs
67
+ Tool: mcp__smartstack__scaffold_extension
68
+ Args:
69
+ type: "dto"
70
+ name: "{entityName}" # PascalCase from step 1
71
+ options:
72
+ navRoute: "{permission_path}" # For proper namespace hierarchy
73
+ schema: "core"
74
+ dryRun: false
126
75
  ```
127
76
 
128
- **CreateDto template:**
77
+ **Second call: Generate Controller with NavRoute**
129
78
 
130
- ```csharp
131
- public record {entity}CreateDto(
132
- string Name,
133
- // ... required properties
134
- );
79
+ ```
80
+ Tool: mcp__smartstack__scaffold_extension
81
+ Args:
82
+ type: "controller"
83
+ name: "{entityName}" # PascalCase from step 1
84
+ options:
85
+ navRoute: "{permission_path}" # MANDATORY for NavRoute attribute
86
+ navRouteSuffix: null # Optional (e.g., "details" → [NavRoute("path", Suffix = "details")])
87
+ dryRun: false
135
88
  ```
136
89
 
137
- **UpdateDto template:**
90
+ **CRITICAL: NavRoute is MANDATORY** - Without it, frontend/backend sync will fail.
138
91
 
139
- ```csharp
140
- public record {entity}UpdateDto(
141
- string? Name,
142
- // ... optional properties
143
- );
144
- ```
92
+ **Why two calls?**
93
+ - The skill `/controller` assumes the Entity already exists (verified in step-01-analyze.md)
94
+ - Type "dto" generates DTOs without regenerating the Entity
95
+ - Type "controller" generates the Controller with NavRoute and references to DTOs
145
96
 
146
- **ResponseDto template:**
147
-
148
- ```csharp
149
- public record {entity}ResponseDto(
150
- Guid Id,
151
- string Name,
152
- // ... all public properties
153
- DateTime CreatedAt,
154
- DateTime? UpdatedAt
155
- )
156
- {
157
- public {entity}ResponseDto({entity} entity) : this(
158
- entity.Id,
159
- entity.Name,
160
- // ... mapping
161
- entity.CreatedAt,
162
- entity.UpdatedAt
163
- ) { }
164
- }
165
- ```
97
+ ### 4. Parse MCP Responses
98
+
99
+ **From first call (DTOs):**
100
+ - `Application/{Context}/{Application}/{Module}/DTOs/{entityName}ResponseDto.cs` - Response DTO
101
+ - `Application/{Context}/{Application}/{Module}/DTOs/Create{entityName}Dto.cs` - Create request
102
+ - `Application/{Context}/{Application}/{Module}/DTOs/Update{entityName}Dto.cs` - Update request
166
103
 
167
- ### 5. Add Security Logging
104
+ **From second call (Controller):**
105
+ - `Api/Controllers/{area}/{entityName}Controller.cs` - REST Controller **with [NavRoute]**
168
106
 
169
- **Ensure logging for all operations:**
107
+ ### 5. Present Output to User
170
108
 
171
- ```csharp
172
- // Create
173
- _logger.LogInformation("User {User} created {entity} {Id}",
174
- _currentUser.Email, entity.Id);
109
+ ```markdown
110
+ ## Controller Generated via MCP
175
111
 
176
- // Update
177
- _logger.LogInformation("User {User} updated {entity} {Id}",
178
- _currentUser.Email, entity.Id);
112
+ ### API Layer
113
+ - `Controllers/{area}/{entityName}Controller.cs`
114
+ - **NavRoute: `{permission_path}`** ✅
115
+ - Endpoints:
116
+ - GET /api/{module} - List all
117
+ - GET /api/{module}/{id} - Get by ID
118
+ - POST /api/{module} - Create
119
+ - PUT /api/{module}/{id} - Update
120
+ - DELETE /api/{module}/{id} - Delete
179
121
 
180
- // Delete (Warning level)
181
- _logger.LogWarning("User {User} deleted {entity} {Id} ({Name})",
182
- _currentUser.Email, id, entity.Name);
122
+ ### Application Layer (DTOs)
123
+ - `{Context}/{Application}/{Module}/DTOs/{entityName}ResponseDto.cs`
124
+ - `{Context}/{Application}/{Module}/DTOs/Create{entityName}Dto.cs`
125
+ - `{Context}/{Application}/{Module}/DTOs/Update{entityName}Dto.cs`
126
+
127
+ ### ✅ NavRoute Integration
128
+ The controller uses `[NavRoute("{permission_path}")]` which enables:
129
+ - ✅ Automatic frontend route generation
130
+ - ✅ Permission-based navigation sync
131
+ - ✅ Dynamic API routing from Navigation entities
132
+
133
+ ### Next Steps
134
+ 1. Permissions will be synchronized in step-04-perms.md
135
+ 2. Validate conventions with MCP `validate_conventions`
183
136
  ```
184
137
 
185
- ### 6. Protect System Accounts (if applicable)
138
+ ---
139
+
140
+ ## MCP RESPONSE HANDLING
186
141
 
187
- **Add guard for system entities:**
142
+ ### Success Case
143
+
144
+ **After first call (DTOs):**
145
+ - Display all generated DTO files
146
+ - Verify DTOs match entity properties
147
+ - Continue to second call
148
+
149
+ **After second call (Controller):**
150
+ - Display controller file
151
+ - Show NavRoute attribute included
152
+ - Highlight frontend/backend sync enabled
153
+ - Store controller info for permission sync
154
+ - Proceed to step-04-perms.md
155
+
156
+ ### Error Case
157
+
158
+ **If first call (DTOs) fails:**
159
+ - Display error message
160
+ - Suggest checking entity name format
161
+ - Verify entity properties are defined
162
+ - Verify MCP server is running (`/mcp:healthcheck`)
163
+ - Do NOT proceed to second call
164
+
165
+ **If second call (Controller) fails:**
166
+ - Display error message
167
+ - Note that DTOs were generated successfully
168
+ - Suggest checking navRoute format
169
+ - Verify MCP server is running (`/mcp:healthcheck`)
170
+ - Do NOT proceed to step-04-perms.md
171
+
172
+ ---
173
+
174
+ ## NAVROUTE VALIDATION
175
+
176
+ **After generation, verify NavRoute is present:**
188
177
 
189
- ```csharp
190
- // Before modify/delete operations
191
- if (entity.UserType == UserType.System || entity.UserType == UserType.LocalAdmin)
192
- {
193
- _logger.LogWarning("Attempt to modify system account {Id} by {User}",
194
- entity.Id, _currentUser.Email);
195
- return BadRequest(new { message = "Cannot modify system accounts" });
196
- }
178
+ ```
179
+ Generated controller MUST contain:
180
+ [NavRoute("{permission_path}")]
181
+
182
+ WITHOUT NavRoute:
183
+ Frontend routes will be hardcoded
184
+ No automatic permission sync
185
+ ❌ Manual navigation management required
197
186
  ```
198
187
 
199
188
  ---
@@ -205,7 +194,7 @@ Generated Files:
205
194
 
206
195
  | File | Path | Status |
207
196
  |------|------|--------|
208
- | Controller | src/.../Controllers/{area}/{module}Controller.cs | ✅ Created |
197
+ | Controller | src/.../Controllers/{area}/{entity}Controller.cs | ✅ Created with [NavRoute] |
209
198
  | CreateDto | src/.../DTOs/{module}/{entity}CreateDto.cs | ✅ Created |
210
199
  | UpdateDto | src/.../DTOs/{module}/{entity}UpdateDto.cs | ✅ Created |
211
200
  | ResponseDto | src/.../DTOs/{module}/{entity}ResponseDto.cs | ✅ Created |
@@ -215,6 +204,25 @@ Generated Files:
215
204
 
216
205
  ---
217
206
 
207
+ ## SUCCESS METRICS
208
+
209
+ - MCP scaffold_extension called successfully (DTOs)
210
+ - DTOs generated (ResponseDto, CreateDto, UpdateDto)
211
+ - MCP scaffold_extension called successfully (Controller)
212
+ - Controller generated with **[NavRoute]** attribute
213
+ - NavRoute matches permission_path
214
+ - Controller references DTOs correctly
215
+ - Proceeded to step-04-perms.md
216
+
217
+ ## FAILURE MODES
218
+
219
+ - MCP call failed (display error, run /mcp:healthcheck, stop)
220
+ - Invalid entity name (must be PascalCase)
221
+ - Invalid navRoute format
222
+ - MCP server not running
223
+
224
+ ---
225
+
218
226
  ## NEXT STEP:
219
227
 
220
- After generation complete, proceed to `./step-04-perms.md`
228
+ After controller generation complete, proceed to `./step-04-perms.md`
@@ -16,113 +16,11 @@ Add permissions to both Permissions.cs (constants) and PermissionConfiguration.c
16
16
 
17
17
  ## EXECUTION SEQUENCE:
18
18
 
19
- ### 1. Update Permissions.cs
19
+ ### 1. Update Permissions.cs & PermissionConfiguration.cs
20
20
 
21
- **Target file:**
22
- ```
23
- src/SmartStack.Application/Common/Authorization/Permissions.cs
24
- ```
25
-
26
- **Find the correct parent class based on {permission_path}:**
27
-
28
- | Permission Path | Parent Class |
29
- |-----------------|--------------|
30
- | `platform.administration.*` | `Platform.Administration` |
31
- | `platform.support.*` | `Platform.Support` |
32
- | `business.*` | `Business` |
33
- | `personal.myspace.*` | `Personal.MySpace` |
34
-
35
- **Add nested class:**
36
-
37
- ```csharp
38
- public static class {module}
39
- {
40
- public const string View = "{permission_path}.read";
41
- public const string Create = "{permission_path}.create";
42
- public const string Update = "{permission_path}.update";
43
- public const string Delete = "{permission_path}.delete";
44
- }
45
- ```
46
-
47
- **Example for platform.support.tickets:**
48
-
49
- ```csharp
50
- public static partial class Permissions
51
- {
52
- public static class Platform
53
- {
54
- public static class Support
55
- {
56
- // Existing classes...
57
-
58
- public static class Tickets // NEW
59
- {
60
- public const string View = "platform.support.tickets.read";
61
- public const string Create = "platform.support.tickets.create";
62
- public const string Update = "platform.support.tickets.update";
63
- public const string Delete = "platform.support.tickets.delete";
64
- }
65
- }
66
- }
67
- }
68
- ```
69
-
70
- ### 2. Update PermissionConfiguration.cs
71
-
72
- **Target file:**
73
- ```
74
- src/SmartStack.Infrastructure/Persistence/Configurations/PermissionConfiguration.cs
75
- ```
76
-
77
- **Find HasData section and add seeds:**
78
-
79
- ```csharp
80
- builder.HasData(
81
- // Existing permissions...
82
-
83
- // {module} permissions
84
- new Permission
85
- {
86
- Id = Guid.NewGuid(), // Generate new GUID
87
- Code = "{permission_path}.read",
88
- Name = "View {module}",
89
- Description = "Allows viewing {module_lowercase} list and details",
90
- Category = "{area}",
91
- IsSystem = true,
92
- CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
93
- },
94
- new Permission
95
- {
96
- Id = Guid.NewGuid(),
97
- Code = "{permission_path}.create",
98
- Name = "Create {module}",
99
- Description = "Allows creating new {module_lowercase}",
100
- Category = "{area}",
101
- IsSystem = true,
102
- CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
103
- },
104
- new Permission
105
- {
106
- Id = Guid.NewGuid(),
107
- Code = "{permission_path}.update",
108
- Name = "Update {module}",
109
- Description = "Allows updating existing {module_lowercase}",
110
- Category = "{area}",
111
- IsSystem = true,
112
- CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
113
- },
114
- new Permission
115
- {
116
- Id = Guid.NewGuid(),
117
- Code = "{permission_path}.delete",
118
- Name = "Delete {module}",
119
- Description = "Allows deleting {module_lowercase}",
120
- Category = "{area}",
121
- IsSystem = true,
122
- CreatedAt = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)
123
- }
124
- );
125
- ```
21
+ See [references/permission-sync-templates.md](../references/permission-sync-templates.md) for the C# templates:
22
+ - **Permissions.cs**: Nested class with 4 constants (View, Create, Update, Delete) + path-to-class mapping
23
+ - **PermissionConfiguration.cs**: 4 HasData Permission entries with deterministic GUIDs
126
24
 
127
25
  ### 3. Generate Migration (Required)
128
26
 
@@ -154,44 +52,7 @@ Suggest command:
154
52
 
155
53
  **If {postman_mode} = true:**
156
54
 
157
- Load `postman-templates.md` and generate tests:
158
-
159
- ```json
160
- {
161
- "name": "{module} API Tests",
162
- "item": [
163
- {
164
- "name": "GET {module} - SuperAdmin (200)",
165
- "request": {
166
- "method": "GET",
167
- "url": "{{baseUrl}}/api/{area}/{module}"
168
- },
169
- "event": [
170
- {
171
- "listen": "test",
172
- "script": {
173
- "exec": ["pm.test('Status 200', () => pm.response.to.have.status(200));"]
174
- }
175
- }
176
- ]
177
- },
178
- {
179
- "name": "GET {module} - No Permission (403)",
180
- "request": { "method": "GET", "url": "{{baseUrl}}/api/{area}/{module}" },
181
- "event": [
182
- {
183
- "listen": "prerequest",
184
- "script": { "exec": ["// Use NoPermUser token"] }
185
- },
186
- {
187
- "listen": "test",
188
- "script": { "exec": ["pm.test('Status 403', () => pm.response.to.have.status(403));"] }
189
- }
190
- ]
191
- }
192
- ]
193
- }
194
- ```
55
+ See [references/permission-sync-templates.md](../references/permission-sync-templates.md) § "Postman API Test Template" for the JSON test collection template (200 OK + 403 Forbidden tests).
195
56
 
196
57
  ---
197
58