@polymorphism-tech/morph-spec 4.10.0 → 4.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -2,90 +2,90 @@
2
2
  name: morph:phase-codebase-analysis
3
3
  description: MORPH-SPEC Design sub-phase that analyzes existing codebase and database schema, producing schema-analysis.md with real column names, types, relationships, and field mismatches. Use at the start of Design phase before generating contracts.cs to prevent incorrect field names or types.
4
4
  user-invocable: false
5
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep
6
- cliVersion: "4.10.0"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ cliVersion: "4.10.2"
7
7
  ---
8
8
 
9
- # MORPH Codebase Analysis - Sub-fase de DESIGN
9
+ # MORPH Codebase Analysis - Design Sub-phase
10
10
 
11
11
  > INTERNAL: Automation skill for schema analysis step within Phase 2 (Design).
12
- > Called by `phase-design.md` Passo 2. Not a standalone user command.
12
+ > Called by `phase-design.md` Step 2. Not a standalone user command.
13
13
 
14
- Automatiza a análise de código existente para gerar `schema-analysis.md` com dados reais do banco/código.
14
+ Automates existing code analysis to generate `schema-analysis.md` with real database/code data.
15
15
 
16
- ## Pré-requisitos
16
+ ## Prerequisites
17
17
 
18
- - [ ] FASE 1 (Setup) concluída
19
- - [ ] Feature tem `proposal.md` aprovado
20
- - [ ] Contexto do projeto carregado (stack, agentes)
18
+ - [ ] Phase 1 (Setup) completed
19
+ - [ ] Feature has approved `proposal.md`
20
+ - [ ] Project context loaded (stack, agents)
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
- > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` para referência MCP.
24
+ > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
25
+ > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
26
26
 
27
- | Ação | Ferramenta | Alternativa |
27
+ | Action | Tool | Alternative |
28
28
  |------|------------|-------------|
29
- | Listar tabelas do banco | **Supabase MCP** `list_tables()` | **Grep** `.from(` no código |
30
- | Obter schema de tabela | **Supabase MCP** `get_table_schema()` | **Read** type definitions |
31
- | Obter relacionamentos FK | **Supabase MCP** `get_relationships()` | **Grep** JOIN/FK patterns |
32
- | Obter políticas RLS | **Supabase MCP** `query()` | **Read** policy files |
33
- | Encontrar queries no código | **Grep** `\.from\(` em `*.ts,*.tsx,*.js,*.cs` | — |
34
- | Encontrar type definitions | **Glob** `src/**/types/**/*.ts` ou `**/Entities/**/*.cs` | — |
35
- | Ler arquivos encontrados | **Read** cada arquivo | — |
36
- | Análise multi-arquivo complexa | **Task** (subagent Explore) | Read individual |
37
- | Gerar schema-analysis.md | **Write** usando template | **Bash** template render |
38
-
39
- **MCPs desta fase:** Supabase (schema — **PRIORITÁRIO**), Database MCPs genéricos.
29
+ | List database tables | **Supabase MCP** `list_tables()` | **Grep** `.from(` in code |
30
+ | Get table schema | **Supabase MCP** `get_table_schema()` | **Read** type definitions |
31
+ | Get FK relationships | **Supabase MCP** `get_relationships()` | **Grep** JOIN/FK patterns |
32
+ | Get RLS policies | **Supabase MCP** `query()` | **Read** policy files |
33
+ | Find queries in code | **Grep** `\.from\(` in `*.ts,*.tsx,*.js,*.cs` | — |
34
+ | Find type definitions | **Glob** `src/**/types/**/*.ts` or `**/Entities/**/*.cs` | — |
35
+ | Read found files | **Read** each file | — |
36
+ | Complex multi-file analysis | **Task** (subagent Explore) | Read individual |
37
+ | Generate schema-analysis.md | **Write** using template | **Bash** template render |
38
+
39
+ **MCPs for this phase:** Supabase (schema — **PRIORITY**), Generic database MCPs.
40
40
 
41
41
  ---
42
42
 
43
- ## Workflow Automatizado
43
+ ## Automated Workflow
44
44
 
45
- ### Passo 1: Detectar Método de Análise
45
+ ### Step 1: Detect Analysis Method
46
46
 
47
- **IMPORTANTE (Problem 8 fix):** Não assuma que o MCP está disponível e acessível.
48
- Verifique primeiro com uma chamada de teste antes de tentar usá-lo.
47
+ **IMPORTANT:** Do not assume the MCP is available and accessible.
48
+ Verify first with a test call before attempting to use it.
49
49
 
50
50
  ```
51
- 1. SE MCP Supabase configurado no settings.json:
52
- Tentar mcp__supabase__list_tables() com timeout implícito
53
- SE retornar dados válidos (array de tabelas com conteúdo):
54
- Usar Método A (MCP direto)
55
- SE retornar erro, timeout, array vazio, ou dados inacessíveis:
56
- Logar: "MCP Supabase configurado mas inacessível (CloudSQL? Auth? Permissões?)"
57
- Usar Método B (análise estática de código)
58
-
59
- 2. SE MCP Database (outro) configurado:
60
- Testar conectividade com query trivial antes de usar
61
- SE OK: Usar Método A adaptado
62
- SE falhar: Usar Método B
63
-
64
- 3. SE nenhum MCP disponível:
65
- Usar Método B (análise estática de código)
51
+ 1. IF Supabase MCP configured in settings.json:
52
+ Try mcp__supabase__list_tables() with implicit timeout
53
+ IF returns valid data (array of tables with content):
54
+ Use Method A (direct MCP)
55
+ IF returns error, timeout, empty array, or inaccessible data:
56
+ Log: "Supabase MCP configured but inaccessible (CloudSQL? Auth? Permissions?)"
57
+ Use Method B (static code analysis)
58
+
59
+ 2. IF Database MCP (other) configured:
60
+ Test connectivity with trivial query before using
61
+ IF OK: Use adapted Method A
62
+ IF fails: Use Method B
63
+
64
+ 3. IF no MCP available:
65
+ Use Method B (static code analysis)
66
66
  ```
67
67
 
68
- **Sinais de MCP inacessível:**
69
- - Resposta vazia ou `[]` em `list_tables()`
70
- - Erro de autenticação / permissão negada
71
- - Schema retornado não bate com o código (ex: tabelas existem no código mas não no MCP)
72
- - Projeto usa banco diferente do Supabase (CloudSQL, RDS, Azure SQL, etc.)
68
+ **Signs of inaccessible MCP:**
69
+ - Empty response or `[]` from `list_tables()`
70
+ - Authentication error / permission denied
71
+ - Returned schema doesn't match code (e.g., tables exist in code but not in MCP)
72
+ - Project uses database other than Supabase (CloudSQL, RDS, Azure SQL, etc.)
73
73
 
74
- ### Passo 2A: Método MCP (Preferencial)
74
+ ### Step 2A: MCP Method (Preferred)
75
75
 
76
- **Ferramentas:** Supabase MCP
76
+ **Tools:** Supabase MCP
77
77
 
78
78
  ```javascript
79
- // 1. Listar todas as tabelas
79
+ // 1. List all tables
80
80
  const tables = await mcp__supabase__list_tables();
81
81
 
82
- // 2. Para cada tabela relevante à feature:
82
+ // 2. For each feature-relevant table:
83
83
  for (const table of relevantTables) {
84
- // 2a. Schema completo
84
+ // 2a. Complete schema
85
85
  const schema = await mcp__supabase__get_table_schema({ table: table.name });
86
86
  // → column_name, data_type, is_nullable, column_default
87
87
 
88
- // 2b. Relacionamentos
88
+ // 2b. Relationships
89
89
  const rels = await mcp__supabase__get_relationships({ table: table.name });
90
90
  // → foreign_table, foreign_column, constraint_type
91
91
 
@@ -94,18 +94,18 @@ for (const table of relevantTables) {
94
94
  query: `SELECT indexname, indexdef FROM pg_indexes WHERE tablename = '${table.name}'`
95
95
  });
96
96
 
97
- // 2d. RLS policies (segurança)
97
+ // 2d. RLS policies (security)
98
98
  const policies = await mcp__supabase__query({
99
99
  query: `SELECT policyname, cmd, qual FROM pg_policies WHERE tablename = '${table.name}'`
100
100
  });
101
101
  }
102
102
  ```
103
103
 
104
- ### Passo 2B: Método Análise Estática (Fallback)
104
+ ### Step 2B: Static Analysis Method (Fallback)
105
105
 
106
- **Ferramentas:** Grep, Glob, Read, Task (subagent para projetos grandes)
106
+ **Tools:** Grep, Glob, Read, Task (subagent for large projects)
107
107
 
108
- **Fase B1: Encontrar Queries**
108
+ **Phase B1: Find Queries**
109
109
 
110
110
  ```
111
111
  Grep: "\.from\(|\.select\(|SELECT |supabase\.|context\.|dbContext\.|DbSet<"
@@ -113,15 +113,15 @@ Type: ts,tsx,js,jsx,cs
113
113
  Output: files_with_matches
114
114
  ```
115
115
 
116
- **Fase B2: Ler Arquivos de Query**
116
+ **Phase B2: Read Query Files**
117
117
 
118
- Para cada arquivo encontrado, use **Read** para extrair:
119
- - Nomes de tabelas: `from('leads')`, `DbSet<Lead>`, `FROM leads`
120
- - Nomes de colunas: `.select('fullname, phonenumber')`, `l.FullName`
121
- - Tipos de dados: TypeScript interfaces, C# DTOs
122
- - Relacionamentos: JOIN clauses, navigation properties
118
+ For each found file, use **Read** to extract:
119
+ - Table names: `from('leads')`, `DbSet<Lead>`, `FROM leads`
120
+ - Column names: `.select('fullname, phonenumber')`, `l.FullName`
121
+ - Data types: TypeScript interfaces, C# DTOs
122
+ - Relationships: JOIN clauses, navigation properties
123
123
 
124
- **Fase B3: Encontrar Type Definitions**
124
+ **Phase B3: Find Type Definitions**
125
125
 
126
126
  ```
127
127
  # TypeScript/JavaScript:
@@ -135,23 +135,23 @@ Glob: "**/Entities/**/*.cs"
135
135
  Glob: "**/Models/**/*.cs"
136
136
  ```
137
137
 
138
- **Fase B4: Quando usar Task (subagent)**
138
+ **Phase B4: When to use Task (subagent)**
139
139
 
140
- Use Task subagent **APENAS** quando:
141
- - Projeto tem 20+ arquivos de query
142
- - Múltiplos padrões de acesso a dados (Supabase + EF Core + raw SQL)
143
- - Análise precisa de contexto cruzado entre muitos arquivos
140
+ Use Task subagent **ONLY** when:
141
+ - Project has 20+ query files
142
+ - Multiple data access patterns (Supabase + EF Core + raw SQL)
143
+ - Precise cross-context analysis across many files
144
144
 
145
- Não use Task subagent quando:
146
- - Projeto tem < 10 arquivos de query (Read direto é mais rápido)
147
- - Padrão de acesso a dados é uniforme ( Supabase OU EF Core)
145
+ Do not use Task subagent when:
146
+ - Project has < 10 query files (direct Read is faster)
147
+ - Data access pattern is uniform (only Supabase OR only EF Core)
148
148
 
149
- ### Passo 2B-Formato: Formato Padronizado para Análise Estática
149
+ ### Step 2B-Format: Standardized Format for Static Analysis
150
150
 
151
- **IMPORTANTE (Problem 10 fix):** Quando usar Método B (análise estática), **sempre use o template oficial**.
152
- Isso garante que `contracts.cs` pode ser gerado mecanicamente, sem interpretação manual.
151
+ **IMPORTANT:** When using Method B (static analysis), **always use the official template**.
152
+ This ensures `contracts.cs` can be generated mechanically, without manual interpretation.
153
153
 
154
- O template está em `framework/templates/docs/schema-analysis.md`. Use-o via:
154
+ The template is at `framework/templates/docs/schema-analysis.md`. Use it via:
155
155
 
156
156
  ```bash
157
157
  npx morph-spec template render docs/schema-analysis \
@@ -194,23 +194,23 @@ npx morph-spec template render docs/schema-analysis \
194
194
  }'
195
195
  ```
196
196
 
197
- **Se o template render não estiver disponível**, use **Write** tool para criar o arquivo diretamente
198
- seguindo a estrutura acima. O formato das tabelas e mismatches é OBRIGATÓRIO sem formato padrão
199
- não é possível gerar contracts.cs mecanicamente.
197
+ **If template render is not available**, use **Write** tool to create the file directly
198
+ following the structure above. The table and mismatch format is MANDATORYwithout standard format
199
+ it's not possible to generate contracts.cs mechanically.
200
200
 
201
- ### Passo 3: Mapear Inconsistências
201
+ ### Step 3: Map Inconsistencies
202
202
 
203
- Crie um mapa de:
203
+ Create a map of:
204
204
 
205
- | Frontend/Código | Banco de Dados | Tipo | Problema |
205
+ | Frontend/Code | Database | Type | Problem |
206
206
  |----------------|----------------|------|----------|
207
- | user.name | users.fullname | string | MISMATCH |
208
- | lead.phone | leads.phonenumber | string | MISMATCH |
209
- | order.metadata | orders.metadata | JSONB | ⚠️ Type complex |
207
+ | user.name | users.fullname | string | MISMATCH |
208
+ | lead.phone | leads.phonenumber | string | MISMATCH |
209
+ | order.metadata | orders.metadata | JSONB | Type complex |
210
210
 
211
- ### Passo 4: Gerar `schema-analysis.md`
211
+ ### Step 4: Generate `schema-analysis.md`
212
212
 
213
- Use o template em `framework/templates/docs/schema-analysis.md`:
213
+ Use the template at `framework/templates/docs/schema-analysis.md`:
214
214
 
215
215
  ```bash
216
216
  npx morph-spec template render docs/schema-analysis \
@@ -218,9 +218,9 @@ npx morph-spec template render docs/schema-analysis \
218
218
  '{ "FEATURE_NAME": "{feature-name}", "DATE": "..." }'
219
219
  ```
220
220
 
221
- OU use **Write** tool para criar diretamente com os dados coletados.
221
+ OR use **Write** tool to create directly with collected data.
222
222
 
223
- ### Passo 5: Atualizar State
223
+ ### Step 5: Update State
224
224
 
225
225
  ```bash
226
226
  npx morph-spec state mark-output {feature-name} schema-analysis
@@ -231,22 +231,40 @@ npx morph-spec state mark-output {feature-name} schema-analysis
231
231
  ## Outputs
232
232
 
233
233
  - `.morph/features/{feature}/1-design/schema-analysis.md`
234
- - State atualizado com output `schemaAnalysis`
234
+ - State updated with `schemaAnalysis` output
235
235
 
236
236
  ## CHECKPOINT
237
237
 
238
- Antes de prosseguir para contracts.cs, apresente ao usuário:
239
-
240
- - [ ] Analisei {N} tabelas
241
- - [ ] Encontrei {N} field name mismatches
242
- - [ ] Encontrei {N} type mismatches
243
- - [ ] Mapeei {N} relacionamentos
244
- - [ ] `schema-analysis.md` criado
238
+ Before proceeding to contracts.cs, present results and ask for confirmation using `AskUserQuestion`:
239
+
240
+ ```json
241
+ {
242
+ "questions": [
243
+ {
244
+ "header": "Schema Review",
245
+ "question": "Schema analysis complete: {N} tables, {N} field mismatches, {N} type mismatches, {N} relationships. Is the analysis correct?",
246
+ "multiSelect": false,
247
+ "options": [
248
+ { "label": "Correct", "description": "Schema analysis matches the real database" },
249
+ { "label": "Has issues", "description": "I see problems — let me explain" }
250
+ ]
251
+ },
252
+ {
253
+ "header": "Contracts",
254
+ "question": "May I generate contracts.cs based on this real schema?",
255
+ "multiSelect": false,
256
+ "options": [
257
+ { "label": "Generate contracts", "description": "Proceed to contracts.cs using the analyzed schema" },
258
+ { "label": "Wait", "description": "I want to review schema-analysis.md first" }
259
+ ]
260
+ }
261
+ ]
262
+ }
263
+ ```
245
264
 
246
- **Perguntas obrigatórias:**
247
- 1. "O schema analysis está correto?"
248
- 2. "Posso gerar contracts.cs com base nesse schema real?"
265
+ **If "Has issues"** → ask what's wrong, fix schema-analysis.md, re-present checkpoint.
266
+ **If "Correct" + "Generate contracts"** → proceed to contracts generation.
249
267
 
250
268
  ---
251
269
 
252
- *MORPH-SPEC by Polymorphism Tech*
270
+ *MORPH-SPEC by Polymorphism Tech*