@polymorphism-tech/morph-spec 4.10.7 → 4.10.8

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 (122) hide show
  1. package/CLAUDE.md +3 -3
  2. package/LICENSE +71 -71
  3. package/README.md +379 -379
  4. package/bin/morph-spec.js +1 -1
  5. package/claude-plugin.json +14 -14
  6. package/docs/CHEATSHEET.md +1 -1
  7. package/docs/QUICKSTART.md +206 -206
  8. package/framework/agents/README.md +14 -14
  9. package/framework/agents/architecture/standards-architect.md +159 -159
  10. package/framework/agents/frontend/blazor-builder.md +13 -0
  11. package/framework/agents/frontend/css-specialist.md +87 -0
  12. package/framework/agents/frontend/nextjs-expert.md +13 -0
  13. package/framework/agents/frontend/nextjs-ui-specialist.md +218 -0
  14. package/framework/agents/frontend/ui-ux-designer.md +80 -10
  15. package/framework/agents/infrastructure/azure-architect.md +149 -149
  16. package/framework/agents/infrastructure/infra-architect.md +48 -48
  17. package/framework/agents.json +2268 -2204
  18. package/framework/hooks/README.md +204 -204
  19. package/framework/hooks/claude-code/session-start/inject-morph-context.js +10 -24
  20. package/framework/hooks/shared/phase-utils.js +139 -139
  21. package/framework/hooks/shared/worktree-helpers.js +30 -8
  22. package/framework/rules/csharp-standards.md +13 -13
  23. package/framework/rules/frontend-standards.md +13 -13
  24. package/framework/rules/infrastructure-standards.md +16 -16
  25. package/framework/rules/testing-standards.md +14 -14
  26. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +12 -0
  27. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +254 -254
  28. package/framework/skills/level-0-meta/morph-init/SKILL.md +88 -3
  29. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -247
  30. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -270
  31. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +515 -499
  32. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +508 -500
  33. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +12 -1
  34. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +272 -262
  35. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +317 -311
  36. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +424 -323
  37. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  38. package/framework/standards/STANDARDS.json +2040 -2040
  39. package/framework/standards/frontend/nextjs/motion-patterns.md +321 -0
  40. package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -17
  41. package/framework/templates/README.md +814 -814
  42. package/framework/templates/code/dotnet/contracts/Commands.cs +74 -74
  43. package/framework/templates/code/dotnet/contracts/Entities.cs +25 -25
  44. package/framework/templates/code/dotnet/contracts/Queries.cs +74 -74
  45. package/framework/templates/code/dotnet/contracts/README.md +74 -74
  46. package/framework/templates/code/dotnet/contracts/api-contracts.cs +173 -173
  47. package/framework/templates/code/dotnet/frontend/component.razor +239 -239
  48. package/framework/templates/code/dotnet/jobs/agent.cs +163 -163
  49. package/framework/templates/code/dotnet/jobs/job.cs +171 -171
  50. package/framework/templates/code/dotnet/test.cs +239 -239
  51. package/framework/templates/code/sql/rls-policy.sql +57 -57
  52. package/framework/templates/code/sql/supabase-migration.sql +100 -100
  53. package/framework/templates/code/sql/supabase-migration.template.sql +113 -113
  54. package/framework/templates/code/typescript/contracts.ts +168 -168
  55. package/framework/templates/context/CONTEXT.md +181 -181
  56. package/framework/templates/context/design-system.md +211 -0
  57. package/framework/templates/docs/proposal.md +182 -182
  58. package/framework/templates/docs/user-stories.md +34 -34
  59. package/framework/templates/examples/design-system-examples.md +357 -357
  60. package/framework/templates/examples/spec-examples.md +90 -90
  61. package/framework/templates/feature/decisions.md +187 -187
  62. package/framework/templates/feature/recap.md +146 -146
  63. package/framework/templates/feature/tasks.md +199 -199
  64. package/framework/templates/infrastructure/azure/README.md +286 -286
  65. package/framework/templates/infrastructure/azure/deploy-checklist.md +426 -426
  66. package/framework/templates/infrastructure/azure/parameters.dev.json +29 -29
  67. package/framework/templates/infrastructure/azure/parameters.prod.json +29 -29
  68. package/framework/templates/infrastructure/azure/parameters.staging.json +29 -29
  69. package/framework/templates/infrastructure/docker/docker-compose.template.yml +67 -67
  70. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  71. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  72. package/framework/templates/infrastructure/docker/easypanel.template.json +54 -54
  73. package/package.json +82 -82
  74. package/src/commands/agents/index.js +13 -13
  75. package/src/commands/project/install-plugin-cmd.js +28 -28
  76. package/src/commands/project/setup-infra-cmd.js +12 -12
  77. package/src/commands/project/worktree.js +58 -2
  78. package/src/commands/tasks/index.js +4 -4
  79. package/src/commands/templates/index.js +5 -5
  80. package/src/commands/utils/index.js +3 -3
  81. package/src/commands/validation/index.js +4 -4
  82. package/src/core/state/phase-state-machine.js +217 -217
  83. package/src/lib/generators/design-system-generator.js +298 -298
  84. package/src/lib/generators/index.js +10 -10
  85. package/src/lib/generators/metadata-extractor.js +387 -387
  86. package/src/lib/stack-filter.js +65 -65
  87. package/src/lib/standards/index.js +7 -7
  88. package/src/lib/standards/standards-context-injector.js +302 -302
  89. package/src/lib/validators/architecture/architecture-validator.js +387 -387
  90. package/src/lib/validators/architecture/index.js +7 -7
  91. package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +316 -316
  92. package/src/lib/validators/blazor/blazor-state-validator.js +279 -279
  93. package/src/lib/validators/blazor/blazor-validator.js +369 -369
  94. package/src/lib/validators/blazor/index.js +9 -9
  95. package/src/lib/validators/content/content-validator.js +287 -287
  96. package/src/lib/validators/content/index.js +7 -7
  97. package/src/lib/validators/contracts/index.js +7 -7
  98. package/src/lib/validators/css/css-validator.js +352 -352
  99. package/src/lib/validators/css/index.js +7 -7
  100. package/src/lib/validators/design-system/design-system-validator.js +231 -231
  101. package/src/lib/validators/design-system/index.js +7 -7
  102. package/src/lib/validators/nextjs/index.js +6 -6
  103. package/src/lib/validators/nextjs/next-component-validator.js +183 -183
  104. package/src/lib/validators/packages/index.js +7 -7
  105. package/src/lib/validators/packages/package-validator.js +360 -360
  106. package/src/lib/validators/shared/index.js +12 -12
  107. package/src/lib/validators/shared/issue-counter.js +18 -18
  108. package/src/lib/validators/shared/result-formatter.js +124 -124
  109. package/src/lib/validators/ui/index.js +7 -7
  110. package/src/lib/validators/ui/ui-contrast-validator.js +422 -422
  111. package/src/scripts/global-install.js +58 -58
  112. package/src/scripts/install-plugin.js +126 -126
  113. package/src/utils/claude-md-injector.js +90 -90
  114. package/src/utils/file-copier.js +200 -196
  115. package/src/utils/hooks-installer.js +556 -494
  116. package/src/utils/logger.js +32 -32
  117. package/src/utils/skills-installer.js +178 -178
  118. package/src/utils/version-checker.js +175 -175
  119. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  120. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  121. package/framework/templates/.idea/morph-templates.xml +0 -92
  122. package/framework/templates/.vscode/morph-templates.code-snippets +0 -186
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 4 (Plan). Generates a detailed implementation plan
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.10.7"
7
+ cliVersion: "4.10.8"
8
8
  ---
9
9
 
10
10
  # MORPH Plan — Phase 4
@@ -65,6 +65,17 @@ Read: .morph/features/{feature}/1-design/spec.md
65
65
  + Read: .morph/config/config.json
66
66
  ```
67
67
 
68
+ ### 1.5 Create session tasks for visibility
69
+
70
+ ```
71
+ TaskCreate: "Analyze feature for execution strategy" → activeForm: "Analyzing feature"
72
+ TaskCreate: "Determine execution strategy" → activeForm: "Planning strategy"
73
+ TaskCreate: "Generate plan.md" → activeForm: "Writing plan"
74
+ TaskCreate: "Plan approval" → activeForm: "Awaiting plan approval"
75
+ ```
76
+
77
+ Update each to `in_progress` before starting and `completed` after finishing.
78
+
68
79
  ---
69
80
 
70
81
  ## Workflow
@@ -1,262 +1,272 @@
1
- ---
2
- name: morph-phase-setup
3
- description: MORPH-SPEC Phase 1 (Setup). Reads project context, detects tech stack, activates relevant agents by reading agents.json, and confirms the feature environment. Use at the start of every MORPH-SPEC feature workflow after proposal approval to load standards and initialize the context.
4
- argument-hint: "[feature-name]"
5
- user-invocable: false
6
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.10.7"
8
- ---
9
-
10
- # MORPH Setup — Phase 1
11
-
12
- > INTERNAL: Workflow skill used by /morph-proposal during automated phase orchestration. Not a user command.
13
-
14
- Initialize the context and prepare the environment for an approved feature.
15
-
16
- ## Prerequisites
17
-
18
- - [ ] Feature has `proposal.md` created (Phase 0 complete)
19
- - [ ] Proposal was approved by the user
20
- - [ ] Agents were detected and registered in state
21
-
22
- ## Recommended Tools
23
-
24
- > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for full guide.
25
- > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
26
-
27
- | Action | Tool | Alternative |
28
- |--------|------|-------------|
29
- | Verify state | **Bash** `npx morph-spec state get` | — |
30
- | Detect agents + standards | **Bash** `npx morph-spec detect-agents $ARGUMENTS --json` → parse → **Bash** `npx morph-spec state add-agent` | **Read** agents.json manually |
31
- | Read project context | **Read** `.morph/context/README.md` | — |
32
- | Read config | **Read** `.morph/config/config.json` | — |
33
- | Detect VSA architecture | **Read** `.morph/config/config.json` → check `config.architecture.style` | — |
34
- | Scan project structure | **Glob** `src/**/*.{ts,tsx,cs}` | — |
35
- | Repository metadata | **GitHub MCP** `get_repo()` | **Bash** `gh repo view --json` |
36
- | Update state | **Bash** `npx morph-spec state set` | — |
37
-
38
- **MCPs for this phase:** GitHub (optional — repo metadata).
39
-
40
- **Anti-patterns:**
41
- - Do not read agents.json manually for keyword matching — use `npx morph-spec detect-agents` CLI
42
- - Do not use a Task agent for agent detection (CLI is faster and consistent)
43
- - Do not use WebSearch for local project info (use Read/Glob)
44
-
45
- ---
46
-
47
- ## Workflow
48
-
49
- ### ENTRY CHECKPOINT: Verify Prerequisites
50
-
51
- Before proceeding with setup:
52
-
53
- - [ ] Does `proposal.md` exist in `.morph/features/$ARGUMENTS/0-proposal/`?
54
- - [ ] Was the proposal presented and approved by the user?
55
- - [ ] Is the feature registered in state?
56
-
57
- If any checkbox is NOT checked → go back to Phase 0 (Proposal).
58
-
59
- ---
60
-
61
- ### Step 1: Load Project Context
62
-
63
- Read these files first — they inform all subsequent decisions:
64
-
65
- ```bash
66
- npx morph-spec state get $ARGUMENTS
67
- ```
68
-
69
- If the feature doesn't exist in state, go back to Phase 0.
70
-
71
- Then read:
72
- - `.morph/context/README.md` — project overview, tech stack, architecture
73
- - `.morph/config/config.json` — project configuration
74
-
75
- ### Step 2: Detect Agents and Load Standards
76
-
77
- #### Step 2.0: Detect Architecture Style and Activate Architect
78
-
79
- Read `.morph/config/config.json` and check `config.architecture.style`:
80
-
81
- | Value | Action |
82
- |-------|--------|
83
- | `"vertical-slice"` | `npx morph-spec state add-agent $ARGUMENTS vsa-architect` |
84
- | absent / any other value | `npx morph-spec state add-agent $ARGUMENTS domain-architect` |
85
-
86
- Proceed with normal keyword detection for all other agents. The architect was already added above — skip it during keyword matching to avoid duplication.
87
-
88
- #### Step 2.1: Keyword Detection
89
-
90
- Use the `detect-agents` CLI to match agent keywords against the proposal (excludes architects already handled in Step 2.0):
91
-
92
- ```bash
93
- npx morph-spec detect-agents $ARGUMENTS --exclude domain-architect,vsa-architect --json
94
- ```
95
-
96
- This reads the proposal from `.morph/features/$ARGUMENTS/0-proposal/proposal.md` and agents.json, returning JSON with `detected[]` and `skipped[]` arrays. Agents with `active_phases: ['*']` are always included.
97
-
98
- Parse the JSON output and add each detected agent to state:
99
-
100
- ```bash
101
- npx morph-spec state add-agent $ARGUMENTS {agent-id}
102
- ```
103
-
104
- Run `add-agent` once per detected agent ID from the `detected[]` array.
105
-
106
- **To load standards for detected agents:**
107
- - For each active agent, read the standards referenced by the `standards[]` field in `agents.json`
108
- - Standard files are located at `.morph/framework/standards/{path}`
109
-
110
- **Standards resolution order:**
111
- 1. `.morph/context/*.md` — project overrides (highest priority)
112
- 2. `.morph/framework/standards/` — standards installed by morph-spec
113
- 3. `framework/standards/` — npm package standards (fallback)
114
-
115
- ### Step 2.5: Validate MCP Connections
116
-
117
- Check that configured MCPs are working before proceeding.
118
-
119
- **1. Collect recommended MCPs:**
120
- - Read `framework/phases.json` → for each phase in the feature's workflow, collect `recommendedMCPs[]`
121
- - Read `framework/skills/level-0-meta/mcp-registry.json` → get `healthCheck` for each MCP
122
-
123
- **2. Identify configured MCPs:**
124
- - Read `.claude/settings.local.json` → identify which MCPs are in `mcpServers`
125
-
126
- **3. For each MCP that is CONFIGURED AND RECOMMENDED:**
127
- 1. Search your available tools for one containing `healthCheck.toolPattern` in the name
128
- 2. If the tool exists → execute the `healthCheck.testCall` with `healthCheck.testParams`
129
- 3. Evaluate the result:
130
-
131
- | Result | Action |
132
- |--------|--------|
133
- | **Success** | `✓ {MCP} — connection verified` |
134
- | **Tool not found** | `○ {MCP} — needs restart to activate` |
135
- | **Error** | → Use `AskUserQuestion` with 3 options (below) |
136
-
137
- **On error — ask the user:**
138
-
139
- Use `AskUserQuestion` with header `"{MCP}"` and options:
140
- - **Continue without {MCP}** — show the `fallback` field from the registry and proceed
141
- - **Reconfigure credentials** — collect new credentials and update `.claude/settings.local.json`
142
- - **Stop setup** — abort and report what needs to be fixed
143
-
144
- **4. For MCPs RECOMMENDED but NOT CONFIGURED:**
145
- - Print `△ {MCP} — not configured (fallback: {registry.fallback})`
146
- - Suggestion: `Tip: configure with /morph-init refresh or npx morph-spec mcp setup`
147
-
148
- **Summary:** Show a status table for each MCP before proceeding:
149
- ```
150
- MCP Readiness:
151
- ✓ context7 — connection verified
152
- ○ playwright — needs restart
153
- △ supabase — not configured (fallback: Grep + Read for schema)
154
- ```
155
-
156
- ---
157
-
158
- ### Step 2.9: Check for Missing Agents
159
-
160
- Run a quick check to verify all expected agents are installed for this project's stack:
161
-
162
- ```bash
163
- npx morph-spec doctor 2>&1 | grep -A 1 "agents completeness"
164
- ```
165
-
166
- If the output shows **missing agents**, inform the user:
167
-
168
- > ⚠ Some agents for your stack are not installed. Run `npx morph-spec setup-infra` to install them.
169
-
170
- Use `AskUserQuestion` with header `"Agents"` and options:
171
- - **Install now** — run `npx morph-spec setup-infra` to reinstall with current stack tags
172
- - **Continue without** — proceed with available agents (may lack specialized support)
173
-
174
- If "Install now" is selected, run the command and continue.
175
-
176
- ---
177
-
178
- ### Step 3: Confirm Stack
179
-
180
- Based on the proposal and context, confirm:
181
- - Tech stack (Blazor Server, Next.js, .NET API, Node.js CLI, etc.)
182
- - Applicable architectural patterns
183
- - Existing reusable components
184
-
185
- ### Step 4: List Active Agents and Dispatch Preview
186
-
187
- Show the agents detected from the proposal:
188
-
189
- ```bash
190
- npx morph-spec state get $ARGUMENTS
191
- ```
192
-
193
- Parse the JSON and list `activeAgents` with their emojis/icons and responsibilities (look up each agent in `.morph/framework/agents.json` for the `icon` field).
194
-
195
- **If there are 2+ specialist agents active**, show the dispatch plan for the next phase:
196
-
197
- ```bash
198
- npx morph-spec dispatch-agents $ARGUMENTS design
199
- ```
200
-
201
- This shows which agents will be dispatched in parallel during the design phase and which tasks they'll execute.
202
-
203
- > **Important mapping:** `agents[].id` from the dispatch config = `subagent_type` in the `Agent` tool.
204
- > Example: `id: "nextjs-expert"` → `Agent(subagent_type=nextjs-expert, prompt=agent.taskPrompt)`.
205
- > Each `id` corresponds to the `name:` field in the frontmatter of the file in `.claude/agents/`.
206
-
207
- ### Step 5: Update State and Determine Next Phase
208
-
209
- Update the feature state:
210
-
211
- ```bash
212
- npx morph-spec state set $ARGUMENTS status in_progress
213
- ```
214
-
215
- **Determine the next phase** based on active agents:
216
-
217
- | Condition | Next Phase |
218
- |-----------|------------|
219
- | `ui-designer` is in activeAgents | **uiux** (UI/UX phase) |
220
- | `ui-designer` is NOT in activeAgents | **design** (skip uiux) |
221
-
222
- Announce the next phase clearly to the user.
223
-
224
- ## Outputs
225
-
226
- Present to the user:
227
-
228
- 1. **Context loaded**:
229
- - Project name
230
- - Confirmed stack
231
- - Applicable standards
232
-
233
- 2. **Active agents**:
234
- - Agent list with emojis/icons and tier
235
- - Responsibilities of each agent
236
-
237
- 3. **Next phase**:
238
- - Which phase comes next (uiux or design)
239
- - Why (ui-designer presence or absence)
240
-
241
- ## Advancement Criteria
242
-
243
- - [x] Project context loaded
244
- - [x] Standards identified (framework + project)
245
- - [x] Stack confirmed
246
- - [x] Agents listed with icons
247
- - [x] State updated to in_progress
248
- - [x] Next phase determined
249
-
250
- ---
251
-
252
- ## Superpowers Integration
253
-
254
- > Available when the `superpowers` plugin is installed.
255
-
256
- | Skill | When to Use | Invocation |
257
- |-------|-------------|-----------|
258
- | `using-git-worktrees` | If the feature requires workspace isolation | `Skill(superpowers:using-git-worktrees)` |
259
-
260
- ---
261
-
262
- Continue automatically to the next phase (UI/UX if ui-designer detected, otherwise Design).
1
+ ---
2
+ name: morph-phase-setup
3
+ description: MORPH-SPEC Phase 1 (Setup). Reads project context, detects tech stack, activates relevant agents by reading agents.json, and confirms the feature environment. Use at the start of every MORPH-SPEC feature workflow after proposal approval to load standards and initialize the context.
4
+ argument-hint: "[feature-name]"
5
+ user-invocable: false
6
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
+ cliVersion: "4.10.8"
8
+ ---
9
+
10
+ # MORPH Setup — Phase 1
11
+
12
+ > INTERNAL: Workflow skill used by /morph-proposal during automated phase orchestration. Not a user command.
13
+
14
+ Initialize the context and prepare the environment for an approved feature.
15
+
16
+ ## Prerequisites
17
+
18
+ - [ ] Feature has `proposal.md` created (Phase 0 complete)
19
+ - [ ] Proposal was approved by the user
20
+ - [ ] Agents were detected and registered in state
21
+
22
+ ## Recommended Tools
23
+
24
+ > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for full guide.
25
+ > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
26
+
27
+ | Action | Tool | Alternative |
28
+ |--------|------|-------------|
29
+ | Verify state | **Bash** `npx morph-spec state get` | — |
30
+ | Detect agents + standards | **Bash** `npx morph-spec detect-agents $ARGUMENTS --json` → parse → **Bash** `npx morph-spec state add-agent` | **Read** agents.json manually |
31
+ | Read project context | **Read** `.morph/context/README.md` | — |
32
+ | Read config | **Read** `.morph/config/config.json` | — |
33
+ | Detect VSA architecture | **Read** `.morph/config/config.json` → check `config.architecture.style` | — |
34
+ | Scan project structure | **Glob** `src/**/*.{ts,tsx,cs}` | — |
35
+ | Repository metadata | **GitHub MCP** `get_repo()` | **Bash** `gh repo view --json` |
36
+ | Update state | **Bash** `npx morph-spec state set` | — |
37
+
38
+ **MCPs for this phase:** GitHub (optional — repo metadata).
39
+
40
+ **Anti-patterns:**
41
+ - Do not read agents.json manually for keyword matching — use `npx morph-spec detect-agents` CLI
42
+ - Do not use a Task agent for agent detection (CLI is faster and consistent)
43
+ - Do not use WebSearch for local project info (use Read/Glob)
44
+
45
+ ---
46
+
47
+ ## Workflow
48
+
49
+ ### ENTRY CHECKPOINT: Verify Prerequisites
50
+
51
+ Before proceeding with setup:
52
+
53
+ - [ ] Does `proposal.md` exist in `.morph/features/$ARGUMENTS/0-proposal/`?
54
+ - [ ] Was the proposal presented and approved by the user?
55
+ - [ ] Is the feature registered in state?
56
+
57
+ If any checkbox is NOT checked → go back to Phase 0 (Proposal).
58
+
59
+ ---
60
+
61
+ ### Create session tasks for visibility
62
+
63
+ ```
64
+ TaskCreate: "Detect agents and load standards" → activeForm: "Detecting agents"
65
+ TaskCreate: "Validate MCP connections" → activeForm: "Validating MCPs"
66
+ TaskCreate: "Confirm stack with user" → activeForm: "Confirming stack"
67
+ TaskCreate: "Configure feature state" → activeForm: "Configuring state"
68
+ ```
69
+
70
+ Update each task to `in_progress` before its step and `completed` after.
71
+
72
+ ---
73
+
74
+ ### Step 1: Load Project Context
75
+
76
+ Read these files first — they inform all subsequent decisions:
77
+
78
+ ```bash
79
+ npx morph-spec state get $ARGUMENTS
80
+ ```
81
+
82
+ If the feature doesn't exist in state, go back to Phase 0.
83
+
84
+ Then read:
85
+ - `.morph/context/README.md` — project overview, tech stack, architecture
86
+ - `.morph/config/config.json` — project configuration
87
+
88
+ ### Step 2: Detect Agents and Load Standards
89
+
90
+ #### Step 2.0: Detect Architecture Style and Activate Architect
91
+
92
+ Read `.morph/config/config.json` and check `config.architecture.style`:
93
+
94
+ | Value | Action |
95
+ |-------|--------|
96
+ | `"vertical-slice"` | `npx morph-spec state add-agent $ARGUMENTS vsa-architect` |
97
+ | absent / any other value | `npx morph-spec state add-agent $ARGUMENTS domain-architect` |
98
+
99
+ Proceed with normal keyword detection for all other agents. The architect was already added above — skip it during keyword matching to avoid duplication.
100
+
101
+ #### Step 2.1: Keyword Detection
102
+
103
+ Use the `detect-agents` CLI to match agent keywords against the proposal (excludes architects already handled in Step 2.0):
104
+
105
+ ```bash
106
+ npx morph-spec detect-agents $ARGUMENTS --exclude domain-architect,vsa-architect --json
107
+ ```
108
+
109
+ This reads the proposal from `.morph/features/$ARGUMENTS/0-proposal/proposal.md` and agents.json, returning JSON with `detected[]` and `skipped[]` arrays. Agents with `active_phases: ['*']` are always included.
110
+
111
+ Parse the JSON output and add each detected agent to state:
112
+
113
+ ```bash
114
+ npx morph-spec state add-agent $ARGUMENTS {agent-id}
115
+ ```
116
+
117
+ Run `add-agent` once per detected agent ID from the `detected[]` array.
118
+
119
+ **To load standards for detected agents:**
120
+ - For each active agent, read the standards referenced by the `standards[]` field in `agents.json`
121
+ - Standard files are located at `.morph/framework/standards/{path}`
122
+
123
+ **Standards resolution order:**
124
+ 1. `.morph/context/*.md` — project overrides (highest priority)
125
+ 2. `.morph/framework/standards/` — standards installed by morph-spec
126
+ 3. `framework/standards/` — npm package standards (fallback)
127
+
128
+ ### Step 2.5: Validate MCP Connections
129
+
130
+ Check that configured MCPs are working before proceeding.
131
+
132
+ **1. Collect recommended MCPs:**
133
+ - Read `framework/phases.json` → for each phase in the feature's workflow, collect `recommendedMCPs[]`
134
+ - Read `framework/skills/level-0-meta/mcp-registry.json` → get `healthCheck` for each MCP
135
+
136
+ **2. Identify configured MCPs:**
137
+ - Read `.claude/settings.local.json` → identify which MCPs are in `mcpServers`
138
+
139
+ **3. For each MCP that is CONFIGURED AND RECOMMENDED:**
140
+ 1. Search your available tools for one containing `healthCheck.toolPattern` in the name
141
+ 2. If the tool exists → execute the `healthCheck.testCall` with `healthCheck.testParams`
142
+ 3. Evaluate the result:
143
+
144
+ | Result | Action |
145
+ |--------|--------|
146
+ | **Success** | `✓ {MCP} — connection verified` |
147
+ | **Tool not found** | `○ {MCP} — needs restart to activate` |
148
+ | **Error** | → Use `AskUserQuestion` with 3 options (below) |
149
+
150
+ **On error — ask the user:**
151
+
152
+ Use `AskUserQuestion` with header `"{MCP}"` and options:
153
+ - **Continue without {MCP}** — show the `fallback` field from the registry and proceed
154
+ - **Reconfigure credentials** — collect new credentials and update `.claude/settings.local.json`
155
+ - **Stop setup** — abort and report what needs to be fixed
156
+
157
+ **4. For MCPs RECOMMENDED but NOT CONFIGURED:**
158
+ - Print `△ {MCP} — not configured (fallback: {registry.fallback})`
159
+ - Suggestion: `Tip: configure with /morph-init refresh or npx morph-spec mcp setup`
160
+
161
+ **Summary:** Show a status table for each MCP before proceeding:
162
+ ```
163
+ MCP Readiness:
164
+ ✓ context7 — connection verified
165
+ ○ playwright — needs restart
166
+ △ supabase — not configured (fallback: Grep + Read for schema)
167
+ ```
168
+
169
+ ---
170
+
171
+ ### Step 2.9: Check for Missing Agents
172
+
173
+ Run a quick check to verify all expected agents are installed for this project's stack:
174
+
175
+ ```bash
176
+ npx morph-spec doctor 2>&1 | grep -A 1 "agents completeness"
177
+ ```
178
+
179
+ If the output shows **missing agents**, inform the user:
180
+
181
+ > ⚠ Some agents for your stack are not installed. Run `npx morph-spec setup-infra` to install them.
182
+
183
+ Use `AskUserQuestion` with header `"Agents"` and options:
184
+ - **Install now** — run `npx morph-spec setup-infra` to reinstall with current stack tags
185
+ - **Continue without** — proceed with available agents (may lack specialized support)
186
+
187
+ If "Install now" is selected, run the command and continue.
188
+
189
+ ---
190
+
191
+ ### Step 3: Confirm Stack
192
+
193
+ Based on the proposal and context, confirm:
194
+ - Tech stack (Blazor Server, Next.js, .NET API, Node.js CLI, etc.)
195
+ - Applicable architectural patterns
196
+ - Existing reusable components
197
+
198
+ ### Step 4: List Active Agents and Dispatch Preview
199
+
200
+ Show the agents detected from the proposal:
201
+
202
+ ```bash
203
+ npx morph-spec state get $ARGUMENTS
204
+ ```
205
+
206
+ Parse the JSON and list `activeAgents` with their emojis/icons and responsibilities (look up each agent in `.morph/framework/agents.json` for the `icon` field).
207
+
208
+ **If there are 2+ specialist agents active**, show the dispatch plan for the next phase:
209
+
210
+ ```bash
211
+ npx morph-spec dispatch-agents $ARGUMENTS design
212
+ ```
213
+
214
+ This shows which agents will be dispatched in parallel during the design phase and which tasks they'll execute.
215
+
216
+ > **Important mapping:** `agents[].id` from the dispatch config = `subagent_type` in the `Agent` tool.
217
+ > Example: `id: "nextjs-expert"` → `Agent(subagent_type=nextjs-expert, prompt=agent.taskPrompt)`.
218
+ > Each `id` corresponds to the `name:` field in the frontmatter of the file in `.claude/agents/`.
219
+
220
+ ### Step 5: Update State and Determine Next Phase
221
+
222
+ Update the feature state:
223
+
224
+ ```bash
225
+ npx morph-spec state set $ARGUMENTS status in_progress
226
+ ```
227
+
228
+ **Determine the next phase** based on active agents:
229
+
230
+ | Condition | Next Phase |
231
+ |-----------|------------|
232
+ | `ui-designer` is in activeAgents | **uiux** (UI/UX phase) |
233
+ | `ui-designer` is NOT in activeAgents | **design** (skip uiux) |
234
+
235
+ Announce the next phase clearly to the user.
236
+
237
+ ## Outputs
238
+
239
+ Present to the user:
240
+
241
+ 1. **Context loaded**:
242
+ - Project name
243
+ - Confirmed stack
244
+ - Applicable standards
245
+
246
+ 2. **Active agents**:
247
+ - Agent list with emojis/icons and tier
248
+ - Responsibilities of each agent
249
+
250
+ 3. **Next phase**:
251
+ - Which phase comes next (uiux or design)
252
+ - Why (ui-designer presence or absence)
253
+
254
+ ## Advancement Criteria
255
+
256
+ - [x] Project context loaded
257
+ - [x] Standards identified (framework + project)
258
+ - [x] Stack confirmed
259
+ - [x] Agents listed with icons
260
+ - [x] State updated to in_progress
261
+ - [x] Next phase determined
262
+
263
+ ---
264
+
265
+ ## Worktree Note
266
+
267
+ Worktree isolation is handled automatically by `/morph-proposal` Step 0 and `/morph-apply` Step 0.
268
+ If a worktree is active, all file operations MUST use the worktree path (injected in session context as `WORKTREE_PATH`).
269
+
270
+ ---
271
+
272
+ Continue automatically to the next phase (UI/UX if ui-designer detected, otherwise Design).