@polymorphism-tech/morph-spec 11.2.0 → 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 +7 -7
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +1 -1
- package/framework/MORPH.md +2 -2
- package/framework/agents.json +4 -4
- package/framework/docs/CLI.md +19 -11
- package/framework/evals/review-checklist.md +26 -2
- package/framework/hooks/README.md +3 -2
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/mcp/registry.json +15 -15
- package/framework/rules/ai-agents-standards.md +9 -1
- package/framework/rules/gsap-standards.md +8 -0
- package/framework/rules/mcp-standards.md +10 -0
- package/framework/schemas/config.schema.json +7 -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 +4 -3
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +1 -1
- 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 +124 -266
- package/framework/templates/README.md +52 -82
- package/framework/templates/REGISTRY.json +0 -206
- 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 +1 -1
- 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 +2 -4
- package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
- package/framework/templates/infrastructure/github/README.md +10 -13
- package/package.json +2 -2
- package/src/commands/mcp/manual-setup.js +95 -0
- package/src/commands/mcp/mcp-setup.js +23 -191
- package/src/commands/project/doctor.js +6 -16
- package/src/commands/project/init-contract.js +2 -2
- package/src/commands/project/init.js +15 -133
- package/src/commands/project/stack-scan.js +6 -14
- package/src/commands/project/stack-set.js +1 -1
- package/src/commands/project/standards.js +1 -2
- package/src/commands/project/update.js +52 -66
- package/src/commands/scaffold/scaffold.js +28 -7
- package/src/lib/ai/ai-project-scan.js +1 -4
- package/src/lib/ai/code-audit.js +1 -6
- package/src/lib/ai/registry-audit.js +2 -1
- package/src/lib/config/project-config.js +3 -2
- package/src/lib/contract/apply.js +2 -1
- package/src/lib/contract/merge.js +1 -0
- package/src/lib/contract/scan.js +5 -5
- package/src/lib/detectors/claude-config-detector.js +45 -47
- package/src/lib/detectors/mcp-config.js +2 -1
- package/src/lib/diff/diff-lines.js +2 -7
- package/src/lib/graph/graph-loader.js +2 -1
- package/src/lib/graph/graphifyignore.js +2 -1
- package/src/lib/installers/install-manifest.js +56 -0
- package/src/lib/installers/mcp-installer.js +14 -5
- package/src/lib/installers/rules-installer.js +9 -15
- package/src/lib/installers/stack-assets.js +42 -21
- package/src/lib/installers/stack-sync.js +12 -12
- 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 +3 -2
- package/src/lib/plan/media.js +3 -3
- package/src/lib/plan/plan-parser.js +5 -10
- package/src/lib/review-reports.js +5 -4
- package/src/lib/stack/stack-scan.js +1 -1
- package/src/lib/standards/verified-against.js +1 -1
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/lib/text.js +5 -0
- package/src/scripts/setup-infra.js +22 -33
- package/src/utils/agents-installer.js +13 -30
- package/src/utils/claude-md-injector.js +16 -50
- package/src/utils/claude-settings-manager.js +2 -2
- package/src/utils/file-copier.js +3 -4
- package/src/utils/hooks-installer.js +55 -20
- package/src/utils/skills-installer.js +18 -78
- 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/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/lib/detectors/index.js +0 -153
- package/src/lib/installers/templates-reconcile.js +0 -26
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import {
|
|
6
|
+
installMcpWithCredentials,
|
|
7
|
+
generateSetupInstructions,
|
|
8
|
+
isRemoteMcp,
|
|
9
|
+
} from '../../lib/installers/mcp-installer.js';
|
|
10
|
+
|
|
11
|
+
const STATUS_ICONS = {
|
|
12
|
+
installed: chalk.green('✓'),
|
|
13
|
+
available: chalk.cyan('○'),
|
|
14
|
+
already_configured: chalk.green('✓'),
|
|
15
|
+
needs_setup: chalk.yellow('⚠'),
|
|
16
|
+
prereq_missing: chalk.red('✗'),
|
|
17
|
+
not_relevant: chalk.gray('─'),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function printMcpStatusTable(rows) {
|
|
21
|
+
for (const row of rows) {
|
|
22
|
+
const icon = STATUS_ICONS[row.status] || '?';
|
|
23
|
+
const statusLabel = row.status.replace(/_/g, ' ');
|
|
24
|
+
console.log(` ${icon} ${row.name.padEnd(15)} ${statusLabel.padEnd(20)} ${chalk.gray(row.detail)}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The project scope writes `.mcp.json`, where every other MCP of this setup lives. The default
|
|
29
|
+
// scope (local) is keyed to this checkout's path in `~/.claude.json`: a worktree never gets it.
|
|
30
|
+
export function remoteAddCommand(name, url) {
|
|
31
|
+
return `claude mcp add --transport http --scope project ${name} ${url}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function printLater(name, entry) {
|
|
35
|
+
if (isRemoteMcp(entry.install.config)) {
|
|
36
|
+
console.log(chalk.gray(` Run later: ${remoteAddCommand(name, entry.install.config.url)}`));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const instructions = generateSetupInstructions(name, entry);
|
|
40
|
+
console.log(chalk.gray(' Add to .mcp.json → mcpServers:'));
|
|
41
|
+
console.log(chalk.gray(' ' + '─'.repeat(55)));
|
|
42
|
+
for (const line of instructions.configSnippet.split('\n')) console.log(chalk.gray(` ${line}`));
|
|
43
|
+
console.log(chalk.gray(' ' + '─'.repeat(55)));
|
|
44
|
+
for (const cred of instructions.credentialUrls) console.log(chalk.gray(` Get ${cred.name}: ${cred.helpUrl}`));
|
|
45
|
+
console.log(chalk.gray(` Or run later: ${instructions.cliCommand}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function askCredentials(credentials, prompt) {
|
|
49
|
+
const values = {};
|
|
50
|
+
for (const cred of credentials) {
|
|
51
|
+
const { value } = await prompt([{
|
|
52
|
+
type: cred.secret ? 'password' : 'input',
|
|
53
|
+
name: 'value',
|
|
54
|
+
message: `${cred.name}:`,
|
|
55
|
+
mask: cred.secret ? '*' : undefined,
|
|
56
|
+
}]);
|
|
57
|
+
values[cred.envVar] = value;
|
|
58
|
+
}
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* One MCP that cannot install by itself: asks, then registers a remote one through `claude mcp add`
|
|
64
|
+
* or writes a credentialed one into `.mcp.json`; a "no" prints how to do it later.
|
|
65
|
+
* @returns {Promise<boolean>} whether the MCP ended up configured
|
|
66
|
+
*/
|
|
67
|
+
export async function setupManualMcp(targetPath, name, entry, {
|
|
68
|
+
prompt = inquirer.prompt, exec = execSync, message = `Set up ${name} MCP now? (${entry.usage})`, defaultYes = false,
|
|
69
|
+
} = {}) {
|
|
70
|
+
for (const warning of entry.install.warnings || []) console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
71
|
+
|
|
72
|
+
const { setupNow } = await prompt([{ type: 'confirm', name: 'setupNow', message, default: defaultYes }]);
|
|
73
|
+
if (!setupNow) {
|
|
74
|
+
printLater(name, entry);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (isRemoteMcp(entry.install.config)) {
|
|
79
|
+
const command = remoteAddCommand(name, entry.install.config.url);
|
|
80
|
+
try {
|
|
81
|
+
exec(command, { stdio: 'inherit', timeout: 120000, cwd: targetPath });
|
|
82
|
+
} catch {
|
|
83
|
+
console.log(chalk.yellow(` ${name} not configured. Run later: ${command}`));
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
console.log(chalk.green(` ✓ ${name} MCP added to .mcp.json (a server with OAuth authenticates through /mcp in the Claude Code session)`));
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const credentialValues = await askCredentials(entry.install.credentials || [], prompt);
|
|
91
|
+
const spinner = ora(`Configuring ${name}...`).start();
|
|
92
|
+
await installMcpWithCredentials(targetPath, name, entry, credentialValues);
|
|
93
|
+
spinner.succeed(`${name} MCP configured`);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
@@ -2,63 +2,34 @@ import chalk from 'chalk';
|
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import { readFileSync, existsSync } from 'fs';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
5
6
|
import { join } from 'path';
|
|
6
7
|
import {
|
|
7
8
|
orchestrateMcpSetup,
|
|
8
9
|
installAutoMcps,
|
|
9
10
|
installCompanionSkills,
|
|
10
|
-
installMcpWithCredentials,
|
|
11
|
-
generateSetupInstructions,
|
|
12
11
|
formatMcpStatusTable,
|
|
13
12
|
loadMcpRegistry,
|
|
14
13
|
isRemoteMcp
|
|
15
14
|
} from '../../lib/installers/mcp-installer.js';
|
|
16
15
|
import { detectClaudeConfig } from '../../lib/detectors/claude-config-detector.js';
|
|
17
|
-
import {
|
|
16
|
+
import { printMcpStatusTable, remoteAddCommand, setupManualMcp } from './manual-setup.js';
|
|
17
|
+
import { scanRepo } from '../../lib/contract/scan.js';
|
|
18
|
+
import { readMorphConfig } from '../../lib/config/project-config.js';
|
|
18
19
|
|
|
19
|
-
//
|
|
20
|
-
// re-detection collapses it to whichever half it notices first.
|
|
20
|
+
// The declared stack wins; without a contract, the same scan `init` runs.
|
|
21
21
|
export async function detectStack(targetPath) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
26
|
-
const configStack = config.project?.stack;
|
|
27
|
-
if (configStack && configStack !== 'unknown') {
|
|
28
|
-
return configStack;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
} catch {
|
|
32
|
-
// Fall through to filesystem detection
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const results = await detectProject(targetPath);
|
|
37
|
-
return results.structure?.stack || 'unknown';
|
|
38
|
-
} catch {
|
|
39
|
-
return 'unknown';
|
|
40
|
-
}
|
|
22
|
+
const configStack = readMorphConfig(targetPath)?.project?.stack;
|
|
23
|
+
if (configStack && configStack !== 'unknown') return configStack;
|
|
24
|
+
return scanRepo(targetPath).stack ?? 'unknown';
|
|
41
25
|
}
|
|
42
26
|
|
|
43
|
-
//
|
|
44
|
-
//
|
|
27
|
+
// An MCP scoped to an integration (neon, asaas) is only offered through these: the stack string never
|
|
28
|
+
// carries them. `integrations` is what `stack-set` declares, `tags` what the `init` scan found.
|
|
45
29
|
export async function detectIntegrations(targetPath) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const integrations = JSON.parse(readFileSync(configPath, 'utf-8')).project?.integrations;
|
|
50
|
-
if (Array.isArray(integrations)) return integrations;
|
|
51
|
-
}
|
|
52
|
-
} catch {
|
|
53
|
-
// Fall through to filesystem detection
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const results = await detectProject(targetPath);
|
|
58
|
-
return results.structure?.integrations ?? [];
|
|
59
|
-
} catch {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
30
|
+
const { integrations, tags } = readMorphConfig(targetPath)?.project ?? {};
|
|
31
|
+
if (Array.isArray(integrations) || Array.isArray(tags)) return [...new Set([...(integrations ?? []), ...(tags ?? [])])];
|
|
32
|
+
return scanRepo(targetPath).tags;
|
|
62
33
|
}
|
|
63
34
|
|
|
64
35
|
export async function mcpSetupCommand(name, options) {
|
|
@@ -80,7 +51,7 @@ export async function mcpSetupCommand(name, options) {
|
|
|
80
51
|
}
|
|
81
52
|
|
|
82
53
|
if (name) {
|
|
83
|
-
return setupSpecificMcp(targetPath, name,
|
|
54
|
+
return setupSpecificMcp(targetPath, name, existingMcps);
|
|
84
55
|
}
|
|
85
56
|
|
|
86
57
|
return interactiveWizard(targetPath, stack, existingMcps, integrations, enabledPlugins);
|
|
@@ -98,25 +69,12 @@ async function showStatusList(targetPath, stack, existingMcps, integrations, ena
|
|
|
98
69
|
console.log(` Stack: ${chalk.bold(stack)}`);
|
|
99
70
|
console.log(' ' + '─'.repeat(60));
|
|
100
71
|
|
|
101
|
-
const STATUS_ICONS = {
|
|
102
|
-
installed: chalk.green('✓'),
|
|
103
|
-
available: chalk.cyan('○'),
|
|
104
|
-
already_configured: chalk.green('✓'),
|
|
105
|
-
needs_setup: chalk.yellow('⚠'),
|
|
106
|
-
prereq_missing: chalk.red('✗'),
|
|
107
|
-
not_relevant: chalk.gray('─')
|
|
108
|
-
};
|
|
109
|
-
|
|
110
72
|
if (statusRows.length === 0) {
|
|
111
73
|
console.log(chalk.gray('\n No MCPs in registry.\n'));
|
|
112
74
|
return;
|
|
113
75
|
}
|
|
114
76
|
|
|
115
|
-
|
|
116
|
-
const icon = STATUS_ICONS[row.status] || '?';
|
|
117
|
-
const statusLabel = row.status.replace(/_/g, ' ');
|
|
118
|
-
console.log(` ${icon} ${row.name.padEnd(15)} ${statusLabel.padEnd(20)} ${chalk.gray(row.detail)}`);
|
|
119
|
-
}
|
|
77
|
+
printMcpStatusTable(statusRows);
|
|
120
78
|
|
|
121
79
|
console.log('');
|
|
122
80
|
}
|
|
@@ -150,7 +108,7 @@ async function autoInstall(targetPath, stack, existingMcps, integrations, enable
|
|
|
150
108
|
console.log('');
|
|
151
109
|
}
|
|
152
110
|
|
|
153
|
-
async function setupSpecificMcp(targetPath, name,
|
|
111
|
+
async function setupSpecificMcp(targetPath, name, existingMcps) {
|
|
154
112
|
const registry = loadMcpRegistry();
|
|
155
113
|
const mcpEntry = registry.mcps[name];
|
|
156
114
|
|
|
@@ -182,7 +140,6 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
182
140
|
const prereqs = mcpEntry.install.prerequisites || [];
|
|
183
141
|
for (const prereq of prereqs) {
|
|
184
142
|
try {
|
|
185
|
-
const { execSync } = await import('child_process');
|
|
186
143
|
execSync(prereq.checkCommand, { stdio: 'ignore', timeout: 5000 });
|
|
187
144
|
} catch {
|
|
188
145
|
console.log(chalk.red(`\n Missing prerequisite: ${prereq.name}`));
|
|
@@ -192,12 +149,6 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
192
149
|
}
|
|
193
150
|
}
|
|
194
151
|
|
|
195
|
-
for (const warning of mcpEntry.install.warnings || []) {
|
|
196
|
-
console.log(chalk.yellow(`\n ⚠ ${warning}`));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const credentials = mcpEntry.install.credentials || [];
|
|
200
|
-
|
|
201
152
|
if (mcpEntry.install.autoInstall) {
|
|
202
153
|
const spinner = ora(`Installing ${name}...`).start();
|
|
203
154
|
const result = await installAutoMcps(targetPath, { [name]: mcpEntry });
|
|
@@ -215,86 +166,14 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
215
166
|
return;
|
|
216
167
|
}
|
|
217
168
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
console.log(chalk.gray(` Usage: ${mcpEntry.usage}`));
|
|
221
|
-
console.log('');
|
|
222
|
-
|
|
223
|
-
const instructions = generateSetupInstructions(name, mcpEntry);
|
|
224
|
-
console.log(chalk.white(` Run this command to add the MCP:`));
|
|
225
|
-
console.log(chalk.cyan(` ${instructions.cliCommand}`));
|
|
226
|
-
console.log('');
|
|
227
|
-
|
|
228
|
-
for (const warning of mcpEntry.install.warnings || []) {
|
|
229
|
-
console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const { installNow } = await inquirer.prompt([{
|
|
233
|
-
type: 'confirm',
|
|
234
|
-
name: 'installNow',
|
|
235
|
-
message: 'Run it now (claude mcp add)?',
|
|
236
|
-
default: true
|
|
237
|
-
}]);
|
|
238
|
-
|
|
239
|
-
if (installNow) {
|
|
240
|
-
console.log(chalk.cyan(` Launching ${name} OAuth authentication...`));
|
|
241
|
-
try {
|
|
242
|
-
const { execSync } = await import('child_process');
|
|
243
|
-
execSync(`claude mcp add --transport http ${name} ${mcpEntry.install.config.url}`, {
|
|
244
|
-
stdio: 'inherit',
|
|
245
|
-
timeout: 120000
|
|
246
|
-
});
|
|
247
|
-
console.log(chalk.green(` ✓ ${name} MCP configured via OAuth`));
|
|
248
|
-
} catch {
|
|
249
|
-
const instructions = generateSetupInstructions(name, mcpEntry);
|
|
250
|
-
console.log(chalk.yellow(` Setup cancelled. Run later: ${instructions.cliCommand}`));
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
console.log('');
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
console.log(chalk.cyan(`\n Setting up ${name} MCP\n`));
|
|
169
|
+
const remote = isRemoteMcp(mcpEntry.install.config);
|
|
170
|
+
console.log(chalk.cyan(`\n Setting up ${name} MCP${remote ? ' (remote)' : ''}\n`));
|
|
259
171
|
console.log(chalk.gray(` Usage: ${mcpEntry.usage}`));
|
|
260
172
|
console.log('');
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
message: 'Enter credentials now?',
|
|
266
|
-
default: true
|
|
267
|
-
}]);
|
|
268
|
-
|
|
269
|
-
if (enterCredentials) {
|
|
270
|
-
const credentialValues = {};
|
|
271
|
-
for (const cred of credentials) {
|
|
272
|
-
const { value } = await inquirer.prompt([{
|
|
273
|
-
type: cred.secret ? 'password' : 'input',
|
|
274
|
-
name: 'value',
|
|
275
|
-
message: `${cred.name}:`,
|
|
276
|
-
mask: cred.secret ? '*' : undefined
|
|
277
|
-
}]);
|
|
278
|
-
credentialValues[cred.envVar] = value;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const spinner = ora(`Configuring ${name}...`).start();
|
|
282
|
-
await installMcpWithCredentials(targetPath, name, mcpEntry, credentialValues);
|
|
283
|
-
spinner.succeed(`${name} MCP configured`);
|
|
284
|
-
} else {
|
|
285
|
-
const instructions = generateSetupInstructions(name, mcpEntry);
|
|
286
|
-
console.log(chalk.gray('\n Add to .mcp.json → mcpServers:'));
|
|
287
|
-
console.log(chalk.gray(' ' + '─'.repeat(55)));
|
|
288
|
-
for (const line of instructions.configSnippet.split('\n')) {
|
|
289
|
-
console.log(chalk.gray(` ${line}`));
|
|
290
|
-
}
|
|
291
|
-
console.log(chalk.gray(' ' + '─'.repeat(55)));
|
|
292
|
-
|
|
293
|
-
for (const cred of instructions.credentialUrls) {
|
|
294
|
-
console.log(chalk.gray(` Get ${cred.name}: ${cred.helpUrl}`));
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
173
|
+
await setupManualMcp(targetPath, name, mcpEntry, {
|
|
174
|
+
message: remote ? `Run it now (${remoteAddCommand(name, mcpEntry.install.config.url)})?` : 'Enter credentials now?',
|
|
175
|
+
defaultYes: true,
|
|
176
|
+
});
|
|
298
177
|
console.log('');
|
|
299
178
|
}
|
|
300
179
|
|
|
@@ -342,54 +221,7 @@ async function interactiveWizard(targetPath, stack, existingMcps, integrations,
|
|
|
342
221
|
|
|
343
222
|
for (const name of manualNames) {
|
|
344
223
|
const entry = orchestration.needsManualSetup[name];
|
|
345
|
-
|
|
346
|
-
for (const warning of entry.install.warnings || []) {
|
|
347
|
-
console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
351
|
-
const { setupNow } = await inquirer.prompt([{
|
|
352
|
-
type: 'confirm',
|
|
353
|
-
name: 'setupNow',
|
|
354
|
-
message: `Set up ${capitalizedName}? (${entry.usage})`,
|
|
355
|
-
default: false
|
|
356
|
-
}]);
|
|
357
|
-
|
|
358
|
-
if (setupNow) {
|
|
359
|
-
if (isRemoteMcp(entry.install.config)) {
|
|
360
|
-
console.log(chalk.cyan(` Launching ${capitalizedName} OAuth...`));
|
|
361
|
-
try {
|
|
362
|
-
const { execSync } = await import('child_process');
|
|
363
|
-
execSync(`claude mcp add --transport http ${name} ${entry.install.config.url}`, {
|
|
364
|
-
stdio: 'inherit',
|
|
365
|
-
timeout: 120000
|
|
366
|
-
});
|
|
367
|
-
console.log(chalk.green(` ✓ ${capitalizedName} configured via OAuth`));
|
|
368
|
-
} catch {
|
|
369
|
-
const instructions = generateSetupInstructions(name, entry);
|
|
370
|
-
console.log(chalk.yellow(` Setup cancelled. Run later: ${instructions.cliCommand}`));
|
|
371
|
-
}
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
const credentialValues = {};
|
|
376
|
-
for (const cred of entry.install.credentials) {
|
|
377
|
-
const { value } = await inquirer.prompt([{
|
|
378
|
-
type: cred.secret ? 'password' : 'input',
|
|
379
|
-
name: 'value',
|
|
380
|
-
message: `${cred.name}:`,
|
|
381
|
-
mask: cred.secret ? '*' : undefined
|
|
382
|
-
}]);
|
|
383
|
-
credentialValues[cred.envVar] = value;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const spinner = ora(`Configuring ${name}...`).start();
|
|
387
|
-
await installMcpWithCredentials(targetPath, name, entry, credentialValues);
|
|
388
|
-
spinner.succeed(`${capitalizedName} configured`);
|
|
389
|
-
} else {
|
|
390
|
-
const instructions = generateSetupInstructions(name, entry);
|
|
391
|
-
console.log(chalk.gray(` Run later: ${instructions.cliCommand}`));
|
|
392
|
-
}
|
|
224
|
+
await setupManualMcp(targetPath, name, entry, { message: `Set up ${name}? (${entry.usage})` });
|
|
393
225
|
}
|
|
394
226
|
}
|
|
395
227
|
|
|
@@ -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,
|
|
@@ -602,15 +601,10 @@ export async function doctorCommand(options = {}) {
|
|
|
602
601
|
hasWarnings = true;
|
|
603
602
|
}
|
|
604
603
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (claudeMdStatus === 'ok') {
|
|
608
|
-
checks.push({ name: 'CLAUDE.md', status: 'ok' });
|
|
609
|
-
} else if (claudeMdStatus === 'missing-import') {
|
|
610
|
-
checks.push({ name: 'CLAUDE.md', status: 'warn', msg: 'missing @.claude/CLAUDE.md import — run morph-spec update' });
|
|
611
|
-
hasWarnings = true;
|
|
604
|
+
if (await pathExists(join(targetPath, '.claude', 'CLAUDE.md'))) {
|
|
605
|
+
checks.push({ name: '.claude/CLAUDE.md', status: 'ok' });
|
|
612
606
|
} else {
|
|
613
|
-
checks.push({ name: 'CLAUDE.md', status: 'missing' });
|
|
607
|
+
checks.push({ name: '.claude/CLAUDE.md', status: 'missing' });
|
|
614
608
|
hasErrors = true;
|
|
615
609
|
}
|
|
616
610
|
|
|
@@ -676,13 +670,9 @@ export async function doctorCommand(options = {}) {
|
|
|
676
670
|
hasErrors = true;
|
|
677
671
|
}
|
|
678
672
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (await pathExists(templatesPath)) {
|
|
683
|
-
checks.push({ name: 'templates/', status: 'ok', msg: 'local override present' });
|
|
684
|
-
} else {
|
|
685
|
-
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;
|
|
686
676
|
}
|
|
687
677
|
|
|
688
678
|
const claudePath = join(targetPath, '.claude');
|
|
@@ -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
|
}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { existsSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import ora from 'ora';
|
|
4
|
-
import { execSync } from 'child_process';
|
|
5
4
|
import { logger } from '../../utils/logger.js';
|
|
6
|
-
import { pathExists, readJson
|
|
5
|
+
import { pathExists, readJson } from '../../utils/file-copier.js';
|
|
7
6
|
import { getInstalledCLIVersion, checkProjectOutdated } from '../../utils/version-checker.js';
|
|
8
7
|
import inquirer from 'inquirer';
|
|
9
|
-
import { detectProject } from '../../lib/detectors/index.js';
|
|
10
8
|
import { detectClaudeConfig, formatConfigSummary } from '../../lib/detectors/claude-config-detector.js';
|
|
11
9
|
import {
|
|
12
10
|
orchestrateMcpSetup,
|
|
13
11
|
installAutoMcps,
|
|
14
12
|
installCompanionSkills,
|
|
15
|
-
installMcpWithCredentials,
|
|
16
|
-
generateSetupInstructions,
|
|
17
13
|
formatMcpStatusTable,
|
|
18
|
-
isRemoteMcp
|
|
19
14
|
} from '../../lib/installers/mcp-installer.js';
|
|
15
|
+
import { printMcpStatusTable, setupManualMcp } from '../mcp/manual-setup.js';
|
|
20
16
|
import { setupInfra } from '../../scripts/setup-infra.js';
|
|
21
17
|
import { getProjectTags } from '../../lib/stack-filter.js';
|
|
22
18
|
import { updateCommand } from './update.js';
|
|
23
19
|
import { setProjectStack } from '../../lib/installers/stack-sync.js';
|
|
24
|
-
import { installStackAssets } from '../../lib/installers/stack-assets.js';
|
|
25
20
|
import { scanRepo } from '../../lib/contract/scan.js';
|
|
26
21
|
import { initDryRun, refreshContract } from './init-contract.js';
|
|
27
22
|
import { isSecondaryWorktree } from '../../../framework/hooks/shared/git-paths.js';
|
|
@@ -53,13 +48,6 @@ export async function chooseGreenfieldStack(options = {}, { isTTY = process.stdi
|
|
|
53
48
|
return stackChoice;
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
async function reinstallForStack(targetPath, stackTags, spinner) {
|
|
57
|
-
if (stackTags.length === 0) return;
|
|
58
|
-
spinner.start('Re-installing stack-filtered assets...');
|
|
59
|
-
await installStackAssets(targetPath, stackTags);
|
|
60
|
-
spinner.succeed(`Stack-filtered assets reinstalled for [${stackTags.join(', ')}]`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
51
|
// A fresh worktree carries the committed contract but not the gitignored harness: that is an install, not a refresh.
|
|
64
52
|
function harnessInstalled(targetPath) {
|
|
65
53
|
return ['.morph/framework/hooks', '.claude/skills/morph-plan'].every((p) => existsSync(join(targetPath, p)));
|
|
@@ -80,7 +68,7 @@ export async function initCommand(options) {
|
|
|
80
68
|
if (projectCheck.isOutdated) {
|
|
81
69
|
logger.info(`MORPH already initialized (v${projectCheck.current}). Framework update available (v${projectCheck.cliVersion}).`);
|
|
82
70
|
logger.blank();
|
|
83
|
-
const updated = await updateCommand(options);
|
|
71
|
+
const updated = await updateCommand({ path: options.path });
|
|
84
72
|
return updated?.refused ? undefined : refreshContract(targetPath);
|
|
85
73
|
}
|
|
86
74
|
logger.info('MORPH já instalado e em dia: atualizando o contrato pelo repo.');
|
|
@@ -100,12 +88,6 @@ export async function initCommand(options) {
|
|
|
100
88
|
|
|
101
89
|
const cliVersion = getInstalledCLIVersion();
|
|
102
90
|
|
|
103
|
-
const configDir = join(morphPath, 'config');
|
|
104
|
-
const configPath = join(configDir, 'config.json');
|
|
105
|
-
|
|
106
|
-
let config = (await pathExists(configPath)) ? await readJson(configPath) : { project: {} };
|
|
107
|
-
if (!config.project) config.project = {};
|
|
108
|
-
|
|
109
91
|
let claudeConfigDetected = null;
|
|
110
92
|
try {
|
|
111
93
|
claudeConfigDetected = await detectClaudeConfig(targetPath);
|
|
@@ -118,43 +100,20 @@ export async function initCommand(options) {
|
|
|
118
100
|
logger.dim(` Claude config detection skipped: ${error.message}`);
|
|
119
101
|
}
|
|
120
102
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (
|
|
124
|
-
try {
|
|
125
|
-
const { structure } = detectProject(targetPath);
|
|
126
|
-
if (structure.stack !== 'unknown') {
|
|
127
|
-
config.project.stack = structure.stack;
|
|
128
|
-
if (structure.integrations.length > 0) config.project.integrations = structure.integrations;
|
|
129
|
-
await writeJson(configPath, config);
|
|
130
|
-
|
|
131
|
-
logger.blank();
|
|
132
|
-
logger.header('Existing Project Detected');
|
|
133
|
-
logger.info(`Stack detected: ${structure.stack}`);
|
|
134
|
-
if (structure.integrations.length > 0) logger.dim(`Integrations: ${structure.integrations.join(', ')}`);
|
|
135
|
-
|
|
136
|
-
await reinstallForStack(targetPath, getProjectTags(config), spinner);
|
|
137
|
-
}
|
|
138
|
-
} catch (error) {
|
|
139
|
-
logger.dim(` Stack detection skipped: ${error.message}`);
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
103
|
+
// A repo with manifests gets its stack from `refreshContract` alone: a value written here first
|
|
104
|
+
// would reach the merge without a fingerprint and freeze as a hand edit.
|
|
105
|
+
if (scanRepo(targetPath).stack === null) {
|
|
142
106
|
const choice = await chooseGreenfieldStack(options);
|
|
143
107
|
if (choice) {
|
|
144
108
|
const result = setProjectStack(targetPath, choice.stack, { integrations: choice.integrations, log: (line) => logger.dim(line) });
|
|
145
|
-
if (result.error) {
|
|
146
|
-
logger.warn(`Stack não declarada: ${result.error}`);
|
|
147
|
-
} else {
|
|
148
|
-
config = await readJson(configPath);
|
|
149
|
-
await reinstallForStack(targetPath, getProjectTags(config), spinner);
|
|
150
|
-
}
|
|
109
|
+
if (result.error) logger.warn(`Stack não declarada: ${result.error}`);
|
|
151
110
|
} else {
|
|
152
111
|
logger.dim(' Stack: não declarada — o /morph-plan pergunta antes de planejar (recomendada: a do Morph)');
|
|
153
112
|
}
|
|
154
113
|
}
|
|
155
114
|
|
|
156
115
|
await refreshContract(targetPath);
|
|
157
|
-
config = await readJson(
|
|
116
|
+
const config = await readJson(join(morphPath, 'config', 'config.json'));
|
|
158
117
|
|
|
159
118
|
let mcpSetupResult = null;
|
|
160
119
|
if (options.skipMcp) {
|
|
@@ -165,7 +124,7 @@ export async function initCommand(options) {
|
|
|
165
124
|
try {
|
|
166
125
|
const existingMcps = claudeConfigDetected?.mcpServers || [];
|
|
167
126
|
const orchestration = orchestrateMcpSetup(targetPath, config.project?.stack ?? 'unknown', existingMcps,
|
|
168
|
-
{ integrations: config
|
|
127
|
+
{ integrations: getProjectTags(config), enabledPlugins: claudeConfigDetected?.enabledPlugins ?? [] });
|
|
169
128
|
|
|
170
129
|
const autoNames = Object.keys(orchestration.autoInstallable);
|
|
171
130
|
const manualNames = Object.keys(orchestration.needsManualSetup);
|
|
@@ -205,94 +164,17 @@ export async function initCommand(options) {
|
|
|
205
164
|
}
|
|
206
165
|
|
|
207
166
|
const manualInstalled = {};
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
for (const warning of entry.install.warnings || []) {
|
|
213
|
-
logger.warn(` ${warning}`);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
217
|
-
const { setupNow } = await inquirer.prompt([{
|
|
218
|
-
type: 'confirm',
|
|
219
|
-
name: 'setupNow',
|
|
220
|
-
message: `Set up ${capitalizedName} MCP now? (${entry.usage})`,
|
|
221
|
-
default: false
|
|
222
|
-
}]);
|
|
223
|
-
|
|
224
|
-
if (setupNow) {
|
|
225
|
-
if (isRemoteMcp(entry.install.config)) {
|
|
226
|
-
const url = entry.install.config.url;
|
|
227
|
-
logger.info(` Launching ${capitalizedName} OAuth authentication...`);
|
|
228
|
-
try {
|
|
229
|
-
execSync(`claude mcp add --transport http ${name} ${url}`, {
|
|
230
|
-
stdio: 'inherit',
|
|
231
|
-
timeout: 120000
|
|
232
|
-
});
|
|
233
|
-
logger.success(` ${capitalizedName} MCP configured`);
|
|
234
|
-
manualInstalled[name] = entry;
|
|
235
|
-
} catch {
|
|
236
|
-
logger.warn(` ${capitalizedName} setup cancelled. Run later: claude mcp add --transport http ${name} ${url}`);
|
|
237
|
-
}
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const credentialValues = {};
|
|
242
|
-
for (const cred of entry.install.credentials) {
|
|
243
|
-
const { value } = await inquirer.prompt([{
|
|
244
|
-
type: cred.secret ? 'password' : 'input',
|
|
245
|
-
name: 'value',
|
|
246
|
-
message: `${cred.name}:`,
|
|
247
|
-
mask: cred.secret ? '*' : undefined
|
|
248
|
-
}]);
|
|
249
|
-
credentialValues[cred.envVar] = value;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
spinner.start(`Configuring ${name}...`);
|
|
253
|
-
await installMcpWithCredentials(targetPath, name, entry, credentialValues);
|
|
254
|
-
spinner.succeed(`${capitalizedName} MCP configured`);
|
|
255
|
-
manualInstalled[name] = entry;
|
|
256
|
-
} else {
|
|
257
|
-
const instructions = generateSetupInstructions(name, entry);
|
|
258
|
-
logger.blank();
|
|
259
|
-
logger.dim(' Add to .mcp.json → mcpServers:');
|
|
260
|
-
logger.dim(' ' + '─'.repeat(55));
|
|
261
|
-
for (const line of instructions.configSnippet.split('\n')) {
|
|
262
|
-
logger.dim(` ${line}`);
|
|
263
|
-
}
|
|
264
|
-
logger.dim(' ' + '─'.repeat(55));
|
|
265
|
-
|
|
266
|
-
for (const cred of instructions.credentialUrls) {
|
|
267
|
-
logger.dim(` Get ${cred.name}: ${cred.helpUrl}`);
|
|
268
|
-
}
|
|
269
|
-
logger.dim(` Or run later: ${instructions.cliCommand}`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
167
|
+
for (const [name, entry] of Object.entries(orchestration.needsManualSetup)) {
|
|
168
|
+
logger.blank();
|
|
169
|
+
if (await setupManualMcp(targetPath, name, entry)) manualInstalled[name] = entry;
|
|
272
170
|
}
|
|
273
171
|
|
|
274
|
-
const
|
|
275
|
-
const statusRows = formatMcpStatusTable(orchestration, justInstalled);
|
|
276
|
-
|
|
172
|
+
const statusRows = formatMcpStatusTable(orchestration, { ...autoInstalled, ...manualInstalled });
|
|
277
173
|
if (statusRows.length > 0) {
|
|
278
174
|
logger.blank();
|
|
279
175
|
logger.info('MCP Servers');
|
|
280
176
|
logger.dim('─'.repeat(60));
|
|
281
|
-
|
|
282
|
-
const STATUS_ICONS = {
|
|
283
|
-
installed: '✓',
|
|
284
|
-
available: '○',
|
|
285
|
-
already_configured: '✓',
|
|
286
|
-
needs_setup: '⚠',
|
|
287
|
-
prereq_missing: '✗',
|
|
288
|
-
not_relevant: '─'
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
for (const row of statusRows) {
|
|
292
|
-
const icon = STATUS_ICONS[row.status] || '?';
|
|
293
|
-
const statusLabel = row.status.replace(/_/g, ' ');
|
|
294
|
-
logger.dim(` ${icon} ${row.name.padEnd(15)} ${statusLabel.padEnd(20)} ${row.detail}`);
|
|
295
|
-
}
|
|
177
|
+
printMcpStatusTable(statusRows);
|
|
296
178
|
}
|
|
297
179
|
|
|
298
180
|
mcpSetupResult = { autoInstalled, manualInstalled, orchestration };
|
|
@@ -313,7 +195,7 @@ export async function initCommand(options) {
|
|
|
313
195
|
logger.blank();
|
|
314
196
|
|
|
315
197
|
logger.info('Files installed:');
|
|
316
|
-
logger.dim(' ✓ CLAUDE.md (
|
|
198
|
+
logger.dim(' ✓ .claude/CLAUDE.md (o Claude Code carrega sozinho; o CLAUDE.md da raiz é seu)');
|
|
317
199
|
logger.dim(' ✓ .morph/config/config.json (o contrato)');
|
|
318
200
|
logger.dim(' ✓ .morph/framework/ (MORPH.md, CLI.md, agents.json, standards/, hooks/)');
|
|
319
201
|
logger.dim(' ✓ .claude/{commands,rules,skills}/ (filtrados pela stack)');
|