@polymorphism-tech/morph-spec 4.9.0 → 4.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +30 -0
  3. package/bin/task-manager.js +34 -22
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +35 -98
  8. package/framework/agents/backend/api-designer.md +3 -0
  9. package/framework/agents/backend/dotnet-senior.md +3 -0
  10. package/framework/agents/backend/ef-modeler.md +2 -0
  11. package/framework/agents/backend/hangfire-orchestrator.md +2 -0
  12. package/framework/agents/backend/ms-agent-expert.md +2 -0
  13. package/framework/agents/frontend/blazor-builder.md +2 -0
  14. package/framework/agents/frontend/nextjs-expert.md +2 -0
  15. package/framework/agents/infrastructure/azure-architect.md +2 -0
  16. package/framework/agents/infrastructure/azure-deploy-specialist.md +2 -0
  17. package/framework/agents/infrastructure/bicep-architect.md +2 -0
  18. package/framework/agents/infrastructure/container-specialist.md +2 -0
  19. package/framework/agents/infrastructure/devops-engineer.md +3 -0
  20. package/framework/agents/infrastructure/infra-architect.md +3 -0
  21. package/framework/agents/integrations/asaas-financial.md +2 -0
  22. package/framework/agents/integrations/azure-identity.md +2 -0
  23. package/framework/agents/integrations/clerk-auth.md +3 -0
  24. package/framework/agents/integrations/hangfire-integration.md +2 -0
  25. package/framework/agents/integrations/resend-email.md +2 -0
  26. package/framework/agents.json +37 -7
  27. package/framework/commands/commit.md +166 -0
  28. package/framework/commands/morph-apply.md +156 -155
  29. package/framework/commands/morph-archive.md +33 -27
  30. package/framework/commands/morph-infra.md +83 -77
  31. package/framework/commands/morph-preflight.md +97 -55
  32. package/framework/commands/morph-proposal.md +131 -58
  33. package/framework/commands/morph-status.md +36 -30
  34. package/framework/commands/morph-troubleshoot.md +68 -59
  35. package/framework/hooks/claude-code/notification/approval-reminder.js +3 -2
  36. package/framework/hooks/claude-code/post-tool-use/dispatch.js +154 -31
  37. package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +7 -84
  38. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +8 -17
  39. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +16 -3
  40. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +4 -3
  41. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +3 -2
  42. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +60 -0
  43. package/framework/hooks/claude-code/session-start/inject-morph-context.js +55 -2
  44. package/framework/hooks/claude-code/session-start/post-compact-restore.js +41 -0
  45. package/framework/hooks/claude-code/stop/validate-completion.js +2 -15
  46. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +23 -5
  47. package/framework/hooks/shared/compact-restore.js +100 -0
  48. package/framework/hooks/shared/dispatch-helpers.js +116 -0
  49. package/framework/hooks/shared/phase-utils.js +9 -5
  50. package/framework/hooks/shared/state-reader.js +27 -3
  51. package/framework/phases.json +30 -7
  52. package/framework/rules/csharp-standards.md +3 -0
  53. package/framework/rules/frontend-standards.md +2 -0
  54. package/framework/rules/infrastructure-standards.md +3 -0
  55. package/framework/rules/morph-workflow.md +143 -86
  56. package/framework/rules/nextjs-standards.md +2 -0
  57. package/framework/rules/testing-standards.md +3 -0
  58. package/framework/skills/level-0-meta/mcp-registry.json +86 -51
  59. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +139 -0
  60. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +42 -19
  61. package/framework/skills/level-0-meta/{code-review → morph-code-review}/SKILL.md +8 -5
  62. package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/SKILL.md +8 -6
  63. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +362 -0
  64. package/framework/skills/level-0-meta/morph-init/SKILL.md +114 -20
  65. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +362 -0
  66. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +95 -87
  67. package/framework/skills/level-0-meta/{simulation-checklist → morph-simulation-checklist}/SKILL.md +24 -0
  68. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/SKILL.md +43 -43
  69. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/references/tools-per-phase.md +1 -2
  70. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/SKILL.md +23 -12
  71. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/scripts/check-phase-outputs.mjs +2 -2
  72. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -0
  73. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -0
  74. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +499 -0
  75. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
  76. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +472 -0
  77. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +50 -0
  78. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +45 -0
  79. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +47 -0
  80. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +246 -0
  81. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +238 -0
  82. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
  83. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +312 -0
  84. package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/scripts/validate-tasks.mjs +3 -3
  85. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +324 -0
  86. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +146 -0
  87. package/framework/standards/integration/mcp/mcp-tools.md +25 -7
  88. package/framework/templates/docs/onboarding.md +2 -2
  89. package/package.json +3 -4
  90. package/src/commands/agents/dispatch-agents.js +50 -3
  91. package/src/commands/mcp/mcp-setup.js +39 -2
  92. package/src/commands/phase/phase-reset.js +74 -0
  93. package/src/commands/project/doctor.js +26 -7
  94. package/src/commands/project/update.js +4 -4
  95. package/src/commands/scope/escalate.js +215 -0
  96. package/src/commands/state/advance-phase.js +27 -53
  97. package/src/commands/state/state.js +1 -1
  98. package/src/commands/task/expand.js +100 -0
  99. package/src/core/paths/output-schema.js +4 -3
  100. package/src/core/state/phase-state-machine.js +7 -4
  101. package/src/core/state/state-manager.js +4 -3
  102. package/src/lib/detectors/claude-config-detector.js +93 -347
  103. package/src/lib/detectors/design-system-detector.js +189 -189
  104. package/src/lib/detectors/index.js +155 -57
  105. package/src/lib/generators/context-generator.js +2 -2
  106. package/src/lib/installers/mcp-installer.js +37 -5
  107. package/src/lib/phase-chain/phase-validator.js +22 -16
  108. package/src/lib/scope/impact-analyzer.js +106 -0
  109. package/src/lib/stack-filter.js +58 -0
  110. package/src/lib/tasks/task-parser.js +1 -1
  111. package/src/lib/validators/shared/emit-validator-dispatch.js +64 -0
  112. package/src/scripts/setup-infra.js +68 -18
  113. package/src/utils/agents-installer.js +51 -17
  114. package/src/utils/claude-md-injector.js +90 -0
  115. package/src/utils/file-copier.js +0 -1
  116. package/src/utils/hooks-installer.js +16 -5
  117. package/src/utils/skills-installer.js +67 -7
  118. package/CLAUDE.md +0 -98
  119. package/framework/memory/patterns-learned.md +0 -766
  120. package/framework/skills/level-0-meta/brainstorming/SKILL.md +0 -137
  121. package/framework/skills/level-0-meta/frontend-review/SKILL.md +0 -359
  122. package/framework/skills/level-0-meta/post-implementation/SKILL.md +0 -362
  123. package/framework/skills/level-0-meta/terminal-title/SKILL.md +0 -61
  124. package/framework/skills/level-0-meta/terminal-title/scripts/set_title.sh +0 -65
  125. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +0 -216
  126. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +0 -252
  127. package/framework/skills/level-1-workflows/phase-design/SKILL.md +0 -383
  128. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +0 -492
  129. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +0 -195
  130. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +0 -271
  131. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +0 -286
  132. package/src/commands/project/index.js +0 -8
  133. package/src/core/index.js +0 -10
  134. package/src/core/state/index.js +0 -8
  135. package/src/core/templates/index.js +0 -9
  136. package/src/core/templates/template-data-sources.js +0 -325
  137. package/src/core/workflows/index.js +0 -7
  138. package/src/lib/detectors/config-detector.js +0 -223
  139. package/src/lib/detectors/standards-generator.js +0 -335
  140. package/src/lib/detectors/structure-detector.js +0 -275
  141. package/src/lib/monitor/agent-resolver.js +0 -144
  142. package/src/lib/monitor/renderer.js +0 -230
  143. package/src/lib/orchestration/index.js +0 -7
  144. package/src/lib/orchestration/team-orchestrator.js +0 -404
  145. package/src/sanitizer/context-sanitizer.js +0 -221
  146. package/src/sanitizer/patterns.js +0 -163
  147. package/src/writer/file-writer.js +0 -86
  148. /package/framework/skills/level-0-meta/{brainstorming → morph-brainstorming}/references/proposal-example.md +0 -0
  149. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-example.md +0 -0
  150. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-guidelines.md +0 -0
  151. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/scripts/scan-csharp.mjs +0 -0
  152. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/references/review-example-nextjs.md +0 -0
  153. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/scripts/scan-nextjs.mjs +0 -0
  154. /package/framework/skills/level-0-meta/{frontend-review → morph-frontend-review}/scripts/scan-accessibility.mjs +0 -0
  155. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-dev-server.mjs +0 -0
  156. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-stack.mjs +0 -0
  157. /package/framework/skills/level-1-workflows/{phase-clarify → morph-phase-clarify}/references/clarifications-example.md +0 -0
  158. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/architecture-analysis-guide.md +0 -0
  159. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-authoring-guide.md +0 -0
  160. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-example.md +0 -0
  161. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/recap-example.md +0 -0
  162. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/vsa-implementation-guide.md +0 -0
  163. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/task-planning-patterns.md +0 -0
  164. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/tasks-example.md +0 -0
@@ -0,0 +1,246 @@
1
+ ---
2
+ name: morph:phase-plan
3
+ description: MORPH-SPEC Phase 4 (Plan). Generates a detailed implementation plan with exact file paths, TDD code blocks, and execution strategy analysis. Produces plan.md in 3-plan/. Use after clarify phase to create an actionable implementation plan before task breakdown.
4
+ argument-hint: "[feature-name]"
5
+ disable-model-invocation: true
6
+ user-invocable: false
7
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
8
+ cliVersion: "4.10.1"
9
+ ---
10
+
11
+ # MORPH Plan — Phase 4
12
+
13
+ > INTERNAL: Workflow skill used by /morph-proposal during automated phase orchestration. Not a user command.
14
+
15
+ Generate a detailed implementation plan with exact paths, TDD code, and execution strategy.
16
+
17
+ ## Prerequisites
18
+
19
+ - [ ] Phase 3 (Clarify) completed
20
+ - [ ] `spec.md` updated with clarifications
21
+ - [ ] `contracts.cs` or `contracts.ts` defined
22
+
23
+ ## Recommended Tools
24
+
25
+ > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
26
+
27
+ | Action | Tool | Alternative |
28
+ |--------|------|-------------|
29
+ | Read spec + contracts + decisions | **Read** all outputs | — |
30
+ | Analyze existing codebase | **Glob** + **Grep** patterns | — |
31
+ | Look up library docs | **Context7 MCP** `query_docs()` | **WebSearch** |
32
+ | Dispatch agents for analysis | **Bash** `npx morph-spec dispatch-agents $ARGUMENTS plan` | — |
33
+ | Update state | **Bash** `npx morph-spec state mark-output $ARGUMENTS plan` | — |
34
+
35
+ **Anti-patterns:**
36
+ - Generating plan without reading contracts (contracts are the source of truth!)
37
+ - Generic paths ("add the file") — always use exact paths
38
+ - Incomplete code in plan ("add validation") — always include complete code
39
+ - Skipping existing codebase analysis (existing patterns guide the plan)
40
+ - Ignoring `config.architecture.style` — VSA and DDD have different structures
41
+
42
+ ---
43
+
44
+ ## Pre-flight
45
+
46
+ ### 0. Ensure plan phase
47
+
48
+ ```bash
49
+ npx morph-spec state get $ARGUMENTS
50
+ ```
51
+
52
+ Check the `"phase"` field:
53
+ - `"phase": "plan"` → correct phase, proceed
54
+ - any other value → run `npx morph-spec phase advance $ARGUMENTS` and re-check
55
+
56
+ > **Rule:** Never write to `3-plan/` until the phase is `plan`.
57
+
58
+ ### 1. Read all prerequisites in PARALLEL
59
+
60
+ ```
61
+ Read: .morph/features/{feature}/1-design/spec.md
62
+ + Read: .morph/features/{feature}/1-design/contracts.cs (or contracts.ts)
63
+ + Read: .morph/features/{feature}/1-design/decisions.md
64
+ + Read: .morph/features/{feature}/1-design/clarifications.md
65
+ + Read: .morph/features/{feature}/1-design/schema-analysis.md (if exists)
66
+ + Read: .morph/config/config.json
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Workflow
72
+
73
+ ### Step 1: Analyze Feature for Context
74
+
75
+ 1. **Scan existing codebase** — Glob to find files that will be modified/created
76
+ 2. **Identify patterns** — Grep for patterns similar to what will be implemented
77
+ 3. **Check library docs** — Context7 for dependency documentation
78
+ 4. **Detect architecture:**
79
+
80
+ ```bash
81
+ cat .morph/config/config.json | grep -A3 '"architecture"'
82
+ ```
83
+
84
+ | `config.architecture.style` value | Path structure |
85
+ |------------------------------------|---------------|
86
+ | `"vertical-slice"` | VSA: `Features/{Entity}Feature/{Operation}/` |
87
+ | any other value | DDD by layer |
88
+
89
+ ### Step 2: Determine Execution Strategy
90
+
91
+ Run the dispatch analysis:
92
+
93
+ ```bash
94
+ npx morph-spec dispatch-agents $ARGUMENTS plan
95
+ ```
96
+
97
+ **Factors for recommendation:**
98
+
99
+ | Factor | Calculation |
100
+ |--------|-------------|
101
+ | `taskCount` | Number of functional requirements + technical components in spec |
102
+ | `domainCount` | Distinct domains in activeAgents (backend, frontend, infra) |
103
+ | `agentCount` | Total activeAgents |
104
+ | `independence` | % of tasks without cross-domain dependencies |
105
+
106
+ **Decision:**
107
+
108
+ | Scenario | Recommendation |
109
+ |----------|----------------|
110
+ | `taskCount < 8` AND `domainCount <= 2` | **Single session** — direct sequential implementation |
111
+ | `taskCount 8-20` AND `domainCount 2-3` | **Subagent-Driven** — one subagent per task group |
112
+ | `taskCount > 20` OR `domainCount > 3` | **Agent Teams** — multi-domain coordination |
113
+
114
+ ### Step 3: Generate `plan.md`
115
+
116
+ Create `.morph/features/$ARGUMENTS/3-plan/plan.md` with this structure:
117
+
118
+ ```markdown
119
+ # {Feature Name} Implementation Plan
120
+
121
+ > **For Claude:** Use morph:phase-implement to execute this plan.
122
+
123
+ **Goal:** {One sentence describing what will be built}
124
+
125
+ **Architecture:** {2-3 sentences about the approach}
126
+
127
+ **Tech Stack:** {Key technologies}
128
+
129
+ **Execution Strategy:** {single | subagents | agent-teams} (Recommended)
130
+
131
+ ---
132
+
133
+ ## GROUP {A} — {Group Name}
134
+
135
+ {Pattern and context for the group}
136
+
137
+ ### {A1} — {Task Name}
138
+
139
+ **Files:**
140
+ - Create: `exact/path/to/file.cs`
141
+ - Modify: `exact/path/to/existing.cs:123-145`
142
+ - Test: `tests/exact/path/to/test.cs`
143
+
144
+ **Step 1: Write the failing test**
145
+
146
+ (Complete test code)
147
+
148
+ **Step 2: Run test to verify it fails**
149
+
150
+ Run: `{exact command}`
151
+ Expected: FAIL with "{message}"
152
+
153
+ **Step 3: Write minimal implementation**
154
+
155
+ (Complete implementation code)
156
+
157
+ **Step 4: Run test to verify it passes**
158
+
159
+ Run: `{exact command}`
160
+ Expected: PASS
161
+
162
+ **Step 5: Commit**
163
+
164
+ git add {files}
165
+ git commit -m "{message}"
166
+ ```
167
+
168
+ **Mandatory rules:**
169
+ - Exact paths ALWAYS (never "add the file somewhere")
170
+ - COMPLETE code in each step (never "add validation later" or "implement here")
171
+ - Exact test commands with expected output (pass/fail message)
172
+ - Each task follows the TDD 5-step cycle above — this is what makes the plan actionable
173
+ - Keep each step to a 2-5 minute action
174
+
175
+ ### Step 4: Update State
176
+
177
+ ```bash
178
+ npx morph-spec state mark-output $ARGUMENTS plan
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Mandatory Approval Pause
184
+
185
+ Use `AskUserQuestion` to capture approval before advancing. This gate prevents task breakdown from starting with an unapproved plan.
186
+
187
+ ```json
188
+ {
189
+ "questions": [
190
+ {
191
+ "header": "Approval",
192
+ "question": "Implementation plan generated. Approve to start task breakdown?",
193
+ "multiSelect": false,
194
+ "options": [
195
+ { "label": "Approve plan", "description": "Advance to task breakdown phase" },
196
+ { "label": "I have feedback", "description": "Type what you want to change" }
197
+ ]
198
+ },
199
+ {
200
+ "header": "Execution",
201
+ "question": "Which execution strategy for implementation?",
202
+ "multiSelect": false,
203
+ "options": [
204
+ { "label": "{Recommendation} (Recommended)", "description": "{Justification from Step 2 analysis}" },
205
+ { "label": "{Alternative 1}", "description": "{Description}" },
206
+ { "label": "{Alternative 2}", "description": "{Description}" }
207
+ ]
208
+ }
209
+ ]
210
+ }
211
+ ```
212
+
213
+ > The first "Execution" option should be the context-aware recommendation from Step 2. Alternatives are the other strategies.
214
+
215
+ - **"Approve plan"** →
216
+ ```bash
217
+ npx morph-spec approve $ARGUMENTS plan
218
+ npx morph-spec phase advance $ARGUMENTS
219
+ ```
220
+ - **"I have feedback" or "Other"** → apply the feedback and repeat this PAUSE
221
+
222
+ ---
223
+
224
+ ## Phase Outputs
225
+
226
+ <!-- morph:outputs:plan -->
227
+ | Output | Path |
228
+ |--------|------|
229
+ | `plan` | `.morph/features/{feature}/3-plan/plan.md` |
230
+ <!-- /morph:outputs -->
231
+
232
+ ---
233
+
234
+ ## Advancement Criteria
235
+
236
+ - [x] `plan.md` created with all groups and tasks
237
+ - [x] Exact paths for all files
238
+ - [x] Complete code in each step
239
+ - [x] Test commands with expected output
240
+ - [x] Execution strategy defined and approved
241
+ - [x] State updated (`mark-output plan`)
242
+ - [x] User approved plan via `AskUserQuestion`
243
+
244
+ ---
245
+
246
+ After approval: proceed automatically to Phase 5 (Tasks).
@@ -0,0 +1,238 @@
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.1"
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 3: Confirm Stack
155
+
156
+ Based on the proposal and context, confirm:
157
+ - Tech stack (Blazor Server, Next.js, .NET API, Node.js CLI, etc.)
158
+ - Applicable architectural patterns
159
+ - Existing reusable components
160
+
161
+ ### Step 4: List Active Agents and Dispatch Preview
162
+
163
+ Show the agents detected from the proposal:
164
+
165
+ ```bash
166
+ npx morph-spec state get $ARGUMENTS
167
+ ```
168
+
169
+ 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).
170
+
171
+ **If there are 2+ specialist agents active**, show the dispatch plan for the next phase:
172
+
173
+ ```bash
174
+ npx morph-spec dispatch-agents $ARGUMENTS design
175
+ ```
176
+
177
+ This shows which agents will be dispatched in parallel during the design phase and which tasks they'll execute.
178
+
179
+ > **Important mapping:** `agents[].id` from the dispatch config = `subagent_type` in the `Agent` tool.
180
+ > Example: `id: "nextjs-expert"` → `Agent(subagent_type=nextjs-expert, prompt=agent.taskPrompt)`.
181
+ > Each `id` corresponds to the `name:` field in the frontmatter of the file in `.claude/agents/`.
182
+
183
+ ### Step 5: Update State and Determine Next Phase
184
+
185
+ Update the feature state:
186
+
187
+ ```bash
188
+ npx morph-spec state set $ARGUMENTS status in_progress
189
+ ```
190
+
191
+ **Determine the next phase** based on active agents:
192
+
193
+ | Condition | Next Phase |
194
+ |-----------|------------|
195
+ | `ui-designer` is in activeAgents | **uiux** (UI/UX phase) |
196
+ | `ui-designer` is NOT in activeAgents | **design** (skip uiux) |
197
+
198
+ Announce the next phase clearly to the user.
199
+
200
+ ## Outputs
201
+
202
+ Present to the user:
203
+
204
+ 1. **Context loaded**:
205
+ - Project name
206
+ - Confirmed stack
207
+ - Applicable standards
208
+
209
+ 2. **Active agents**:
210
+ - Agent list with emojis/icons and tier
211
+ - Responsibilities of each agent
212
+
213
+ 3. **Next phase**:
214
+ - Which phase comes next (uiux or design)
215
+ - Why (ui-designer presence or absence)
216
+
217
+ ## Advancement Criteria
218
+
219
+ - [x] Project context loaded
220
+ - [x] Standards identified (framework + project)
221
+ - [x] Stack confirmed
222
+ - [x] Agents listed with icons
223
+ - [x] State updated to in_progress
224
+ - [x] Next phase determined
225
+
226
+ ---
227
+
228
+ ## Superpowers Integration
229
+
230
+ > Available when the `superpowers` plugin is installed.
231
+
232
+ | Skill | When to Use | Invocation |
233
+ |-------|-------------|-----------|
234
+ | `using-git-worktrees` | If the feature requires workspace isolation | `Skill(superpowers:using-git-worktrees)` |
235
+
236
+ ---
237
+
238
+ Continue automatically to the next phase (UI/UX if ui-designer detected, otherwise Design).
@@ -0,0 +1,14 @@
1
+ {
2
+ "sessionId": "",
3
+ "feature": "",
4
+ "phase": "",
5
+ "hooks": [
6
+ {
7
+ "name": "set-terminal-title",
8
+ "event": "UserPromptSubmit",
9
+ "result": "failed",
10
+ "ts": "16:38:44"
11
+ }
12
+ ],
13
+ "skills": []
14
+ }