@atlashub/smartstack-cli 2.5.3 → 2.6.1

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 (44) hide show
  1. package/.documentation/business-analyse.html +4 -4
  2. package/.documentation/commands.html +2 -2
  3. package/.documentation/index.html +2 -2
  4. package/.documentation/js/app.js +2 -2
  5. package/dist/index.js +163 -56
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/templates/mcp-scaffolding/component.tsx.hbs +14 -14
  9. package/templates/mcp-scaffolding/controller.cs.hbs +6 -5
  10. package/templates/skills/_resources/docs-manifest-schema.md +3 -3
  11. package/templates/skills/_resources/mcp-validate-documentation-spec.md +6 -6
  12. package/templates/skills/apex/steps/step-04b-doc-sync.md +4 -4
  13. package/templates/skills/apex/steps/step-05-examine.md +1 -1
  14. package/templates/skills/apex/templates/04b-doc-sync.md +1 -1
  15. package/templates/skills/application/SKILL.md +33 -16
  16. package/templates/skills/application/steps/step-00-init.md +86 -3
  17. package/templates/skills/application/steps/step-01-navigation.md +34 -0
  18. package/templates/skills/application/steps/step-02-permissions.md +37 -0
  19. package/templates/skills/application/steps/step-03-roles.md +23 -2
  20. package/templates/skills/application/steps/step-03b-provider.md +251 -0
  21. package/templates/skills/application/steps/step-04-backend.md +75 -0
  22. package/templates/skills/application/steps/step-05-frontend.md +149 -10
  23. package/templates/skills/application/steps/step-06-migration.md +27 -15
  24. package/templates/skills/application/steps/step-07-tests.md +404 -0
  25. package/templates/skills/application/steps/step-08-documentation.md +137 -0
  26. package/templates/skills/application/templates-frontend.md +133 -26
  27. package/templates/skills/application/templates-seed.md +116 -0
  28. package/templates/skills/business-analyse/SKILL.md +1 -1
  29. package/templates/skills/business-analyse/questionnaire/07-ui.md +15 -0
  30. package/templates/skills/business-analyse/questionnaire/10-documentation.md +2 -2
  31. package/templates/skills/business-analyse/schemas/feature-schema.json +96 -7
  32. package/templates/skills/business-analyse/steps/step-03-specify.md +134 -5
  33. package/templates/skills/business-analyse/steps/step-05-handoff.md +61 -8
  34. package/templates/skills/business-analyse/templates/tpl-frd.md +1 -1
  35. package/templates/skills/business-analyse/templates-frd.md +8 -8
  36. package/templates/skills/business-analyse/templates-react.md +26 -26
  37. package/templates/skills/documentation/SKILL.md +6 -6
  38. package/templates/skills/documentation/data-schema.md +70 -44
  39. package/templates/skills/documentation/templates.md +6 -6
  40. package/templates/skills/ralph-loop/SKILL.md +1 -2
  41. package/templates/skills/ralph-loop/steps/step-01-task.md +1 -1
  42. package/templates/skills/ui-components/SKILL.md +33 -2
  43. package/templates/skills/ui-components/patterns/dashboard-chart.md +327 -0
  44. package/templates/skills/ui-components/style-guide.md +27 -0
@@ -0,0 +1,404 @@
1
+ ---
2
+ name: step-07-tests
3
+ description: Generate backend and security tests using MCP tools
4
+ prev_step: steps/step-06-migration.md
5
+ next_step: steps/step-08-documentation.md
6
+ ---
7
+
8
+ # Step 7: Test Generation
9
+
10
+ ## MANDATORY EXECUTION RULES
11
+
12
+ - ALWAYS use MCP `scaffold_tests` for test generation
13
+ - ALWAYS generate at least 3 test categories: controller, service, entity
14
+ - ALWAYS follow naming convention: `{Method}_When{Condition}_Should{Result}`
15
+ - YOU ARE AN ORCHESTRATOR calling MCP, not a generator
16
+
17
+ ## YOUR TASK
18
+
19
+ Use MCP tools to generate test files covering:
20
+ 1. Controller integration tests (API endpoints)
21
+ 2. Service unit tests (business logic)
22
+ 3. Entity unit tests (domain rules)
23
+ 4. Validator unit tests (input validation)
24
+ 5. Repository integration tests (data access)
25
+ 6. Security tests (OWASP coverage)
26
+
27
+ ---
28
+
29
+ ## AVAILABLE STATE
30
+
31
+ From previous steps:
32
+
33
+ | Variable | Description |
34
+ |----------|-------------|
35
+ | `{entity_name}` | PascalCase entity name |
36
+ | `{entity_code}` | kebab-case code |
37
+ | `{full_path}` | Complete navigation path (navRoute) |
38
+ | `{namespace}` | .NET namespace |
39
+ | `{api_route}` | API endpoint path |
40
+
41
+ ---
42
+
43
+ ## PRE-REQUISITES
44
+
45
+ ### 1. Verify Test Project Exists
46
+
47
+ Check that the solution contains a test project:
48
+
49
+ ```bash
50
+ # Look for existing test project
51
+ ls *Tests*/*.csproj 2>/dev/null || ls tests/*/*.csproj 2>/dev/null
52
+ ```
53
+
54
+ If NO test project exists, create one:
55
+
56
+ ```bash
57
+ dotnet new xunit -n {SolutionName}.Tests -o tests/{SolutionName}.Tests
58
+ dotnet sln add tests/{SolutionName}.Tests/{SolutionName}.Tests.csproj
59
+ ```
60
+
61
+ ### 2. Verify Required NuGet Packages
62
+
63
+ The test project MUST have these packages:
64
+
65
+ | Package | Purpose |
66
+ |---------|---------|
67
+ | `xunit` | Test framework |
68
+ | `FluentAssertions` | Assertion library |
69
+ | `Moq` | Mocking framework |
70
+ | `Microsoft.AspNetCore.Mvc.Testing` | Integration test support |
71
+ | `Microsoft.EntityFrameworkCore.InMemory` | In-memory DB for repository tests |
72
+ | `FluentValidation.TestHelper` | Validator testing support |
73
+
74
+ ```bash
75
+ cd tests/{SolutionName}.Tests
76
+ dotnet add package FluentAssertions
77
+ dotnet add package Moq
78
+ dotnet add package Microsoft.AspNetCore.Mvc.Testing
79
+ dotnet add package Microsoft.EntityFrameworkCore.InMemory
80
+ dotnet add package FluentValidation.TestHelper
81
+ ```
82
+
83
+ ---
84
+
85
+ ## EXECUTION SEQUENCE
86
+
87
+ ### 1. Generate Controller Tests
88
+
89
+ ```
90
+ Tool: mcp__smartstack__scaffold_tests
91
+ Args:
92
+ type: "controller"
93
+ name: "{entity_name}"
94
+ options:
95
+ namespace: "{namespace}"
96
+ navRoute: "{full_path}"
97
+ includeAuthorization: true
98
+ isSystemEntity: false
99
+ ```
100
+
101
+ This generates:
102
+ - `Tests/Integration/Controllers/{EntityName}ControllerTests.cs`
103
+
104
+ **Coverage:**
105
+ - GET all → 200 with list
106
+ - GET by ID → 200 when exists, 404 when not
107
+ - POST → 201 when valid, 400 when invalid, 409 when duplicate
108
+ - PUT → 200 when valid, 404 when not exists, 409 on concurrency
109
+ - DELETE → 204 when exists, 404 when not
110
+ - Authorization → 401 unauthenticated, 403 forbidden
111
+ - Tenant isolation → only current tenant data
112
+ - Pagination → paged results
113
+ - Error format → ProblemDetails
114
+
115
+ ### 2. Generate Service Tests
116
+
117
+ ```
118
+ Tool: mcp__smartstack__scaffold_tests
119
+ Args:
120
+ type: "service"
121
+ name: "{entity_name}"
122
+ options:
123
+ namespace: "{namespace}"
124
+ includeSoftDelete: true
125
+ isSystemEntity: false
126
+ ```
127
+
128
+ This generates:
129
+ - `Tests/Unit/Services/{EntityName}ServiceTests.cs`
130
+
131
+ **Coverage:**
132
+ - GetById → entity when exists, null when not
133
+ - GetAll → list when entities exist, empty when none
134
+ - Create → success, duplicate code rejection
135
+ - Update → success, not found exception
136
+ - Delete → soft delete, already deleted, not found
137
+ - Tenant isolation → correct tenant assignment
138
+ - Error handling → repository failure, concurrency conflict
139
+
140
+ ### 3. Generate Entity Tests
141
+
142
+ ```
143
+ Tool: mcp__smartstack__scaffold_tests
144
+ Args:
145
+ type: "entity"
146
+ name: "{entity_name}"
147
+ options:
148
+ namespace: "{namespace}"
149
+ includeSoftDelete: true
150
+ includeAudit: true
151
+ isSystemEntity: false
152
+ ```
153
+
154
+ This generates:
155
+ - `Tests/Unit/Domain/{EntityName}Tests.cs`
156
+
157
+ **Coverage:**
158
+ - Factory method Create → valid data, empty tenant, invalid code
159
+ - Update → audit fields
160
+ - Soft delete → mark as deleted, already deleted, restore
161
+ - Audit trail → creation fields, update fields
162
+ - Tenant isolation → immutable TenantId
163
+
164
+ ### 4. Generate Validator Tests
165
+
166
+ ```
167
+ Tool: mcp__smartstack__scaffold_tests
168
+ Args:
169
+ type: "validator"
170
+ name: "{entity_name}"
171
+ options:
172
+ namespace: "{namespace}"
173
+ ```
174
+
175
+ This generates:
176
+ - `Tests/Unit/Validators/{EntityName}ValidatorTests.cs`
177
+
178
+ **Coverage:**
179
+ - Code validation → valid, null/empty, max length, valid format, invalid characters
180
+ - Name validation → valid, max length
181
+ - Update validation → valid data, optional null fields
182
+ - Security → XSS, SQL injection, prototype pollution
183
+ - Cross-field validation → dependent fields
184
+ - Multiple errors → all errors returned
185
+
186
+ ### 5. Generate Repository Tests
187
+
188
+ ```
189
+ Tool: mcp__smartstack__scaffold_tests
190
+ Args:
191
+ type: "repository"
192
+ name: "{entity_name}"
193
+ options:
194
+ namespace: "{namespace}"
195
+ includeSoftDelete: true
196
+ isSystemEntity: false
197
+ ```
198
+
199
+ This generates:
200
+ - `Tests/Integration/Repositories/{EntityName}RepositoryTests.cs`
201
+
202
+ **Coverage:**
203
+ - GetById → exists, not exists, soft deleted
204
+ - GetAll → entities exist, empty, exclude soft deleted
205
+ - Add → persist, generate ID
206
+ - Update → persist changes
207
+ - Remove → delete entity
208
+ - ExistsByCode → exists, not exists, soft deleted
209
+ - Tenant isolation → current tenant only, cross-tenant returns null
210
+ - Pagination → correct page and counts
211
+ - Concurrency → concurrent modification exception
212
+
213
+ ### 6. Generate Security Tests
214
+
215
+ ```
216
+ Tool: mcp__smartstack__scaffold_tests
217
+ Args:
218
+ type: "security"
219
+ name: "{entity_name}"
220
+ options:
221
+ namespace: "{namespace}"
222
+ isSystemEntity: false
223
+ ```
224
+
225
+ This generates:
226
+ - `Tests/Security/{EntityName}SecurityTests.cs`
227
+
228
+ **Coverage:**
229
+ - Authentication → 401 for unauthenticated, expired token, malformed token
230
+ - Authorization → 403 for insufficient permissions
231
+ - Tenant isolation → cross-tenant access returns 404, tenant ID not injectable
232
+ - Input validation → XSS prevention, SQL injection prevention, path traversal, prototype pollution
233
+ - IDOR → no data leakage via ID guessing
234
+ - Rate limiting → 429 on excessive requests
235
+ - Sensitive data → no passwords/secrets/stack traces exposed
236
+ - CORS → no wildcard origins
237
+ - Security headers → X-Content-Type-Options, X-Frame-Options, X-XSS-Protection
238
+
239
+ ---
240
+
241
+ ## POST-GENERATION VERIFICATION (MANDATORY)
242
+
243
+ ### 1. Naming Convention Check (BLOCKING)
244
+
245
+ All test methods MUST follow: `{Method}_When{Condition}_Should{Result}`
246
+
247
+ ```
248
+ FORBIDDEN patterns:
249
+ Test1, Test2, TestMethod, MyTest
250
+ Should_Return_OK, test_get_all
251
+
252
+ REQUIRED pattern:
253
+ GetAll_WhenCalled_ShouldReturn200WithList
254
+ Create_WhenDuplicateCode_ShouldThrowException
255
+ Delete_WhenNotAuthenticated_ShouldReturn401
256
+ ```
257
+
258
+ ### 2. Test Structure Check (BLOCKING)
259
+
260
+ All tests MUST follow Arrange-Act-Assert:
261
+
262
+ ```csharp
263
+ // ✅ CORRECT
264
+ [Fact]
265
+ public async Task GetById_WhenExists_ShouldReturn200()
266
+ {
267
+ // Arrange
268
+ var id = Guid.NewGuid();
269
+ // ...
270
+
271
+ // Act
272
+ var response = await _client.GetAsync($"/api/{entityCode}/{id}");
273
+
274
+ // Assert
275
+ response.StatusCode.Should().Be(HttpStatusCode.OK);
276
+ }
277
+
278
+ // ❌ FORBIDDEN - No AAA structure
279
+ [Fact]
280
+ public async Task TestGetById()
281
+ {
282
+ var response = await _client.GetAsync("/api/test/123");
283
+ Assert.True(response.IsSuccessStatusCode);
284
+ }
285
+ ```
286
+
287
+ ### 3. Dependencies Check (BLOCKING)
288
+
289
+ Verify test project references:
290
+ - `FluentAssertions` (NOT `Assert.Equal`)
291
+ - `Moq` (NOT manual fakes)
292
+ - `xunit` (NOT NUnit or MSTest)
293
+
294
+ ### 4. Coverage Check
295
+
296
+ Minimum test coverage per category:
297
+
298
+ | Category | Minimum Tests |
299
+ |----------|---------------|
300
+ | Controller | 10 (CRUD + auth + tenant) |
301
+ | Service | 8 (CRUD + errors) |
302
+ | Entity | 5 (factory + update + validation) |
303
+ | Validator | 8 (code + name + security) |
304
+ | Repository | 8 (CRUD + tenant + pagination) |
305
+ | Security | 10 (auth + injection + headers) |
306
+
307
+ ### 5. Build Check (BLOCKING)
308
+
309
+ ```bash
310
+ dotnet build tests/{SolutionName}.Tests/{SolutionName}.Tests.csproj
311
+ ```
312
+
313
+ If build fails, fix compilation errors before proceeding.
314
+
315
+ ### 6. Test Run (NON-BLOCKING)
316
+
317
+ ```bash
318
+ dotnet test tests/{SolutionName}.Tests/{SolutionName}.Tests.csproj --no-build
319
+ ```
320
+
321
+ Note: Some tests may fail initially because the service/repository implementations are stubs. This is expected. The test structure and conventions must be correct.
322
+
323
+ ---
324
+
325
+ ## PRESENT OUTPUT TO USER
326
+
327
+ ```markdown
328
+ ## Test Suite Generated
329
+
330
+ ### Test Files
331
+
332
+ | File | Category | Tests |
333
+ |------|----------|-------|
334
+ | `Tests/Integration/Controllers/{EntityName}ControllerTests.cs` | Controller | ~12 |
335
+ | `Tests/Unit/Services/{EntityName}ServiceTests.cs` | Service | ~10 |
336
+ | `Tests/Unit/Domain/{EntityName}Tests.cs` | Entity | ~8 |
337
+ | `Tests/Unit/Validators/{EntityName}ValidatorTests.cs` | Validator | ~12 |
338
+ | `Tests/Integration/Repositories/{EntityName}RepositoryTests.cs` | Repository | ~12 |
339
+ | `Tests/Security/{EntityName}SecurityTests.cs` | Security | ~15 |
340
+
341
+ ### Test Categories
342
+
343
+ | Category | Coverage |
344
+ |----------|----------|
345
+ | CRUD Operations | ✅ All endpoints tested |
346
+ | Authentication | ✅ 401 for unauthenticated |
347
+ | Authorization | ✅ 403 for insufficient permissions |
348
+ | Tenant Isolation | ✅ Cross-tenant access blocked |
349
+ | Input Validation | ✅ XSS, SQL injection, path traversal |
350
+ | Error Handling | ✅ ProblemDetails format |
351
+ | Concurrency | ✅ Optimistic locking |
352
+ | Pagination | ✅ Paged results |
353
+
354
+ ### Naming Convention
355
+ All tests follow: `{Method}_When{Condition}_Should{Result}`
356
+
357
+ ### Required NuGet Packages
358
+ - xunit
359
+ - FluentAssertions
360
+ - Moq
361
+ - Microsoft.AspNetCore.Mvc.Testing
362
+ - Microsoft.EntityFrameworkCore.InMemory
363
+ - FluentValidation.TestHelper
364
+
365
+ ### Next Steps
366
+ 1. Implement service stubs to make tests pass
367
+ 2. Run `dotnet test` to verify test compilation
368
+ 3. Achieve >80% code coverage
369
+ ```
370
+
371
+ ---
372
+
373
+ ## SUCCESS METRICS
374
+
375
+ - Test project exists in solution
376
+ - All 6 test categories generated
377
+ - Naming convention `{Method}_When{Condition}_Should{Result}` respected
378
+ - Arrange-Act-Assert structure in all tests
379
+ - FluentAssertions used (not Assert.Equal)
380
+ - Moq used for mocking
381
+ - Test project builds successfully
382
+ - Minimum test count met per category
383
+
384
+ ## FAILURE MODES
385
+
386
+ - Test project doesn't exist → Create it first
387
+ - Missing NuGet packages → Install them
388
+ - Build failures → Fix compilation errors
389
+ - Wrong naming convention → Rename tests
390
+ - Missing test categories → Generate missing ones
391
+
392
+ ---
393
+
394
+ ## END OF WORKFLOW
395
+
396
+ This is the final step of the /application skill workflow. The user now has:
397
+ - Full navigation structure (step 01)
398
+ - RBAC permissions (step 02)
399
+ - Role mappings (step 03)
400
+ - Client seed provider (step 03b, if applicable)
401
+ - Backend CRUD API (step 04)
402
+ - Frontend components + i18n + routes (step 05)
403
+ - Database migration (step 06)
404
+ - **Complete test suite (step 07)**
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: step-08-documentation
3
+ description: Generate in-app user documentation for the module
4
+ prev_step: steps/step-07-tests.md
5
+ next_step: null
6
+ ---
7
+
8
+ # Step 8: Documentation Generation
9
+
10
+ ## CONDITION D'EXECUTION
11
+
12
+ Ce step s'execute si :
13
+ - Le feature.json du module contient `documentation.userDocRequired: true`
14
+ - OU si aucun feature.json n'existe (generation par defaut - documentation est toujours utile)
15
+
16
+ Si `documentation.userDocRequired` est explicitement `false`, afficher :
17
+
18
+ ```
19
+ ℹ Documentation skipped (userDocRequired: false in feature.json)
20
+ ```
21
+
22
+ Et passer directement au recapitulatif final.
23
+
24
+ ## MANDATORY EXECUTION RULES
25
+
26
+ - ALWAYS check feature.json for documentation requirements before generating
27
+ - ALWAYS invoke the `/documentation` skill (not manual generation)
28
+ - ALWAYS update feature.json documentation status after generation
29
+ - YOU ARE AN ORCHESTRATOR calling `/documentation`, not a generator
30
+
31
+ ## YOUR TASK
32
+
33
+ Declencher le skill `/documentation` pour generer la page de documentation in-app du module.
34
+ Le skill `/documentation` lit les sources du module (entites, controleur, permissions, feature.json)
35
+ et genere une page de documentation data-driven integree dans l'application web.
36
+
37
+ ## EXECUTION
38
+
39
+ ### 1. Verify Prerequisites
40
+
41
+ Before invoking documentation generation, verify:
42
+
43
+ - [ ] Module backend is generated (controller, services, entities exist)
44
+ - [ ] Module frontend is generated (pages, components exist)
45
+ - [ ] i18n translations exist (4 languages: fr, en, it, de)
46
+ - [ ] Permissions are defined (Permissions.cs exists)
47
+
48
+ If any prerequisite is missing, warn but continue (documentation can reference planned features).
49
+
50
+ ### 2. Check feature.json Documentation Requirements
51
+
52
+ ```
53
+ Read feature.json for the current module:
54
+ - documentation.userDocRequired → generate user documentation page
55
+ - documentation.techDocRequired → generate technical documentation (ERD)
56
+ ```
57
+
58
+ ### 3. Invoke /documentation Skill
59
+
60
+ **For user documentation (default):**
61
+
62
+ Equivalent of: `/documentation user {module_name}`
63
+
64
+ The `/documentation` skill will:
65
+ 1. Read sources (entities, controller, permissions, feature.json specification)
66
+ 2. Generate `doc-data.ts` (structured data file, ~50 lines)
67
+ 3. Generate `index.tsx` (page wrapper, ~10 lines)
68
+ 4. Generate i18n FR file (source language - EN/IT/DE deferred to translation pipeline)
69
+ 5. Update `docs-manifest.json`
70
+ 6. Update `App.tsx` routing
71
+ 7. Update `UserIndexPage.tsx` (add module entry)
72
+
73
+ **For technical documentation (if techDocRequired):**
74
+
75
+ Equivalent of: `/documentation database {module_name}`
76
+
77
+ Generates database ERD and schema documentation page.
78
+
79
+ ### 4. Update feature.json Status
80
+
81
+ If feature.json exists, update the documentation status:
82
+
83
+ ```
84
+ ba-writer.enrichSection({
85
+ featureId: {feature_id},
86
+ section: "documentation",
87
+ data: {
88
+ status: "generated",
89
+ generatedAt: "{ISO timestamp}"
90
+ }
91
+ })
92
+ ```
93
+
94
+ ### 5. Present Result
95
+
96
+ ```
97
+ ═══════════════════════════════════════════════════════════════
98
+ ✓ DOCUMENTATION GENERATED - {module_name}
99
+ ═══════════════════════════════════════════════════════════════
100
+
101
+ Files generated:
102
+ ✓ docs/business/{app}/{module}/doc-data.ts
103
+ ✓ docs/business/{app}/{module}/index.tsx
104
+ ✓ i18n/locales/fr/docs-{app}-{module}.json
105
+ ✓ docs-manifest.json (updated)
106
+ ✓ App.tsx (route added)
107
+ ✓ UserIndexPage.tsx (module entry added)
108
+
109
+ Documentation URL: /system/docs/user/{app}/{module}
110
+ ═══════════════════════════════════════════════════════════════
111
+ ```
112
+
113
+ ## FINAL RECAP
114
+
115
+ After documentation generation (or skip), present the complete module recap:
116
+
117
+ ```
118
+ ═══════════════════════════════════════════════════════════════
119
+ ✓ MODULE COMPLETE - {module_name}
120
+ ═══════════════════════════════════════════════════════════════
121
+
122
+ Step 01: Navigation ✓
123
+ Step 02: Permissions ✓
124
+ Step 03: Roles ✓
125
+ Step 04: Backend ✓
126
+ Step 05: Frontend ✓
127
+ Step 06: Migration ✓
128
+ Step 07: Tests ✓
129
+ Step 08: Documentation ✓ (or ⊘ skipped)
130
+
131
+ Total files generated: {count}
132
+ ═══════════════════════════════════════════════════════════════
133
+ ```
134
+
135
+ ## NEXT STEP
136
+
137
+ End of `/application` workflow. No further steps.