@polymorphism-tech/morph-spec 4.2.0 → 4.3.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.
- package/CLAUDE.md +108 -946
- package/bin/morph-spec.js +284 -9
- package/bin/task-manager.cjs +102 -14
- package/bin/validate.js +4 -4
- package/docs/{v3.0 → next-generation}/AGENTS.md +1 -1
- package/docs/next-generation/CONTEXT-OPTIMIZATION.md +267 -0
- package/docs/next-generation/EXECUTION-FLOW.md +274 -0
- package/docs/next-generation/META-PROMPTS.md +235 -0
- package/docs/next-generation/MIGRATION-GUIDE.md +253 -0
- package/docs/next-generation/THREAD-MANAGEMENT.md +240 -0
- package/package.json +5 -5
- package/src/commands/agents/agents-fuse.js +97 -0
- package/src/commands/agents/micro-agent.js +112 -0
- package/src/commands/agents/spawn-team.js +69 -4
- package/src/commands/agents/squad-template.js +146 -0
- package/src/commands/analytics/analytics.js +176 -0
- package/src/commands/context/context-prime.js +63 -0
- package/src/commands/context/core-four.js +54 -0
- package/src/commands/mcp/mcp.js +102 -0
- package/src/commands/project/detect-agents.js +32 -2
- package/src/commands/project/detect.js +11 -1
- package/src/commands/project/doctor.js +573 -356
- package/src/commands/project/init.js +9 -2
- package/src/commands/project/update.js +13 -3
- package/src/commands/state/advance-phase.js +448 -416
- package/src/commands/state/state.js +14 -12
- package/src/commands/tasks/task.js +1 -1
- package/src/commands/templates/template-render.js +80 -1
- package/src/commands/threads/thread-template.js +103 -0
- package/src/commands/threads/threads.js +261 -0
- package/src/commands/trust/trust.js +205 -0
- package/src/{orchestrator.js → core/orchestrator.js} +8 -8
- package/src/core/state/state-manager.js +37 -17
- package/src/core/workflows/workflow-detector.js +114 -3
- package/src/lib/agents/micro-agent-factory.js +161 -0
- package/src/lib/analytics/analytics-engine.js +345 -0
- package/src/lib/checkpoints/checkpoint-hooks.js +298 -258
- package/src/lib/context/context-bundler.js +240 -0
- package/src/lib/context/context-optimizer.js +212 -0
- package/src/lib/context/context-tracker.js +273 -0
- package/src/lib/context/core-four-tracker.js +201 -0
- package/src/lib/context/mcp-optimizer.js +200 -0
- package/src/lib/detectors/index.js +1 -1
- package/src/lib/detectors/standards-generator.js +77 -17
- package/src/lib/detectors/structure-detector.js +67 -39
- package/src/lib/execution/fusion-executor.js +304 -0
- package/src/lib/execution/parallel-executor.js +270 -0
- package/src/lib/generators/context-generator.js +3 -3
- package/src/lib/generators/recap-generator.js +32 -12
- package/src/lib/hooks/hook-executor.js +169 -0
- package/src/lib/hooks/stop-hook-executor.js +286 -0
- package/src/lib/hops/hop-composer.js +221 -0
- package/src/lib/threads/thread-coordinator.js +238 -0
- package/src/lib/threads/thread-manager.js +317 -0
- package/src/lib/tracking/artifact-trail.js +202 -0
- package/src/lib/trust/trust-manager.js +269 -0
- package/src/lib/validators/design-system/design-system-validator.js +2 -2
- package/src/lib/validators/validation-runner.js +14 -30
- package/src/utils/hooks-installer.js +69 -0
- package/stacks/blazor-azure/.morph/config/agents.json +72 -3
- package/stacks/nextjs-supabase/.morph/config/agents.json +3 -3
- package/docs/llm-interaction-config.md +0 -735
- package/docs/v3.0/EXECUTION-FLOW.md +0 -1304
- package/src/commands/utils/migrate-state.js +0 -158
- package/src/commands/utils/upgrade.js +0 -346
- package/src/lib/validators/architecture-validator.js +0 -60
- package/src/lib/validators/content-validator.js +0 -164
- package/src/lib/validators/package-validator.js +0 -61
- package/src/lib/validators/ui-contrast-validator.js +0 -44
- package/stacks/blazor-azure/.claude/commands/morph-apply.md +0 -221
- package/stacks/blazor-azure/.claude/commands/morph-archive.md +0 -79
- package/stacks/blazor-azure/.claude/commands/morph-deploy.md +0 -529
- package/stacks/blazor-azure/.claude/commands/morph-infra.md +0 -209
- package/stacks/blazor-azure/.claude/commands/morph-preflight.md +0 -227
- package/stacks/blazor-azure/.claude/commands/morph-proposal.md +0 -122
- package/stacks/blazor-azure/.claude/commands/morph-status.md +0 -86
- package/stacks/blazor-azure/.claude/commands/morph-troubleshoot.md +0 -122
- package/stacks/blazor-azure/.claude/skills/level-0-meta/README.md +0 -7
- package/stacks/blazor-azure/.claude/skills/level-0-meta/code-review.md +0 -226
- package/stacks/blazor-azure/.claude/skills/level-0-meta/morph-checklist.md +0 -117
- package/stacks/blazor-azure/.claude/skills/level-0-meta/simulation-checklist.md +0 -77
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/README.md +0 -7
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/morph-replicate.md +0 -213
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/phase-clarify.md +0 -131
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/phase-design.md +0 -213
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/phase-setup.md +0 -106
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/phase-tasks.md +0 -164
- package/stacks/blazor-azure/.claude/skills/level-1-workflows/phase-uiux.md +0 -169
- package/stacks/blazor-azure/.claude/skills/level-2-domains/README.md +0 -14
- package/stacks/blazor-azure/.claude/skills/level-2-domains/ai-agents/ai-system-architect.md +0 -192
- package/stacks/blazor-azure/.claude/skills/level-2-domains/architecture/po-pm-advisor.md +0 -197
- package/stacks/blazor-azure/.claude/skills/level-2-domains/architecture/prompt-engineer.md +0 -189
- package/stacks/blazor-azure/.claude/skills/level-2-domains/architecture/seo-growth-hacker.md +0 -320
- package/stacks/blazor-azure/.claude/skills/level-2-domains/architecture/standards-architect.md +0 -156
- package/stacks/blazor-azure/.claude/skills/level-2-domains/backend/api-designer.md +0 -59
- package/stacks/blazor-azure/.claude/skills/level-2-domains/backend/dotnet-senior.md +0 -77
- package/stacks/blazor-azure/.claude/skills/level-2-domains/backend/ef-modeler.md +0 -58
- package/stacks/blazor-azure/.claude/skills/level-2-domains/backend/hangfire-orchestrator.md +0 -126
- package/stacks/blazor-azure/.claude/skills/level-2-domains/backend/ms-agent-expert.md +0 -45
- package/stacks/blazor-azure/.claude/skills/level-2-domains/frontend/blazor-builder.md +0 -210
- package/stacks/blazor-azure/.claude/skills/level-2-domains/frontend/nextjs-expert.md +0 -154
- package/stacks/blazor-azure/.claude/skills/level-2-domains/frontend/ui-ux-designer.md +0 -191
- package/stacks/blazor-azure/.claude/skills/level-2-domains/infrastructure/azure-architect.md +0 -142
- package/stacks/blazor-azure/.claude/skills/level-2-domains/infrastructure/azure-deploy-specialist.md +0 -699
- package/stacks/blazor-azure/.claude/skills/level-2-domains/infrastructure/bicep-architect.md +0 -126
- package/stacks/blazor-azure/.claude/skills/level-2-domains/infrastructure/container-specialist.md +0 -131
- package/stacks/blazor-azure/.claude/skills/level-2-domains/infrastructure/devops-engineer.md +0 -119
- package/stacks/blazor-azure/.claude/skills/level-2-domains/integrations/asaas-financial.md +0 -130
- package/stacks/blazor-azure/.claude/skills/level-2-domains/integrations/azure-identity.md +0 -142
- package/stacks/blazor-azure/.claude/skills/level-2-domains/integrations/clerk-auth.md +0 -108
- package/stacks/blazor-azure/.claude/skills/level-2-domains/integrations/hangfire-orchestrator.md +0 -64
- package/stacks/blazor-azure/.claude/skills/level-2-domains/integrations/resend-email.md +0 -119
- package/stacks/blazor-azure/.claude/skills/level-2-domains/quality/code-analyzer.md +0 -235
- package/stacks/blazor-azure/.claude/skills/level-2-domains/quality/testing-specialist.md +0 -126
- package/stacks/blazor-azure/.claude/skills/level-3-technologies/README.md +0 -7
- package/stacks/blazor-azure/.claude/skills/level-4-patterns/README.md +0 -7
- package/stacks/blazor-azure/.morph/archive/.gitkeep +0 -25
- package/stacks/blazor-azure/.morph/features/.gitkeep +0 -25
- package/stacks/blazor-azure/.morph/schemas/agent.schema.json +0 -296
- package/stacks/blazor-azure/.morph/schemas/tasks.schema.json +0 -220
- package/stacks/blazor-azure/.morph/specs/.gitkeep +0 -20
- package/stacks/blazor-azure/.morph/test-infra/example.bicep +0 -59
- package/stacks/nextjs-supabase/.claude/commands/morph-apply.md +0 -221
- package/stacks/nextjs-supabase/.claude/commands/morph-archive.md +0 -79
- package/stacks/nextjs-supabase/.claude/commands/morph-deploy.md +0 -529
- package/stacks/nextjs-supabase/.claude/commands/morph-infra.md +0 -209
- package/stacks/nextjs-supabase/.claude/commands/morph-preflight.md +0 -227
- package/stacks/nextjs-supabase/.claude/commands/morph-proposal.md +0 -122
- package/stacks/nextjs-supabase/.claude/commands/morph-status.md +0 -86
- package/stacks/nextjs-supabase/.claude/commands/morph-troubleshoot.md +0 -122
- package/stacks/nextjs-supabase/.claude/settings.local.json +0 -6
- package/stacks/nextjs-supabase/.claude/skills/level-2-domains/backend/dotnet-supabase.md +0 -244
- package/stacks/nextjs-supabase/.claude/skills/level-2-domains/frontend/nextjs-supabase.md +0 -335
- package/stacks/nextjs-supabase/.claude/skills/level-2-domains/infrastructure/easypanel-deployer.md +0 -189
- package/stacks/nextjs-supabase/.claude/skills/level-2-domains/integrations/supabase-expert.md +0 -50
- /package/docs/{v3.0 → next-generation}/ANALYSIS.md +0 -0
- /package/docs/{v3.0 → next-generation}/ARCHITECTURE.md +0 -0
- /package/docs/{v3.0 → next-generation}/FEATURES.md +0 -0
- /package/docs/{v3.0 → next-generation}/README.md +0 -0
- /package/docs/{v3.0 → next-generation}/ROADMAP.md +0 -0
package/CLAUDE.md
CHANGED
|
@@ -1,993 +1,155 @@
|
|
|
1
|
-
# MORPH-SPEC -
|
|
1
|
+
# MORPH-SPEC - Claude Code Instructions
|
|
2
2
|
|
|
3
3
|
> by Polymorphism Tech
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Spec-driven development system. Specialized agent hub for multi-stack projects with Infrastructure as Code.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## CRITICAL RULES
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
### NEVER:
|
|
12
|
+
- Skip to code without a specification
|
|
13
|
+
- Implement without design approval
|
|
14
|
+
- Ignore standards in `.morph/standards/`
|
|
15
|
+
- Create infrastructure manually
|
|
16
|
+
- Generate code without defined contracts
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## REGRAS CRÍTICAS
|
|
26
|
-
|
|
27
|
-
### NUNCA:
|
|
28
|
-
- Pular direto para código sem especificação
|
|
29
|
-
- Implementar sem aprovação do design
|
|
30
|
-
- Ignorar padrões em `.morph/standards/`
|
|
31
|
-
- Criar recursos de infra manualmente (use IaC)
|
|
32
|
-
- Gerar código sem contracts definidos
|
|
33
|
-
|
|
34
|
-
### SEMPRE:
|
|
35
|
-
- Seguir as 5 fases obrigatórias
|
|
36
|
-
- Gerar outputs em `.morph/features/{feature}/`
|
|
37
|
-
- Documentar decisões em `decisions.md`
|
|
38
|
-
- Checkpoint a cada 3 tasks implementadas
|
|
39
|
-
- Usar Infrastructure as Code
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## WORKFLOW (5 Fases)
|
|
44
|
-
|
|
45
|
-
| Fase | Gatilho | Ações | Output | Pausa? |
|
|
46
|
-
|------|---------|-------|--------|--------|
|
|
47
|
-
| **1. SETUP** | Feature request | Ler project.md, identificar stack, ativar agentes, criar pasta | proposal.md | Não |
|
|
48
|
-
| **2. DESIGN** | Setup concluído | Spec + contracts + decisions + custos + IaC | spec.md, contracts, decisions.md | **Sim** |
|
|
49
|
-
| **3. CLARIFY** | Design aprovado | Ambiguidades, perguntas, edge cases | Spec atualizado | Não |
|
|
50
|
-
| **4. TASKS** | Clarificações resolvidas | Quebrar em tasks, ordem, checkpoints, dependências | tasks.md | **Sim** |
|
|
51
|
-
| **5. IMPLEMENT** | Tasks aprovadas | Task por task, checkpoint a cada 3, recap | Código + recap.md | Não |
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## WORKFLOW DETECTION SYSTEM (Detecção Automática de Complexidade)
|
|
56
|
-
|
|
57
|
-
O framework agora detecta **AUTOMATICAMENTE** o workflow apropriado baseado na análise do pedido do usuário.
|
|
58
|
-
|
|
59
|
-
### 5 Tipos de Workflow
|
|
60
|
-
|
|
61
|
-
| Workflow | Complexidade | Arquivos | Linhas | Keywords Exemplo |
|
|
62
|
-
|----------|--------------|----------|--------|------------------|
|
|
63
|
-
| **fast-track** | Trivial | ≤3 | ≤50 | bug, fix, corrigir, css, typo |
|
|
64
|
-
| **standard** | Média | 3-10 | 50-500 | paginação, filtro, refactor, export |
|
|
65
|
-
| **full-morph** | Alta | >10 | >500 | sistema, autenticação, integração, cqrs |
|
|
66
|
-
| **design-impl** | N/A | N/A | N/A | prototype, figma, html para, replicar |
|
|
67
|
-
| **ui-refresh** | N/A | N/A | N/A | redesign, modernizar, aesthetic, bonito |
|
|
68
|
-
|
|
69
|
-
### Como Funciona
|
|
70
|
-
|
|
71
|
-
**1. Quando Criar Feature:**
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Detecção automática
|
|
75
|
-
npx morph-spec feature create user-pagination \
|
|
76
|
-
--request "add pagination to users table"
|
|
77
|
-
|
|
78
|
-
# Output:
|
|
79
|
-
🔍 Analyzing request...
|
|
80
|
-
✓ Detected workflow: standard (85% confidence)
|
|
81
|
-
Matched keyword: "paginação"
|
|
82
|
-
Estimated: 5 files, ~200 lines
|
|
83
|
-
|
|
84
|
-
📋 Created feature: user-pagination
|
|
85
|
-
Phase: proposal
|
|
86
|
-
Workflow: standard
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**2. Análise Manual (Opcional):**
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npx morph-spec detect-workflow "implement complete authentication system"
|
|
93
|
-
|
|
94
|
-
# Output:
|
|
95
|
-
Detected Workflow: full-morph (92% confidence)
|
|
96
|
-
|
|
97
|
-
Criteria Match:
|
|
98
|
-
✓ Keywords: "authentication", "complete", "system"
|
|
99
|
-
✓ Estimated: 15 files, ~800 lines
|
|
100
|
-
✓ Infrastructure: detected
|
|
101
|
-
|
|
102
|
-
Phases to Run:
|
|
103
|
-
1. CONTEXT
|
|
104
|
-
2. PROPOSAL - ⏸️ Pause for approval
|
|
105
|
-
3. SETUP
|
|
106
|
-
4. UI/UX - ⏸️ Pause for approval
|
|
107
|
-
5. DESIGN - ⏸️ Pause for approval
|
|
108
|
-
6. CLARIFY
|
|
109
|
-
7. TASKS - ⏸️ Pause for approval
|
|
110
|
-
8. IMPLEMENT
|
|
111
|
-
9. SYNC - ⏸️ Pause for approval
|
|
112
|
-
|
|
113
|
-
Phases Skipped: None (all mandatory for full-morph)
|
|
114
|
-
|
|
115
|
-
Alternative Workflows:
|
|
116
|
-
- standard (15%): If scope reduced to basic login only
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Workflow Behaviors
|
|
120
|
-
|
|
121
|
-
#### fast-track (Trivial)
|
|
122
|
-
- **Objetivo:** Correções rápidas, ajustes CSS, edge cases
|
|
123
|
-
- **Fases:** Quick Analysis (proposal+setup+design combinados) → Implement
|
|
124
|
-
- **Fases Puladas:** UIUX, CLARIFY, TASKS, SYNC
|
|
125
|
-
- **Outputs:** Apenas commit message (sem .md files)
|
|
126
|
-
- **Exemplo:** "fix typo in login button"
|
|
127
|
-
|
|
128
|
-
#### standard (Média Complexidade)
|
|
129
|
-
- **Objetivo:** Features simples, refatorações, otimizações
|
|
130
|
-
- **Fases:** PROPOSAL (simplificado) → DESIGN (conciso) → TASKS (se >5 tasks) → IMPLEMENT
|
|
131
|
-
- **Fases Puladas:** SETUP (contexto já carregado), UIUX (sem frontend significativo), CLARIFY (spec claro), SYNC (decisões táticas)
|
|
132
|
-
- **Outputs:** proposal.md, spec.md, recap.md (minimal)
|
|
133
|
-
- **Exemplo:** "add pagination to users table"
|
|
134
|
-
|
|
135
|
-
#### full-morph (Alta Complexidade)
|
|
136
|
-
- **Objetivo:** Sistemas completos, arquitetura, integrações
|
|
137
|
-
- **Fases:** TODAS (9 fases obrigatórias)
|
|
138
|
-
- **Fases Puladas:** Nenhuma
|
|
139
|
-
- **Outputs:** Completo (proposal, ui-*, spec, contracts, tasks, decisions, recap)
|
|
140
|
-
- **Exemplo:** "implement complete authentication system with OAuth"
|
|
141
|
-
|
|
142
|
-
#### design-impl (Prototipo → Código)
|
|
143
|
-
- **Objetivo:** Converter HTML, Figma, mockups para código funcional
|
|
144
|
-
- **Fases:** ANÁLISE DO PROTÓTIPO → TASKS (lista de telas) → IMPLEMENT (por tela)
|
|
145
|
-
- **Fases Puladas:** PROPOSAL, DESIGN técnico, CLARIFY, SYNC
|
|
146
|
-
- **Outputs:** recap.md, .razor code, CSS
|
|
147
|
-
- **Exemplo:** "convert HTML prototype to Blazor components"
|
|
148
|
-
|
|
149
|
-
#### ui-refresh (Redesign Visual)
|
|
150
|
-
- **Objetivo:** Mudanças apenas visuais, sem lógica de negócio
|
|
151
|
-
- **Fases:** ANÁLISE VISUAL → DESIGN SYSTEM (simplificado) → IMPLEMENT (por página)
|
|
152
|
-
- **Fases Puladas:** SETUP completo, CONTRACTS, TASKS detalhadas, INFRA, CLARIFY, SYNC
|
|
153
|
-
- **Outputs:** design-refresh-checklist.md, CSS, .razor pages, recap.md
|
|
154
|
-
- **Exemplo:** "redesign dashboard to look more modern"
|
|
155
|
-
|
|
156
|
-
### Algoritmo de Detecção
|
|
157
|
-
|
|
158
|
-
O sistema usa 4 fatores ponderados:
|
|
159
|
-
|
|
160
|
-
1. **Keywords (40%):** Matching de palavras-chave (PT + EN)
|
|
161
|
-
2. **Complexity (30%):** Estimativa de arquivos/linhas/componentes
|
|
162
|
-
3. **Priority (20%):** Workflows específicos > genéricos
|
|
163
|
-
4. **Context (10%):** Condições especiais (has prototype? existing pages?)
|
|
164
|
-
|
|
165
|
-
**Penalties:**
|
|
166
|
-
- -50% para workflows sem keyword match (exceto full-morph)
|
|
167
|
-
|
|
168
|
-
**Boosts:**
|
|
169
|
-
- +20% para workflows com 3+ keywords matched
|
|
170
|
-
|
|
171
|
-
### Override Manual
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
# Forçar workflow específico
|
|
175
|
-
npx morph-spec state set user-auth workflow full-morph
|
|
176
|
-
|
|
177
|
-
# Re-detectar após mudanças no pedido
|
|
178
|
-
npx morph-spec state detect-workflow user-auth \
|
|
179
|
-
"implement basic login only (no OAuth)"
|
|
180
|
-
|
|
181
|
-
# Output:
|
|
182
|
-
🔄 Re-analyzing request...
|
|
183
|
-
✓ New workflow: standard (78% confidence)
|
|
184
|
-
Previous: full-morph
|
|
185
|
-
Reason: Scope reduced - no OAuth, no registration
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Configurações de Workflow
|
|
189
|
-
|
|
190
|
-
Workflows são definidos em `framework/workflows/configs/*.json`:
|
|
191
|
-
|
|
192
|
-
```json
|
|
193
|
-
{
|
|
194
|
-
"id": "standard",
|
|
195
|
-
"criteria": {
|
|
196
|
-
"minFiles": 3,
|
|
197
|
-
"maxFiles": 10,
|
|
198
|
-
"minLines": 50,
|
|
199
|
-
"maxLines": 500
|
|
200
|
-
},
|
|
201
|
-
"keywords": ["paginação", "pagination", "filtro", "filter"],
|
|
202
|
-
"phases": {
|
|
203
|
-
"run": ["proposal", "design", "tasks", "implement"],
|
|
204
|
-
"skip": ["setup", "uiux", "clarify", "sync"]
|
|
205
|
-
},
|
|
206
|
-
"priority": 2
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Documentação Completa
|
|
211
|
-
|
|
212
|
-
Veja `framework/workflows/` para:
|
|
213
|
-
- **docs/STORY-DRIVEN-DEVELOPMENT.md:** Filosofia do sistema
|
|
214
|
-
- **docs/{workflow}.md:** Detalhes de cada workflow (5 arquivos)
|
|
215
|
-
- **configs/{workflow}.json:** Configurações executáveis (5 arquivos)
|
|
216
|
-
- **README.md:** Guia completo do sistema de workflows
|
|
217
|
-
|
|
218
|
-
**REGRA CRÍTICA:** Confie na detecção automática. Override manual apenas se houver contexto que o sistema não detectou (ex: "parece grande mas já temos 80% do código pronto").
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## APPROVAL GATES (Portões de Aprovação)
|
|
223
|
-
|
|
224
|
-
O sistema agora rastreia aprovações explícitas para cada fase crítica em `state.json`.
|
|
225
|
-
|
|
226
|
-
### Gates Obrigatórios
|
|
227
|
-
|
|
228
|
-
| Gate | Quando | Bloqueio | Comando |
|
|
229
|
-
|------|--------|----------|---------|
|
|
230
|
-
| **design** | Após DESIGN concluído | Impede `design → clarify` | `npx morph-spec approve {feature} design` |
|
|
231
|
-
| **tasks** | Após TASKS concluído | Impede `tasks → implement` | `npx morph-spec approve {feature} tasks` |
|
|
232
|
-
|
|
233
|
-
### Workflow com Approval Gates
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
# 1. Completar fase DESIGN
|
|
237
|
-
# Sistema gera: spec.md, contracts, decisions.md
|
|
238
|
-
|
|
239
|
-
# 2. PAUSAR e apresentar ao usuário
|
|
240
|
-
# Use AskUserQuestion: "Approve design to proceed to clarify phase?"
|
|
241
|
-
|
|
242
|
-
# 3. Se aprovado pelo usuário:
|
|
243
|
-
npx morph-spec approve {feature} design
|
|
244
|
-
|
|
245
|
-
# 4. Avançar fase (agora permitido)
|
|
246
|
-
npx morph-spec advance-phase {feature} clarify
|
|
247
|
-
|
|
248
|
-
# 5. Mesmo processo para TASKS → IMPLEMENT
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
### Comandos de Approval
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
# Aprovar gate
|
|
255
|
-
npx morph-spec approve {feature} {gate}
|
|
256
|
-
|
|
257
|
-
# Rejeitar com motivo
|
|
258
|
-
npx morph-spec reject {feature} {gate} "Reason here"
|
|
259
|
-
|
|
260
|
-
# Ver status de todas as aprovações
|
|
261
|
-
npx morph-spec approval-status {feature}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### Overrides (Usar com Cuidado)
|
|
265
|
-
|
|
266
|
-
```bash
|
|
267
|
-
# Pular verificação de aprovação (não recomendado)
|
|
268
|
-
npx morph-spec advance-phase {feature} {next-phase} --skip-approval
|
|
269
|
-
|
|
270
|
-
# Forçar transição inválida (emergências apenas)
|
|
271
|
-
npx morph-spec advance-phase {feature} {next-phase} --force
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
**REGRA CRÍTICA:** SEMPRE apresente outputs ao usuário e obtenha aprovação explícita antes de avançar de DESIGN ou TASKS.
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## AUTOMATIC CHECKPOINTS (Validação Automática)
|
|
279
|
-
|
|
280
|
-
A cada 3 tasks completadas, o sistema executa validação automática.
|
|
281
|
-
|
|
282
|
-
### O Que é Validado
|
|
283
|
-
|
|
284
|
-
| Validator | O Que Verifica | Falha Bloqueia? |
|
|
285
|
-
|-----------|----------------|-----------------|
|
|
286
|
-
| **architecture** | DI patterns, Blazor lifecycle, async/await | ✅ Sim |
|
|
287
|
-
| **packages** | Conflitos NuGet, versões incompatíveis | ✅ Sim |
|
|
288
|
-
| **design-system** | CSS compliance, color palette, spacing | ⚠️ Warning |
|
|
289
|
-
| **security** | Secrets expostos, SQL injection, XSS | ✅ Sim |
|
|
290
|
-
|
|
291
|
-
### Comportamento no Checkpoint
|
|
292
|
-
|
|
293
|
-
```bash
|
|
294
|
-
# Task 3, 6, 9, 12... completadas
|
|
295
|
-
🔍 Running CHECKPOINT 1...
|
|
296
|
-
✅ Architecture: 0 violations
|
|
297
|
-
✅ Packages: 0 conflicts
|
|
298
|
-
⚠️ Design System: 2 warnings (non-blocking)
|
|
299
|
-
✅ Security: 0 issues
|
|
300
|
-
|
|
301
|
-
✅ Checkpoint 1 passed
|
|
302
|
-
|
|
303
|
-
# Se checkpoint FALHAR:
|
|
304
|
-
❌ Checkpoint 2 failed!
|
|
305
|
-
- Architecture: DbContext injected directly in component
|
|
306
|
-
- Security: API key hardcoded in appsettings.json
|
|
307
|
-
|
|
308
|
-
❌ Task NOT marked done. Fix violations before proceeding.
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Configuração
|
|
312
|
-
|
|
313
|
-
Edite `.morph/config/llm-interaction.json`:
|
|
314
|
-
|
|
315
|
-
```json
|
|
316
|
-
{
|
|
317
|
-
"checkpoints": {
|
|
318
|
-
"frequency": 3,
|
|
319
|
-
"autoValidate": true,
|
|
320
|
-
"validators": {
|
|
321
|
-
"enabled": ["architecture", "packages", "security"]
|
|
322
|
-
},
|
|
323
|
-
"onFailure": {
|
|
324
|
-
"blockProgress": true,
|
|
325
|
-
"maxRetries": 3
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
**IMPORTANTE:** Se checkpoint falha 3 vezes, use `AskUserQuestion` para decidir: simplificar implementação, pular validador (arriscado), ou escalar para troubleshooting-expert.
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## PHASE VALIDATION RULES (Validação Estrita)
|
|
336
|
-
|
|
337
|
-
O sistema agora impede transições de fase inválidas com **state machine**.
|
|
338
|
-
|
|
339
|
-
### Transições Válidas
|
|
340
|
-
|
|
341
|
-
```
|
|
342
|
-
proposal → setup
|
|
343
|
-
setup → uiux | design
|
|
344
|
-
uiux → design
|
|
345
|
-
design → clarify
|
|
346
|
-
clarify → tasks
|
|
347
|
-
tasks → implement
|
|
348
|
-
implement → sync | archived
|
|
349
|
-
sync → archived
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### 5 Gates de Validação
|
|
353
|
-
|
|
354
|
-
Ao avançar fase, o sistema verifica (em ordem):
|
|
355
|
-
|
|
356
|
-
1. **State Machine:** Transição é válida? (`proposal → implement` ❌)
|
|
357
|
-
2. **Approval Gates:** Gate foi aprovado? (`design` ou `tasks` gates)
|
|
358
|
-
3. **Output Requirements:** Arquivos obrigatórios existem? (spec.md, tasks.json)
|
|
359
|
-
4. **Spec Content:** `spec.md` tem todas as seções? (Overview, Requirements, Technical Design, Data Model, API Contracts)
|
|
360
|
-
5. **Tasks Content:** `tasks.json` tem estrutura válida? (IDs, descriptions, dependencies válidas, sem ciclos)
|
|
361
|
-
|
|
362
|
-
### Exemplo de Bloqueio
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
npx morph-spec advance-phase user-auth implement
|
|
366
|
-
|
|
367
|
-
❌ Invalid phase transition: design → implement
|
|
368
|
-
Valid next phases: clarify
|
|
369
|
-
|
|
370
|
-
❌ Approval gate 'design' not approved
|
|
371
|
-
Run: npx morph-spec approve user-auth design
|
|
372
|
-
|
|
373
|
-
❌ Spec validation failed:
|
|
374
|
-
- Missing section: ## Data Model
|
|
375
|
-
- Missing section: ## API Contracts
|
|
376
|
-
|
|
377
|
-
Fix these issues before proceeding.
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
**REGRA:** Nunca pule fases. Se precisa pular (ex: feature simples sem UIUX), documente em `decisions.md` ADR e use `--force`.
|
|
381
|
-
|
|
382
|
-
---
|
|
383
|
-
|
|
384
|
-
## CLAUDE CODE HOOKS (Validação em Hooks)
|
|
385
|
-
|
|
386
|
-
O framework integra com o sistema de hooks do Claude Code para validação automática em eventos Git e Agent Teams.
|
|
387
|
-
|
|
388
|
-
### Arquitetura de Hooks
|
|
389
|
-
|
|
390
|
-
**Universal (framework/hooks/):** Hooks compartilhados por todas as stacks
|
|
391
|
-
- **pre-commit/**: `agents.sh`, `specs.sh`, `orchestrator.sh`
|
|
392
|
-
- **commit-msg/**: `conventional-commits.sh` (Conventional Commits format)
|
|
393
|
-
- **pre-push/**: `run-tests.sh` (executa test suite completo)
|
|
394
|
-
- **agent-teams/**: `teammate-idle.js`, `task-completed.js`, `phase-advanced.js`
|
|
395
|
-
|
|
396
|
-
**Stack-Specific (stacks/{stack}/.morph/hooks/):** Hooks específicos de cada stack
|
|
397
|
-
- **pre-commit/**: `tests-csharp.sh` (blazor-azure), `tests-typescript.sh` (nextjs-supabase)
|
|
398
|
-
|
|
399
|
-
### Instalação de Git Hooks
|
|
400
|
-
|
|
401
|
-
```bash
|
|
402
|
-
# No diretório .git/hooks do projeto
|
|
403
|
-
cd .git/hooks
|
|
404
|
-
|
|
405
|
-
# Pre-commit (valida agents.json, spec.md, executa testes)
|
|
406
|
-
ln -sf ../../framework/hooks/pre-commit/orchestrator.sh pre-commit
|
|
407
|
-
chmod +x pre-commit
|
|
408
|
-
|
|
409
|
-
# Commit-msg (valida formato Conventional Commits)
|
|
410
|
-
ln -sf ../../framework/hooks/commit-msg/conventional-commits.sh commit-msg
|
|
411
|
-
chmod +x commit-msg
|
|
412
|
-
|
|
413
|
-
# Pre-push (executa suite de testes antes de push)
|
|
414
|
-
ln -sf ../../framework/hooks/pre-push/run-tests.sh pre-push
|
|
415
|
-
chmod +x pre-push
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### Configuração de Agent Teams Hooks
|
|
419
|
-
|
|
420
|
-
Adicione em `.claude/settings.local.json`:
|
|
421
|
-
|
|
422
|
-
```json
|
|
423
|
-
{
|
|
424
|
-
"hooks": {
|
|
425
|
-
"TeammateIdle": "node framework/hooks/agent-teams/teammate-idle.js {feature}",
|
|
426
|
-
"TaskCompleted": "node framework/hooks/agent-teams/task-completed.js {feature} {taskId}",
|
|
427
|
-
"PhaseAdvanced": "node framework/hooks/agent-teams/phase-advanced.js {feature} {fromPhase} {toPhase}"
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
```
|
|
431
|
-
|
|
432
|
-
### Validators com Hook Behavior
|
|
433
|
-
|
|
434
|
-
5 validators tier-4 configurados em `agents.json` com `hook_behavior`:
|
|
435
|
-
|
|
436
|
-
| Validator | Hook Triggers | Valida | Bloqueia? |
|
|
437
|
-
|-----------|---------------|--------|-----------|
|
|
438
|
-
| **security-expert** | TeammateIdle, TaskCompleted | SQL injection, XSS, Secrets | ✅ Sim |
|
|
439
|
-
| **architecture-expert** | TeammateIdle, TaskCompleted | DbContext injection, async/await, DI order | ✅ Sim |
|
|
440
|
-
| **packages-validator** | TaskCompleted | NuGet conflicts, .NET 10 compatibility | ✅ Sim |
|
|
441
|
-
| **design-system-validator** | TeammateIdle | CSS palette, spacing, typography | ⚠️ Warning |
|
|
442
|
-
| **blazor-concurrency-validator** | TaskCompleted | DbContext lifecycle, async void, JSInterop | ✅ Sim |
|
|
443
|
-
|
|
444
|
-
### Como Funciona
|
|
445
|
-
|
|
446
|
-
**Git Hooks:**
|
|
447
|
-
```
|
|
448
|
-
git commit → pre-commit hook → orchestrator.sh
|
|
449
|
-
├─ Executa framework/hooks/pre-commit/*.sh (universal)
|
|
450
|
-
└─ Executa .morph/hooks/pre-commit/*.sh (stack-specific)
|
|
451
|
-
↓
|
|
452
|
-
commit-msg hook → valida formato Conventional Commits
|
|
453
|
-
↓
|
|
454
|
-
git push → pre-push hook → executa test suite
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
**Agent Teams Hooks:**
|
|
458
|
-
```
|
|
459
|
-
Teammate idle → TeammateIdle hook
|
|
460
|
-
├─ Carrega agents.json
|
|
461
|
-
├─ Filtra validators com hook_triggers: ["TeammateIdle"]
|
|
462
|
-
├─ Executa validators via hook-executor.js
|
|
463
|
-
└─ Bloqueia se errors > 0 e blocks_on_fail: true
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
### Bypass (Não Recomendado)
|
|
467
|
-
|
|
468
|
-
```bash
|
|
469
|
-
# Pular hooks Git
|
|
470
|
-
git commit --no-verify
|
|
471
|
-
git push --no-verify
|
|
472
|
-
|
|
473
|
-
# Pular validação de task
|
|
474
|
-
npx morph-spec task done feature-name task-id --skip-validation
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
**IMPORTANTE:** Veja `framework/hooks/README.md` para documentação completa de hooks.
|
|
478
|
-
|
|
479
|
-
---
|
|
480
|
-
|
|
481
|
-
## AGENT INVOCATION PATTERNS (Spawning de Agentes)
|
|
482
|
-
|
|
483
|
-
Use **Task tool** para spawnar subagentes quando apropriado.
|
|
484
|
-
|
|
485
|
-
### Quando Spawnar Agentes
|
|
486
|
-
|
|
487
|
-
Spawnar subagentes quando:
|
|
488
|
-
|
|
489
|
-
- **5+ agentes ativos** (conforme state.activeAgents)
|
|
490
|
-
- **Multi-domínio** (backend + frontend + infra)
|
|
491
|
-
- **15+ arquivos** a modificar
|
|
492
|
-
- **Complexidade: high ou critical**
|
|
493
|
-
|
|
494
|
-
### Pattern 1: Squad Leader Spawning
|
|
495
|
-
|
|
496
|
-
```typescript
|
|
497
|
-
// Use Task tool
|
|
498
|
-
{
|
|
499
|
-
subagent_type: "general-purpose",
|
|
500
|
-
description: "Implement backend API layer",
|
|
501
|
-
prompt: `You are the Backend Squad Leader (dotnet-senior)...
|
|
502
|
-
|
|
503
|
-
Your Domain Leaders:
|
|
504
|
-
- ef-modeler: Database/EF Core layer
|
|
505
|
-
- api-designer: REST endpoints + DTOs
|
|
506
|
-
- event-architect: Domain events + Hangfire jobs
|
|
507
|
-
|
|
508
|
-
Your Mission: Implement user authentication API
|
|
509
|
-
|
|
510
|
-
Feature Spec: [Include spec.md summary]
|
|
511
|
-
|
|
512
|
-
Standards:
|
|
513
|
-
- .morph/standards/coding.md
|
|
514
|
-
- .morph/standards/architecture.md
|
|
515
|
-
- .morph/standards/dotnet10-compatibility.md
|
|
516
|
-
|
|
517
|
-
Your Tasks (from tasks.json):
|
|
518
|
-
- T001: Create User entity + DbContext
|
|
519
|
-
- T002: Implement UserService with password hashing
|
|
520
|
-
- T003: Create AuthController with login/register endpoints
|
|
521
|
-
|
|
522
|
-
Deliverables:
|
|
523
|
-
- Entities/User.cs
|
|
524
|
-
- Data/AppDbContext.cs
|
|
525
|
-
- Services/UserService.cs
|
|
526
|
-
- Controllers/AuthController.cs
|
|
527
|
-
- DTOs (LoginRequest, RegisterRequest, AuthResponse)
|
|
528
|
-
- Migrations
|
|
529
|
-
|
|
530
|
-
Constraints:
|
|
531
|
-
- Use IDbContextFactory (not direct DbContext injection)
|
|
532
|
-
- BCrypt for password hashing
|
|
533
|
-
- JWT tokens (not sessions)
|
|
534
|
-
|
|
535
|
-
Report back when complete with file list + any blockers.`
|
|
536
|
-
}
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
### Pattern 2: Get Team Hierarchy Helper
|
|
540
|
-
|
|
541
|
-
```bash
|
|
542
|
-
# Gera configurações prontas para Task tool
|
|
543
|
-
npx morph-spec spawn-team {feature}
|
|
544
|
-
|
|
545
|
-
# Output: JSON configs para cada squadmate
|
|
546
|
-
{
|
|
547
|
-
"teammates": [
|
|
548
|
-
{
|
|
549
|
-
"agent": "dotnet-senior",
|
|
550
|
-
"role": "Backend Squad Leader",
|
|
551
|
-
"taskConfig": { ... }
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
"agent": "ef-modeler",
|
|
555
|
-
"role": "Database Layer",
|
|
556
|
-
"taskConfig": { ... }
|
|
557
|
-
}
|
|
558
|
-
]
|
|
559
|
-
}
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
### Pattern 3: Sequential Handoff
|
|
563
|
-
|
|
564
|
-
```typescript
|
|
565
|
-
// 1. Backend squad gera API contracts
|
|
566
|
-
Task tool → dotnet-senior → generates contracts.cs
|
|
567
|
-
|
|
568
|
-
// 2. AGUARDAR conclusão (não spawnar frontend ainda)
|
|
569
|
-
|
|
570
|
-
// 3. Frontend squad usa contracts no contexto
|
|
571
|
-
Task tool → nextjs-senior → uses contracts.cs for type generation
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
### Agent Context Template
|
|
575
|
-
|
|
576
|
-
Use `.morph/templates/agent-context.md` para gerar contexto consistente:
|
|
577
|
-
|
|
578
|
-
```bash
|
|
579
|
-
node bin/render-template.js agent-context \
|
|
580
|
-
--feature=user-auth \
|
|
581
|
-
--agent=dotnet-senior \
|
|
582
|
-
--output=.morph/temp/agent-context.txt
|
|
583
|
-
```
|
|
584
|
-
|
|
585
|
-
**REGRA:** Sempre inclua spec.md summary, standards relevantes, e tasks específicas no prompt do agente.
|
|
18
|
+
### ALWAYS:
|
|
19
|
+
- Follow the 5 mandatory phases
|
|
20
|
+
- Generate outputs in `.morph/project/outputs/{feature}/`
|
|
21
|
+
- Document decisions in `decisions.md`
|
|
22
|
+
- Checkpoint every 3 implemented tasks
|
|
23
|
+
- Use Infrastructure as Code
|
|
586
24
|
|
|
587
25
|
---
|
|
588
26
|
|
|
589
|
-
##
|
|
590
|
-
|
|
591
|
-
Para features grandes, use `metadata.json` para acesso rápido (reduz uso de tokens em 60-80%).
|
|
592
|
-
|
|
593
|
-
### Quando Usar metadata.json
|
|
594
|
-
|
|
595
|
-
**USE metadata.json para:**
|
|
596
|
-
- Quick status (fase atual, progresso %)
|
|
597
|
-
- Lista de agentes ativos
|
|
598
|
-
- Resumo de decisões (ADRs com links)
|
|
599
|
-
- Histórico de checkpoints
|
|
600
|
-
|
|
601
|
-
**USE arquivos .md completos para:**
|
|
602
|
-
- Spec técnico detalhado
|
|
603
|
-
- User stories completas
|
|
604
|
-
- Diagramas e arquitetura
|
|
605
|
-
|
|
606
|
-
### Estrutura do metadata.json
|
|
607
|
-
|
|
608
|
-
```json
|
|
609
|
-
{
|
|
610
|
-
"version": "1.0.0",
|
|
611
|
-
"feature": "user-authentication",
|
|
612
|
-
"status": "active",
|
|
613
|
-
"phase": "implement",
|
|
614
|
-
|
|
615
|
-
"spec": {
|
|
616
|
-
"id": "user-auth",
|
|
617
|
-
"status": "Approved",
|
|
618
|
-
"complexity": "Medium",
|
|
619
|
-
"summary": {
|
|
620
|
-
"problem": "Users need secure login/register...",
|
|
621
|
-
"solution": "JWT-based auth with BCrypt...",
|
|
622
|
-
"tags": ["security", "authentication", "jwt"]
|
|
623
|
-
},
|
|
624
|
-
"requirements": ["REQ1: JWT tokens", "REQ2: BCrypt hashing"],
|
|
625
|
-
"dataModel": ["User entity", "RefreshToken entity"]
|
|
626
|
-
},
|
|
627
|
-
|
|
628
|
-
"decisions": {
|
|
629
|
-
"decisions": [
|
|
630
|
-
{
|
|
631
|
-
"id": "ADR-001",
|
|
632
|
-
"title": "JWT vs Sessions",
|
|
633
|
-
"summary": "Chose JWT for stateless auth...",
|
|
634
|
-
"fullPath": ".morph/features/user-auth/decisions.md#adr-001"
|
|
635
|
-
}
|
|
636
|
-
]
|
|
637
|
-
},
|
|
638
|
-
|
|
639
|
-
"tasks": {
|
|
640
|
-
"total": 12,
|
|
641
|
-
"completed": 8,
|
|
642
|
-
"progress": "67%"
|
|
643
|
-
},
|
|
644
|
-
|
|
645
|
-
"agents": ["dotnet-senior", "ef-modeler", "api-designer"],
|
|
646
|
-
|
|
647
|
-
"checkpoints": [
|
|
648
|
-
{ "num": 1, "passed": true, "timestamp": "2026-02-14T10:30:00Z" },
|
|
649
|
-
{ "num": 2, "passed": true, "timestamp": "2026-02-14T11:45:00Z" }
|
|
650
|
-
],
|
|
651
|
-
|
|
652
|
-
"quickLinks": {
|
|
653
|
-
"spec": ".morph/features/user-auth/spec.md",
|
|
654
|
-
"tasks": ".morph/features/user-auth/tasks.json",
|
|
655
|
-
"decisions": ".morph/features/user-auth/decisions.md"
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
```
|
|
27
|
+
## WORKFLOW (5 Phases)
|
|
659
28
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
# (Configurado em llm-interaction.json: "updateFrequency": "on_task_done")
|
|
668
|
-
# NOTA: Não há comando manual para gerar metadata - sempre auto-gerado
|
|
669
|
-
```
|
|
670
|
-
|
|
671
|
-
### Configuração
|
|
672
|
-
|
|
673
|
-
```json
|
|
674
|
-
{
|
|
675
|
-
"metadata": {
|
|
676
|
-
"autoGenerate": true,
|
|
677
|
-
"updateFrequency": "on_task_done"
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
```
|
|
29
|
+
| Phase | Trigger | Actions | Output | Pause? |
|
|
30
|
+
|-------|---------|---------|--------|--------|
|
|
31
|
+
| **1. SETUP** | Feature request | Read project context, identify stack, activate agents, create folder | proposal.md | No |
|
|
32
|
+
| **2. DESIGN** | Setup done | Spec + contracts + decisions + costs | spec.md, contracts, decisions.md | **Yes** |
|
|
33
|
+
| **3. CLARIFY** | Design approved | Ambiguities, questions, edge cases | Updated spec | No |
|
|
34
|
+
| **4. TASKS** | Clarifications resolved | Break into tasks, ordering, checkpoints, dependencies | tasks.md | **Yes** |
|
|
35
|
+
| **5. IMPLEMENT** | Tasks approved | Task by task, checkpoint every 3, recap | Code + recap.md | No |
|
|
681
36
|
|
|
682
37
|
---
|
|
683
38
|
|
|
684
|
-
##
|
|
685
|
-
|
|
686
|
-
Capture e reutilize patterns bem-sucedidos em `.morph/memory/patterns-learned.md`.
|
|
687
|
-
|
|
688
|
-
### Antes de Começar Nova Feature
|
|
689
|
-
|
|
690
|
-
```bash
|
|
691
|
-
# Buscar patterns relevantes
|
|
692
|
-
npx morph-spec search-patterns "blazor state"
|
|
693
|
-
npx morph-spec search-patterns "background job"
|
|
694
|
-
npx morph-spec search-patterns "bicep naming"
|
|
695
|
-
|
|
696
|
-
# Output:
|
|
697
|
-
🔍 Found 3 pattern(s) for: "blazor state"
|
|
39
|
+
## PROJECT STRUCTURE
|
|
698
40
|
|
|
699
|
-
1. Blazor DbContext Lifecycle
|
|
700
|
-
Category: Anti-Pattern to Avoid
|
|
701
|
-
Source: Framework standard
|
|
702
|
-
|
|
703
|
-
Problem: Directly injecting DbContext in Blazor components...
|
|
704
|
-
|
|
705
|
-
Correct Approach:
|
|
706
|
-
[Inject] IDbContextFactory<AppDbContext> DbFactory { get; set; }
|
|
707
|
-
...
|
|
708
41
|
```
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
#
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
#
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
42
|
+
project/
|
|
43
|
+
├── CLAUDE.md
|
|
44
|
+
├── .morph/
|
|
45
|
+
│ ├── config/ # config.json, agents.json
|
|
46
|
+
│ ├── standards/ # coding, architecture, stack-specific
|
|
47
|
+
│ ├── templates/ # Output templates
|
|
48
|
+
│ ├── project/
|
|
49
|
+
│ │ ├── context/ # detection-log.md, project.md
|
|
50
|
+
│ │ ├── standards/ # inferred.md, overrides.md
|
|
51
|
+
│ │ └── outputs/{feature}/ # Features in development
|
|
52
|
+
│ │ ├── proposal.md, spec.md, tasks.md
|
|
53
|
+
│ │ ├── contracts, decisions.md, recap.md
|
|
54
|
+
└── .claude/commands/ # Slash commands
|
|
721
55
|
```
|
|
722
56
|
|
|
723
|
-
### Categorias de Patterns
|
|
724
|
-
|
|
725
|
-
| Categoria | Quando Usar |
|
|
726
|
-
|-----------|-------------|
|
|
727
|
-
| `success` | Abordagens comprovadas para replicar |
|
|
728
|
-
| `avoid` | Anti-patterns e erros cometidos |
|
|
729
|
-
| `optimization` | Melhorias de performance |
|
|
730
|
-
| `security` | Best practices de segurança |
|
|
731
|
-
| `convention` | Convenções do projeto (naming, estrutura) |
|
|
732
|
-
| `best-practice` | Práticas gerais recomendadas |
|
|
733
|
-
|
|
734
|
-
### Pattern Library Pré-Seeded
|
|
735
|
-
|
|
736
|
-
O framework já vem com 11 patterns em `.morph/memory/patterns-learned.md`:
|
|
737
|
-
|
|
738
|
-
- Blazor DbContext Lifecycle (anti-pattern)
|
|
739
|
-
- Background Job Retry Strategy (best practice)
|
|
740
|
-
- Azure Bicep Resource Naming (convention)
|
|
741
|
-
- API Versioning Strategy (architecture)
|
|
742
|
-
- EF Core Migration Naming (convention)
|
|
743
|
-
- Blazor DI Registration Order (best practice)
|
|
744
|
-
- Component Parameter Validation (best practice)
|
|
745
|
-
- Async Method Naming (convention)
|
|
746
|
-
- Error Handling Strategy (best practice)
|
|
747
|
-
- Bicep Output Exports (convention)
|
|
748
|
-
- Azure Key Vault Secrets (security)
|
|
749
|
-
|
|
750
|
-
**REGRA:** Sempre busque patterns antes de começar. Capture patterns após completar. Biblioteca cresce com o tempo.
|
|
751
|
-
|
|
752
57
|
---
|
|
753
58
|
|
|
754
|
-
##
|
|
755
|
-
|
|
756
|
-
Use **AskUserQuestion** com templates estruturados em `.morph/templates/decision-prompts.md`.
|
|
757
|
-
|
|
758
|
-
### Quando Usar AskUserQuestion
|
|
759
|
-
|
|
760
|
-
**SEMPRE use para:**
|
|
761
|
-
- Escolhas arquiteturais (múltiplas abordagens válidas)
|
|
762
|
-
- Clarificação de escopo (requisitos ambíguos)
|
|
763
|
-
- Override de validators (checkpoint failures)
|
|
764
|
-
- Pular fases (features simples sem UIUX)
|
|
765
|
-
- Breaking changes (API versioning, migrations)
|
|
766
|
-
|
|
767
|
-
### Pattern 1: Arquitetura Choice
|
|
768
|
-
|
|
769
|
-
```markdown
|
|
770
|
-
I've designed two approaches for "user-authentication":
|
|
771
|
-
|
|
772
|
-
**Option A: JWT with HttpOnly Cookies**
|
|
773
|
-
- Pros: XSS protection, automatic CSRF with SameSite
|
|
774
|
-
- Cons: Harder CORS, mobile app compatibility
|
|
775
|
-
- Cost: +2 tasks (CSRF middleware)
|
|
776
|
-
|
|
777
|
-
**Option B: JWT in Authorization Header**
|
|
778
|
-
- Pros: Simpler CORS, better mobile support
|
|
779
|
-
- Cons: Requires manual XSS protection
|
|
780
|
-
- Cost: +1 task (XSS sanitization)
|
|
781
|
-
|
|
782
|
-
Recommendation: Option A (more secure for web apps)
|
|
783
|
-
|
|
784
|
-
Which approach do you prefer?
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
### Pattern 2: Scope Clarification
|
|
788
|
-
|
|
789
|
-
```markdown
|
|
790
|
-
Analyzing "scheduled-reports" feature. Need clarification:
|
|
791
|
-
|
|
792
|
-
1. **Scope:** Include email delivery or just generation?
|
|
793
|
-
2. **Users:** For admins only or all authenticated users?
|
|
794
|
-
3. **Priority:** Critical (deploy this week) or enhancement (iterate)?
|
|
795
|
-
4. **Format:** PDF only or PDF + Excel + CSV?
|
|
796
|
-
|
|
797
|
-
Please clarify so I can generate accurate spec.
|
|
798
|
-
```
|
|
799
|
-
|
|
800
|
-
### Pattern 3: Validator Override
|
|
801
|
-
|
|
802
|
-
```markdown
|
|
803
|
-
Checkpoint failed 3 times:
|
|
804
|
-
|
|
805
|
-
**Error:** Architecture validator - "DbContext injected directly in ReportsPage.razor"
|
|
806
|
-
|
|
807
|
-
**Attempts:**
|
|
808
|
-
1. Tried refactoring to service layer - still triggered (service was scoped)
|
|
809
|
-
2. Tried IDbContextFactory - validator didn't detect pattern
|
|
810
|
-
3. Re-read architecture.md - our implementation is correct per standard
|
|
811
|
-
|
|
812
|
-
**Options:**
|
|
813
|
-
1. Skip architecture validator for this checkpoint (risky)
|
|
814
|
-
2. Simplify implementation (use in-memory data, no DB)
|
|
815
|
-
3. Escalate to troubleshooting-expert agent
|
|
816
|
-
4. Pause for your guidance
|
|
817
|
-
|
|
818
|
-
What should I do?
|
|
819
|
-
```
|
|
820
|
-
|
|
821
|
-
### Pattern 4: Task Ordering
|
|
822
|
-
|
|
823
|
-
```markdown
|
|
824
|
-
Task dependency conflict detected in "user-auth":
|
|
59
|
+
## AGENTS
|
|
825
60
|
|
|
826
|
-
|
|
827
|
-
- T003 (AuthController) depends on T005 (JWT service)
|
|
828
|
-
- T005 (JWT service) depends on T003 (AuthController contracts)
|
|
61
|
+
### Tier 1 — Orchestrators (Always Active)
|
|
829
62
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
63
|
+
| Agent | Responsibilities |
|
|
64
|
+
|-------|-----------------|
|
|
65
|
+
| **Standards Architect** | Standards, naming, review, cross-cutting concerns |
|
|
66
|
+
| **AI System Architect** | Agent systems, AI integrations, LLM orchestration |
|
|
67
|
+
| **Thread Orchestrator** | Parallel execution, thread management, context optimization |
|
|
833
68
|
|
|
834
|
-
|
|
835
|
-
```
|
|
836
|
-
|
|
837
|
-
### Templates Disponíveis
|
|
69
|
+
### Tier 2 — Domain Leaders
|
|
838
70
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
- Breaking Change Approval
|
|
845
|
-
- Phase Skip Justification
|
|
71
|
+
| Agent | Responsibilities |
|
|
72
|
+
|-------|-----------------|
|
|
73
|
+
| **Tech Lead** | Architecture decisions, code quality, task breakdown |
|
|
74
|
+
| **DevOps Engineer** | CI/CD, deployment pipelines, infrastructure |
|
|
75
|
+
| **QA Lead** | Test strategies, validation, quality gates |
|
|
846
76
|
|
|
847
|
-
|
|
77
|
+
### Tier 3 — Specialists (Activated by keywords)
|
|
848
78
|
|
|
849
|
-
|
|
79
|
+
| Agent | Keywords |
|
|
80
|
+
|-------|---------|
|
|
81
|
+
| **Next.js Expert** | nextjs, react, frontend, app router, pages |
|
|
82
|
+
| **Blazor Builder** | blazor, razor, mudblazor, fluent ui |
|
|
83
|
+
| **API Designer** | api, endpoint, rest, openapi, swagger |
|
|
84
|
+
| **.NET Senior** | dotnet, csharp, minimal api, ef core |
|
|
85
|
+
| **EF Modeler** | entity framework, migrations, dbcontext |
|
|
86
|
+
| **Azure Architect** | azure, container apps, bicep, app service |
|
|
87
|
+
| **Bicep Architect** | bicep, iac, arm template, azure resources |
|
|
88
|
+
| **Azure Deploy Specialist** | deploy, ci/cd, github actions, azure devops |
|
|
89
|
+
| **Container Specialist** | docker, dockerfile, compose, kubernetes |
|
|
90
|
+
| **Supabase Expert** | supabase, postgresql, rls, realtime, pgvector |
|
|
91
|
+
| **Azure Identity** | auth, authentication, entra id, jwt, oauth |
|
|
92
|
+
| **Clerk Auth** | clerk, auth0, authentication, social login |
|
|
93
|
+
| **Asaas Financial** | payment, billing, subscription, asaas |
|
|
94
|
+
| **Resend Email** | email, resend, smtp, notifications |
|
|
95
|
+
| **Hangfire Orchestrator** | background jobs, queue, scheduling, hangfire |
|
|
96
|
+
| **MS Agent Expert** | semantic kernel, microsoft agents, ai pipeline |
|
|
97
|
+
| **UI/UX Designer** | design, ux, wireframe, mockup, figma |
|
|
98
|
+
| **SEO Growth Hacker** | seo, performance, analytics, lighthouse |
|
|
99
|
+
| **PO/PM Advisor** | product, roadmap, requirements, user stories |
|
|
100
|
+
| **Prompt Engineer** | prompts, system prompts, llm, few-shot |
|
|
101
|
+
| **Context Optimizer** | context window, token optimization, chunking |
|
|
102
|
+
| **Vector Search Expert** | vector db, embeddings, semantic search, rag |
|
|
103
|
+
| **Observability Expert** | logging, tracing, metrics, opentelemetry |
|
|
104
|
+
| **Code Analyzer** | refactor, analysis, code review, complexity |
|
|
105
|
+
| **Testing Specialist** | tests, coverage, tdd, bdd, vitest, jest, xunit |
|
|
850
106
|
|
|
851
|
-
|
|
107
|
+
### Tier 4 — Validators
|
|
852
108
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
│ ├── blazor-azure/ # Stack Blazor + Azure
|
|
857
|
-
│ │ ├── CLAUDE.md
|
|
858
|
-
│ │ ├── .morph/{config, standards, templates, examples}
|
|
859
|
-
│ │ └── .claude/{skills, commands}
|
|
860
|
-
│ │
|
|
861
|
-
│ └── nextjs-supabase/ # Stack Next.js + Supabase
|
|
862
|
-
│ ├── CLAUDE.md
|
|
863
|
-
│ ├── .morph/{config, standards, templates, examples}
|
|
864
|
-
│ └── .claude/{skills}
|
|
865
|
-
│
|
|
866
|
-
├── framework/ # Compartilhado entre stacks
|
|
867
|
-
│ └── standards/{13 files} # coding, architecture, blazor-*, css-*
|
|
868
|
-
│
|
|
869
|
-
└── src/ # CLI (morph-spec)
|
|
870
|
-
```
|
|
871
|
-
|
|
872
|
-
---
|
|
873
|
-
|
|
874
|
-
## COMANDOS
|
|
875
|
-
|
|
876
|
-
| Comando | Ação |
|
|
877
|
-
|---------|------|
|
|
878
|
-
| `/morph-proposal {feature}` | Spec pipeline completo (fases 0-4, auto-continuação com pausas) |
|
|
879
|
-
| `/morph-apply {feature}` | Implementar feature (fase 5) |
|
|
880
|
-
| `/morph-status` | Dashboard |
|
|
881
|
-
| `/morph-archive {feature}` | Arquivar feature concluída |
|
|
882
|
-
| `/morph-infra {action}` | Gerenciar infra (Bicep ou Docker) |
|
|
883
|
-
| `/morph-preflight` | Validação pre-deploy |
|
|
884
|
-
| `/morph-troubleshoot {error}` | Troubleshooting de erros |
|
|
109
|
+
| Agent | Responsibilities |
|
|
110
|
+
|-------|-----------------|
|
|
111
|
+
| **Contract Compliance Validator** | Ensures implementation matches spec contracts |
|
|
885
112
|
|
|
886
113
|
---
|
|
887
114
|
|
|
888
115
|
## TEMPLATES
|
|
889
116
|
|
|
890
|
-
>
|
|
891
|
-
|
|
892
|
-
### Overview
|
|
893
|
-
|
|
894
|
-
Templates estão em `framework/templates/` organizados por **tecnologia** (não por stack):
|
|
895
|
-
- `code/dotnet/` - Templates .NET (service, repository, component, etc.)
|
|
896
|
-
- `code/typescript/` - Templates TypeScript (contracts, etc.)
|
|
897
|
-
- `code/sql/` - Templates SQL (Supabase migrations, RLS policies)
|
|
898
|
-
- `infrastructure/azure/` - Bicep templates para Azure
|
|
899
|
-
- `infrastructure/docker/` - Dockerfiles e Docker Compose
|
|
900
|
-
- `integrations/` - Integrações (Asaas, Clerk, Azure Identity)
|
|
901
|
-
- `ui/` - Design systems (CSS, Fluent/Mud themes)
|
|
902
|
-
- `saas/` - Multi-tenant patterns
|
|
903
|
-
|
|
904
|
-
**Por quê tecnologia?** Permite reutilizar templates entre stacks (ex: service.cs funciona para blazor-azure E nextjs-supabase).
|
|
905
|
-
|
|
906
|
-
### CLI Commands
|
|
907
|
-
|
|
908
|
-
```bash
|
|
909
|
-
# Listar todos os templates
|
|
910
|
-
morph-spec template list
|
|
117
|
+
> ALWAYS use `morph-spec template render` to render. NEVER fill placeholders manually.
|
|
911
118
|
|
|
912
|
-
|
|
913
|
-
morph-spec template list --category code
|
|
914
|
-
morph-spec template list --phase implement
|
|
119
|
+
### Placeholders: `{{PLACEHOLDER}}`
|
|
915
120
|
|
|
916
|
-
|
|
917
|
-
morph-spec template show dotnet-backend-service --preview
|
|
918
|
-
|
|
919
|
-
# Renderizar template (usando Handlebars)
|
|
920
|
-
morph-spec template render dotnet-backend-service UserService.cs '{
|
|
921
|
-
"FEATURE_NAME": "user-auth",
|
|
922
|
-
"NAMESPACE": "MyApp.Services"
|
|
923
|
-
}'
|
|
924
|
-
|
|
925
|
-
# Customizar template (criar override stack-specific)
|
|
926
|
-
morph-spec template customize dotnet-backend-service --stack blazor-azure
|
|
927
|
-
```
|
|
928
|
-
|
|
929
|
-
### Handlebars Helpers (v2.0)
|
|
930
|
-
|
|
931
|
-
**✅ USE (novo):**
|
|
932
|
-
|
|
933
|
-
| Helper | Input | Output | Uso |
|
|
934
|
-
|--------|-------|--------|-----|
|
|
935
|
-
| `{{pascalCase str}}` | `user-auth` | `UserAuth` | Classes |
|
|
936
|
-
| `{{camelCase str}}` | `user-auth` | `userAuth` | Variables |
|
|
937
|
-
| `{{snakeCase str}}` | `user-auth` | `user_auth` | SQL |
|
|
938
|
-
| `{{titleCase str}}` | `user-auth` | `User Auth` | Titles |
|
|
939
|
-
| `{{pluralize str}}` | `user` | `users` | Collections |
|
|
940
|
-
|
|
941
|
-
**❌ DEPRECADO (v1.0):**
|
|
942
|
-
|
|
943
|
-
| Placeholder | Status | Use Instead |
|
|
944
|
-
|-------------|--------|-------------|
|
|
945
|
-
| `{{FEATURE_NAME_PASCAL}}` | ❌ Deprecated | `{{pascalCase FEATURE_NAME}}` |
|
|
946
|
-
| `{{FEATURE_NAME_CAMEL}}` | ❌ Deprecated | `{{camelCase FEATURE_NAME}}` |
|
|
947
|
-
| `{{FEATURE_NAME_SNAKE}}` | ❌ Deprecated | `{{snakeCase FEATURE_NAME}}` |
|
|
948
|
-
|
|
949
|
-
### Variáveis Padrão (auto-injetadas)
|
|
950
|
-
|
|
951
|
-
| Placeholder | Exemplo |
|
|
121
|
+
| Placeholder | Example |
|
|
952
122
|
|-------------|---------|
|
|
953
123
|
| `{{FEATURE_NAME}}` | `scheduled-reports` |
|
|
954
|
-
| `{{
|
|
955
|
-
| `{{
|
|
956
|
-
| `{{
|
|
957
|
-
| `{{
|
|
958
|
-
| `{{NAMESPACE}}` | Auto from config.json |
|
|
959
|
-
| `{{AUTHOR}}` | Auto from config.json |
|
|
960
|
-
|
|
961
|
-
### Stack Overrides
|
|
962
|
-
|
|
963
|
-
Templates são resolvidos com fallback automático:
|
|
964
|
-
1. `stacks/{stack}/.morph/templates/` (override stack-specific)
|
|
965
|
-
2. `.morph/templates/` (override project-local)
|
|
966
|
-
3. `framework/templates/` (fallback padrão)
|
|
967
|
-
|
|
968
|
-
Para customizar um template:
|
|
969
|
-
```bash
|
|
970
|
-
morph-spec template customize dotnet-backend-service --stack blazor-azure
|
|
971
|
-
# Edite: stacks/blazor-azure/.morph/templates/code/dotnet/backend/service.cs
|
|
972
|
-
```
|
|
124
|
+
| `{{FEATURE_NAME_PASCAL}}` | `ScheduledReports` |
|
|
125
|
+
| `{{FEATURE_NAME_CAMEL}}` | `scheduledReports` |
|
|
126
|
+
| `{{STACK}}` | `blazor-azure` or `nextjs-supabase` |
|
|
127
|
+
| `{{DATE}}`, `{{AUTHOR}}`, `{{NAMESPACE}}` | Auto from config.json |
|
|
973
128
|
|
|
974
|
-
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## COMMANDS
|
|
975
132
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
-
|
|
979
|
-
-
|
|
980
|
-
-
|
|
133
|
+
| Command | Action |
|
|
134
|
+
|---------|--------|
|
|
135
|
+
| `/morph-proposal {feature}` | Full spec pipeline (phases 1-4, auto-continuation with pauses) |
|
|
136
|
+
| `/morph-apply {feature}` | Implement feature (phase 5) |
|
|
137
|
+
| `/morph-status` | Dashboard |
|
|
138
|
+
| `/morph-archive {feature}` | Archive completed feature |
|
|
139
|
+
| `/morph-infra {action}` | Manage infrastructure |
|
|
140
|
+
| `/morph-preflight` | Pre-deploy validation |
|
|
141
|
+
| `/morph-troubleshoot {error}` | Error troubleshooting |
|
|
981
142
|
|
|
982
143
|
---
|
|
983
144
|
|
|
984
|
-
##
|
|
145
|
+
## REFERENCES
|
|
985
146
|
|
|
986
|
-
-
|
|
987
|
-
-
|
|
988
|
-
-
|
|
989
|
-
-
|
|
147
|
+
- `.morph/config/config.json` — Project configuration
|
|
148
|
+
- `.morph/config/agents.json` — Full agent definitions
|
|
149
|
+
- `.morph/standards/` — Coding, architecture, stack-specific standards
|
|
150
|
+
- `.morph/project/context/` — Detection log, project context
|
|
151
|
+
- `.morph/project/standards/inferred.md` — Auto-detected project standards
|
|
990
152
|
|
|
991
153
|
---
|
|
992
154
|
|
|
993
|
-
*MORPH-SPEC by Polymorphism Tech*
|
|
155
|
+
*MORPH-SPEC v4.3.0 by Polymorphism Tech*
|