@polymorphism-tech/morph-spec 4.10.0 → 4.10.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 (71) hide show
  1. package/README.md +2 -2
  2. package/claude-plugin.json +1 -1
  3. package/docs/CHEATSHEET.md +1 -1
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/CLAUDE.md +5 -69
  6. package/framework/agents/backend/api-designer.md +3 -0
  7. package/framework/agents/backend/dotnet-senior.md +3 -0
  8. package/framework/agents/backend/ef-modeler.md +2 -0
  9. package/framework/agents/backend/hangfire-orchestrator.md +2 -0
  10. package/framework/agents/backend/ms-agent-expert.md +2 -0
  11. package/framework/agents/frontend/blazor-builder.md +2 -0
  12. package/framework/agents/frontend/nextjs-expert.md +2 -0
  13. package/framework/agents/infrastructure/azure-architect.md +2 -0
  14. package/framework/agents/infrastructure/azure-deploy-specialist.md +2 -0
  15. package/framework/agents/infrastructure/bicep-architect.md +2 -0
  16. package/framework/agents/infrastructure/container-specialist.md +2 -0
  17. package/framework/agents/infrastructure/devops-engineer.md +3 -0
  18. package/framework/agents/infrastructure/infra-architect.md +3 -0
  19. package/framework/agents/integrations/asaas-financial.md +2 -0
  20. package/framework/agents/integrations/azure-identity.md +2 -0
  21. package/framework/agents/integrations/clerk-auth.md +3 -0
  22. package/framework/agents/integrations/hangfire-integration.md +2 -0
  23. package/framework/agents/integrations/resend-email.md +2 -0
  24. package/framework/commands/morph-apply.md +151 -161
  25. package/framework/commands/morph-archive.md +28 -28
  26. package/framework/commands/morph-infra.md +79 -79
  27. package/framework/commands/morph-preflight.md +92 -56
  28. package/framework/commands/morph-proposal.md +94 -70
  29. package/framework/commands/morph-status.md +31 -31
  30. package/framework/commands/morph-troubleshoot.md +63 -60
  31. package/framework/rules/csharp-standards.md +3 -0
  32. package/framework/rules/frontend-standards.md +2 -0
  33. package/framework/rules/infrastructure-standards.md +3 -0
  34. package/framework/rules/morph-workflow.md +57 -2
  35. package/framework/rules/nextjs-standards.md +2 -0
  36. package/framework/rules/testing-standards.md +3 -0
  37. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +54 -49
  38. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +42 -19
  39. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +8 -5
  40. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +7 -5
  41. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +139 -136
  42. package/framework/skills/level-0-meta/morph-init/SKILL.md +42 -13
  43. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +130 -130
  44. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +95 -87
  45. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +24 -0
  46. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +42 -41
  47. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +22 -11
  48. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +123 -114
  49. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +120 -102
  50. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +206 -214
  51. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
  52. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +241 -360
  53. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +107 -115
  54. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +135 -135
  55. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
  56. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +143 -139
  57. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +168 -165
  58. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +57 -8
  59. package/package.json +3 -3
  60. package/src/commands/project/doctor.js +7 -2
  61. package/src/commands/project/update.js +4 -4
  62. package/src/lib/stack-filter.js +58 -0
  63. package/src/scripts/setup-infra.js +53 -18
  64. package/src/utils/agents-installer.js +19 -5
  65. package/src/utils/claude-md-injector.js +90 -0
  66. package/src/utils/hooks-installer.js +1 -4
  67. package/src/utils/skills-installer.js +67 -7
  68. package/CLAUDE.md +0 -98
  69. package/framework/memory/patterns-learned.md +0 -766
  70. package/framework/skills/level-0-meta/morph-terminal-title/SKILL.md +0 -61
  71. 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.0"
6
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
7
+ cliVersion: "4.10.1"
8
8
  ---
9
9
 
10
- # MORPH Design - FASE 2
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
- Design técnico interativo: schema primeiro, blueprint validado, artefatos gerados com loop de qualidade.
14
+ Schema-first interactive design: read the real schema, validate with user, generate blueprint, produce artifacts through a quality loop.
15
15
 
16
- ## Pré-requisitos
16
+ ## Prerequisites
17
17
 
18
- - [ ] FASE 1 (Setup) concluída
19
- - [ ] FASE 1.5 (UI/UX) concluída OU pulada
20
- - [ ] Proposta aprovada pelo usuário
18
+ - [ ] Phase 1 (Setup) completed
19
+ - [ ] Phase 1.5 (UI/UX) completed OR skipped
20
+ - [ ] Proposal approved by the user
21
21
 
22
- ## Ferramentas Recomendadas
22
+ ## Recommended Tools
23
23
 
24
- > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` para guia completo.
25
- > **Example:** `references/spec-example.md` — filled-in spec.md showing expected output quality.
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
- | Ação | Ferramenta | Alternativa |
28
- |------|------------|-------------|
29
- | Ler proposal + UI specs | **Read** output files | — |
30
- | **Detectar arquitetura** | **Bash** `cat .morph/config/config.json \| grep -A3 '"architecture"'` | **Read** config.json |
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: políticas RLS | **Supabase MCP** `query()` com `pg_policies` | **Read** policy files |
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** para cada agente ativo do dispatch config | — |
38
- | Research biblioteca | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
39
- | Renderizar contracts VSA | **Bash** `npx morph-spec template render dotnet-contracts-vsa ...` | — |
40
- | Renderizar contracts DDD | **Bash** `npx morph-spec template render dotnet-contracts-level{N} ...` | — |
41
- | Renderizar spec.md | **Bash** `npx morph-spec template render docs/spec ...` | — |
42
- | Renderizar decisions.md | **Bash** `npx morph-spec template render docs/decisions ...` | — |
43
- | Atualizar state | **Bash** `npx morph-spec state mark-output $ARGUMENTS <type>` | — |
44
-
45
- **Anti-padrões:**
46
- - Gerar contratos antes de ler o schema real campos adivinhados corrompem todo o design
47
- - Apresentar Blueprint sem validar com o usuário primeiro
48
- - Perguntas como texto simplessempre use `AskUserQuestion`
49
- - Executar schema analysis e blueprint em sequência são independentes, paralelize
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
- ## ✅ PRÉ-VOO
54
+ ## PRE-FLIGHT
55
55
 
56
- **PASSO 0 (ANTES de qualquer leitura ou escrita) — Garantir fase design:**
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
- Verifique o campo `"phase"` no output:
62
+ Check the `"phase"` field in the output:
63
63
 
64
- **Se `"phase": "design"`** → fase correta, prossiga.
64
+ **If `"phase": "design"`** → phase is correct, proceed.
65
65
 
66
- **Se `"phase": "proposal"`** → execute em sequência:
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
- **Se `"phase": "setup"`** → execute:
71
+ **If `"phase": "setup"`** → execute:
72
72
  1. `npx morph-spec phase advance $ARGUMENTS` (→ design)
73
73
 
74
- **Qualquer outro valor** → não prossigaestado inconsistente, reporte ao usuário.
74
+ **Any other value** → do not proceedinconsistent state, report to user.
75
75
 
76
- > **Regra:** Nunca escreva em `1-design/` enquanto a fase não for `design`. O hook bloqueará e a sequência ficará corrompida.
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
- Leia em paralelo:
80
+ Read in parallel:
81
81
  ```
82
82
  Read: .morph/features/$ARGUMENTS/0-proposal/proposal.md
83
- + Read: .morph/config/config.json ← detectar architecture.style
83
+ + Read: .morph/config/config.json ← detect architecture.style
84
84
  + Read: .morph/context/README.md
85
85
  ```
86
86
 
87
- **Detectar estilo de arquitetura:**
87
+ **Detect architecture style:**
88
88
 
89
- ```bash
90
- cat .morph/config/config.json | grep -A3 '"architecture"'
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
- Crie tasks de sessão:
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 Real (OBRIGATÓRIO antes de qualquer geração)
98
+ ## CHECKPOINT 1 — Real Schema (MANDATORY before any generation)
111
99
 
112
- > **Regra:** Nunca assuma nomes de campos. Todo DTO gerado deve ter origem rastreável no schema.
100
+ > **Rule:** Never assume field names. Every generated DTO must have a traceable origin in the schema.
113
101
 
114
- ### 1.1 Ler schema real
102
+ ### 1.1 Read real schema
115
103
 
116
- Execute em paralelo conforme o stack detectado em `config.json`:
104
+ Execute in parallel according to the stack detected in `config.json`:
117
105
 
118
- **Supabase (preferencial se disponível):**
106
+ **Supabase (preferred if available):**
119
107
  ```
120
- Supabase MCP: list_tables() → get_table_schema(table) para cada tabela relevante
121
- + get_relationships() → políticas RLS se aplicável
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 cada arquivo de entidade
127
- Glob: **/*DbContext.cs → Read para ver DbSet<> e relações
128
- Grep: "DbSet<" → confirmar entidades mapeadas
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 arquivos encontrados
122
+ Grep: "export interface|export type" → Read found files
135
123
  ```
136
124
 
137
- ### 1.2 Gerar schema-analysis.md
125
+ ### 1.2 Generate schema-analysis.md
138
126
 
139
- Escreva `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` com:
127
+ Write `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` with:
140
128
 
141
129
  ```markdown
142
130
  # Schema Analysis — {Feature}
143
131
 
144
- ## Entidades Relevantes
132
+ ## Relevant Entities
145
133
 
146
134
  ### {EntityName}
147
- | Campo | Tipo DB | Tipo C#/TS | Nullable | Notas |
135
+ | Field | DB Type | C#/TS Type | Nullable | Notes |
148
136
  |-------|---------|-----------|----------|-------|
149
137
  | id | uuid | Guid | No | PK |
150
138
  | ... | ... | ... | ... | ... |
151
139
 
152
- ## Relacionamentos
153
- - {Entity A} 1—N {Entity B} via {campo FK}
140
+ ## Relationships
141
+ - {Entity A} 1—N {Entity B} via {FK field}
154
142
 
155
- ## Campos JSONB / Complexos
156
- - {campo}: estrutura interna {chaves conhecidas}
143
+ ## JSONB / Complex Fields
144
+ - {field}: internal structure {known keys}
157
145
 
158
- ## Campos sem uso identificado
159
- - {campo}: presente no schema mas sem referência na proposta
146
+ ## Fields Not Referenced in Proposal
147
+ - {field}: present in schema but no reference in the proposal
160
148
  ```
161
149
 
162
- ### 1.3 Validar com usuário
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": "Encontrei estas entidades e campos no schema. Estão corretos antes de gerar os contratos?",
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": "Confirmar e continuar", "description": "Schema mapeado corretamente" },
174
- { "label": "Tenho correções", "description": "Use Other para descrever o que está errado" }
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
- - **"Confirmar"** → prosseguir para Checkpoint 2
181
- - **"Tenho correções" / Other** → aplicar correções no schema-analysis.md e repetir 1.3
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 de Arquitetura (OBRIGATÓRIO antes de gerar contracts)
173
+ ## CHECKPOINT 2 — Architecture Blueprint (MANDATORY before generating contracts)
186
174
 
187
- > Use o caminho correspondente ao estilo detectado no PRÉ-VOO.
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 o `taskPrompt` do agente `vsa-architect` do resultado. Chame:
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 + conteúdo de proposal.md + schema-analysis.md>)
190
+ Agent(subagent_type=vsa-architect, prompt=<taskPrompt + contents of proposal.md + schema-analysis.md>)
203
191
  ```
204
192
 
205
- O agente produz um VSA Blueprint com:
206
- - Entity fields (baseados no schema validado no Checkpoint 1)
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 por campo
198
+ - Validation rules per field
211
199
 
212
- **Paralelize** com outros agentes ativos do dispatch config.
200
+ **Parallelize** with other active agents from the dispatch config.
213
201
 
214
- #### 2-VSA.2 Validar Blueprint com usuário
202
+ #### 2-VSA.2 Validate Blueprint with user
215
203
 
216
- Apresente o blueprint gerado de forma legível e use `AskUserQuestion`:
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": "Planejei estes slices e operações para a feature. Confirmar antes de gerar spec e contracts?",
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": "Confirmar blueprint", "description": "Gerar spec.md e contracts-vsa.cs com este blueprint" },
226
- { "label": "Preciso ajustar", "description": "Use Other para descrever o que mudar no blueprint" }
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
- - **"Confirmar"** → prosseguir para geração VSA
233
- - **"Preciso ajustar" / Other** → atualizar blueprint e repetir 2-VSA.2
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 Determinar Nível de Complexidade
227
+ #### 2-DDD.1 Determine Complexity Level
240
228
 
241
- Leia a proposta e avalie com base nas 5 perguntas de detecção em `framework/standards/architecture/ddd/complexity-levels.md`:
229
+ Read the proposal and evaluate using the 5 detection questions in `framework/standards/architecture/ddd/complexity-levels.md`:
242
230
 
243
- | Nível | Quando usar |
231
+ | Level | When to use |
244
232
  |-------|-------------|
245
- | **Nível 1 (CRUD)** | Entidades simples, sem regras de negócio complexas, CRUD básico |
246
- | **Nível 2 (Business Logic)** | Invariantes de domínio, workflows de negócio, múltiplas entidades relacionadas |
247
- | **Nível 3 (Bounded Context)** | Isolamento de contexto, eventos de integração, sistemas distribuídos |
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
- > Se incerto, assuma Nível 1 e use `AskUserQuestion` para confirmar.
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 o `taskPrompt` do agente `domain-architect` do resultado. Chame:
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 + conteúdo de proposal.md + schema-analysis.md + nível detectado>)
248
+ Agent(subagent_type=domain-architect, prompt=<taskPrompt + contents of proposal.md + schema-analysis.md + detected level>)
261
249
  ```
262
250
 
263
- O agente produz um Architecture Blueprint com:
264
- - **Nível 1:** Entidades, repositórios, services, DTOs
265
- - **Nível 2:** AggregateRoot, Value Objects, Domain Events, CQRS handlers
266
- - **Nível 3:** BC setup, Integration Events, Anti-corruption layer
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
- **Paralelize** com outros agentes ativos do dispatch config.
256
+ **Parallelize** with other active agents from the dispatch config.
269
257
 
270
- #### 2-DDD.3 Validar Blueprint com usuário
258
+ #### 2-DDD.3 Validate Blueprint with user
271
259
 
272
- Apresente o blueprint gerado de forma legível e use `AskUserQuestion`:
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": "Planejei esta arquitetura de domínio para a feature. Confirmar antes de gerar spec e contracts?",
266
+ "question": "Planned this domain architecture for the feature. Confirm before generating spec and contracts?",
279
267
  "multiSelect": false,
280
268
  "options": [
281
- { "label": "Confirmar blueprint", "description": "Gerar spec.md e contracts-level{N}.cs com este blueprint" },
282
- { "label": "Preciso ajustar", "description": "Use Other para descrever o que mudar no blueprint" }
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
- - **"Confirmar"** → prosseguir para geração DDD
289
- - **"Preciso ajustar" / Other** → atualizar blueprint e repetir 2-DDD.3
276
+ - **"Confirm"** → proceed to DDD generation
277
+ - **"Need adjustments" / Other** → update blueprint and repeat 2-DDD.3
290
278
 
291
279
  ---
292
280
 
293
- ## Geração de Artefatos
281
+ ## Artifact Generation
294
282
 
295
- Com schema validado (Checkpoint 1) e blueprint confirmado (Checkpoint 2):
283
+ With schema validated (Checkpoint 1) and blueprint confirmed (Checkpoint 2):
296
284
 
297
- ### Gerar spec.md
285
+ ### Generate spec.md
298
286
 
299
- > Estrutura detalhada: `references/spec-authoring-guide.md`
287
+ > Detailed structure: `references/spec-authoring-guide.md`
300
288
 
301
- Crie `.morph/features/$ARGUMENTS/1-design/spec.md` com:
302
- - Overview, Functional Requirements (FR001...) com critérios de aceitação mensuráveis
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:** seção `## Architecture Style: Vertical Slice` com slices e operações
305
- - **DDD:** seção `## Domain Complexity` com nível (1/2/3) e justificativa
306
- - Infrastructure Requirements (se aplicável)
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
- ### Gerar contracts.cs — VSA
296
+ ### Generate contracts — VSA
309
297
 
310
- **Fonte obrigatória:** campos do `schema-analysis.md` + operações do VSA Blueprint.
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
- Após renderizar, preencha os `// placeholder:` com os campos reais do schema-analysis.md.
312
+ After rendering, fill in the `// placeholder:` sections with real fields from schema-analysis.md.
325
313
 
326
- **Padrões obrigatórios (VSA):**
327
- - `sealed` em handlers, endpoints, validators, records
328
- - `Guid.CreateVersion7()` para IDs
329
- - `result.Match()` nos endpoints
330
- - `{Entity}Errors` estático compartilhado por todos os slices
331
- - CancellationToken em todos os métodos async
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
- ### Gerar contracts.cs — DDD
321
+ ### Generate contracts — DDD
334
322
 
335
- **Fonte obrigatória:** campos do `schema-analysis.md` + componentes do DDD Blueprint.
323
+ **Mandatory source:** fields from `schema-analysis.md` + components from the DDD Blueprint.
336
324
 
337
325
  ```bash
338
- # Substituir {N} pelo nível detectado (1, 2 ou 3):
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
- Após renderizar, preencha os `// placeholder:` com os campos reais do schema-analysis.md.
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
- **Padrões obrigatórios (DDD):**
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
- ### Gerar decisions.md
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 obrigatórios: escolha de arquitetura (VSA vs DDD + justificativa), biblioteca UI (se UI/UX executou), integrações externas, recursos Azure com estimativa de custos.
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
- ## Sistema de Pontuação de Qualidade
360
+ ## Quality Scoring System
369
361
 
370
- Após gerar os artefatos, avalie o design com o **Quality Score (0–100)**:
362
+ After generating artifacts, evaluate the design with the **Quality Score (0–100)**:
371
363
 
372
- | Dimensão | Pts | Critério de máxima pontuação |
373
- |----------|-----|------------------------------|
374
- | **Fidelidade ao schema** | 25 | Todos os campos em contracts.cs têm origem rastreável no schema-analysis.md — zero adivinhados |
375
- | **Cobertura funcional** | 20 | Todos os FRs da proposta estão no spec com critérios de aceitação mensuráveis |
376
- | **Blueprint completo** | 20 | **VSA:** todos os slices têm handler, validator (exceto GetAll), endpoint e errors \| **DDD:** todas as entidades/aggregates/services têm componentes do nível detectado |
377
- | **Integrações externas** | 20 | APIs/services com payload, error format e retry policy documentados |
378
- | **Infra / custos** | 15 | Azure resources estimados com custo, ou "N/A" explícito documentado |
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 | Ação |
383
- |-------|------|
384
- | ≥ 85 | Design satisfatório. Oferecer encerrar ou refinar opcionalmente |
385
- | 70–84 | Continuar. Focar nas dimensões mais fracas |
386
- | < 70 | Continuar. Questões técnicas abertas bloqueam implementação |
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 de Qualidade
382
+ ## Quality Loop
391
383
 
392
- **Repita até: score ≥ 85 OU usuário aprova.**
384
+ **Repeat until: score ≥ 85 OR user approves.**
393
385
 
394
- ### A. Calcular score
386
+ ### A. Calculate score
395
387
 
396
- Pontue cada dimensão com base nos artefatos gerados. Identifique as lacunas mais impactantes.
388
+ Score each dimension based on the generated artifacts. Identify the most impactful gaps.
397
389
 
398
- ### B. Identificar questões abertas
390
+ ### B. Identify open questions
399
391
 
400
- Perguntas típicas por dimensão:
392
+ Typical questions by dimension:
401
393
 
402
- | Dimensão fraca | Exemplos de questões |
403
- |----------------|----------------------|
404
- | Schema fidelity | "O campo `metadata` (JSONB) tem estrutura definida? Quais chaves?" |
405
- | Cobertura funcional | "FR003 diz 'notificar usuário' — por email, push ou ambos?" |
406
- | Blueprint VSA | "O slice CreateOrder deve disparar um job de email ou é síncrono?" |
407
- | Blueprint DDD | "O método `Place()` do OrderAggregate deve emitir `OrderPlacedEvent`?" |
408
- | Integrações | "A API de pagamento usa webhook ou polling para confirmar?" |
409
- | Infra/custos | "Este feature precisa de storage Azure? Qual tier?" |
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. Perguntar via AskUserQuestion
403
+ ### C. Ask via AskUserQuestion
412
404
 
413
- Máximo 3 questões técnicas por chamada. Na última chamada de cada round, inclua sempre:
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": "Encerrar?",
418
- "question": "Deseja encerrar o design agora ou continuar refinando?",
409
+ "header": "Continue?",
410
+ "question": "Continue refining or finalize the design?",
419
411
  "multiSelect": false,
420
412
  "options": [
421
- { "label": "Continuar refinando", "description": "Claude identificou mais questões abertas" },
422
- { "label": "Encerrar design", "description": "Prosseguir para Clarify com o design atual" }
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
- > Se score ≥ 85, ajuste: `"Continuar (opcional)"` com description `"Score {N}/100 — design está satisfatório"`
419
+ > If score ≥ 85, adjust: `"Continue (optional)"` with description `"Score {N}/100 — design is satisfactory"`
428
420
 
429
- ### D. Incorporar respostas
421
+ ### D. Incorporate answers
430
422
 
431
- Atualize spec.md, contracts.cs e decisions.md com as respostas recebidas. Recalcule o score.
423
+ Update spec.md, contracts, and decisions.md with the answers received. Recalculate the score.
432
424
 
433
- ### E. Condição de saída
425
+ ### E. Exit condition
434
426
 
435
- - Usuário escolheu **"Encerrar design"** → sair do loop
436
- - Score ≥ 85 E sem questões novassair do loop
427
+ - User chose **"Finalize design"** → exit loop
428
+ - Score ≥ 85 AND no new questionsexit loop
437
429
 
438
430
  ---
439
431
 
440
- ## Pós-Loop: Atualizar State
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
- Se houver custos Azure estimados:
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
- ## PAUSA OBRIGATÓRIA
446
+ ## MANDATORY PAUSE
455
447
 
456
448
  ```json
457
449
  {
458
450
  "questions": [{
459
- "header": "Aprovação",
460
- "question": "Design gerado. Aprovar para continuar para Clarify?",
451
+ "header": "Approval",
452
+ "question": "Design generated. Approve to continue to Clarify?",
461
453
  "multiSelect": false,
462
454
  "options": [
463
- { "label": "Aprovar e continuar", "description": "Avançar para fase Clarify" },
464
- { "label": "Tenho feedback", "description": "Digite o que deseja mudar (Other)" }
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
- - **"Aprovar e continuar"** →
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
- - **"Tenho feedback" / Other** → aplicar feedback e repetir PAUSA
467
+ - **"I have feedback" / Other** → apply feedback and repeat PAUSE
476
468
 
477
- ## Outputs Gerados
469
+ ## Generated Outputs
478
470
 
479
- - `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` — Schema real mapeado e validado
480
- - `.morph/features/$ARGUMENTS/1-design/spec.md` — Especificação técnica completa
481
- - `.morph/features/$ARGUMENTS/1-design/contracts.cs` — Contracts baseados no schema real (VSA ou DDD)
482
- - `.morph/features/$ARGUMENTS/1-design/decisions.md` — ADRs documentados
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
- ## Critérios de Avanço
476
+ ## Advancement Criteria
485
477
 
486
- - [x] Estilo de arquitetura detectado em `config.architecture.style`
487
- - [x] Schema validado pelo usuário (Checkpoint 1)
488
- - [x] Blueprint confirmado pelo usuário (Checkpoint 2-VSA ou 2-DDD)
489
- - [x] Score de qualidade ≥ 85 OU usuário encerrou
490
- - [x] Todos os field names em contracts.cs rastreáveis ao schema-analysis.md
491
- - [x] State atualizado
492
- - [x] Usuário aprovou na PAUSA OBRIGATÓRIA
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 | Caminho |
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
- Continuar automaticamente para FASE 3 (Clarify) após aprovação.
499
+ Continue automatically to Phase 3 (Clarify) after approval.