@polymorphism-tech/morph-spec 11.1.1 → 11.3.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.
- package/README.md +3 -2
- package/bin/morph-spec.js +13 -23
- package/docs/CHEATSHEET.md +3 -3
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +3 -1
- package/framework/MORPH.md +8 -3
- package/framework/agents.json +4 -4
- package/framework/docs/CLI.md +28 -18
- package/framework/evals/review-checklist.md +35 -18
- package/framework/hooks/README.md +18 -11
- package/framework/hooks/claude-code/core/README.md +2 -2
- package/framework/hooks/claude-code/core/chain.js +9 -25
- package/framework/hooks/claude-code/core/comment-guard.js +3 -9
- package/framework/hooks/claude-code/core/conventional-commit.js +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +6 -6
- package/framework/hooks/claude-code/core/masked-exit.js +4 -3
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +2 -4
- package/framework/hooks/claude-code/core/stack-changed.js +5 -4
- package/framework/hooks/claude-code/core/validate-completion.js +15 -12
- package/framework/hooks/shared/contract.js +22 -1
- package/framework/hooks/shared/git-paths.js +6 -0
- package/framework/hooks/shared/graph-freshness.js +3 -3
- package/framework/hooks/shared/graph-refresh.js +5 -10
- package/framework/hooks/shared/hook-response.js +1 -18
- package/framework/hooks/shared/payload-utils.js +12 -1
- package/framework/hooks/shared/phase-utils.js +4 -52
- package/framework/hooks/shared/report-progress.js +1 -1
- package/framework/mcp/registry.json +16 -32
- package/framework/rules/ai-agents-standards.md +9 -1
- package/framework/rules/dotnet-templates.md +32 -33
- package/framework/rules/gsap-standards.md +8 -0
- package/framework/rules/infrastructure-standards.md +9 -9
- package/framework/rules/mcp-standards.md +10 -0
- package/framework/rules/neon-standards.md +4 -4
- package/framework/rules/nextjs-templates.md +10 -11
- package/framework/rules/ui-design.md +2 -2
- package/framework/schemas/config.schema.json +11 -0
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +6 -4
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +5 -5
- package/framework/standards/STANDARDS.json +8 -4
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/agent-archetypes.md +1 -1
- package/framework/standards/ai-agents/middleware-patterns.md +0 -2
- package/framework/standards/ai-agents/prompt-sources.md +2 -2
- package/framework/standards/ai-agents/providers/model-registry.md +9 -12
- package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
- package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
- package/framework/standards/integration/mcp/mcp-tools.md +125 -267
- package/framework/templates/README.md +52 -82
- package/framework/templates/REGISTRY.json +1 -281
- package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
- package/framework/templates/context/design-system.md +1 -1
- package/framework/templates/docs/plan.md +2 -2
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +3 -5
- package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
- package/framework/templates/infrastructure/github/README.md +10 -13
- package/package.json +7 -16
- package/src/commands/graph/build.js +2 -2
- package/src/commands/mcp/manual-setup.js +95 -0
- package/src/commands/mcp/mcp-setup.js +26 -192
- package/src/commands/project/doctor.js +48 -142
- package/src/commands/project/env.js +2 -1
- package/src/commands/project/init-contract.js +2 -2
- package/src/commands/project/init.js +34 -294
- package/src/commands/project/stack-scan.js +6 -14
- package/src/commands/project/stack-set.js +3 -1
- package/src/commands/project/standards.js +1 -2
- package/src/commands/project/update.js +87 -205
- package/src/commands/scaffold/scaffold.js +43 -5
- package/src/commands/validation/check.js +12 -10
- package/src/commands/validation/prove-red.js +61 -22
- package/src/core/paths/output-schema.js +8 -27
- package/src/core/templates/template-registry.js +8 -43
- package/src/core/templates/template-renderer.js +3 -200
- package/src/lib/ai/ai-checks.js +1 -1
- package/src/lib/ai/ai-project-scan.js +2 -5
- package/src/lib/ai/code-audit.js +3 -8
- package/src/lib/ai/registry-audit.js +2 -1
- package/src/lib/check/signals.js +25 -7
- package/src/lib/config/project-config.js +3 -2
- package/src/lib/contract/apply.js +2 -1
- package/src/lib/contract/defaults.js +2 -2
- package/src/lib/contract/merge.js +1 -0
- package/src/lib/contract/scan.js +5 -5
- package/src/lib/detectors/claude-config-detector.js +44 -98
- package/src/lib/detectors/mcp-config.js +2 -1
- package/src/lib/diff/diff-lines.js +4 -9
- package/src/lib/generators/scaffold-generator.js +5 -17
- package/src/lib/git/default-branch.js +5 -13
- package/src/lib/graph/graph-health.js +1 -1
- package/src/lib/graph/graph-loader.js +2 -1
- package/src/lib/graph/graphifyignore.js +5 -5
- package/src/lib/graph/sanitize.js +2 -2
- package/src/lib/installers/effects.js +0 -13
- package/src/lib/installers/install-manifest.js +56 -0
- package/src/lib/installers/mcp-installer.js +16 -19
- package/src/lib/installers/memory-installer.js +5 -8
- package/src/lib/installers/rules-installer.js +9 -15
- package/src/lib/installers/stack-assets.js +54 -7
- package/src/lib/installers/stack-sync.js +16 -16
- package/src/lib/installers/stack-tooling.js +4 -3
- package/src/lib/json-file.js +9 -0
- package/src/lib/plan/artifact-vocabulary.js +1 -1
- package/src/lib/plan/checks.js +4 -3
- package/src/lib/plan/media.js +6 -6
- package/src/lib/plan/plan-parser.js +6 -11
- package/src/lib/review-reports.js +13 -18
- package/src/lib/scan/worktree-dirs.js +1 -3
- package/src/lib/specs/adr-index.js +4 -4
- package/src/lib/specs/revocations.js +3 -3
- package/src/lib/stack/stack-scan.js +4 -4
- package/src/lib/standards/registry.js +1 -1
- package/src/lib/standards/verified-against.js +3 -3
- package/src/lib/tests-audit/audit.js +3 -3
- package/src/lib/text.js +5 -0
- package/src/scripts/global-install.js +41 -19
- package/src/scripts/setup-infra.js +68 -187
- package/src/utils/agents-installer.js +21 -60
- package/src/utils/claude-md-injector.js +16 -50
- package/src/utils/claude-settings-manager.js +29 -27
- package/src/utils/file-copier.js +3 -4
- package/src/utils/hooks-installer.js +83 -62
- package/src/utils/skills-installer.js +18 -78
- package/src/utils/version-checker.js +2 -31
- package/CLAUDE.md +0 -118
- package/framework/commands/create-umbraco-lp.md +0 -37
- package/framework/commands/migrate-lp-to-umbraco.md +0 -35
- package/framework/commands/morph-apply.md +0 -14
- package/framework/hooks/shared/spawn-command.js +0 -23
- package/framework/templates/CLAUDE.md.core.guide.md +0 -29
- package/framework/templates/CLAUDE.md.core.template +0 -22
- package/framework/templates/IDE-SNIPPETS.md +0 -262
- package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
- package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
- package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
- package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
- package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
- package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
- package/framework/templates/code/dotnet/contracts/README.md +0 -74
- package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
- package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
- package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
- package/framework/templates/code/typescript/contracts.ts +0 -140
- package/framework/templates/context/ARCHITECTURE.md +0 -106
- package/framework/templates/examples/design-system-examples.md +0 -354
- package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
- package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
- package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
- package/framework/templates/integrations/asaas-client.cs +0 -332
- package/framework/templates/integrations/asaas-webhook.cs +0 -290
- package/framework/templates/integrations/neon-auth-config.cs +0 -170
- package/framework/templates/ui/design-system.css +0 -226
- package/src/commands/context/context-refresh.js +0 -63
- package/src/lib/detectors/index.js +0 -178
- package/src/lib/generators/architecture-scanner.js +0 -543
- package/src/lib/generators/settings-generator.js +0 -97
- package/src/lib/graph/god-nodes.js +0 -65
- package/src/lib/installers/templates-reconcile.js +0 -26
|
@@ -5,7 +5,6 @@ import fs from 'fs-extra';
|
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { logger } from '../../utils/logger.js';
|
|
7
7
|
import { pathExists, readJson } from '../../utils/file-copier.js';
|
|
8
|
-
import { checkClaudeMdImport } from '../../utils/claude-md-injector.js';
|
|
9
8
|
import {
|
|
10
9
|
checkCLIOutdated,
|
|
11
10
|
checkProjectOutdated,
|
|
@@ -18,6 +17,7 @@ import { stackRuleGaps } from '../../lib/installers/stack-sync.js';
|
|
|
18
17
|
import { auditGraph } from '../../lib/graph/graph-health.js';
|
|
19
18
|
|
|
20
19
|
const isWindows = platform() === 'win32';
|
|
20
|
+
const PACKAGE_FRAMEWORK = join(import.meta.dirname, '..', '..', '..', 'framework');
|
|
21
21
|
|
|
22
22
|
export function checkInstalledPlugins(pluginsData) {
|
|
23
23
|
const REQUIRED = ['context7'];
|
|
@@ -57,20 +57,6 @@ function getNpmGlobalPrefix() {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
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
60
|
export function validateAgentsJson(agentsData) {
|
|
75
61
|
const checks = [];
|
|
76
62
|
const agentEntries = Object.entries(agentsData.agents || {})
|
|
@@ -101,14 +87,9 @@ export function validateAgentsJson(agentsData) {
|
|
|
101
87
|
|
|
102
88
|
const version = agentsData.version || 'unknown';
|
|
103
89
|
const isCurrent = version.startsWith('6.');
|
|
104
|
-
const v4Fields = [];
|
|
105
90
|
const missingFields = [];
|
|
106
91
|
|
|
107
92
|
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
93
|
if (!data.title) missingFields.push(`${id}.title`);
|
|
113
94
|
if (!Array.isArray(data.domains)) missingFields.push(`${id}.domains`);
|
|
114
95
|
if (typeof data.persona !== 'string' || !data.persona) missingFields.push(`${id}.persona`);
|
|
@@ -124,15 +105,6 @@ export function validateAgentsJson(agentsData) {
|
|
|
124
105
|
});
|
|
125
106
|
}
|
|
126
107
|
|
|
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
108
|
// The installer's own rule, so this cannot pass a value it refuses. ERROR: that persona is not generated.
|
|
137
109
|
const maxTurnsErrors = agentEntries
|
|
138
110
|
.map(([id, data]) => maxTurnsError(id, data?.maxTurns))
|
|
@@ -193,37 +165,16 @@ async function doctorFullCommand(frameworkRoot) {
|
|
|
193
165
|
}
|
|
194
166
|
};
|
|
195
167
|
|
|
196
|
-
// Two layouts reach this command (framework repo:
|
|
197
|
-
// .morph/framework
|
|
168
|
+
// Two layouts reach this command (framework repo: framework/, no .morph/; installed project:
|
|
169
|
+
// .morph/framework/). Each check runs only where it means something.
|
|
198
170
|
const installedAgentsPath = join(frameworkRoot, '.morph/framework/agents.json');
|
|
199
|
-
const
|
|
171
|
+
const sourceAgentsPath = join(frameworkRoot, 'framework/agents.json');
|
|
200
172
|
const inFrameworkRepo = !(await pathExists(installedAgentsPath))
|
|
201
|
-
&& await pathExists(
|
|
202
|
-
const agentsPath = inFrameworkRepo ?
|
|
173
|
+
&& await pathExists(sourceAgentsPath);
|
|
174
|
+
const agentsPath = inFrameworkRepo ? sourceAgentsPath : installedAgentsPath;
|
|
203
175
|
|
|
204
176
|
console.log(chalk.gray(`\n Contexto: ${inFrameworkRepo ? 'repo do framework' : 'projeto instalado'}`));
|
|
205
177
|
|
|
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
178
|
const stdsRoot = inFrameworkRepo ? frameworkRoot : join(frameworkRoot, '.morph');
|
|
228
179
|
console.log(chalk.cyan(`\n ${inFrameworkRepo ? '' : '.morph/'}framework/standards/ — Framework Standards (${FRAMEWORK_STANDARDS.length} files)`));
|
|
229
180
|
const missingStds = [];
|
|
@@ -251,10 +202,10 @@ async function doctorFullCommand(frameworkRoot) {
|
|
|
251
202
|
}
|
|
252
203
|
|
|
253
204
|
// Installed project only: in the framework repo source and installed copy are the same file.
|
|
254
|
-
if (!inFrameworkRepo && await pathExists(agentsPath)
|
|
205
|
+
if (!inFrameworkRepo && await pathExists(agentsPath)) {
|
|
255
206
|
try {
|
|
256
207
|
const installed = JSON.parse(await fs.readFile(agentsPath, 'utf8'));
|
|
257
|
-
const canonical = JSON.parse(await fs.readFile(
|
|
208
|
+
const canonical = JSON.parse(await fs.readFile(join(PACKAGE_FRAMEWORK, 'agents.json'), 'utf8'));
|
|
258
209
|
const installedVer = installed.version || 'unknown';
|
|
259
210
|
const canonicalVer = canonical.version || 'unknown';
|
|
260
211
|
const isFresh = installedVer === canonicalVer;
|
|
@@ -279,7 +230,7 @@ async function doctorFullCommand(frameworkRoot) {
|
|
|
279
230
|
// installed .morph/framework/ has no mcp/, and rendering without it
|
|
280
231
|
// flagged every persona with an `mcp` grant as stale on a clean install.
|
|
281
232
|
const drift = checkAgentsDrift(frameworkRoot, join(frameworkRoot, '.morph/framework'), projectTags,
|
|
282
|
-
{ mcpRegistryDir:
|
|
233
|
+
{ mcpRegistryDir: PACKAGE_FRAMEWORK });
|
|
283
234
|
if (drift.invalid.length > 0) {
|
|
284
235
|
check('Personas agents.json valid', false, false,
|
|
285
236
|
`${drift.invalid.map(i => i.reason).join(' | ')} — corrija o agents.json e rode 'morph-spec update'`);
|
|
@@ -533,16 +484,16 @@ export async function doctorAiCommand(targetPath, options = {}) {
|
|
|
533
484
|
}
|
|
534
485
|
|
|
535
486
|
export async function doctorCommand(options = {}) {
|
|
536
|
-
//
|
|
487
|
+
// Duas superfícies dariam dois códigos de saída no mesmo processo: recusa.
|
|
488
|
+
const [first, ...rest] = ['ai', 'full', 'mcp', 'reset'].filter((f) => options[f]).map((f) => `--${f}`);
|
|
489
|
+
if (rest.length) {
|
|
490
|
+
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.`);
|
|
491
|
+
logger.dim(` Rode uma por vez: morph-spec doctor ${first}`);
|
|
492
|
+
process.exitCode = 1;
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
|
|
537
496
|
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
497
|
return doctorAiCommand(process.cwd(), options);
|
|
547
498
|
}
|
|
548
499
|
|
|
@@ -587,16 +538,6 @@ export async function doctorCommand(options = {}) {
|
|
|
587
538
|
let hasErrors = false;
|
|
588
539
|
let hasWarnings = false;
|
|
589
540
|
|
|
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
541
|
const cliCheck = await checkCLIOutdated();
|
|
601
542
|
const projectCheck = await checkProjectOutdated(targetPath);
|
|
602
543
|
|
|
@@ -660,15 +601,10 @@ export async function doctorCommand(options = {}) {
|
|
|
660
601
|
hasWarnings = true;
|
|
661
602
|
}
|
|
662
603
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
if (claudeMdStatus === 'ok') {
|
|
666
|
-
checks.push({ name: 'CLAUDE.md', status: 'ok' });
|
|
667
|
-
} else if (claudeMdStatus === 'missing-import') {
|
|
668
|
-
checks.push({ name: 'CLAUDE.md', status: 'warn', msg: 'missing @.claude/CLAUDE.md import — run morph-spec update' });
|
|
669
|
-
hasWarnings = true;
|
|
604
|
+
if (await pathExists(join(targetPath, '.claude', 'CLAUDE.md'))) {
|
|
605
|
+
checks.push({ name: '.claude/CLAUDE.md', status: 'ok' });
|
|
670
606
|
} else {
|
|
671
|
-
checks.push({ name: 'CLAUDE.md', status: 'missing' });
|
|
607
|
+
checks.push({ name: '.claude/CLAUDE.md', status: 'missing' });
|
|
672
608
|
hasErrors = true;
|
|
673
609
|
}
|
|
674
610
|
|
|
@@ -688,6 +624,7 @@ export async function doctorCommand(options = {}) {
|
|
|
688
624
|
checks.push({ name: 'config.json', status: 'ok' });
|
|
689
625
|
} else {
|
|
690
626
|
checks.push({ name: 'config.json', status: 'warn', msg: 'project.name not set' });
|
|
627
|
+
hasWarnings = true;
|
|
691
628
|
}
|
|
692
629
|
} catch {
|
|
693
630
|
checks.push({ name: 'config.json', status: 'error', msg: 'invalid JSON' });
|
|
@@ -717,11 +654,9 @@ export async function doctorCommand(options = {}) {
|
|
|
717
654
|
}
|
|
718
655
|
|
|
719
656
|
const standardsPath = join(morphPath, 'framework', 'standards');
|
|
720
|
-
const frameworkStdsRoot = join(
|
|
657
|
+
const frameworkStdsRoot = join(PACKAGE_FRAMEWORK, 'standards');
|
|
721
658
|
if (await pathExists(standardsPath)) {
|
|
722
|
-
|
|
723
|
-
await pathExists(join(standardsPath, 'vertical-slice.md'));
|
|
724
|
-
if (vsaStd) {
|
|
659
|
+
if (await pathExists(join(standardsPath, 'architecture', 'vertical-slice', 'vertical-slice.md'))) {
|
|
725
660
|
checks.push({ name: 'standards/', status: 'ok' });
|
|
726
661
|
} else {
|
|
727
662
|
checks.push({ name: 'standards/', status: 'warn', msg: 'VSA standard missing — run morph-spec init' });
|
|
@@ -735,13 +670,9 @@ export async function doctorCommand(options = {}) {
|
|
|
735
670
|
hasErrors = true;
|
|
736
671
|
}
|
|
737
672
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if (await pathExists(templatesPath)) {
|
|
742
|
-
checks.push({ name: 'templates/', status: 'ok', msg: 'local override present' });
|
|
743
|
-
} else {
|
|
744
|
-
checks.push({ name: 'templates/', status: 'ok', msg: 'resolved from package (no local override)' });
|
|
673
|
+
if (await pathExists(join(morphPath, 'framework', 'templates'))) {
|
|
674
|
+
checks.push({ name: 'templates/', status: 'warn', msg: 'not read: templates come from the package (morph-spec scaffold show <id>) — delete .morph/framework/templates/' });
|
|
675
|
+
hasWarnings = true;
|
|
745
676
|
}
|
|
746
677
|
|
|
747
678
|
const claudePath = join(targetPath, '.claude');
|
|
@@ -755,29 +686,6 @@ export async function doctorCommand(options = {}) {
|
|
|
755
686
|
if (hasCommands && hasSkills) {
|
|
756
687
|
checks.push({ name: '.claude/', status: 'ok' });
|
|
757
688
|
|
|
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
689
|
const rulesPath = join(claudePath, 'rules');
|
|
782
690
|
if (await pathExists(rulesPath)) {
|
|
783
691
|
const ruleFiles = await fs.readdir(rulesPath);
|
|
@@ -794,7 +702,7 @@ export async function doctorCommand(options = {}) {
|
|
|
794
702
|
hasWarnings = true;
|
|
795
703
|
}
|
|
796
704
|
if (gaps?.missing.length) {
|
|
797
|
-
checks.push({ name: 'stack rules', status: 'warn', msg: `faltando para [${gaps.tags.join(', ')}]: ${gaps.missing.join(', ')} — rode morph-spec
|
|
705
|
+
checks.push({ name: 'stack rules', status: 'warn', msg: `faltando para [${gaps.tags.join(', ')}]: ${gaps.missing.join(', ')} — rode morph-spec update` });
|
|
798
706
|
hasWarnings = true;
|
|
799
707
|
}
|
|
800
708
|
|
|
@@ -811,8 +719,7 @@ export async function doctorCommand(options = {}) {
|
|
|
811
719
|
projectTags = getProjectTags(await readJson(configPath));
|
|
812
720
|
} catch {}
|
|
813
721
|
const tagsLabel = projectTags.length > 0 ? projectTags.join(', ') : 'all (stack unknown)';
|
|
814
|
-
const
|
|
815
|
-
const { missing } = checkMissingAgents(targetPath, frameworkDir, projectTags);
|
|
722
|
+
const { missing } = checkMissingAgents(targetPath, PACKAGE_FRAMEWORK, projectTags);
|
|
816
723
|
if (missing.length > 0) {
|
|
817
724
|
const names = missing.map(m => m.name).join(', ');
|
|
818
725
|
checks.push({
|
|
@@ -887,15 +794,17 @@ export async function doctorCommand(options = {}) {
|
|
|
887
794
|
}
|
|
888
795
|
} catch {}
|
|
889
796
|
|
|
890
|
-
console.log(chalk.cyan('\n Claude Code Plugins (required by morph-spec init)'));
|
|
891
797
|
const pluginsFile = join(homedir(), '.claude', 'plugins', 'installed_plugins.json');
|
|
892
798
|
let pluginData = { plugins: {} };
|
|
893
799
|
try {
|
|
894
800
|
pluginData = JSON.parse(await fs.readFile(pluginsFile, 'utf8'));
|
|
895
801
|
} catch {}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
802
|
+
if (checkInstalledPlugins(pluginData.plugins || {}).context7) {
|
|
803
|
+
checks.push({ name: 'context7 plugin', status: 'ok' });
|
|
804
|
+
} else {
|
|
805
|
+
checks.push({ name: 'context7 plugin', status: 'missing', msg: 'run: claude plugin install context7@claude-plugins-official' });
|
|
806
|
+
hasErrors = true;
|
|
807
|
+
}
|
|
899
808
|
} else {
|
|
900
809
|
// `.claude/` without commands/ or skills/: count what is left; near-total loss is an ERROR with the fix.
|
|
901
810
|
const pieces = ['agents', 'rules', 'skills', 'commands'];
|
|
@@ -936,10 +845,9 @@ export async function doctorCommand(options = {}) {
|
|
|
936
845
|
checks.push({ name: 'codebase graph', status: 'ok', msg: graphAudit.msg });
|
|
937
846
|
}
|
|
938
847
|
|
|
939
|
-
const frameworkTemplatesRoot = join(import.meta.dirname, '..', '..', '..', 'framework', 'templates');
|
|
940
848
|
const keyTemplates = [
|
|
941
|
-
{ name: 'plan.md', path: join(
|
|
942
|
-
{ name: 'morph-uiux mockups.md', path: join(
|
|
849
|
+
{ name: 'plan.md', path: join(PACKAGE_FRAMEWORK, 'templates', 'docs', 'plan.md') },
|
|
850
|
+
{ name: 'morph-uiux mockups.md', path: join(PACKAGE_FRAMEWORK, 'skills', 'core', 'morph-uiux', 'references', 'mockups.md') }
|
|
943
851
|
];
|
|
944
852
|
const missingTemplates = [];
|
|
945
853
|
for (const template of keyTemplates) {
|
|
@@ -960,24 +868,22 @@ export async function doctorCommand(options = {}) {
|
|
|
960
868
|
|
|
961
869
|
const nodeVersion = process.version;
|
|
962
870
|
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0], 10);
|
|
963
|
-
if (majorVersion >=
|
|
871
|
+
if (majorVersion >= 22) {
|
|
964
872
|
checks.push({ name: `Node.js ${nodeVersion}`, status: 'ok' });
|
|
965
873
|
} else {
|
|
966
|
-
checks.push({ name: `Node.js ${nodeVersion}`, status: 'warn', msg: '
|
|
874
|
+
checks.push({ name: `Node.js ${nodeVersion}`, status: 'warn', msg: 'v22+ required' });
|
|
967
875
|
hasWarnings = true;
|
|
968
876
|
}
|
|
969
877
|
|
|
970
|
-
for (const
|
|
971
|
-
if (
|
|
972
|
-
console.log(chalk.green(` ✓ ${
|
|
973
|
-
} else if (
|
|
974
|
-
console.log(chalk.yellow(` ⚠ ${
|
|
975
|
-
} else if (
|
|
976
|
-
console.log(chalk.red(` ✗ ${
|
|
977
|
-
} else if (
|
|
978
|
-
console.log(chalk.red(` ✗ ${
|
|
979
|
-
} else if (check.status === 'skip') {
|
|
980
|
-
console.log(chalk.gray(` ○ ${check.name}`) + chalk.gray(check.msg ? ` (${check.msg})` : ''));
|
|
878
|
+
for (const c of checks) {
|
|
879
|
+
if (c.status === 'ok') {
|
|
880
|
+
console.log(chalk.green(` ✓ ${c.name}`));
|
|
881
|
+
} else if (c.status === 'warn') {
|
|
882
|
+
console.log(chalk.yellow(` ⚠ ${c.name}`) + chalk.gray(` (${c.msg})`));
|
|
883
|
+
} else if (c.status === 'missing') {
|
|
884
|
+
console.log(chalk.red(` ✗ ${c.name}`) + chalk.gray(c.msg ? ` (missing — ${c.msg})` : ' (missing)'));
|
|
885
|
+
} else if (c.status === 'error') {
|
|
886
|
+
console.log(chalk.red(` ✗ ${c.name}`) + chalk.gray(` (${c.msg})`));
|
|
981
887
|
}
|
|
982
888
|
}
|
|
983
889
|
|
|
@@ -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
|
-
|
|
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;
|
|
@@ -4,7 +4,7 @@ import { installStackAssets } from '../../lib/installers/stack-assets.js';
|
|
|
4
4
|
|
|
5
5
|
const ACTION = { added: 'novo', updated: 'atualizado pelo scan', kept: 'mantido (editado à mão)', removed: 'removido (o scan não gera mais)' };
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function contractLines(plan) {
|
|
8
8
|
const p = plan.config.project ?? {};
|
|
9
9
|
const lines = [];
|
|
10
10
|
lines.push(`Stack: ${p.stack ?? 'não detectada (repo vazio: o init pergunta; sem terminal, use --stack)'}${p.tags?.length ? ` · tags: ${p.tags.join(', ')}` : ''}`);
|
|
@@ -19,7 +19,7 @@ export function contractLines(plan) {
|
|
|
19
19
|
return lines;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function previewLines(tags) {
|
|
23
23
|
const preview = installPreview(tags);
|
|
24
24
|
return Object.entries(preview).map(([kind, list]) => `Instala ${kind}: ${list.length ? list.join(', ') : '—'}`);
|
|
25
25
|
}
|