@polymorphism-tech/morph-spec 4.22.0 → 5.0.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 (211) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  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 +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1198
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -31
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -243
  35. package/framework/phases.json +41 -115
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  47. package/framework/templates/CLAUDE.md.core.template +22 -0
  48. package/framework/templates/REGISTRY.json +4 -4
  49. package/framework/workflows/configs/fast-track.json +5 -10
  50. package/framework/workflows/configs/full.json +4 -8
  51. package/framework/workflows/configs/quick.json +32 -0
  52. package/framework/workflows/configs/standard.json +57 -64
  53. package/package.json +7 -6
  54. package/src/commands/mcp/mcp-setup.js +58 -31
  55. package/src/commands/project/doctor.js +69 -70
  56. package/src/commands/project/init.js +26 -5
  57. package/src/commands/project/status.js +18 -19
  58. package/src/commands/state/approve.js +1 -1
  59. package/src/commands/validation/validate-feature.js +18 -112
  60. package/src/core/paths/output-schema.js +133 -152
  61. package/src/core/state/phase-state-machine.js +10 -24
  62. package/src/core/state/state-manager.js +17 -17
  63. package/src/core/workflows/workflow-detector.js +214 -31
  64. package/src/core/workflows/workflow-router.js +204 -0
  65. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  66. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  67. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  68. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  69. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  70. package/src/dashboard/scanner/agents-scanner.js +30 -35
  71. package/src/lib/agents/metrics-aggregator.js +1 -1
  72. package/src/lib/agents/output-collector.js +7 -9
  73. package/src/lib/context/context-builder.js +289 -0
  74. package/src/lib/detectors/claude-config-detector.js +19 -3
  75. package/src/lib/generators/context-generator.js +20 -42
  76. package/src/lib/generators/index.js +1 -0
  77. package/src/lib/generators/mandate-generator.js +512 -0
  78. package/src/lib/generators/metadata-extractor.js +1 -1
  79. package/src/lib/generators/recap-generator.js +3 -4
  80. package/src/lib/installers/mcp-installer.js +300 -92
  81. package/src/lib/phase-chain/phase-validator.js +36 -40
  82. package/src/lib/stack/stack-profile.js +74 -91
  83. package/src/lib/tasks/task-parser.js +1 -1
  84. package/src/lib/tasks/wave-resolver.js +353 -0
  85. package/src/lib/validators/checkpoint-persistence.js +2 -2
  86. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  87. package/src/lib/validators/content/index.js +1 -0
  88. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  89. package/src/scripts/global-install.js +2 -27
  90. package/src/utils/agents-installer.js +224 -447
  91. package/src/utils/claude-settings-manager.js +57 -15
  92. package/src/utils/file-copier.js +1 -0
  93. package/src/utils/hooks-installer.js +15 -117
  94. package/src/utils/skills-installer.js +12 -18
  95. package/bin/detect-agents.js +0 -226
  96. package/bin/task-manager.js +0 -1036
  97. package/framework/agents/README.md +0 -13
  98. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  99. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  100. package/framework/agents/architecture/architecture-expert.md +0 -98
  101. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  102. package/framework/agents/architecture/packages-validator.md +0 -89
  103. package/framework/agents/architecture/security-expert.md +0 -79
  104. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  105. package/framework/agents/architecture/standards-architect.md +0 -153
  106. package/framework/agents/backend/dotnet-senior.md +0 -163
  107. package/framework/agents/backend/ef-modeler.md +0 -119
  108. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  109. package/framework/agents/backend/ms-agent-expert.md +0 -55
  110. package/framework/agents/backend/neon-expert.md +0 -379
  111. package/framework/agents/frontend/css-specialist.md +0 -89
  112. package/framework/agents/frontend/design-system-validator.md +0 -100
  113. package/framework/agents/frontend/gsap-animator.md +0 -131
  114. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  115. package/framework/agents/frontend/nextjs-expert.md +0 -201
  116. package/framework/agents/frontend/ui-designer.md +0 -259
  117. package/framework/agents/infrastructure/infra-architect.md +0 -215
  118. package/framework/agents/integrations/asaas-financial.md +0 -138
  119. package/framework/agents/integrations/neon-auth.md +0 -151
  120. package/framework/agents/integrations/resend-email.md +0 -127
  121. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  122. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  123. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  124. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  125. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  126. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  127. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  128. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  129. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  130. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  131. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  132. package/framework/hooks/shared/compact-restore.js +0 -123
  133. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  134. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  135. package/framework/hooks/shared/stale-task-reset.js +0 -57
  136. package/framework/hooks/shared/worktree-helpers.js +0 -75
  137. package/framework/skills/level-0-meta/README.md +0 -7
  138. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  139. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  140. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  141. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  142. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  143. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  144. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  145. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  146. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  147. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  148. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  149. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  150. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  151. package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +0 -290
  152. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  153. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  154. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -401
  155. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  156. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  157. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  158. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  159. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  160. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  161. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  162. package/framework/skills/level-1-workflows/README.md +0 -7
  163. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  164. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  165. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  166. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  168. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  169. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -634
  170. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  171. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -54
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  173. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  174. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  175. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  176. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  177. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  181. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -995
  182. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  183. package/framework/squad-templates/backend-only.json +0 -47
  184. package/framework/squad-templates/frontend-only.json +0 -56
  185. package/framework/squad-templates/full-stack.json +0 -74
  186. package/src/commands/agents/agent-metrics.js +0 -174
  187. package/src/commands/agents/audit-dispatch.js +0 -82
  188. package/src/commands/agents/detect-agents.js +0 -275
  189. package/src/commands/agents/dispatch-agents.js +0 -461
  190. package/src/commands/agents/index.js +0 -13
  191. package/src/commands/agents/manage-agents.js +0 -352
  192. package/src/commands/agents/project-metrics.js +0 -74
  193. package/src/commands/phase/phase-reset.js +0 -74
  194. package/src/commands/scope/escalate.js +0 -217
  195. package/src/commands/state/advance-phase.js +0 -600
  196. package/src/commands/state/phase-runner.js +0 -215
  197. package/src/commands/state/state.js +0 -444
  198. package/src/commands/task/expand.js +0 -100
  199. package/src/commands/tasks/index.js +0 -4
  200. package/src/commands/tasks/task.js +0 -105
  201. package/src/commands/templates/index.js +0 -5
  202. package/src/commands/templates/template-render.js +0 -93
  203. package/src/commands/trust/trust.js +0 -118
  204. package/src/lib/agents/agents-manager.js +0 -349
  205. package/src/lib/build/build-runner.js +0 -99
  206. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  207. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  208. package/src/lib/scope/impact-analyzer.js +0 -106
  209. package/src/lib/trust/trust-manager.js +0 -157
  210. package/src/utils/tier-helpers.js +0 -24
  211. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
@@ -1,537 +0,0 @@
1
- ---
2
- name: morph-init
3
- description: >
4
- LLM-powered project initialization. Installs morph-spec infrastructure if
5
- needed, auto-installs required plugins (superpowers, context7), analyzes any
6
- project structure intelligently, generates rich context/README.md and
7
- config.json, and configures MCPs. Use once per project after installing
8
- @polymorphism-tech/morph-spec. Re-run with /morph-init refresh to update
9
- context as the project evolves.
10
- argument-hint: "[refresh]"
11
- user-invocable: true
12
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep
13
- ---
14
-
15
- # morph-init — LLM-Powered Project Initialization
16
-
17
- > Run once after `npm install @polymorphism-tech/morph-spec`.
18
- > Re-run as `/morph-init refresh` when your project evolves.
19
-
20
- ---
21
-
22
- ## Step 0 — Resolve CLI
23
-
24
- Before running any `morph-spec` command, detect how to invoke the CLI:
25
-
26
- ```bash
27
- # Try local first (project dependency), then global
28
- morph-spec --version
29
- ```
30
-
31
- - If `morph-spec --version` succeeds → use `morph-spec` as the CLI prefix for all commands.
32
- - If it fails → try `morph-spec --version` (global install). If that works → use `morph-spec`.
33
- - If both fail → **STOP** and show:
34
- ```
35
- morph-spec CLI not found. Install it first:
36
- npm install @polymorphism-tech/morph-spec
37
- ```
38
-
39
- Use the resolved CLI prefix (e.g. `morph-spec`) for ALL bash commands in the following steps.
40
-
41
- ---
42
-
43
- ## Step 1 — Required Plugins
44
-
45
- Check for required Claude Code plugins: **superpowers**, **context7**, and **playwright**.
46
-
47
- Read `~/.claude/plugins/installed_plugins.json` and check for:
48
- - `superpowers@claude-plugins-official`
49
- - `context7@claude-plugins-official`
50
- - `playwright@claude-plugins-official`
51
-
52
- For each missing plugin, run:
53
-
54
- ```bash
55
- claude plugin install superpowers@claude-plugins-official
56
- claude plugin install context7@claude-plugins-official
57
- claude plugin install playwright@claude-plugins-official
58
- ```
59
-
60
- **If the command succeeds:** `✓ {plugin} installed. Restart Claude Code after /morph-init completes.`
61
-
62
- **If the command fails:** Show this and **STOP** — do not continue:
63
-
64
- ```
65
- Plugin {plugin} could not be installed automatically.
66
- Run manually and restart Claude Code:
67
- claude plugin install {plugin}
68
- Then re-run /morph-init.
69
- ```
70
-
71
- All three plugins are required. Do not continue if any is missing.
72
-
73
- ---
74
-
75
- ## Step 2 — Infrastructure
76
-
77
- Check if `.morph/` exists in the current directory.
78
-
79
- **If MISSING:**
80
- ```bash
81
- morph-spec setup-infra
82
- ```
83
- Output confirms: `✓ MORPH-SPEC infrastructure installed.`
84
-
85
- **If EXISTS and argument is `refresh`:**
86
- Re-run setup-infra to update framework files, then continue with context/config refresh:
87
- ```bash
88
- morph-spec setup-infra
89
- ```
90
-
91
- **If EXISTS and no argument:**
92
- Ask: *"MORPH already initialized. Refresh context and config? (y/n)"*
93
- If `y` → re-run `morph-spec setup-infra` then continue.
94
- If `n` → STOP.
95
-
96
- ---
97
-
98
- ## Step 3 — Analyze Project
99
-
100
- Gather evidence to build a stack map. Run these in parallel:
101
-
102
- | Tool | Pattern | Signal |
103
- |------|---------|--------|
104
- | `Glob` | `**/package.json` | Detect next, neon, @neondatabase/auth, stripe in deps |
105
- | `Glob` | `**/*.csproj` | .NET projects at any depth |
106
- | `Glob` | `**/next.config.{js,ts,mjs}` | Next.js in any subdirectory |
107
- | `Glob` | `**/components.json` | shadcn/ui |
108
- | `Glob` | `**/docker-compose*.yml` | Container services |
109
- | `Glob` | `database/migrations/**` | Database migrations |
110
- | `Grep` | `DATABASE_URL\|NEON_\|neonctl` | Neon database config |
111
-
112
- | `Glob` | `**/Abstractions/IHandler.cs` | VSA pattern (KanaiyaKatarmal) |
113
- | `Glob` | `**/Pipelines/ValidationDecorator.cs` | VSA pipeline |
114
- | `Glob` | `**/Features/**/*Feature` | VSA feature folder suffix |
115
- | `Read` | `.env.example` | Env vars reveal integrations |
116
- | `Read` | `README.md` | Existing project description |
117
- | `Grep` | `@neondatabase/serverless` | Neon dep in any package.json |
118
- | `Grep` | `@neondatabase/auth\|auth0\|nextauth` | Auth provider |
119
- | `Grep` | `stripe\|asaas` | Payment provider |
120
-
121
- Read each found `package.json` for dependency names. Build an **evidence map**:
122
-
123
- ```
124
- stack: [nextjs, dotnet, ...]
125
- integrations: [neon, docker, neon-auth, ...]
126
- uiLibrary: shadcn | null
127
- monorepo: true | false
128
- frontendPath: src/frontend (if monorepo)
129
- backendPath: src/backend (if monorepo)
130
- architectureStyle: vertical-slice | null ← new
131
- ```
132
-
133
- **VSA detection:** `architectureStyle: "vertical-slice"` if any of these exist:
134
- - `Abstractions/IHandler.cs` found by Glob
135
- - `Pipelines/ValidationDecorator.cs` found by Glob
136
- - 2+ folders with `Feature` suffix in `Features/` (e.g., `BookFeature`, `OrderFeature`)
137
-
138
- ---
139
-
140
- ## Step 4 — Ask Targeted Questions
141
-
142
- **Rule: only ask what cannot be inferred with ≥90% confidence from files.**
143
-
144
- Ask at most 3 questions, only those that apply:
145
-
146
- | # | Question | Condition | Purpose |
147
- |---|----------|-----------|---------|
148
- | 1 | *"In one sentence: what is the main purpose of **[ProjectName]**?"* | Always | README.md Overview |
149
- | 2 | *"Confirmed: frontend at `{frontendPath}`, backend at `{backendPath}`. Correct?"* | Monorepo detected | Validate paths before persisting |
150
- | 3 | *"Neon (cloud PostgreSQL) or self-hosted Postgres?"* | Neon detected | Database configuration |
151
-
152
- Do **not** ask about technology already confirmed by file evidence.
153
-
154
- ---
155
-
156
- ## Step 4.5 — Scaffold Design System
157
-
158
- ### 4.5.0 — Check if DS already exists
159
-
160
- ```
161
- Read: .morph/context/design-system.md
162
- ```
163
-
164
- **If the file EXISTS with non-TODO content in the Aesthetic Direction section:**
165
- → Skip steps 4.5.1–4.5.2. Print: `✓ Design system found — .morph/context/design-system.md`
166
-
167
- ### 4.5.1 — ALWAYS scan for existing CSS tokens
168
-
169
- Search for existing CSS custom properties across the project's frontend directories.
170
-
171
- Glob these patterns (exclude `node_modules/`, `.next/`, `dist/`, `build/`):
172
- ```
173
- wwwroot/**/*.css
174
- wwwroot/**/*.scss
175
- styles/**/*.css
176
- src/styles/**/*.css
177
- src/**/*.css
178
- src/**/*.scss
179
- src/**/*.module.css
180
- public/**/*.css
181
- ```
182
-
183
- For each CSS/SCSS file found, Grep for `:root {` blocks containing `--` custom properties.
184
-
185
- Track:
186
- - `cssTokensFound` (bool)
187
- - `tokenCount` (int — total number of `--variable` lines found)
188
- - `sourceFiles` (array of file paths that had tokens)
189
-
190
- ### 4.5.2 — Decision tree
191
-
192
- **Case A: CSS tokens found (existing project)**
193
-
194
- 1. Create `.morph/context/design-system.md` from scanned tokens:
195
- - `## Color Tokens` → `:root { }` block with all found color variables (preserve exact variable names from CSS)
196
- - `## Typography` → found font-family values (map to `--font-display` / `--font-body` by variable name heuristic)
197
- - `## Spacing Tokens` → found spacing variables
198
- - `## Aesthetic Direction` → `#TODO` (requires user judgment — fill in during `/morph-phase-uiux`)
199
- - `## Changelog` → `- [today's date] [morph-init] Auto-generated from CSS scan ([N] tokens from [files])`
200
-
201
- 2. Skip the `AskUserQuestion` for direction/brand color — the project has established colors
202
-
203
- 3. Print:
204
- ```
205
- ✓ Design system scaffolded from existing CSS
206
- Source: [file list]
207
- Tokens: [N] colors, [M] font families, [K] spacing values
208
- Note: Aesthetic Direction is TODO — fill in during /morph-phase-uiux
209
- ```
210
-
211
- 4. Continue to Step 5.
212
-
213
- **Case B: No CSS tokens found (greenfield project)**
214
-
215
- 1. Copy the template:
216
- ```bash
217
- cp .morph/framework/templates/context/design-system.md .morph/context/design-system.md
218
- ```
219
- *(The template is at `framework/templates/context/design-system.md` in the installed framework)*
220
-
221
- 2. Ask 3 quick questions using `AskUserQuestion`:
222
-
223
- ```json
224
- {
225
- "questions": [
226
- {
227
- "header": "Design System Setup",
228
- "question": "Let's set up your project's design system. What is the aesthetic direction for [ProjectName]?",
229
- "multiSelect": false,
230
- "options": [
231
- { "label": "Minimal Refined", "description": "Luxurious and precise — elegant serif + light sans, monochromatic + 1 sharp accent" },
232
- { "label": "Editorial", "description": "Magazine-grade, opinionated — strong display font + high contrast, dramatic reveals" },
233
- { "label": "Soft Professional", "description": "Warm and trustworthy — rounded sans + warm pastels, gentle micro-interactions" },
234
- { "label": "Industrial", "description": "Technical and direct — monospace/condensed + neutral colors, minimal motion" },
235
- { "label": "Modern Luxury", "description": "Exclusive and refined — italic display + dark background + gold/copper accent" },
236
- { "label": "Skip for now", "description": "Leave as TODO — fill in manually later" }
237
- ]
238
- }
239
- ]
240
- }
241
- ```
242
-
243
- 3. **If user chose a direction (not "Skip for now")**, ask a follow-up:
244
-
245
- ```json
246
- {
247
- "questions": [
248
- {
249
- "header": "Brand Color",
250
- "question": "What is your approximate dominant/primary color? (You can adjust exact values later)",
251
- "multiSelect": false,
252
- "options": [
253
- { "label": "Deep blue/navy", "description": "Professional, trustworthy" },
254
- { "label": "Rich green", "description": "Growth, sustainability" },
255
- { "label": "Warm orange/red", "description": "Energy, urgency" },
256
- { "label": "Cool purple/violet", "description": "Creative, premium" },
257
- { "label": "True black/dark", "description": "Minimal, premium, editorial" },
258
- { "label": "I'll specify manually", "description": "Leave as TODO" }
259
- ]
260
- }
261
- ]
262
- }
263
- ```
264
-
265
- 4. Fill in the design-system.md with user responses:
266
-
267
- | User answered | What to update |
268
- |--------------|----------------|
269
- | Direction chosen | Replace `[Minimal Refined / Editorial / ...]` with chosen direction. Update Font Pair with the correct fonts: Minimal Refined → Cormorant Garamond + DM Sans; Editorial → Playfair Display + Source Sans 3; Soft Professional → Nunito + Inter; Industrial → JetBrains Mono + IBM Plex Sans; Modern Luxury → Bodoni Moda + Sora |
270
- | Color chosen | Replace `--color-primary: #TODO` with a reasonable hex for that color family: deep blue → #1e3a5f, rich green → #065f46, warm orange → #c2410c, purple → #6d28d9, black → #0a0a0a. Add note: "Adjust exact values to match your brand" |
271
- | "Skip for now" | Leave all TODOs in place |
272
-
273
- 5. Update the Changelog in design-system.md:
274
- Add entry: `- [today's date] [morph-init] Initial scaffold from morph-init`
275
-
276
- 6. Print confirmation:
277
- ```
278
- ✓ Design system scaffolded — .morph/context/design-system.md
279
- Direction: [chosen direction or "TODO — fill in manually"]
280
- Edit to refine exact token values before the UI/UX phase.
281
- ```
282
-
283
- 7. Continue to Step 5.
284
-
285
- ---
286
-
287
- ## Step 5 — Generate `context/README.md`
288
-
289
- Write `.morph/context/README.md`:
290
-
291
- ```markdown
292
- # [ProjectName] — Project Context
293
-
294
- ## Overview
295
- [Answer from question 1]
296
-
297
- ## Tech Stack
298
- | Layer | Technology | Location |
299
- |------------|-----------|----------|
300
- [One row per detected layer — frontend, backend, database, UI library, auth, payments]
301
-
302
- ## Architecture
303
- [monorepo / single-stack / etc — describe layers and responsibilities]
304
-
305
- ## Key Integrations
306
- [Per integration: service → purpose → detected via: evidence file/dep]
307
-
308
- ## Agent Notes
309
- [Patterns from eslint/tsconfig/.editorconfig, important paths,
310
- project-specific conventions for MORPH agents]
311
- ```
312
-
313
- ---
314
-
315
- ## Step 6 — Update `config.json`
316
-
317
- Read `.morph/config/config.json` and merge into `project`:
318
-
319
- ```json
320
- {
321
- "framework": "global",
322
- "frameworkVersion": "[current version]",
323
- "project": {
324
- "name": "[ProjectName]",
325
- "description": "[answer from question 1]",
326
- "stack": "[stacks joined with +, e.g. nextjs+dotnet]",
327
- "architecture": "[monorepo | single-stack | detected pattern]",
328
- "uiLibrary": "[detected or null]",
329
- "integrations": ["neon", "docker", "neon-auth"],
330
- "frontendPath": "[path if monorepo, else omit]",
331
- "backendPath": "[path if monorepo, else omit]"
332
- }
333
- }
334
- ```
335
-
336
- **If `architectureStyle: "vertical-slice"` was detected in Step 3**, also add:
337
-
338
- ```json
339
- {
340
- "architecture": {
341
- "style": "vertical-slice"
342
- }
343
- }
344
- ```
345
-
346
- And inform the user:
347
-
348
- ```
349
- ✓ Detected: Vertical Slice Architecture (IHandler.cs / *Feature folders)
350
- → config.json: architecture.style = "vertical-slice"
351
- → morph-spec will use dotnet-senior + contracts-vsa.cs for features
352
- ```
353
-
354
- > This key is what activates `dotnet-senior` (VSA mode) during `/morph-proposal`.
355
-
356
- **If the project doesn't exist yet (new VSA project from scratch)**, also inform:
357
-
358
- ```
359
- To create a new VSA project:
360
- dotnet new install https://github.com/polymorphism-tech/Morph_Template_VerticalSliceArchitecture
361
- dotnet new vsa -n MyProject
362
- cd MyProject && morph-spec init
363
- ```
364
-
365
- ---
366
-
367
- ## Step 6.5 — Reinstall Stack-Filtered Assets
368
-
369
- Now that config.json has the correct `project.stack` and `project.integrations`,
370
- re-install stack-aware assets (rules, skills, agents) with the correct stack tags:
371
-
372
- ```bash
373
- morph-spec setup-infra --reinstall
374
- ```
375
-
376
- This re-runs only the stack-aware installation steps (rules, skills, tier 1-4 agents,
377
- domain agents) using projectTags derived from the updated config.json.
378
- Infrastructure steps (directory creation, framework copy, hooks) are skipped.
379
-
380
- Output confirms: `✓ setup-infra (reinstall): complete.`
381
-
382
- ---
383
-
384
- ## Step 7 — Configure MCPs
385
-
386
- For each detected integration with an available MCP:
387
-
388
- **Neon detected:**
389
- > *"Neon database detected. Use `neonctl` for branch management and `psql` for direct database operations."*
390
- > No MCP configuration needed — CLI is the primary tool for Neon interaction.
391
-
392
- **GitHub:**
393
- > *"Configure GitHub MCP? Requires Docker + a `GITHUB_PERSONAL_ACCESS_TOKEN`."*
394
- - YES → collect token → write Docker config:
395
- ```json
396
- "github": {
397
- "command": "docker",
398
- "args": ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
399
- "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "<token>" }
400
- }
401
- ```
402
- - NO → show snippet + `morph-spec mcp setup github`
403
-
404
- **Vercel detected** (vercel.json exists OR stack is nextjs):
405
- > *"Configure Vercel MCP? Uses OAuth — no credentials needed."*
406
- - YES → write remote config:
407
- ```json
408
- "vercel": { "type": "http", "url": "https://mcp.vercel.com" }
409
- ```
410
- - NO → show snippet + `morph-spec mcp setup vercel`
411
-
412
- **Asaas detected** (integrations includes "asaas"):
413
- > *"Configure Asaas MCP? Provides API docs, schemas, and code examples for the Asaas payments API."*
414
- - YES → write config to `.claude/settings.local.json`:
415
- ```json
416
- "asaas": { "type": "http", "url": "https://docs.asaas.com/mcp" }
417
- ```
418
- - NO → skip (use WebFetch on https://docs.asaas.com for API docs)
419
-
420
- Only offer Docker, Azure if explicitly detected in `.env.example`.
421
-
422
- > **Format rules for MCP configs:**
423
- >
424
- > **Remote MCPs** (Vercel) — no credentials, OAuth-based:
425
- > ```json
426
- > "mcp-name": { "type": "http", "url": "https://mcp.example.com" }
427
- > ```
428
- >
429
- > **Stdio MCPs** (Context7, Playwright) — local process with `cmd /c` on Windows:
430
- > ```json
431
- > "mcp-name": {
432
- > "command": "cmd",
433
- > "args": ["/c", "npx", "-y", "@package/mcp-server"],
434
- > "env": { "KEY": "VALUE" }
435
- > }
436
- > ```
437
- >
438
- > **Docker MCPs** (GitHub) — Docker container:
439
- > ```json
440
- > "mcp-name": {
441
- > "command": "docker",
442
- > "args": ["run", "-i", "--rm", "-e", "TOKEN_VAR", "ghcr.io/org/image"],
443
- > "env": { "TOKEN_VAR": "<value>" }
444
- > }
445
- > ```
446
- >
447
- > **Never** use `"command": "cmd /c"` (space-separated string) — that is invalid and will fail.
448
- > **Never** use `"command": "npx"` directly — it also fails on Windows without `cmd`.
449
-
450
- ---
451
-
452
- ## Step 7.5 — Validate MCP Connections
453
-
454
- For each MCP configured in Step 7, run a health check to verify it actually works.
455
-
456
- **Read the registry:** `framework/skills/level-0-meta/mcp-registry.json` → for each configured MCP, get its `healthCheck` object.
457
-
458
- **For each configured MCP:**
459
-
460
- 1. **Find available tool:** Search your available tools for one matching `healthCheck.toolPattern` (substring match — e.g., tool name contains "context7")
461
- 2. **If tool found → execute the test call:** Follow `healthCheck.testCall` using `healthCheck.testParams`
462
- 3. **Evaluate result:**
463
-
464
- | Result | Action |
465
- |--------|--------|
466
- | **Success** (matches `healthCheck.successIndicator`) | Print `✓ {MCP} — connection verified` |
467
- | **Tool not found** (no tool matching `toolPattern`) | Print `○ {MCP} — needs restart to activate` (MCP configured but tools not yet loaded) |
468
- | **Error** (tool found but call fails) | → **AskUserQuestion** (see below) |
469
-
470
- **On error — ask user with 3 options:**
471
-
472
- Use `AskUserQuestion` with header `"{MCP} failed"` and these options:
473
- - **Reconfigure credentials** — Loop back to Step 7 for this specific MCP. Maximum 2 retries per MCP. After 2 failures, force option 2.
474
- - **Continue without {MCP}** — Show the `fallback` field from the registry (e.g., "WebSearch + WebFetch for library documentation") and proceed.
475
- - **Stop init** — Abort initialization. User must fix MCP configuration manually and re-run `/morph-init`.
476
-
477
- **Retry tracking:** Keep a counter per MCP. On the 2nd failure for the same MCP, skip the "Reconfigure" option and only offer "Continue without" or "Stop".
478
-
479
- ---
480
-
481
- ## Step 7.7 — Run Doctor
482
-
483
- After all configuration is complete, run the health check to verify everything is properly installed:
484
-
485
- ```bash
486
- morph-spec doctor
487
- ```
488
-
489
- This validates: config.json integrity, agents.json presence, hooks installation, skills distribution, required command files, and state.json schema version. Fix any reported issues before proceeding.
490
-
491
- ---
492
-
493
- ## Step 7.8 — Workflow Selection
494
-
495
- If the project stack suggests a non-standard workflow, ask the user:
496
-
497
- | Stack | Default Workflow | Alternative |
498
- |-------|-----------------|-------------|
499
- | Simple feature | `fast-track` (proposal → tasks → implement) | `standard` |
500
- | Medium feature | `standard` (proposal → design → plan → tasks → implement) | `full` |
501
- | Complex feature | `full` (all phases including uiux + sync) | — |
502
-
503
- For Node.js CLI projects, update config:
504
- ```json
505
- { "workflow": "nodejs-cli" }
506
- ```
507
-
508
- ---
509
-
510
- ## Step 8 — Final Output
511
-
512
- Before printing the summary, check `~/.claude/settings.local.json` for `env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`. If set to `"1"`, mark Agent Teams as enabled; otherwise show the warning.
513
-
514
- **Important:** Report the `morph-spec doctor` output verbatim. Do NOT fabricate or reinterpret warnings about missing agents — the doctor check is authoritative. If doctor reports no issues, do not add your own warnings.
515
-
516
- ```
517
- ✓ Plugins: superpowers ✓ context7 ✓ playwright ✓
518
- ✓ Infrastructure: .morph/ structure, hooks, agents, rules, skills
519
- ✓ Agents: [N] total ([T1] orchestrators, [T2] domain leaders, [S] specialists)
520
- ✓ context/README.md generated
521
- ✓ config.json updated
522
- Stack: [stack] | Architecture: [architecture]
523
- Integrations: [list]
524
- ✓ MCPs: [configured list] ([N verified] / [M needs restart] / [K failed])
525
-
526
- [If CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = "1":]
527
- ✓ Agent Teams: enabled
528
-
529
- [If CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is NOT set:]
530
- ⚠ Agent Teams not enabled. Multi-agent workflows require:
531
- ~/.claude/settings.local.json → {"env": {"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"}}
532
-
533
- [If any plugin was newly installed:]
534
- ○ Restart Claude Code to activate newly installed plugins.
535
-
536
- Next: /morph-proposal [feature-name]
537
- ```