@polymorphism-tech/morph-spec 4.8.7 → 4.8.9

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 (35) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +22 -1
  3. package/bin/task-manager.cjs +120 -16
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/agents.json +1855 -1815
  8. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +141 -23
  9. package/framework/hooks/claude-code/statusline.py +0 -12
  10. package/framework/hooks/claude-code/statusline.sh +6 -2
  11. package/framework/hooks/claude-code/stop/validate-completion.js +70 -23
  12. package/framework/hooks/dev/guard-version-numbers.js +1 -1
  13. package/framework/skills/level-0-meta/morph-init/SKILL.md +44 -6
  14. package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +67 -16
  15. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +1 -1
  16. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +77 -7
  17. package/framework/skills/level-1-workflows/phase-design/SKILL.md +115 -51
  18. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +139 -1
  19. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +29 -6
  20. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +115 -5
  21. package/framework/skills/level-1-workflows/phase-tasks/references/tasks-example.md +173 -0
  22. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +1 -1
  23. package/framework/standards/STANDARDS.json +944 -933
  24. package/framework/standards/architecture/vertical-slice/vertical-slice.md +429 -0
  25. package/framework/templates/REGISTRY.json +1909 -1888
  26. package/framework/templates/code/dotnet/contracts/contracts-vsa.cs +282 -0
  27. package/framework/templates/docs/spec.md +33 -1
  28. package/package.json +1 -1
  29. package/src/commands/agents/dispatch-agents.js +430 -0
  30. package/src/commands/agents/index.js +2 -1
  31. package/src/commands/project/doctor.js +138 -2
  32. package/src/commands/state/state.js +20 -4
  33. package/src/commands/templates/generate-contracts.js +445 -0
  34. package/src/commands/templates/index.js +1 -0
  35. package/src/lib/validators/validation-runner.js +19 -7
@@ -5,7 +5,7 @@ argument-hint: "[feature-name]"
5
5
  disable-model-invocation: true
6
6
  user-invocable: false
7
7
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep
8
- cliVersion: "4.8.7"
8
+ cliVersion: "4.8.9"
9
9
  ---
10
10
 
11
11
  # MORPH Tasks - FASE 4
@@ -40,9 +40,13 @@ Quebre a especificação em tasks executáveis, defina ordem de execução e est
40
40
  **MCPs desta fase:** Context7 (estimar complexidade), GitHub (criar issues).
41
41
 
42
42
  **Anti-padrões:**
43
- - ❌ Task agent para quebrar spec simples (faça diretamente)
44
- - ✅ Task agent para specs complexos com 50+ requisitos (análise legítima multi-step)
43
+ - ❌ Task agent para quebrar spec simples de 1 domínio (faça diretamente)
44
+ - ✅ Task agent para specs multi-domínio (backend + frontend + infra = 3 planners em paralelo)
45
+ - ✅ Task agent quando spec tem 20+ requisitos em múltiplos bounded contexts
45
46
  - ❌ Criar tasks.json sem ler todos os outputs primeiro
47
+ - ❌ **(VSA)** Criar tasks separadas para Handler, Validator e Endpoint — um slice = uma task
48
+ - ❌ **(VSA)** Usar categorias DDD (`domain`, `application`, `infrastructure`) em projetos VSA
49
+ - ❌ **(VSA)** Criar task de "Implementar Service layer" — não existe em VSA
46
50
 
47
51
  ---
48
52
 
@@ -74,7 +78,111 @@ npx morph-spec approval get $ARGUMENTS design
74
78
 
75
79
  ---
76
80
 
77
- ### Passo 0: Ler Nível de Domínio
81
+ ### Passo 0: Detectar Estilo de Arquitetura
82
+
83
+ Antes de tudo, determine se o projeto é VSA ou DDD:
84
+
85
+ ```bash
86
+ cat .morph/config/config.json | grep -A3 '"architecture"'
87
+ ```
88
+
89
+ **Se `config.architecture.style === "vertical-slice"`** → siga o **Passo 0.5 (VSA)** e pule o Passo 0 DDD.
90
+ **Caso contrário** → siga o **Passo 0.6 (DDD)** abaixo.
91
+
92
+ ---
93
+
94
+ ### Passo 0.5: Plano de Tasks — VSA
95
+
96
+ **Ref:** `framework/standards/architecture/vertical-slice/vertical-slice.md`
97
+
98
+ Leia a seção `## Architecture Style: Vertical Slice` do spec.md para o **VSA Blueprint** (entity fields, operações, rotas, validações):
99
+
100
+ ```bash
101
+ grep -A30 "## Architecture Style" ".morph/features/$ARGUMENTS/1-design/spec.md"
102
+ ```
103
+
104
+ **Categorias de tasks VSA** (uma task por slice — Handler + Validator + Endpoint juntos):
105
+
106
+ | Categoria | Descrição | Arquivo(s) |
107
+ |-----------|-----------|------------|
108
+ | **entity** | Entity class + DbSet no ApplicationDbContext | `Entities/{Entity}.cs`, `Database/ApplicationDbContext.cs` |
109
+ | **errors** | `{Entity}Errors` static class com factory methods | `Features/{Entity}Feature/{Entity}Errors.cs` |
110
+ | **tags** | Constante em ApiTags (se tag nova) | `Constants/ApiTags.cs` |
111
+ | **migration** | `dotnet ef migrations add` + `database update` | `Migrations/...` |
112
+ | **slice** | Slice completo: Handler (+ Request + Response records) + Validator + Endpoint | `Features/{Entity}Feature/{Op}/{Op}Handler.cs`, `...Validator.cs`, `...Endpoint.cs` |
113
+ | **tests** | Unit tests dos handlers | `Tests/Features/{Entity}Feature/...` |
114
+ | **docs** | README, Swagger, comentários | — |
115
+
116
+ **Ordem obrigatória (bottom-up VSA):**
117
+
118
+ ```
119
+ T001: Entity + DbContext DbSet
120
+
121
+ T002: {Entity}Errors (factory methods)
122
+
123
+ T003: ApiTags constant (se tag ainda não existe)
124
+
125
+ T004: Migration (Add{Entity} + database update)
126
+
127
+ T005: Slice Create{Entity} ← Handler+Validator+Endpoint = 1 task
128
+ T006: Slice GetAll{Entity}s ← Handler+Endpoint = 1 task (sem Validator)
129
+ T007: Slice Get{Entity}ById ← Handler+Validator+Endpoint = 1 task
130
+ T008: Slice Update{Entity} ← Handler+Validator+Endpoint = 1 task
131
+ T009: Slice Delete{Entity} ← Handler+Validator+Endpoint = 1 task
132
+
133
+ T010+: Slices customizados (operações extra do VSA Blueprint)
134
+
135
+ T0NN: Tests
136
+ ```
137
+
138
+ **Regras VSA para tasks:**
139
+ - 1 task = 1 slice completo (Handler + Validator + Endpoint num único task)
140
+ - `GetAll` NÃO tem Validator — mencionar explicitamente no task
141
+ - Cada task de slice lista os 3 arquivos que devem ser criados no campo `files`
142
+ - Entity task deve incluir a linha `DbSet<{Entity}>` no `ApplicationDbContext`
143
+ - Migration task é separada da entity task (pode rodar em paralelo com errors + tags)
144
+
145
+ **Exemplo de tasks VSA geradas:**
146
+
147
+ ```json
148
+ { "id": "T001", "title": "Criar Entity Book + registrar DbSet no ApplicationDbContext",
149
+ "category": "entity", "dependencies": [], "estimatedMinutes": 20,
150
+ "files": ["Entities/Book.cs", "Database/ApplicationDbContext.cs"] }
151
+
152
+ { "id": "T002", "title": "Criar BookErrors (NotFound + outros factory methods)",
153
+ "category": "errors", "dependencies": ["T001"], "estimatedMinutes": 10,
154
+ "files": ["Features/BookFeature/BookErrors.cs"] }
155
+
156
+ { "id": "T003", "title": "Adicionar ApiTags.Books em Constants/ApiTags.cs",
157
+ "category": "tags", "dependencies": [], "estimatedMinutes": 5,
158
+ "files": ["Constants/ApiTags.cs"] }
159
+
160
+ { "id": "T004", "title": "Criar migration AddBook + aplicar ao banco",
161
+ "category": "migration", "dependencies": ["T001"], "estimatedMinutes": 10,
162
+ "files": ["Migrations/...AddBook.cs"] }
163
+
164
+ { "id": "T005", "title": "Implementar slice CreateBook (Handler + Validator + Endpoint)",
165
+ "category": "slice", "dependencies": ["T001", "T002", "T003", "T004"],
166
+ "estimatedMinutes": 45,
167
+ "files": [
168
+ "Features/BookFeature/CreateBook/CreateBookHandler.cs",
169
+ "Features/BookFeature/CreateBook/CreateBookValidator.cs",
170
+ "Features/BookFeature/CreateBook/CreateBookEndpoint.cs"
171
+ ] }
172
+
173
+ { "id": "T006", "title": "Implementar slice GetAllBooks (Handler + Endpoint, sem Validator)",
174
+ "category": "slice", "dependencies": ["T001", "T004"], "estimatedMinutes": 25,
175
+ "files": [
176
+ "Features/BookFeature/GetAllBooks/GetAllBooksHandler.cs",
177
+ "Features/BookFeature/GetAllBooks/GetAllBooksEndpoint.cs"
178
+ ] }
179
+ ```
180
+
181
+ **Após definir tasks VSA, pule direto para o Passo 3 (Dependências).**
182
+
183
+ ---
184
+
185
+ ### Passo 0.6: Ler Nível de Domínio — DDD
78
186
 
79
187
  **Ref:** `framework/standards/architecture/ddd/complexity-levels.md`
80
188
 
@@ -114,10 +222,12 @@ Use o nível para **restringir** as categorias de tasks às listadas para o nív
114
222
 
115
223
  ### Passo 1: Analisar Spec
116
224
 
225
+ > **VSA:** Se veio do Passo 0.5, o breakdown de tasks já foi definido — use os exemplos gerados como base e pule para o Passo 3 (Dependências).
226
+
117
227
  Leia `.morph/features/$ARGUMENTS/1-design/spec.md` e identifique:
118
228
 
119
229
  1. **Requisitos funcionais** (FR001, FR002, ...)
120
- 2. **Componentes técnicos** (Entities, Services, Controllers, Pages)
230
+ 2. **Componentes técnicos** (Entities, Services/Slices, Controllers/Endpoints, Pages)
121
231
  3. **Infraestrutura** (Bicep, migrations, configs)
122
232
  4. **Testes** (Unit tests, integration tests)
123
233
 
@@ -228,4 +228,177 @@ Integration tests using `WebApplicationFactory` + in-memory SQLite (or TestConta
228
228
 
229
229
  ---
230
230
 
231
+ ---
232
+
233
+ # Tasks - Book CRUD (VSA Example)
234
+
235
+ > Example of tasks.md for a Vertical Slice Architecture (VSA) feature.
236
+ > Key rule: 1 task = 1 complete slice (Handler + Validator + Endpoint together).
237
+ > GetAll slices have no Validator — stated explicitly in the task.
238
+
239
+ | Task ID | Category | Title | Status |
240
+ |---------|----------|-------|--------|
241
+ | T001 | entity | Criar Entity Book + registrar DbSet no ApplicationDbContext | Pending |
242
+ | T002 | errors | Criar BookErrors (NotFound + outros factory methods) | Pending |
243
+ | T003 | tags | Adicionar ApiTags.Books em Constants/ApiTags.cs | Pending |
244
+ | T004 | migration | Criar migration AddBook + aplicar ao banco | Pending |
245
+ | T005 | slice | Implementar slice CreateBook (Handler + Validator + Endpoint) | Pending |
246
+ | T006 | slice | Implementar slice GetAllBooks (Handler + Endpoint, sem Validator) | Pending |
247
+ | T007 | slice | Implementar slice GetBookById (Handler + Validator + Endpoint) | Pending |
248
+ | T008 | slice | Implementar slice UpdateBook (Handler + Validator + Endpoint) | Pending |
249
+ | T009 | slice | Implementar slice DeleteBook (Handler + Validator + Endpoint) | Pending |
250
+
251
+ **Status Values:** `Pending | In Progress | Blocked | Done`
252
+
253
+ ---
254
+
255
+ ## Phase 1: Foundation
256
+
257
+ ### T001: Criar Entity Book + registrar DbSet no ApplicationDbContext
258
+ - **Category:** entity
259
+ - **Estimate:** 20min
260
+ - **Dependencies:** None
261
+
262
+ **Description:**
263
+ Criar a entity `Book` com todos os campos definidos no spec.md. Registrar `DbSet<Book>` no `ApplicationDbContext`. Usar `Guid.CreateVersion7()` para o campo Id — não `Guid.NewGuid()`. Propriedades obrigatórias como `sealed` ou com setters `private init`.
264
+
265
+ **Deliverables:**
266
+ - [ ] Create: `Entities/Book.cs`
267
+ - [ ] Update: `Database/ApplicationDbContext.cs` (add `public DbSet<Book> Books { get; set; } = null!;`)
268
+
269
+ ---
270
+
271
+ ### T002: Criar BookErrors (NotFound + outros factory methods)
272
+ - **Category:** errors
273
+ - **Estimate:** 10min
274
+ - **Dependencies:** T001
275
+
276
+ **Description:**
277
+ Criar a classe `BookErrors` static com factory methods para cada tipo de erro da feature. Cada method retorna um `Error` com code e description. Esses erros são compartilhados por todos os slices da BookFeature.
278
+
279
+ **Deliverables:**
280
+ - [ ] Create: `Features/BookFeature/BookErrors.cs`
281
+
282
+ ---
283
+
284
+ ### T003: Adicionar ApiTags.Books em Constants/ApiTags.cs
285
+ - **Category:** tags
286
+ - **Estimate:** 5min
287
+ - **Dependencies:** None
288
+
289
+ **Description:**
290
+ Adicionar a constante `Books` em `ApiTags` para uso em todos os endpoints da feature. Se a constante já existir, pular esta task.
291
+
292
+ **Deliverables:**
293
+ - [ ] Update: `Constants/ApiTags.cs` (add `public const string Books = "books";`)
294
+
295
+ ---
296
+
297
+ ### T004: Criar migration AddBook + aplicar ao banco
298
+ - **Category:** migration
299
+ - **Estimate:** 10min
300
+ - **Dependencies:** T001
301
+
302
+ **Description:**
303
+ Gerar a migration EF Core para a entity `Book` e aplicar ao banco local. Verificar que a migration foi gerada corretamente antes de aplicar.
304
+
305
+ **Deliverables:**
306
+ - [ ] Run: `dotnet ef migrations add AddBook`
307
+ - [ ] Run: `dotnet ef database update`
308
+ - [ ] Verify: migration applies without errors
309
+
310
+ ---
311
+
312
+ ## Phase 2: Slices
313
+
314
+ ### T005: Implementar slice CreateBook (Handler + Validator + Endpoint)
315
+ - **Category:** slice
316
+ - **Estimate:** 45min
317
+ - **Dependencies:** T001, T002, T003, T004
318
+
319
+ **Description:**
320
+ Implementar o slice completo de criação. O arquivo Handler deve conter os records `CreateBookRequest` e `CreateBookResponse` no mesmo arquivo. O Validator deve herdar de `AbstractValidator<CreateBookRequest>`. O Endpoint deve ser `internal sealed` e usar `result.Match()` — nunca `result.Value` sem checar `IsSuccess`.
321
+
322
+ Handler injeta: `IRepository<Book>` + `IUnitOfWork`.
323
+
324
+ **Deliverables:**
325
+ - [ ] Create: `Features/BookFeature/CreateBook/CreateBookHandler.cs`
326
+ - [ ] Create: `Features/BookFeature/CreateBook/CreateBookValidator.cs`
327
+ - [ ] Create: `Features/BookFeature/CreateBook/CreateBookEndpoint.cs`
328
+
329
+ ---
330
+
331
+ ### T006: Implementar slice GetAllBooks (Handler + Endpoint, sem Validator)
332
+ - **Category:** slice
333
+ - **Estimate:** 25min
334
+ - **Dependencies:** T001, T004
335
+
336
+ **Description:**
337
+ Implementar o slice de listagem. GetAll NÃO tem Validator (sem parâmetros de entrada para validar). Handler injeta apenas `IRepository<Book>` — não precisa de `IUnitOfWork` (read-only).
338
+
339
+ **Deliverables:**
340
+ - [ ] Create: `Features/BookFeature/GetAllBooks/GetAllBooksHandler.cs`
341
+ - [ ] Create: `Features/BookFeature/GetAllBooks/GetAllBooksEndpoint.cs`
342
+
343
+ ---
344
+
345
+ ### T007: Implementar slice GetBookById (Handler + Validator + Endpoint)
346
+ - **Category:** slice
347
+ - **Estimate:** 30min
348
+ - **Dependencies:** T001, T002, T004
349
+
350
+ **Description:**
351
+ Implementar o slice de busca por ID. Validator verifica que o Guid não é empty. Handler retorna `BookErrors.NotFound()` se o livro não existir. Handler injeta apenas `IRepository<Book>`.
352
+
353
+ **Deliverables:**
354
+ - [ ] Create: `Features/BookFeature/GetBookById/GetBookByIdHandler.cs`
355
+ - [ ] Create: `Features/BookFeature/GetBookById/GetBookByIdValidator.cs`
356
+ - [ ] Create: `Features/BookFeature/GetBookById/GetBookByIdEndpoint.cs`
357
+
358
+ ---
359
+
360
+ ### T008: Implementar slice UpdateBook (Handler + Validator + Endpoint)
361
+ - **Category:** slice
362
+ - **Estimate:** 45min
363
+ - **Dependencies:** T001, T002, T003, T004
364
+
365
+ **Description:**
366
+ Implementar o slice de atualização. Handler retorna `BookErrors.NotFound()` se o livro não existir antes de atualizar. Handler injeta: `IRepository<Book>` + `IUnitOfWork`.
367
+
368
+ **Deliverables:**
369
+ - [ ] Create: `Features/BookFeature/UpdateBook/UpdateBookHandler.cs`
370
+ - [ ] Create: `Features/BookFeature/UpdateBook/UpdateBookValidator.cs`
371
+ - [ ] Create: `Features/BookFeature/UpdateBook/UpdateBookEndpoint.cs`
372
+
373
+ ---
374
+
375
+ ### T009: Implementar slice DeleteBook (Handler + Validator + Endpoint)
376
+ - **Category:** slice
377
+ - **Estimate:** 30min
378
+ - **Dependencies:** T001, T002, T003, T004
379
+
380
+ **Description:**
381
+ Implementar o slice de deleção. Handler verifica existência antes de deletar, retorna `BookErrors.NotFound()` se não existir. Handler injeta: `IRepository<Book>` + `IUnitOfWork`.
382
+
383
+ **Deliverables:**
384
+ - [ ] Create: `Features/BookFeature/DeleteBook/DeleteBookHandler.cs`
385
+ - [ ] Create: `Features/BookFeature/DeleteBook/DeleteBookValidator.cs`
386
+ - [ ] Create: `Features/BookFeature/DeleteBook/DeleteBookEndpoint.cs`
387
+
388
+ ---
389
+
390
+ ## Summary
391
+
392
+ | Phase | Tasks | Estimate |
393
+ |-------|-------|----------|
394
+ | Foundation (entity + errors + tags + migration) | T001–T004 | 45min |
395
+ | Slices (Create + GetAll + GetById + Update + Delete) | T005–T009 | 2h55m |
396
+ | **Total** | **9 tasks** | **~3h40m** |
397
+
398
+ > **VSA Note:** No manual DI registration needed — `AddHandlersFromAssembly()`,
399
+ > `RegisterApiEndpointsFromAssembly()`, and `AddValidatorsFromAssembly()` discover
400
+ > all handlers, endpoints and validators automatically via assembly scanning (Scrutor).
401
+
402
+ ---
403
+
231
404
  *MORPH-SPEC by Polymorphism Tech*
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 1.5 (UI/UX). Creates design-system.md, mockups.md,
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep
7
- cliVersion: "4.8.7"
7
+ cliVersion: "4.8.9"
8
8
  ---
9
9
 
10
10
  # MORPH UI/UX Design - FASE 1.5