@polymorphism-tech/morph-spec 4.22.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1198
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -31
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -243
  35. package/framework/phases.json +41 -115
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  47. package/framework/templates/CLAUDE.md.core.template +22 -0
  48. package/framework/templates/REGISTRY.json +4 -4
  49. package/framework/workflows/configs/fast-track.json +5 -10
  50. package/framework/workflows/configs/full.json +4 -8
  51. package/framework/workflows/configs/quick.json +32 -0
  52. package/framework/workflows/configs/standard.json +57 -64
  53. package/package.json +7 -6
  54. package/src/commands/mcp/mcp-setup.js +58 -31
  55. package/src/commands/project/doctor.js +69 -70
  56. package/src/commands/project/init.js +26 -5
  57. package/src/commands/project/status.js +18 -19
  58. package/src/commands/state/approve.js +1 -1
  59. package/src/commands/validation/validate-feature.js +18 -112
  60. package/src/core/paths/output-schema.js +133 -152
  61. package/src/core/state/phase-state-machine.js +10 -24
  62. package/src/core/state/state-manager.js +17 -17
  63. package/src/core/workflows/workflow-detector.js +214 -31
  64. package/src/core/workflows/workflow-router.js +204 -0
  65. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  66. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  67. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  68. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  69. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  70. package/src/dashboard/scanner/agents-scanner.js +30 -35
  71. package/src/lib/agents/metrics-aggregator.js +1 -1
  72. package/src/lib/agents/output-collector.js +7 -9
  73. package/src/lib/context/context-builder.js +289 -0
  74. package/src/lib/detectors/claude-config-detector.js +19 -3
  75. package/src/lib/generators/context-generator.js +20 -42
  76. package/src/lib/generators/index.js +1 -0
  77. package/src/lib/generators/mandate-generator.js +512 -0
  78. package/src/lib/generators/metadata-extractor.js +1 -1
  79. package/src/lib/generators/recap-generator.js +3 -4
  80. package/src/lib/installers/mcp-installer.js +300 -92
  81. package/src/lib/phase-chain/phase-validator.js +36 -40
  82. package/src/lib/stack/stack-profile.js +74 -91
  83. package/src/lib/tasks/task-parser.js +1 -1
  84. package/src/lib/tasks/wave-resolver.js +353 -0
  85. package/src/lib/validators/checkpoint-persistence.js +2 -2
  86. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  87. package/src/lib/validators/content/index.js +1 -0
  88. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  89. package/src/scripts/global-install.js +2 -27
  90. package/src/utils/agents-installer.js +224 -447
  91. package/src/utils/claude-settings-manager.js +57 -15
  92. package/src/utils/file-copier.js +1 -0
  93. package/src/utils/hooks-installer.js +15 -117
  94. package/src/utils/skills-installer.js +12 -18
  95. package/bin/detect-agents.js +0 -226
  96. package/bin/task-manager.js +0 -1036
  97. package/framework/agents/README.md +0 -13
  98. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  99. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  100. package/framework/agents/architecture/architecture-expert.md +0 -98
  101. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  102. package/framework/agents/architecture/packages-validator.md +0 -89
  103. package/framework/agents/architecture/security-expert.md +0 -79
  104. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  105. package/framework/agents/architecture/standards-architect.md +0 -153
  106. package/framework/agents/backend/dotnet-senior.md +0 -163
  107. package/framework/agents/backend/ef-modeler.md +0 -119
  108. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  109. package/framework/agents/backend/ms-agent-expert.md +0 -55
  110. package/framework/agents/backend/neon-expert.md +0 -379
  111. package/framework/agents/frontend/css-specialist.md +0 -89
  112. package/framework/agents/frontend/design-system-validator.md +0 -100
  113. package/framework/agents/frontend/gsap-animator.md +0 -131
  114. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  115. package/framework/agents/frontend/nextjs-expert.md +0 -201
  116. package/framework/agents/frontend/ui-designer.md +0 -259
  117. package/framework/agents/infrastructure/infra-architect.md +0 -215
  118. package/framework/agents/integrations/asaas-financial.md +0 -138
  119. package/framework/agents/integrations/neon-auth.md +0 -151
  120. package/framework/agents/integrations/resend-email.md +0 -127
  121. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  122. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  123. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  124. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  125. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  126. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  127. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  128. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  129. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  130. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  131. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  132. package/framework/hooks/shared/compact-restore.js +0 -123
  133. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  134. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  135. package/framework/hooks/shared/stale-task-reset.js +0 -57
  136. package/framework/hooks/shared/worktree-helpers.js +0 -75
  137. package/framework/skills/level-0-meta/README.md +0 -7
  138. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  139. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  140. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  141. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  142. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  143. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  144. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  145. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  146. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  147. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  148. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  149. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  150. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  151. package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +0 -290
  152. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  153. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  154. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -401
  155. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  156. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  157. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  158. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  159. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  160. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  161. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  162. package/framework/skills/level-1-workflows/README.md +0 -7
  163. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  164. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  165. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  166. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  168. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  169. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -634
  170. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  171. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -54
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  173. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  174. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  175. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  176. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  177. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  181. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -995
  182. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  183. package/framework/squad-templates/backend-only.json +0 -47
  184. package/framework/squad-templates/frontend-only.json +0 -56
  185. package/framework/squad-templates/full-stack.json +0 -74
  186. package/src/commands/agents/agent-metrics.js +0 -174
  187. package/src/commands/agents/audit-dispatch.js +0 -82
  188. package/src/commands/agents/detect-agents.js +0 -275
  189. package/src/commands/agents/dispatch-agents.js +0 -461
  190. package/src/commands/agents/index.js +0 -13
  191. package/src/commands/agents/manage-agents.js +0 -352
  192. package/src/commands/agents/project-metrics.js +0 -74
  193. package/src/commands/phase/phase-reset.js +0 -74
  194. package/src/commands/scope/escalate.js +0 -217
  195. package/src/commands/state/advance-phase.js +0 -600
  196. package/src/commands/state/phase-runner.js +0 -215
  197. package/src/commands/state/state.js +0 -444
  198. package/src/commands/task/expand.js +0 -100
  199. package/src/commands/tasks/index.js +0 -4
  200. package/src/commands/tasks/task.js +0 -105
  201. package/src/commands/templates/index.js +0 -5
  202. package/src/commands/templates/template-render.js +0 -93
  203. package/src/commands/trust/trust.js +0 -118
  204. package/src/lib/agents/agents-manager.js +0 -349
  205. package/src/lib/build/build-runner.js +0 -99
  206. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  207. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  208. package/src/lib/scope/impact-analyzer.js +0 -106
  209. package/src/lib/trust/trust-manager.js +0 -157
  210. package/src/utils/tier-helpers.js +0 -24
  211. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
package/bin/morph-spec.js CHANGED
@@ -1,491 +1,224 @@
1
- #!/usr/bin/env node
2
-
3
- import { program } from 'commander';
4
- import chalk from 'chalk';
5
- import { fileURLToPath } from 'url';
6
- import { dirname, join } from 'path';
7
- import { readFileSync } from 'fs';
8
-
9
- // Project commands
10
- import { initCommand } from '../src/commands/project/init.js';
11
- import { setupInfraCommand } from '../src/commands/project/setup-infra-cmd.js';
12
- import { installPluginCommand } from '../src/commands/project/install-plugin-cmd.js';
13
- import { updateCommand } from '../src/commands/project/update.js';
14
- import { doctorCommand } from '../src/commands/project/doctor.js';
15
-
16
- import { statusCommand } from '../src/commands/project/status.js';
17
- import { worktreeSetupCommand } from '../src/commands/project/worktree.js';
18
- import { checkpointSaveCommand } from '../src/commands/project/checkpoint.js';
19
-
20
- // State commands
21
- import { stateCommand } from '../src/commands/state/state.js';
22
- import { advancePhaseCommand } from '../src/commands/state/advance-phase.js';
23
- import { approveCommand, approvalStatusCommand, unapproveCommand } from '../src/commands/state/approve.js';
24
- import { phaseRunCommand } from '../src/commands/state/phase-runner.js';
25
- import { phaseResetCommand } from '../src/commands/phase/phase-reset.js';
26
-
27
- // Agent commands
28
- import { dispatchAgentsCommand } from '../src/commands/agents/dispatch-agents.js';
29
- import { auditDispatchCommand } from '../src/commands/agents/audit-dispatch.js';
30
- import { detectAgentsCommand } from '../src/commands/agents/detect-agents.js';
31
- import { agentMetricsCommand } from '../src/commands/agents/agent-metrics.js';
32
- import {
33
- agentListCommand,
34
- agentShowCommand,
35
- agentAddCommand,
36
- agentEditCommand,
37
- agentRemoveCommand,
38
- } from '../src/commands/agents/manage-agents.js';
39
-
40
- // Task commands
41
- import { taskDoneCommand, taskStartCommand, taskBulkDoneCommand, taskAnnotateCommand } from '../src/commands/tasks/task.js';
42
-
43
- // Scope escalation commands
44
- import { scopeEscalateCommand } from '../src/commands/scope/escalate.js';
45
- import { taskExpandCommand } from '../src/commands/task/expand.js';
46
-
47
- // Validation commands
48
- import { validateCommand } from './validate.js';
49
- import { validateFeatureCommand } from '../src/commands/validation/validate-feature.js';
50
-
51
- // Template commands
52
- import { templateRenderCommand } from '../src/commands/templates/template-render.js';
53
-
54
- // Scaffold commands
55
- import { scaffoldDotnetCommand, scaffoldNextjsCommand } from '../src/commands/scaffold/scaffold.js';
56
- // MCP commands
57
- import { mcpSetupCommand } from '../src/commands/mcp/mcp-setup.js';
58
-
59
- // Trust commands
60
- import { trustStatusCommand, trustSetCommand } from '../src/commands/trust/trust.js';
61
-
62
- // Project metrics
63
- import { projectMetricsCommand } from '../src/commands/agents/project-metrics.js';
64
-
65
- // Context commands
66
- import { contextRefreshCommand } from '../src/commands/context/context-refresh.js';
67
-
68
- // Dashboard commands
69
- import { dashboardCommand } from '../src/commands/dashboard/dashboard.js';
70
-
71
- const __dirname = dirname(fileURLToPath(import.meta.url));
72
- const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
73
-
74
- const banner = chalk.cyan(`
75
- ███╗ ███╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗
76
- ████╗ ████║██╔═══██╗██╔══██╗██╔══██╗██║ ██║
77
- ██╔████╔██║██║ ██║██████╔╝██████╔╝███████║
78
- ██║╚██╔╝██║██║ ██║██╔══██╗██╔═══╝ ██╔══██║
79
- ██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ██║ ██║
80
- ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
81
-
82
- Methodical Orchestration for Reliable Production-ready SPEC-driven development
83
- by Polymorphism Tech | v${pkg.version}
84
- `);
85
-
86
- program
87
- .name('morph-spec')
88
- .description('MORPH-SPEC Framework CLI')
89
- .version(pkg.version)
90
- .addHelpText('beforeAll', banner);
91
-
92
- program
93
- .command('init')
94
- .description('Initialize MORPH-SPEC in current directory')
95
- .option('-f, --force', 'Overwrite existing MORPH installation')
96
- .option('-p, --path <path>', 'Target path (default: current directory)')
97
- .option('--skip-mcp', 'Skip MCP server auto-setup')
98
- .action(initCommand);
99
-
100
- program
101
- .command('setup-infra')
102
- .description('Install MORPH-SPEC infrastructure (headless, no prompts). Called by /morph-init skill.')
103
- .option('-p, --path <path>', 'Target path (default: current directory)')
104
- .option('--reinstall', 'Re-install only stack-aware assets (rules, skills, agents)')
105
- .action(setupInfraCommand);
106
-
107
- program
108
- .command('install-plugin <name>')
109
- .description('Install a Claude Code plugin (superpowers, context7). Called by /morph-init skill.')
110
- .action(installPluginCommand);
111
-
112
- program
113
- .command('update')
114
- .description('Update MORPH templates and standards to latest version')
115
- .option('--templates', 'Update only templates')
116
- .option('--standards', 'Update only standards')
117
- .action(updateCommand);
118
-
119
- program
120
- .command('doctor')
121
- .description('Check MORPH installation health')
122
- .option('--full', 'Run full health check (lib files, commands, HOPs, standards, agents, state)')
123
- .option('--mcp', 'Check MCP server configuration (binary + env vars)')
124
- .option('--reset', 'Remove morph-managed entries from .claude/settings.local.json')
125
- .action(doctorCommand);
126
-
127
- program
128
- .command('status <feature>')
129
- .description('Show comprehensive feature status dashboard')
130
- .option('--json', 'Output as JSON')
131
- .option('-v, --verbose', 'Show detailed output')
132
- .action(statusCommand);
133
-
134
- // Worktree commands
135
- const worktreeCommand = program
136
- .command('worktree')
137
- .description('Manage git worktrees for feature isolation');
138
-
139
- worktreeCommand
140
- .command('setup <feature>')
141
- .description('Create a worktree at .worktrees/{feature}/ on branch morph/{feature}')
142
- .option('--fresh', 'Create a new dated branch even if one already exists')
143
- .action((feature, options) => worktreeSetupCommand(feature, options));
144
-
145
- // State management commands
146
- program
147
- .command('state <action> [args...]')
148
- .description('Manage state.json (init | get | set | list | add-agent | remove-agent | mark-output)')
149
- .option('--force', 'Force overwrite (init) or bypass phase protection gates (set phase)')
150
- .option('--project <name>', 'Project name (init command)')
151
- .option('--type <type>', 'Project type (init command)')
152
- .option('--json', 'Output as JSON (get command)')
153
- .action((action, args, options) => stateCommand(action, args, options));
154
-
155
- // Task management commands (MORPH-SPEC 3.0)
156
- const taskCommand = program
157
- .command('task')
158
- .description('Manage feature tasks (done | start | expand | annotate)');
159
-
160
- taskCommand
161
- .command('done <feature> <task-ids...>')
162
- .description('Mark tasks as completed (runs validation first)')
163
- .option('--note <text>', 'Add a deviation note explaining why task was done differently than planned')
164
- .option('--skip-validation', 'Skip code validation (budget-limited, requires --reason)')
165
- .option('--reason <text>', 'Reason for skipping validation (required with --skip-validation)')
166
- .option('--skip-build', 'Skip test build guard')
167
- .option('--dry-run', 'Show validation results without marking tasks as complete')
168
- .action((feature, taskIds, options) => taskDoneCommand(feature, taskIds, options));
169
-
170
- taskCommand
171
- .command('start <feature> <task-id>')
172
- .description('Start a task (mark as in_progress)')
173
- .action((feature, taskId, options) => taskStartCommand(feature, taskId, options));
174
-
175
- taskCommand
176
- .command('expand <feature> <task-id>')
177
- .description('Expand a task into sub-tasks (low-impact scope escalation)')
178
- .option('--into <subtasks...>', 'Sub-task definitions ("T017a: Title")')
179
- .action((feature, taskId, options) => taskExpandCommand(feature, taskId, options));
180
-
181
- taskCommand
182
- .command('bulk-done <feature> [range]')
183
- .description('Complete multiple tasks with a single validation pass')
184
- .option('--all', 'Complete all non-completed tasks')
185
- .option('--from <id>', 'Start of task range (e.g. T007)')
186
- .option('--to <id>', 'End of task range (e.g. T014)')
187
- .option('--note <text>', 'Add a deviation note explaining why tasks were done differently than planned')
188
- .option('--skip-validation', 'Skip code validation (budget-limited, requires --reason)')
189
- .option('--reason <text>', 'Reason for skipping validation (required with --skip-validation)')
190
- .option('--skip-build', 'Skip test build guard')
191
- .option('--dry-run', 'Show validation results without marking tasks as complete')
192
- .action((feature, range, options) => taskBulkDoneCommand(feature, range, options));
193
-
194
- taskCommand
195
- .command('annotate <feature> <task-id> <text>')
196
- .description('Add a note to a task (deviation, context, or blocker resolution)')
197
- .option('--type <type>', 'Note type: deviation | context | blocker-resolved', 'deviation')
198
- .option('--mark-done', 'Also mark the task as completed')
199
- .action((feature, taskId, text, options) => taskAnnotateCommand(feature, taskId, text, options));
200
-
201
- // Generation commands
202
- const generateCommand = program
203
- .command('generate')
204
- .description('Generate code from templates');
205
-
206
- generateCommand
207
- .command('recap <feature>')
208
- .description('Auto-generate recap.md from project data (state, validation, contracts)')
209
- .option('--quiet', 'Suppress output')
210
- .action(async (feature, options) => {
211
- const { generateRecap } = await import('../src/lib/generators/recap-generator.js');
212
- await generateRecap('.', feature, options);
213
- });
214
-
215
- // Validation commands (Sprint 4: Continuous Validation)
216
- program
217
- .command('validate [validator]')
218
- .description('Run project validations (all | packages | architecture | contrast)')
219
- .option('-v, --verbose', 'Show detailed output')
220
- .option('--auto-fix, --fix', 'Auto-fix issues where possible')
221
- .option('--no-fail', 'Don\'t exit with error code')
222
- .option('--wcag-aaa', 'Use WCAG AAA standard (stricter)')
223
- .action((validator, options) => {
224
- const args = validator ? [validator] : ['all'];
225
- if (options.verbose) args.push('--verbose');
226
- if (options.autoFix) args.push('--auto-fix');
227
- if (options.noFail) args.push('--no-fail');
228
- if (options.wcagAaa) args.push('--wcag-aaa');
229
- validateCommand(args);
230
- });
231
-
232
- // Phase management commands
233
- const phaseCommand = program
234
- .command('phase')
235
- .description('Phase management (advance | validate)');
236
-
237
- phaseCommand
238
- .command('advance <feature>')
239
- .description('Validate current phase and advance to next')
240
- .option('--skip-optional', 'Skip optional phases (uiux, sync)')
241
- .option('--skip-approval', 'Skip approval gate checks')
242
- .option('--force', 'Force phase transition even if state machine rejects it')
243
- .action((feature, options) => advancePhaseCommand(feature, options));
244
-
245
- phaseCommand
246
- .command('run <feature>')
247
- .description('Automated phase chain runner — advances phases until blocker or max reached')
248
- .option('--dry-run', 'Show decision tree without executing')
249
- .option('--max-phases <n>', 'Max phases to auto-advance (default: 6)', parseInt)
250
- .option('--skip-approval', 'Skip approval gate checks')
251
- .action((feature, options) => phaseRunCommand(feature, options));
252
-
253
- phaseCommand
254
- .command('reset <feature> <phase>')
255
- .description('Reset feature phase (recovery tool — bypasses approval gates)')
256
- .action((feature, phase) => phaseResetCommand(feature, phase));
257
-
258
- // Feature validation command (content-aware)
259
- program
260
- .command('validate-feature <feature>')
261
- .alias('vf')
262
- .description('Content-aware validation of feature outputs (sections, schema, contracts)')
263
- .option('--phase <phase>', 'Validate outputs for a specific phase')
264
- .option('--json', 'Output as JSON')
265
- .option('-v, --verbose', 'Show detailed output')
266
- .action(validateFeatureCommand);
267
-
268
- // Checkpoint save/restore commands
269
- program
270
- .command('checkpoint-save <feature>')
271
- .description('Save full context at current phase boundary')
272
- .option('--label <label>', 'Custom label for checkpoint')
273
- .action(checkpointSaveCommand);
274
-
275
- // Approval workflow commands
276
- program
277
- .command('approve <feature> <gate>')
278
- .description('Approve a phase gate (design, tasks, uiux, proposal)')
279
- .option('--approver <name>', 'Name of approver (default: current user)')
280
- .option('--notes <notes>', 'Approval notes')
281
- .action((feature, gate, options) => approveCommand(feature, gate, options));
282
-
283
- program
284
- .command('approval-status <feature>')
285
- .description('Show approval status for all gates')
286
- .option('--json', 'Output as JSON')
287
- .action((feature, options) => approvalStatusCommand(feature, options));
288
-
289
- program
290
- .command('unapprove <feature> <gate>')
291
- .description('Revoke a phase gate approval (proposal, design, tasks, uiux)')
292
- .option('--revoker <name>', 'Name of person revoking (default: current user)')
293
- .option('--reason <reason>', 'Reason for revocation')
294
- .action((feature, gate, options) => unapproveCommand(feature, gate, options));
295
-
296
- // Template management commands
297
- const templateCommand = program
298
- .command('template')
299
- .description('Template management (render)');
300
-
301
- templateCommand
302
- .command('render <template-id> <output-path> <variables-json>')
303
- .description('Render a template with variables')
304
- .option('--dry-run', 'Preview without writing file')
305
- .option('--project-path <path>', 'Project path (default: current directory)')
306
- .option('-v, --verbose', 'Show detailed output')
307
- .action(templateRenderCommand);
308
-
309
- // Scaffold commands (code generation from templates)
310
- const scaffoldCmd = program
311
- .command('scaffold')
312
- .description('Generate feature files from templates');
313
-
314
- scaffoldCmd
315
- .command('dotnet <feature> <slice-name>')
316
- .description('Generate VSA feature slice (.NET)')
317
- .option('--dry-run', 'Preview files without writing')
318
- .option('--namespace <ns>', 'Root namespace (auto-detected from .csproj)')
319
- .option('--output-dir <path>', 'Output directory (default: cwd)')
320
- .option('-v, --verbose', 'Show detailed output')
321
- .action(scaffoldDotnetCommand);
322
-
323
- scaffoldCmd
324
- .command('nextjs <feature>')
325
- .description('Generate feature page + components (Next.js)')
326
- .option('--dry-run', 'Preview files without writing')
327
- .option('--output-dir <path>', 'Output directory (default: cwd)')
328
- .option('-v, --verbose', 'Show detailed output')
329
- .action(scaffoldNextjsCommand);
330
-
331
- // Trust commands
332
- const trustCommand = program
333
- .command('trust')
334
- .description('Trust level management for zero-touch execution');
335
-
336
- trustCommand
337
- .command('status [feature]')
338
- .description('Show trust level and auto-approval status')
339
- .action(trustStatusCommand);
340
-
341
- trustCommand
342
- .command('set <feature> <level> [reason]')
343
- .description('Manually set trust level (manual|high|auto)')
344
- .action(trustSetCommand);
345
-
346
- // ─────────────────────────────────────────────────────────────────────────────
347
- // MCP Setup
348
- // ─────────────────────────────────────────────────────────────────────────────
349
- const mcpCommand = program
350
- .command('mcp')
351
- .description('MCP server setup and configuration');
352
-
353
- mcpCommand
354
- .command('setup [name]')
355
- .description('Install and configure MCP servers')
356
- .option('--list', 'Show MCP install status')
357
- .option('--auto', 'Auto-install credential-free MCPs without prompts')
358
- .action((name, options) => mcpSetupCommand(name, options));
359
-
360
- // Agent orchestration commands
361
- program
362
- .command('dispatch-agents <feature> <phase>')
363
- .description('Build dispatch config for parallel agent orchestration (design | tasks | implement)')
364
- .option('--table', 'Human-readable table output instead of JSON')
365
- .option('--mode <mode>', 'Dispatch mode: validate (includes Tier-4 validators as read-only)')
366
- .option('--preflight', 'Exit with code 1 if any agent files are missing')
367
- .option('-v, --verbose', 'Show stack trace on error')
368
- .action((feature, phase, options) => dispatchAgentsCommand(feature, phase, options));
369
-
370
- program
371
- .command('audit-dispatch <feature>')
372
- .description('Display dispatch audit log for a feature')
373
- .option('--json', 'Output as JSON instead of table')
374
- .action((feature, options) => auditDispatchCommand(feature, options));
375
-
376
- program
377
- .command('agent-metrics [feature]')
378
- .description('Display agent performance metrics for a feature')
379
- .option('--json', 'Output as JSON instead of table')
380
- .option('--all', 'Aggregate metrics across all features')
381
- .action((feature, options) => agentMetricsCommand(feature, options));
382
-
383
- program
384
- .command('detect-agents <feature>')
385
- .description('Detect relevant agents for a feature based on proposal keywords')
386
- .option('--proposal <path>', 'Path to proposal file (default: .morph/features/{feature}/0-proposal/proposal.md)')
387
- .option('--json', 'Output as JSON (default)')
388
- .option('--table', 'Human-readable table output')
389
- .option('--exclude <ids>', 'Comma-separated agent IDs to exclude')
390
- .option('--refresh', 'Refresh detection using all phase outputs (additive, mutates state)')
391
- .action((feature, options) => detectAgentsCommand(feature, options));
392
-
393
- // Scope escalation commands
394
- const scopeCommand = program
395
- .command('scope')
396
- .description('Scope management (escalate)');
397
-
398
- scopeCommand
399
- .command('escalate <feature>')
400
- .description('Escalate scope when implementation reveals unexpected complexity')
401
- .option('--task <id>', 'Trigger task ID (required)')
402
- .option('--reason <text>', 'Reason for escalation (required)')
403
- .option('--target <phase>', 'Override target phase (tasks | design)')
404
- .option('--dry-run', 'Show recommendation without executing')
405
- .action((feature, options) => scopeEscalateCommand(feature, options));
406
-
407
- // Agent management commands (CRUD)
408
- const agentCommand = program
409
- .command('agent')
410
- .description('Manage agents in agents.json (list, show, add, edit, remove)');
411
-
412
- agentCommand
413
- .command('list')
414
- .description('List all agents with optional filters')
415
- .option('--group <name>', 'Filter by group')
416
- .option('--tier <n>', 'Filter by tier (1-4)')
417
- .option('--json', 'Output as JSON')
418
- .action((options) => agentListCommand(options));
419
-
420
- agentCommand
421
- .command('show <id>')
422
- .description('Show detailed info for an agent')
423
- .option('--json', 'Output as JSON')
424
- .option('--full', 'Show full spawn_prompt (no truncation)')
425
- .action((id, options) => agentShowCommand(id, options));
426
-
427
- agentCommand
428
- .command('add <id>')
429
- .description('Add a new agent via interactive wizard')
430
- .option('--non-interactive', 'Use flags instead of prompts')
431
- .option('--tier <n>', 'Tier (1-4)')
432
- .option('--title <title>', 'Agent title')
433
- .option('--group <group>', 'Agent group')
434
- .option('--active-phases <phases>', 'Comma-separated phases or *')
435
- .option('--reports-to <id>', 'Parent agent ID or "user"')
436
- .option('--domains <domains>', 'Comma-separated domains')
437
- .option('--keywords <keywords>', 'Comma-separated keywords')
438
- .option('--spawn-prompt <prompt>', 'Teammate spawn prompt')
439
- .option('--role <role>', 'Teammate role')
440
- .option('--icon <emoji>', 'Teammate icon')
441
- .action((id, options) => agentAddCommand(id, options));
442
-
443
- agentCommand
444
- .command('edit <id>')
445
- .description('Edit agent fields via flags')
446
- .option('--tier <n>', 'New tier')
447
- .option('--title <title>', 'New title')
448
- .option('--group <group>', 'New group')
449
- .option('--active-phases <phases>', 'New phases (comma-sep)')
450
- .option('--reports-to <id>', 'New reports_to')
451
- .option('--keywords <keywords>', 'New keywords (comma-sep)')
452
- .option('--domains <domains>', 'New domains (comma-sep)')
453
- .option('--spawn-prompt <prompt>', 'New spawn prompt')
454
- .action((id, options) => agentEditCommand(id, options));
455
-
456
- agentCommand
457
- .command('remove <id>')
458
- .description('Remove an agent from agents.json')
459
- .option('--force', 'Skip confirmation prompt')
460
- .action((id, options) => agentRemoveCommand(id, options));
461
-
462
- // Project-level metrics
463
- program
464
- .command('project-metrics')
465
- .description('Aggregate project-level metrics from state.json')
466
- .option('--json', 'Output as JSON')
467
- .option('--save', 'Save metrics to .morph/metrics.json')
468
- .action((options) => projectMetricsCommand(options));
469
-
470
- // Context management commands
471
- const contextCommand = program
472
- .command('context')
473
- .description('Project context management (refresh)');
474
-
475
- contextCommand
476
- .command('refresh')
477
- .description('Scan project architecture and generate .morph/context/README.md')
478
- .option('-p, --path <path>', 'Target path (default: current directory)')
479
- .option('-v, --verbose', 'Show detailed scan output')
480
- .option('--json', 'Output scan result as JSON')
481
- .action((options) => contextRefreshCommand(options));
482
-
483
- // Dashboard / Inspector
484
- program
485
- .command('dashboard')
486
- .description('Open the morph-spec inspector dashboard')
487
- .option('-p, --port <port>', 'Port number', '3200')
488
- .option('--no-open', 'Don\'t auto-open browser')
489
- .action(dashboardCommand);
490
-
491
- program.parse();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * morph-spec CLI v5
5
+ *
6
+ * In v5 the CLI is the *installer* — Claude executes everything else
7
+ * autonomously based on MORPH.md and the core skills. Commands here are
8
+ * limited to actions that humans take or operations Claude needs help with
9
+ * (scaffolding, validation, context refresh).
10
+ */
11
+
12
+ import { program } from 'commander';
13
+ import chalk from 'chalk';
14
+ import { fileURLToPath } from 'url';
15
+ import { dirname, join } from 'path';
16
+ import { readFileSync } from 'fs';
17
+
18
+ // === Project / install ===
19
+ import { initCommand } from '../src/commands/project/init.js';
20
+ import { setupInfraCommand } from '../src/commands/project/setup-infra-cmd.js';
21
+ import { installPluginCommand } from '../src/commands/project/install-plugin-cmd.js';
22
+ import { updateCommand } from '../src/commands/project/update.js';
23
+ import { doctorCommand } from '../src/commands/project/doctor.js';
24
+ import { statusCommand } from '../src/commands/project/status.js';
25
+ import { worktreeSetupCommand } from '../src/commands/project/worktree.js';
26
+
27
+ // === Approval gates (human-only) ===
28
+ import { approveCommand, approvalStatusCommand, unapproveCommand } from '../src/commands/state/approve.js';
29
+
30
+ // === Validation ===
31
+ import { validateCommand } from './validate.js';
32
+ import { validateFeatureCommand } from '../src/commands/validation/validate-feature.js';
33
+
34
+ // === Scaffolding ===
35
+ import { scaffoldDotnetCommand, scaffoldNextjsCommand } from '../src/commands/scaffold/scaffold.js';
36
+
37
+ // === MCP setup ===
38
+ import { mcpSetupCommand } from '../src/commands/mcp/mcp-setup.js';
39
+
40
+ // === Context refresh ===
41
+ import { contextRefreshCommand } from '../src/commands/context/context-refresh.js';
42
+
43
+ // === Dashboard ===
44
+ import { dashboardCommand } from '../src/commands/dashboard/dashboard.js';
45
+
46
+ const __dirname = dirname(fileURLToPath(import.meta.url));
47
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
48
+
49
+ const banner = chalk.cyan(`
50
+ ███╗ ███╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗
51
+ ████╗ ████║██╔═══██╗██╔══██╗██╔══██╗██║ ██║
52
+ ██╔████╔██║██║ ██║██████╔╝██████╔╝███████║
53
+ ██║╚██╔╝██║██║ ██║██╔══██╗██╔═══╝ ██╔══██║
54
+ ██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ██║ ██║
55
+ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
56
+
57
+ Spec-driven development harness for Claude Code
58
+ by Polymorphism Tech | v${pkg.version}
59
+ `);
60
+
61
+ program
62
+ .name('morph-spec')
63
+ .description('MORPH-SPEC Framework CLI')
64
+ .version(pkg.version)
65
+ .addHelpText('beforeAll', banner);
66
+
67
+ // ─── Install ──────────────────────────────────────────────────────────────
68
+ program
69
+ .command('init')
70
+ .description('Initialize MORPH-SPEC in current directory')
71
+ .option('-f, --force', 'Overwrite existing MORPH installation')
72
+ .option('-p, --path <path>', 'Target path (default: current directory)')
73
+ .option('--skip-mcp', 'Skip MCP server auto-setup')
74
+ .action(initCommand);
75
+
76
+ program
77
+ .command('setup-infra')
78
+ .description('Install MORPH-SPEC infrastructure (headless, no prompts)')
79
+ .option('-p, --path <path>', 'Target path (default: current directory)')
80
+ .option('--reinstall', 'Re-install only stack-aware assets (rules, skills, agents)')
81
+ .action(setupInfraCommand);
82
+
83
+ program
84
+ .command('install-plugin <name>')
85
+ .description('Install a Claude Code plugin (superpowers, context7)')
86
+ .action(installPluginCommand);
87
+
88
+ program
89
+ .command('update')
90
+ .description('Update MORPH templates and standards to latest version')
91
+ .option('--templates', 'Update only templates')
92
+ .option('--standards', 'Update only standards')
93
+ .action(updateCommand);
94
+
95
+ program
96
+ .command('doctor')
97
+ .description('Check MORPH installation health')
98
+ .option('--full', 'Run full health check')
99
+ .option('--mcp', 'Check MCP server configuration')
100
+ .option('--reset', 'Remove morph-managed entries from .claude/settings.local.json')
101
+ .action(doctorCommand);
102
+
103
+ // ─── Status / inspection ──────────────────────────────────────────────────
104
+ program
105
+ .command('status <feature>')
106
+ .description('Show feature status (phase, gate state, task counts)')
107
+ .option('--json', 'Output as JSON')
108
+ .option('-v, --verbose', 'Show detailed output')
109
+ .action(statusCommand);
110
+
111
+ // ─── Approval gates (dev-only) ────────────────────────────────────────────
112
+ program
113
+ .command('approve <feature> <gate>')
114
+ .description('Approve a phase gate (proposal, plan, review)')
115
+ .option('--approver <name>', 'Name of approver (default: current user)')
116
+ .option('--notes <notes>', 'Approval notes')
117
+ .action((feature, gate, options) => approveCommand(feature, gate, options));
118
+
119
+ program
120
+ .command('approval-status <feature>')
121
+ .description('Show approval status for all gates')
122
+ .option('--json', 'Output as JSON')
123
+ .action((feature, options) => approvalStatusCommand(feature, options));
124
+
125
+ program
126
+ .command('unapprove <feature> <gate>')
127
+ .description('Revoke a phase gate approval (recovery only)')
128
+ .option('--revoker <name>', 'Name of person revoking')
129
+ .option('--reason <reason>', 'Reason for revocation')
130
+ .action((feature, gate, options) => unapproveCommand(feature, gate, options));
131
+
132
+ // ─── Validation ───────────────────────────────────────────────────────────
133
+ program
134
+ .command('validate [validator]')
135
+ .description('Run project validations (all | packages | architecture | contrast)')
136
+ .option('-v, --verbose', 'Show detailed output')
137
+ .option('--auto-fix, --fix', 'Auto-fix issues where possible')
138
+ .option('--no-fail', 'Don\'t exit with error code')
139
+ .option('--wcag-aaa', 'Use WCAG AAA standard (stricter)')
140
+ .action((validator, options) => {
141
+ const args = validator ? [validator] : ['all'];
142
+ if (options.verbose) args.push('--verbose');
143
+ if (options.autoFix) args.push('--auto-fix');
144
+ if (options.noFail) args.push('--no-fail');
145
+ if (options.wcagAaa) args.push('--wcag-aaa');
146
+ validateCommand(args);
147
+ });
148
+
149
+ program
150
+ .command('validate-feature <feature>')
151
+ .alias('vf')
152
+ .description('Content-aware validation of feature outputs (sections, schema, contracts)')
153
+ .option('--phase <phase>', 'Validate outputs for a specific phase')
154
+ .option('--json', 'Output as JSON')
155
+ .option('-v, --verbose', 'Show detailed output')
156
+ .action(validateFeatureCommand);
157
+
158
+ // ─── Scaffolding ──────────────────────────────────────────────────────────
159
+ const scaffoldCmd = program
160
+ .command('scaffold')
161
+ .description('Generate feature files from templates');
162
+
163
+ scaffoldCmd
164
+ .command('dotnet <feature> <slice-name>')
165
+ .description('Generate VSA feature slice (.NET)')
166
+ .option('--dry-run', 'Preview files without writing')
167
+ .option('--namespace <ns>', 'Root namespace (auto-detected from .csproj)')
168
+ .option('--output-dir <path>', 'Output directory (default: cwd)')
169
+ .option('-v, --verbose', 'Show detailed output')
170
+ .action(scaffoldDotnetCommand);
171
+
172
+ scaffoldCmd
173
+ .command('nextjs <feature>')
174
+ .description('Generate feature page + components (Next.js)')
175
+ .option('--dry-run', 'Preview files without writing')
176
+ .option('--output-dir <path>', 'Output directory (default: cwd)')
177
+ .option('-v, --verbose', 'Show detailed output')
178
+ .action(scaffoldNextjsCommand);
179
+
180
+ // ─── MCP setup ────────────────────────────────────────────────────────────
181
+ const mcpCommand = program
182
+ .command('mcp')
183
+ .description('MCP server setup and configuration');
184
+
185
+ mcpCommand
186
+ .command('setup [name]')
187
+ .description('Install and configure MCP servers')
188
+ .option('--list', 'Show MCP install status')
189
+ .option('--auto', 'Auto-install credential-free MCPs without prompts')
190
+ .action((name, options) => mcpSetupCommand(name, options));
191
+
192
+ // ─── Context refresh ──────────────────────────────────────────────────────
193
+ const contextCommand = program
194
+ .command('context')
195
+ .description('Project context management (refresh)');
196
+
197
+ contextCommand
198
+ .command('refresh')
199
+ .description('Scan project architecture and generate .morph/context/README.md')
200
+ .option('-p, --path <path>', 'Target path (default: current directory)')
201
+ .option('-v, --verbose', 'Show detailed scan output')
202
+ .option('--json', 'Output scan result as JSON')
203
+ .action((options) => contextRefreshCommand(options));
204
+
205
+ // ─── Worktree (optional, isolation) ───────────────────────────────────────
206
+ const worktreeCommand = program
207
+ .command('worktree')
208
+ .description('Manage git worktrees for feature isolation');
209
+
210
+ worktreeCommand
211
+ .command('setup <feature>')
212
+ .description('Create a worktree at .worktrees/{feature}/ on branch morph/{feature}')
213
+ .option('--fresh', 'Create a new dated branch even if one already exists')
214
+ .action((feature, options) => worktreeSetupCommand(feature, options));
215
+
216
+ // ─── Dashboard ────────────────────────────────────────────────────────────
217
+ program
218
+ .command('dashboard')
219
+ .description('Open the morph-spec inspector dashboard')
220
+ .option('-p, --port <port>', 'Port number', '3200')
221
+ .option('--no-open', 'Don\'t auto-open browser')
222
+ .action(dashboardCommand);
223
+
224
+ program.parse();