opencastle 0.38.2 → 1.1.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 +89 -4
- package/bin/cli.mjs +20 -3
- package/dist/cli/adapters/antigravity.d.ts +1 -1
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.d.ts +8 -4
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.js +13 -7
- package/dist/cli/adapters/claude-code.js.map +1 -1
- package/dist/cli/adapters/codex.d.ts +1 -1
- package/dist/cli/adapters/codex.d.ts.map +1 -1
- package/dist/cli/adapters/cursor.d.ts +1 -1
- package/dist/cli/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/adapters/opencode.d.ts +1 -1
- package/dist/cli/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts +3 -2
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +13 -25
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +8 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +43 -46
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +14 -3
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +63 -75
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/windsurf.d.ts +1 -1
- package/dist/cli/adapters/windsurf.d.ts.map +1 -1
- package/dist/cli/baseline.d.ts +3 -0
- package/dist/cli/baseline.d.ts.map +1 -0
- package/dist/cli/baseline.js +280 -0
- package/dist/cli/baseline.js.map +1 -0
- package/dist/cli/ci.d.ts +18 -0
- package/dist/cli/ci.d.ts.map +1 -0
- package/dist/cli/ci.js +279 -0
- package/dist/cli/ci.js.map +1 -0
- package/dist/cli/command-namespace.d.ts +91 -0
- package/dist/cli/command-namespace.d.ts.map +1 -0
- package/dist/cli/command-namespace.js +218 -0
- package/dist/cli/command-namespace.js.map +1 -0
- package/dist/cli/command-namespace.test.d.ts +2 -0
- package/dist/cli/command-namespace.test.d.ts.map +1 -0
- package/dist/cli/command-namespace.test.js +356 -0
- package/dist/cli/command-namespace.test.js.map +1 -0
- package/dist/cli/copy.d.ts +1 -1
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +3 -2
- package/dist/cli/copy.js.map +1 -1
- package/dist/cli/dispatcher.test.js +2 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +5 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts +3 -3
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +66 -9
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctor.test.js +2 -2
- package/dist/cli/doctor.test.js.map +1 -1
- package/dist/cli/explain.d.ts +3 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +222 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fleet.d.ts +30 -0
- package/dist/cli/fleet.d.ts.map +1 -0
- package/dist/cli/fleet.js +149 -0
- package/dist/cli/fleet.js.map +1 -0
- package/dist/cli/github-report.d.ts +49 -0
- package/dist/cli/github-report.d.ts.map +1 -0
- package/dist/cli/github-report.js +161 -0
- package/dist/cli/github-report.js.map +1 -0
- package/dist/cli/github-report.test.d.ts +2 -0
- package/dist/cli/github-report.test.d.ts.map +1 -0
- package/dist/cli/github-report.test.js +146 -0
- package/dist/cli/github-report.test.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +171 -96
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +35 -29
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +152 -0
- package/dist/cli/layers.d.ts.map +1 -0
- package/dist/cli/layers.js +932 -0
- package/dist/cli/layers.js.map +1 -0
- package/dist/cli/layers.test.d.ts +2 -0
- package/dist/cli/layers.test.d.ts.map +1 -0
- package/dist/cli/layers.test.js +483 -0
- package/dist/cli/layers.test.js.map +1 -0
- package/dist/cli/lock.d.ts +130 -0
- package/dist/cli/lock.d.ts.map +1 -0
- package/dist/cli/lock.js +320 -0
- package/dist/cli/lock.js.map +1 -0
- package/dist/cli/managed-paths.d.ts +18 -1
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +72 -2
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +2 -0
- package/dist/cli/manifest.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts +164 -0
- package/dist/cli/mcp-audit.d.ts.map +1 -0
- package/dist/cli/mcp-audit.js +504 -0
- package/dist/cli/mcp-audit.js.map +1 -0
- package/dist/cli/mcp-audit.test.d.ts +2 -0
- package/dist/cli/mcp-audit.test.d.ts.map +1 -0
- package/dist/cli/mcp-audit.test.js +215 -0
- package/dist/cli/mcp-audit.test.js.map +1 -0
- package/dist/cli/mcp-upgrade.test.d.ts +2 -0
- package/dist/cli/mcp-upgrade.test.d.ts.map +1 -0
- package/dist/cli/mcp-upgrade.test.js +118 -0
- package/dist/cli/mcp-upgrade.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +74 -5
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +340 -32
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/policy.d.ts +58 -0
- package/dist/cli/policy.d.ts.map +1 -0
- package/dist/cli/policy.js +194 -0
- package/dist/cli/policy.js.map +1 -0
- package/dist/cli/publish-workflow.test.js +55 -1
- package/dist/cli/publish-workflow.test.js.map +1 -1
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +25 -6
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/review.d.ts +25 -0
- package/dist/cli/review.d.ts.map +1 -0
- package/dist/cli/review.js +437 -0
- package/dist/cli/review.js.map +1 -0
- package/dist/cli/status.d.ts +2 -0
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +25 -4
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/status.test.js +5 -3
- package/dist/cli/status.test.js.map +1 -1
- package/dist/cli/sync-check.d.ts +16 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +241 -17
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +14 -8
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -0
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/team-ci.test.d.ts +2 -0
- package/dist/cli/team-ci.test.d.ts.map +1 -0
- package/dist/cli/team-ci.test.js +169 -0
- package/dist/cli/team-ci.test.js.map +1 -0
- package/dist/cli/team-commands.test.d.ts +2 -0
- package/dist/cli/team-commands.test.d.ts.map +1 -0
- package/dist/cli/team-commands.test.js +233 -0
- package/dist/cli/team-commands.test.js.map +1 -0
- package/dist/cli/team-config.d.ts +88 -0
- package/dist/cli/team-config.d.ts.map +1 -0
- package/dist/cli/team-config.js +261 -0
- package/dist/cli/team-config.js.map +1 -0
- package/dist/cli/team-health.d.ts +49 -0
- package/dist/cli/team-health.d.ts.map +1 -0
- package/dist/cli/team-health.js +205 -0
- package/dist/cli/team-health.js.map +1 -0
- package/dist/cli/team-sources.test.d.ts +2 -0
- package/dist/cli/team-sources.test.d.ts.map +1 -0
- package/dist/cli/team-sources.test.js +542 -0
- package/dist/cli/team-sources.test.js.map +1 -0
- package/dist/cli/types.d.ts +48 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +218 -44
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/version-range.d.ts +24 -0
- package/dist/cli/version-range.d.ts.map +1 -0
- package/dist/cli/version-range.js +157 -0
- package/dist/cli/version-range.js.map +1 -0
- package/dist/cli/website-plugins.test.d.ts +2 -0
- package/dist/cli/website-plugins.test.d.ts.map +1 -0
- package/dist/cli/website-plugins.test.js +34 -0
- package/dist/cli/website-plugins.test.js.map +1 -0
- package/dist/orchestrator/plugins/chrome-devtools/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/chrome-devtools/config.js +11 -1
- package/dist/orchestrator/plugins/chrome-devtools/config.js.map +1 -1
- package/dist/orchestrator/plugins/contentful/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/contentful/config.js +11 -1
- package/dist/orchestrator/plugins/contentful/config.js.map +1 -1
- package/dist/orchestrator/plugins/convex/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/convex/config.js +11 -1
- package/dist/orchestrator/plugins/convex/config.js.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.js +14 -1
- package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
- package/dist/orchestrator/plugins/figma/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/figma/config.js +24 -13
- package/dist/orchestrator/plugins/figma/config.js.map +1 -1
- package/dist/orchestrator/plugins/linear/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/linear/config.js +27 -17
- package/dist/orchestrator/plugins/linear/config.js.map +1 -1
- package/dist/orchestrator/plugins/netlify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/netlify/config.js +23 -9
- package/dist/orchestrator/plugins/netlify/config.js.map +1 -1
- package/dist/orchestrator/plugins/nextjs/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/nextjs/config.js +11 -1
- package/dist/orchestrator/plugins/nextjs/config.js.map +1 -1
- package/dist/orchestrator/plugins/nx/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/nx/config.js +11 -1
- package/dist/orchestrator/plugins/nx/config.js.map +1 -1
- package/dist/orchestrator/plugins/pins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/pins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/pins.test.js +78 -0
- package/dist/orchestrator/plugins/pins.test.js.map +1 -0
- package/dist/orchestrator/plugins/playwright/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/playwright/config.js +11 -1
- package/dist/orchestrator/plugins/playwright/config.js.map +1 -1
- package/dist/orchestrator/plugins/prisma/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/prisma/config.js +17 -2
- package/dist/orchestrator/plugins/prisma/config.js.map +1 -1
- package/dist/orchestrator/plugins/resend/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/resend/config.js +17 -1
- package/dist/orchestrator/plugins/resend/config.js.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.js +13 -1
- package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
- package/dist/orchestrator/plugins/slack/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/slack/config.js +20 -1
- package/dist/orchestrator/plugins/slack/config.js.map +1 -1
- package/dist/orchestrator/plugins/strapi/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/strapi/config.js +11 -1
- package/dist/orchestrator/plugins/strapi/config.js.map +1 -1
- package/dist/orchestrator/plugins/trello/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/trello/config.js +21 -1
- package/dist/orchestrator/plugins/trello/config.js.map +1 -1
- package/dist/orchestrator/plugins/types.d.ts +22 -0
- package/dist/orchestrator/plugins/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/cli/adapters/claude-code.ts +13 -7
- package/src/cli/adapters/rules-dir-base.ts +23 -44
- package/src/cli/adapters/single-file-base.ts +65 -50
- package/src/cli/adapters/vscode.ts +75 -77
- package/src/cli/baseline.ts +289 -0
- package/src/cli/ci.ts +289 -0
- package/src/cli/command-namespace.test.ts +417 -0
- package/src/cli/command-namespace.ts +222 -0
- package/src/cli/copy.ts +6 -2
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +5 -0
- package/src/cli/doctor.test.ts +2 -2
- package/src/cli/doctor.ts +92 -6
- package/src/cli/explain.ts +222 -0
- package/src/cli/fleet.ts +176 -0
- package/src/cli/github-report.test.ts +158 -0
- package/src/cli/github-report.ts +179 -0
- package/src/cli/init.test.ts +36 -31
- package/src/cli/init.ts +174 -96
- package/src/cli/layers.test.ts +525 -0
- package/src/cli/layers.ts +1089 -0
- package/src/cli/lock.ts +395 -0
- package/src/cli/managed-paths.ts +73 -3
- package/src/cli/manifest.ts +2 -0
- package/src/cli/mcp-audit.test.ts +259 -0
- package/src/cli/mcp-audit.ts +619 -0
- package/src/cli/mcp-upgrade.test.ts +135 -0
- package/src/cli/mcp.ts +373 -34
- package/src/cli/policy.ts +207 -0
- package/src/cli/publish-workflow.test.ts +60 -1
- package/src/cli/remove.ts +28 -6
- package/src/cli/review.ts +457 -0
- package/src/cli/status.test.ts +5 -3
- package/src/cli/status.ts +29 -4
- package/src/cli/sync-check.test.ts +16 -8
- package/src/cli/sync-check.ts +264 -17
- package/src/cli/sync.ts +2 -0
- package/src/cli/team-ci.test.ts +195 -0
- package/src/cli/team-commands.test.ts +253 -0
- package/src/cli/team-config.ts +289 -0
- package/src/cli/team-health.ts +234 -0
- package/src/cli/team-sources.test.ts +578 -0
- package/src/cli/types.ts +51 -1
- package/src/cli/update.ts +229 -44
- package/src/cli/version-range.ts +150 -0
- package/src/cli/website-plugins.test.ts +41 -0
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/plugins/chrome-devtools/config.ts +11 -1
- package/src/orchestrator/plugins/contentful/config.ts +11 -1
- package/src/orchestrator/plugins/convex/config.ts +11 -1
- package/src/orchestrator/plugins/coolify/config.ts +14 -1
- package/src/orchestrator/plugins/figma/SKILL.md +18 -14
- package/src/orchestrator/plugins/figma/config.ts +24 -13
- package/src/orchestrator/plugins/linear/SKILL.md +6 -14
- package/src/orchestrator/plugins/linear/config.ts +27 -17
- package/src/orchestrator/plugins/netlify/config.ts +23 -9
- package/src/orchestrator/plugins/nextjs/config.ts +11 -1
- package/src/orchestrator/plugins/nx/config.ts +11 -1
- package/src/orchestrator/plugins/pins.test.ts +80 -0
- package/src/orchestrator/plugins/playwright/config.ts +11 -1
- package/src/orchestrator/plugins/prisma/config.ts +17 -2
- package/src/orchestrator/plugins/resend/config.ts +17 -1
- package/src/orchestrator/plugins/sentry/config.ts +13 -1
- package/src/orchestrator/plugins/slack/config.ts +20 -1
- package/src/orchestrator/plugins/strapi/config.ts +11 -1
- package/src/orchestrator/plugins/trello/config.ts +21 -1
- package/src/orchestrator/plugins/types.ts +24 -0
- package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -4
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
2
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync, realpathSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { packageLaunch, isPinned, auditMcpConfig, checkMcpSupplyChain, unwrapShell } from './mcp-audit.js'
|
|
6
|
+
|
|
7
|
+
describe('packageLaunch', () => {
|
|
8
|
+
it('reads the package npx runs, past its own flags', () => {
|
|
9
|
+
expect(packageLaunch('npx', ['-y', '@playwright/mcp@0.0.83'])).toMatchObject({
|
|
10
|
+
name: '@playwright/mcp',
|
|
11
|
+
version: '0.0.83',
|
|
12
|
+
localOnly: false,
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('separates a scope from a version', () => {
|
|
17
|
+
expect(packageLaunch('npx', ['@sentry/mcp-server'])).toMatchObject({ name: '@sentry/mcp-server', version: null })
|
|
18
|
+
expect(packageLaunch('npx', ['-y', 'convex@latest', 'mcp', 'start'])).toMatchObject({
|
|
19
|
+
name: 'convex',
|
|
20
|
+
version: 'latest',
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('treats npx --no as the project’s own dependency', () => {
|
|
25
|
+
const launch = packageLaunch('npx', ['--no', 'prisma', 'mcp'])!
|
|
26
|
+
expect(launch.localOnly).toBe(true)
|
|
27
|
+
expect(isPinned(launch)).toBe(true)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('follows -p and --package', () => {
|
|
31
|
+
expect(packageLaunch('npx', ['-y', '-p', 'foo@1.2.3', 'foo-mcp'])!.spec).toBe('foo@1.2.3')
|
|
32
|
+
expect(packageLaunch('npx', ['--package=bar@2.0.0', 'bar'])!.spec).toBe('bar@2.0.0')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('reads pnpm dlx and bunx, and a Windows shim', () => {
|
|
36
|
+
expect(packageLaunch('pnpm', ['dlx', 'foo@1.0.0'])!.name).toBe('foo')
|
|
37
|
+
expect(packageLaunch('bunx', ['foo'])!.version).toBeNull()
|
|
38
|
+
expect(packageLaunch('C:\\tools\\npx.cmd', ['-y', 'foo@1.0.0'])!.name).toBe('foo')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('ignores commands that fetch nothing, and specs that are not registry packages', () => {
|
|
42
|
+
expect(packageLaunch('node', ['server.js'])).toBeNull()
|
|
43
|
+
expect(packageLaunch('pnpm', ['exec', 'foo'])).toBeNull()
|
|
44
|
+
expect(packageLaunch('npx', ['./local-server'])).toBeNull()
|
|
45
|
+
expect(packageLaunch('npx', ['github:org/repo'])).toBeNull()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('skips the value of an option it knows, and stops at one it does not', () => {
|
|
49
|
+
expect(packageLaunch('npx', ['-y', '--registry', 'https://r.example.com', 'foo@1.0.0'])!.name).toBe('foo')
|
|
50
|
+
expect(packageLaunch('npx', ['--registry=https://r.example.com', 'foo'])!.version).toBeNull()
|
|
51
|
+
expect(packageLaunch('npx', ['--weird', 'x', 'foo'])).toBeNull()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('reads only the runner’s flags — what follows the package is the server’s', () => {
|
|
55
|
+
// `--no` after the package is an argument to the server, not to npx.
|
|
56
|
+
expect(packageLaunch('npx', ['-y', 'foo@latest', '--no'])!.localOnly).toBe(false)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('sees through the cmd /c wrapper Claude Code documents for Windows', () => {
|
|
60
|
+
expect(unwrapShell('cmd', ['/c', 'npx', '-y', 'foo'])).toEqual({ command: 'npx', args: ['-y', 'foo'] })
|
|
61
|
+
expect(packageLaunch('cmd', ['/c', 'npx', '-y', 'foo@latest'])).toMatchObject({ name: 'foo', version: 'latest' })
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('reads uvx, including --from and ==', () => {
|
|
65
|
+
expect(packageLaunch('uvx', ['mcp-server-fetch'])).toMatchObject({ name: 'mcp-server-fetch', version: null })
|
|
66
|
+
expect(packageLaunch('uvx', ['mcp-server-fetch==2025.4.7'])).toMatchObject({ version: '2025.4.7' })
|
|
67
|
+
expect(packageLaunch('uvx', ['--from', 'pkg@1.2.3', 'pkg-mcp'])).toMatchObject({ name: 'pkg', version: '1.2.3' })
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('reads npm exec and pipx run', () => {
|
|
71
|
+
expect(packageLaunch('npm', ['exec', '--yes', 'foo@latest'])).toMatchObject({ name: 'foo', version: 'latest' })
|
|
72
|
+
expect(packageLaunch('pipx', ['run', 'pkg==1.2.3'])).toMatchObject({ name: 'pkg', version: '1.2.3' })
|
|
73
|
+
expect(packageLaunch('pipx', ['run', '--spec', 'pkg==1.2.3', 'pkg-mcp'])).toMatchObject({ version: '1.2.3' })
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('names no package for a shell string', () => {
|
|
77
|
+
expect(packageLaunch('npx', ['-c', 'echo hi'])).toBeNull()
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('isPinned', () => {
|
|
82
|
+
const pinned = (spec: string) => isPinned(packageLaunch('npx', ['-y', spec])!)
|
|
83
|
+
it('accepts an exact version, including a prerelease', () => {
|
|
84
|
+
expect(pinned('foo@1.2.3')).toBe(true)
|
|
85
|
+
expect(pinned('@a/b@1.0.0-rc.1')).toBe(true)
|
|
86
|
+
})
|
|
87
|
+
it('rejects a tag, a range, or nothing', () => {
|
|
88
|
+
expect(pinned('foo@latest')).toBe(false)
|
|
89
|
+
expect(pinned('foo@^1.2.3')).toBe(false)
|
|
90
|
+
expect(pinned('foo@1.x')).toBe(false)
|
|
91
|
+
expect(pinned('foo')).toBe(false)
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe('auditMcpConfig', () => {
|
|
96
|
+
it('reads the VS Code dialect', () => {
|
|
97
|
+
const { findings, outdated } = auditMcpConfig(
|
|
98
|
+
{ servers: { Playwright: { type: 'stdio', command: 'npx', args: ['-y', '@playwright/mcp@latest'] } } },
|
|
99
|
+
'vscode',
|
|
100
|
+
)
|
|
101
|
+
expect(findings).toEqual([
|
|
102
|
+
{
|
|
103
|
+
server: 'Playwright',
|
|
104
|
+
problem: 'unpinned',
|
|
105
|
+
subject: '@playwright/mcp@latest',
|
|
106
|
+
pkg: '@playwright/mcp',
|
|
107
|
+
sync: 'replaces',
|
|
108
|
+
plugin: 'playwright',
|
|
109
|
+
},
|
|
110
|
+
])
|
|
111
|
+
expect(outdated).toEqual(['Playwright'])
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('reads the OpenCode dialect, where command is an array', () => {
|
|
115
|
+
const { findings } = auditMcpConfig({ mcp: { Mine: { type: 'local', command: ['npx', '-y', 'thing'] } } }, 'opencode')
|
|
116
|
+
expect(findings).toMatchObject([{ server: 'Mine', problem: 'unpinned', sync: 'keeps' }])
|
|
117
|
+
expect(findings[0].plugin).toBeUndefined()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('names a package that does not exist on npm', () => {
|
|
121
|
+
const { findings } = auditMcpConfig(
|
|
122
|
+
{ mcpServers: { Netlify: { command: 'npx', args: ['-y', 'netlify-mcp@latest'] } } },
|
|
123
|
+
'cursor',
|
|
124
|
+
)
|
|
125
|
+
expect(findings).toMatchObject([{ server: 'Netlify', problem: 'nonexistent' }])
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('flags a remote server Claude Code would read as stdio, and only there', () => {
|
|
129
|
+
const config = { mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } }
|
|
130
|
+
expect(auditMcpConfig(config, 'claude-code').findings).toMatchObject([{ server: 'Supabase', problem: 'untyped-remote' }])
|
|
131
|
+
expect(auditMcpConfig(config, 'cursor').findings).toEqual([])
|
|
132
|
+
expect(auditMcpConfig({ mcpServers: { Supabase: { type: 'http', url: 'https://x' } } }, 'claude-code').findings).toEqual([])
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('passes pinned, project-local, remote and local servers, and counts them', () => {
|
|
136
|
+
const config = {
|
|
137
|
+
mcpServers: {
|
|
138
|
+
Playwright: { command: 'npx', args: ['-y', '@playwright/mcp@0.0.83'] },
|
|
139
|
+
Prisma: { command: 'npx', args: ['--no', 'prisma', 'mcp'] },
|
|
140
|
+
Mine: { command: 'node', args: ['tools/mcp.js'] },
|
|
141
|
+
Remote: { type: 'http', url: 'https://mcp.example.com' },
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
const audit = auditMcpConfig(config, 'claude-code')
|
|
145
|
+
expect(audit.findings).toEqual([])
|
|
146
|
+
expect(audit.passed).toBe(4)
|
|
147
|
+
expect(audit.unaudited).toEqual([])
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('says what it could not read instead of passing it', () => {
|
|
151
|
+
const audit = auditMcpConfig(
|
|
152
|
+
{
|
|
153
|
+
mcpServers: {
|
|
154
|
+
Box: { command: 'docker', args: ['run', '-i', 'mcp/fetch:latest'] },
|
|
155
|
+
Odd: { command: 'npx', args: ['--weird', 'x', 'foo'] },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
'cursor',
|
|
159
|
+
)
|
|
160
|
+
expect(audit.passed).toBe(0)
|
|
161
|
+
expect(audit.unaudited.map((u) => u.server)).toEqual(['Box', 'Odd'])
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('passes a container image pinned by digest, and only that', () => {
|
|
165
|
+
const digest = 'mcp/fetch@sha256:' + 'a'.repeat(64)
|
|
166
|
+
expect(auditMcpConfig({ mcpServers: { Box: { command: 'docker', args: ['run', '-i', digest] } } }, 'cursor').passed).toBe(1)
|
|
167
|
+
expect(auditMcpConfig({ mcpServers: { Box: { command: 'docker', args: ['run', '-i', 'mcp/fetch:1.2'] } } }, 'cursor').unaudited).toHaveLength(1)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('knows sync removes a plugin server the stack does not include', () => {
|
|
171
|
+
const { findings } = auditMcpConfig(
|
|
172
|
+
{ mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } },
|
|
173
|
+
'claude-code',
|
|
174
|
+
new Set(),
|
|
175
|
+
)
|
|
176
|
+
expect(findings).toMatchObject([{ server: 'Supabase', sync: 'removes', plugin: 'supabase' }])
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
describe('checkMcpSupplyChain', () => {
|
|
181
|
+
let root: string
|
|
182
|
+
beforeEach(() => {
|
|
183
|
+
root = realpathSync(mkdtempSync(join(tmpdir(), 'mcp-audit-')))
|
|
184
|
+
})
|
|
185
|
+
afterEach(() => {
|
|
186
|
+
rmSync(root, { recursive: true, force: true })
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
const write = (rel: string, value: unknown) => {
|
|
190
|
+
mkdirSync(join(root, rel, '..'), { recursive: true })
|
|
191
|
+
writeFileSync(join(root, rel), JSON.stringify(value))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
it('passes with no config at all', () => {
|
|
195
|
+
expect(checkMcpSupplyChain(root, 'claude-code')).toMatchObject({ ok: true })
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('leaves an unparseable config to the check that owns it', () => {
|
|
199
|
+
writeFileSync(join(root, '.mcp.json'), '{ nope')
|
|
200
|
+
const r = checkMcpSupplyChain(root, 'claude-code')
|
|
201
|
+
expect(r.ok).toBe(true)
|
|
202
|
+
expect(r.warning).toBeUndefined()
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('warns on an unpinned server and points sync at the ones it owns', () => {
|
|
206
|
+
write('.cursor/mcp.json', { mcpServers: { Playwright: { command: 'npx', args: ['-y', '@playwright/mcp@latest'] } } })
|
|
207
|
+
const r = checkMcpSupplyChain(root, 'cursor')
|
|
208
|
+
expect(r).toMatchObject({ ok: true, warning: true })
|
|
209
|
+
expect(r.fix).toMatch(/^opencastle sync/)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('does not send the user to sync for a server sync will not touch', () => {
|
|
213
|
+
write('.cursor/mcp.json', { mcpServers: { Mine: { command: 'npx', args: ['-y', 'my-mcp'] } } })
|
|
214
|
+
const r = checkMcpSupplyChain(root, 'cursor')
|
|
215
|
+
expect(r.fix).toMatch(/^fix Mine by hand/)
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it('does not say sync fixes a server that sync will delete', () => {
|
|
219
|
+
write('.mcp.json', { mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } })
|
|
220
|
+
const r = checkMcpSupplyChain(root, 'claude-code', new Set())
|
|
221
|
+
expect(r.fix).toContain('opencastle sync removes Supabase')
|
|
222
|
+
expect(r.fix).toContain('opencastle add supabase')
|
|
223
|
+
expect(r.fix).not.toContain('fixes')
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
it('warns, rather than passing, when it cannot read what a server launches', () => {
|
|
227
|
+
write('.cursor/mcp.json', { mcpServers: { Box: { command: 'docker', args: ['run', '-i', 'mcp/fetch:latest'] } } })
|
|
228
|
+
const r = checkMcpSupplyChain(root, 'cursor')
|
|
229
|
+
expect(r).toMatchObject({ ok: true, warning: true })
|
|
230
|
+
expect(r.detail).toContain('Box (container image without a digest)')
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
it('tells an edited plugin entry apart from one sync still owns', () => {
|
|
234
|
+
write('.cursor/mcp.json', {
|
|
235
|
+
mcpServers: {
|
|
236
|
+
Playwright: { command: 'npx', args: ['-y', '@playwright/mcp@latest', '--headless'] },
|
|
237
|
+
'chrome-devtools': { command: 'npx', args: ['-y', 'chrome-devtools-mcp@latest'] },
|
|
238
|
+
},
|
|
239
|
+
})
|
|
240
|
+
const r = checkMcpSupplyChain(root, 'cursor')
|
|
241
|
+
expect(r.fix).toContain('opencastle sync fixes chrome-devtools')
|
|
242
|
+
expect(r.fix).toContain('Playwright changed since OpenCastle wrote them')
|
|
243
|
+
expect(r.fix).toContain('opencastle sync --force')
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
it('fails on a server that cannot load', () => {
|
|
247
|
+
write('.mcp.json', { mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } })
|
|
248
|
+
const r = checkMcpSupplyChain(root, 'claude-code')
|
|
249
|
+
expect(r.ok).toBe(false)
|
|
250
|
+
expect(r.detail).toContain('Supabase')
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('fails on a package that is not on npm, and says why', () => {
|
|
254
|
+
write('.vscode/mcp.json', { servers: { Figma: { type: 'stdio', command: 'npx', args: ['-y', '@anthropic/figma-mcp@latest'] } } })
|
|
255
|
+
const r = checkMcpSupplyChain(root, 'vscode')
|
|
256
|
+
expect(r.ok).toBe(false)
|
|
257
|
+
expect(r.detail).toContain('never published')
|
|
258
|
+
})
|
|
259
|
+
})
|