@polymorphism-tech/morph-spec 4.10.6 → 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 (149) hide show
  1. package/CLAUDE.md +3 -0
  2. package/LICENSE +71 -71
  3. package/README.md +379 -379
  4. package/bin/morph-spec.js +89 -0
  5. package/bin/task-manager.js +59 -6
  6. package/claude-plugin.json +14 -14
  7. package/docs/CHEATSHEET.md +1 -1
  8. package/docs/QUICKSTART.md +206 -206
  9. package/framework/agents/README.md +14 -14
  10. package/framework/agents/architecture/standards-architect.md +159 -159
  11. package/framework/agents/frontend/blazor-builder.md +13 -0
  12. package/framework/agents/frontend/css-specialist.md +87 -0
  13. package/framework/agents/frontend/nextjs-expert.md +13 -0
  14. package/framework/agents/frontend/nextjs-ui-specialist.md +218 -0
  15. package/framework/agents/frontend/ui-ux-designer.md +80 -10
  16. package/framework/agents/infrastructure/azure-architect.md +149 -149
  17. package/framework/agents/infrastructure/infra-architect.md +48 -48
  18. package/framework/agents.json +2268 -2567
  19. package/framework/hooks/README.md +204 -204
  20. package/framework/hooks/claude-code/post-tool-use/dispatch.js +10 -5
  21. package/framework/hooks/claude-code/session-start/inject-morph-context.js +10 -24
  22. package/framework/hooks/shared/phase-utils.js +139 -139
  23. package/framework/hooks/shared/worktree-helpers.js +30 -8
  24. package/framework/rules/csharp-standards.md +13 -13
  25. package/framework/rules/frontend-standards.md +13 -13
  26. package/framework/rules/infrastructure-standards.md +16 -16
  27. package/framework/rules/testing-standards.md +14 -14
  28. package/framework/skills/README.md +0 -1
  29. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +12 -0
  30. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +254 -254
  31. package/framework/skills/level-0-meta/morph-init/SKILL.md +88 -3
  32. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -247
  33. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -270
  34. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +515 -499
  35. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +508 -471
  36. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +12 -1
  37. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +272 -258
  38. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +317 -311
  39. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +424 -323
  40. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  41. package/framework/standards/STANDARDS.json +2040 -2040
  42. package/framework/standards/frontend/nextjs/motion-patterns.md +321 -0
  43. package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -17
  44. package/framework/templates/README.md +814 -814
  45. package/framework/templates/code/dotnet/contracts/Commands.cs +74 -74
  46. package/framework/templates/code/dotnet/contracts/Entities.cs +25 -25
  47. package/framework/templates/code/dotnet/contracts/Queries.cs +74 -74
  48. package/framework/templates/code/dotnet/contracts/README.md +74 -74
  49. package/framework/templates/code/dotnet/contracts/api-contracts.cs +173 -173
  50. package/framework/templates/code/dotnet/frontend/component.razor +239 -239
  51. package/framework/templates/code/dotnet/jobs/agent.cs +163 -163
  52. package/framework/templates/code/dotnet/jobs/job.cs +171 -171
  53. package/framework/templates/code/dotnet/test.cs +239 -239
  54. package/framework/templates/code/sql/rls-policy.sql +57 -57
  55. package/framework/templates/code/sql/supabase-migration.sql +100 -100
  56. package/framework/templates/code/sql/supabase-migration.template.sql +113 -113
  57. package/framework/templates/code/typescript/contracts.ts +168 -168
  58. package/framework/templates/context/CONTEXT.md +181 -181
  59. package/framework/templates/context/design-system.md +211 -0
  60. package/framework/templates/docs/proposal.md +182 -182
  61. package/framework/templates/docs/user-stories.md +34 -34
  62. package/framework/templates/examples/design-system-examples.md +357 -357
  63. package/framework/templates/examples/spec-examples.md +90 -90
  64. package/framework/templates/feature/decisions.md +187 -187
  65. package/framework/templates/feature/recap.md +146 -146
  66. package/framework/templates/feature/tasks.md +199 -199
  67. package/framework/templates/infrastructure/azure/README.md +286 -286
  68. package/framework/templates/infrastructure/azure/deploy-checklist.md +426 -426
  69. package/framework/templates/infrastructure/azure/parameters.dev.json +29 -29
  70. package/framework/templates/infrastructure/azure/parameters.prod.json +29 -29
  71. package/framework/templates/infrastructure/azure/parameters.staging.json +29 -29
  72. package/framework/templates/infrastructure/docker/docker-compose.template.yml +67 -67
  73. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  74. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  75. package/framework/templates/infrastructure/docker/easypanel.template.json +54 -54
  76. package/package.json +82 -82
  77. package/src/commands/agents/agent-metrics.js +174 -0
  78. package/src/commands/agents/audit-dispatch.js +82 -0
  79. package/src/commands/agents/detect-agents.js +275 -0
  80. package/src/commands/agents/dispatch-agents.js +41 -135
  81. package/src/commands/agents/index.js +13 -4
  82. package/src/commands/agents/manage-agents.js +352 -0
  83. package/src/commands/project/doctor.js +59 -0
  84. package/src/commands/project/install-plugin-cmd.js +28 -28
  85. package/src/commands/project/setup-infra-cmd.js +12 -12
  86. package/src/commands/project/update.js +1 -17
  87. package/src/commands/project/worktree.js +58 -2
  88. package/src/commands/state/advance-phase.js +11 -3
  89. package/src/commands/tasks/index.js +4 -4
  90. package/src/commands/templates/index.js +5 -5
  91. package/src/commands/utils/index.js +3 -3
  92. package/src/commands/validation/index.js +4 -4
  93. package/src/core/state/phase-state-machine.js +217 -217
  94. package/src/core/state/state-manager.js +81 -0
  95. package/src/lib/agents/agents-manager.js +349 -0
  96. package/src/lib/agents/metrics-calculator.js +125 -0
  97. package/src/lib/agents/output-collector.js +75 -0
  98. package/src/lib/generators/context-generator.js +8 -7
  99. package/src/lib/generators/design-system-generator.js +298 -298
  100. package/src/lib/generators/index.js +10 -10
  101. package/src/lib/generators/metadata-extractor.js +387 -387
  102. package/src/lib/stack-filter.js +65 -65
  103. package/src/lib/standards/index.js +7 -7
  104. package/src/lib/standards/standards-context-injector.js +302 -302
  105. package/src/lib/tasks/task-parser.js +94 -3
  106. package/src/lib/validators/architecture/architecture-validator.js +387 -387
  107. package/src/lib/validators/architecture/index.js +7 -7
  108. package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +316 -316
  109. package/src/lib/validators/blazor/blazor-state-validator.js +279 -279
  110. package/src/lib/validators/blazor/blazor-validator.js +369 -369
  111. package/src/lib/validators/blazor/index.js +9 -9
  112. package/src/lib/validators/checkpoint-persistence.js +39 -0
  113. package/src/lib/validators/content/content-validator.js +287 -279
  114. package/src/lib/validators/content/index.js +7 -7
  115. package/src/lib/validators/contracts/index.js +7 -7
  116. package/src/lib/validators/css/css-validator.js +352 -352
  117. package/src/lib/validators/css/index.js +7 -7
  118. package/src/lib/validators/design-system/design-system-validator.js +231 -231
  119. package/src/lib/validators/design-system/index.js +7 -7
  120. package/src/lib/validators/nextjs/index.js +6 -6
  121. package/src/lib/validators/nextjs/next-component-validator.js +183 -183
  122. package/src/lib/validators/packages/index.js +7 -7
  123. package/src/lib/validators/packages/package-validator.js +360 -360
  124. package/src/lib/validators/shared/index.js +12 -12
  125. package/src/lib/validators/shared/issue-counter.js +18 -18
  126. package/src/lib/validators/shared/result-formatter.js +124 -124
  127. package/src/lib/validators/spec-validator.js +2 -2
  128. package/src/lib/validators/ui/index.js +7 -7
  129. package/src/lib/validators/ui/ui-contrast-validator.js +422 -422
  130. package/src/lib/validators/validation-runner.js +20 -0
  131. package/src/scripts/global-install.js +58 -58
  132. package/src/scripts/install-plugin.js +126 -126
  133. package/src/scripts/setup-infra.js +1 -17
  134. package/src/utils/agent-id-mapper.js +11 -0
  135. package/src/utils/agents-installer.js +40 -8
  136. package/src/utils/claude-md-injector.js +90 -90
  137. package/src/utils/claude-settings-manager.js +1 -1
  138. package/src/utils/file-copier.js +200 -196
  139. package/src/utils/hooks-installer.js +556 -739
  140. package/src/utils/logger.js +32 -32
  141. package/src/utils/skills-installer.js +178 -178
  142. package/src/utils/tier-helpers.js +24 -0
  143. package/src/utils/version-checker.js +175 -175
  144. package/framework/agents/architecture/po-pm-advisor.md +0 -203
  145. package/framework/hooks/claude-code/user-prompt/set-terminal-title.js +0 -68
  146. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  147. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  148. package/framework/templates/.idea/morph-templates.xml +0 -92
  149. 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.6"
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,258 +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.6"
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 | **Read** `.morph/framework/agents.json` → match keywords → **Bash** `npx morph-spec state add-agent` | — |
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 call a `detect-agents` CLI command (it doesn't exist — read `.morph/framework/agents.json` directly)
42
- - Do not use a Task agent for inline keyword matching (fast enough to do directly)
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
- Read agents.json and match keywords (except `domain-architect` and `vsa-architect` which were handled in Step 2.0):
91
-
92
- 1. Read `.morph/framework/agents.json` (or `framework/agents.json` in the framework project itself)
93
- 2. Extract the feature title and description from `0-proposal/proposal.md`
94
- 3. For each agent in the JSON (except architects), check if any keyword from the `keywords[]` field appears in the proposal text
95
- 4. Include all agents with `always_active: true` automatically
96
- 5. Add matched agents to state:
97
-
98
- ```bash
99
- npx morph-spec state add-agent $ARGUMENTS {agent-id}
100
- ```
101
-
102
- **To load standards for detected agents:**
103
- - For each active agent, read the standards referenced by the `standards[]` field in `agents.json`
104
- - Standard files are located at `.morph/framework/standards/{path}`
105
-
106
- **Standards resolution order:**
107
- 1. `.morph/context/*.md` — project overrides (highest priority)
108
- 2. `.morph/framework/standards/` — standards installed by morph-spec
109
- 3. `framework/standards/` — npm package standards (fallback)
110
-
111
- ### Step 2.5: Validate MCP Connections
112
-
113
- Check that configured MCPs are working before proceeding.
114
-
115
- **1. Collect recommended MCPs:**
116
- - Read `framework/phases.json` → for each phase in the feature's workflow, collect `recommendedMCPs[]`
117
- - Read `framework/skills/level-0-meta/mcp-registry.json` → get `healthCheck` for each MCP
118
-
119
- **2. Identify configured MCPs:**
120
- - Read `.claude/settings.local.json` → identify which MCPs are in `mcpServers`
121
-
122
- **3. For each MCP that is CONFIGURED AND RECOMMENDED:**
123
- 1. Search your available tools for one containing `healthCheck.toolPattern` in the name
124
- 2. If the tool exists → execute the `healthCheck.testCall` with `healthCheck.testParams`
125
- 3. Evaluate the result:
126
-
127
- | Result | Action |
128
- |--------|--------|
129
- | **Success** | `✓ {MCP} — connection verified` |
130
- | **Tool not found** | `○ {MCP} — needs restart to activate` |
131
- | **Error** | → Use `AskUserQuestion` with 3 options (below) |
132
-
133
- **On error — ask the user:**
134
-
135
- Use `AskUserQuestion` with header `"{MCP}"` and options:
136
- - **Continue without {MCP}** — show the `fallback` field from the registry and proceed
137
- - **Reconfigure credentials** — collect new credentials and update `.claude/settings.local.json`
138
- - **Stop setup** — abort and report what needs to be fixed
139
-
140
- **4. For MCPs RECOMMENDED but NOT CONFIGURED:**
141
- - Print `△ {MCP} — not configured (fallback: {registry.fallback})`
142
- - Suggestion: `Tip: configure with /morph-init refresh or npx morph-spec mcp setup`
143
-
144
- **Summary:** Show a status table for each MCP before proceeding:
145
- ```
146
- MCP Readiness:
147
- ✓ context7 — connection verified
148
- ○ playwright — needs restart
149
- △ supabase — not configured (fallback: Grep + Read for schema)
150
- ```
151
-
152
- ---
153
-
154
- ### Step 2.9: Check for Missing Agents
155
-
156
- Run a quick check to verify all expected agents are installed for this project's stack:
157
-
158
- ```bash
159
- npx morph-spec doctor 2>&1 | grep -A 1 "agents completeness"
160
- ```
161
-
162
- If the output shows **missing agents**, inform the user:
163
-
164
- > ⚠ Some agents for your stack are not installed. Run `npx morph-spec setup-infra` to install them.
165
-
166
- Use `AskUserQuestion` with header `"Agents"` and options:
167
- - **Install now** — run `npx morph-spec setup-infra` to reinstall with current stack tags
168
- - **Continue without** — proceed with available agents (may lack specialized support)
169
-
170
- If "Install now" is selected, run the command and continue.
171
-
172
- ---
173
-
174
- ### Step 3: Confirm Stack
175
-
176
- Based on the proposal and context, confirm:
177
- - Tech stack (Blazor Server, Next.js, .NET API, Node.js CLI, etc.)
178
- - Applicable architectural patterns
179
- - Existing reusable components
180
-
181
- ### Step 4: List Active Agents and Dispatch Preview
182
-
183
- Show the agents detected from the proposal:
184
-
185
- ```bash
186
- npx morph-spec state get $ARGUMENTS
187
- ```
188
-
189
- 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).
190
-
191
- **If there are 2+ specialist agents active**, show the dispatch plan for the next phase:
192
-
193
- ```bash
194
- npx morph-spec dispatch-agents $ARGUMENTS design
195
- ```
196
-
197
- This shows which agents will be dispatched in parallel during the design phase and which tasks they'll execute.
198
-
199
- > **Important mapping:** `agents[].id` from the dispatch config = `subagent_type` in the `Agent` tool.
200
- > Example: `id: "nextjs-expert"` → `Agent(subagent_type=nextjs-expert, prompt=agent.taskPrompt)`.
201
- > Each `id` corresponds to the `name:` field in the frontmatter of the file in `.claude/agents/`.
202
-
203
- ### Step 5: Update State and Determine Next Phase
204
-
205
- Update the feature state:
206
-
207
- ```bash
208
- npx morph-spec state set $ARGUMENTS status in_progress
209
- ```
210
-
211
- **Determine the next phase** based on active agents:
212
-
213
- | Condition | Next Phase |
214
- |-----------|------------|
215
- | `ui-designer` is in activeAgents | **uiux** (UI/UX phase) |
216
- | `ui-designer` is NOT in activeAgents | **design** (skip uiux) |
217
-
218
- Announce the next phase clearly to the user.
219
-
220
- ## Outputs
221
-
222
- Present to the user:
223
-
224
- 1. **Context loaded**:
225
- - Project name
226
- - Confirmed stack
227
- - Applicable standards
228
-
229
- 2. **Active agents**:
230
- - Agent list with emojis/icons and tier
231
- - Responsibilities of each agent
232
-
233
- 3. **Next phase**:
234
- - Which phase comes next (uiux or design)
235
- - Why (ui-designer presence or absence)
236
-
237
- ## Advancement Criteria
238
-
239
- - [x] Project context loaded
240
- - [x] Standards identified (framework + project)
241
- - [x] Stack confirmed
242
- - [x] Agents listed with icons
243
- - [x] State updated to in_progress
244
- - [x] Next phase determined
245
-
246
- ---
247
-
248
- ## Superpowers Integration
249
-
250
- > Available when the `superpowers` plugin is installed.
251
-
252
- | Skill | When to Use | Invocation |
253
- |-------|-------------|-----------|
254
- | `using-git-worktrees` | If the feature requires workspace isolation | `Skill(superpowers:using-git-worktrees)` |
255
-
256
- ---
257
-
258
- 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).