@atlashub/smartstack-cli 1.13.2 → 1.14.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/.documentation/agents.html +1 -1
- package/.documentation/apex.html +1 -1
- package/.documentation/business-analyse.html +1 -1
- package/.documentation/cli-commands.html +3 -3
- package/.documentation/commands.html +1 -1
- package/.documentation/efcore.html +1 -1
- package/.documentation/gitflow.html +1 -1
- package/.documentation/hooks.html +1 -1
- package/.documentation/index.html +1 -1
- package/.documentation/init.html +3 -3
- package/.documentation/installation.html +1001 -352
- package/.documentation/ralph-loop.html +1 -1
- package/.documentation/test-web.html +1 -1
- package/README.md +88 -20
- package/dist/index.js +276 -85
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/agents/code-reviewer.md +163 -0
- package/templates/agents/efcore/db-deploy.md +25 -7
- package/templates/agents/efcore/db-reset.md +31 -10
- package/templates/agents/efcore/db-status.md +22 -5
- package/templates/agents/efcore/migration.md +69 -19
- package/templates/agents/gitflow/cleanup.md +8 -1
- package/templates/agents/gitflow/commit.md +7 -5
- package/templates/agents/gitflow/finish.md +6 -4
- package/templates/agents/gitflow/pr.md +8 -1
- package/templates/agents/gitflow/start.md +1 -1
- package/templates/commands/check-version.md +267 -0
- package/templates/commands/efcore/_shared.md +30 -1
- package/templates/commands/efcore/db-reset.md +18 -6
- package/templates/commands/gitflow/OPTIMIZATIONS.md +206 -0
- package/templates/commands/refactor.md +164 -0
- package/templates/project/DependencyInjection.Application.cs.template +25 -0
- package/templates/project/DependencyInjection.Infrastructure.cs.template +61 -0
- package/templates/project/DesignTimeExtensionsDbContextFactory.cs.template +70 -0
- package/templates/project/ExampleEntity.cs.template +116 -0
- package/templates/project/ExampleEntityConfiguration.cs.template +64 -0
- package/templates/project/ExampleService.cs.template +146 -0
- package/templates/project/ExtensionsDbContext.cs.template +41 -0
- package/templates/project/IExtensionsDbContext.cs.template +22 -0
- package/templates/project/Program.cs.template +47 -0
- package/templates/project/README.md +79 -0
- package/templates/ralph/README.md +10 -8
- package/templates/ralph/ralph.config.yaml +2 -2
- package/templates/skills/_shared.md +44 -44
- package/templates/skills/ai-prompt/SKILL.md +55 -55
- package/templates/skills/apex/SKILL.md +235 -0
- package/templates/skills/apex/steps/step-00-init.md +203 -0
- package/templates/skills/apex/steps/step-01-analyze.md +210 -0
- package/templates/skills/apex/steps/step-02-plan.md +217 -0
- package/templates/skills/apex/steps/step-03-execute.md +178 -0
- package/templates/skills/apex/steps/step-04-validate.md +217 -0
- package/templates/skills/apex/steps/step-05-examine.md +207 -0
- package/templates/skills/apex/steps/step-06-resolve.md +181 -0
- package/templates/skills/apex/steps/step-07-tests.md +206 -0
- package/templates/skills/apex/steps/step-08-run-tests.md +207 -0
- package/templates/skills/apex/templates/00-context.md +46 -0
- package/templates/skills/apex/templates/01-analyze.md +63 -0
- package/templates/skills/apex/templates/02-plan.md +63 -0
- package/templates/skills/apex/templates/03-execute.md +34 -0
- package/templates/skills/apex/templates/04-validate.md +61 -0
- package/templates/skills/apex/templates/05-examine.md +58 -0
- package/templates/skills/apex/templates/06-resolve.md +39 -0
- package/templates/skills/apex/templates/07-tests.md +56 -0
- package/templates/skills/apex/templates/08-run-tests.md +41 -0
- package/templates/skills/apex/templates/README.md +69 -0
- package/templates/skills/application/SKILL.md +50 -50
- package/templates/skills/application/templates-backend.md +25 -25
- package/templates/skills/application/templates-frontend.md +43 -43
- package/templates/skills/application/templates-i18n.md +29 -29
- package/templates/skills/application/templates-seed.md +77 -77
- package/templates/skills/business-analyse/SKILL.md +223 -0
- package/templates/skills/business-analyse/_shared.md +258 -0
- package/templates/skills/business-analyse/questionnaire/01-context.md +33 -0
- package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +35 -0
- package/templates/skills/business-analyse/questionnaire/03-scope.md +35 -0
- package/templates/skills/business-analyse/questionnaire/04-data.md +36 -0
- package/templates/skills/business-analyse/questionnaire/05-integrations.md +36 -0
- package/templates/skills/business-analyse/questionnaire/06-security.md +40 -0
- package/templates/skills/business-analyse/questionnaire/07-ui.md +36 -0
- package/templates/skills/business-analyse/questionnaire/08-performance.md +35 -0
- package/templates/skills/business-analyse/questionnaire/09-constraints.md +35 -0
- package/templates/skills/business-analyse/questionnaire/10-documentation.md +35 -0
- package/templates/skills/business-analyse/questionnaire.md +177 -177
- package/templates/skills/business-analyse/react/components.md +340 -0
- package/templates/skills/business-analyse/react/i18n-template.md +245 -0
- package/templates/skills/business-analyse/react/schema.md +151 -0
- package/templates/skills/business-analyse/steps/step-00-init.md +293 -0
- package/templates/skills/business-analyse/steps/step-01-discover.md +267 -0
- package/templates/skills/business-analyse/steps/step-02-analyse.md +243 -0
- package/templates/skills/business-analyse/steps/step-03-specify.md +317 -0
- package/templates/skills/business-analyse/steps/step-04-validate.md +239 -0
- package/templates/skills/business-analyse/steps/step-05-handoff.md +336 -0
- package/templates/skills/business-analyse/steps/step-06-doc-html.md +261 -0
- package/templates/skills/business-analyse/templates/00-context.md +105 -0
- package/templates/skills/business-analyse/templates/frd-brd.md +97 -0
- package/templates/skills/business-analyse/templates/frd-discovery.md +78 -0
- package/templates/skills/business-analyse/templates/frd-handoff.md +118 -0
- package/templates/skills/business-analyse/templates/frd-spec.md +168 -0
- package/templates/skills/business-analyse/templates-frd.md +217 -217
- package/templates/skills/business-analyse/templates-react.md +26 -26
- package/templates/skills/controller/SKILL.md +141 -92
- package/templates/skills/controller/postman-templates.md +15 -15
- package/templates/skills/controller/steps/step-00-init.md +191 -0
- package/templates/skills/controller/steps/step-01-analyze.md +146 -0
- package/templates/skills/controller/steps/step-02-plan.md +176 -0
- package/templates/skills/controller/steps/step-03-generate.md +219 -0
- package/templates/skills/controller/steps/step-04-perms.md +219 -0
- package/templates/skills/controller/steps/step-05-validate.md +107 -0
- package/templates/skills/controller/templates.md +77 -77
- package/templates/skills/documentation/SKILL.md +79 -79
- package/templates/skills/feature-full/SKILL.md +38 -38
- package/templates/skills/gitflow/SKILL.md +277 -0
- package/templates/{commands → skills}/gitflow/_shared.md +20 -20
- package/templates/skills/gitflow/phases/abort.md +173 -0
- package/templates/skills/gitflow/phases/cleanup.md +226 -0
- package/templates/skills/gitflow/phases/status.md +178 -0
- package/templates/skills/gitflow/steps/step-commit.md +255 -0
- package/templates/skills/gitflow/steps/step-finish.md +255 -0
- package/templates/skills/gitflow/steps/step-init.md +209 -0
- package/templates/skills/gitflow/steps/step-merge.md +225 -0
- package/templates/skills/gitflow/steps/step-plan.md +208 -0
- package/templates/skills/gitflow/steps/step-pr.md +235 -0
- package/templates/skills/gitflow/steps/step-start.md +234 -0
- package/templates/skills/gitflow/steps/step-sync.md +200 -0
- package/templates/skills/gitflow/templates/config.json +53 -0
- package/templates/skills/notification/SKILL.md +51 -51
- package/templates/skills/ralph-loop/SKILL.md +228 -0
- package/templates/skills/ralph-loop/steps/step-00-init.md +201 -0
- package/templates/skills/ralph-loop/steps/step-01-task.md +169 -0
- package/templates/skills/ralph-loop/steps/step-02-execute.md +173 -0
- package/templates/skills/ralph-loop/steps/step-03-commit.md +170 -0
- package/templates/skills/ralph-loop/steps/step-04-check.md +162 -0
- package/templates/skills/ralph-loop/steps/step-05-report.md +181 -0
- package/templates/skills/review-code/SKILL.md +219 -0
- package/templates/skills/review-code/references/clean-code-principles.md +140 -0
- package/templates/skills/review-code/references/code-quality-metrics.md +174 -0
- package/templates/skills/review-code/references/feedback-patterns.md +149 -0
- package/templates/skills/review-code/references/security-checklist.md +127 -0
- package/templates/skills/ui-components/SKILL.md +54 -54
- package/templates/skills/workflow/SKILL.md +46 -46
- package/templates/commands/ai-prompt.md +0 -315
- package/templates/commands/apex/1-analyze.md +0 -100
- package/templates/commands/apex/2-plan.md +0 -145
- package/templates/commands/apex/3-execute.md +0 -171
- package/templates/commands/apex/4-examine.md +0 -116
- package/templates/commands/apex/5-tasks.md +0 -209
- package/templates/commands/apex.md +0 -76
- package/templates/commands/application/create.md +0 -362
- package/templates/commands/application/templates-backend.md +0 -463
- package/templates/commands/application/templates-frontend.md +0 -517
- package/templates/commands/application/templates-i18n.md +0 -478
- package/templates/commands/application/templates-seed.md +0 -362
- package/templates/commands/application.md +0 -303
- package/templates/commands/business-analyse/0-orchestrate.md +0 -156
- package/templates/commands/business-analyse/1-init.md +0 -99
- package/templates/commands/business-analyse/2-discover.md +0 -143
- package/templates/commands/business-analyse/3-analyse.md +0 -106
- package/templates/commands/business-analyse/4-specify.md +0 -133
- package/templates/commands/business-analyse/5-validate.md +0 -132
- package/templates/commands/business-analyse/6-handoff.md +0 -157
- package/templates/commands/business-analyse/7-doc-html.md +0 -103
- package/templates/commands/business-analyse/_shared.md +0 -176
- package/templates/commands/business-analyse/bug.md +0 -118
- package/templates/commands/business-analyse/change-request.md +0 -144
- package/templates/commands/business-analyse/hotfix.md +0 -116
- package/templates/commands/business-analyse.md +0 -121
- package/templates/commands/controller/create.md +0 -216
- package/templates/commands/controller/postman-templates.md +0 -528
- package/templates/commands/controller/templates.md +0 -600
- package/templates/commands/controller.md +0 -337
- package/templates/commands/create/agent.md +0 -138
- package/templates/commands/create/command.md +0 -166
- package/templates/commands/create/hook.md +0 -234
- package/templates/commands/create/plugin.md +0 -329
- package/templates/commands/create/project.md +0 -508
- package/templates/commands/create/skill.md +0 -199
- package/templates/commands/create.md +0 -220
- package/templates/commands/documentation/module.md +0 -202
- package/templates/commands/documentation/templates.md +0 -432
- package/templates/commands/documentation.md +0 -190
- package/templates/commands/epct.md +0 -69
- package/templates/commands/explain.md +0 -186
- package/templates/commands/feature-full.md +0 -267
- package/templates/commands/gitflow/1-init.md +0 -188
- package/templates/commands/gitflow/10-start.md +0 -190
- package/templates/commands/gitflow/11-finish.md +0 -382
- package/templates/commands/gitflow/12-cleanup.md +0 -103
- package/templates/commands/gitflow/13-sync.md +0 -216
- package/templates/commands/gitflow/14-rebase.md +0 -251
- package/templates/commands/gitflow/2-status.md +0 -122
- package/templates/commands/gitflow/3-commit.md +0 -209
- package/templates/commands/gitflow/4-plan.md +0 -174
- package/templates/commands/gitflow/5-exec.md +0 -202
- package/templates/commands/gitflow/6-abort.md +0 -121
- package/templates/commands/gitflow/7-pull-request.md +0 -176
- package/templates/commands/gitflow/8-review.md +0 -113
- package/templates/commands/gitflow/9-merge.md +0 -157
- package/templates/commands/gitflow.md +0 -128
- package/templates/commands/implement.md +0 -663
- package/templates/commands/init.md +0 -567
- package/templates/commands/mcp-integration.md +0 -330
- package/templates/commands/notification.md +0 -129
- package/templates/commands/oneshot.md +0 -57
- package/templates/commands/quickstart.md +0 -154
- package/templates/commands/ralph-loop/cancel-ralph.md +0 -18
- package/templates/commands/ralph-loop/help.md +0 -126
- package/templates/commands/ralph-loop/ralph-loop.md +0 -120
- package/templates/commands/review.md +0 -106
- package/templates/commands/workflow.md +0 -193
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: step-01-analyze
|
|
3
|
+
description: Analyze existing codebase - find Entity, DbContext, patterns
|
|
4
|
+
next_step: steps/step-02-plan.md
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Step 1: Analyze Codebase
|
|
8
|
+
|
|
9
|
+
## YOUR TASK:
|
|
10
|
+
|
|
11
|
+
Gather all context needed to generate the controller. Find the Entity, check DbContext, analyze existing patterns.
|
|
12
|
+
|
|
13
|
+
**ULTRA THINK before searching.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## EXECUTION SEQUENCE:
|
|
18
|
+
|
|
19
|
+
### 1. Find Entity Domain
|
|
20
|
+
|
|
21
|
+
**Search for entity file:**
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Glob: "src/SmartStack.Domain/**/{entity}.cs"
|
|
25
|
+
Glob: "src/SmartStack.Domain/**/{entity}s.cs"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Extract from Entity:**
|
|
29
|
+
- Properties (for DTO generation)
|
|
30
|
+
- Factory method signature `Create(...)`
|
|
31
|
+
- Update method signature `Update(...)`
|
|
32
|
+
- Relationships (navigation properties)
|
|
33
|
+
- Base class (BaseEntity, AuditableEntity, TenantEntity)
|
|
34
|
+
|
|
35
|
+
**If Entity NOT found:**
|
|
36
|
+
```
|
|
37
|
+
STOP - Entity {entity} not found in Domain layer.
|
|
38
|
+
Create entity first: /apex add {entity} entity to Domain
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Check DbContext
|
|
42
|
+
|
|
43
|
+
**Verify DbSet exists:**
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Grep: "DbSet<{entity}>" in IApplicationDbContext.cs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**If DbSet NOT found:**
|
|
50
|
+
```
|
|
51
|
+
WARNING: DbSet<{entity}> not in DbContext.
|
|
52
|
+
Will need to add: DbSet<{entity}> {module} { get; }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Analyze Existing Permissions
|
|
56
|
+
|
|
57
|
+
**Check current permissions:**
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Read: src/SmartStack.Application/Common/Authorization/Permissions.cs
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Look for:**
|
|
64
|
+
- Existing permission class for this module
|
|
65
|
+
- Permission naming pattern used
|
|
66
|
+
- Nested class structure
|
|
67
|
+
|
|
68
|
+
### 4. Find Similar Controllers
|
|
69
|
+
|
|
70
|
+
**Find reference controllers in same area:**
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Glob: "src/SmartStack.Api/Controllers/{area}/*.cs"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Extract patterns from existing controllers:**
|
|
77
|
+
- Constructor injection pattern
|
|
78
|
+
- Base class used
|
|
79
|
+
- Common attributes
|
|
80
|
+
- Response type patterns
|
|
81
|
+
- Error handling patterns
|
|
82
|
+
|
|
83
|
+
### 5. Check for Existing Controller
|
|
84
|
+
|
|
85
|
+
**Verify controller doesn't exist:**
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Glob: "src/SmartStack.Api/Controllers/{area}/{module}Controller.cs"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**If EXISTS:**
|
|
92
|
+
```
|
|
93
|
+
WARNING: Controller already exists!
|
|
94
|
+
Options:
|
|
95
|
+
1. Overwrite (will backup existing)
|
|
96
|
+
2. Abort generation
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 6. Compile Analysis Report
|
|
100
|
+
|
|
101
|
+
**Store in state:**
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
{entity_found} = true/false
|
|
105
|
+
{entity_path} = "src/SmartStack.Domain/..."
|
|
106
|
+
{entity_properties} = [list of properties]
|
|
107
|
+
{entity_base_class} = "TenantEntity" | "AuditableEntity" | "BaseEntity"
|
|
108
|
+
{dbset_exists} = true/false
|
|
109
|
+
{permissions_exist} = true/false
|
|
110
|
+
{similar_controller} = "path/to/similar.cs" (for reference)
|
|
111
|
+
{controller_exists} = true/false
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## OUTPUT FORMAT:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
Analysis Complete:
|
|
120
|
+
|
|
121
|
+
| Check | Status | Details |
|
|
122
|
+
|-------|--------|---------|
|
|
123
|
+
| Entity | ✅/❌ | {entity_path} |
|
|
124
|
+
| DbSet | ✅/❌ | DbSet<{entity}> |
|
|
125
|
+
| Permissions | ✅/❌ | {permission_path}.* |
|
|
126
|
+
| Reference | ✅ | {similar_controller} |
|
|
127
|
+
| Existing | ⚠️/✅ | Controller exists/new |
|
|
128
|
+
|
|
129
|
+
Entity Properties:
|
|
130
|
+
- Id (Guid)
|
|
131
|
+
- Name (string)
|
|
132
|
+
- ... (extracted from entity)
|
|
133
|
+
|
|
134
|
+
-> Planning controller structure...
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## BLOCKING CONDITIONS:
|
|
140
|
+
|
|
141
|
+
- **Entity not found** → STOP, suggest creating entity first
|
|
142
|
+
- **Controller exists + auto_mode=false** → ASK user to confirm overwrite
|
|
143
|
+
|
|
144
|
+
## NEXT STEP:
|
|
145
|
+
|
|
146
|
+
After analysis complete, proceed to `./step-02-plan.md`
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: step-02-plan
|
|
3
|
+
description: Plan controller structure - endpoints, DTOs, permissions
|
|
4
|
+
next_step: steps/step-03-generate.md
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Step 2: Plan Controller Structure
|
|
8
|
+
|
|
9
|
+
## YOUR TASK:
|
|
10
|
+
|
|
11
|
+
Design the complete controller structure based on analysis. Define endpoints, DTOs, and permissions.
|
|
12
|
+
|
|
13
|
+
**ULTRA THINK about REST conventions and SmartStack patterns.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## EXECUTION SEQUENCE:
|
|
18
|
+
|
|
19
|
+
### 1. Determine Controller Type
|
|
20
|
+
|
|
21
|
+
**Based on {area} and analysis:**
|
|
22
|
+
|
|
23
|
+
| Indicator | → Controller Type |
|
|
24
|
+
|-----------|-------------------|
|
|
25
|
+
| Area = Auth | `auth` (login, logout, tokens) |
|
|
26
|
+
| Entity has all CRUD methods | `crud` (full CRUD) |
|
|
27
|
+
| Entity missing Create/Update | `readonly` (GET only) |
|
|
28
|
+
| User specifies custom | `custom` (specific endpoints) |
|
|
29
|
+
|
|
30
|
+
**If not auto_mode, confirm:**
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
AskUserQuestion:
|
|
34
|
+
header: "Type"
|
|
35
|
+
question: "What type of controller?"
|
|
36
|
+
options:
|
|
37
|
+
- label: "CRUD Complet (Recommended)"
|
|
38
|
+
description: "GET list, GET by ID, POST, PUT, PATCH, DELETE"
|
|
39
|
+
- label: "Read-Only"
|
|
40
|
+
description: "GET list, GET by ID only"
|
|
41
|
+
- label: "Custom"
|
|
42
|
+
description: "I'll specify the endpoints"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Plan Endpoints
|
|
46
|
+
|
|
47
|
+
**For CRUD controller:**
|
|
48
|
+
|
|
49
|
+
| Method | Route | Action | Permission |
|
|
50
|
+
|--------|-------|--------|------------|
|
|
51
|
+
| GET | `/{module}` | GetAll | `{permission_path}.read` |
|
|
52
|
+
| GET | `/{module}/{id}` | GetById | `{permission_path}.read` |
|
|
53
|
+
| POST | `/{module}` | Create | `{permission_path}.create` |
|
|
54
|
+
| PUT | `/{module}/{id}` | Update | `{permission_path}.update` |
|
|
55
|
+
| PATCH | `/{module}/{id}/status` | UpdateStatus | `{permission_path}.update` |
|
|
56
|
+
| DELETE | `/{module}/{id}` | Delete | `{permission_path}.delete` |
|
|
57
|
+
|
|
58
|
+
**For Auth controller:**
|
|
59
|
+
|
|
60
|
+
| Method | Route | Action | Permission |
|
|
61
|
+
|--------|-------|--------|------------|
|
|
62
|
+
| POST | `/auth/login` | Login | AllowAnonymous |
|
|
63
|
+
| POST | `/auth/logout` | Logout | Authorize |
|
|
64
|
+
| POST | `/auth/refresh` | RefreshToken | AllowAnonymous |
|
|
65
|
+
| POST | `/auth/change-password` | ChangePassword | Authorize |
|
|
66
|
+
|
|
67
|
+
### 3. Plan DTOs (if dto_mode)
|
|
68
|
+
|
|
69
|
+
**CreateDto:**
|
|
70
|
+
```
|
|
71
|
+
{entity}CreateDto:
|
|
72
|
+
- Required properties from Entity.Create()
|
|
73
|
+
- Validation attributes
|
|
74
|
+
- No Id, CreatedAt, etc.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**UpdateDto:**
|
|
78
|
+
```
|
|
79
|
+
{entity}UpdateDto:
|
|
80
|
+
- Updatable properties from Entity.Update()
|
|
81
|
+
- Validation attributes
|
|
82
|
+
- No Id, audit fields
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**ResponseDto:**
|
|
86
|
+
```
|
|
87
|
+
{entity}ResponseDto:
|
|
88
|
+
- All public properties
|
|
89
|
+
- Formatted dates
|
|
90
|
+
- Nested DTOs for relationships
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 4. Plan Permissions
|
|
94
|
+
|
|
95
|
+
**Permission structure:**
|
|
96
|
+
|
|
97
|
+
```csharp
|
|
98
|
+
public static class {module}
|
|
99
|
+
{
|
|
100
|
+
public const string View = "{permission_path}.read";
|
|
101
|
+
public const string Create = "{permission_path}.create";
|
|
102
|
+
public const string Update = "{permission_path}.update";
|
|
103
|
+
public const string Delete = "{permission_path}.delete";
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Permission seeds:**
|
|
108
|
+
|
|
109
|
+
```csharp
|
|
110
|
+
new Permission { Code = "{permission_path}.read", Name = "View {module}", ... }
|
|
111
|
+
new Permission { Code = "{permission_path}.create", Name = "Create {module}", ... }
|
|
112
|
+
new Permission { Code = "{permission_path}.update", Name = "Update {module}", ... }
|
|
113
|
+
new Permission { Code = "{permission_path}.delete", Name = "Delete {module}", ... }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 5. Plan Services to Inject
|
|
117
|
+
|
|
118
|
+
**Required services:**
|
|
119
|
+
|
|
120
|
+
| Service | Required | Reason |
|
|
121
|
+
|---------|----------|--------|
|
|
122
|
+
| `IApplicationDbContext` | Always | DB access |
|
|
123
|
+
| `ICurrentUserService` | Always | User context |
|
|
124
|
+
| `ILogger<T>` | Always | Logging |
|
|
125
|
+
| `IPermissionService` | If roles/perms | Cache invalidation |
|
|
126
|
+
| `IPasswordService` | If auth | Password hashing |
|
|
127
|
+
| `IJwtService` | If auth | Token generation |
|
|
128
|
+
|
|
129
|
+
### 6. Confirmation (if not auto_mode)
|
|
130
|
+
|
|
131
|
+
**Show plan for approval:**
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
Controller Plan: {area}/{module}Controller
|
|
135
|
+
|
|
136
|
+
Endpoints:
|
|
137
|
+
GET /api/{area}/{module} → GetAll
|
|
138
|
+
GET /api/{area}/{module}/{id} → GetById
|
|
139
|
+
POST /api/{area}/{module} → Create
|
|
140
|
+
PUT /api/{area}/{module}/{id} → Update
|
|
141
|
+
DELETE /api/{area}/{module}/{id} → Delete
|
|
142
|
+
|
|
143
|
+
DTOs: {dto_mode ? "CreateDto, UpdateDto, ResponseDto" : "None (inline)"}
|
|
144
|
+
|
|
145
|
+
Permissions:
|
|
146
|
+
{permission_path}.read
|
|
147
|
+
{permission_path}.create
|
|
148
|
+
{permission_path}.update
|
|
149
|
+
{permission_path}.delete
|
|
150
|
+
|
|
151
|
+
Proceed with generation?
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## OUTPUT FORMAT:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
Plan Complete:
|
|
160
|
+
|
|
161
|
+
| Aspect | Details |
|
|
162
|
+
|--------|---------|
|
|
163
|
+
| Type | {controller_type} |
|
|
164
|
+
| Endpoints | {endpoint_count} |
|
|
165
|
+
| DTOs | {dto_count} |
|
|
166
|
+
| Permissions | 4 (CRUD) |
|
|
167
|
+
| Services | {service_count} |
|
|
168
|
+
|
|
169
|
+
-> Generating controller...
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## NEXT STEP:
|
|
175
|
+
|
|
176
|
+
After plan confirmed (or auto_mode), proceed to `./step-03-generate.md`
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: step-03-generate
|
|
3
|
+
description: Generate controller file and DTOs
|
|
4
|
+
next_step: steps/step-04-perms.md
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Step 3: Generate Controller
|
|
8
|
+
|
|
9
|
+
## YOUR TASK:
|
|
10
|
+
|
|
11
|
+
Generate the controller file following SmartStack conventions. Use templates from `templates.md`.
|
|
12
|
+
|
|
13
|
+
**ULTRA THINK about security and patterns.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## EXECUTION SEQUENCE:
|
|
18
|
+
|
|
19
|
+
### 1. Load Templates
|
|
20
|
+
|
|
21
|
+
**Read template file:**
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Read: templates/templates.md
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Select appropriate template based on {controller_type}:**
|
|
28
|
+
- CRUD Controller template
|
|
29
|
+
- Auth Controller template
|
|
30
|
+
- ReadOnly Controller template
|
|
31
|
+
|
|
32
|
+
### 2. Generate Controller File
|
|
33
|
+
|
|
34
|
+
**Target path:**
|
|
35
|
+
```
|
|
36
|
+
src/SmartStack.Api/Controllers/{area}/{module}Controller.cs
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Apply template with variables:**
|
|
40
|
+
|
|
41
|
+
```csharp
|
|
42
|
+
using Microsoft.AspNetCore.Mvc;
|
|
43
|
+
using Microsoft.AspNetCore.Http;
|
|
44
|
+
using SmartStack.Application.Common.Authorization;
|
|
45
|
+
using SmartStack.Application.Common.Interfaces;
|
|
46
|
+
using SmartStack.Domain.Entities;
|
|
47
|
+
|
|
48
|
+
namespace SmartStack.Api.Controllers.{area};
|
|
49
|
+
|
|
50
|
+
[ApiController]
|
|
51
|
+
[Route("api/{area_lowercase}/[controller]")]
|
|
52
|
+
[Authorize]
|
|
53
|
+
public class {module}Controller : ControllerBase
|
|
54
|
+
{
|
|
55
|
+
private readonly IApplicationDbContext _context;
|
|
56
|
+
private readonly ICurrentUserService _currentUser;
|
|
57
|
+
private readonly ILogger<{module}Controller> _logger;
|
|
58
|
+
|
|
59
|
+
public {module}Controller(
|
|
60
|
+
IApplicationDbContext context,
|
|
61
|
+
ICurrentUserService currentUser,
|
|
62
|
+
ILogger<{module}Controller> logger)
|
|
63
|
+
{
|
|
64
|
+
_context = context;
|
|
65
|
+
_currentUser = currentUser;
|
|
66
|
+
_logger = logger;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Endpoints generated based on plan...
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3. Generate Endpoints
|
|
74
|
+
|
|
75
|
+
**For each planned endpoint, generate with:**
|
|
76
|
+
|
|
77
|
+
1. **Attributes:**
|
|
78
|
+
- `[HttpGet]`, `[HttpPost]`, etc.
|
|
79
|
+
- `[RequirePermission(Permissions.{module}.View)]`
|
|
80
|
+
- `[ProducesResponseType(typeof(...), StatusCodes.Status200OK)]`
|
|
81
|
+
- `[ProducesResponseType(StatusCodes.Status401Unauthorized)]`
|
|
82
|
+
- `[ProducesResponseType(StatusCodes.Status403Forbidden)]`
|
|
83
|
+
|
|
84
|
+
2. **Method body:**
|
|
85
|
+
- Parameter validation
|
|
86
|
+
- Entity operation
|
|
87
|
+
- Logging
|
|
88
|
+
- Response mapping
|
|
89
|
+
|
|
90
|
+
**Example GET endpoint:**
|
|
91
|
+
|
|
92
|
+
```csharp
|
|
93
|
+
[HttpGet]
|
|
94
|
+
[RequirePermission(Permissions.{module}.View)]
|
|
95
|
+
[ProducesResponseType(typeof(PagedResult<{entity}ResponseDto>), StatusCodes.Status200OK)]
|
|
96
|
+
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
97
|
+
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
|
98
|
+
public async Task<IActionResult> GetAll(
|
|
99
|
+
[FromQuery] int page = 1,
|
|
100
|
+
[FromQuery] int pageSize = 20,
|
|
101
|
+
CancellationToken ct = default)
|
|
102
|
+
{
|
|
103
|
+
var query = _context.{module}
|
|
104
|
+
.AsNoTracking()
|
|
105
|
+
.OrderByDescending(x => x.CreatedAt);
|
|
106
|
+
|
|
107
|
+
var total = await query.CountAsync(ct);
|
|
108
|
+
var items = await query
|
|
109
|
+
.Skip((page - 1) * pageSize)
|
|
110
|
+
.Take(pageSize)
|
|
111
|
+
.Select(x => new {entity}ResponseDto(x))
|
|
112
|
+
.ToListAsync(ct);
|
|
113
|
+
|
|
114
|
+
return Ok(new PagedResult<{entity}ResponseDto>(items, total, page, pageSize));
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 4. Generate DTOs (if dto_mode)
|
|
119
|
+
|
|
120
|
+
**Target paths:**
|
|
121
|
+
```
|
|
122
|
+
src/SmartStack.Application/DTOs/{module}/{entity}CreateDto.cs
|
|
123
|
+
src/SmartStack.Application/DTOs/{module}/{entity}UpdateDto.cs
|
|
124
|
+
src/SmartStack.Application/DTOs/{module}/{entity}ResponseDto.cs
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**CreateDto template:**
|
|
128
|
+
|
|
129
|
+
```csharp
|
|
130
|
+
public record {entity}CreateDto(
|
|
131
|
+
string Name,
|
|
132
|
+
// ... required properties
|
|
133
|
+
);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**UpdateDto template:**
|
|
137
|
+
|
|
138
|
+
```csharp
|
|
139
|
+
public record {entity}UpdateDto(
|
|
140
|
+
string? Name,
|
|
141
|
+
// ... optional properties
|
|
142
|
+
);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**ResponseDto template:**
|
|
146
|
+
|
|
147
|
+
```csharp
|
|
148
|
+
public record {entity}ResponseDto(
|
|
149
|
+
Guid Id,
|
|
150
|
+
string Name,
|
|
151
|
+
// ... all public properties
|
|
152
|
+
DateTime CreatedAt,
|
|
153
|
+
DateTime? UpdatedAt
|
|
154
|
+
)
|
|
155
|
+
{
|
|
156
|
+
public {entity}ResponseDto({entity} entity) : this(
|
|
157
|
+
entity.Id,
|
|
158
|
+
entity.Name,
|
|
159
|
+
// ... mapping
|
|
160
|
+
entity.CreatedAt,
|
|
161
|
+
entity.UpdatedAt
|
|
162
|
+
) { }
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 5. Add Security Logging
|
|
167
|
+
|
|
168
|
+
**Ensure logging for all operations:**
|
|
169
|
+
|
|
170
|
+
```csharp
|
|
171
|
+
// Create
|
|
172
|
+
_logger.LogInformation("User {User} created {entity} {Id}",
|
|
173
|
+
_currentUser.Email, entity.Id);
|
|
174
|
+
|
|
175
|
+
// Update
|
|
176
|
+
_logger.LogInformation("User {User} updated {entity} {Id}",
|
|
177
|
+
_currentUser.Email, entity.Id);
|
|
178
|
+
|
|
179
|
+
// Delete (Warning level)
|
|
180
|
+
_logger.LogWarning("User {User} deleted {entity} {Id} ({Name})",
|
|
181
|
+
_currentUser.Email, id, entity.Name);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 6. Protect System Accounts (if applicable)
|
|
185
|
+
|
|
186
|
+
**Add guard for system entities:**
|
|
187
|
+
|
|
188
|
+
```csharp
|
|
189
|
+
// Before modify/delete operations
|
|
190
|
+
if (entity.UserType == UserType.System || entity.UserType == UserType.LocalAdmin)
|
|
191
|
+
{
|
|
192
|
+
_logger.LogWarning("Attempt to modify system account {Id} by {User}",
|
|
193
|
+
entity.Id, _currentUser.Email);
|
|
194
|
+
return BadRequest(new { message = "Cannot modify system accounts" });
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## OUTPUT FORMAT:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
Generated Files:
|
|
204
|
+
|
|
205
|
+
| File | Path | Status |
|
|
206
|
+
|------|------|--------|
|
|
207
|
+
| Controller | src/.../Controllers/{area}/{module}Controller.cs | ✅ Created |
|
|
208
|
+
| CreateDto | src/.../DTOs/{module}/{entity}CreateDto.cs | ✅ Created |
|
|
209
|
+
| UpdateDto | src/.../DTOs/{module}/{entity}UpdateDto.cs | ✅ Created |
|
|
210
|
+
| ResponseDto | src/.../DTOs/{module}/{entity}ResponseDto.cs | ✅ Created |
|
|
211
|
+
|
|
212
|
+
-> Synchronizing permissions...
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## NEXT STEP:
|
|
218
|
+
|
|
219
|
+
After generation complete, proceed to `./step-04-perms.md`
|