@polymorphism-tech/morph-spec 4.21.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 (213) 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 -1183
  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 -28
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -210
  35. package/framework/phases.json +40 -114
  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/standards/STANDARDS.json +32 -0
  47. package/framework/standards/frontend/design-system/ai-image-generation.md +244 -0
  48. package/framework/standards/integration/mcp/mcp-tools.md +48 -0
  49. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  50. package/framework/templates/CLAUDE.md.core.template +22 -0
  51. package/framework/templates/REGISTRY.json +4 -4
  52. package/framework/workflows/configs/fast-track.json +5 -10
  53. package/framework/workflows/configs/full.json +4 -8
  54. package/framework/workflows/configs/quick.json +32 -0
  55. package/framework/workflows/configs/standard.json +57 -64
  56. package/package.json +7 -6
  57. package/src/commands/mcp/mcp-setup.js +58 -31
  58. package/src/commands/project/doctor.js +69 -70
  59. package/src/commands/project/init.js +26 -5
  60. package/src/commands/project/status.js +18 -19
  61. package/src/commands/state/approve.js +1 -1
  62. package/src/commands/validation/validate-feature.js +18 -112
  63. package/src/core/paths/output-schema.js +133 -151
  64. package/src/core/state/phase-state-machine.js +10 -24
  65. package/src/core/state/state-manager.js +17 -17
  66. package/src/core/workflows/workflow-detector.js +214 -31
  67. package/src/core/workflows/workflow-router.js +204 -0
  68. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  69. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  70. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  71. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  72. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  73. package/src/dashboard/scanner/agents-scanner.js +30 -35
  74. package/src/lib/agents/metrics-aggregator.js +1 -1
  75. package/src/lib/agents/output-collector.js +7 -8
  76. package/src/lib/context/context-builder.js +289 -0
  77. package/src/lib/detectors/claude-config-detector.js +19 -3
  78. package/src/lib/generators/context-generator.js +20 -42
  79. package/src/lib/generators/index.js +1 -0
  80. package/src/lib/generators/mandate-generator.js +512 -0
  81. package/src/lib/generators/metadata-extractor.js +1 -1
  82. package/src/lib/generators/recap-generator.js +3 -4
  83. package/src/lib/installers/mcp-installer.js +300 -92
  84. package/src/lib/phase-chain/phase-validator.js +36 -40
  85. package/src/lib/stack/stack-profile.js +74 -91
  86. package/src/lib/tasks/task-parser.js +1 -1
  87. package/src/lib/tasks/wave-resolver.js +353 -0
  88. package/src/lib/validators/checkpoint-persistence.js +2 -2
  89. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  90. package/src/lib/validators/content/index.js +1 -0
  91. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  92. package/src/scripts/global-install.js +2 -27
  93. package/src/utils/agents-installer.js +224 -447
  94. package/src/utils/claude-settings-manager.js +57 -15
  95. package/src/utils/file-copier.js +1 -0
  96. package/src/utils/hooks-installer.js +15 -117
  97. package/src/utils/skills-installer.js +12 -18
  98. package/bin/detect-agents.js +0 -226
  99. package/bin/task-manager.js +0 -1036
  100. package/framework/agents/README.md +0 -13
  101. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  102. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  103. package/framework/agents/architecture/architecture-expert.md +0 -98
  104. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  105. package/framework/agents/architecture/packages-validator.md +0 -89
  106. package/framework/agents/architecture/security-expert.md +0 -79
  107. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  108. package/framework/agents/architecture/standards-architect.md +0 -153
  109. package/framework/agents/backend/dotnet-senior.md +0 -163
  110. package/framework/agents/backend/ef-modeler.md +0 -119
  111. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  112. package/framework/agents/backend/ms-agent-expert.md +0 -55
  113. package/framework/agents/backend/neon-expert.md +0 -379
  114. package/framework/agents/frontend/css-specialist.md +0 -89
  115. package/framework/agents/frontend/design-system-validator.md +0 -100
  116. package/framework/agents/frontend/gsap-animator.md +0 -131
  117. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  118. package/framework/agents/frontend/nextjs-expert.md +0 -201
  119. package/framework/agents/frontend/ui-designer.md +0 -259
  120. package/framework/agents/infrastructure/infra-architect.md +0 -215
  121. package/framework/agents/integrations/asaas-financial.md +0 -138
  122. package/framework/agents/integrations/neon-auth.md +0 -151
  123. package/framework/agents/integrations/resend-email.md +0 -127
  124. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  125. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  126. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  127. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  128. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  129. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  130. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  131. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  132. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  133. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  134. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  135. package/framework/hooks/shared/compact-restore.js +0 -123
  136. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  137. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  138. package/framework/hooks/shared/stale-task-reset.js +0 -57
  139. package/framework/hooks/shared/worktree-helpers.js +0 -75
  140. package/framework/skills/level-0-meta/README.md +0 -7
  141. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  142. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  143. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  144. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  145. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  146. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  147. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  148. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  149. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  150. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  151. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  152. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  153. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  154. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  155. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  156. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -382
  157. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  158. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  159. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  160. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  161. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  162. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  163. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  164. package/framework/skills/level-1-workflows/README.md +0 -7
  165. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  166. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  168. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  169. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  170. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  171. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -493
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  173. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -46
  174. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  175. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  176. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  177. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  181. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  182. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  183. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -788
  184. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  185. package/framework/squad-templates/backend-only.json +0 -47
  186. package/framework/squad-templates/frontend-only.json +0 -56
  187. package/framework/squad-templates/full-stack.json +0 -74
  188. package/src/commands/agents/agent-metrics.js +0 -174
  189. package/src/commands/agents/audit-dispatch.js +0 -82
  190. package/src/commands/agents/detect-agents.js +0 -275
  191. package/src/commands/agents/dispatch-agents.js +0 -461
  192. package/src/commands/agents/index.js +0 -13
  193. package/src/commands/agents/manage-agents.js +0 -352
  194. package/src/commands/agents/project-metrics.js +0 -74
  195. package/src/commands/phase/phase-reset.js +0 -74
  196. package/src/commands/scope/escalate.js +0 -217
  197. package/src/commands/state/advance-phase.js +0 -600
  198. package/src/commands/state/phase-runner.js +0 -215
  199. package/src/commands/state/state.js +0 -444
  200. package/src/commands/task/expand.js +0 -100
  201. package/src/commands/tasks/index.js +0 -4
  202. package/src/commands/tasks/task.js +0 -105
  203. package/src/commands/templates/index.js +0 -5
  204. package/src/commands/templates/template-render.js +0 -93
  205. package/src/commands/trust/trust.js +0 -118
  206. package/src/lib/agents/agents-manager.js +0 -349
  207. package/src/lib/build/build-runner.js +0 -99
  208. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  209. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  210. package/src/lib/scope/impact-analyzer.js +0 -106
  211. package/src/lib/trust/trust-manager.js +0 -157
  212. package/src/utils/tier-helpers.js +0 -24
  213. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
package/CLAUDE.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # CLAUDE.md
2
2
 
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3
+ This file provides guidance to Claude Code when working with code in **this repository** (the morph-spec CLI source).
4
4
 
5
5
  ## What This Is
6
6
 
7
- morph-spec is a spec-driven development framework CLI (`@polymorphism-tech/morph-spec`). It orchestrates AI-first feature development through structured phases with approval gates. This repo is the **framework source code** — not a project that uses morph-spec.
7
+ morph-spec is a spec-driven development harness CLI (`@polymorphism-tech/morph-spec` v5). In v5 the CLI is purely an **installer mechanism** — once installed, Claude Code itself executes the workflow autonomously based on `framework/MORPH.md` (the NLH charter) and the core skills.
8
+
9
+ This repo is the **framework source code** — not a project that uses morph-spec.
8
10
 
9
11
  ## Build & Test Commands
10
12
 
@@ -13,14 +15,10 @@ morph-spec is a spec-driven development framework CLI (`@polymorphism-tech/morph
13
15
  npm test
14
16
 
15
17
  # Run a single test file
16
- node --test test/commands/task-done.test.js
17
-
18
- # Run tests matching a name pattern
19
- node --test --test-name-pattern="should advance phase" test/commands/advance-phase.test.js
18
+ node --test test/lib/state-manager.test.js
20
19
 
21
20
  # Coverage
22
- npm run test:coverage # text + html + lcov
23
- npm run test:coverage:summary # text-summary only
21
+ npm run test:coverage
24
22
 
25
23
  # Generate JSDoc API docs
26
24
  npm run docs
@@ -35,109 +33,97 @@ No build step — pure ESM JavaScript, runs directly via Node.js 18+.
35
33
 
36
34
  ### Module Layout
37
35
 
38
- - **`bin/morph-spec.js`** — Commander.js CLI entry point. All commands registered here.
39
- - **`src/commands/`** — CLI command handlers organized by domain (state/, tasks/, agents/, validation/, trust/, etc.)
40
- - **`src/core/`** — Core domain logic (not CLI-coupled):
41
- - `state/state-manager.js` — Atomic state I/O with process-ID temp files to prevent race conditions
42
- - `paths/output-schema.js` — **Single source of truth** for all 15 output types, their filenames, phase directories, and gate associations
36
+ - **`bin/morph-spec.js`** — Commander.js CLI entry point. v5 surface: install/inspect commands only. No more task/phase/dispatch commands.
37
+ - **`src/commands/`** — CLI command handlers organized by domain (project/, state/, validation/, scaffold/, mcp/, context/, dashboard/).
38
+ - **`src/core/`** — Core domain logic:
39
+ - `state/state-manager.js` — Atomic state I/O with process-ID temp files
40
+ - `paths/output-schema.js` — **Single source of truth** for the 13 v5 output types
43
41
  - `templates/` — Handlebars template registry and renderer
44
- - `workflows/` — Workflow type detector (standard vs nodejs-cli)
42
+ - `workflows/` — Workflow type detector
45
43
  - **`src/lib/`** — Libraries and subsystems:
46
- - `validators/` — 25+ data-driven validators (architecture, blazor, css, design-system, nextjs, etc.)
47
- - `generators/` — Code generation (design-system, context, recap, metadata)
48
- - `trust/trust-manager.js` — 3-level trust model (manual/high/auto)
44
+ - `validators/` — Data-driven validators (architecture, css, design-system, nextjs)
45
+ - `generators/` — Code generation (mandate, recap, context)
49
46
  - `stack-filter.js` — Stack-aware asset filtering via YAML frontmatter `stacks:` tags
50
- - `hooks/` — Hook executor
51
- - `installers/` — Agents, skills, hooks installers for target projects
52
- - **`src/utils/`** — Shared utilities (logger, banner, file-copier, claude-settings-manager, etc.)
47
+ - `installers/` — Agents, skills, hooks installers
48
+ - **`src/utils/`** — Shared utilities (logger, banner, file-copier, claude-settings-manager, agents-installer, skills-installer, hooks-installer)
53
49
  - **`framework/`** — Metadata installed into target projects (READ-ONLY at runtime):
54
- - `agents.json` (v4.0.0)
55
- - `phases.json` (7 phases incl. sync)
56
- - `standards/STANDARDS.json`
57
- - `hooks/claude-code/` — Hook scripts (fail-open design)
58
- - `skills/` — Morph skills (level-0-meta + level-1-workflows)
50
+ - `MORPH.md` — NLH charter (the single source of behavioral truth)
51
+ - `CLAUDE.md` — Runtime instructions injected into target's `.claude/CLAUDE.md`
52
+ - `agents.json` (v5.0.0) — 7 domain personas, no tiers
53
+ - `phases.json` — 5 phases (proposal, uiux, plan, implement, review)
54
+ - `standards/STANDARDS.json` — index of available standards
55
+ - `hooks/claude-code/core/` — 6 fail-open guardrail hooks
56
+ - `skills/core/` — 7 core NLH skills (single source of truth)
59
57
  - `templates/` — Handlebars templates for code generation
58
+ - `mcp/registry.json` — MCP server registry
59
+ - `evals/rubrics/` — 4 dimension rubrics for morph-eval
60
60
 
61
61
  ### Key Architectural Patterns
62
62
 
63
- **Dual-layer phase tracking:** Phase is derived from filesystem (`derivePhase()` scans for highest-numbered phase folder) — state.json only overrides for lightweight phases (sync).
63
+ **NLH (Natural Language Harness):** Behavior lives in `framework/MORPH.md` — read once per session by Claude. JS hooks are silent guardrails only, never orchestrators.
64
64
 
65
- **Output schema as single source of truth:** `src/core/paths/output-schema.js` defines all output types. Run `npm run generate` after modifying it to update derived reference files.
65
+ **Output schema as single source of truth:** `src/core/paths/output-schema.js` defines all output types. Run `npm run generate` after modifying it.
66
66
 
67
- **Data-driven validation:** `agents.json` lists validators per agent. The validation runner reads active agents from state and orchestrates only relevant validators.
67
+ **Fail-open hooks:** All hooks check `stateExists()` first and return `{}` if state is missing/corrupt. Hooks never throw or write state.
68
68
 
69
- **Fail-open hooks:** All hooks in `framework/hooks/claude-code/` check `stateExists()` first and return `{}` (empty/pass-through) if state is missing or corrupt. Hooks never throw or write state.
69
+ **Atomic state writes:** `state-manager.js` writes to `${path}.tmp.${pid}` then renames.
70
70
 
71
- **Atomic state writes:** `state-manager.js` writes to a process-ID temp file then renames, preventing corruption from concurrent CLI invocations.
71
+ **Stack-aware filtering:** Assets declare `stacks: ['dotnet']` in YAML frontmatter or `stack: ['dotnet']` in `agents.json`. `setup-infra.js` reads `config.json → project.stack`, splits into tags, and installs only matching assets.
72
72
 
73
- **Stack-aware filtering:** Assets declare `stacks: ['dotnet']` in YAML frontmatter. `setup-infra.js` reads `config.json → project.stack`, splits into tags, and installs only matching assets. `stacks: ['*']` = universal.
73
+ **Personas, not tiers:** `agents.json` has 7 flat domain personas (dotnet-senior, ef-modeler, maf-expert, nextjs-expert, ui-designer, infra-engineer, evaluator). No tier system — Claude assumes the 3 NLH roles (Orchestrator/Specialist/Evaluator) per MORPH.md.
74
74
 
75
75
  ### Phase Sequence
76
76
 
77
77
  ```
78
- proposal → [uiux] → design → plan → tasks → implement → [sync]
78
+ proposal → [uiux] → plan → implement → review
79
79
  ```
80
80
 
81
- Phases in brackets are optional. Approval gates exist at: proposal, design, plan, tasks, uiux.
81
+ Approval gates: Gate 1 (proposal), Gate 2 (plan), Gate 3 (review). `uiux` is optional.
82
82
 
83
83
  ### State Schema (v5.0.0)
84
84
 
85
- State lives in `.morph/state.json` in target projects. Phase and outputs are **derived from filesystem**, not stored in state. State tracks: features (status, activeAgents, taskList, trustConfig, metadata), project info, and version.
85
+ State lives in `.morph/state.json`. Phase derived from filesystem (not stored). State tracks: features (status, taskList, approvalGates, outputs), metadata, version.
86
86
 
87
87
  ## Testing Conventions
88
88
 
89
89
  - **Framework:** Node.js native `node:test` — no Jest or Mocha
90
90
  - **Concurrency:** Always sequential (`--test-concurrency=1`) — tests use `process.chdir()`
91
- - **Temp dirs:** Use `createTempDir()` / `cleanupTempDir()` from `test/helpers/test-utils.js` — creates dirs with `morph-test-` prefix
92
- - **Mock state:** Use `createMockState(overrides)` and `createStateFile(tempDir, state)` from test-utils
93
- - **Pattern:** Each test creates a temp dir, chdir into it, sets up mock state/filesystem, runs the function, asserts, then restores cwd and cleans up in afterEach
91
+ - **Temp dirs:** `createTempDir()` / `cleanupTempDir()` from `test/helpers/test-utils.js`
92
+ - **Mock state:** `createMockState(overrides)` and `createStateFile(tempDir, state)` from test-utils
94
93
 
95
94
  ## Code Conventions
96
95
 
97
- - **ESM only** — all files use `import`/`export`, package.json has `"type": "module"`
98
- - **Output type normalization** — `normalizeOutputType()` auto-converts kebab-case to camelCase via regex
99
- - **Template helpers** — Handlebars v2.0 helpers: pascalCase, camelCase, snakeCase, kebabCase, pluralize, plus comparison/logic helpers
100
- - **CLI structure** — Commands are thin wrappers that delegate to `src/core/` or `src/lib/` modules. Keep business logic out of command files.
96
+ - **ESM only** — `import`/`export`, package.json `"type": "module"`
97
+ - **Output type normalization** — `normalizeOutputType()` auto-converts kebab-case to camelCase
98
+ - **Template helpers** — Handlebars v2.0: pascalCase, camelCase, snakeCase, kebabCase, pluralize, plus comparison/logic helpers
99
+ - **CLI structure** — Commands are thin wrappers; business logic in `src/core/` or `src/lib/`
101
100
 
102
101
  ## Framework Development Guardrails
103
102
 
104
- When modifying framework components, always verify the full scope of related files. A PostToolUse hook (`.claude/hooks/post-tool-use/framework-consistency-guard.js`) will remind you, but you should also proactively check.
103
+ When modifying framework components, verify the full scope of related files.
105
104
 
106
105
  ### Dependency Matrix
107
106
 
108
- | When you modify... | Also verify... |
109
- |---------------------|----------------|
110
- | `framework/agents.json` | squad-templates/*.json, agents-installer.js (tier defaults), advance-phase.js (hardcoded agent lists), doctor.js (REQUIRED_AGENTS), agents-manager.js (validation rules), total_agents/tier counts |
111
- | `framework/standards/**` | STANDARDS.json (entry exists), agents.json (agents reference the standard), .md file exists at declared path |
112
- | `framework/hooks/claude-code/**` | hooks-installer.js (MORPH_HOOKS array + MORPH_PERMISSIONS), hook follows fail-open pattern |
113
- | `framework/skills/**` | phases.json (requiredSkills if phase-bound), skills-installer.js, SKILL.md frontmatter |
114
- | `framework/phases.json` | advance-phase.js, dispatch-agents.js, output-schema.js (phase mappings) |
115
- | `framework/templates/**` | REGISTRY.json (template registered) |
116
- | `src/core/paths/output-schema.js` | Run `npm run generate` to update phase-utils.js and skill markdown blocks |
117
-
118
- ### Per-Domain Checklists
119
-
120
- **Agents** — required fields: tier, title, group, active_phases, reports_to, domains, keywords, validators, standards. If tier 3+: teammate.spawn_prompt. If stack-specific: stacks[]. Update total_agents/tier counts.
121
-
122
- **Standards** — STANDARDS.json entry needs: id, name, path, category, subcategory, tags, digest. At least one agent must reference it. If stack-specific: stacks[].
123
-
124
- **Hooks** — must be in MORPH_HOOKS array in hooks-installer.js. Must follow fail-open pattern. If needs permissions: add to MORPH_PERMISSIONS.
125
-
126
- **Skills** — SKILL.md with valid frontmatter. If phase-bound: in phases.json requiredSkills. If stack-specific: stacks[] frontmatter.
127
-
128
- **Phases** — index/folder consistent. requiredSkills reference existing dirs. advance-phase.js handles transitions.
129
-
130
- **Templates** — registered in REGISTRY.json. Uses only available Handlebars helpers.
131
-
132
- **Output Schema** — always run `npm run generate` after changes.
107
+ | When you modify... | Also verify... |
108
+ |----------------------------------|-------------------------------------------------------------------------------------------|
109
+ | `framework/agents.json` | agents-installer.js (test/utils/agents-installer.test.js), doctor.js (REQUIRED_AGENTS) |
110
+ | `framework/standards/**` | STANDARDS.json entry exists, agents reference standard, .md file exists |
111
+ | `framework/hooks/claude-code/**` | hooks-installer.js MORPH_HOOKS array, hook follows fail-open pattern |
112
+ | `framework/skills/core/**` | MORPH.md skills table, skills-installer.js, SKILL.md frontmatter |
113
+ | `framework/phases.json` | output-schema.js (phase mappings), test/framework/phases.test.js |
114
+ | `framework/templates/**` | REGISTRY.json (template registered), valid Handlebars helpers |
115
+ | `src/core/paths/output-schema.js`| Run `npm run generate` to update phase-utils.js |
116
+ | `framework/MORPH.md` | All core skills (cross-references), CLAUDE.md (slash command list) |
133
117
 
134
118
  ### Test Coverage
135
119
 
136
- Every `src/**/*.js` file should have a corresponding `test/**/*.test.js`. The consistency hook will warn when a test file is missing.
120
+ Every `src/**/*.js` file should have a corresponding `test/**/*.test.js`.
137
121
 
138
122
  ## Framework vs Runtime Distinction
139
123
 
140
- - **This repo** (`morph-spec-framework/`) = the CLI tool source code
124
+ - **This repo** = the CLI source (installer)
141
125
  - **`framework/`** = files installed into target projects via `morph-spec init`
142
- - **`framework/CLAUDE.md`** = the CLAUDE.md injected into target projects (not for this repo)
143
- - When editing `framework/` files, you're changing what gets installed in user projects, not runtime behavior of the CLI itself
126
+ - **`framework/CLAUDE.md`** = injected into target's `.claude/CLAUDE.md` (not for this repo)
127
+ - **`framework/MORPH.md`** = the NLH charter — every behavioral change lands here, not in JS hooks
128
+
129
+ When editing `framework/` files, you're changing what gets installed in user projects, not runtime behavior of the CLI itself.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
4
4
 
5
5
  **Package:** `@polymorphism-tech/morph-spec`
6
- **Version:** 4.21.0
6
+ **Version:** 4.22.1
7
7
  **Requires:** Node.js 18+, Claude Code
8
8
 
9
9
  ---
@@ -364,4 +364,4 @@ Code generated by morph-spec (contracts, templates, implementation output) belon
364
364
 
365
365
  ---
366
366
 
367
- *morph-spec v4.21.0 by [Polymorphism Tech](https://polymorphism.tech)*
367
+ *morph-spec v4.22.1 by [Polymorphism Tech](https://polymorphism.tech)*