@polymorphism-tech/morph-spec 11.1.1 → 11.2.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 (106) hide show
  1. package/README.md +1 -1
  2. package/bin/morph-spec.js +9 -19
  3. package/docs/CHEATSHEET.md +3 -3
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/CLAUDE.md +2 -0
  6. package/framework/MORPH.md +7 -2
  7. package/framework/agents.json +3 -3
  8. package/framework/docs/CLI.md +14 -12
  9. package/framework/evals/review-checklist.md +9 -16
  10. package/framework/hooks/README.md +15 -9
  11. package/framework/hooks/claude-code/core/README.md +2 -2
  12. package/framework/hooks/claude-code/core/chain.js +9 -25
  13. package/framework/hooks/claude-code/core/comment-guard.js +3 -9
  14. package/framework/hooks/claude-code/core/conventional-commit.js +3 -3
  15. package/framework/hooks/claude-code/core/graph-refresh-kick.js +4 -4
  16. package/framework/hooks/claude-code/core/masked-exit.js +4 -3
  17. package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
  18. package/framework/hooks/claude-code/core/protect-spec-files.js +2 -4
  19. package/framework/hooks/claude-code/core/stack-changed.js +5 -4
  20. package/framework/hooks/claude-code/core/validate-completion.js +15 -12
  21. package/framework/hooks/shared/contract.js +22 -1
  22. package/framework/hooks/shared/git-paths.js +6 -0
  23. package/framework/hooks/shared/graph-freshness.js +3 -3
  24. package/framework/hooks/shared/graph-refresh.js +5 -10
  25. package/framework/hooks/shared/hook-response.js +1 -18
  26. package/framework/hooks/shared/payload-utils.js +12 -1
  27. package/framework/hooks/shared/phase-utils.js +4 -52
  28. package/framework/hooks/shared/report-progress.js +1 -1
  29. package/framework/mcp/registry.json +1 -17
  30. package/framework/rules/dotnet-templates.md +32 -33
  31. package/framework/rules/infrastructure-standards.md +9 -9
  32. package/framework/rules/neon-standards.md +4 -4
  33. package/framework/rules/nextjs-templates.md +10 -11
  34. package/framework/rules/ui-design.md +2 -2
  35. package/framework/schemas/config.schema.json +4 -0
  36. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  37. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  38. package/framework/skills/core/morph-apply/SKILL.md +5 -4
  39. package/framework/skills/core/morph-plan/SKILL.md +1 -1
  40. package/framework/skills/core/morph-uiux/SKILL.md +5 -5
  41. package/framework/standards/integration/mcp/mcp-tools.md +2 -2
  42. package/framework/templates/REGISTRY.json +1 -75
  43. package/framework/templates/docs/plan.md +1 -1
  44. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +1 -1
  45. package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
  46. package/package.json +6 -15
  47. package/src/commands/graph/build.js +2 -2
  48. package/src/commands/mcp/mcp-setup.js +6 -4
  49. package/src/commands/project/doctor.js +42 -126
  50. package/src/commands/project/env.js +2 -1
  51. package/src/commands/project/init.js +28 -170
  52. package/src/commands/project/stack-set.js +3 -1
  53. package/src/commands/project/update.js +49 -153
  54. package/src/commands/scaffold/scaffold.js +21 -4
  55. package/src/commands/validation/check.js +12 -10
  56. package/src/commands/validation/prove-red.js +61 -22
  57. package/src/core/paths/output-schema.js +8 -27
  58. package/src/core/templates/template-registry.js +8 -43
  59. package/src/core/templates/template-renderer.js +3 -200
  60. package/src/lib/ai/ai-checks.js +1 -1
  61. package/src/lib/ai/ai-project-scan.js +1 -1
  62. package/src/lib/ai/code-audit.js +2 -2
  63. package/src/lib/check/signals.js +25 -7
  64. package/src/lib/contract/defaults.js +2 -2
  65. package/src/lib/detectors/claude-config-detector.js +0 -52
  66. package/src/lib/detectors/index.js +5 -30
  67. package/src/lib/diff/diff-lines.js +3 -3
  68. package/src/lib/generators/scaffold-generator.js +5 -17
  69. package/src/lib/git/default-branch.js +5 -13
  70. package/src/lib/graph/graph-health.js +1 -1
  71. package/src/lib/graph/graphifyignore.js +3 -4
  72. package/src/lib/graph/sanitize.js +2 -2
  73. package/src/lib/installers/effects.js +0 -13
  74. package/src/lib/installers/mcp-installer.js +5 -17
  75. package/src/lib/installers/memory-installer.js +5 -8
  76. package/src/lib/installers/stack-assets.js +33 -7
  77. package/src/lib/installers/stack-sync.js +4 -4
  78. package/src/lib/plan/checks.js +1 -1
  79. package/src/lib/plan/media.js +3 -3
  80. package/src/lib/plan/plan-parser.js +1 -1
  81. package/src/lib/review-reports.js +8 -14
  82. package/src/lib/scan/worktree-dirs.js +1 -3
  83. package/src/lib/specs/adr-index.js +4 -4
  84. package/src/lib/specs/revocations.js +3 -3
  85. package/src/lib/stack/stack-scan.js +3 -3
  86. package/src/lib/standards/registry.js +1 -1
  87. package/src/lib/standards/verified-against.js +2 -2
  88. package/src/lib/tests-audit/audit.js +2 -2
  89. package/src/scripts/global-install.js +41 -19
  90. package/src/scripts/setup-infra.js +57 -165
  91. package/src/utils/agents-installer.js +8 -30
  92. package/src/utils/claude-settings-manager.js +29 -27
  93. package/src/utils/hooks-installer.js +30 -44
  94. package/src/utils/version-checker.js +2 -31
  95. package/CLAUDE.md +0 -118
  96. package/framework/commands/create-umbraco-lp.md +0 -37
  97. package/framework/commands/migrate-lp-to-umbraco.md +0 -35
  98. package/framework/commands/morph-apply.md +0 -14
  99. package/framework/hooks/shared/spawn-command.js +0 -23
  100. package/framework/templates/CLAUDE.md.core.guide.md +0 -29
  101. package/framework/templates/CLAUDE.md.core.template +0 -22
  102. package/framework/templates/context/ARCHITECTURE.md +0 -106
  103. package/src/commands/context/context-refresh.js +0 -63
  104. package/src/lib/generators/architecture-scanner.js +0 -543
  105. package/src/lib/generators/settings-generator.js +0 -97
  106. package/src/lib/graph/god-nodes.js +0 -65
@@ -33,7 +33,7 @@ export async function detectStack(targetPath) {
33
33
  }
34
34
 
35
35
  try {
36
- const results = await detectProject(targetPath, { conversation: false, generateStandards: false });
36
+ const results = await detectProject(targetPath);
37
37
  return results.structure?.stack || 'unknown';
38
38
  } catch {
39
39
  return 'unknown';
@@ -54,7 +54,7 @@ export async function detectIntegrations(targetPath) {
54
54
  }
55
55
 
56
56
  try {
57
- const results = await detectProject(targetPath, { conversation: false, generateStandards: false });
57
+ const results = await detectProject(targetPath);
58
58
  return results.structure?.integrations ?? [];
59
59
  } catch {
60
60
  return [];
@@ -158,15 +158,17 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
158
158
  console.log(chalk.red(`\n Unknown MCP: ${name}`));
159
159
  console.log(chalk.gray(` Available: ${Object.keys(registry.mcps).join(', ')}`));
160
160
  console.log('');
161
+ process.exitCode = 1;
161
162
  return;
162
163
  }
163
164
 
164
165
  if (!mcpEntry.install) {
165
166
  console.log(chalk.red(`\n MCP "${name}" has no install configuration.\n`));
167
+ process.exitCode = 1;
166
168
  return;
167
169
  }
168
170
 
169
- const isInstalled = existingMcps.some(s => s.name.toLowerCase().includes(name));
171
+ const isInstalled = existingMcps.some(s => s.name.toLowerCase() === name.toLowerCase());
170
172
  if (isInstalled) {
171
173
  const { reconfigure } = await inquirer.prompt([{
172
174
  type: 'confirm',
@@ -230,7 +232,7 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
230
232
  const { installNow } = await inquirer.prompt([{
231
233
  type: 'confirm',
232
234
  name: 'installNow',
233
- message: 'Add to .mcp.json now?',
235
+ message: 'Run it now (claude mcp add)?',
234
236
  default: true
235
237
  }]);
236
238
 
@@ -18,6 +18,7 @@ import { stackRuleGaps } from '../../lib/installers/stack-sync.js';
18
18
  import { auditGraph } from '../../lib/graph/graph-health.js';
19
19
 
20
20
  const isWindows = platform() === 'win32';
21
+ const PACKAGE_FRAMEWORK = join(import.meta.dirname, '..', '..', '..', 'framework');
21
22
 
22
23
  export function checkInstalledPlugins(pluginsData) {
23
24
  const REQUIRED = ['context7'];
@@ -57,20 +58,6 @@ function getNpmGlobalPrefix() {
57
58
  }
58
59
  }
59
60
 
60
- const REQUIRED_LIB_FILES = [
61
- 'src/lib/stack-filter.js'
62
- ];
63
-
64
- const REQUIRED_COMMAND_FILES = [
65
- 'src/commands/project/init.js',
66
- 'src/commands/project/update.js',
67
- 'src/commands/project/doctor.js',
68
- 'src/commands/validation/check.js',
69
- 'src/commands/scaffold/scaffold.js',
70
- 'src/commands/mcp/mcp-setup.js',
71
- 'src/commands/context/context-refresh.js',
72
- ];
73
-
74
61
  export function validateAgentsJson(agentsData) {
75
62
  const checks = [];
76
63
  const agentEntries = Object.entries(agentsData.agents || {})
@@ -101,14 +88,9 @@ export function validateAgentsJson(agentsData) {
101
88
 
102
89
  const version = agentsData.version || 'unknown';
103
90
  const isCurrent = version.startsWith('6.');
104
- const v4Fields = [];
105
91
  const missingFields = [];
106
92
 
107
93
  for (const [id, data] of agentEntries) {
108
- if (data.tier !== undefined) v4Fields.push(`${id}.tier`);
109
- if (data.active_phases !== undefined) v4Fields.push(`${id}.active_phases`);
110
- if (data.reports_to !== undefined) v4Fields.push(`${id}.reports_to`);
111
- if (data.teammate !== undefined) v4Fields.push(`${id}.teammate`);
112
94
  if (!data.title) missingFields.push(`${id}.title`);
113
95
  if (!Array.isArray(data.domains)) missingFields.push(`${id}.domains`);
114
96
  if (typeof data.persona !== 'string' || !data.persona) missingFields.push(`${id}.persona`);
@@ -124,15 +106,6 @@ export function validateAgentsJson(agentsData) {
124
106
  });
125
107
  }
126
108
 
127
- if (v4Fields.length > 0) {
128
- const sample = v4Fields.slice(0, 3).join(', ');
129
- checks.push({
130
- name: 'agents.json deprecated v4 fields',
131
- status: 'warn',
132
- msg: `${v4Fields.length} v4 field(s) found: ${sample}${v4Fields.length > 3 ? '...' : ''}`
133
- });
134
- }
135
-
136
109
  // The installer's own rule, so this cannot pass a value it refuses. ERROR: that persona is not generated.
137
110
  const maxTurnsErrors = agentEntries
138
111
  .map(([id, data]) => maxTurnsError(id, data?.maxTurns))
@@ -193,37 +166,16 @@ async function doctorFullCommand(frameworkRoot) {
193
166
  }
194
167
  };
195
168
 
196
- // Two layouts reach this command (framework repo: src/, no .morph/; installed project:
197
- // .morph/framework/, CLI in node_modules). Each check runs only where it means something.
169
+ // Two layouts reach this command (framework repo: framework/, no .morph/; installed project:
170
+ // .morph/framework/). Each check runs only where it means something.
198
171
  const installedAgentsPath = join(frameworkRoot, '.morph/framework/agents.json');
199
- const canonicalAgentsPath = join(frameworkRoot, 'framework/agents.json');
172
+ const sourceAgentsPath = join(frameworkRoot, 'framework/agents.json');
200
173
  const inFrameworkRepo = !(await pathExists(installedAgentsPath))
201
- && await pathExists(canonicalAgentsPath);
202
- const agentsPath = inFrameworkRepo ? canonicalAgentsPath : installedAgentsPath;
174
+ && await pathExists(sourceAgentsPath);
175
+ const agentsPath = inFrameworkRepo ? sourceAgentsPath : installedAgentsPath;
203
176
 
204
177
  console.log(chalk.gray(`\n Contexto: ${inFrameworkRepo ? 'repo do framework' : 'projeto instalado'}`));
205
178
 
206
- // An installed project has no src/: the CLI's integrity in node_modules is npm's job.
207
- if (inFrameworkRepo) {
208
- console.log(chalk.cyan(`\n src/lib/ — Core Libraries (${REQUIRED_LIB_FILES.length} files)`));
209
- const missingLibs = [];
210
- for (const f of REQUIRED_LIB_FILES) {
211
- if (!(await pathExists(join(frameworkRoot, f)))) missingLibs.push(f.split('/').pop());
212
- }
213
- check(`Core Libraries (${REQUIRED_LIB_FILES.length - missingLibs.length}/${REQUIRED_LIB_FILES.length})`,
214
- missingLibs.length === 0, false,
215
- missingLibs.length > 0 ? `missing: ${missingLibs.join(', ')}` : '');
216
-
217
- console.log(chalk.cyan(`\n src/commands/ — Command Files (${REQUIRED_COMMAND_FILES.length} files)`));
218
- const missingCmds = [];
219
- for (const f of REQUIRED_COMMAND_FILES) {
220
- if (!(await pathExists(join(frameworkRoot, f)))) missingCmds.push(f.split('/').pop());
221
- }
222
- check(`Command Files (${REQUIRED_COMMAND_FILES.length - missingCmds.length}/${REQUIRED_COMMAND_FILES.length})`,
223
- missingCmds.length === 0, false,
224
- missingCmds.length > 0 ? `missing: ${missingCmds.join(', ')}` : '');
225
- }
226
-
227
179
  const stdsRoot = inFrameworkRepo ? frameworkRoot : join(frameworkRoot, '.morph');
228
180
  console.log(chalk.cyan(`\n ${inFrameworkRepo ? '' : '.morph/'}framework/standards/ — Framework Standards (${FRAMEWORK_STANDARDS.length} files)`));
229
181
  const missingStds = [];
@@ -251,10 +203,10 @@ async function doctorFullCommand(frameworkRoot) {
251
203
  }
252
204
 
253
205
  // Installed project only: in the framework repo source and installed copy are the same file.
254
- if (!inFrameworkRepo && await pathExists(agentsPath) && await pathExists(canonicalAgentsPath)) {
206
+ if (!inFrameworkRepo && await pathExists(agentsPath)) {
255
207
  try {
256
208
  const installed = JSON.parse(await fs.readFile(agentsPath, 'utf8'));
257
- const canonical = JSON.parse(await fs.readFile(canonicalAgentsPath, 'utf8'));
209
+ const canonical = JSON.parse(await fs.readFile(join(PACKAGE_FRAMEWORK, 'agents.json'), 'utf8'));
258
210
  const installedVer = installed.version || 'unknown';
259
211
  const canonicalVer = canonical.version || 'unknown';
260
212
  const isFresh = installedVer === canonicalVer;
@@ -279,7 +231,7 @@ async function doctorFullCommand(frameworkRoot) {
279
231
  // installed .morph/framework/ has no mcp/, and rendering without it
280
232
  // flagged every persona with an `mcp` grant as stale on a clean install.
281
233
  const drift = checkAgentsDrift(frameworkRoot, join(frameworkRoot, '.morph/framework'), projectTags,
282
- { mcpRegistryDir: join(import.meta.dirname, '..', '..', '..', 'framework') });
234
+ { mcpRegistryDir: PACKAGE_FRAMEWORK });
283
235
  if (drift.invalid.length > 0) {
284
236
  check('Personas agents.json valid', false, false,
285
237
  `${drift.invalid.map(i => i.reason).join(' | ')} — corrija o agents.json e rode 'morph-spec update'`);
@@ -533,16 +485,16 @@ export async function doctorAiCommand(targetPath, options = {}) {
533
485
  }
534
486
 
535
487
  export async function doctorCommand(options = {}) {
536
- // `--ai` com outra superfície daria dois códigos de saída no mesmo processo: recusa.
488
+ // Duas superfícies dariam dois códigos de saída no mesmo processo: recusa.
489
+ const [first, ...rest] = ['ai', 'full', 'mcp', 'reset'].filter((f) => options[f]).map((f) => `--${f}`);
490
+ if (rest.length) {
491
+ logger.error(`${first} não se combina com ${rest.join(' e ')} — cada superfície tem o seu relatório e o seu código de saída.`);
492
+ logger.dim(` Rode uma por vez: morph-spec doctor ${first}`);
493
+ process.exitCode = 1;
494
+ return false;
495
+ }
496
+
537
497
  if (options.ai) {
538
- const conflicts = ['full', 'mcp'].filter((f) => options[f]);
539
- if (conflicts.length) {
540
- const flags = conflicts.map((f) => `--${f}`).join(' e ');
541
- logger.error(`--ai não se combina com ${flags} — cada superfície tem o seu relatório e o seu código de saída.`);
542
- logger.dim(' Rode: morph-spec doctor --ai');
543
- process.exitCode = 1;
544
- return false;
545
- }
546
498
  return doctorAiCommand(process.cwd(), options);
547
499
  }
548
500
 
@@ -587,16 +539,6 @@ export async function doctorCommand(options = {}) {
587
539
  let hasErrors = false;
588
540
  let hasWarnings = false;
589
541
 
590
- const check = (name, passed, warnOnly = false, msg = '') => {
591
- if (passed) {
592
- checks.push({ name, status: 'ok' });
593
- } else {
594
- checks.push({ name, status: warnOnly ? 'warn' : 'missing', msg });
595
- if (warnOnly) hasWarnings = true;
596
- else hasErrors = true;
597
- }
598
- };
599
-
600
542
  const cliCheck = await checkCLIOutdated();
601
543
  const projectCheck = await checkProjectOutdated(targetPath);
602
544
 
@@ -688,6 +630,7 @@ export async function doctorCommand(options = {}) {
688
630
  checks.push({ name: 'config.json', status: 'ok' });
689
631
  } else {
690
632
  checks.push({ name: 'config.json', status: 'warn', msg: 'project.name not set' });
633
+ hasWarnings = true;
691
634
  }
692
635
  } catch {
693
636
  checks.push({ name: 'config.json', status: 'error', msg: 'invalid JSON' });
@@ -717,11 +660,9 @@ export async function doctorCommand(options = {}) {
717
660
  }
718
661
 
719
662
  const standardsPath = join(morphPath, 'framework', 'standards');
720
- const frameworkStdsRoot = join(import.meta.dirname, '..', '..', '..', 'framework', 'standards');
663
+ const frameworkStdsRoot = join(PACKAGE_FRAMEWORK, 'standards');
721
664
  if (await pathExists(standardsPath)) {
722
- const vsaStd = await pathExists(join(standardsPath, 'architecture', 'vertical-slice', 'vertical-slice.md')) ||
723
- await pathExists(join(standardsPath, 'vertical-slice.md'));
724
- if (vsaStd) {
665
+ if (await pathExists(join(standardsPath, 'architecture', 'vertical-slice', 'vertical-slice.md'))) {
725
666
  checks.push({ name: 'standards/', status: 'ok' });
726
667
  } else {
727
668
  checks.push({ name: 'standards/', status: 'warn', msg: 'VSA standard missing — run morph-spec init' });
@@ -755,29 +696,6 @@ export async function doctorCommand(options = {}) {
755
696
  if (hasCommands && hasSkills) {
756
697
  checks.push({ name: '.claude/', status: 'ok' });
757
698
 
758
- const skillEntries = await fs.readdir(skillsPath, { withFileTypes: true });
759
- const skillDirs = skillEntries.filter(e => e.isDirectory() || e.isSymbolicLink());
760
- let linkedCount = 0;
761
-
762
- for (const dir of skillDirs) {
763
- try {
764
- const stat = await fs.lstat(join(skillsPath, dir.name));
765
- if (stat.isSymbolicLink()) linkedCount++;
766
- } catch {}
767
- }
768
-
769
- if (skillDirs.length > 0) {
770
- if (linkedCount === skillDirs.length) {
771
- checks.push({ name: '.claude/skills/ links', status: 'ok', msg: `${linkedCount} categories linked` });
772
- } else if (linkedCount > 0) {
773
- checks.push({ name: '.claude/skills/ links', status: 'warn', msg: `${linkedCount}/${skillDirs.length} linked, rest copied` });
774
- hasWarnings = true;
775
- } else {
776
- checks.push({ name: '.claude/skills/ links', status: 'warn', msg: 'all categories copied (no auto-update)' });
777
- hasWarnings = true;
778
- }
779
- }
780
-
781
699
  const rulesPath = join(claudePath, 'rules');
782
700
  if (await pathExists(rulesPath)) {
783
701
  const ruleFiles = await fs.readdir(rulesPath);
@@ -794,7 +712,7 @@ export async function doctorCommand(options = {}) {
794
712
  hasWarnings = true;
795
713
  }
796
714
  if (gaps?.missing.length) {
797
- checks.push({ name: 'stack rules', status: 'warn', msg: `faltando para [${gaps.tags.join(', ')}]: ${gaps.missing.join(', ')} — rode morph-spec verify ou update` });
715
+ checks.push({ name: 'stack rules', status: 'warn', msg: `faltando para [${gaps.tags.join(', ')}]: ${gaps.missing.join(', ')} — rode morph-spec update` });
798
716
  hasWarnings = true;
799
717
  }
800
718
 
@@ -811,8 +729,7 @@ export async function doctorCommand(options = {}) {
811
729
  projectTags = getProjectTags(await readJson(configPath));
812
730
  } catch {}
813
731
  const tagsLabel = projectTags.length > 0 ? projectTags.join(', ') : 'all (stack unknown)';
814
- const frameworkDir = join(import.meta.dirname, '..', '..', '..', 'framework');
815
- const { missing } = checkMissingAgents(targetPath, frameworkDir, projectTags);
732
+ const { missing } = checkMissingAgents(targetPath, PACKAGE_FRAMEWORK, projectTags);
816
733
  if (missing.length > 0) {
817
734
  const names = missing.map(m => m.name).join(', ');
818
735
  checks.push({
@@ -887,15 +804,17 @@ export async function doctorCommand(options = {}) {
887
804
  }
888
805
  } catch {}
889
806
 
890
- console.log(chalk.cyan('\n Claude Code Plugins (required by morph-spec init)'));
891
807
  const pluginsFile = join(homedir(), '.claude', 'plugins', 'installed_plugins.json');
892
808
  let pluginData = { plugins: {} };
893
809
  try {
894
810
  pluginData = JSON.parse(await fs.readFile(pluginsFile, 'utf8'));
895
811
  } catch {}
896
- const pluginStatus = checkInstalledPlugins(pluginData.plugins || {});
897
- check('context7 plugin', pluginStatus.context7, false,
898
- 'Run: morph-spec install-plugin context7');
812
+ if (checkInstalledPlugins(pluginData.plugins || {}).context7) {
813
+ checks.push({ name: 'context7 plugin', status: 'ok' });
814
+ } else {
815
+ checks.push({ name: 'context7 plugin', status: 'missing', msg: 'run: claude plugin install context7@claude-plugins-official' });
816
+ hasErrors = true;
817
+ }
899
818
  } else {
900
819
  // `.claude/` without commands/ or skills/: count what is left; near-total loss is an ERROR with the fix.
901
820
  const pieces = ['agents', 'rules', 'skills', 'commands'];
@@ -936,10 +855,9 @@ export async function doctorCommand(options = {}) {
936
855
  checks.push({ name: 'codebase graph', status: 'ok', msg: graphAudit.msg });
937
856
  }
938
857
 
939
- const frameworkTemplatesRoot = join(import.meta.dirname, '..', '..', '..', 'framework', 'templates');
940
858
  const keyTemplates = [
941
- { name: 'plan.md', path: join(frameworkTemplatesRoot, 'docs', 'plan.md') },
942
- { name: 'morph-uiux mockups.md', path: join(frameworkTemplatesRoot, '..', 'skills', 'core', 'morph-uiux', 'references', 'mockups.md') }
859
+ { name: 'plan.md', path: join(PACKAGE_FRAMEWORK, 'templates', 'docs', 'plan.md') },
860
+ { name: 'morph-uiux mockups.md', path: join(PACKAGE_FRAMEWORK, 'skills', 'core', 'morph-uiux', 'references', 'mockups.md') }
943
861
  ];
944
862
  const missingTemplates = [];
945
863
  for (const template of keyTemplates) {
@@ -960,24 +878,22 @@ export async function doctorCommand(options = {}) {
960
878
 
961
879
  const nodeVersion = process.version;
962
880
  const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0], 10);
963
- if (majorVersion >= 18) {
881
+ if (majorVersion >= 22) {
964
882
  checks.push({ name: `Node.js ${nodeVersion}`, status: 'ok' });
965
883
  } else {
966
- checks.push({ name: `Node.js ${nodeVersion}`, status: 'warn', msg: 'v18+ recommended' });
884
+ checks.push({ name: `Node.js ${nodeVersion}`, status: 'warn', msg: 'v22+ required' });
967
885
  hasWarnings = true;
968
886
  }
969
887
 
970
- for (const check of checks) {
971
- if (check.status === 'ok') {
972
- console.log(chalk.green(` ✓ ${check.name}`));
973
- } else if (check.status === 'warn') {
974
- console.log(chalk.yellow(` ⚠ ${check.name}`) + chalk.gray(` (${check.msg})`));
975
- } else if (check.status === 'missing') {
976
- console.log(chalk.red(` ✗ ${check.name}`) + chalk.gray(' (missing)'));
977
- } else if (check.status === 'error') {
978
- console.log(chalk.red(` ✗ ${check.name}`) + chalk.gray(` (${check.msg})`));
979
- } else if (check.status === 'skip') {
980
- console.log(chalk.gray(` ○ ${check.name}`) + chalk.gray(check.msg ? ` (${check.msg})` : ''));
888
+ for (const c of checks) {
889
+ if (c.status === 'ok') {
890
+ console.log(chalk.green(` ✓ ${c.name}`));
891
+ } else if (c.status === 'warn') {
892
+ console.log(chalk.yellow(` ⚠ ${c.name}`) + chalk.gray(` (${c.msg})`));
893
+ } else if (c.status === 'missing') {
894
+ console.log(chalk.red(` ✗ ${c.name}`) + chalk.gray(c.msg ? ` (missing — ${c.msg})` : ' (missing)'));
895
+ } else if (c.status === 'error') {
896
+ console.log(chalk.red(` ✗ ${c.name}`) + chalk.gray(` (${c.msg})`));
981
897
  }
982
898
  }
983
899
 
@@ -3,7 +3,8 @@ import { execFileSync } from 'child_process';
3
3
  import { readMorphConfig } from '../../lib/config/project-config.js';
4
4
  import { branchEnv } from '../../lib/contract/ports.js';
5
5
 
6
- function currentBranch(cwd) {
6
+ /** `null` on a detached HEAD or outside git. */
7
+ export function currentBranch(cwd) {
7
8
  try {
8
9
  const branch = execFileSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd, stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
9
10
  return branch && branch !== 'HEAD' ? branch : null;