@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
@@ -1,129 +0,0 @@
1
- import { execFileSync } from 'child_process';
2
- import chalk from 'chalk';
3
- import { isGitRepo, resolvePrimaryRoot } from './worktree.js';
4
- import { detectDefaultBranch } from '../../lib/git/default-branch.js';
5
- import { buildPrIndex } from '../../lib/git/pr-index.js';
6
- import { classifyBranches } from '../../lib/git/branch-classifier.js';
7
-
8
- // `-D`, not `-d`: `-d` refuses every squash-merged branch. Safety comes from only
9
- // reaching here with integration positively proven.
10
- function deleteLocal(name, cwd) {
11
- try {
12
- execFileSync('git', ['branch', '-D', name], { cwd, stdio: 'pipe' });
13
- return { deleted: true };
14
- } catch (err) {
15
- return { deleted: false, error: (err.stderr?.toString() || err.message || 'unknown').trim().slice(0, 200) };
16
- }
17
- }
18
-
19
- function deleteRemote(name, cwd) {
20
- try {
21
- execFileSync('git', ['push', 'origin', '--delete', name], { cwd, stdio: 'pipe', timeout: 20000 });
22
- return { deleted: true };
23
- } catch (err) {
24
- return { deleted: false, error: (err.stderr?.toString() || err.message || 'unknown').trim().slice(0, 200) };
25
- }
26
- }
27
-
28
- function remoteRefExists(name, cwd) {
29
- try {
30
- execFileSync('git', ['show-ref', '--verify', '--quiet', `refs/remotes/origin/${name}`], { cwd, stdio: 'pipe' });
31
- return true;
32
- } catch {
33
- return false;
34
- }
35
- }
36
-
37
- export function branchPruneCommand(options = {}) {
38
- const cwd = options.cwd || process.cwd();
39
- const emit = (payload, code = 0) => {
40
- if (options.json) console.log(JSON.stringify(payload, null, 2));
41
- else printReport(payload, options);
42
- process.exitCode = code;
43
- return payload;
44
- };
45
-
46
- if (!isGitRepo(cwd)) {
47
- return emit({ pruned: [], kept: [], error: 'not-a-git-repo' });
48
- }
49
- const root = resolvePrimaryRoot(cwd);
50
- const defaultBranch = detectDefaultBranch(root);
51
- // null = UNKNOWN, never "no PR": a missing `gh` costs conservatism, not safety.
52
- const prIndex = buildPrIndex(root);
53
-
54
- const classified = classifyBranches({ cwd: root, defaultBranch, prIndex });
55
- const pruned = [];
56
- const kept = [];
57
-
58
- for (const b of classified) {
59
- if (!b.deletable) { kept.push(b); continue; }
60
- if (options.dryRun) {
61
- pruned.push({ ...b, deleted: false, dryRun: true, remoteDeleted: false });
62
- continue;
63
- }
64
- const local = deleteLocal(b.name, root);
65
- let remoteDeleted = false;
66
- let remoteError;
67
- if (local.deleted && options.remote && remoteRefExists(b.name, root)) {
68
- const r = deleteRemote(b.name, root);
69
- remoteDeleted = r.deleted;
70
- if (!r.deleted) remoteError = r.error;
71
- }
72
- if (local.deleted) pruned.push({ ...b, deleted: true, remoteDeleted, ...(remoteError ? { remoteError } : {}) });
73
- else kept.push({ ...b, kind: 'delete-failed', reason: `git branch -D falhou: ${local.error}`, deletable: false });
74
- }
75
-
76
- return emit({
77
- defaultBranch,
78
- prIndexAvailable: prIndex !== null,
79
- dryRun: options.dryRun === true,
80
- remote: options.remote === true,
81
- pruned,
82
- kept,
83
- });
84
- }
85
-
86
- const KIND_LABEL = {
87
- 'merged-ancestral': chalk.green('merged'),
88
- 'merged-squash': chalk.green('squash-merged'),
89
- open: chalk.yellow('PR aberto'),
90
- 'in-worktree': chalk.cyan('em uso'),
91
- unmerged: chalk.red('não integrada'),
92
- 'delete-failed': chalk.red('falhou'),
93
- };
94
-
95
- function printReport(payload, options) {
96
- if (payload.error === 'not-a-git-repo') {
97
- console.log(chalk.gray('não é um repositório git — nada a fazer'));
98
- return;
99
- }
100
- const verb = payload.dryRun ? 'seriam apagadas' : 'apagadas';
101
- console.log(chalk.bold(`\nbranch prune — default: ${payload.defaultBranch || chalk.red('não resolvida')}`));
102
- if (!payload.prIndexAvailable) {
103
- // Without `gh`, squash-merged branches may legitimately show as unmerged.
104
- console.log(chalk.gray(' (sem `gh`/GitHub: squash-merge só é detectado por árvore idêntica)'));
105
- }
106
-
107
- if (payload.pruned.length) {
108
- console.log(chalk.bold(`\n ${payload.pruned.length} ${verb}:`));
109
- for (const b of payload.pruned) {
110
- const remote = b.remoteDeleted ? chalk.gray(' + origin') : '';
111
- console.log(` ${KIND_LABEL[b.kind] || b.kind} ${chalk.bold(b.name)}${remote}`);
112
- console.log(chalk.gray(` ${b.reason}`));
113
- if (b.remoteError) console.log(chalk.yellow(` origin não apagada: ${b.remoteError}`));
114
- }
115
- } else {
116
- console.log(chalk.gray('\n nada a apagar'));
117
- }
118
-
119
- if (payload.kept.length) {
120
- console.log(chalk.bold(`\n ${payload.kept.length} mantida(s):`));
121
- for (const b of payload.kept) {
122
- console.log(` ${KIND_LABEL[b.kind] || b.kind} ${chalk.bold(b.name)}${b.ahead ? chalk.gray(` (+${b.ahead})`) : ''}`);
123
- console.log(chalk.gray(` ${b.reason}`));
124
- }
125
- }
126
- if (payload.dryRun) console.log(chalk.gray('\n --dry-run: nada foi apagado'));
127
- if (!options.remote && payload.pruned.length) console.log(chalk.gray(' branches remotas intactas (use --remote para apagá-las também)'));
128
- console.log();
129
- }
@@ -1,132 +0,0 @@
1
- import chalk from 'chalk';
2
- import { execSync } from 'child_process';
3
- import { resolve } from 'path';
4
- import { isGitRepo, resolvePrimaryRoot } from './worktree.js';
5
- import {
6
- acquireClaim,
7
- foreignClaim,
8
- listClaims,
9
- releaseClaim,
10
- claimAge,
11
- } from '../../../framework/hooks/shared/claim-registry.js';
12
-
13
- function gitCommonDirOf(cwd) {
14
- const root = resolvePrimaryRoot(cwd);
15
- const common = execSync('git rev-parse --git-common-dir', { cwd: root, stdio: 'pipe' }).toString().trim();
16
- return common ? resolve(root, common) : null;
17
- }
18
-
19
- const norm = (p) => String(p ?? '').replace(/\\/g, '/');
20
-
21
- /**
22
- * Moves this tree's live claim, identified by PATH: the CLI never sees the session id
23
- * SessionStart stamps. Reusing that claim's session id keeps the move from reading as a takeover.
24
- */
25
- function acquireOrMove(feature, { cwd, gitCommonDir, json }) {
26
- const here = norm(cwd);
27
- const previousHere = listClaims(gitCommonDir)
28
- .find((c) => c.live && c.feature !== feature && norm(c.path) === here);
29
- const takenFrom = foreignClaim(feature, { gitCommonDir, sessionId: previousHere?.sessionId });
30
-
31
- if (previousHere) releaseClaim(previousHere.feature, { gitCommonDir });
32
- const identity = previousHere?.sessionId || `cli-${process.pid}`;
33
- acquireClaim(feature, { gitCommonDir, sessionId: identity, pid: process.pid, path: cwd });
34
-
35
- if (json) {
36
- console.log(JSON.stringify({
37
- feature,
38
- claimed: true,
39
- movedFrom: previousHere?.feature ?? null,
40
- tookOverFrom: takenFrom ? { pid: takenFrom.pid, path: takenFrom.path } : null,
41
- }));
42
- process.exit(0);
43
- }
44
-
45
- console.log(previousHere
46
- ? chalk.green(`\n✅ Claim movido de "${previousHere.feature}" para "${feature}".\n`)
47
- : chalk.green(`\n✅ Claim de "${feature}" adquirido.\n`));
48
- if (takenFrom) {
49
- console.log(chalk.yellow(
50
- `⚠️ "${feature}" tinha claim VIVO de outra sessão (pid ${takenFrom.pid}` +
51
- `${takenFrom.path ? ` · ${takenFrom.path}` : ''}, visto há ${claimAge(takenFrom)}) — assumido agora. ` +
52
- 'Confirme com a outra sessão antes de finish/archive/delete.\n'
53
- ));
54
- }
55
- process.exit(0);
56
- }
57
-
58
- export function claimCommand(feature, options = {}) {
59
- const cwd = options.cwd || process.cwd();
60
- if (!isGitRepo(cwd)) {
61
- console.log(chalk.gray('Fora de um repositório git — não há registro de claims.'));
62
- process.exit(0);
63
- }
64
-
65
- let gitCommonDir = null;
66
- try {
67
- gitCommonDir = gitCommonDirOf(cwd);
68
- } catch { gitCommonDir = null; }
69
- if (!gitCommonDir) {
70
- console.log(chalk.gray('Não foi possível resolver o git common dir — nenhum claim a mostrar.'));
71
- process.exit(0);
72
- }
73
-
74
- if (options.release) {
75
- if (!feature) {
76
- console.error(chalk.red('\n❌ --release exige o nome da feature: morph-spec claim <feature> --release\n'));
77
- process.exit(1);
78
- }
79
- const released = releaseClaim(feature, { gitCommonDir });
80
- if (options.json) {
81
- console.log(JSON.stringify({ feature, released }));
82
- process.exit(0);
83
- }
84
- console.log(released
85
- ? chalk.green(`\n✅ Claim de "${feature}" liberado.\n`)
86
- : chalk.yellow(`\n⚠️ Nenhum claim registrado para "${feature}" — nada a liberar.\n`));
87
- process.exit(0);
88
- }
89
-
90
- if (feature && !options.list) {
91
- acquireOrMove(feature, { cwd, gitCommonDir, json: options.json });
92
- return;
93
- }
94
-
95
- const all = listClaims(gitCommonDir);
96
- const scoped = feature ? all.filter((c) => c.feature === feature) : all;
97
-
98
- // Claim morto segue no registro (`live` é computado na leitura): por padrão só o que ainda
99
- // avisa; `--all` devolve tudo e o rodapé conta o que ficou de fora.
100
- const rows = options.all ? scoped : scoped.filter((c) => c.live);
101
- const hidden = scoped.length - rows.length;
102
-
103
- if (options.json) {
104
- console.log(JSON.stringify(rows));
105
- process.exit(0);
106
- }
107
-
108
- if (!rows.length) {
109
- console.log(chalk.gray(feature
110
- ? `Nenhum claim vivo para "${feature}".`
111
- : 'Nenhuma feature reclamada — nenhuma sessão viva registrada.'));
112
- if (hidden > 0) {
113
- console.log(chalk.gray(`(${hidden} claim(s) morto(s) omitido(s) — \`--all\` para ver, \`--release\` para limpar)`));
114
- }
115
- process.exit(0);
116
- }
117
-
118
- const col = (s, w) => String(s ?? '-').padEnd(w);
119
- console.log(chalk.white.bold(col('FEATURE', 24) + col('ESTADO', 10) + col('VISTO HÁ', 12) + col('PID', 9) + 'ONDE'));
120
- for (const c of rows) {
121
- const state = c.live ? chalk.yellow('viva') : chalk.gray('morta');
122
- console.log(
123
- col(c.feature, 24) + state + ' '.repeat(Math.max(1, 10 - (c.live ? 4 : 5)))
124
- + col(claimAge(c), 12) + col(c.pid, 9) + (c.path || '-'),
125
- );
126
- }
127
- if (hidden > 0) {
128
- console.log(chalk.gray(`\n${hidden} claim(s) morto(s) omitido(s) — \`--all\` para ver.`));
129
- }
130
- console.log(chalk.gray('\nClaims são AVISOS, nunca bloqueios. Claim órfão: `morph-spec claim <f> --release`'));
131
- process.exit(0);
132
- }
@@ -1,162 +0,0 @@
1
- import chalk from 'chalk';
2
- import { logger } from '../../utils/logger.js';
3
- import { listProcesses } from '../../lib/procs/list.js';
4
- import { classifyProcs } from '../../lib/procs/classify.js';
5
- import { readMcpConfig, findDuplicateMcps, mcpCommandTokens } from '../../lib/procs/mcp-config.js';
6
- import { inspectWslConfig } from '../../lib/procs/wslconfig.js';
7
- import { readHeavyConfig } from '../../../framework/hooks/shared/heavy-config.js';
8
- import { heavyDir, heavyStatus } from '../../../framework/hooks/shared/heavy-holders.js';
9
-
10
- function readHolderPids(targetPath) {
11
- try {
12
- const config = readHeavyConfig(targetPath);
13
- const { holders } = heavyStatus({ dir: heavyDir(), maxHoldMs: config.maxHoldMinutes * 60_000 });
14
- return holders.map((h) => h.pid).filter(Number.isInteger);
15
- } catch {
16
- return [];
17
- }
18
- }
19
-
20
- export function formatAge(ms) {
21
- if (ms === null) return '?';
22
- const min = Math.floor(ms / 60000);
23
- if (min < 60) return `${min}min`;
24
- const h = Math.floor(min / 60);
25
- if (h < 48) return `${h}h${String(min % 60).padStart(2, '0')}`;
26
- return `${Math.floor(h / 24)}d`;
27
- }
28
-
29
- const VERDICT_TEXT = {
30
- orphan: 'órfão — `--prune` encerra por PID',
31
- protected: 'protegido',
32
- 'build-server': 'nó de build',
33
- };
34
-
35
- export function collectProcsReport(targetPath, deps = {}) {
36
- const d = { listProcesses, readMcpConfig, inspectWslConfig, now: Date.now(), ...deps };
37
- d.holderPids ??= readHolderPids(targetPath);
38
- const listing = d.listProcesses();
39
- const mcp = d.readMcpConfig({ projectDir: targetPath });
40
-
41
- let procs;
42
- let vmmemMb = 0;
43
- if (listing.procs === null) {
44
- procs = { status: 'skip', reason: listing.reason };
45
- } else {
46
- const { rows, sessions } = classifyProcs(listing.procs, {
47
- now: d.now,
48
- mcpTokens: mcpCommandTokens(mcp),
49
- holderPids: d.holderPids,
50
- });
51
- procs = { status: 'ok', sessions, total: rows.length, rows };
52
- const vmmem = listing.procs.filter((p) => p.name.startsWith('vmmem')).reduce((sum, p) => sum + p.rss, 0);
53
- vmmemMb = Math.round(vmmem / (1024 * 1024));
54
- }
55
-
56
- return {
57
- procs,
58
- mcp: {
59
- duplicates: findDuplicateMcps(mcp),
60
- unreadable: mcp.unreadable,
61
- servers: mcp.servers.length,
62
- pluginServers: mcp.pluginServers.length,
63
- },
64
- wsl: { ...d.inspectWslConfig(), vmmemMb },
65
- };
66
- }
67
-
68
- function renderProcs(procs) {
69
- if (procs.status === 'skip') {
70
- console.log(chalk.gray(` ○ Processos — não verificado: ${procs.reason}`));
71
- return;
72
- }
73
- const orphans = procs.rows.filter((r) => r.orphan);
74
- console.log(` ${chalk.bold('Processos')} — ${procs.total} candidato(s) (node, dotnet, testhost, esbuild, chrome headless), `
75
- + `${procs.total - orphans.length} com pai vivo, ${orphans.length} sem pai; ${procs.sessions} sessão(ões) do Claude viva(s)`);
76
- if (!orphans.length) {
77
- console.log(chalk.green(' ✓ nenhum processo órfão'));
78
- return;
79
- }
80
- for (const r of orphans) {
81
- const label = VERDICT_TEXT[r.verdict] ?? r.verdict;
82
- const mark = r.verdict === 'orphan' ? chalk.yellow(' ⚠') : chalk.gray(' ○');
83
- console.log(`${mark} pid ${r.pid} ${r.name} ${r.rssMb} MB, ${formatAge(r.ageMs)} — ${label}${r.reason ? `: ${r.reason}` : ''}`);
84
- if (r.cmd) console.log(chalk.gray(` ${r.cmd.length > 110 ? `${r.cmd.slice(0, 107)}...` : r.cmd}`));
85
- }
86
- }
87
-
88
- function renderMcp(mcp) {
89
- console.log(` ${chalk.bold('MCP duplicado')} — ${mcp.servers} servidor(es) de configuração, ${mcp.pluginServers} de plugin`);
90
- if (!mcp.duplicates.length) console.log(chalk.green(' ✓ nenhum MCP declarado no projeto e também entregue por plugin'));
91
- for (const dup of mcp.duplicates) {
92
- console.log(chalk.yellow(` ⚠ ${dup.server}: declarado em ${dup.declaredIn.join(', ')} e entregue pelo plugin ${dup.plugin} — sobem 2 processos`));
93
- console.log(chalk.gray(` tools: ${dup.toolNames.join(' e ')}`));
94
- console.log(chalk.gray(` conserto (só sugestão): remova "${dup.server}" do .mcp.json, ou desligue o plugin ${dup.plugin}`));
95
- }
96
- for (const file of mcp.unreadable) console.log(chalk.gray(` ○ não verificado: ${file} (ilegível)`));
97
- }
98
-
99
- function renderWsl(wsl) {
100
- if (wsl.status === 'skip') {
101
- console.log(chalk.gray(` ○ WSL — não verificado: ${wsl.reason}`));
102
- return;
103
- }
104
- const held = wsl.vmmemMb > 0 ? ` (vmmem segura ${wsl.vmmemMb} MB agora)` : '';
105
- if (wsl.status === 'missing') console.log(chalk.yellow(` ⚠ WSL — ${wsl.path} ausente${held}`));
106
- else if (wsl.suggestion) console.log(chalk.yellow(` ⚠ WSL — ${wsl.path} sem limite de memória ou sem devolução gradual${held}`));
107
- else console.log(chalk.green(` ✓ WSL — ${wsl.path} com memory=${wsl.memory} e autoMemoryReclaim=${wsl.autoMemoryReclaim}`));
108
- if (wsl.suggestion) {
109
- console.log(chalk.gray(' conserto (só sugestão; o morph-spec não escreve fora do repo), acrescente a esse arquivo:'));
110
- for (const line of wsl.suggestion.split('\n')) console.log(chalk.gray(` ${line}`));
111
- console.log(chalk.gray(' depois rode `wsl --shutdown` para o WSL reler o arquivo'));
112
- }
113
- }
114
-
115
- function renderPrune(results) {
116
- console.log(` ${chalk.bold('Poda')}`);
117
- if (!results.length) {
118
- console.log(chalk.green(' ✓ nada a podar'));
119
- return;
120
- }
121
- for (const r of results) {
122
- const line = `pid ${r.pid} ${r.name}${r.reason ? ` — ${r.reason}` : ''}`;
123
- if (r.outcome === 'killed') console.log(chalk.green(` ✓ encerrado: ${line}`));
124
- else if (r.outcome === 'skipped') console.log(chalk.gray(` ○ pulado: ${line}`));
125
- else console.log(chalk.red(` ✗ falhou: ${line}`));
126
- }
127
- }
128
-
129
- export async function doctorProcsCommand(targetPath, options = {}) {
130
- const report = collectProcsReport(targetPath, options.deps);
131
-
132
- if (options.prune) {
133
- const { pruneOrphans } = await import('../../lib/procs/prune.js');
134
- const { afterHeavyRun } = await import('../../lib/heavy/cleanup.js');
135
- report.prune = report.procs.status === 'ok' ? pruneOrphans(report.procs.rows, options.pruneDeps) : [];
136
- report.buildServer = afterHeavyRun({
137
- projectPath: targetPath, config: readHeavyConfig(targetPath), deps: options.cleanupDeps,
138
- });
139
- }
140
-
141
- if (options.json) {
142
- console.log(JSON.stringify(report, null, 2));
143
- } else {
144
- logger.header(options.prune ? 'Processos e memória (com --prune)' : 'Processos e memória (somente leitura)');
145
- renderProcs(report.procs);
146
- logger.blank();
147
- renderMcp(report.mcp);
148
- logger.blank();
149
- renderWsl(report.wsl);
150
- if (report.prune) {
151
- logger.blank();
152
- renderPrune(report.prune);
153
- const bs = report.buildServer;
154
- const mark = bs.status === 'ran' ? chalk.green('✓') : bs.status === 'failed' ? chalk.red('✗') : chalk.gray('○');
155
- console.log(` ${mark} nós de build (dotnet build-server shutdown): ${bs.status}${bs.reason ? ` — ${bs.reason}` : ''}`);
156
- }
157
- logger.blank();
158
- }
159
-
160
- process.exitCode = report.prune?.some((r) => r.outcome === 'failed') ? 1 : 0;
161
- return report;
162
- }
@@ -1,66 +0,0 @@
1
- import chalk from 'chalk';
2
- import { scanFleet } from '../../lib/worktree/fleet-scanner.js';
3
- import { claimAge } from '../../../framework/hooks/shared/claim-registry.js';
4
-
5
- export function fleetCommand(options = {}) {
6
- const fleet = scanFleet(options.cwd || process.cwd());
7
-
8
- if (options.json) {
9
- console.log(JSON.stringify(fleet));
10
- process.exit(0);
11
- }
12
-
13
- if (!fleet.entries.length) {
14
- console.log(chalk.gray('Frota vazia — nenhuma feature ativa (raiz ou worktrees).'));
15
- process.exit(0);
16
- }
17
-
18
- const col = (s, w) => String(s ?? '-').padEnd(w);
19
-
20
- /** `-` (unknown) shares the "nothing there" glyph on purpose: both mean "do not trust the local view alone". */
21
- const remoteCell = (r) => {
22
- if (!r) return '-';
23
- if (r.pr) return `PR #${r.pr.number}${r.pr.state && r.pr.state !== 'OPEN' ? ` (${r.pr.state.toLowerCase()})` : ''}`;
24
- return r.pushed ? 'pushed' : 'local';
25
- };
26
-
27
- const claimCell = (c) => {
28
- if (!c) return '-';
29
- const age = claimAge(c);
30
- return c.live ? chalk.yellow(`sessão (${age})`) : chalk.gray(`morta (${age})`);
31
- };
32
-
33
- console.log(chalk.white.bold(
34
- // PHASE at 18 fits `aguardando-merge`; narrower misaligns every column after it.
35
- col('FEATURE', 20) + col('TYPE', 9) + col('PHASE', 18) + col('CENÁRIOS', 10)
36
- + col('GATES PEND.', 20) + col('WHERE', 24) + col('REMOTO', 16) + col('CLAIM', 16)
37
- + col('PORTS', 12) + 'ATIVIDADE',
38
- ));
39
- for (const e of fleet.entries) {
40
- const scenarios = e.scenarios ? `${e.scenarios.done}/${e.scenarios.total}` : '-';
41
- const gates = e.pendingGates.length ? e.pendingGates.join(',') : '-';
42
- // pr-pending exists only on its branch, never in a worktree or the root.
43
- const where = (e.location === 'worktree' || e.location === 'pr-pending') ? e.branch : 'raiz';
44
- const ports = e.env ? `${e.env.range[0]}-${e.env.range[1]}` : '-';
45
- const activity = [
46
- e.lastCommit ? `commit ${e.lastCommit}` : null,
47
- Number.isInteger(e.dirty) && e.dirty > 0 ? chalk.yellow(`${e.dirty} dirty`) : null,
48
- ].filter(Boolean).join(' · ') || '-';
49
- // padEnd counts invisible color codes, so pad the claim cell on its plain
50
- // length and append the padding by hand.
51
- const claimPlain = e.claim ? `${e.claim.live ? 'sessão' : 'morta'} (${claimAge(e.claim)})` : '-';
52
- console.log(
53
- col(e.feature, 20) + col(e.workType || '-', 9) + col(e.phase, 18) + col(scenarios, 10)
54
- + col(gates, 20) + col(where, 24) + col(remoteCell(e.remote), 16)
55
- + claimCell(e.claim) + ' '.repeat(Math.max(1, 16 - claimPlain.length))
56
- + col(ports, 12) + activity,
57
- );
58
- }
59
- const claimed = fleet.entries.filter((e) => e.claim?.live);
60
- if (claimed.length) {
61
- console.log(chalk.yellow(`\n⚠ ${claimed.length} feature(s) com sessão ativa — confirme antes de finish/archive/delete.`));
62
- console.log(chalk.gray(" Claim órfão de sessão morta: `morph-spec claim <f> --release`"));
63
- }
64
- console.log(chalk.gray(`\nRaiz primária: ${fleet.root}`));
65
- process.exit(0);
66
- }
@@ -1,81 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import chalk from 'chalk';
3
- import { logger } from '../../utils/logger.js';
4
- import { readHeavyConfig } from '../../../framework/hooks/shared/heavy-config.js';
5
- import { createHeavyGate, HeavyBusyError } from '../../lib/heavy/gate.js';
6
- import { describeHolder, heavyDir, heavyStatus } from '../../../framework/hooks/shared/heavy-slots.js';
7
- import { resolveSpawn } from '../../../framework/hooks/shared/spawn-command.js';
8
- import { heavyClass, heavyKind } from '../../../framework/hooks/shared/heavy-command.js';
9
- import { memoryBusyHint } from '../../lib/heavy/live-stacks.js';
10
- import { reclaimUnlessDisabled } from '../../lib/heavy/reclaim.js';
11
-
12
- const EXIT_BUSY = 3;
13
-
14
- export function heavyReclaimCommand(options = {}) {
15
- const projectPath = process.cwd();
16
- const result = reclaimUnlessDisabled({ projectPath, config: readHeavyConfig(projectPath) });
17
- if (options.json) {
18
- console.log(JSON.stringify(result));
19
- return result;
20
- }
21
- const gone = [...result.freed, ...result.containers];
22
- console.log(gone.length ? `Derrubado: ${gone.join(', ')}` : 'Nada ocioso para derrubar.');
23
- return result;
24
- }
25
-
26
- export function heavyStatusCommand(options = {}) {
27
- const config = readHeavyConfig(process.cwd());
28
- const status = heavyStatus({ dir: heavyDir(), maxHoldMs: config.maxHoldMinutes * 60_000 });
29
- const report = {
30
- enabled: config.enabled,
31
- slots: config.slots,
32
- minFreeMemGb: config.minFreeMemGb,
33
- minFreeMemGbByKind: config.minFreeMemGbByKind,
34
- dir: status.dir,
35
- freeGb: Number(status.freeGb.toFixed(2)),
36
- holders: status.holders.map(({ pid, label, feature, node, cwd, since, leaseId }) => ({ pid, label, feature, node, cwd, since, ...(leaseId ? { leaseId } : {}) })),
37
- exclusive: status.exclusive ? { pid: status.exclusive.pid, label: status.exclusive.label, since: status.exclusive.since } : null,
38
- };
39
-
40
- if (options.json) {
41
- console.log(JSON.stringify(report, null, 2));
42
- return report;
43
- }
44
-
45
- logger.header('Slots de nós pesados (build, testes, e2e)');
46
- if (!config.enabled) console.log(chalk.yellow(' ⚠ semáforo desligado (heavy.enabled: false ou MORPH_HEAVY=off)'));
47
- console.log(chalk.gray(` diretório: ${report.dir}`));
48
- const floors = config.minFreeMemGbByKind;
49
- const memMark = report.freeGb < Math.max(...Object.values(floors)) ? chalk.yellow('⚠') : chalk.green('✓');
50
- const floorText = Object.entries(floors).map(([kind, gb]) => `${kind} ${gb}`).join(' · ');
51
- console.log(` ${memMark} RAM livre: ${report.freeGb.toFixed(1)} GB (mínimo em GB: ${floorText})`);
52
- console.log(` slots em uso: ${status.holders.length}/${config.slots}`);
53
- for (const h of status.holders) console.log(chalk.gray(` • ${describeHolder(h)}${h.cwd ? ` — ${h.cwd}` : ''}`));
54
- if (status.exclusive) console.log(chalk.yellow(` ⚠ limpeza do servidor de build em curso (${describeHolder(status.exclusive)})`));
55
- logger.blank();
56
- return report;
57
- }
58
-
59
- export function heavyRunCommand(command, options = {}) {
60
- const [file, ...args] = command;
61
- const gate = createHeavyGate({ projectPath: process.cwd(), label: options.label ?? 'run' });
62
- try {
63
- gate.enter(file, heavyClass(heavyKind(command.join(' '))));
64
- } catch (err) {
65
- if (!(err instanceof HeavyBusyError)) throw err;
66
- console.error(chalk.yellow(`\n⏳ ${file} não rodou: ${err.message}. Não é vermelho — a fila já esperou o prazo dela: não repita em laço — siga sem esta rodada e avise o usuário (\`morph-spec heavy status\` mostra quem segura os slots).\n`));
67
- const hint = memoryBusyHint(err, process.cwd());
68
- if (hint) console.error(chalk.yellow(`${hint}\n`));
69
- process.exit(EXIT_BUSY);
70
- }
71
-
72
- const spawn = resolveSpawn(file, args);
73
- const res = spawnSync(spawn.file, spawn.args, { stdio: 'inherit', shell: spawn.shell });
74
- gate.release();
75
-
76
- if (res.error) {
77
- console.error(chalk.red(`\n❌ não consegui executar ${file}: ${res.error.message}\n`));
78
- process.exit(127);
79
- }
80
- process.exit(res.status ?? 1);
81
- }
@@ -1,27 +0,0 @@
1
- import { installPlugin } from '../../scripts/install-plugin.js';
2
- import { logger } from '../../utils/logger.js';
3
-
4
- export async function installPluginCommand(pluginName, _options) {
5
- if (!pluginName) {
6
- logger.error('Plugin name required. Usage: morph-spec install-plugin <name>');
7
- logger.dim(' Available: context7');
8
- process.exit(1);
9
- }
10
- try {
11
- const result = await installPlugin(pluginName);
12
- if (result.alreadyInstalled) {
13
- logger.dim(` ✓ ${pluginName} already installed (${result.version})`);
14
- } else {
15
- logger.success(` ✓ ${pluginName} installed (${result.version})`);
16
- logger.dim(' Restart Claude Code to activate.');
17
- }
18
- } catch (err) {
19
- logger.error(`Failed to install plugin "${pluginName}": ${err.message}`);
20
- logger.blank();
21
- logger.warn('Manual installation:');
22
- logger.dim(' 1. Claude Code → Settings (Cmd/Ctrl+,) → Extensions');
23
- logger.dim(` 2. Browse → search "${pluginName}" → Install`);
24
- logger.dim(' 3. Restart Claude Code');
25
- process.exit(1);
26
- }
27
- }
@@ -1,61 +0,0 @@
1
- import chalk from 'chalk';
2
- import { join } from 'path';
3
- import { getFeature, derivePhase, deriveOutputs } from '../../core/state/state-manager.js';
4
- import { implementProgress } from '../../../framework/hooks/shared/report-progress.js';
5
- import { PHASE_NAME, retrato } from '../../../framework/hooks/shared/owner-words.js';
6
- import { nextStepFor } from '../../lib/next-step.js';
7
-
8
- export async function statusCommand(featureName, options = {}) {
9
- if (!featureName) {
10
- console.error(chalk.red('✗ Diga qual feature: morph-spec status <feature>'));
11
- process.exit(1);
12
- }
13
-
14
- let feature;
15
- try {
16
- feature = getFeature(featureName);
17
- } catch (err) {
18
- console.error(chalk.red(`✗ Não consegui ler o estado do projeto: ${err.message}`));
19
- console.error(chalk.gray('Para diagnosticar: morph-spec doctor'));
20
- process.exit(1);
21
- }
22
- if (!feature) {
23
- console.error(chalk.red(`✗ Não achei a feature ${featureName} neste projeto.`));
24
- process.exit(1);
25
- }
26
-
27
- const featurePath = join(process.cwd(), '.morph', 'features', featureName);
28
- const phase = feature.phase || derivePhase(featurePath);
29
- const next = nextStepFor(featureName, process.cwd());
30
-
31
- if (options.json) {
32
- const order = ['plan', 'uiux', 'implement', 'review'];
33
- const at = order.indexOf(phase);
34
- const phases = order.map((key, i) => ({
35
- key, name: PHASE_NAME[key], optional: key === 'uiux',
36
- status: i < at ? 'completed' : i === at ? 'current' : 'pending',
37
- }));
38
- const required = phases.filter((p) => !p.optional);
39
- console.log(JSON.stringify({
40
- feature: featureName,
41
- phase,
42
- phaseName: PHASE_NAME[phase] ?? phase,
43
- status: feature.status,
44
- completion: Math.round((required.filter((p) => p.status === 'completed').length / required.length) * 100),
45
- phases,
46
- outputs: Object.entries(feature.outputs || deriveOutputs(featureName, process.cwd())).map(([type, o]) => ({ type, created: o.created, path: o.path })),
47
- scenarios: implementProgress(featurePath),
48
- approvals: feature.approvalGates || {},
49
- next,
50
- }, null, 2));
51
- return;
52
- }
53
-
54
- const lines = next?.retrato
55
- ?? retrato({ slug: featureName, feature, progress: implementProgress(featurePath), phase });
56
- console.log('');
57
- for (const line of lines) console.log(line);
58
- console.log('');
59
- }
60
-
61
- export default statusCommand;