@polymorphism-tech/morph-spec 4.10.0 → 4.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +5 -69
- package/framework/agents/backend/api-designer.md +3 -0
- package/framework/agents/backend/dotnet-senior.md +3 -0
- package/framework/agents/backend/ef-modeler.md +2 -0
- package/framework/agents/backend/hangfire-orchestrator.md +2 -0
- package/framework/agents/backend/ms-agent-expert.md +2 -0
- package/framework/agents/frontend/blazor-builder.md +2 -0
- package/framework/agents/frontend/nextjs-expert.md +2 -0
- package/framework/agents/infrastructure/azure-architect.md +2 -0
- package/framework/agents/infrastructure/azure-deploy-specialist.md +2 -0
- package/framework/agents/infrastructure/bicep-architect.md +2 -0
- package/framework/agents/infrastructure/container-specialist.md +2 -0
- package/framework/agents/infrastructure/devops-engineer.md +3 -0
- package/framework/agents/infrastructure/infra-architect.md +3 -0
- package/framework/agents/integrations/asaas-financial.md +2 -0
- package/framework/agents/integrations/azure-identity.md +2 -0
- package/framework/agents/integrations/clerk-auth.md +3 -0
- package/framework/agents/integrations/hangfire-integration.md +2 -0
- package/framework/agents/integrations/resend-email.md +2 -0
- package/framework/commands/morph-apply.md +151 -161
- package/framework/commands/morph-archive.md +28 -28
- package/framework/commands/morph-infra.md +79 -79
- package/framework/commands/morph-preflight.md +92 -56
- package/framework/commands/morph-proposal.md +94 -70
- package/framework/commands/morph-status.md +31 -31
- package/framework/commands/morph-troubleshoot.md +63 -60
- package/framework/rules/csharp-standards.md +3 -0
- package/framework/rules/frontend-standards.md +2 -0
- package/framework/rules/infrastructure-standards.md +3 -0
- package/framework/rules/morph-workflow.md +57 -2
- package/framework/rules/nextjs-standards.md +2 -0
- package/framework/rules/testing-standards.md +3 -0
- package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +54 -49
- package/framework/skills/level-0-meta/morph-checklist/SKILL.md +42 -19
- package/framework/skills/level-0-meta/morph-code-review/SKILL.md +8 -5
- package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +7 -5
- package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +139 -136
- package/framework/skills/level-0-meta/morph-init/SKILL.md +42 -13
- package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +130 -130
- package/framework/skills/level-0-meta/morph-replicate/SKILL.md +95 -87
- package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +24 -0
- package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +42 -41
- package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +22 -11
- package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +123 -114
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +120 -102
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +206 -214
- package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +241 -360
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +107 -115
- package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +135 -135
- package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +143 -139
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +168 -165
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +57 -8
- package/package.json +3 -3
- package/src/commands/project/doctor.js +7 -2
- package/src/commands/project/update.js +4 -4
- package/src/lib/stack-filter.js +58 -0
- package/src/scripts/setup-infra.js +53 -18
- package/src/utils/agents-installer.js +19 -5
- package/src/utils/claude-md-injector.js +90 -0
- package/src/utils/hooks-installer.js +1 -4
- package/src/utils/skills-installer.js +67 -7
- package/CLAUDE.md +0 -98
- package/framework/memory/patterns-learned.md +0 -766
- package/framework/skills/level-0-meta/morph-terminal-title/SKILL.md +0 -61
- package/framework/skills/level-0-meta/morph-terminal-title/scripts/set_title.sh +0 -65
|
@@ -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.
|
|
5
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
6
|
+
cliVersion: "4.10.2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# MORPH Codebase Analysis - Sub-
|
|
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`
|
|
12
|
+
> Called by `phase-design.md` Step 2. Not a standalone user command.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Automates existing code analysis to generate `schema-analysis.md` with real database/code data.
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Prerequisites
|
|
17
17
|
|
|
18
|
-
- [ ]
|
|
19
|
-
- [ ] Feature
|
|
20
|
-
- [ ]
|
|
18
|
+
- [ ] Phase 1 (Setup) completed
|
|
19
|
+
- [ ] Feature has approved `proposal.md`
|
|
20
|
+
- [ ] Project context loaded (stack, agents)
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Recommended Tools
|
|
23
23
|
|
|
24
|
-
> **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md`
|
|
25
|
-
> **Ref:** `framework/standards/integration/mcp/mcp-tools.md`
|
|
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
|
-
|
|
|
27
|
+
| Action | Tool | Alternative |
|
|
28
28
|
|------|------------|-------------|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
**MCPs
|
|
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
|
|
43
|
+
## Automated Workflow
|
|
44
44
|
|
|
45
|
-
###
|
|
45
|
+
### Step 1: Detect Analysis Method
|
|
46
46
|
|
|
47
|
-
**
|
|
48
|
-
|
|
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.
|
|
52
|
-
→
|
|
53
|
-
→
|
|
54
|
-
→
|
|
55
|
-
→
|
|
56
|
-
→
|
|
57
|
-
→
|
|
58
|
-
|
|
59
|
-
2.
|
|
60
|
-
→
|
|
61
|
-
→
|
|
62
|
-
→
|
|
63
|
-
|
|
64
|
-
3.
|
|
65
|
-
→
|
|
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
|
-
**
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
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
|
-
###
|
|
74
|
+
### Step 2A: MCP Method (Preferred)
|
|
75
75
|
|
|
76
|
-
**
|
|
76
|
+
**Tools:** Supabase MCP
|
|
77
77
|
|
|
78
78
|
```javascript
|
|
79
|
-
// 1.
|
|
79
|
+
// 1. List all tables
|
|
80
80
|
const tables = await mcp__supabase__list_tables();
|
|
81
81
|
|
|
82
|
-
// 2.
|
|
82
|
+
// 2. For each feature-relevant table:
|
|
83
83
|
for (const table of relevantTables) {
|
|
84
|
-
// 2a.
|
|
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.
|
|
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 (
|
|
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
|
-
###
|
|
104
|
+
### Step 2B: Static Analysis Method (Fallback)
|
|
105
105
|
|
|
106
|
-
**
|
|
106
|
+
**Tools:** Grep, Glob, Read, Task (subagent for large projects)
|
|
107
107
|
|
|
108
|
-
**
|
|
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
|
-
**
|
|
116
|
+
**Phase B2: Read Query Files**
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
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
|
-
**
|
|
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
|
-
**
|
|
138
|
+
**Phase B4: When to use Task (subagent)**
|
|
139
139
|
|
|
140
|
-
Use Task subagent **
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
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
|
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
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
|
-
###
|
|
149
|
+
### Step 2B-Format: Standardized Format for Static Analysis
|
|
150
150
|
|
|
151
|
-
**
|
|
152
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
198
|
-
|
|
199
|
-
|
|
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 MANDATORY — without standard format
|
|
199
|
+
it's not possible to generate contracts.cs mechanically.
|
|
200
200
|
|
|
201
|
-
###
|
|
201
|
+
### Step 3: Map Inconsistencies
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
Create a map of:
|
|
204
204
|
|
|
205
|
-
| Frontend/
|
|
205
|
+
| Frontend/Code | Database | Type | Problem |
|
|
206
206
|
|----------------|----------------|------|----------|
|
|
207
|
-
| user.name | users.fullname | string |
|
|
208
|
-
| lead.phone | leads.phonenumber | string |
|
|
209
|
-
| order.metadata | orders.metadata | JSONB |
|
|
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
|
-
###
|
|
211
|
+
### Step 4: Generate `schema-analysis.md`
|
|
212
212
|
|
|
213
|
-
Use
|
|
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
|
-
|
|
221
|
+
OR use **Write** tool to create directly with collected data.
|
|
222
222
|
|
|
223
|
-
###
|
|
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
|
|
234
|
+
- State updated with `schemaAnalysis` output
|
|
235
235
|
|
|
236
236
|
## CHECKPOINT
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
**
|
|
247
|
-
|
|
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*
|