@polymorphism-tech/morph-spec 10.12.0 → 11.0.0

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 (323) hide show
  1. package/CLAUDE.md +27 -57
  2. package/README.md +51 -340
  3. package/bin/morph-spec.js +22 -373
  4. package/docs/CHEATSHEET.md +37 -166
  5. package/docs/QUICKSTART.md +14 -74
  6. package/framework/CLAUDE.md +15 -26
  7. package/framework/MORPH.md +34 -101
  8. package/framework/agents.json +8 -8
  9. package/framework/commands/morph-apply.md +5 -5
  10. package/framework/commands/morph-infra.md +1 -1
  11. package/framework/docs/CLI.md +74 -886
  12. package/framework/evals/review-checklist.md +14 -14
  13. package/framework/hooks/README.md +21 -189
  14. package/framework/hooks/claude-code/core/README.md +2 -5
  15. package/framework/hooks/claude-code/core/conventional-commit.js +2 -2
  16. package/framework/hooks/claude-code/core/denylist.json +3 -3
  17. package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
  18. package/framework/hooks/claude-code/core/masked-exit.js +6 -6
  19. package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
  20. package/framework/hooks/claude-code/core/protect-spec-files.js +17 -61
  21. package/framework/hooks/claude-code/core/stack-changed.js +35 -0
  22. package/framework/hooks/claude-code/core/validate-completion.js +31 -86
  23. package/framework/hooks/shared/{heavy-command.js → command-kind.js} +6 -79
  24. package/framework/hooks/shared/command-tokens.js +0 -139
  25. package/framework/hooks/shared/contract.js +14 -0
  26. package/framework/hooks/shared/feature-slug.js +21 -0
  27. package/framework/hooks/shared/frontend-locations.js +0 -1
  28. package/framework/hooks/shared/git-paths.js +0 -15
  29. package/framework/hooks/shared/graph-freshness.js +0 -19
  30. package/framework/hooks/shared/hook-response.js +0 -7
  31. package/framework/hooks/shared/morph-cli.js +2 -81
  32. package/framework/hooks/shared/owner-words.js +2 -120
  33. package/framework/hooks/shared/payload-utils.js +0 -39
  34. package/framework/hooks/shared/report-progress.js +7 -101
  35. package/framework/hooks/statusline.js +16 -60
  36. package/framework/mcp/registry.json +2 -2
  37. package/framework/rules/ai-agents-standards.md +1 -1
  38. package/framework/rules/asaas-standards.md +1 -1
  39. package/framework/rules/ef-standards.md +1 -1
  40. package/framework/rules/gsap-standards.md +1 -1
  41. package/framework/rules/hangfire-standards.md +1 -1
  42. package/framework/rules/implement-report.md +3 -3
  43. package/framework/rules/neon-auth-standards.md +1 -1
  44. package/framework/rules/nextjs-standards.md +1 -1
  45. package/framework/rules/plan-grammar.md +13 -11
  46. package/framework/rules/resend-standards.md +1 -1
  47. package/framework/rules/ui-design.md +4 -0
  48. package/framework/schemas/config.schema.json +95 -310
  49. package/framework/skills/README.md +12 -32
  50. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  51. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  52. package/framework/skills/core/morph-apply/SKILL.md +21 -46
  53. package/framework/skills/core/morph-plan/SKILL.md +28 -63
  54. package/framework/skills/core/morph-uiux/SKILL.md +23 -25
  55. package/framework/{templates/docs/ui-mockups.md → skills/core/morph-uiux/references/mockups.md} +4 -4
  56. package/framework/standards/STANDARDS.json +10 -11
  57. package/framework/standards/STANDARDS.meta.json +1 -1
  58. package/framework/standards/ai-agents/evals-with-cache.md +18 -32
  59. package/framework/standards/ai-agents/observability-patterns.md +2 -2
  60. package/framework/standards/architecture/code-comments.md +2 -5
  61. package/framework/standards/architecture/engineering-lens.md +1 -1
  62. package/framework/standards/backend/dotnet/testing.md +4 -4
  63. package/framework/standards/frontend/nextjs/lint.md +24 -10
  64. package/framework/standards/frontend/nextjs/testing.md +2 -2
  65. package/framework/standards/infrastructure/docker/local-compose-isolation.md +14 -30
  66. package/framework/templates/CLAUDE.md.core.guide.md +2 -2
  67. package/framework/templates/README.md +1 -1
  68. package/framework/templates/REGISTRY.json +3 -33
  69. package/framework/templates/docs/plan.md +3 -2
  70. package/framework/templates/dotnet/ai-kit/README.md +2 -4
  71. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +1 -1
  72. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +1 -1
  73. package/package.json +1 -2
  74. package/src/commands/graph/explain.js +2 -1
  75. package/src/commands/graph/status.js +2 -1
  76. package/src/commands/mcp/mcp-setup.js +1 -2
  77. package/src/commands/project/doctor.js +5 -341
  78. package/src/commands/project/env.js +21 -52
  79. package/src/commands/project/init-contract.js +47 -0
  80. package/src/commands/project/init.js +36 -66
  81. package/src/commands/project/stack-scan.js +1 -1
  82. package/src/commands/project/update.js +15 -50
  83. package/src/commands/validation/check.js +128 -0
  84. package/src/commands/validation/plan-check.js +41 -64
  85. package/src/commands/validation/prove-red.js +1 -1
  86. package/src/core/paths/output-schema.js +0 -22
  87. package/src/core/templates/template-renderer.js +0 -14
  88. package/src/lib/ai/ai-project-scan.js +1 -6
  89. package/src/lib/check/attempts.js +38 -0
  90. package/src/lib/check/signals.js +145 -0
  91. package/src/lib/config/project-config.js +13 -0
  92. package/src/lib/contract/apply.js +62 -0
  93. package/src/lib/contract/defaults.js +96 -0
  94. package/src/lib/contract/merge.js +79 -0
  95. package/src/lib/contract/ports.js +43 -0
  96. package/src/lib/contract/scan.js +102 -0
  97. package/src/lib/detectors/claude-config-detector.js +7 -0
  98. package/src/lib/{procs → detectors}/mcp-config.js +1 -37
  99. package/src/lib/diff/diff-lines.js +64 -0
  100. package/src/lib/generators/architecture-scanner.js +1 -1
  101. package/src/lib/generators/scaffold-generator.js +0 -7
  102. package/src/lib/git/default-branch.js +0 -122
  103. package/src/lib/graph/diff-tree.js +2 -1
  104. package/src/lib/graph/god-nodes.js +2 -1
  105. package/src/lib/graph/graphify-runtime.js +0 -1
  106. package/src/lib/graph/graphifyignore.js +1 -1
  107. package/src/lib/graph/sanitize.js +2 -8
  108. package/src/lib/installers/memory-installer.js +15 -30
  109. package/src/lib/installers/stack-sync.js +16 -9
  110. package/src/lib/plan/checks.js +20 -64
  111. package/src/lib/plan/media.js +1 -1
  112. package/src/lib/plan/plan-parser.js +5 -5
  113. package/src/lib/review-reports.js +3 -77
  114. package/src/lib/scan/worktree-dirs.js +3 -0
  115. package/src/lib/specs/adr-index.js +2 -2
  116. package/src/lib/stack/dotnet-build-ignores.js +10 -2
  117. package/src/lib/stack/stack-scan.js +2 -2
  118. package/src/lib/stack-filter.js +3 -2
  119. package/src/lib/tests-audit/audit.js +1 -1
  120. package/src/scripts/setup-infra.js +6 -59
  121. package/src/utils/agents-installer.js +1 -34
  122. package/src/utils/atomic-json.js +27 -0
  123. package/src/utils/file-copier.js +4 -12
  124. package/src/utils/hooks-installer.js +9 -107
  125. package/claude-plugin.json +0 -14
  126. package/framework/commands/morph-archive.md +0 -46
  127. package/framework/commands/morph-hotfix.md +0 -17
  128. package/framework/commands/morph-preflight.md +0 -180
  129. package/framework/commands/morph-review.md +0 -15
  130. package/framework/commands/morph-status.md +0 -37
  131. package/framework/hooks/claude-code/core/block-destructive-worktree-removal.js +0 -80
  132. package/framework/hooks/claude-code/core/block-raw-worktree-add.js +0 -72
  133. package/framework/hooks/claude-code/core/enforce-phase-writes.js +0 -100
  134. package/framework/hooks/claude-code/core/gate-guard.js +0 -148
  135. package/framework/hooks/claude-code/core/heavy-gate.js +0 -78
  136. package/framework/hooks/claude-code/core/heavy-release.js +0 -23
  137. package/framework/hooks/claude-code/core/loop-detect.js +0 -79
  138. package/framework/hooks/claude-code/core/state-sync.js +0 -214
  139. package/framework/hooks/claude-code/core/telemetry-log.js +0 -259
  140. package/framework/hooks/claude-code/core/test-budget.js +0 -29
  141. package/framework/hooks/claude-code/core/worktree-context.js +0 -249
  142. package/framework/hooks/claude-code/core/worktree-create.js +0 -119
  143. package/framework/hooks/claude-code/core/worktree-env-inject.js +0 -68
  144. package/framework/hooks/claude-code/core/worktree-remove.js +0 -55
  145. package/framework/hooks/shared/build-check.js +0 -120
  146. package/framework/hooks/shared/claim-registry.js +0 -125
  147. package/framework/hooks/shared/e2e-check.js +0 -1022
  148. package/framework/hooks/shared/feature-locator.js +0 -82
  149. package/framework/hooks/shared/gate-event.js +0 -18
  150. package/framework/hooks/shared/gate-question.js +0 -20
  151. package/framework/hooks/shared/heavy-config.js +0 -113
  152. package/framework/hooks/shared/heavy-holders.js +0 -85
  153. package/framework/hooks/shared/heavy-slots.js +0 -280
  154. package/framework/hooks/shared/host-services.js +0 -440
  155. package/framework/hooks/shared/next-step.js +0 -181
  156. package/framework/hooks/shared/redact-secrets.js +0 -44
  157. package/framework/hooks/shared/reparse-scan.js +0 -40
  158. package/framework/hooks/shared/state-reader.js +0 -220
  159. package/framework/hooks/shared/state-writer.js +0 -112
  160. package/framework/hooks/shared/telemetry-logger.js +0 -101
  161. package/framework/hooks/shared/transcript-usage.js +0 -58
  162. package/framework/hooks/shared/worktree-root.js +0 -71
  163. package/framework/phases.json +0 -92
  164. package/framework/schemas/feature.schema.json +0 -242
  165. package/framework/skills/core/morph-apply/references/hotfix.md +0 -46
  166. package/framework/skills/core/morph-apply/references/machine.md +0 -30
  167. package/framework/skills/core/morph-apply/references/review.md +0 -77
  168. package/framework/skills/core/morph-plan/references/critique.md +0 -51
  169. package/framework/skills/core/morph-plan/references/interview.md +0 -37
  170. package/framework/templates/state.template.json +0 -17
  171. package/src/commands/dashboard/dashboard.js +0 -74
  172. package/src/commands/e2e/e2e.js +0 -400
  173. package/src/commands/observability/cost.js +0 -283
  174. package/src/commands/project/branch.js +0 -129
  175. package/src/commands/project/claim.js +0 -132
  176. package/src/commands/project/doctor-procs.js +0 -162
  177. package/src/commands/project/fleet.js +0 -66
  178. package/src/commands/project/heavy.js +0 -81
  179. package/src/commands/project/install-plugin-cmd.js +0 -27
  180. package/src/commands/project/status.js +0 -61
  181. package/src/commands/project/worktree.js +0 -1234
  182. package/src/commands/state/advance.js +0 -248
  183. package/src/commands/state/approve.js +0 -303
  184. package/src/commands/state/archive.js +0 -231
  185. package/src/commands/state/auto-approval.js +0 -67
  186. package/src/commands/state/create.js +0 -274
  187. package/src/commands/state/delete.js +0 -192
  188. package/src/commands/state/finish.js +0 -1247
  189. package/src/commands/state/gate-check.js +0 -244
  190. package/src/commands/state/gate-decision.js +0 -122
  191. package/src/commands/state/list.js +0 -244
  192. package/src/commands/state/next.js +0 -24
  193. package/src/commands/state/recap.js +0 -80
  194. package/src/commands/state/report-check.js +0 -244
  195. package/src/commands/state/retype.js +0 -110
  196. package/src/commands/validation/verify.js +0 -421
  197. package/src/core/state/feature-identity.js +0 -10
  198. package/src/core/state/gate-order.js +0 -23
  199. package/src/core/state/lifecycle-audit.js +0 -171
  200. package/src/core/state/state-manager.js +0 -523
  201. package/src/core/templates/template-seed.js +0 -21
  202. package/src/core/work-types.js +0 -44
  203. package/src/dashboard/app/App.jsx +0 -84
  204. package/src/dashboard/app/components/ActivityFeed.jsx +0 -166
  205. package/src/dashboard/app/components/CommandPalette.jsx +0 -144
  206. package/src/dashboard/app/components/DetailPanel.jsx +0 -43
  207. package/src/dashboard/app/components/EntityLink.jsx +0 -42
  208. package/src/dashboard/app/components/ErrorBoundary.jsx +0 -47
  209. package/src/dashboard/app/components/FlowGraph.jsx +0 -19
  210. package/src/dashboard/app/components/GatePauses.jsx +0 -116
  211. package/src/dashboard/app/components/KnowledgeMarkdown.jsx +0 -42
  212. package/src/dashboard/app/components/Markdown.jsx +0 -38
  213. package/src/dashboard/app/components/PhaseRail.jsx +0 -100
  214. package/src/dashboard/app/components/SearchFilter.jsx +0 -36
  215. package/src/dashboard/app/components/SessionMap.jsx +0 -77
  216. package/src/dashboard/app/components/Sidebar.jsx +0 -147
  217. package/src/dashboard/app/hooks/useMorphQuery.js +0 -44
  218. package/src/dashboard/app/hooks/usePref.js +0 -34
  219. package/src/dashboard/app/lib/format.js +0 -69
  220. package/src/dashboard/app/lib/phases.js +0 -75
  221. package/src/dashboard/app/lib/project.js +0 -38
  222. package/src/dashboard/app/main.jsx +0 -13
  223. package/src/dashboard/app/pages/Activity.jsx +0 -28
  224. package/src/dashboard/app/pages/AgentMap.jsx +0 -363
  225. package/src/dashboard/app/pages/FeatureDetail.jsx +0 -579
  226. package/src/dashboard/app/pages/Features.jsx +0 -393
  227. package/src/dashboard/app/pages/Guide.jsx +0 -145
  228. package/src/dashboard/app/pages/HookInspector.jsx +0 -444
  229. package/src/dashboard/app/pages/PhasePipeline.jsx +0 -273
  230. package/src/dashboard/app/pages/Portfolio.jsx +0 -190
  231. package/src/dashboard/app/pages/RulesMap.jsx +0 -285
  232. package/src/dashboard/app/pages/SkillsLibrary.jsx +0 -468
  233. package/src/dashboard/app/pages/Standards.jsx +0 -392
  234. package/src/dashboard/app/styles/index.css +0 -187
  235. package/src/dashboard/index.html +0 -14
  236. package/src/dashboard/package.json +0 -32
  237. package/src/dashboard/scanner/activity-scanner.js +0 -321
  238. package/src/dashboard/scanner/agents-scanner.js +0 -67
  239. package/src/dashboard/scanner/docs-scanner.js +0 -34
  240. package/src/dashboard/scanner/feature-status.js +0 -7
  241. package/src/dashboard/scanner/features-scanner.js +0 -397
  242. package/src/dashboard/scanner/hooks-scanner.js +0 -96
  243. package/src/dashboard/scanner/index.js +0 -21
  244. package/src/dashboard/scanner/phases-scanner.js +0 -14
  245. package/src/dashboard/scanner/portfolio.js +0 -129
  246. package/src/dashboard/scanner/project-api.js +0 -160
  247. package/src/dashboard/scanner/rules-scanner.js +0 -46
  248. package/src/dashboard/scanner/skills-scanner.js +0 -104
  249. package/src/dashboard/scanner/standards-scanner.js +0 -38
  250. package/src/dashboard/vite-plugin-morph-data.js +0 -120
  251. package/src/dashboard/vite.config.js +0 -26
  252. package/src/lib/ci/ci-verify.js +0 -30
  253. package/src/lib/ci/github-ci.js +0 -52
  254. package/src/lib/ci/pr-checks.js +0 -76
  255. package/src/lib/e2e/applicability.js +0 -39
  256. package/src/lib/e2e/compose-env.js +0 -80
  257. package/src/lib/e2e/stack-teardown.js +0 -96
  258. package/src/lib/git/branch-classifier.js +0 -104
  259. package/src/lib/git/evidence-staleness.js +0 -40
  260. package/src/lib/git/gh.js +0 -15
  261. package/src/lib/git/pending-prs.js +0 -58
  262. package/src/lib/git/pr-files.js +0 -31
  263. package/src/lib/git/pr-index.js +0 -39
  264. package/src/lib/git/tree-fingerprint.js +0 -58
  265. package/src/lib/git/tree-state.js +0 -125
  266. package/src/lib/heavy/cleanup.js +0 -72
  267. package/src/lib/heavy/gate.js +0 -168
  268. package/src/lib/heavy/live-stacks.js +0 -64
  269. package/src/lib/heavy/reclaim.js +0 -107
  270. package/src/lib/heavy/watchdog.js +0 -46
  271. package/src/lib/next-step.js +0 -12
  272. package/src/lib/plan/critique.js +0 -67
  273. package/src/lib/plan/plan-template.js +0 -18
  274. package/src/lib/procs/classify.js +0 -91
  275. package/src/lib/procs/list.js +0 -124
  276. package/src/lib/procs/prune.js +0 -47
  277. package/src/lib/procs/wslconfig.js +0 -70
  278. package/src/lib/projects/registry.js +0 -121
  279. package/src/lib/recap/piper.js +0 -36
  280. package/src/lib/recap/recap.js +0 -259
  281. package/src/lib/review-confirmation.js +0 -66
  282. package/src/lib/risk/diff-risk.js +0 -137
  283. package/src/lib/risk-detector.js +0 -638
  284. package/src/lib/specs/design-seed.js +0 -18
  285. package/src/lib/specs/screen-checklist.js +0 -315
  286. package/src/lib/stack/stack-profile.js +0 -69
  287. package/src/lib/tasks/eval-node.js +0 -293
  288. package/src/lib/tasks/linux-runner.js +0 -200
  289. package/src/lib/tasks/test-nodes.js +0 -414
  290. package/src/lib/tasks/test-runner.js +0 -569
  291. package/src/lib/telemetry/metrics.js +0 -384
  292. package/src/lib/telemetry/telemetry-reader.js +0 -276
  293. package/src/lib/telemetry/verify-event.js +0 -57
  294. package/src/lib/validators/code-budget/code-budget-validator.js +0 -170
  295. package/src/lib/validators/contracts/contract-compliance-validator.js +0 -219
  296. package/src/lib/validators/nextjs/next-component-validator.js +0 -142
  297. package/src/lib/validators/packages/package-validator.js +0 -310
  298. package/src/lib/validators/reuse/reuse-validator.js +0 -202
  299. package/src/lib/validators/reuse/symbol-scanner.js +0 -64
  300. package/src/lib/validators/validation-runner.js +0 -188
  301. package/src/lib/validators/verify-cache.js +0 -63
  302. package/src/lib/validators/verify-runner.js +0 -971
  303. package/src/lib/verify/affected.js +0 -143
  304. package/src/lib/verify/detached.js +0 -159
  305. package/src/lib/view/feature-html.js +0 -480
  306. package/src/lib/view/feature-page.client.js +0 -109
  307. package/src/lib/view/feature-page.css +0 -278
  308. package/src/lib/view/feature-view.js +0 -113
  309. package/src/lib/view/flow-layers.js +0 -79
  310. package/src/lib/view/flow-svg.js +0 -63
  311. package/src/lib/view/tokens.css +0 -18
  312. package/src/lib/work-type-detector.js +0 -81
  313. package/src/lib/worktree/dirs.js +0 -3
  314. package/src/lib/worktree/docker-audit.js +0 -175
  315. package/src/lib/worktree/env-allocator.js +0 -177
  316. package/src/lib/worktree/feature-truth.js +0 -145
  317. package/src/lib/worktree/finish-backup.js +0 -529
  318. package/src/lib/worktree/fleet-scanner.js +0 -223
  319. package/src/lib/worktree/ignored-triage.js +0 -136
  320. package/src/lib/worktree/vscode-settings.js +0 -112
  321. package/src/lib/worktree/worktree-audit.js +0 -323
  322. package/src/lib/worktree/worktree-include.js +0 -44
  323. package/src/scripts/install-plugin.js +0 -114
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
2
2
  import { execFileSync } from 'child_process';
3
3
  import { join, dirname, resolve } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
- import { WORKTREE_DIR_NAMES } from '../lib/worktree/dirs.js';
5
+ import { WORKTREE_DIR_NAMES } from '../lib/scan/worktree-dirs.js';
6
6
  import { realEffects } from '../lib/installers/effects.js';
7
7
 
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -64,14 +64,9 @@ export async function readFile(path) {
64
64
  }
65
65
 
66
66
  export const MORPH_GITIGNORE_ENTRIES = [
67
- // Rebuilt from the committed feature.json files; committing it sweeps every feature into one commit.
68
- '.morph/state.json',
69
- '.morph/state.json.tmp.*',
70
- '.morph/state.json.lock/',
71
67
  '.morph/framework/',
72
68
  '.morph/memory/',
73
69
  '.morph/plans/',
74
- '.morph/analytics/',
75
70
  '.morph/logs/',
76
71
  '.claude/commands/',
77
72
  '.claude/rules/',
@@ -79,10 +74,8 @@ export const MORPH_GITIGNORE_ENTRIES = [
79
74
  '.claude/agents/',
80
75
  '.claude/CLAUDE.md',
81
76
  '.claude/settings.local.json',
82
- // The legacy name stays so an existing `.worktrees/` is not dirt that makes `finish` refuse.
83
77
  ...WORKTREE_DIR_NAMES.map((d) => `/${d}/`),
84
78
  '.playwright-mcp/',
85
- 'docs/superpowers/',
86
79
  'graphify-out/',
87
80
  ];
88
81
 
@@ -115,11 +108,10 @@ export async function updateGitignore(projectPath, fx = realEffects()) {
115
108
  const currentMorphRules = lines.slice(morphStartIndex, morphEndIndex + 1);
116
109
  const expectedMorphRules = morphRules.slice(1, -1);
117
110
 
118
- const missingRules = expectedMorphRules.filter(rule =>
119
- rule.startsWith('#') || !currentMorphRules.some(line => line.trim() === rule)
120
- );
111
+ const current = currentMorphRules.slice(1).map((line) => line.trim()).filter(Boolean);
112
+ const stale = current.length !== expectedMorphRules.length - 1 || current.some((line, i) => line !== expectedMorphRules[i + 1]);
121
113
 
122
- if (missingRules.length > 0) {
114
+ if (stale) {
123
115
  lines.splice(morphStartIndex, morphEndIndex - morphStartIndex, ...morphRules.slice(1, -1));
124
116
  content = lines.join(eol);
125
117
  }
@@ -1,11 +1,10 @@
1
- import { join, dirname } from 'path';
1
+ import { join } from 'path';
2
2
  import { readFile } from 'fs/promises';
3
- import { existsSync, readdirSync } from 'fs';
3
+ import { existsSync } from 'fs';
4
4
  import { homedir } from 'os';
5
5
  import { realEffects } from '../lib/installers/effects.js';
6
- import { CPU_SHARE_ENVS, cpuShareOf, readHeavyConfig } from '../../framework/hooks/shared/heavy-config.js';
7
6
 
8
- const HOOKS_VERSION = '3.17.0';
7
+ const HOOKS_VERSION = '4.0.0';
9
8
 
10
9
 
11
10
  // `Edit(path)` only: an Edit rule also covers Write, while a `Write(path)` rule
@@ -20,7 +19,6 @@ const MORPH_DENY = [
20
19
 
21
20
  const MORPH_ALLOW = [
22
21
  'Edit(.morph/features/**)',
23
- 'Edit(.morph/state.json)',
24
22
  'Edit(.morph/context/**)',
25
23
  'Bash(mkdir:.morph/**)',
26
24
  'Bash(ls:.morph/**)',
@@ -32,56 +30,22 @@ const MORPH_PERMISSIONS = MORPH_DENY;
32
30
  // run order (block-first-wins). `args` stays separate from `command`: getHookSubpath()
33
31
  // would capture inlined args into the quoted path. `timeout` is in SECONDS.
34
32
  const MORPH_HOOKS = [
35
- {
36
- event: 'SessionStart',
37
- matcher: null,
38
- hooks: [{
39
- type: 'command',
40
- command: 'node framework/hooks/claude-code/core/worktree-context.js',
41
- timeout: 5
42
- }]
43
- },
44
-
45
33
  {
46
34
  event: 'PreToolUse',
47
35
  matcher: 'Write|Edit',
48
36
  hooks: [{
49
37
  type: 'command',
50
- command: 'node framework/hooks/claude-code/core/chain.js',
51
- args: ['protect-spec-files', 'enforce-phase-writes']
38
+ command: 'node framework/hooks/claude-code/core/protect-spec-files.js'
52
39
  }]
53
40
  },
54
41
 
55
- // heavy-gate after every guard (a blocked command must not hold a slot);
56
- // worktree-env-inject LAST so a command a previous link blocked is never rewritten.
57
42
  {
58
43
  event: 'PreToolUse',
59
44
  matcher: 'Bash',
60
45
  hooks: [{
61
46
  type: 'command',
62
47
  command: 'node framework/hooks/claude-code/core/chain.js',
63
- args: ['pre-bash-denylist', 'test-budget', 'conventional-commit', 'block-destructive-worktree-removal', 'block-raw-worktree-add', 'heavy-gate', 'worktree-env-inject']
64
- }]
65
- },
66
-
67
- {
68
- event: 'WorktreeCreate',
69
- matcher: null,
70
- hooks: [{
71
- type: 'command',
72
- command: 'node framework/hooks/claude-code/core/worktree-create.js',
73
- timeout: 120
74
- }]
75
- },
76
-
77
- // Not fired in headless runs: block-destructive-worktree-removal stays the primary defense.
78
- {
79
- event: 'WorktreeRemove',
80
- matcher: null,
81
- hooks: [{
82
- type: 'command',
83
- command: 'node framework/hooks/claude-code/core/worktree-remove.js',
84
- timeout: 60
48
+ args: ['pre-bash-denylist', 'conventional-commit']
85
49
  }]
86
50
  },
87
51
 
@@ -95,74 +59,18 @@ const MORPH_HOOKS = [
95
59
  }]
96
60
  },
97
61
 
98
- // gate-guard after state-sync so it sees the gate state-sync just recorded.
99
- {
100
- event: 'PostToolUse',
101
- matcher: 'Write|Edit|AskUserQuestion',
102
- hooks: [{
103
- type: 'command',
104
- command: 'node framework/hooks/claude-code/core/chain.js',
105
- args: ['state-sync', 'gate-guard'],
106
- timeout: 6
107
- }]
108
- },
109
-
62
+ // masked-exit last: it reads the command every other link already let through.
110
63
  {
111
64
  event: 'PostToolUse',
112
- matcher: null,
65
+ matcher: 'Bash',
113
66
  hooks: [{
114
67
  type: 'command',
115
68
  command: 'node framework/hooks/claude-code/core/chain.js',
116
- args: ['telemetry-log', 'loop-detect', 'graph-refresh-kick', 'heavy-release', 'masked-exit'],
69
+ args: ['graph-refresh-kick', 'stack-changed', 'masked-exit'],
117
70
  timeout: 10
118
71
  }]
119
72
  },
120
73
 
121
- // Recording-only bindings are `async: true`; a hook that decides is never async.
122
- {
123
- event: 'PostToolUseFailure',
124
- matcher: null,
125
- hooks: [{
126
- type: 'command',
127
- command: 'node framework/hooks/claude-code/core/chain.js',
128
- args: ['telemetry-log', 'heavy-release'],
129
- timeout: 5,
130
- async: true
131
- }]
132
- },
133
-
134
- {
135
- event: 'PostToolBatch',
136
- matcher: null,
137
- hooks: [{
138
- type: 'command',
139
- command: 'node framework/hooks/claude-code/core/telemetry-log.js',
140
- timeout: 5,
141
- async: true
142
- }]
143
- },
144
-
145
- {
146
- event: 'SubagentStop',
147
- matcher: null,
148
- hooks: [{
149
- type: 'command',
150
- command: 'node framework/hooks/claude-code/core/telemetry-log.js',
151
- timeout: 10,
152
- async: true
153
- }]
154
- },
155
-
156
- {
157
- event: 'UserPromptSubmit',
158
- matcher: null,
159
- hooks: [{
160
- type: 'command',
161
- command: 'node framework/hooks/claude-code/core/telemetry-log.js',
162
- timeout: 5
163
- }]
164
- },
165
-
166
74
  {
167
75
  event: 'Stop',
168
76
  matcher: null,
@@ -247,6 +155,7 @@ export async function installClaudeHooks(targetPath, { fx = realEffects() } = {}
247
155
  }
248
156
 
249
157
  const STALE_ALLOW = [
158
+ 'Edit(.morph/state.json)',
250
159
  'Write(.morph/features/**)',
251
160
  'Write(.morph/context/**)',
252
161
  ];
@@ -276,13 +185,6 @@ export async function installClaudeHooks(targetPath, { fx = realEffects() } = {}
276
185
  settings.plansDirectory = '.morph/plans';
277
186
  }
278
187
 
279
- // What runs outside the queue (a loose `dotnet test`) keeps to a run's share too; a value already here stays.
280
- const heavy = readHeavyConfig(targetPath);
281
- if (heavy.yieldToUser) {
282
- const share = String(cpuShareOf(heavy.slots));
283
- settings.env = { ...Object.fromEntries(CPU_SHARE_ENVS.map((name) => [name, share])), ...settings.env };
284
- }
285
-
286
188
  settings._morph_managed = settings._morph_managed || {};
287
189
  settings._morph_managed.hooks_version = HOOKS_VERSION;
288
190
  settings._morph_managed.hooks_installed = [...new Set(MORPH_HOOKS.map(h => h.event))];
@@ -1,14 +0,0 @@
1
- {
2
- "name": "morph-spec",
3
- "version": "10.12.0",
4
- "displayName": "MORPH-SPEC Framework",
5
- "description": "Spec-driven development with 38 agents and 8-phase workflow for .NET/Blazor/Next.js/Azure",
6
- "publisher": "polymorphism-tech",
7
- "skills": {
8
- "directory": "framework/skills",
9
- "namespace": "morph-spec"
10
- },
11
- "hooks": {
12
- "directory": "framework/hooks/claude-code"
13
- }
14
- }
@@ -1,46 +0,0 @@
1
- ---
2
- description: Archive a feature WITHOUT integrating — reserved for legacy features (no morph/{f} branch) and cleanup; the normal close is morph-spec finish
3
- argument-hint: <feature-name>
4
- allowed-tools: Read, Bash
5
- ---
6
-
7
- # Archive MORPH Feature
8
-
9
- Archive-**without-integrate**: move a feature out of the active set in `.morph/features/` without
10
- merging or opening a PR. This is the **reserved** path — for **legacy** features (born before the
11
- "every feature is born on a `morph/{f}` branch" model, so there's no branch to integrate) and for
12
- **cleanup**. The **normal close** of a feature is `morph-spec finish {feature} --pr|--merge`, which
13
- archives *and* integrates *and* tears down the worktree in one step (see `MORPH.md` §2.2 and
14
- `morph-apply` §6). Reach for `/morph-archive` only when integration is not wanted.
15
-
16
- This is a thin wrapper over the atomic, git-aware CLI command — do **not** move folders or edit state
17
- by hand. The command moves the folder, stamps the feature `completed` + `archivedAt` in its
18
- `feature.json`, **commits the move scoped to the feature's own pathspec** (`.morph/features/{f}` +
19
- `.morph/archive/{f}`, never `commit -a`), and cleans the derivable root index, all-or-nothing. Re-running
20
- is idempotent: an already-archived feature is reported, not re-moved.
21
-
22
- ## Workflow
23
-
24
- 1. **Verify** the feature cleared Gate 3:
25
- ```
26
- morph-spec status {feature} --verbose
27
- ```
28
- Gate `review` must be `approved`. If not, stop and report what's missing (don't force it without
29
- the user's say-so).
30
-
31
- 2. **Archive** atomically:
32
- ```
33
- morph-spec archive {feature}
34
- ```
35
- The command refuses if Gate 3 isn't approved (override with `--force` only when the user asks).
36
- It moves `.morph/features/{feature}/` → `.morph/archive/{feature}/` (via `git mv` when possible),
37
- sets `status: "completed"` + `archivedAt` + `archivedFrom.sha`, keeps only `feature.json` and
38
- `2-plan/plan.md` (the rest stays readable at that sha), commits that move scoped to the feature's
39
- pathspec, and drops the feature from the thin index.
40
-
41
- 3. **Report** the new path (`.morph/archive/{feature}/`). Do not invent metrics not recorded in
42
- `feature.json` or in `3-implement/report.md` at `archivedFrom.sha`.
43
-
44
- ---
45
-
46
- **Feature to archive:** $ARGUMENTS
@@ -1,17 +0,0 @@
1
- ---
2
- description: Hotfix de produção — diagnóstico da causa raiz, plano curto, fix cirúrgico, verify, Gate 3 sempre humano.
3
- argument-hint: <feature-name>
4
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Agent, AskUserQuestion, Skill
5
- ---
6
-
7
- # /morph-hotfix
8
-
9
- Resolve uma queda ou bug crítico de produção com prioridade em velocidade, sem abrir mão da aprovação
10
- humana antes do ship.
11
-
12
- Atalho: invoque `Skill(morph-apply)` com o nome da feature e siga `references/hotfix.md` da skill do
13
- começo ao fim: `morph-spec create --type hotfix` → diagnóstico (causa raiz e blast radius, nesta sessão)
14
- → plano curto (C1 sintoma ausente, C2 regressão) → fix → verify → Gate 3 sempre humano, nunca
15
- `--mode auto`.
16
-
17
- **Feature:** $ARGUMENTS
@@ -1,180 +0,0 @@
1
- ---
2
- description: Validate project readiness before deploy — checks specs, contracts, tests, Docker, Neon/PostgreSQL, and Coolify configuration
3
- argument-hint: [feature-name]
4
- allowed-tools: Read, Bash, Glob, Grep
5
- ---
6
-
7
- # Pre-Flight Check for Deployment
8
-
9
- Validates project readiness before deploying to Docker/Coolify + Neon/PostgreSQL.
10
-
11
- ## Usage
12
-
13
- ```
14
- /morph-preflight
15
- ```
16
-
17
- ## Purpose
18
-
19
- Detect problems **before** deploy that would cause production failures. Saves time and avoids debugging in production.
20
-
21
- ---
22
-
23
- ## MORPH-SPEC Validation (run before all other checks)
24
-
25
- These checks verify that the morph-spec workflow is complete for the feature being deployed.
26
-
27
- ```bash
28
- # Verify implementation is complete
29
- morph-spec status {feature} --verbose
30
- morph-spec verify {feature}
31
- ```
32
-
33
- | Check | Command | Pass Criteria |
34
- |-------|---------|---------------|
35
- | Phase is implement or later | `status` | phase derived as `implement` or `review` |
36
- | All gates approved | `status --verbose` | plan (and uiux, when the feature has design) and review gates approved |
37
- | Build, tests and validators pass | `verify` | every node green |
38
- | All slices reported | `status` → Fatias | 0 slices pending or partial |
39
-
40
- **If any MORPH check fails:** Show which check failed and recommend: `Run /morph-apply {feature} to complete implementation before deploying.`
41
-
42
- ---
43
-
44
- **Tests:** the proof the gates read is `morph-spec verify {feature}` without `--filter`. A bare `dotnet test`/`npm test` is fine for checking something (it goes through the heavy-job queue), but it leaves no proof. Any red node blocks deployment.
45
-
46
- ---
47
-
48
- ## Validations Performed
49
-
50
- ### 1. Package Version Conflicts
51
-
52
- **What it checks:**
53
- - No version conflicts (NU1605, NU1608)
54
- - Critical packages with compatible versions
55
-
56
- **How to check:**
57
- ```bash
58
- dotnet restore --verbosity normal 2>&1 | grep -E "(NU1605|NU1608|warning)"
59
- ```
60
-
61
- ---
62
-
63
- ### 2. Database Migrations (Neon/PostgreSQL)
64
-
65
- **What it checks:**
66
- - Database is reachable
67
- - No pending migrations
68
- - RLS policies defined for all public tables
69
- - Database schema matches expected state
70
-
71
- **How to check:**
72
- ```bash
73
- # Step 0: Verify database connectivity
74
- psql "$(neon connection-string)" -c "SELECT 1" 2>/dev/null && \
75
- echo "✓ Database reachable" || \
76
- echo "✗ Database unreachable — skip remaining migration checks"
77
-
78
- # Check for pending migrations (skip if connectivity failed)
79
- neon branches schema-diff <base-branch> <branch>
80
-
81
- # Verify RLS is enabled on all tables
82
- psql "$(neon connection-string)" -c "SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename NOT IN (SELECT tablename FROM pg_policies)"
83
- ```
84
-
85
- > **Important:** If the database connectivity check fails, skip all migration checks and warn the user. Do not block the preflight — the database may be intentionally scaled to zero.
86
-
87
- **Common fix:**
88
- ```bash
89
- dotnet ef migrations add <migration-name>
90
- ```
91
-
92
- ---
93
-
94
- ### 3. Dockerfile Validation
95
-
96
- **What it checks:**
97
- - Dockerfile exists for each service (API, Web)
98
- - Multi-stage build configured
99
- - EXPOSE ports correct
100
- - ENTRYPOINT defined
101
- - .dockerignore present
102
-
103
- **How to check:**
104
- `Dockerfile.api` and `Dockerfile.web` are the names the `docker-dockerfile-api`/`docker-dockerfile-web` templates emit (`outputName` in REGISTRY.json); check the project's real names first.
105
-
106
- ```bash
107
- # Validate API Dockerfile
108
- docker build --check -f Dockerfile.api .
109
-
110
- # Validate Web Dockerfile
111
- docker build --check -f Dockerfile.web .
112
- ```
113
-
114
- ---
115
-
116
- ### 4. Docker Compose
117
-
118
- **What it checks:**
119
- - `docker-compose.yml` exists and is valid
120
- - All services have health checks
121
- - Environment variables reference `.env` (not hardcoded)
122
- - Volumes mapped correctly
123
-
124
- **How to check:**
125
- ```bash
126
- docker compose config --quiet
127
- ```
128
-
129
- ---
130
-
131
- ### 5. Environment Variables & Secrets
132
-
133
- **What it checks:**
134
- - Connection strings not hardcoded in code
135
- - Secrets in environment variables (not in appsettings)
136
- - `.env.example` exists with all required vars documented
137
- - No credentials in source code
138
-
139
- **How to check:**
140
- ```bash
141
- # Detect passwords in appsettings
142
- grep -rE "(Password=|Pwd=|Secret=|sk_live|pk_live)" appsettings*.json src/ --include="*.cs" --include="*.json" | grep -v Development
143
-
144
- # Verify .env.example exists
145
- test -f .env.example && echo "OK" || echo "MISSING .env.example"
146
- ```
147
-
148
- ---
149
-
150
- ### 6. Coolify Configuration
151
-
152
- **What it checks:**
153
- - Application correctly defined in Coolify (source repo, Dockerfile path, port)
154
- - Health check endpoints exist (`/health` or `/healthz`)
155
- - Port mappings match Dockerfile EXPOSE
156
-
157
- **How to check:**
158
- ```bash
159
- # Verify health endpoint exists in code
160
- grep -rn "MapGet.*health" src/ --include="*.cs"
161
-
162
- # Verify Coolify config placeholders were filled in (local file only)
163
- grep -E "REPLACE_WITH_" coolify.json 2>/dev/null && echo "✗ coolify.json still has unfilled placeholders" || echo "✓ coolify.json configured"
164
- ```
165
-
166
- > Coolify has no MCP/CLI — its API is only reachable via SSH into the VPS. `morph-preflight` never does this itself; it only checks the project's local files. Live verification against the running instance is a manual step for whoever holds VPS access.
167
-
168
- ---
169
-
170
- ## Usage Workflow
171
-
172
- ### Before creating PR for production
173
-
174
- ```bash
175
- /morph-preflight
176
- ```
177
-
178
- ---
179
-
180
- *MORPH-SPEC by Polymorphism Tech*
@@ -1,15 +0,0 @@
1
- ---
2
- description: Conduz o Gate 3 de uma feature com o verify verde — verificador, revisor e (com caminho sensível) segurança em contexto fresco.
3
- argument-hint: <feature-name>
4
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Agent, AskUserQuestion, Skill
5
- ---
6
-
7
- # /morph-review
8
-
9
- Atalho: invoque `Skill(morph-apply)` com o nome da feature e entre no §5 (Gate 3), seguindo
10
- `references/review.md` da skill.
11
-
12
- Pré-requisito: todo `Cn` `feito` em `3-implement/report.md` e o `morph-spec verify {feature}` verde.
13
- Faltando, `morph-spec next {feature} --json` diz o passo.
14
-
15
- **Feature:** $ARGUMENTS
@@ -1,37 +0,0 @@
1
- ---
2
- description: Show current MORPH-SPEC feature status (phase, gates, slice progress)
3
- argument-hint: [feature-name]
4
- allowed-tools: Read, Bash
5
- ---
6
-
7
- # MORPH Status
8
-
9
- Show the status of a MORPH-SPEC feature: current phase, approval gates, and output completion.
10
-
11
- ## Usage
12
-
13
- ```bash
14
- morph-spec status <feature-name>
15
- ```
16
-
17
- Optional flags:
18
- - `--json` — emit JSON for tooling
19
- - `-v, --verbose` — show output files and gate details
20
-
21
- ## Resolving the active feature
22
-
23
- If the user did not pass a feature name in `$ARGUMENTS`:
24
-
25
- 1. Read `.morph/state.json`.
26
- 2. Pick the most recently updated feature whose `status !== 'completed'`.
27
- 3. If none exists, ask the user which feature to inspect via `AskUserQuestion`.
28
-
29
- ## What you display
30
-
31
- The CLI prints the glance block in plain Portuguese: feature name, Entrega, Passo, Cenários (done of total, the missing ones by name), Travado, Espera você and Próximo — the same block `morph-spec next` prints.
32
-
33
- After running the CLI, show the block as printed: never re-summarize it with internal ids (`C3`, gate names, file names), and never a next step of your own.
34
-
35
- ---
36
-
37
- $ARGUMENTS
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env node
2
- import { existsSync, lstatSync } from 'fs';
3
- import { resolve, isAbsolute } from 'path';
4
- import { blockResult, runStandalone } from '../../shared/hook-response.js';
5
- import { stateExists } from '../../shared/state-reader.js';
6
- import { scanForBlockers } from '../../shared/reparse-scan.js';
7
- import { simpleCommands, tokenize } from '../../shared/command-tokens.js';
8
-
9
- // Generic recursive removals FOLLOW a worktree's junctions and empty the root's `.claude/` and `.morph/framework/`.
10
- // The reparse scan is the authority, not the path shape; anything unparseable passes.
11
-
12
- // A hook never imports a sibling hook (its standalone tail would fire), so the tokenizer lives in shared/.
13
- export { tokenize };
14
-
15
- // A flag belongs to its own simple command: the `-rn` of a grep after `&&` is not the `git rm`'s.
16
- export function extractRemovalTarget(command) {
17
- for (const simple of simpleCommands(command)) {
18
- const target = removalTargetOf(simple.map((t) => t.text));
19
- if (target) return target;
20
- }
21
- return null;
22
- }
23
-
24
- function removalTargetOf(tokens) {
25
- if (!tokens.length) return null;
26
- const lower = tokens.map((t) => t.toLowerCase());
27
-
28
- // The path is always the last non-flag token.
29
- const gi = lower.indexOf('git');
30
- if (gi !== -1 && lower[gi + 1] === 'worktree' && lower[gi + 2] === 'remove') {
31
- const rest = tokens.slice(gi + 3).filter((t) => !t.startsWith('-'));
32
- return rest.length ? rest[rest.length - 1] : null;
33
- }
34
-
35
- // Needs both the command word and a recursive flag: a plain `rm file` cannot traverse a junction.
36
- const recursive = tokens.some((t) => /^(-[a-z]*r[a-z]*|--recursive|\/s)$/i.test(t));
37
- const removalCmd = lower.find((t) => /^(rm|remove-item|ri|rd|rmdir|del)$/.test(t));
38
- if (!removalCmd || !recursive) return null;
39
-
40
- const idx = lower.indexOf(removalCmd);
41
- // A cmd.exe switch is a slash plus one or two letters; anything longer is a POSIX absolute path.
42
- const isCmdSwitch = (t) => /^\/[a-z]{1,2}$/i.test(t);
43
- const operands = tokens.slice(idx + 1).filter((t) => !t.startsWith('-') && !isCmdSwitch(t));
44
- // Named-parameter form: `Remove-Item -Path <p> -Recurse`.
45
- const pathFlag = lower.findIndex((t) => t === '-path' || t === '-literalpath');
46
- if (pathFlag !== -1 && tokens[pathFlag + 1]) return tokens[pathFlag + 1];
47
- return operands.length ? operands[0] : null;
48
- }
49
-
50
- export async function run(payload) {
51
- try {
52
- if (!stateExists()) return null;
53
-
54
- const command = payload?.tool_input?.command || '';
55
- if (!command) return null;
56
-
57
- const raw = extractRemovalTarget(command);
58
- if (!raw) return null;
59
-
60
- const cwd = payload?.cwd || process.cwd();
61
- const target = isAbsolute(raw) ? resolve(raw) : resolve(cwd, raw);
62
- if (!existsSync(target) || lstatSync(target).isFile()) return null;
63
-
64
- const { safe, blockers } = scanForBlockers(target);
65
- if (safe) return null;
66
-
67
- const shown = blockers.slice(0, 5).join(', ');
68
- const more = blockers.length > 5 ? `, +${blockers.length - 5}` : '';
69
- return blockResult(
70
- `Remoção bloqueada: "${target}" contém link(s) que este comando SEGUIRIA para fora, apagando o alvo real na raiz do projeto (${shown}${more}).\n\n` +
71
- `Isto é o que esvazia o \`.claude/\` e o \`.morph/framework/\` da raiz.\n\n` +
72
- `Use: \`morph-spec worktree remove --target "${target}"\` — ele desmonta as junctions ANTES de remover, e recusa se não conseguir provar que é seguro.\n` +
73
- `Para fechar a feature de vez: \`morph-spec finish <feature> --pr|--merge\`.`
74
- );
75
- } catch {
76
- return null;
77
- }
78
- }
79
-
80
- await runStandalone(run);