@atlashub/smartstack-cli 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +74897 -1477
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
- package/templates/agents/efcore/db-deploy.md +5 -0
- package/templates/agents/efcore/db-reset.md +5 -0
- package/templates/agents/efcore/db-seed.md +5 -0
- package/templates/agents/efcore/db-status.md +5 -0
- package/templates/agents/efcore/migration.md +8 -0
- package/templates/agents/efcore/rebase-snapshot.md +41 -12
- package/templates/agents/efcore/squash.md +59 -19
- package/templates/commands/efcore/_shared.md +117 -0
- package/templates/commands/efcore/db-deploy.md +32 -4
- package/templates/commands/efcore/db-reset.md +38 -2
- package/templates/commands/efcore/db-status.md +24 -6
- package/templates/commands/efcore/migration.md +57 -9
- package/templates/commands/efcore/rebase-snapshot.md +56 -3
- package/templates/commands/efcore/squash.md +85 -18
- package/templates/skills/efcore/SKILL.md +162 -0
- package/templates/skills/efcore/steps/db/step-deploy.md +208 -0
- package/templates/skills/efcore/steps/db/step-reset.md +259 -0
- package/templates/skills/efcore/steps/db/step-seed.md +244 -0
- package/templates/skills/efcore/steps/db/step-status.md +198 -0
- package/templates/skills/efcore/steps/migration/step-00-init.md +102 -0
- package/templates/skills/efcore/steps/migration/step-01-check.md +138 -0
- package/templates/skills/efcore/steps/migration/step-02-create.md +144 -0
- package/templates/skills/efcore/steps/migration/step-03-validate.md +203 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-00-init.md +173 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-01-backup.md +100 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-02-fetch.md +115 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +108 -0
- package/templates/skills/efcore/steps/rebase-snapshot/step-04-validate.md +157 -0
- package/templates/skills/efcore/steps/shared/step-00-init.md +266 -0
- package/templates/skills/efcore/steps/squash/step-00-init.md +141 -0
- package/templates/skills/efcore/steps/squash/step-01-backup.md +120 -0
- package/templates/skills/efcore/steps/squash/step-02-fetch.md +168 -0
- package/templates/skills/efcore/steps/squash/step-03-create.md +178 -0
- package/templates/skills/efcore/steps/squash/step-04-validate.md +174 -0
- package/templates/skills/gitflow/steps/step-commit.md +25 -20
- package/templates/skills/gitflow/steps/step-start.md +9 -0
- package/templates/skills/review-code/SKILL.md +77 -0
- package/templates/skills/review-code/references/smartstack-conventions.md +302 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
<overview>
|
|
2
|
+
SmartStack-specific conventions and patterns. This reference is used when reviewing SmartStack projects to ensure compliance with the architecture and security standards.
|
|
3
|
+
|
|
4
|
+
**IMPORTANT**: All convention validation MUST be delegated to the MCP SmartStack tools. This file documents what to look for; the MCP validates automatically.
|
|
5
|
+
</overview>
|
|
6
|
+
|
|
7
|
+
<mcp_tools>
|
|
8
|
+
## MCP SmartStack Tools for Code Review
|
|
9
|
+
|
|
10
|
+
| Tool | Purpose | When to use |
|
|
11
|
+
|------|---------|-------------|
|
|
12
|
+
| `mcp__smartstack__validate_conventions` | Validate all SmartStack conventions | Always run first |
|
|
13
|
+
| `mcp__smartstack__validate_test_conventions` | Validate test patterns | When tests are in scope |
|
|
14
|
+
| `mcp__smartstack__validate_security` | Security-specific checks | Security-focused reviews |
|
|
15
|
+
| `mcp__smartstack__analyze_code_quality` | Code metrics analysis | Quality-focused reviews |
|
|
16
|
+
| `mcp__smartstack__check_migrations` | EF Core migration conflicts | When migrations are modified |
|
|
17
|
+
</mcp_tools>
|
|
18
|
+
|
|
19
|
+
<architecture>
|
|
20
|
+
## SmartStack Architecture (Clean Architecture)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
SmartStack/
|
|
24
|
+
├── SmartStack.Domain/ # Entities, Value Objects, Domain Events
|
|
25
|
+
├── SmartStack.Application/ # Services, DTOs, Commands/Queries
|
|
26
|
+
├── SmartStack.Infrastructure/ # EF Core, External services
|
|
27
|
+
├── SmartStack.Api/ # Controllers, Middleware
|
|
28
|
+
└── SmartStack.Web/ # React frontend
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Dependency rule**: Dependencies point inward only (Api → Application → Domain).
|
|
32
|
+
</architecture>
|
|
33
|
+
|
|
34
|
+
<entities>
|
|
35
|
+
## Entity Conventions
|
|
36
|
+
|
|
37
|
+
<tenant_aware>
|
|
38
|
+
**Tenant-aware entities** (most business entities):
|
|
39
|
+
```csharp
|
|
40
|
+
public class Order : BaseEntity, ITenantEntity
|
|
41
|
+
{
|
|
42
|
+
public Guid TenantId { get; private set; }
|
|
43
|
+
|
|
44
|
+
private Order() { } // EF Core constructor
|
|
45
|
+
|
|
46
|
+
public static Order Create(Guid tenantId, ...)
|
|
47
|
+
{
|
|
48
|
+
return new Order { TenantId = tenantId, ... };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Requirements:**
|
|
54
|
+
- [ ] Implements `ITenantEntity`
|
|
55
|
+
- [ ] Has `TenantId` property
|
|
56
|
+
- [ ] Private parameterless constructor
|
|
57
|
+
- [ ] Static `Create()` factory method with `tenantId` as first parameter
|
|
58
|
+
</tenant_aware>
|
|
59
|
+
|
|
60
|
+
<system_entity>
|
|
61
|
+
**System entities** (platform-level, no tenant):
|
|
62
|
+
```csharp
|
|
63
|
+
public class Permission : SystemEntity
|
|
64
|
+
{
|
|
65
|
+
private Permission() { }
|
|
66
|
+
|
|
67
|
+
public static Permission Create(...)
|
|
68
|
+
{
|
|
69
|
+
return new Permission { ... };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Requirements:**
|
|
75
|
+
- [ ] Inherits from `SystemEntity`
|
|
76
|
+
- [ ] NO `TenantId` property
|
|
77
|
+
- [ ] Private parameterless constructor
|
|
78
|
+
- [ ] Static `Create()` factory method
|
|
79
|
+
</system_entity>
|
|
80
|
+
</entities>
|
|
81
|
+
|
|
82
|
+
<tables>
|
|
83
|
+
## Table Naming Conventions
|
|
84
|
+
|
|
85
|
+
**Schema**: All tables MUST specify schema explicitly.
|
|
86
|
+
```csharp
|
|
87
|
+
builder.ToTable("auth_users", SchemaConstants.Core);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Prefixes by domain:**
|
|
91
|
+
| Prefix | Domain | Examples |
|
|
92
|
+
|--------|--------|----------|
|
|
93
|
+
| `auth_` | Authentication | auth_users, auth_roles |
|
|
94
|
+
| `nav_` | Navigation | nav_menus, nav_routes |
|
|
95
|
+
| `cfg_` | Configuration | cfg_settings, cfg_features |
|
|
96
|
+
| `ai_` | AI/Prompts | ai_prompts, ai_models |
|
|
97
|
+
| `ntf_` | Notifications | ntf_templates, ntf_logs |
|
|
98
|
+
| `wkf_` | Workflows | wkf_definitions, wkf_instances |
|
|
99
|
+
| `doc_` | Documents | doc_files, doc_versions |
|
|
100
|
+
| `tkt_` | Tickets/Support | tkt_tickets, tkt_comments |
|
|
101
|
+
|
|
102
|
+
**Schemas:**
|
|
103
|
+
- `core` (SchemaConstants.Core): SmartStack platform tables
|
|
104
|
+
- `extensions` (SchemaConstants.Extensions): Client-specific tables
|
|
105
|
+
</tables>
|
|
106
|
+
|
|
107
|
+
<migrations>
|
|
108
|
+
## Migration Naming
|
|
109
|
+
|
|
110
|
+
**Format**: `{context}_v{version}_{sequence}_{Description}.cs`
|
|
111
|
+
|
|
112
|
+
**Examples:**
|
|
113
|
+
- `core_v1.0.0_001_CreateAuthUsers.cs`
|
|
114
|
+
- `core_v1.2.0_001_AddUserProfiles.cs`
|
|
115
|
+
- `extensions_v1.0.0_001_CreateClientOrders.cs`
|
|
116
|
+
|
|
117
|
+
**Rules:**
|
|
118
|
+
- [ ] Context: `core` or `extensions`
|
|
119
|
+
- [ ] Version: semver format (1.0.0)
|
|
120
|
+
- [ ] Sequence: 3-digit padded (001, 002)
|
|
121
|
+
- [ ] Description: PascalCase, descriptive
|
|
122
|
+
</migrations>
|
|
123
|
+
|
|
124
|
+
<controllers>
|
|
125
|
+
## Controller Conventions
|
|
126
|
+
|
|
127
|
+
**NavRoute attribute** (preferred):
|
|
128
|
+
```csharp
|
|
129
|
+
[ApiController]
|
|
130
|
+
[NavRoute("platform.administration.users")]
|
|
131
|
+
public class UsersController : ControllerBase
|
|
132
|
+
{
|
|
133
|
+
// Routes generated from NavRoute: /api/platform/administration/users
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**NavRoute format:**
|
|
138
|
+
- Lowercase only
|
|
139
|
+
- Dot-separated hierarchy
|
|
140
|
+
- Minimum 2 levels: `context.application`
|
|
141
|
+
- Full path: `context.application.module`
|
|
142
|
+
|
|
143
|
+
**Examples:**
|
|
144
|
+
- `platform.administration.users`
|
|
145
|
+
- `platform.administration.roles`
|
|
146
|
+
- `business.crm.contacts`
|
|
147
|
+
- `personal.myspace.dashboard`
|
|
148
|
+
</controllers>
|
|
149
|
+
|
|
150
|
+
<services>
|
|
151
|
+
## Service Conventions
|
|
152
|
+
|
|
153
|
+
**Interface pattern:**
|
|
154
|
+
```csharp
|
|
155
|
+
// Interface
|
|
156
|
+
public interface IUserService
|
|
157
|
+
{
|
|
158
|
+
Task<UserDto> GetByIdAsync(Guid id, CancellationToken ct);
|
|
159
|
+
Task<UserDto> CreateAsync(CreateUserDto dto, CancellationToken ct);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Implementation
|
|
163
|
+
public class UserService : IUserService
|
|
164
|
+
{
|
|
165
|
+
// ...
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Requirements:**
|
|
170
|
+
- [ ] Interface named `I{Name}Service`
|
|
171
|
+
- [ ] Implementation named `{Name}Service`
|
|
172
|
+
- [ ] All methods async with CancellationToken
|
|
173
|
+
- [ ] Return DTOs, not entities
|
|
174
|
+
</services>
|
|
175
|
+
|
|
176
|
+
<security>
|
|
177
|
+
## SmartStack Security Patterns
|
|
178
|
+
|
|
179
|
+
<multi_tenant>
|
|
180
|
+
**Multi-tenant isolation:**
|
|
181
|
+
- ALL queries MUST filter by TenantId (automatic via EF Core global filters)
|
|
182
|
+
- NEVER expose TenantId in URLs
|
|
183
|
+
- NEVER allow cross-tenant data access
|
|
184
|
+
- Create methods MUST require tenantId parameter
|
|
185
|
+
|
|
186
|
+
**Check for violations:**
|
|
187
|
+
```csharp
|
|
188
|
+
// BAD: No tenant filter
|
|
189
|
+
var users = await _context.Users.ToListAsync();
|
|
190
|
+
|
|
191
|
+
// GOOD: Tenant filter applied (via global filter or explicit)
|
|
192
|
+
var users = await _context.Users
|
|
193
|
+
.Where(u => u.TenantId == _tenantId)
|
|
194
|
+
.ToListAsync();
|
|
195
|
+
```
|
|
196
|
+
</multi_tenant>
|
|
197
|
+
|
|
198
|
+
<authorization>
|
|
199
|
+
**RBAC with NavRoute:**
|
|
200
|
+
- Controllers use `[NavRoute]` for automatic permission mapping
|
|
201
|
+
- Permissions follow NavRoute pattern: `{navroute}.{action}`
|
|
202
|
+
- Actions: `read`, `create`, `update`, `delete`, `*` (wildcard)
|
|
203
|
+
|
|
204
|
+
**Example permissions:**
|
|
205
|
+
- `platform.administration.users.read`
|
|
206
|
+
- `platform.administration.users.create`
|
|
207
|
+
- `platform.administration.users.*` (all actions)
|
|
208
|
+
</authorization>
|
|
209
|
+
|
|
210
|
+
<input_validation>
|
|
211
|
+
**FluentValidation:**
|
|
212
|
+
```csharp
|
|
213
|
+
public class CreateUserDtoValidator : AbstractValidator<CreateUserDto>
|
|
214
|
+
{
|
|
215
|
+
public CreateUserDtoValidator()
|
|
216
|
+
{
|
|
217
|
+
RuleFor(x => x.Email)
|
|
218
|
+
.NotEmpty()
|
|
219
|
+
.EmailAddress()
|
|
220
|
+
.MaximumLength(256);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
</input_validation>
|
|
225
|
+
</security>
|
|
226
|
+
|
|
227
|
+
<tests>
|
|
228
|
+
## Test Conventions
|
|
229
|
+
|
|
230
|
+
**Naming pattern:** `{Method}_When{Condition}_Should{Result}`
|
|
231
|
+
```csharp
|
|
232
|
+
public class UserServiceTests
|
|
233
|
+
{
|
|
234
|
+
[Fact]
|
|
235
|
+
public async Task GetById_WhenUserExists_ShouldReturnUser() { }
|
|
236
|
+
|
|
237
|
+
[Fact]
|
|
238
|
+
public async Task GetById_WhenUserNotFound_ShouldThrowNotFoundException() { }
|
|
239
|
+
|
|
240
|
+
[Fact]
|
|
241
|
+
public async Task Create_WhenValidDto_ShouldCreateAndReturnUser() { }
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Structure:**
|
|
246
|
+
```
|
|
247
|
+
Tests/
|
|
248
|
+
├── Unit/
|
|
249
|
+
│ ├── Services/
|
|
250
|
+
│ └── Validators/
|
|
251
|
+
└── Integration/
|
|
252
|
+
└── Controllers/
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Patterns:**
|
|
256
|
+
- [ ] AAA pattern (Arrange, Act, Assert)
|
|
257
|
+
- [ ] FluentAssertions for assertions
|
|
258
|
+
- [ ] Moq for mocking
|
|
259
|
+
- [ ] Tenant isolation tests for all tenant-aware services
|
|
260
|
+
</tests>
|
|
261
|
+
|
|
262
|
+
<review_checklist>
|
|
263
|
+
## SmartStack Code Review Checklist
|
|
264
|
+
|
|
265
|
+
**Run MCP validation first:**
|
|
266
|
+
```
|
|
267
|
+
mcp__smartstack__validate_conventions checks: ["all"]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Then verify manually:**
|
|
271
|
+
|
|
272
|
+
<security_checks>
|
|
273
|
+
### Security (BLOCKING)
|
|
274
|
+
- [ ] No hardcoded credentials or secrets
|
|
275
|
+
- [ ] TenantId isolation enforced
|
|
276
|
+
- [ ] Authorization on all endpoints
|
|
277
|
+
- [ ] Input validation present
|
|
278
|
+
- [ ] No SQL injection risks (use EF Core properly)
|
|
279
|
+
</security_checks>
|
|
280
|
+
|
|
281
|
+
<architecture_checks>
|
|
282
|
+
### Architecture (BLOCKING)
|
|
283
|
+
- [ ] Entities use correct base class (BaseEntity/SystemEntity)
|
|
284
|
+
- [ ] Services have interfaces
|
|
285
|
+
- [ ] Controllers use [NavRoute]
|
|
286
|
+
- [ ] Migrations follow naming convention
|
|
287
|
+
</architecture_checks>
|
|
288
|
+
|
|
289
|
+
<quality_checks>
|
|
290
|
+
### Quality (SUGGESTION)
|
|
291
|
+
- [ ] Tests exist for new functionality
|
|
292
|
+
- [ ] Factory methods used for entity creation
|
|
293
|
+
- [ ] DTOs used for API boundaries
|
|
294
|
+
- [ ] Async methods have CancellationToken
|
|
295
|
+
</quality_checks>
|
|
296
|
+
</review_checklist>
|
|
297
|
+
|
|
298
|
+
<sources>
|
|
299
|
+
- SmartStack Architecture Documentation
|
|
300
|
+
- SmartStack.mcp validation tools
|
|
301
|
+
- Clean Architecture by Robert C. Martin
|
|
302
|
+
</sources>
|