@polymorphism-tech/morph-spec 4.10.0 → 4.10.2
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/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +5 -69
- package/framework/agents/backend/api-designer.md +3 -0
- package/framework/agents/backend/dotnet-senior.md +3 -0
- package/framework/agents/backend/ef-modeler.md +2 -0
- package/framework/agents/backend/hangfire-orchestrator.md +2 -0
- package/framework/agents/backend/ms-agent-expert.md +2 -0
- package/framework/agents/frontend/blazor-builder.md +2 -0
- package/framework/agents/frontend/nextjs-expert.md +2 -0
- package/framework/agents/infrastructure/azure-architect.md +2 -0
- package/framework/agents/infrastructure/azure-deploy-specialist.md +2 -0
- package/framework/agents/infrastructure/bicep-architect.md +2 -0
- package/framework/agents/infrastructure/container-specialist.md +2 -0
- package/framework/agents/infrastructure/devops-engineer.md +3 -0
- package/framework/agents/infrastructure/infra-architect.md +3 -0
- package/framework/agents/integrations/asaas-financial.md +2 -0
- package/framework/agents/integrations/azure-identity.md +2 -0
- package/framework/agents/integrations/clerk-auth.md +3 -0
- package/framework/agents/integrations/hangfire-integration.md +2 -0
- package/framework/agents/integrations/resend-email.md +2 -0
- package/framework/commands/morph-apply.md +151 -161
- package/framework/commands/morph-archive.md +28 -28
- package/framework/commands/morph-infra.md +79 -79
- package/framework/commands/morph-preflight.md +92 -56
- package/framework/commands/morph-proposal.md +94 -70
- package/framework/commands/morph-status.md +31 -31
- package/framework/commands/morph-troubleshoot.md +63 -60
- package/framework/rules/csharp-standards.md +3 -0
- package/framework/rules/frontend-standards.md +2 -0
- package/framework/rules/infrastructure-standards.md +3 -0
- package/framework/rules/morph-workflow.md +57 -2
- package/framework/rules/nextjs-standards.md +2 -0
- package/framework/rules/testing-standards.md +3 -0
- package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +54 -49
- package/framework/skills/level-0-meta/morph-checklist/SKILL.md +42 -19
- package/framework/skills/level-0-meta/morph-code-review/SKILL.md +8 -5
- package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +7 -5
- package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +139 -136
- package/framework/skills/level-0-meta/morph-init/SKILL.md +42 -13
- package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +130 -130
- package/framework/skills/level-0-meta/morph-replicate/SKILL.md +95 -87
- package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +24 -0
- package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +42 -41
- package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +22 -11
- package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +123 -114
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +120 -102
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +206 -214
- package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +241 -360
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +107 -115
- package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +135 -135
- package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +143 -139
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +168 -165
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +57 -8
- package/package.json +3 -3
- package/src/commands/project/doctor.js +7 -2
- package/src/commands/project/update.js +4 -4
- package/src/lib/stack-filter.js +58 -0
- package/src/scripts/setup-infra.js +53 -18
- package/src/utils/agents-installer.js +19 -5
- package/src/utils/claude-md-injector.js +90 -0
- package/src/utils/hooks-installer.js +1 -4
- package/src/utils/skills-installer.js +67 -7
- package/CLAUDE.md +0 -98
- package/framework/memory/patterns-learned.md +0 -766
- package/framework/skills/level-0-meta/morph-terminal-title/SKILL.md +0 -61
- package/framework/skills/level-0-meta/morph-terminal-title/scripts/set_title.sh +0 -65
|
@@ -3,163 +3,151 @@ name: morph:phase-design
|
|
|
3
3
|
description: MORPH-SPEC Phase 2 (Design). Schema-first interactive design: reads EF models/Supabase/DB, validates findings with user, then routes to VSA Blueprint or DDD Architecture Blueprint based on config.architecture.style, producing spec.md, contracts.cs, schema-analysis.md, and decisions.md through a quality loop (score 0-100). Use after setup phase to create technical specifications grounded in the real database schema.
|
|
4
4
|
argument-hint: "[feature-name]"
|
|
5
5
|
user-invocable: false
|
|
6
|
-
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
-
cliVersion: "4.10.
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
|
|
7
|
+
cliVersion: "4.10.2"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
# MORPH Design
|
|
10
|
+
# MORPH Design — Phase 2
|
|
11
11
|
|
|
12
12
|
> INTERNAL: Workflow skill used by /morph-proposal during automated phase orchestration. Not a user command.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Schema-first interactive design: read the real schema, validate with user, generate blueprint, produce artifacts through a quality loop.
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Prerequisites
|
|
17
17
|
|
|
18
|
-
- [ ]
|
|
19
|
-
- [ ]
|
|
20
|
-
- [ ]
|
|
18
|
+
- [ ] Phase 1 (Setup) completed
|
|
19
|
+
- [ ] Phase 1.5 (UI/UX) completed OR skipped
|
|
20
|
+
- [ ] Proposal approved by the user
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Recommended Tools
|
|
23
23
|
|
|
24
|
-
> **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md`
|
|
25
|
-
> **
|
|
24
|
+
> **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for full guide.
|
|
25
|
+
> **Ref:** `references/spec-example.md` — filled-in spec.md showing expected output quality.
|
|
26
|
+
> **Ref:** `references/spec-authoring-guide.md` — section structure for spec.md.
|
|
26
27
|
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
|
|
|
30
|
-
| **
|
|
28
|
+
| Action | Tool | Alternative |
|
|
29
|
+
|--------|------|-------------|
|
|
30
|
+
| Read proposal + UI specs | **Read** output files | — |
|
|
31
|
+
| **Detect architecture** | **Read** `.morph/config/config.json` → check `architecture.style` | **Bash** `grep` |
|
|
31
32
|
| **Schema: Supabase** | **Supabase MCP** `list_tables()`, `get_table_schema()`, `get_relationships()` | — |
|
|
32
33
|
| **Schema: EF Core** | **Glob** `**/Entities/**/*.cs` + **Glob** `**/*Context.cs` → **Read** | **Grep** `DbSet<` |
|
|
33
34
|
| **Schema: Next.js/TS** | **Glob** `src/**/types/**/*.ts` + **Grep** `interface\|type.*=` | — |
|
|
34
|
-
| Schema:
|
|
35
|
+
| Schema: RLS policies | **Supabase MCP** `query()` with `pg_policies` | **Read** policy files |
|
|
35
36
|
| Dispatch vsa-architect | **Agent** `subagent_type=vsa-architect` + `prompt=agent.taskPrompt` | — |
|
|
36
37
|
| Dispatch domain-architect | **Agent** `subagent_type=domain-architect` + `prompt=agent.taskPrompt` | — |
|
|
37
|
-
| Dispatch tech leads | **Agent**
|
|
38
|
-
| Research
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
45
|
-
**Anti-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- ❌ Ignorar `config.architecture.style` — sempre detecte antes do CHECKPOINT 2
|
|
38
|
+
| Dispatch tech leads | **Agent** for each active agent from dispatch config | — |
|
|
39
|
+
| Research library | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
|
|
40
|
+
| Render contracts VSA | **Bash** `npx morph-spec template render dotnet-contracts-vsa ...` | — |
|
|
41
|
+
| Render contracts DDD | **Bash** `npx morph-spec template render dotnet-contracts-level{N} ...` | — |
|
|
42
|
+
| Render spec.md | **Bash** `npx morph-spec template render docs/spec ...` | — |
|
|
43
|
+
| Render decisions.md | **Bash** `npx morph-spec template render docs/decisions ...` | — |
|
|
44
|
+
| Update state | **Bash** `npx morph-spec state mark-output $ARGUMENTS <type>` | — |
|
|
45
|
+
|
|
46
|
+
**Anti-patterns:**
|
|
47
|
+
- Do not generate contracts before reading the real schema — guessed field names corrupt the entire design
|
|
48
|
+
- Do not present a Blueprint without validating with the user first
|
|
49
|
+
- Do not ask questions as plain text — always use `AskUserQuestion`
|
|
50
|
+
- Do not ignore `config.architecture.style` — always detect it before CHECKPOINT 2
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
-
##
|
|
54
|
+
## PRE-FLIGHT
|
|
55
55
|
|
|
56
|
-
**
|
|
56
|
+
**STEP 0 (BEFORE any reads or writes) — Ensure phase is design:**
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
npx morph-spec state get $ARGUMENTS
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Check the `"phase"` field in the output:
|
|
63
63
|
|
|
64
|
-
**
|
|
64
|
+
**If `"phase": "design"`** → phase is correct, proceed.
|
|
65
65
|
|
|
66
|
-
**
|
|
66
|
+
**If `"phase": "proposal"`** → execute in sequence:
|
|
67
67
|
1. `npx morph-spec state mark-output $ARGUMENTS proposal`
|
|
68
68
|
2. `npx morph-spec phase advance $ARGUMENTS` (→ setup)
|
|
69
69
|
3. `npx morph-spec phase advance $ARGUMENTS` (→ design)
|
|
70
70
|
|
|
71
|
-
**
|
|
71
|
+
**If `"phase": "setup"`** → execute:
|
|
72
72
|
1. `npx morph-spec phase advance $ARGUMENTS` (→ design)
|
|
73
73
|
|
|
74
|
-
**
|
|
74
|
+
**Any other value** → do not proceed — inconsistent state, report to user.
|
|
75
75
|
|
|
76
|
-
> **
|
|
76
|
+
> **Rule:** Never write to `1-design/` while the phase is not `design`. The hook will block and the sequence will be corrupted.
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
Read in parallel:
|
|
81
81
|
```
|
|
82
82
|
Read: .morph/features/$ARGUMENTS/0-proposal/proposal.md
|
|
83
|
-
+ Read: .morph/config/config.json ←
|
|
83
|
+
+ Read: .morph/config/config.json ← detect architecture.style
|
|
84
84
|
+ Read: .morph/context/README.md
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
**
|
|
87
|
+
**Detect architecture style:**
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
| Valor de `config.architecture.style` | Caminho |
|
|
94
|
-
|--------------------------------------|---------|
|
|
95
|
-
| `"vertical-slice"` | → **VSA** (CHECKPOINT 2-VSA + contratos VSA) |
|
|
96
|
-
| qualquer outro valor ou ausente | → **DDD** (CHECKPOINT 2-DDD + contratos DDD) |
|
|
97
|
-
|
|
98
|
-
Se escopo ≥ 20 tasks ou refactor toca ≥ 5 arquivos de domínio → **EnterPlanMode** antes de continuar.
|
|
89
|
+
| Value of `config.architecture.style` | Path |
|
|
90
|
+
|--------------------------------------|------|
|
|
91
|
+
| `"vertical-slice"` | → **VSA** (CHECKPOINT 2-VSA + VSA contracts) |
|
|
92
|
+
| any other value or absent | → **DDD** (CHECKPOINT 2-DDD + DDD contracts) |
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
TaskCreate: "Analisar schema" → activeForm: "Lendo schema real"
|
|
103
|
-
TaskCreate: "Validar Blueprint" → activeForm: "Gerando blueprint"
|
|
104
|
-
TaskCreate: "Gerar spec + contracts" → activeForm: "Gerando artefatos"
|
|
105
|
-
TaskCreate: "Loop de qualidade" → activeForm: "Refinando design"
|
|
106
|
-
```
|
|
94
|
+
If scope ≥ 20 tasks or refactor touches ≥ 5 domain files → **EnterPlanMode** before continuing.
|
|
107
95
|
|
|
108
96
|
---
|
|
109
97
|
|
|
110
|
-
## CHECKPOINT 1 — Schema
|
|
98
|
+
## CHECKPOINT 1 — Real Schema (MANDATORY before any generation)
|
|
111
99
|
|
|
112
|
-
> **
|
|
100
|
+
> **Rule:** Never assume field names. Every generated DTO must have a traceable origin in the schema.
|
|
113
101
|
|
|
114
|
-
### 1.1
|
|
102
|
+
### 1.1 Read real schema
|
|
115
103
|
|
|
116
|
-
Execute
|
|
104
|
+
Execute in parallel according to the stack detected in `config.json`:
|
|
117
105
|
|
|
118
|
-
**Supabase (
|
|
106
|
+
**Supabase (preferred if available):**
|
|
119
107
|
```
|
|
120
|
-
Supabase MCP: list_tables() → get_table_schema(table)
|
|
121
|
-
+ get_relationships() →
|
|
108
|
+
Supabase MCP: list_tables() → get_table_schema(table) for each relevant table
|
|
109
|
+
+ get_relationships() → RLS policies if applicable
|
|
122
110
|
```
|
|
123
111
|
|
|
124
112
|
**EF Core (.NET):**
|
|
125
113
|
```
|
|
126
|
-
Glob: **/Entities/**/*.cs → Read
|
|
127
|
-
Glob: **/*DbContext.cs → Read
|
|
128
|
-
Grep: "DbSet<" →
|
|
114
|
+
Glob: **/Entities/**/*.cs → Read each entity file
|
|
115
|
+
Glob: **/*DbContext.cs → Read to see DbSet<> and relations
|
|
116
|
+
Grep: "DbSet<" → confirm mapped entities
|
|
129
117
|
```
|
|
130
118
|
|
|
131
119
|
**TypeScript/Next.js:**
|
|
132
120
|
```
|
|
133
121
|
Glob: src/**/types/**/*.ts, src/**/models/**/*.ts
|
|
134
|
-
Grep: "export interface|export type" → Read
|
|
122
|
+
Grep: "export interface|export type" → Read found files
|
|
135
123
|
```
|
|
136
124
|
|
|
137
|
-
### 1.2
|
|
125
|
+
### 1.2 Generate schema-analysis.md
|
|
138
126
|
|
|
139
|
-
|
|
127
|
+
Write `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` with:
|
|
140
128
|
|
|
141
129
|
```markdown
|
|
142
130
|
# Schema Analysis — {Feature}
|
|
143
131
|
|
|
144
|
-
##
|
|
132
|
+
## Relevant Entities
|
|
145
133
|
|
|
146
134
|
### {EntityName}
|
|
147
|
-
|
|
|
135
|
+
| Field | DB Type | C#/TS Type | Nullable | Notes |
|
|
148
136
|
|-------|---------|-----------|----------|-------|
|
|
149
137
|
| id | uuid | Guid | No | PK |
|
|
150
138
|
| ... | ... | ... | ... | ... |
|
|
151
139
|
|
|
152
|
-
##
|
|
153
|
-
- {Entity A} 1—N {Entity B} via {
|
|
140
|
+
## Relationships
|
|
141
|
+
- {Entity A} 1—N {Entity B} via {FK field}
|
|
154
142
|
|
|
155
|
-
##
|
|
156
|
-
- {
|
|
143
|
+
## JSONB / Complex Fields
|
|
144
|
+
- {field}: internal structure {known keys}
|
|
157
145
|
|
|
158
|
-
##
|
|
159
|
-
- {
|
|
146
|
+
## Fields Not Referenced in Proposal
|
|
147
|
+
- {field}: present in schema but no reference in the proposal
|
|
160
148
|
```
|
|
161
149
|
|
|
162
|
-
### 1.3
|
|
150
|
+
### 1.3 Validate with user
|
|
163
151
|
|
|
164
152
|
Use `AskUserQuestion`:
|
|
165
153
|
|
|
@@ -167,24 +155,24 @@ Use `AskUserQuestion`:
|
|
|
167
155
|
{
|
|
168
156
|
"questions": [{
|
|
169
157
|
"header": "Schema OK?",
|
|
170
|
-
"question": "
|
|
158
|
+
"question": "Found these entities and fields in the schema. Are they correct before generating contracts?",
|
|
171
159
|
"multiSelect": false,
|
|
172
160
|
"options": [
|
|
173
|
-
{ "label": "
|
|
174
|
-
{ "label": "
|
|
161
|
+
{ "label": "Confirm and continue", "description": "Schema mapped correctly" },
|
|
162
|
+
{ "label": "I have corrections", "description": "Use Other to describe what's wrong" }
|
|
175
163
|
]
|
|
176
164
|
}]
|
|
177
165
|
}
|
|
178
166
|
```
|
|
179
167
|
|
|
180
|
-
- **"
|
|
181
|
-
- **"
|
|
168
|
+
- **"Confirm"** → proceed to Checkpoint 2
|
|
169
|
+
- **"I have corrections" / Other** → apply corrections to schema-analysis.md and repeat 1.3
|
|
182
170
|
|
|
183
171
|
---
|
|
184
172
|
|
|
185
|
-
## CHECKPOINT 2 — Blueprint
|
|
173
|
+
## CHECKPOINT 2 — Architecture Blueprint (MANDATORY before generating contracts)
|
|
186
174
|
|
|
187
|
-
> Use
|
|
175
|
+
> Use the path corresponding to the style detected in PRE-FLIGHT.
|
|
188
176
|
|
|
189
177
|
---
|
|
190
178
|
|
|
@@ -196,57 +184,57 @@ Use `AskUserQuestion`:
|
|
|
196
184
|
npx morph-spec dispatch-agents $ARGUMENTS design
|
|
197
185
|
```
|
|
198
186
|
|
|
199
|
-
Use
|
|
187
|
+
Use the `taskPrompt` from the `vsa-architect` agent in the result. Call:
|
|
200
188
|
|
|
201
189
|
```
|
|
202
|
-
Agent(subagent_type=vsa-architect, prompt=<taskPrompt +
|
|
190
|
+
Agent(subagent_type=vsa-architect, prompt=<taskPrompt + contents of proposal.md + schema-analysis.md>)
|
|
203
191
|
```
|
|
204
192
|
|
|
205
|
-
|
|
206
|
-
- Entity fields (
|
|
193
|
+
The agent produces a VSA Blueprint with:
|
|
194
|
+
- Entity fields (based on the schema validated in Checkpoint 1)
|
|
207
195
|
- Operations (GetAll, GetById, Create, Update, Delete + custom)
|
|
208
196
|
- Routes (`GET /api/{feature}s`, `POST /api/{feature}s`, etc.)
|
|
209
197
|
- Error types (`{Entity}Errors.NotFound`, `{Entity}Errors.AlreadyExists`, etc.)
|
|
210
|
-
- Validation rules
|
|
198
|
+
- Validation rules per field
|
|
211
199
|
|
|
212
|
-
**
|
|
200
|
+
**Parallelize** with other active agents from the dispatch config.
|
|
213
201
|
|
|
214
|
-
#### 2-VSA.2
|
|
202
|
+
#### 2-VSA.2 Validate Blueprint with user
|
|
215
203
|
|
|
216
|
-
|
|
204
|
+
Present the generated blueprint in a readable format and use `AskUserQuestion`:
|
|
217
205
|
|
|
218
206
|
```json
|
|
219
207
|
{
|
|
220
208
|
"questions": [{
|
|
221
209
|
"header": "Blueprint OK?",
|
|
222
|
-
"question": "
|
|
210
|
+
"question": "Planned these slices and operations for the feature. Confirm before generating spec and contracts?",
|
|
223
211
|
"multiSelect": false,
|
|
224
212
|
"options": [
|
|
225
|
-
{ "label": "
|
|
226
|
-
{ "label": "
|
|
213
|
+
{ "label": "Confirm blueprint", "description": "Generate spec.md and contracts with this blueprint" },
|
|
214
|
+
{ "label": "Need adjustments", "description": "Use Other to describe what to change" }
|
|
227
215
|
]
|
|
228
216
|
}]
|
|
229
217
|
}
|
|
230
218
|
```
|
|
231
219
|
|
|
232
|
-
- **"
|
|
233
|
-
- **"
|
|
220
|
+
- **"Confirm"** → proceed to VSA generation
|
|
221
|
+
- **"Need adjustments" / Other** → update blueprint and repeat 2-VSA.2
|
|
234
222
|
|
|
235
223
|
---
|
|
236
224
|
|
|
237
225
|
### CHECKPOINT 2-DDD — Domain-Driven Design
|
|
238
226
|
|
|
239
|
-
#### 2-DDD.1
|
|
227
|
+
#### 2-DDD.1 Determine Complexity Level
|
|
240
228
|
|
|
241
|
-
|
|
229
|
+
Read the proposal and evaluate using the 5 detection questions in `framework/standards/architecture/ddd/complexity-levels.md`:
|
|
242
230
|
|
|
243
|
-
|
|
|
231
|
+
| Level | When to use |
|
|
244
232
|
|-------|-------------|
|
|
245
|
-
| **
|
|
246
|
-
| **
|
|
247
|
-
| **
|
|
233
|
+
| **Level 1 (CRUD)** | Simple entities, no complex business rules, basic CRUD |
|
|
234
|
+
| **Level 2 (Business Logic)** | Domain invariants, business workflows, multiple related entities |
|
|
235
|
+
| **Level 3 (Bounded Context)** | Context isolation, integration events, distributed systems |
|
|
248
236
|
|
|
249
|
-
>
|
|
237
|
+
> If uncertain, assume Level 1 and use `AskUserQuestion` to confirm.
|
|
250
238
|
|
|
251
239
|
#### 2-DDD.2 Dispatch domain-architect
|
|
252
240
|
|
|
@@ -254,60 +242,60 @@ Leia a proposta e avalie com base nas 5 perguntas de detecção em `framework/st
|
|
|
254
242
|
npx morph-spec dispatch-agents $ARGUMENTS design
|
|
255
243
|
```
|
|
256
244
|
|
|
257
|
-
Use
|
|
245
|
+
Use the `taskPrompt` from the `domain-architect` agent in the result. Call:
|
|
258
246
|
|
|
259
247
|
```
|
|
260
|
-
Agent(subagent_type=domain-architect, prompt=<taskPrompt +
|
|
248
|
+
Agent(subagent_type=domain-architect, prompt=<taskPrompt + contents of proposal.md + schema-analysis.md + detected level>)
|
|
261
249
|
```
|
|
262
250
|
|
|
263
|
-
|
|
264
|
-
- **
|
|
265
|
-
- **
|
|
266
|
-
- **
|
|
251
|
+
The agent produces an Architecture Blueprint with:
|
|
252
|
+
- **Level 1:** Entities, repositories, services, DTOs
|
|
253
|
+
- **Level 2:** AggregateRoot, Value Objects, Domain Events, CQRS handlers
|
|
254
|
+
- **Level 3:** BC setup, Integration Events, Anti-corruption layer
|
|
267
255
|
|
|
268
|
-
**
|
|
256
|
+
**Parallelize** with other active agents from the dispatch config.
|
|
269
257
|
|
|
270
|
-
#### 2-DDD.3
|
|
258
|
+
#### 2-DDD.3 Validate Blueprint with user
|
|
271
259
|
|
|
272
|
-
|
|
260
|
+
Present the generated blueprint in a readable format and use `AskUserQuestion`:
|
|
273
261
|
|
|
274
262
|
```json
|
|
275
263
|
{
|
|
276
264
|
"questions": [{
|
|
277
265
|
"header": "Blueprint OK?",
|
|
278
|
-
"question": "
|
|
266
|
+
"question": "Planned this domain architecture for the feature. Confirm before generating spec and contracts?",
|
|
279
267
|
"multiSelect": false,
|
|
280
268
|
"options": [
|
|
281
|
-
{ "label": "
|
|
282
|
-
{ "label": "
|
|
269
|
+
{ "label": "Confirm blueprint", "description": "Generate spec.md and contracts with this blueprint" },
|
|
270
|
+
{ "label": "Need adjustments", "description": "Use Other to describe what to change" }
|
|
283
271
|
]
|
|
284
272
|
}]
|
|
285
273
|
}
|
|
286
274
|
```
|
|
287
275
|
|
|
288
|
-
- **"
|
|
289
|
-
- **"
|
|
276
|
+
- **"Confirm"** → proceed to DDD generation
|
|
277
|
+
- **"Need adjustments" / Other** → update blueprint and repeat 2-DDD.3
|
|
290
278
|
|
|
291
279
|
---
|
|
292
280
|
|
|
293
|
-
##
|
|
281
|
+
## Artifact Generation
|
|
294
282
|
|
|
295
|
-
|
|
283
|
+
With schema validated (Checkpoint 1) and blueprint confirmed (Checkpoint 2):
|
|
296
284
|
|
|
297
|
-
###
|
|
285
|
+
### Generate spec.md
|
|
298
286
|
|
|
299
|
-
>
|
|
287
|
+
> Detailed structure: `references/spec-authoring-guide.md`
|
|
300
288
|
|
|
301
|
-
|
|
302
|
-
- Overview, Functional Requirements (FR001...)
|
|
289
|
+
Read the spec-authoring-guide first, then create `.morph/features/$ARGUMENTS/1-design/spec.md` with:
|
|
290
|
+
- Overview, Functional Requirements (FR001...) with measurable acceptance criteria
|
|
303
291
|
- Non-Functional Requirements, Data Model
|
|
304
|
-
- **VSA:**
|
|
305
|
-
- **DDD:**
|
|
306
|
-
- Infrastructure Requirements (
|
|
292
|
+
- **VSA:** section `## Architecture Style: Vertical Slice` with slices and operations
|
|
293
|
+
- **DDD:** section `## Domain Complexity` with level (1/2/3) and justification
|
|
294
|
+
- Infrastructure Requirements (if applicable)
|
|
307
295
|
|
|
308
|
-
###
|
|
296
|
+
### Generate contracts — VSA
|
|
309
297
|
|
|
310
|
-
**
|
|
298
|
+
**Mandatory source:** fields from `schema-analysis.md` + operations from the VSA Blueprint.
|
|
311
299
|
|
|
312
300
|
```bash
|
|
313
301
|
npx morph-spec template render \
|
|
@@ -321,21 +309,21 @@ npx morph-spec template render \
|
|
|
321
309
|
}'
|
|
322
310
|
```
|
|
323
311
|
|
|
324
|
-
|
|
312
|
+
After rendering, fill in the `// placeholder:` sections with real fields from schema-analysis.md.
|
|
325
313
|
|
|
326
|
-
**
|
|
327
|
-
- `sealed`
|
|
328
|
-
- `Guid.CreateVersion7()`
|
|
329
|
-
- `result.Match()`
|
|
330
|
-
- `{Entity}Errors`
|
|
331
|
-
- CancellationToken
|
|
314
|
+
**Mandatory VSA patterns:**
|
|
315
|
+
- `sealed` on handlers, endpoints, validators, records
|
|
316
|
+
- `Guid.CreateVersion7()` for IDs
|
|
317
|
+
- `result.Match()` in endpoints
|
|
318
|
+
- `{Entity}Errors` static shared across all slices
|
|
319
|
+
- CancellationToken in all async methods
|
|
332
320
|
|
|
333
|
-
###
|
|
321
|
+
### Generate contracts — DDD
|
|
334
322
|
|
|
335
|
-
**
|
|
323
|
+
**Mandatory source:** fields from `schema-analysis.md` + components from the DDD Blueprint.
|
|
336
324
|
|
|
337
325
|
```bash
|
|
338
|
-
#
|
|
326
|
+
# Replace {N} with the detected level (1, 2, or 3):
|
|
339
327
|
npx morph-spec template render \
|
|
340
328
|
dotnet-contracts-level{N} \
|
|
341
329
|
.morph/features/$ARGUMENTS/1-design/contracts.cs \
|
|
@@ -346,14 +334,18 @@ npx morph-spec template render \
|
|
|
346
334
|
}'
|
|
347
335
|
```
|
|
348
336
|
|
|
349
|
-
|
|
337
|
+
After rendering, fill in the `// placeholder:` sections with real fields from schema-analysis.md.
|
|
338
|
+
|
|
339
|
+
**Mandatory DDD patterns:**
|
|
340
|
+
- Level 1: repository interfaces + service with mapped methods
|
|
341
|
+
- Level 2: AggregateRoot with invariants + immutable Value Objects + Domain Events
|
|
342
|
+
- Level 3: adds Integration Events + Bounded Context boundary
|
|
343
|
+
|
|
344
|
+
### Stack adaptation for contracts
|
|
350
345
|
|
|
351
|
-
|
|
352
|
-
- Nível 1: interfaces de repositório + service com métodos mapeados
|
|
353
|
-
- Nível 2: AggregateRoot com invariantes + Value Objects imutáveis + Domain Events
|
|
354
|
-
- Nível 3: adiciona Integration Events + Bounded Context boundary
|
|
346
|
+
For TypeScript/Next.js projects, generate `contracts.ts` instead of `contracts.cs`. Use TypeScript interfaces with the same DDD/VSA patterns adapted to the language (e.g., `readonly` fields for Value Objects, union types for status enums, typed event interfaces for Domain Events).
|
|
355
347
|
|
|
356
|
-
###
|
|
348
|
+
### Generate decisions.md
|
|
357
349
|
|
|
358
350
|
```bash
|
|
359
351
|
npx morph-spec template render docs/decisions \
|
|
@@ -361,83 +353,83 @@ npx morph-spec template render docs/decisions \
|
|
|
361
353
|
'{"FEATURE_NAME": "$ARGUMENTS", "DATE": "{{TODAY}}", "decisions": []}'
|
|
362
354
|
```
|
|
363
355
|
|
|
364
|
-
ADRs
|
|
356
|
+
Mandatory ADRs: architecture choice (VSA vs DDD + justification), UI library (if UI/UX phase ran), external integrations, Azure resources with cost estimates.
|
|
365
357
|
|
|
366
358
|
---
|
|
367
359
|
|
|
368
|
-
##
|
|
360
|
+
## Quality Scoring System
|
|
369
361
|
|
|
370
|
-
|
|
362
|
+
After generating artifacts, evaluate the design with the **Quality Score (0–100)**:
|
|
371
363
|
|
|
372
|
-
|
|
|
373
|
-
|
|
374
|
-
| **
|
|
375
|
-
| **
|
|
376
|
-
| **Blueprint
|
|
377
|
-
| **
|
|
378
|
-
| **Infra /
|
|
364
|
+
| Dimension | Pts | Maximum score criteria |
|
|
365
|
+
|-----------|-----|----------------------|
|
|
366
|
+
| **Schema fidelity** | 25 | All fields in contracts have traceable origin in schema-analysis.md — zero guessed |
|
|
367
|
+
| **Functional coverage** | 20 | All FRs from the proposal are in spec with measurable acceptance criteria |
|
|
368
|
+
| **Blueprint complete** | 20 | **VSA:** all slices have handler, validator (except GetAll), endpoint and errors \| **DDD:** all entities/aggregates/services have components for the detected level |
|
|
369
|
+
| **External integrations** | 20 | APIs/services with payload, error format and retry policy documented |
|
|
370
|
+
| **Infra / costs** | 15 | Azure resources estimated with cost, or "N/A" explicitly documented |
|
|
379
371
|
|
|
380
372
|
**Thresholds:**
|
|
381
373
|
|
|
382
|
-
| Score |
|
|
383
|
-
|
|
384
|
-
| ≥ 85 | Design
|
|
385
|
-
| 70–84 |
|
|
386
|
-
| < 70 |
|
|
374
|
+
| Score | Action |
|
|
375
|
+
|-------|--------|
|
|
376
|
+
| ≥ 85 | Design satisfactory. Offer to close or optionally refine |
|
|
377
|
+
| 70–84 | Continue. Focus on the weakest dimensions |
|
|
378
|
+
| < 70 | Continue. Open technical questions block implementation |
|
|
387
379
|
|
|
388
380
|
---
|
|
389
381
|
|
|
390
|
-
## Loop
|
|
382
|
+
## Quality Loop
|
|
391
383
|
|
|
392
|
-
**
|
|
384
|
+
**Repeat until: score ≥ 85 OR user approves.**
|
|
393
385
|
|
|
394
|
-
### A.
|
|
386
|
+
### A. Calculate score
|
|
395
387
|
|
|
396
|
-
|
|
388
|
+
Score each dimension based on the generated artifacts. Identify the most impactful gaps.
|
|
397
389
|
|
|
398
|
-
### B.
|
|
390
|
+
### B. Identify open questions
|
|
399
391
|
|
|
400
|
-
|
|
392
|
+
Typical questions by dimension:
|
|
401
393
|
|
|
402
|
-
|
|
|
403
|
-
|
|
404
|
-
| Schema fidelity | "
|
|
405
|
-
|
|
|
406
|
-
| Blueprint VSA | "
|
|
407
|
-
| Blueprint DDD | "
|
|
408
|
-
|
|
|
409
|
-
| Infra/
|
|
394
|
+
| Weak dimension | Example questions |
|
|
395
|
+
|----------------|-------------------|
|
|
396
|
+
| Schema fidelity | "The `metadata` field (JSONB) — what is its structure? Which keys?" |
|
|
397
|
+
| Functional coverage | "FR003 says 'notify user' — by email, push, or both?" |
|
|
398
|
+
| Blueprint VSA | "Should the CreateOrder slice trigger an email job or is it synchronous?" |
|
|
399
|
+
| Blueprint DDD | "Should `Place()` on OrderAggregate emit `OrderPlacedEvent`?" |
|
|
400
|
+
| Integrations | "Does the payment API use webhook or polling to confirm?" |
|
|
401
|
+
| Infra/costs | "Does this feature need Azure storage? Which tier?" |
|
|
410
402
|
|
|
411
|
-
### C.
|
|
403
|
+
### C. Ask via AskUserQuestion
|
|
412
404
|
|
|
413
|
-
|
|
405
|
+
Maximum 3 technical questions per call. In the last call of each round, always include:
|
|
414
406
|
|
|
415
407
|
```json
|
|
416
408
|
{
|
|
417
|
-
"header": "
|
|
418
|
-
"question": "
|
|
409
|
+
"header": "Continue?",
|
|
410
|
+
"question": "Continue refining or finalize the design?",
|
|
419
411
|
"multiSelect": false,
|
|
420
412
|
"options": [
|
|
421
|
-
{ "label": "
|
|
422
|
-
{ "label": "
|
|
413
|
+
{ "label": "Continue refining", "description": "More open questions identified" },
|
|
414
|
+
{ "label": "Finalize design", "description": "Proceed to Clarify with current design" }
|
|
423
415
|
]
|
|
424
416
|
}
|
|
425
417
|
```
|
|
426
418
|
|
|
427
|
-
>
|
|
419
|
+
> If score ≥ 85, adjust: `"Continue (optional)"` with description `"Score {N}/100 — design is satisfactory"`
|
|
428
420
|
|
|
429
|
-
### D.
|
|
421
|
+
### D. Incorporate answers
|
|
430
422
|
|
|
431
|
-
|
|
423
|
+
Update spec.md, contracts, and decisions.md with the answers received. Recalculate the score.
|
|
432
424
|
|
|
433
|
-
### E.
|
|
425
|
+
### E. Exit condition
|
|
434
426
|
|
|
435
|
-
-
|
|
436
|
-
- Score ≥ 85
|
|
427
|
+
- User chose **"Finalize design"** → exit loop
|
|
428
|
+
- Score ≥ 85 AND no new questions → exit loop
|
|
437
429
|
|
|
438
430
|
---
|
|
439
431
|
|
|
440
|
-
##
|
|
432
|
+
## Post-Loop: Update State
|
|
441
433
|
|
|
442
434
|
```bash
|
|
443
435
|
npx morph-spec state mark-output $ARGUMENTS schema-analysis
|
|
@@ -446,56 +438,56 @@ npx morph-spec state mark-output $ARGUMENTS contracts
|
|
|
446
438
|
npx morph-spec state mark-output $ARGUMENTS decisions
|
|
447
439
|
```
|
|
448
440
|
|
|
449
|
-
|
|
441
|
+
If Azure costs were estimated:
|
|
450
442
|
```bash
|
|
451
443
|
npx morph-spec state set $ARGUMENTS costs.estimated {X.XX}
|
|
452
444
|
```
|
|
453
445
|
|
|
454
|
-
##
|
|
446
|
+
## MANDATORY PAUSE
|
|
455
447
|
|
|
456
448
|
```json
|
|
457
449
|
{
|
|
458
450
|
"questions": [{
|
|
459
|
-
"header": "
|
|
460
|
-
"question": "Design
|
|
451
|
+
"header": "Approval",
|
|
452
|
+
"question": "Design generated. Approve to continue to Clarify?",
|
|
461
453
|
"multiSelect": false,
|
|
462
454
|
"options": [
|
|
463
|
-
{ "label": "
|
|
464
|
-
{ "label": "
|
|
455
|
+
{ "label": "Approve and continue", "description": "Advance to Clarify phase" },
|
|
456
|
+
{ "label": "I have feedback", "description": "Describe what to change (Other)" }
|
|
465
457
|
]
|
|
466
458
|
}]
|
|
467
459
|
}
|
|
468
460
|
```
|
|
469
461
|
|
|
470
|
-
- **"
|
|
462
|
+
- **"Approve and continue"** →
|
|
471
463
|
```bash
|
|
472
464
|
npx morph-spec approve $ARGUMENTS design
|
|
473
465
|
npx morph-spec phase advance $ARGUMENTS
|
|
474
466
|
```
|
|
475
|
-
- **"
|
|
467
|
+
- **"I have feedback" / Other** → apply feedback and repeat PAUSE
|
|
476
468
|
|
|
477
|
-
## Outputs
|
|
469
|
+
## Generated Outputs
|
|
478
470
|
|
|
479
|
-
- `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` —
|
|
480
|
-
- `.morph/features/$ARGUMENTS/1-design/spec.md` —
|
|
481
|
-
- `.morph/features/$ARGUMENTS/1-design/contracts.cs` — Contracts
|
|
482
|
-
- `.morph/features/$ARGUMENTS/1-design/decisions.md` — ADRs
|
|
471
|
+
- `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` — Real schema mapped and validated
|
|
472
|
+
- `.morph/features/$ARGUMENTS/1-design/spec.md` — Complete technical specification
|
|
473
|
+
- `.morph/features/$ARGUMENTS/1-design/contracts.cs` (or `.ts` for TypeScript projects) — Contracts based on real schema (VSA or DDD)
|
|
474
|
+
- `.morph/features/$ARGUMENTS/1-design/decisions.md` — Documented ADRs
|
|
483
475
|
|
|
484
|
-
##
|
|
476
|
+
## Advancement Criteria
|
|
485
477
|
|
|
486
|
-
- [x]
|
|
487
|
-
- [x] Schema
|
|
488
|
-
- [x] Blueprint
|
|
489
|
-
- [x]
|
|
490
|
-
- [x]
|
|
491
|
-
- [x] State
|
|
492
|
-
- [x]
|
|
478
|
+
- [x] Architecture style detected from `config.architecture.style`
|
|
479
|
+
- [x] Schema validated by user (Checkpoint 1)
|
|
480
|
+
- [x] Blueprint confirmed by user (Checkpoint 2-VSA or 2-DDD)
|
|
481
|
+
- [x] Quality score ≥ 85 OR user finalized
|
|
482
|
+
- [x] All field names in contracts traceable to schema-analysis.md
|
|
483
|
+
- [x] State updated
|
|
484
|
+
- [x] User approved at MANDATORY PAUSE
|
|
493
485
|
|
|
494
486
|
---
|
|
495
487
|
|
|
496
488
|
<!-- morph:outputs:design -->
|
|
497
|
-
| Output |
|
|
498
|
-
|
|
489
|
+
| Output | Path |
|
|
490
|
+
|--------|------|
|
|
499
491
|
| `schemaAnalysis` | `.morph/features/{feature}/1-design/schema-analysis.md` |
|
|
500
492
|
| `spec` | `.morph/features/{feature}/1-design/spec.md` |
|
|
501
493
|
| `contracts` | `.morph/features/{feature}/1-design/contracts.cs` |
|
|
@@ -504,4 +496,4 @@ npx morph-spec state set $ARGUMENTS costs.estimated {X.XX}
|
|
|
504
496
|
| `decisions` | `.morph/features/{feature}/1-design/decisions.md` |
|
|
505
497
|
<!-- /morph:outputs -->
|
|
506
498
|
|
|
507
|
-
|
|
499
|
+
Continue automatically to Phase 3 (Clarify) after approval.
|