@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
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
# Docker Compose for Local Development
|
|
2
2
|
# Next.js + Neon Stack
|
|
3
3
|
#
|
|
4
|
-
# One compose project per worktree.
|
|
5
|
-
# COMPOSE_PROJECT_NAME
|
|
6
|
-
# and volume — so two features running side by side never share a
|
|
7
|
-
# Explicit `container_name:` entries are NOT prefixed, which is why
|
|
8
|
-
# declares none: a named container is a collision waiting for the
|
|
9
|
-
# worktree.
|
|
4
|
+
# One compose project per worktree. `morph-spec env` derives
|
|
5
|
+
# COMPOSE_PROJECT_NAME from the branch name, which prefixes every container,
|
|
6
|
+
# network and volume — so two features running side by side never share a
|
|
7
|
+
# resource. Explicit `container_name:` entries are NOT prefixed, which is why
|
|
8
|
+
# this file declares none: a named container is a collision waiting for the
|
|
9
|
+
# second worktree.
|
|
10
10
|
#
|
|
11
|
-
# Host ports come from the
|
|
11
|
+
# Host ports come from the branch's port block (`morph-spec env`; `morph-spec
|
|
12
|
+
# check` injects the same variables into the contract's test commands):
|
|
12
13
|
# PORT block + 0 (web)
|
|
13
14
|
# API_PORT block + 1 (api)
|
|
14
15
|
# POSTGRES_PORT block + 2 (postgres)
|
|
15
16
|
# REDIS_PORT block + 3 (redis)
|
|
16
17
|
# Every published port reads one of those variables with a single-stack
|
|
17
18
|
# default. A fixed host port here would defeat the block no matter what the
|
|
18
|
-
#
|
|
19
|
-
# compose inside a worktree (`compose-not-isolable`).
|
|
19
|
+
# environment carries.
|
|
20
20
|
#
|
|
21
|
-
# Named volumes
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
21
|
+
# Named volumes outlive the branch: remove them with `docker compose down -v`
|
|
22
|
+
# when the feature closes. Healthchecks are what make `up --wait` meaningful:
|
|
23
|
+
# without them Compose reports "started" the moment the process launches, and
|
|
24
|
+
# the e2e tests would navigate an application not serving yet.
|
|
25
25
|
#
|
|
26
|
-
#
|
|
27
|
-
# `
|
|
28
|
-
# baseURL: process.env.PLAYWRIGHT_BASE_URL ?? `http://localhost:${process.env.PORT ?? 3000}`
|
|
26
|
+
# `playwright.config.ts` must read the port instead of hardcoding a URL:
|
|
27
|
+
# baseURL: `http://localhost:${process.env.PORT ?? 3000}`
|
|
29
28
|
|
|
30
29
|
services:
|
|
31
30
|
# Next.js Application
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
Reusable GitHub Actions workflows
|
|
7
|
+
Reusable GitHub Actions workflows for a .NET API + Next.js web deployed on Coolify with Docker.
|
|
8
8
|
|
|
9
9
|
**Key Features:**
|
|
10
|
-
- Handlebars
|
|
11
|
-
- Composite actions for shared logic
|
|
10
|
+
- Handlebars templates (`.hbs`)
|
|
12
11
|
- Docker multi-stage builds (.NET API + Next.js Web)
|
|
13
12
|
- Coolify deployment via SSH (no MCP/CLI exists — the Coolify API is not publicly exposed, so the runner SSHes into the VPS to trigger it)
|
|
14
13
|
|
|
@@ -18,14 +17,10 @@ Reusable GitHub Actions workflows and composite actions for the **nextjs-neon**
|
|
|
18
17
|
|
|
19
18
|
```
|
|
20
19
|
infrastructure/github/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
│
|
|
26
|
-
└── actions/
|
|
27
|
-
├── docker-build-push/action.yml.hbs # Build & push Docker image
|
|
28
|
-
└── health-check/action.yml.hbs # Poll health endpoint
|
|
20
|
+
└── workflows/
|
|
21
|
+
├── dotnet-build.yml.hbs # .NET restore, build, test, coverage
|
|
22
|
+
├── docker-build-push.yml.hbs # Docker build & push to registry
|
|
23
|
+
└── deploy-coolify.yml.hbs # Coolify deployment via SSH
|
|
29
24
|
```
|
|
30
25
|
|
|
31
26
|
## Workflows
|
|
@@ -46,10 +41,12 @@ infrastructure/github/
|
|
|
46
41
|
|
|
47
42
|
## Usage
|
|
48
43
|
|
|
49
|
-
|
|
44
|
+
Nothing installs these files: read one by its `REGISTRY.json` id and adapt it to the project.
|
|
50
45
|
|
|
51
46
|
```bash
|
|
52
|
-
morph-spec
|
|
47
|
+
morph-spec scaffold show github-workflow-dotnet-build
|
|
48
|
+
morph-spec scaffold show github-workflow-docker-build-push
|
|
49
|
+
morph-spec scaffold show github-workflow-deploy-coolify
|
|
53
50
|
```
|
|
54
51
|
|
|
55
52
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymorphism-tech/morph-spec",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "MORPH-SPEC: NLH (Natural Language Harness) for spec-driven development with Claude Code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -30,29 +30,23 @@
|
|
|
30
30
|
"docs/QUICKSTART.md",
|
|
31
31
|
"docs/CHEATSHEET.md",
|
|
32
32
|
"README.md",
|
|
33
|
-
"LICENSE"
|
|
34
|
-
"CLAUDE.md"
|
|
33
|
+
"LICENSE"
|
|
35
34
|
],
|
|
36
35
|
"type": "module",
|
|
37
36
|
"engines": {
|
|
38
37
|
"node": ">=22.0.0"
|
|
39
38
|
},
|
|
40
39
|
"scripts": {
|
|
41
|
-
"
|
|
42
|
-
"generate": "node scripts/generate-
|
|
43
|
-
"generate:check": "node scripts/generate-refs.js --check && node scripts/generate-ai-pin-props.js --check && node scripts/api-probe/probe.mjs --check",
|
|
40
|
+
"generate": "node scripts/generate-ai-pin-props.js && node scripts/api-probe/probe.mjs --generate",
|
|
41
|
+
"generate:check": "node scripts/generate-ai-pin-props.js --check && node scripts/api-probe/probe.mjs --check",
|
|
44
42
|
"generate-standards": "node scripts/generate-standards-registry.js",
|
|
45
43
|
"generate-standards:check": "node scripts/generate-standards-registry.js --check",
|
|
46
44
|
"validate": "node scripts/validate-framework.js",
|
|
47
45
|
"freshness": "node scripts/check-freshness.js",
|
|
48
|
-
"verify": "npm run generate:check && npm run generate-standards:check && npm run validate && npm run freshness && npm test",
|
|
46
|
+
"verify": "npm run generate:check && npm run generate-standards:check && npm run validate && npm run freshness && npm run test:changed",
|
|
49
47
|
"test": "node scripts/run-tests.mjs",
|
|
50
48
|
"test:changed": "node scripts/test-changed.mjs",
|
|
51
49
|
"test:coverage": "c8 --reporter=text --reporter=html --reporter=lcov node scripts/run-tests.mjs",
|
|
52
|
-
"test:coverage:summary": "c8 --reporter=text-summary node scripts/run-tests.mjs",
|
|
53
|
-
"docs": "jsdoc -c jsdoc.json",
|
|
54
|
-
"docs:watch": "jsdoc -c jsdoc.json --watch",
|
|
55
|
-
"docs:serve": "npx http-server docs/api -p 8080 -o",
|
|
56
50
|
"release": "node scripts/release.js",
|
|
57
51
|
"prepublishOnly": "node scripts/prepublish-check.js",
|
|
58
52
|
"postinstall": "node src/scripts/global-install.js",
|
|
@@ -62,10 +56,9 @@
|
|
|
62
56
|
"chalk": "^5.3.0",
|
|
63
57
|
"commander": "^12.0.0",
|
|
64
58
|
"fs-extra": "^11.2.0",
|
|
65
|
-
"glob": "^13.0.6",
|
|
66
59
|
"handlebars": "^4.7.8",
|
|
67
60
|
"inquirer": "^9.2.0",
|
|
68
|
-
"minimatch": "^
|
|
61
|
+
"minimatch": "^11.0.9",
|
|
69
62
|
"ora": "^8.0.0"
|
|
70
63
|
},
|
|
71
64
|
"repository": {
|
|
@@ -83,8 +76,6 @@
|
|
|
83
76
|
"access": "public"
|
|
84
77
|
},
|
|
85
78
|
"devDependencies": {
|
|
86
|
-
"c8": "^11.0.0"
|
|
87
|
-
"docdash": "^2.0.2",
|
|
88
|
-
"jsdoc": "^4.0.5"
|
|
79
|
+
"c8": "^11.0.0"
|
|
89
80
|
}
|
|
90
81
|
}
|
|
@@ -26,8 +26,8 @@ function readProjectTags(projectPath) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Numa worktree o arquivo do checkout nunca é reescrito; ausente, as regras entram só durante
|
|
29
|
-
// a rodada (uma sobra suja a worktree
|
|
30
|
-
//
|
|
29
|
+
// a rodada (uma sobra suja a worktree). `TEMP_IGNORE_MARKER` na 1ª linha deixa a próxima rodada
|
|
30
|
+
// reconhecer a sobra de um processo morto.
|
|
31
31
|
function prepareIgnore(projectPath, tags) {
|
|
32
32
|
const none = () => {};
|
|
33
33
|
if (!isSecondaryWorktree(projectPath)) return { ...writeGraphifyignore(projectPath, tags), cleanup: none };
|
|
@@ -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, { conversation: false, generateStandards: false });
|
|
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, { conversation: false, generateStandards: false });
|
|
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
|
|
|
@@ -158,15 +116,17 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
158
116
|
console.log(chalk.red(`\n Unknown MCP: ${name}`));
|
|
159
117
|
console.log(chalk.gray(` Available: ${Object.keys(registry.mcps).join(', ')}`));
|
|
160
118
|
console.log('');
|
|
119
|
+
process.exitCode = 1;
|
|
161
120
|
return;
|
|
162
121
|
}
|
|
163
122
|
|
|
164
123
|
if (!mcpEntry.install) {
|
|
165
124
|
console.log(chalk.red(`\n MCP "${name}" has no install configuration.\n`));
|
|
125
|
+
process.exitCode = 1;
|
|
166
126
|
return;
|
|
167
127
|
}
|
|
168
128
|
|
|
169
|
-
const isInstalled = existingMcps.some(s => s.name.toLowerCase().
|
|
129
|
+
const isInstalled = existingMcps.some(s => s.name.toLowerCase() === name.toLowerCase());
|
|
170
130
|
if (isInstalled) {
|
|
171
131
|
const { reconfigure } = await inquirer.prompt([{
|
|
172
132
|
type: 'confirm',
|
|
@@ -180,7 +140,6 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
180
140
|
const prereqs = mcpEntry.install.prerequisites || [];
|
|
181
141
|
for (const prereq of prereqs) {
|
|
182
142
|
try {
|
|
183
|
-
const { execSync } = await import('child_process');
|
|
184
143
|
execSync(prereq.checkCommand, { stdio: 'ignore', timeout: 5000 });
|
|
185
144
|
} catch {
|
|
186
145
|
console.log(chalk.red(`\n Missing prerequisite: ${prereq.name}`));
|
|
@@ -190,12 +149,6 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
190
149
|
}
|
|
191
150
|
}
|
|
192
151
|
|
|
193
|
-
for (const warning of mcpEntry.install.warnings || []) {
|
|
194
|
-
console.log(chalk.yellow(`\n ⚠ ${warning}`));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const credentials = mcpEntry.install.credentials || [];
|
|
198
|
-
|
|
199
152
|
if (mcpEntry.install.autoInstall) {
|
|
200
153
|
const spinner = ora(`Installing ${name}...`).start();
|
|
201
154
|
const result = await installAutoMcps(targetPath, { [name]: mcpEntry });
|
|
@@ -213,86 +166,14 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
213
166
|
return;
|
|
214
167
|
}
|
|
215
168
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
console.log(chalk.gray(` Usage: ${mcpEntry.usage}`));
|
|
219
|
-
console.log('');
|
|
220
|
-
|
|
221
|
-
const instructions = generateSetupInstructions(name, mcpEntry);
|
|
222
|
-
console.log(chalk.white(` Run this command to add the MCP:`));
|
|
223
|
-
console.log(chalk.cyan(` ${instructions.cliCommand}`));
|
|
224
|
-
console.log('');
|
|
225
|
-
|
|
226
|
-
for (const warning of mcpEntry.install.warnings || []) {
|
|
227
|
-
console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const { installNow } = await inquirer.prompt([{
|
|
231
|
-
type: 'confirm',
|
|
232
|
-
name: 'installNow',
|
|
233
|
-
message: 'Add to .mcp.json now?',
|
|
234
|
-
default: true
|
|
235
|
-
}]);
|
|
236
|
-
|
|
237
|
-
if (installNow) {
|
|
238
|
-
console.log(chalk.cyan(` Launching ${name} OAuth authentication...`));
|
|
239
|
-
try {
|
|
240
|
-
const { execSync } = await import('child_process');
|
|
241
|
-
execSync(`claude mcp add --transport http ${name} ${mcpEntry.install.config.url}`, {
|
|
242
|
-
stdio: 'inherit',
|
|
243
|
-
timeout: 120000
|
|
244
|
-
});
|
|
245
|
-
console.log(chalk.green(` ✓ ${name} MCP configured via OAuth`));
|
|
246
|
-
} catch {
|
|
247
|
-
const instructions = generateSetupInstructions(name, mcpEntry);
|
|
248
|
-
console.log(chalk.yellow(` Setup cancelled. Run later: ${instructions.cliCommand}`));
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
console.log('');
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
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`));
|
|
257
171
|
console.log(chalk.gray(` Usage: ${mcpEntry.usage}`));
|
|
258
172
|
console.log('');
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
message: 'Enter credentials now?',
|
|
264
|
-
default: true
|
|
265
|
-
}]);
|
|
266
|
-
|
|
267
|
-
if (enterCredentials) {
|
|
268
|
-
const credentialValues = {};
|
|
269
|
-
for (const cred of credentials) {
|
|
270
|
-
const { value } = await inquirer.prompt([{
|
|
271
|
-
type: cred.secret ? 'password' : 'input',
|
|
272
|
-
name: 'value',
|
|
273
|
-
message: `${cred.name}:`,
|
|
274
|
-
mask: cred.secret ? '*' : undefined
|
|
275
|
-
}]);
|
|
276
|
-
credentialValues[cred.envVar] = value;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const spinner = ora(`Configuring ${name}...`).start();
|
|
280
|
-
await installMcpWithCredentials(targetPath, name, mcpEntry, credentialValues);
|
|
281
|
-
spinner.succeed(`${name} MCP configured`);
|
|
282
|
-
} else {
|
|
283
|
-
const instructions = generateSetupInstructions(name, mcpEntry);
|
|
284
|
-
console.log(chalk.gray('\n Add to .mcp.json → mcpServers:'));
|
|
285
|
-
console.log(chalk.gray(' ' + '─'.repeat(55)));
|
|
286
|
-
for (const line of instructions.configSnippet.split('\n')) {
|
|
287
|
-
console.log(chalk.gray(` ${line}`));
|
|
288
|
-
}
|
|
289
|
-
console.log(chalk.gray(' ' + '─'.repeat(55)));
|
|
290
|
-
|
|
291
|
-
for (const cred of instructions.credentialUrls) {
|
|
292
|
-
console.log(chalk.gray(` Get ${cred.name}: ${cred.helpUrl}`));
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
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
|
+
});
|
|
296
177
|
console.log('');
|
|
297
178
|
}
|
|
298
179
|
|
|
@@ -340,54 +221,7 @@ async function interactiveWizard(targetPath, stack, existingMcps, integrations,
|
|
|
340
221
|
|
|
341
222
|
for (const name of manualNames) {
|
|
342
223
|
const entry = orchestration.needsManualSetup[name];
|
|
343
|
-
|
|
344
|
-
for (const warning of entry.install.warnings || []) {
|
|
345
|
-
console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
349
|
-
const { setupNow } = await inquirer.prompt([{
|
|
350
|
-
type: 'confirm',
|
|
351
|
-
name: 'setupNow',
|
|
352
|
-
message: `Set up ${capitalizedName}? (${entry.usage})`,
|
|
353
|
-
default: false
|
|
354
|
-
}]);
|
|
355
|
-
|
|
356
|
-
if (setupNow) {
|
|
357
|
-
if (isRemoteMcp(entry.install.config)) {
|
|
358
|
-
console.log(chalk.cyan(` Launching ${capitalizedName} OAuth...`));
|
|
359
|
-
try {
|
|
360
|
-
const { execSync } = await import('child_process');
|
|
361
|
-
execSync(`claude mcp add --transport http ${name} ${entry.install.config.url}`, {
|
|
362
|
-
stdio: 'inherit',
|
|
363
|
-
timeout: 120000
|
|
364
|
-
});
|
|
365
|
-
console.log(chalk.green(` ✓ ${capitalizedName} configured via OAuth`));
|
|
366
|
-
} catch {
|
|
367
|
-
const instructions = generateSetupInstructions(name, entry);
|
|
368
|
-
console.log(chalk.yellow(` Setup cancelled. Run later: ${instructions.cliCommand}`));
|
|
369
|
-
}
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const credentialValues = {};
|
|
374
|
-
for (const cred of entry.install.credentials) {
|
|
375
|
-
const { value } = await inquirer.prompt([{
|
|
376
|
-
type: cred.secret ? 'password' : 'input',
|
|
377
|
-
name: 'value',
|
|
378
|
-
message: `${cred.name}:`,
|
|
379
|
-
mask: cred.secret ? '*' : undefined
|
|
380
|
-
}]);
|
|
381
|
-
credentialValues[cred.envVar] = value;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const spinner = ora(`Configuring ${name}...`).start();
|
|
385
|
-
await installMcpWithCredentials(targetPath, name, entry, credentialValues);
|
|
386
|
-
spinner.succeed(`${capitalizedName} configured`);
|
|
387
|
-
} else {
|
|
388
|
-
const instructions = generateSetupInstructions(name, entry);
|
|
389
|
-
console.log(chalk.gray(` Run later: ${instructions.cliCommand}`));
|
|
390
|
-
}
|
|
224
|
+
await setupManualMcp(targetPath, name, entry, { message: `Set up ${name}? (${entry.usage})` });
|
|
391
225
|
}
|
|
392
226
|
}
|
|
393
227
|
|