@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
package/CLAUDE.md CHANGED
@@ -4,19 +4,15 @@ This file provides guidance to Claude Code when working with code in **this repo
4
4
 
5
5
  ## What This Is
6
6
 
7
- morph-spec is a spec-driven development harness CLI (`@polymorphism-tech/morph-spec`). The CLI installs the harness and owns the deterministic steps (state, gates, `plan-check`, `verify`, `report-check`, worktrees); Claude Code runs the workflow from `framework/MORPH.md` (the NLH charter) and the core skills.
7
+ morph-spec is a harness CLI (`@polymorphism-tech/morph-spec`) that makes Claude Code write code well: a plan with scenarios `C1..Cn`, a red proof per scenario, review personas in fresh context, and a `## Resultado` an orchestrator reads. The CLI installs the harness (contract, skills, rules, personas, hooks) and owns the deterministic steps (`plan-check`, `prove-red`, `check`); Claude Code runs the flow from `framework/MORPH.md` and the core skills. It never orchestrates: worktrees, the Claude call and the PR belong to whoever runs it.
8
8
 
9
9
  This repo is the **framework source code** — not a project that uses morph-spec.
10
10
 
11
- **Do not run the morph-spec workflow here.** No `init`, `create`, `plan-check`, `gate-check`, `approve`, `advance`, `verify`, `context refresh` or `finish`, and no `/morph-plan` or `/morph-apply` as a process, even if a prompt starts with one: confirm first. Work here is ordinary: a normal branch, `npm test`, `npm run generate:check`, a PR. `framework/skills/` and `framework/CLAUDE.md` are source to edit, not instructions to follow. `/.morph/` is gitignored: this repo keeps no morph-spec state.
11
+ **Do not run the morph-spec workflow here.** No `init`, `plan-check`, `prove-red`, `check` or `context refresh`, and no `/morph-plan` or `/morph-apply` as a process, even if a prompt starts with one: confirm first. Work here is ordinary: a normal branch, `npm test`, `npm run generate:check`, a PR. `framework/skills/` and `framework/CLAUDE.md` are source to edit, not instructions to follow. `/.morph/` is gitignored: this repo keeps no morph-spec state.
12
12
 
13
13
  ## Build & Test Commands
14
14
 
15
15
  ```bash
16
- # Once per clone: the dashboard render smoke test (test/dashboard/pages-smoke.test.js)
17
- # needs the dashboard's own deps and FAILS without them — CI installs them too
18
- cd src/dashboard && npm install
19
-
20
16
  # Dev loop: only the test files the current change can reach (vs the merge-base with main)
21
17
  npm run test:changed # add -- --list to see the selection and why
22
18
 
@@ -25,7 +21,7 @@ npm run test:changed # add -- --list to see the selection and why
25
21
  npm test
26
22
 
27
23
  # A subtree or file (still parallel); --test-concurrency=1 to debug serially
28
- node scripts/run-tests.mjs test/lib/state-manager.test.js
24
+ node scripts/run-tests.mjs test/commands/check.test.js
29
25
 
30
26
  # Coverage
31
27
  npm run test:coverage
@@ -43,58 +39,33 @@ No build step — pure ESM JavaScript, runs directly via Node.js 22+.
43
39
 
44
40
  ### Module Layout
45
41
 
46
- - **`bin/morph-spec.js`** — Commander.js CLI entry point: install/inspect commands plus the deterministic steps of the loop (`create`, `plan-check`, `gate-check`, `approve`/`advance`, `verify`, `report-check`, `e2e`, `finish`).
47
- - **`src/commands/`** — CLI command handlers organized by domain (project/, state/, validation/, scaffold/, mcp/, context/, dashboard/).
48
- - **`src/core/`** — Core domain logic:
49
- - `state/state-manager.js` — Atomic state I/O with process-ID temp files
50
- - `paths/output-schema.js` — **Single source of truth** for the output types (`plan`, `checks`, the `1-design/` docs, `recap`, `evidencias`, the three review reports)
51
- - `templates/` — Handlebars template registry and renderer
52
- - `workflows/` — Workflow type detector
53
- - **`src/lib/`** — Libraries and subsystems:
54
- - `validators/` — Validators run by the `verify` validators node (code-budget, contracts, nextjs, packages, reuse)
55
- - `generators/` — Code generation (architecture context, scaffold, settings)
56
- - `stack-filter.js` — Stack-aware asset filtering via YAML frontmatter `stacks:` tags
57
- - `installers/` — Agents, skills, hooks installers
58
- - **`src/utils/`** — Shared utilities (logger, banner, file-copier, claude-settings-manager, agents-installer, skills-installer, hooks-installer)
59
- - **`framework/`** — Metadata installed into target projects (READ-ONLY at runtime):
60
- - `MORPH.md` — NLH charter (the single source of behavioral truth; ≤ 8k chars, `resident-size` canary)
61
- - `CLAUDE.md` — Runtime instructions injected into target's `.claude/CLAUDE.md` (≤ 3k chars)
62
- - `agents.json` — the 3 Gate 3 personas (see below); `maxTurns` per persona
63
- - `phases.json` — 4 phases (plan, uiux, implement, review)
64
- - `standards/STANDARDS.json` — index of available standards
65
- - `hooks/claude-code/core/` — fail-open guardrail hooks (+ `hooks/shared/` for what hooks and `src/` both read)
66
- - `skills/core/` — core NLH skills (single source of truth; listed on the `**Skills core**` line of MORPH.md §7)
67
- - `rules/` — path-scoped stack rules only (`paths:` frontmatter); no always-on rule
42
+ - **`bin/morph-spec.js`** — Commander.js CLI entry point: install/inspect commands (`init`, `update`, `setup-infra`, `doctor`, `standards`, `graph`, `stack-*`) and the deterministic steps of the loop (`plan-check`, `prove-red`, `check`, `env`).
43
+ - **`src/commands/`** — CLI command handlers by domain (project/, validation/, graph/, scaffold/, mcp/, context/, standards/).
44
+ - **`src/core/`** — `paths/output-schema.js` (**single source of truth** for the feature files: `plan`, `checks`, `implementReport`, the review reports, the `1-design/` docs) and `templates/` (Handlebars registry and renderer).
45
+ - **`src/lib/`** — `contract/` (scan → defaults → merge → apply of `.morph/config/config.json`, and `ports.js` for the branch-hash ports), `check/` (signals and attempts), `plan/` (the one `plan.md` parser and `checks.json` builder), `review-reports.js` (the one reader of the persona reports), `diff/`, `graph/`, `stack/`, `installers/`, `generators/`, `ai/` (`doctor --ai`), `stack-filter.js`.
46
+ - **`src/utils/`** — installers (agents, skills, hooks, claude-settings), logger, file-copier, version-checker.
47
+ - **`framework/`** — what `init` installs into target projects (read-only at runtime):
48
+ - `MORPH.md` — the NLH charter (≤ 8k chars, `resident-size` canary); `CLAUDE.md` — injected into the target's `.claude/CLAUDE.md` (≤ 3k chars)
49
+ - `agents.json` — the 3 review personas; `.claude/agents/morph-*.md` are generated from it
50
+ - `skills/core/` — `morph-plan`, `morph-apply`, `morph-uiux` (+ the Umbraco ones), listed in MORPH.md
51
+ - `rules/` — path-scoped stack rules (`paths:` + `stacks:`), no always-on rule
52
+ - `hooks/claude-code/core/` — fail-open guardrails; `hooks/shared/` — what hooks and `src/` both read
53
+ - `standards/` + `STANDARDS.json`, `templates/` + `REGISTRY.json`, `mcp/registry.json`, `schemas/`, `evals/review-checklist.md`
68
54
  - `docs/CLI.md` — the CLI reference, one `###` per command, installed as `.morph/framework/CLI.md`
69
- - `templates/` — Handlebars templates for code generation
70
- - `mcp/registry.json` — MCP server registry
71
- - `evals/review-checklist.md` — o que os agentes do Gate 3 procuram (veredito SHIP/FIX + bloqueador com evidência)
72
55
 
73
56
  ### Key Architectural Patterns
74
57
 
75
- **NLH (Natural Language Harness):** Behavior lives in `framework/MORPH.md` — read once per session by Claude. JS hooks are silent guardrails only, never orchestrators.
76
-
77
- **Output schema as single source of truth:** `src/core/paths/output-schema.js` defines all output types. Run `npm run generate` after modifying it.
78
-
79
- **Fail-open hooks:** All hooks check `stateExists()` first and return `{}` if state is missing/corrupt. Hooks never throw or write state.
80
-
81
- **Atomic state writes:** `state-manager.js` writes to `${path}.tmp.${pid}` then renames.
58
+ **NLH (Natural Language Harness):** behavior lives in `framework/MORPH.md` and the skills. JS hooks are silent guardrails, never orchestrators.
82
59
 
83
- **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.
60
+ **The contract:** `.morph/config/config.json` (`project.stack`/`tags`, `tests[]` with `tier`, `risk` globs, `limits`), shape in `framework/schemas/config.schema.json`. `init` writes it from a scan and is idempotent (`_generated` fingerprints keep hand edits). Every hook and validation command starts from `contractExists()`: no contract, no-op (hooks) or exit 2.
84
61
 
85
- **Single loop:** the main session plans, implements the whole plan in one window, fixes and finishes; domain know-how lives in the stack rules `framework/rules/*-standards.md`, loaded by `paths:` when the session touches a matching file and installed by `syncStackRules` from `plan-check`/`verify`/`update` (`docs/specs/single-loop/decisions.md`, ADR-010). `agents.json` has only the 3 read-only Gate 3 roles — `verifier` (executes each `Cn`), `reviewer` (plan.md + diff), `security` (sensitive paths) — dispatched in fresh context in the same response. `reviewer` is `sonnet`, `security` is `opus`; the dispatch routes the verifier to `opus` when `verifierModelFor` (risk-detector.js, read by `report-check --before-eval`) sees prompt/model or media.
86
-
87
- ### Phase Sequence
88
-
89
- ```
90
- plan → [uiux] → implement → review
91
- ```
62
+ **The feature is the branch:** `.morph/features/<slugOfBranch>/` (`framework/hooks/shared/feature-slug.js`). No state file, no phases, no gates: `plan.md` freezes once `checks.json` exists, progress is `3-implement/report.md` (`pendente`/`feito`/`bloqueado` per `Cn`), and `check --report` writes `## Resultado` (`pronto` | `precisa-humano` with the signals).
92
63
 
93
- Gates: `plan` (plan.md + `checks.json` from `plan-check`), `uiux` (optional, after the plan gate, `1-design/`), `review` (Gate 3: `verifier.md` + `reviewer.md` [+ `security.md`]). Folders keep their ids: `2-plan/`, `1-design/`, `3-implement/`, `4-review/`. `chore`/`hotfix` are born with `plan` stamped by policy. Done-when = the scenarios `C1..Cn` of plan.md; progress = `3-implement/report.md` (one row per `Cn`: `pendente`/`feito`/`bloqueado`). The archive keeps `feature.json` + `2-plan/plan.md`.
64
+ **Fail-open hooks:** every hook returns `null` on any error or without a contract. Hooks never throw and never write project state.
94
65
 
95
- ### State Schema
66
+ **Stack-aware filtering:** assets declare `stacks:` in frontmatter (or `stack` in `agents.json`); `getProjectTags` unites `project.stack`, `project.tags` and `integrations`, and only matching assets install.
96
67
 
97
- Authoritative, committed state: `.morph/features/{f}/feature.json` (status, approvalGates, gateDecisions, outputs, verification), shape in `framework/schemas/feature.schema.json`. `.morph/state.json` is a thin gitignored index rebuilt on load. Phase is derived from the filesystem and the gates, never stored.
68
+ **Review:** `agents.json` has the 3 read-only roles — `verifier` (runs each `Cn`), `reviewer` (plan.md + diff), `security` (sensitive diffs) — dispatched once, in fresh context, by the session that implemented. Their reports in `4-review/` feed the `sem-revisao`/`revisao-fix`/`nao-provado` signals of `check --report`.
98
69
 
99
70
  ## Testing Conventions
100
71
 
@@ -125,14 +96,13 @@ A matriz "mexeu em X → verifique Y" mora em `.claude/rules/matrix-*.md`, uma r
125
96
  | --- | --- |
126
97
  | `.claude/rules/matrix-agents.md` | Personas (`agents.json`) e o installer delas |
127
98
  | `.claude/rules/matrix-standards.md` | Standards, registro e seções |
128
- | `.claude/rules/matrix-hooks.md` | Hooks, telemetria e comment-guard |
99
+ | `.claude/rules/matrix-hooks.md` | Hooks e comment-guard |
129
100
  | `.claude/rules/matrix-charter.md` | Carta NLH, skills e docs instaláveis |
130
- | `.claude/rules/matrix-templates-ai.md` | Fases, templates, ai-kit e CI |
131
- | `.claude/rules/matrix-plan-review.md` | Plano, progresso, gates e Gate 3 |
132
- | `.claude/rules/matrix-verify.md` | Verify, testes e CI |
133
- | `.claude/rules/matrix-worktree-git.md` | Worktrees, finish e git |
134
- | `.claude/rules/matrix-graph.md` | Grafo de codebase e validador de reuso |
135
- | `.claude/rules/matrix-platform.md` | MCP, installers, procs, heavy e dashboard |
101
+ | `.claude/rules/matrix-templates-ai.md` | Templates, ai-kit e CI |
102
+ | `.claude/rules/matrix-plan-review.md` | Plano, progresso, feature pelo branch e relatórios de revisão |
103
+ | `.claude/rules/matrix-check.md` | `check`, sinais e portas pelo branch |
104
+ | `.claude/rules/matrix-graph.md` | Grafo de codebase |
105
+ | `.claude/rules/matrix-platform.md` | MCP, installers e contrato |
136
106
 
137
107
  ### Test Coverage
138
108
 
package/README.md CHANGED
@@ -1,379 +1,90 @@
1
1
  # morph-spec
2
2
 
3
- > Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
3
+ > Harness para o Claude Code escrever código bem: plano com cenários, prova de que o teste morde, revisão em contexto novo e um resultado que um orquestrador lê.
4
4
 
5
5
  **Package:** `@polymorphism-tech/morph-spec`
6
- **Version:** 10.12.0
6
+ **Version:** 11.0.0
7
7
  **Requires:** Node.js 22+, Claude Code
8
8
 
9
9
  ---
10
10
 
11
- ## What it does
11
+ ## O que faz
12
12
 
13
- morph-spec enforces a spec-first development workflow. When you ask for a feature, it does not write code immediately. It runs through structured phases (plan, implement, review) with approval gates before a single line of implementation is generated. Each phase produces traceable output files. Every decision is documented.
13
+ Cada mudança passa por quatro passos, numa sessão só do Claude Code, com ou sem humano:
14
14
 
15
- It integrates natively with Claude Code: skills become slash commands, agents become native subagents, hooks inject state context automatically, and rules enforce standards based on file paths.
16
-
17
- ---
18
-
19
- ## Requirements
20
-
21
- - [Claude Code](https://claude.ai/code) (latest)
22
- - Node.js 22+
23
- - npm 9+ or pnpm
24
-
25
- ---
26
-
27
- ## Installation
28
-
29
- Install the CLI globally:
30
-
31
- ```bash
32
- npm install -g @polymorphism-tech/morph-spec@latest --prefer-online
33
15
  ```
34
-
35
- Then initialize in your project:
36
-
37
- ```bash
38
- morph-spec init
16
+ issue ──→ plano (Cn) ──→ prova vermelha ──→ implementação ──→ revisão ──→ ## Resultado
17
+ plan-check prove-red check personas check --report
39
18
  ```
40
19
 
41
- ### Init options
42
-
20
+ | Passo | O que garante |
21
+ | --- | --- |
22
+ | **Plano** (`/morph-plan`) | `2-plan/plan.md` com cenários `C1..Cn` em Dado/Quando/Então, cada um com o tipo de prova; `plan-check` valida e grava `checks.json`, e o plano congela |
23
+ | **Prova** (`prove-red`) | o teste do cenário falha sem a mudança — um teste que passa dos dois jeitos não prova nada |
24
+ | **Implementação** (`/morph-apply`) | o plano inteiro, com `check` rodando os testes do contrato do repo |
25
+ | **Revisão** | três personas em contexto novo (`morph-verifier`, `morph-reviewer`, `morph-security`), uma rodada, cada achado com frequência × severidade |
26
+ | **Resultado** | `check --report` grava `status: pronto` ou `status: precisa-humano` com os motivos no `3-implement/report.md` |
43
27
 
44
- | Flag | Description |
45
- | ------------ | ------------------------------------- |
46
- | `--force` | Overwrite existing installation |
47
- | `--skip-mcp` | Skip MCP configuration prompt |
48
- | `--path` | Target directory (default: cwd) |
49
-
50
-
51
- After init, open the project in Claude Code. The framework activates automatically via `.claude/settings.local.json`.
28
+ O morph-spec não orquestra: quem cria a worktree, chama o Claude e abre o PR é quem roda (um bot com a label `agente`, o Orca, `claude -w`, você). Ele só percebe onde está — a feature é a pasta do branch, as portas saem do hash do branch.
52
29
 
53
30
  ---
54
31
 
55
- ## Project structure (after init)
56
-
57
- ```
58
- your-project/
59
- ├── CLAUDE.md # AI instructions for this project
60
- ├── .morph/
61
- │ ├── config/
62
- │ │ └── config.json # Project configuration
63
- │ ├── framework/
64
- │ │ ├── agents.json # 10 personas (READ-ONLY)
65
- │ │ ├── standards/ # Coding and architecture standards (READ-ONLY)
66
- │ │ └── templates/ # Code and IaC templates (READ-ONLY)
67
- │ ├── context/ # Project context (README.md, standards.md)
68
- │ ├── features/ # Active features
69
- │ │ └── {feature}/
70
- │ │ ├── feature.json # Authoritative state (committed)
71
- │ │ ├── 2-plan/ # plan.md + checks.json (from plan-check)
72
- │ │ ├── 1-design/ # UI/UX design (optional, after the plan gate)
73
- │ │ ├── 3-implement/ # reports/F{n}.md — one per plan slice
74
- │ │ └── 4-review/ # verifier.md + reviewer.md [+ security.md]
75
- │ └── state.json # READ-ONLY — managed by CLI only
76
- └── .claude/
77
- ├── commands/ # Slash commands
78
- ├── skills/ # Framework skills (flat .md files)
79
- ├── agents/ # Native subagents (one morph-{id}.md per persona)
80
- ├── rules/ # Stack-aware, path-scoped standards rules
81
- └── settings.local.json # Hooks configuration
82
- ```
83
-
84
- ---
85
-
86
- ## Phase workflow
87
-
88
- Features move through structured phases. Some are optional depending on feature type.
89
-
90
- ```
91
- plan → [uiux] → implement → review
92
- ```
93
-
94
- `uiux` is optional — it applies only to UI-heavy features and comes after the plan gate.
95
-
96
- ### Phase outputs
97
-
98
-
99
- | Phase | Directory | Key files |
100
- | --------- | --------------- | ------------------------------------------------------------------ |
101
- | Plan | `2-plan/` | `plan.md` (scenarios `C{n}`, decisions, slices `F{n}`), `checks.json`, `stack-scan.md`, `scout-map.md` |
102
- | Design | `1-design/` | `design-system.md`, `mockups.md`, `components.md`, `flows.md` |
103
- | Implement | `3-implement/` | `reports/F{n}.md` + source code |
104
- | Review | `4-review/` | `verifier.md`, `reviewer.md`, `security.md` (when required) |
105
-
106
-
107
- ### Approval gates
108
-
109
- - **Plan gate** — `plan.md` must pass `morph-spec plan-check` with zero errors (it writes `checks.json`) before implement.
110
- - **UI/UX gate** (optional) — the `1-design/` outputs, after the plan gate.
111
- - **Gate 3 (Review)** — independent sub-agents write `verifier.md` (every `C{n}` proved), `reviewer.md` and, when required, `security.md`, each answering SHIP or FIX.
112
-
113
- In `trust: "auto"` mode (default), gates auto-pass without risk signals. See `framework/MORPH.md` for risk-signal details.
114
-
115
- Check gate status:
116
-
117
- ```bash
118
- morph-spec status {feature}
119
- ```
120
-
121
- ---
122
-
123
- ## Work-type routing & worktrees
124
-
125
- Not every change deserves the full pipeline. Every feature is born with a **work type** — `feature`, `bug`, `chore`, or `hotfix` — set via `morph-spec create {feature} --type <type>` or classified from free text with `--request "<text>"`. The type dimensions the pipeline: `feature` and `bug` run the full plan → [uiux] → implement → review sequence; `chore` skips straight to implement (plan gate stamped by policy at birth); `hotfix` runs scout (read-only root-cause) → surgical fix → test loop, and its Gate 3 always pauses for a human even under `trust: auto`. Change the type mid-flight with `morph-spec retype {feature} {newType}` (undoes only policy-stamped gates, preserves human approvals, blocked after Gate 3).
126
-
127
- Independent features can also be developed **in parallel, each isolated in its own git worktree** — one feature, one worktree, one Claude Code instance. `morph-spec create {feature} --worktree` (or `morph-spec worktree setup {feature}`) creates `worktrees/{feature}/` on branch `morph/{feature}`. The authoritative `feature.json` travels committed on the branch; shared infra (`node_modules`, `.claude`, `.morph/framework`) is linked via junctions (`morph-spec worktree link --all` repairs it if missing). Close out with `morph-spec finish {feature} --pr|--merge` (archive + integrate + teardown); `morph-spec worktree list` shows every active worktree with its phase and gate status.
128
-
129
- ---
130
-
131
- ## Slash commands
132
-
133
- These commands are available inside Claude Code after init.
134
-
135
-
136
- | Command | Description |
137
- | ------------------------------ | ---------------------------------------------------------- |
138
- | `/morph-plan {feature}` | Interview, `plan.md`, `plan-check` and the plan gate |
139
- | `/morph-apply {feature}` | Autonomous execution + review (Gate 3) |
140
- | `/morph-hotfix {feature}` | Surgical hotfix ADW — scout → fix → human Gate 3 → ship |
141
- | `/morph-status [feature]` | Status of the active (or specified) feature |
142
- | `/morph-archive {feature}` | Archive **without integrating** (legacy feature / cleanup); normal close is `morph-spec finish --pr\|--merge` |
143
- | `/morph-preflight` | Pre-deploy validation (specs, contracts, tests, infra) |
144
- | `/morph-troubleshoot [error]` | Root-cause diagnosis for .NET/Next.js errors |
145
-
146
-
147
- ---
148
-
149
- ## CLI reference
150
-
151
- ### Project management
152
-
153
- ```bash
154
- morph-spec init # Initialize MORPH in current project
155
- morph-spec init --force # Overwrite existing installation
156
- morph-spec update # Update framework files and re-analyze project
157
- morph-spec doctor # Check installation health
158
- morph-spec doctor --full # Full health check (all file verifications)
159
- ```
160
-
161
- ### Feature workflow
162
-
163
- ```bash
164
- morph-spec fleet # Every active feature (root + worktrees): phase, gates, activity
165
- morph-spec status {feature} # Feature status dashboard
166
- morph-spec approve {feature} {gate} # Approve a phase gate (plan, uiux, review)
167
- morph-spec advance {feature} # Approve the current gate and scaffold the next phase folder
168
- morph-spec finish {feature} --pr|--merge # Close a feature: archive + integrate (PR or local merge) + teardown
169
- morph-spec archive {feature} # Archive WITHOUT integrating (legacy feature / cleanup)
170
- ```
171
-
172
- `finish` is the normal close for both flows: it archives (committing the move inside `morph/{feature}`), then integrates — `--merge` merges `--no-ff` into the default branch locally; `--pr` pushes the branch and runs `gh pr create` (needs `origin` + authenticated `gh`) — and tears down the worktree if there is one. Plain `archive` is reserved for legacy features (born before every feature had a `morph/{feature}` branch) and cleanup.
173
-
174
- Progress within a feature is the slice reports `3-implement/reports/F{n}.md`: absent means pending, `PARCIAL` on the first line means partial. There is no CLI command for starting or finishing a slice.
175
-
176
- ### Validation
177
-
178
- ```bash
179
- morph-spec verify {feature} # Deterministic build+tests+validators chain, before the LLM judge
180
- ```
181
-
182
- ### Work-type routing
183
-
184
- ```bash
185
- morph-spec create {feature} --type feature|bug|chore|hotfix --description "<what/why>" # Explicit birth: type dimensions the pipeline, description is required
186
- morph-spec create {feature} --request "<free text>" # Detector classifies the type AND seeds the description
187
- morph-spec retype {feature} {newType} # Change work type mid-flight (blocked after Gate 3)
188
- ```
189
-
190
- ### Worktrees (parallel development)
32
+ ## Instalação
191
33
 
192
34
  ```bash
193
- morph-spec create {feature} --description "<what/why>" --worktree # Birth the feature already isolated in its own worktree
194
- morph-spec worktree setup {feature} # Create worktrees/{feature}/ on branch morph/{feature}
195
- morph-spec worktree link [--all] # Relink shared infra (node_modules, .claude, .morph/framework)
196
- morph-spec worktree list [--json] # List active feature worktrees with phase/gate status
197
- # Close a worktree feature with `morph-spec finish {feature} --pr|--merge` (see Feature workflow).
35
+ npm install -g @polymorphism-tech/morph-spec@latest
36
+ cd seu-repo
37
+ morph-spec init # ou: morph-spec init --dry-run
198
38
  ```
199
39
 
200
- **Codebase graph** — optional, fail-open. `init` installs [graphify](https://pypi.org/project/graphifyy/) (pinned 0.9.50) when a Python toolchain is available and writes a stack-aware `.graphifyignore`; without one, it records the fact and moves on. Everything degrades to grep.
201
-
202
- ```bash
203
- morph-spec graph build # Extract the graph (local AST, zero tokens)
204
- morph-spec graph status # Size, freshness, sanitizer health
205
- morph-spec graph affected {symbol} --uses-only # Who actually uses it (not who implements it)
206
- morph-spec graph explain {symbol} # Neighbourhood, cited file:line
207
- ```
208
-
209
- The gain is **precision, not recall**: the graph finds nothing grep would miss, but it drops 58% of the noise and tells you *what kind* of relationship each hit is — the difference between "20 types implement this interface" and "2 actually use it". The graph is never consumed raw: a sanitizing layer fixes the C# namespace-scope resolution gap that would otherwise report **zero** consumers where two exist.
210
-
211
- ---
212
-
213
- ## Agent model
214
-
215
- morph-spec dispatches 10 flat personas — no tiers, no hierarchy — defined in `.morph/framework/agents.json` (single source of truth) and installed identically to `.claude/agents/morph-{id}.md`. Claude picks the right persona per plan slice from the domains/keywords in `agents.json`, then dispatches it via the `Agent` tool.
216
-
217
- | Persona | Domain | Model |
218
- | ---------------- | -------------------------------------- | ------ |
219
- | `dotnet-senior` | Backend (.NET, VSA) | sonnet |
220
- | `ef-modeler` | EF Core / Postgres modeling | sonnet |
221
- | `maf-expert` | Microsoft Agent Framework | sonnet |
222
- | `nextjs-expert` | Frontend (Next.js/React) | sonnet |
223
- | `ui-designer` | UI/UX, design systems | sonnet |
224
- | `infra-engineer` | Jobs, deployment, observability | sonnet |
225
- | `verifier` | Gate 3: proves every scenario `C{n}` (read-only) | sonnet (opus for prompt/model or media) |
226
- | `reviewer` | Gate 3: judges the diff (read-only) | sonnet |
227
- | `security` | Gate 3: security review (read-only) | opus |
228
- | `scout` | Read-only codebase diagnosis | sonnet |
229
-
230
- `morph-spec doctor` detects drift between `agents.json` and the generated `.claude/agents/morph-*.md` files — never hand-edit the generated files.
40
+ O `init` lê os manifests (`package.json`, `*.csproj`, `pyproject.toml`, compose, `components.json`) e escreve o **contrato do repo** em `.morph/config/config.json`: stack, comandos de teste por tier, globs de risco por categoria e limites. Instala só o que a stack usa — rules por `paths:`, skills, personas e hooks. Rodar de novo atualiza sem apagar edição manual. Funciona em .NET, Next.js/React/Vue, Node, Python, LP Umbraco e site estático.
231
41
 
232
42
  ---
233
43
 
234
- ## Hooks
235
-
236
- Guardrail hooks are installed into `.claude/settings.local.json` across 13 event bindings. All are **fail-open** — they check that state exists first and silently no-op on missing/corrupt state; they never throw, write state, or orchestrate.
44
+ ## Modo autônomo
237
45
 
46
+ Com `MORPH_AUTONOMOUS=1` (ou sem humano) a sessão não pergunta: o que não é decisão dela termina como `precisa-humano` e o orquestrador abre o PR como rascunho. Sinais que levam a isso:
238
47
 
239
- | Event | Hook(s) | Purpose |
240
- | --------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
241
- | `SessionStart` | `worktree-context.js` | Injects feature identity (worktree) or active-feature summary (root) |
242
- | `PreToolUse` (Write\|Edit) | `protect-spec-files.js`, `enforce-phase-writes.js` | Freezes `plan.md` after the plan gate (only `plan-check` writes `checks.json`); enforces phase folders |
243
- | `PreToolUse` (Bash) | `pre-bash-denylist.js`, `block-destructive-worktree-removal.js`, `block-raw-worktree-add.js`, `heavy-gate.js`, `worktree-env-inject.js` | Destructive-command guards, worktree governance, heavy-node semaphore, per-worktree env |
244
- | `WorktreeCreate` / `WorktreeRemove` | `worktree-create.js`, `worktree-remove.js` | Native worktrees delegate to the CLI |
245
- | `PostToolUse` (Write\|Edit) | `comment-guard.js` | Blocks added comments the comment standard forbids |
246
- | `PostToolUse` | `state-sync.js`, `gate-guard.js` | Syncs feature state; enforces gate ordering |
247
- | `PostToolUse`, `PostToolUseFailure`, `PostToolBatch`, `SubagentStop`, `UserPromptSubmit` | `telemetry-log.js`, `loop-detect.js`, `graph-refresh-kick.js`, `heavy-release.js`, `masked-exit.js` | Telemetry, repeated-action loops, graph refresh, heavy-slot release, masked test exit warning |
248
- | `Stop` | `validate-completion.js` | Warns about incomplete tasks, missing outputs, or pending approval gates |
48
+ | Sinal | Quando |
49
+ | --- | --- |
50
+ | `risco` | o diff toca dados, envio a pessoas, acesso/segurança ou infra |
51
+ | `cenarios-propostos` | a issue veio sem cenários e o agente os propôs |
52
+ | `degrau` | cenário com migration ou mudança irreversível |
53
+ | `pr-grande` / `plano-grande` | acima dos limites do contrato |
54
+ | `preso` | 8 tentativas, ou 3 vermelhos com o mesmo erro |
55
+ | `vermelho`, `pendente`, `sem-prova` | teste falhando, cenário não fechado, nenhum teste rodou |
56
+ | `sem-revisao`, `revisao-fix`, `nao-provado` | revisão ausente, revisão pedindo correção, cenário que o verificador não provou |
57
+ | `nao-commitado` | trabalho fora do commit, que o PR não leva |
249
58
 
250
-
251
- Protected files (via `permissions.deny`):
252
-
253
- - `.morph/state.json` — never edited directly, derived from `feature.json` files
254
- - `.morph/framework/` — read-only framework content
59
+ Template de issue: **Objetivo / Cenários (Cn) / Fora de escopo**.
255
60
 
256
61
  ---
257
62
 
258
- ## Rules
63
+ ## Comandos
259
64
 
260
- Rules are installed to `.claude/rules/` based on your detected stack (`stacks:` frontmatter, same tagging mechanism as agents and templates) and activate automatically based on file path patterns (`paths:` frontmatter); no rule is always active — the workflow lives in `MORPH.md` and the skills. A subset of the current set:
261
-
262
- | Rule file | Applies to | Stack |
263
- | ----------------------------- | ------------------------------------------------- | --------- |
264
- | `csharp-standards.md` | `**/*.cs`, `**/*.csproj` | dotnet |
265
- | `frontend-standards.md` | `**/*.tsx`, `**/*.css`, `**/*.scss` | nextjs |
266
- | `nextjs-standards.md` | Next.js-specific patterns | nextjs |
267
- | `ai-agents-standards.md` | `**/Agents/**`, `**/*Agent*.cs` | dotnet |
268
- | `infrastructure-standards.md` | `**/Dockerfile*`, `**/docker-compose*`, `**/.github/**` | docker |
65
+ | Comando | Para quê |
66
+ | --- | --- |
67
+ | `init [--dry-run]` | contrato do repo e instalação filtrada pela stack |
68
+ | `update` | reinstala os payloads da versão da CLI |
69
+ | `plan-check` | valida o plano e grava `checks.json` |
70
+ | `prove-red <f> --test "<cmd>"` | o teste do cenário falha sem a mudança? |
71
+ | `check [--tier fast\|full\|e2e] [--report]` | testes do contrato + sinais de risco; `--report` grava `## Resultado` |
72
+ | `env` | portas e `COMPOSE_PROJECT_NAME` do branch |
73
+ | `standards --find "<tema>"` | o standard certo, por digest e âncora |
74
+ | `graph affected\|explain <símbolo>` | blast radius pelo grafo de código (sem grafo, grep) |
75
+ | `stack-scan`, `stack-set`, `tests-audit` | auditoria da stack, declaração da stack, auditoria dos testes |
76
+ | `doctor [--full\|--mcp\|--ai]` | saúde da instalação |
269
77
 
78
+ Referência completa: [`framework/docs/CLI.md`](framework/docs/CLI.md).
270
79
 
271
80
  ---
272
81
 
273
- ## Stack support
274
-
275
-
276
- | Technology | Support |
277
- | ------------------------------------------- | ------------------------------------------------------------- |
278
- | .NET 10 / ASP.NET Core | Full — VSA with direct handlers, result pattern, Minimal API |
279
- | EF Core / Neon (Postgres) | Full — migrations, Neon Auth (Better Auth) |
280
- | Next.js / React / TypeScript | Full — components, routing, state management |
281
- | Microsoft Agent Framework (MAF) | Full — single-agent + structured output + tools + RAG |
282
-
283
-
284
- TypeScript strict mode is enforced by default. See `.morph/framework/standards/` for all coding standards.
285
-
286
- ---
287
-
288
- ## Update
289
-
290
- To update the framework files in an existing project:
82
+ ## Desenvolvimento
291
83
 
292
84
  ```bash
293
- morph-spec update
85
+ npm test # suíte inteira (paralela)
86
+ npm run test:changed # só o que a mudança alcança
87
+ npm run generate:check && npm run validate
294
88
  ```
295
89
 
296
- This re-syncs `.morph/framework/`, `.claude/skills/`, `.claude/agents/`, `.claude/rules/`, and `CLAUDE.md` with the installed package version. Your `.morph/config/config.json`, `.morph/context/`, and feature outputs are not touched.
297
-
298
- After updating, run `morph-spec doctor` to confirm the installation is healthy.
299
-
300
- ---
301
-
302
- ## Key rules
303
-
304
- **Never skip phases.** Every feature starts with a plan. No code is written until `plan.md` passes `plan-check` and the plan gate is approved.
305
-
306
- **Never edit protected files directly:**
307
-
308
- - `.morph/state.json` — derived automatically from `feature.json`; use `morph-spec approve`/`advance`/`gate-decision` to change feature state
309
- - `.morph/framework/` — read-only, updated by `morph-spec update`
310
-
311
- **Always document decisions.** Architectural choices go in the `## Decisões` section of `2-plan/plan.md` (ADRs are indexed when the feature closes), not in commit messages.
312
-
313
- **Verify runs once per feature.** `morph-spec verify {feature}` runs the build + test + validator chain relevant to your stack; red triggers an autonomous correction loop rather than a pause. Gate 3 is three independent sub-agents (verifier, reviewer, security when required) that answer SHIP or FIX with evidence-typed blockers.
314
-
315
- ---
316
-
317
- ## Troubleshooting
318
-
319
- ### `morph-spec: command not found`
320
-
321
- The installer automatically adds the npm global directory to your PowerShell `$PROFILE`. Open a **new terminal** after installing. If it still doesn't work, add it manually:
322
-
323
- ```bash
324
- npm config get prefix
325
- # Add {prefix} to your PATH
326
- ```
327
-
328
- ### `morph-spec doctor` reports issues
329
-
330
- Run doctor to see all checks:
331
-
332
- ```bash
333
- morph-spec doctor
334
- ```
335
-
336
- Common fixes:
337
-
338
- - **Missing `.claude/agents/`** — run `morph-spec update` to reinstall agents
339
- - **Missing `.claude/rules/`** — run `morph-spec update` to reinstall rules
340
- - **State version mismatch** — state auto-migrates on next CLI command; if it fails, back up and re-init
341
- - **Hooks not firing** — confirm `.claude/settings.local.json` exists and contains the `hooks` key
342
-
343
- ### EPERM on Windows global install
344
-
345
- Windows may block global npm installs without elevated permissions. Options:
346
-
347
- 1. Run terminal as Administrator (not recommended long-term)
348
- 2. Change npm global prefix to a user-writable directory:
349
-
350
- ```bat
351
- mkdir %APPDATA%\npm-global
352
- npm config set prefix %APPDATA%\npm-global
353
- :: Add %APPDATA%\npm-global to your PATH
354
- npm install -g @polymorphism-tech/morph-spec@latest --prefer-online
355
- ```
356
-
357
- 1. Open a new terminal (the installer adds npm to your PATH automatically)
358
-
359
- ### Hook not triggering on SessionStart
360
-
361
- Ensure `.claude/settings.local.json` is not gitignored in your project. The file must be present for Claude Code to load hooks. If it is missing, re-run `morph-spec setup-infra` or `morph-spec init --force`.
362
-
363
- ---
364
-
365
- ## Standards
366
-
367
- The framework ships 60 registered standards across 7 categories (`ai-agents`, `architecture`, `backend`, `data`, `frontend`, `infrastructure`, `integration`), stored in `.morph/framework/standards/STANDARDS.json`. Standards are looked up on demand (by keyword/alias) rather than preloaded wholesale into context, and enforced via stack-aware, path-scoped rules installed to `.claude/rules/` during `morph-spec init`.
368
-
369
- ---
370
-
371
- ## License
372
-
373
- Proprietary — see [LICENSE](./LICENSE).
374
-
375
- Code generated by morph-spec (contracts, templates, implementation output) belongs to you.
376
-
377
- ---
378
-
379
- *morph-spec v10.12.0 by [Polymorphism Tech](https://polymorphism.tech)*
90
+ Veja [`CLAUDE.md`](CLAUDE.md) para a arquitetura do código e [`CONTRIBUTING.md`](CONTRIBUTING.md) para o fluxo de PR e release.