@atlashub/smartstack-cli 3.7.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +4 -2
  4. package/templates/agents/action.md +1 -0
  5. package/templates/agents/ba-writer.md +33 -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/backend-controller-hierarchy.md +58 -0
  28. package/templates/skills/application/references/backend-entity-seeding.md +72 -0
  29. package/templates/skills/application/references/backend-verification.md +88 -0
  30. package/templates/skills/application/references/frontend-verification.md +111 -0
  31. package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
  32. package/templates/skills/application/references/provider-template.md +134 -0
  33. package/templates/skills/application/references/test-frontend.md +73 -0
  34. package/templates/skills/application/references/test-prerequisites.md +72 -0
  35. package/templates/skills/application/steps/step-01-navigation.md +7 -198
  36. package/templates/skills/application/steps/step-03b-provider.md +4 -128
  37. package/templates/skills/application/steps/step-04-backend.md +20 -350
  38. package/templates/skills/application/steps/step-05-frontend.md +12 -101
  39. package/templates/skills/application/steps/step-07-tests.md +12 -132
  40. package/templates/skills/business-analyse/SKILL.md +11 -2
  41. package/templates/skills/business-analyse/html/ba-interactive.html +3214 -2246
  42. package/templates/skills/business-analyse/html/build-html.js +77 -0
  43. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +130 -0
  44. package/templates/skills/business-analyse/html/src/scripts/02-navigation.js +22 -0
  45. package/templates/skills/business-analyse/html/src/scripts/03-render-cadrage.js +208 -0
  46. package/templates/skills/business-analyse/html/src/scripts/04-render-modules.js +211 -0
  47. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +554 -0
  48. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +110 -0
  49. package/templates/skills/business-analyse/html/src/scripts/07-render-handoff.js +90 -0
  50. package/templates/skills/business-analyse/html/src/scripts/08-editing.js +45 -0
  51. package/templates/skills/business-analyse/html/src/scripts/09-export.js +168 -0
  52. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +171 -0
  53. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +161 -0
  54. package/templates/skills/business-analyse/html/src/styles/01-variables.css +38 -0
  55. package/templates/skills/business-analyse/html/src/styles/02-layout.css +101 -0
  56. package/templates/skills/business-analyse/html/src/styles/03-navigation.css +62 -0
  57. package/templates/skills/business-analyse/html/src/styles/04-cards.css +196 -0
  58. package/templates/skills/business-analyse/html/src/styles/05-modules.css +325 -0
  59. package/templates/skills/business-analyse/html/src/styles/06-wireframes.css +230 -0
  60. package/templates/skills/business-analyse/html/src/styles/07-comments.css +184 -0
  61. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +241 -0
  62. package/templates/skills/business-analyse/html/src/template.html +623 -0
  63. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  64. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  65. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  66. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  67. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  68. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  69. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  70. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  71. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  72. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  73. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  74. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  75. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  76. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  77. package/templates/skills/business-analyse/steps/step-00-init.md +35 -68
  78. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  79. package/templates/skills/business-analyse/steps/step-03a-data.md +6 -49
  80. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  81. package/templates/skills/business-analyse/steps/step-03d-validate.md +3 -48
  82. package/templates/skills/business-analyse/steps/step-04-consolidation.md +9 -104
  83. package/templates/skills/business-analyse/steps/step-05a-handoff.md +25 -441
  84. package/templates/skills/business-analyse/steps/step-05b-deploy.md +19 -187
  85. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  86. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  87. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  88. package/templates/skills/check-version/SKILL.md +7 -0
  89. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  90. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  91. package/templates/skills/controller/steps/step-03-generate.md +6 -158
  92. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  93. package/templates/skills/debug/SKILL.md +7 -0
  94. package/templates/skills/explore/SKILL.md +6 -0
  95. package/templates/skills/feature-full/SKILL.md +39 -142
  96. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  97. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  98. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  99. package/templates/skills/gitflow/references/plan-template.md +69 -0
  100. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  101. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  102. package/templates/skills/gitflow/steps/step-init.md +18 -289
  103. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  104. package/templates/skills/gitflow/steps/step-start.md +16 -126
  105. package/templates/skills/mcp/SKILL.md +9 -213
  106. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  107. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  108. package/templates/skills/notification/SKILL.md +7 -0
  109. package/templates/skills/quick-search/SKILL.md +5 -0
  110. package/templates/skills/ralph-loop/SKILL.md +99 -381
  111. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  112. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  113. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  114. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  115. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  116. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  117. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  118. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  119. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  120. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  121. package/templates/skills/refactor/SKILL.md +12 -176
  122. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  123. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  124. package/templates/skills/review-code/SKILL.md +19 -257
  125. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  126. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  127. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  128. package/templates/skills/ui-components/SKILL.md +7 -0
  129. package/templates/skills/utils/SKILL.md +6 -0
  130. package/templates/skills/validate/SKILL.md +6 -0
  131. package/templates/skills/validate-feature/SKILL.md +8 -0
  132. package/templates/skills/workflow/SKILL.md +40 -118
  133. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -0,0 +1,159 @@
1
+ # Controller & DTO Code Templates
2
+
3
+ > Referenced from `steps/step-03-generate.md` — C# templates for controller, DTOs, and security patterns.
4
+
5
+ ---
6
+
7
+ ## Controller Template
8
+
9
+ **Target path:** `src/SmartStack.Api/Controllers/{ContextShort}/{Application}/{entity}Controller.cs`
10
+
11
+ > Context mapping: `business` → `Business`, `platform` → `Admin`, `personal` → `User`
12
+
13
+ ```csharp
14
+ using Microsoft.AspNetCore.Mvc;
15
+ using Microsoft.AspNetCore.Http;
16
+ using SmartStack.Application.Common.Authorization;
17
+ using SmartStack.Application.Common.Interfaces;
18
+ using SmartStack.Domain.Entities;
19
+
20
+ namespace SmartStack.Api.Controllers.{area};
21
+
22
+ [ApiController]
23
+ [Route("api/{area_lowercase}/[controller]")]
24
+ [Authorize]
25
+ public class {module}Controller : ControllerBase
26
+ {
27
+ private readonly IApplicationDbContext _context;
28
+ private readonly ICurrentUserService _currentUser;
29
+ private readonly ILogger<{module}Controller> _logger;
30
+
31
+ public {module}Controller(
32
+ IApplicationDbContext context,
33
+ ICurrentUserService currentUser,
34
+ ILogger<{module}Controller> logger)
35
+ {
36
+ _context = context;
37
+ _currentUser = currentUser;
38
+ _logger = logger;
39
+ }
40
+
41
+ // Endpoints generated based on plan...
42
+ }
43
+ ```
44
+
45
+ ---
46
+
47
+ ## GET Endpoint Example
48
+
49
+ ```csharp
50
+ [HttpGet]
51
+ [RequirePermission(Permissions.{module}.View)]
52
+ [ProducesResponseType(typeof(PagedResult<{entity}ResponseDto>), StatusCodes.Status200OK)]
53
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
54
+ [ProducesResponseType(StatusCodes.Status403Forbidden)]
55
+ public async Task<IActionResult> GetAll(
56
+ [FromQuery] int page = 1,
57
+ [FromQuery] int pageSize = 20,
58
+ CancellationToken ct = default)
59
+ {
60
+ var query = _context.{module}
61
+ .AsNoTracking()
62
+ .OrderByDescending(x => x.CreatedAt);
63
+
64
+ var total = await query.CountAsync(ct);
65
+ var items = await query
66
+ .Skip((page - 1) * pageSize)
67
+ .Take(pageSize)
68
+ .Select(x => new {entity}ResponseDto(x))
69
+ .ToListAsync(ct);
70
+
71
+ return Ok(new PagedResult<{entity}ResponseDto>(items, total, page, pageSize));
72
+ }
73
+ ```
74
+
75
+ **Endpoint attributes to include:**
76
+ 1. `[HttpGet]`, `[HttpPost]`, etc.
77
+ 2. `[RequirePermission(Permissions.{module}.View)]`
78
+ 3. `[ProducesResponseType(typeof(...), StatusCodes.Status200OK)]`
79
+ 4. `[ProducesResponseType(StatusCodes.Status401Unauthorized)]`
80
+ 5. `[ProducesResponseType(StatusCodes.Status403Forbidden)]`
81
+
82
+ ---
83
+
84
+ ## DTO Templates
85
+
86
+ **Target paths:**
87
+ ```
88
+ src/SmartStack.Application/DTOs/{module}/{entity}CreateDto.cs
89
+ src/SmartStack.Application/DTOs/{module}/{entity}UpdateDto.cs
90
+ src/SmartStack.Application/DTOs/{module}/{entity}ResponseDto.cs
91
+ ```
92
+
93
+ **CreateDto:**
94
+ ```csharp
95
+ public record {entity}CreateDto(
96
+ string Name,
97
+ // ... required properties
98
+ );
99
+ ```
100
+
101
+ **UpdateDto:**
102
+ ```csharp
103
+ public record {entity}UpdateDto(
104
+ string? Name,
105
+ // ... optional properties
106
+ );
107
+ ```
108
+
109
+ **ResponseDto:**
110
+ ```csharp
111
+ public record {entity}ResponseDto(
112
+ Guid Id,
113
+ string Name,
114
+ // ... all public properties
115
+ DateTime CreatedAt,
116
+ DateTime? UpdatedAt
117
+ )
118
+ {
119
+ public {entity}ResponseDto({entity} entity) : this(
120
+ entity.Id,
121
+ entity.Name,
122
+ // ... mapping
123
+ entity.CreatedAt,
124
+ entity.UpdatedAt
125
+ ) { }
126
+ }
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Security Logging Templates
132
+
133
+ ```csharp
134
+ // Create
135
+ _logger.LogInformation("User {User} created {entity} {Id}",
136
+ _currentUser.Email, entity.Id);
137
+
138
+ // Update
139
+ _logger.LogInformation("User {User} updated {entity} {Id}",
140
+ _currentUser.Email, entity.Id);
141
+
142
+ // Delete (Warning level)
143
+ _logger.LogWarning("User {User} deleted {entity} {Id} ({Name})",
144
+ _currentUser.Email, id, entity.Name);
145
+ ```
146
+
147
+ ---
148
+
149
+ ## System Account Protection
150
+
151
+ ```csharp
152
+ // Before modify/delete operations
153
+ if (entity.UserType == UserType.System || entity.UserType == UserType.LocalAdmin)
154
+ {
155
+ _logger.LogWarning("Attempt to modify system account {Id} by {User}",
156
+ entity.Id, _currentUser.Email);
157
+ return BadRequest(new { message = "Cannot modify system accounts" });
158
+ }
159
+ ```
@@ -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
+ ```
@@ -37,164 +37,12 @@ src/SmartStack.Api/Controllers/{ContextShort}/{Application}/{entity}Controller.c
37
37
  ```
38
38
  > Context mapping: `business` → `Business`, `platform` → `Admin`, `personal` → `User`
39
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
- }
72
- ```
73
-
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
- ```
118
-
119
- ### 4. Generate DTOs (if dto_mode)
120
-
121
- **Target paths:**
122
- ```
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
126
- ```
127
-
128
- **CreateDto template:**
129
-
130
- ```csharp
131
- public record {entity}CreateDto(
132
- string Name,
133
- // ... required properties
134
- );
135
- ```
136
-
137
- **UpdateDto template:**
138
-
139
- ```csharp
140
- public record {entity}UpdateDto(
141
- string? Name,
142
- // ... optional properties
143
- );
144
- ```
145
-
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
- ```
166
-
167
- ### 5. Add Security Logging
168
-
169
- **Ensure logging for all operations:**
170
-
171
- ```csharp
172
- // Create
173
- _logger.LogInformation("User {User} created {entity} {Id}",
174
- _currentUser.Email, entity.Id);
175
-
176
- // Update
177
- _logger.LogInformation("User {User} updated {entity} {Id}",
178
- _currentUser.Email, entity.Id);
179
-
180
- // Delete (Warning level)
181
- _logger.LogWarning("User {User} deleted {entity} {Id} ({Name})",
182
- _currentUser.Email, id, entity.Name);
183
- ```
184
-
185
- ### 6. Protect System Accounts (if applicable)
186
-
187
- **Add guard for system entities:**
188
-
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
- }
197
- ```
40
+ See [references/controller-code-templates.md](../references/controller-code-templates.md) for all C# templates:
41
+ - **Controller class** with DI constructor (IApplicationDbContext, ICurrentUserService, ILogger)
42
+ - **GET endpoint** with pagination (PagedResult, AsNoTracking)
43
+ - **DTOs** (CreateDto, UpdateDto, ResponseDto with entity mapping constructor)
44
+ - **Security logging** (Create/Update at Info, Delete at Warning)
45
+ - **System account protection** guard (UserType.System/LocalAdmin)
198
46
 
199
47
  ---
200
48
 
@@ -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
 
@@ -163,3 +163,10 @@ Evaluate solutions:
163
163
  <priority>
164
164
  Understanding > Speed > Completeness. Every bug must be fully understood before attempting fixes.
165
165
  </priority>
166
+
167
+ <success_criteria>
168
+ - Root cause identified with evidence (not just symptoms)
169
+ - Fix implemented with minimal, targeted changes
170
+ - Original error no longer reproducible
171
+ - Related tests pass without regressions
172
+ </success_criteria>
@@ -90,3 +90,9 @@ Provide comprehensive response:
90
90
  <priority>
91
91
  Accuracy > Speed > Brevity. Provide complete answers with evidence.
92
92
  </priority>
93
+
94
+ <success_criteria>
95
+ - Question answered with supporting file references and line numbers
96
+ - All relevant code patterns and conventions identified
97
+ - Dependencies and connections mapped
98
+ </success_criteria>