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,578 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team sources through the compiler: every target gets the team's content,
|
|
3
|
+
* every target gets the team's MCP servers in its own dialect, and the check a
|
|
4
|
+
* team runs in CI sees what `sync` would change.
|
|
5
|
+
*/
|
|
6
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, readdirSync, symlinkSync } from 'node:fs'
|
|
7
|
+
import { tmpdir } from 'node:os'
|
|
8
|
+
import { join, resolve, dirname } from 'node:path'
|
|
9
|
+
import { execFileSync } from 'node:child_process'
|
|
10
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
11
|
+
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
12
|
+
import { resolveSources, materialize, type CompileSource } from './layers.js'
|
|
13
|
+
import { rebuildMcpConfig, getMcpConfigRelPath, envRef, upgradeGeneratedServers } from './mcp.js'
|
|
14
|
+
import { buildCheckReport } from './sync-check.js'
|
|
15
|
+
import { writeManifest } from './manifest.js'
|
|
16
|
+
import { recordLockFor, type Lock } from './lock.js'
|
|
17
|
+
import { diffLocks, reviewMarkdown } from './review.js'
|
|
18
|
+
import { auditMcpConfig, describeFinding } from './mcp-audit.js'
|
|
19
|
+
import { parseLock, serializeLock, buildLock } from './lock.js'
|
|
20
|
+
const buildLockFor = (src: CompileSource) => buildLock(src, { ides: ['claude-code'], stack: { ides: ['claude-code'], techTools: [], teamTools: [] } })
|
|
21
|
+
import { emptyPolicy } from './policy.js'
|
|
22
|
+
import { buildFleet } from './fleet.js'
|
|
23
|
+
import { planCi } from './ci.js'
|
|
24
|
+
import type { IdeChoice, StackConfig, Manifest } from './types.js'
|
|
25
|
+
|
|
26
|
+
const pkgRoot = resolve(import.meta.dirname, '..', '..')
|
|
27
|
+
const ALL: IdeChoice[] = ['vscode', 'cursor', 'windsurf', 'claude-code', 'opencode', 'codex', 'antigravity']
|
|
28
|
+
|
|
29
|
+
function write(root: string, files: Record<string, string>): void {
|
|
30
|
+
for (const [rel, text] of Object.entries(files)) {
|
|
31
|
+
const abs = join(root, rel)
|
|
32
|
+
mkdirSync(dirname(abs), { recursive: true })
|
|
33
|
+
writeFileSync(abs, text)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const TEAM = {
|
|
38
|
+
'.opencastle/skills/deploy-runbook/SKILL.md': '---\nname: deploy-runbook\ndescription: "How we deploy. Use when releasing."\n---\n\n# Deploy\n\nRELEASE-MARKER\n',
|
|
39
|
+
'.opencastle/instructions/house-style.md': '# House style\n\nHOUSE-MARKER\n',
|
|
40
|
+
'.opencastle/agents/release-captain.agent.md': '---\nname: Release captain\ndescription: "Cuts releases"\n---\n\nCAPTAIN-MARKER\n',
|
|
41
|
+
'.opencastle/config.json': JSON.stringify({
|
|
42
|
+
mcpServers: {
|
|
43
|
+
'acme-db': { command: 'npx', args: ['-y', '@acme/db-mcp@2.1.0'], env: { DB_URL: '${DB_URL}' } },
|
|
44
|
+
'acme-docs': { url: 'https://docs.acme.dev/mcp', headers: { Authorization: 'Bearer ${DOCS_TOKEN}' } },
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Every file under a directory, with its text. */
|
|
50
|
+
function textsUnder(root: string, skip = ['.opencastle', 'node_modules']): string {
|
|
51
|
+
const out: string[] = []
|
|
52
|
+
const walk = (dir: string): void => {
|
|
53
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
54
|
+
if (skip.includes(e.name)) continue
|
|
55
|
+
const abs = join(dir, e.name)
|
|
56
|
+
if (e.isDirectory()) walk(abs)
|
|
57
|
+
else out.push(readFileSync(abs, 'utf8'))
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
walk(root)
|
|
61
|
+
return out.join('\n')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('every target compiles the team content', () => {
|
|
65
|
+
let project: string
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
project = mkdtempSync(join(tmpdir(), 'team-targets-'))
|
|
68
|
+
write(project, TEAM)
|
|
69
|
+
})
|
|
70
|
+
afterEach(() => {
|
|
71
|
+
rmSync(project, { recursive: true, force: true })
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
for (const ide of ALL) {
|
|
75
|
+
it(`${ide}: the team's skill, instruction and agent reach the generated output`, async () => {
|
|
76
|
+
const stack: StackConfig = { ides: [ide], techTools: [], teamTools: [] }
|
|
77
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
|
|
78
|
+
try {
|
|
79
|
+
const adapter = await IDE_ADAPTERS[ide]()
|
|
80
|
+
await adapter.install(pkgRoot, project, stack, undefined, src)
|
|
81
|
+
} finally {
|
|
82
|
+
src.dispose()
|
|
83
|
+
}
|
|
84
|
+
const all = textsUnder(project)
|
|
85
|
+
expect(all).toContain('RELEASE-MARKER')
|
|
86
|
+
expect(all).toContain('HOUSE-MARKER')
|
|
87
|
+
expect(all).toContain('CAPTAIN-MARKER')
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
describe("the team's MCP servers, in each target's dialect", () => {
|
|
93
|
+
let project: string
|
|
94
|
+
let src: CompileSource
|
|
95
|
+
const stack: StackConfig = { ides: ALL, techTools: [], teamTools: [] }
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
project = mkdtempSync(join(tmpdir(), 'team-mcp-'))
|
|
98
|
+
write(project, TEAM)
|
|
99
|
+
src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
|
|
100
|
+
})
|
|
101
|
+
afterEach(() => {
|
|
102
|
+
src.dispose()
|
|
103
|
+
rmSync(project, { recursive: true, force: true })
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const read = (ide: IdeChoice): Record<string, Record<string, unknown>> => {
|
|
107
|
+
const parsed = JSON.parse(readFileSync(join(project, getMcpConfigRelPath(ide)), 'utf8'))
|
|
108
|
+
return parsed.mcp ?? parsed.servers ?? parsed.mcpServers
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
it('spells variables the way each assistant expands them', async () => {
|
|
112
|
+
for (const ide of ['claude-code', 'cursor', 'opencode'] as IdeChoice[]) await rebuildMcpConfig(project, ide, stack, undefined, src.mcp)
|
|
113
|
+
expect(read('claude-code')['acme-db']).toEqual({ command: 'npx', args: ['-y', '@acme/db-mcp@2.1.0'], env: { DB_URL: '${DB_URL}' } })
|
|
114
|
+
expect(read('claude-code')['acme-docs']).toEqual({ type: 'http', url: 'https://docs.acme.dev/mcp', headers: { Authorization: 'Bearer ${DOCS_TOKEN}' } })
|
|
115
|
+
expect(read('cursor')['acme-db'].env).toEqual({ DB_URL: '${env:DB_URL}' })
|
|
116
|
+
expect(read('cursor')['acme-docs'].headers).toEqual({ Authorization: 'Bearer ${env:DOCS_TOKEN}' })
|
|
117
|
+
expect(read('opencode')['acme-db']).toEqual({ type: 'local', command: ['npx', '-y', '@acme/db-mcp@2.1.0'], environment: { DB_URL: '{env:DB_URL}' } })
|
|
118
|
+
expect(read('opencode')['acme-docs']).toMatchObject({ type: 'remote', headers: { Authorization: 'Bearer {env:DOCS_TOKEN}' } })
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('gives VS Code an envFile for forwarded variables and a password input for a header', async () => {
|
|
122
|
+
await rebuildMcpConfig(project, 'vscode', stack, undefined, src.mcp)
|
|
123
|
+
const config = JSON.parse(readFileSync(join(project, '.vscode', 'mcp.json'), 'utf8'))
|
|
124
|
+
expect(config.servers['acme-db']).toEqual({ type: 'stdio', command: 'npx', args: ['-y', '@acme/db-mcp@2.1.0'], envFile: '${workspaceFolder}/.env' })
|
|
125
|
+
expect(config.servers['acme-docs'].headers).toEqual({ Authorization: 'Bearer ${input:DOCS_TOKEN}' })
|
|
126
|
+
expect(config.inputs).toContainEqual({ id: 'DOCS_TOKEN', type: 'promptString', description: 'DOCS_TOKEN for the acme-docs MCP server', password: true })
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('rewrites an edited team server, keeps a hand-added one, and removes a retired one', async () => {
|
|
130
|
+
const rel = getMcpConfigRelPath('claude-code')
|
|
131
|
+
write(project, {
|
|
132
|
+
[rel]: JSON.stringify({
|
|
133
|
+
mcpServers: {
|
|
134
|
+
'acme-db': { command: 'npx', args: ['-y', '@acme/db-mcp@1.0.0'] },
|
|
135
|
+
'acme-old': { url: 'https://old.acme.dev/mcp' },
|
|
136
|
+
mine: { command: 'node', args: ['tools/mcp.js'] },
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
})
|
|
140
|
+
const retiring = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot, ['acme-old'])
|
|
141
|
+
try {
|
|
142
|
+
const outcome = await rebuildMcpConfig(project, 'claude-code', stack, undefined, retiring.mcp)
|
|
143
|
+
expect(outcome.teamWritten.sort()).toEqual(['acme-db', 'acme-docs'])
|
|
144
|
+
expect(outcome.teamRemoved).toEqual(['acme-old'])
|
|
145
|
+
} finally {
|
|
146
|
+
retiring.dispose()
|
|
147
|
+
}
|
|
148
|
+
const servers = read('claude-code')
|
|
149
|
+
expect(Object.keys(servers).sort()).toEqual(['acme-db', 'acme-docs', 'mine'])
|
|
150
|
+
expect(servers['acme-db'].args).toEqual(['-y', '@acme/db-mcp@2.1.0'])
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
describe('integration servers get per-target variables too', () => {
|
|
155
|
+
it('writes ${env:NAME} for Cursor and {env:NAME} for OpenCode', () => {
|
|
156
|
+
expect(envRef('cursor', 'X')).toBe('${env:X}')
|
|
157
|
+
expect(envRef('windsurf', 'X')).toBe('${env:X}')
|
|
158
|
+
expect(envRef('opencode', 'X')).toBe('{env:X}')
|
|
159
|
+
expect(envRef('claude-code', 'X')).toBe('${X}')
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('moves an entry an earlier release wrote with ${NAME} for Cursor to the spelling Cursor expands', () => {
|
|
163
|
+
const servers: Record<string, unknown> = {
|
|
164
|
+
Sentry: { command: 'npx', args: ['@sentry/mcp-server@0.42.0'], env: { SENTRY_ACCESS_TOKEN: '${SENTRY_ACCESS_TOKEN}' } },
|
|
165
|
+
}
|
|
166
|
+
expect(upgradeGeneratedServers(servers, 'cursor', new Set(['Sentry']))).toEqual(['Sentry'])
|
|
167
|
+
expect((servers.Sentry as { env: Record<string, string> }).env).toEqual({ SENTRY_ACCESS_TOKEN: '${env:SENTRY_ACCESS_TOKEN}' })
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
describe('sync --check sees what the team sources say', () => {
|
|
172
|
+
let project: string
|
|
173
|
+
const manifest: Manifest = {
|
|
174
|
+
version: '0.0.1',
|
|
175
|
+
ide: 'claude-code',
|
|
176
|
+
ides: ['claude-code'],
|
|
177
|
+
installedAt: '2026-01-01T00:00:00.000Z',
|
|
178
|
+
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
179
|
+
stack: { ides: ['claude-code'], techTools: [], teamTools: [] },
|
|
180
|
+
}
|
|
181
|
+
async function compile(): Promise<void> {
|
|
182
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack: manifest.stack! }), pkgRoot)
|
|
183
|
+
try {
|
|
184
|
+
const adapter = await IDE_ADAPTERS['claude-code']()
|
|
185
|
+
await adapter.install(pkgRoot, project, manifest.stack, undefined, src)
|
|
186
|
+
await rebuildMcpConfig(project, 'claude-code', manifest.stack!, undefined, src.mcp)
|
|
187
|
+
} finally {
|
|
188
|
+
src.dispose()
|
|
189
|
+
}
|
|
190
|
+
await writeManifest(project, manifest)
|
|
191
|
+
await recordLockFor(pkgRoot, project, manifest)
|
|
192
|
+
}
|
|
193
|
+
beforeEach(() => {
|
|
194
|
+
project = mkdtempSync(join(tmpdir(), 'team-check-'))
|
|
195
|
+
write(project, TEAM)
|
|
196
|
+
})
|
|
197
|
+
afterEach(() => {
|
|
198
|
+
rmSync(project, { recursive: true, force: true })
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('is clean right after a compile', async () => {
|
|
202
|
+
await compile()
|
|
203
|
+
expect((await buildCheckReport(pkgRoot, project)).drift).toEqual([])
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
it('reports a changed team skill as drift in the output and in the lock', async () => {
|
|
207
|
+
await compile()
|
|
208
|
+
write(project, { '.opencastle/skills/deploy-runbook/SKILL.md': TEAM['.opencastle/skills/deploy-runbook/SKILL.md'] + '\nMore.\n' })
|
|
209
|
+
const drift = (await buildCheckReport(pkgRoot, project)).drift
|
|
210
|
+
expect(drift.some((d) => d.path === '.opencastle/lock.json' && d.kind === 'changed')).toBe(true)
|
|
211
|
+
expect(drift.some((d) => d.path.includes('deploy-runbook') && d.kind === 'changed')).toBe(true)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
it('reports a missing lock', async () => {
|
|
215
|
+
await compile()
|
|
216
|
+
rmSync(join(project, '.opencastle', 'lock.json'))
|
|
217
|
+
expect((await buildCheckReport(pkgRoot, project)).drift).toEqual([
|
|
218
|
+
expect.objectContaining({ path: '.opencastle/lock.json', kind: 'missing' }),
|
|
219
|
+
])
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('reports a team problem once, as the team problem, instead of comparing', async () => {
|
|
223
|
+
await compile()
|
|
224
|
+
write(project, { '.opencastle/config.json': '{ "extends": ["@acme/not-installed"] }' })
|
|
225
|
+
const report = await buildCheckReport(pkgRoot, project)
|
|
226
|
+
expect(report.checked).toBe(0)
|
|
227
|
+
expect(report.drift).toEqual([expect.objectContaining({ origin: 'team', kind: 'unreducible', path: '.opencastle/config.json' })])
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it('fails on a server the policy refuses, even one added by hand', async () => {
|
|
231
|
+
write(project, {
|
|
232
|
+
'.opencastle/config.json': JSON.stringify({
|
|
233
|
+
policy: { mcp: { allow: ['acme-*'] } },
|
|
234
|
+
mcpServers: { 'acme-db': { command: 'npx', args: ['-y', '@acme/db-mcp@2.1.0'] } },
|
|
235
|
+
}),
|
|
236
|
+
})
|
|
237
|
+
await compile()
|
|
238
|
+
const rel = getMcpConfigRelPath('claude-code')
|
|
239
|
+
const config = JSON.parse(readFileSync(join(project, rel), 'utf8'))
|
|
240
|
+
config.mcpServers.rogue = { command: 'npx', args: ['-y', 'rogue-mcp@1.0.0'] }
|
|
241
|
+
writeFileSync(join(project, rel), JSON.stringify(config))
|
|
242
|
+
const drift = (await buildCheckReport(pkgRoot, project)).drift
|
|
243
|
+
expect(drift).toEqual([
|
|
244
|
+
expect.objectContaining({ kind: 'unreducible', origin: 'mcp', detail: expect.stringContaining('rogue: not on the MCP allowlist of project') }),
|
|
245
|
+
])
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('sees an edited team server as something sync rewrites', async () => {
|
|
249
|
+
await compile()
|
|
250
|
+
const rel = getMcpConfigRelPath('claude-code')
|
|
251
|
+
const config = JSON.parse(readFileSync(join(project, rel), 'utf8'))
|
|
252
|
+
config.mcpServers['acme-db'].args = ['-y', '@acme/db-mcp@1.0.0']
|
|
253
|
+
writeFileSync(join(project, rel), JSON.stringify(config))
|
|
254
|
+
const drift = (await buildCheckReport(pkgRoot, project)).drift
|
|
255
|
+
expect(drift).toEqual([expect.objectContaining({ kind: 'outdated', detail: expect.stringContaining('so sync writes: acme-db') })])
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
describe('review: a change in sentences', () => {
|
|
260
|
+
const lock = (over: Partial<Lock> = {}): Lock => ({
|
|
261
|
+
lockfileVersion: 1,
|
|
262
|
+
opencastle: '0.36.0',
|
|
263
|
+
targets: ['claude-code'],
|
|
264
|
+
integrations: [],
|
|
265
|
+
layers: [
|
|
266
|
+
{ id: 'opencastle', kind: 'core', version: '0.36.0' },
|
|
267
|
+
{ id: '@acme/base', kind: 'baseline', version: '1.4.0', integrity: 'sha256-a' },
|
|
268
|
+
],
|
|
269
|
+
content: { 'skills/deploy': { from: 'project', sha: 'aaa' } },
|
|
270
|
+
mcp: { Sentry: { from: 'plugin:sentry', transport: 'stdio', launch: 'npx @sentry/mcp-server@0.42.0' } },
|
|
271
|
+
policy: { allow: { '@acme/base': ['Sentry'] } },
|
|
272
|
+
context: { tokens: 5000, instructions: 2000, index: 3000 },
|
|
273
|
+
...over,
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it('says nothing when nothing an assistant gets has changed', () => {
|
|
277
|
+
expect(diffLocks(lock(), lock())).toEqual([])
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
it('marks a new server, a wider allowlist, a new instruction and a big context jump for review', () => {
|
|
281
|
+
const head = lock({
|
|
282
|
+
layers: [
|
|
283
|
+
{ id: 'opencastle', kind: 'core', version: '0.36.0' },
|
|
284
|
+
{ id: '@acme/base', kind: 'baseline', version: '1.5.0', integrity: 'sha256-b' },
|
|
285
|
+
],
|
|
286
|
+
content: {
|
|
287
|
+
'skills/deploy': { from: 'project', sha: 'aaa' },
|
|
288
|
+
'instructions/api-style': { from: '@acme/base', sha: 'ccc', tokens: 900 },
|
|
289
|
+
},
|
|
290
|
+
mcp: {
|
|
291
|
+
Sentry: { from: 'plugin:sentry', transport: 'stdio', launch: 'npx @sentry/mcp-server@0.43.0' },
|
|
292
|
+
'acme-docs': { from: '@acme/base', transport: 'http', launch: 'https://docs.acme.dev/mcp', env: ['DOCS_TOKEN'] },
|
|
293
|
+
},
|
|
294
|
+
policy: { allow: { '@acme/base': ['Sentry', 'acme-docs'] } },
|
|
295
|
+
context: { tokens: 5900, instructions: 2900, index: 3000 },
|
|
296
|
+
})
|
|
297
|
+
const lines = diffLocks(lock(), head)
|
|
298
|
+
const flagged = lines.filter((l) => l.level === 'review').map((l) => l.text)
|
|
299
|
+
const plain = lines.filter((l) => l.level === 'info').map((l) => l.text)
|
|
300
|
+
expect(plain).toContain('@acme/base 1.4.0 → 1.5.0')
|
|
301
|
+
expect(plain).toContain('MCP server **Sentry**: 0.42.0 → 0.43.0')
|
|
302
|
+
expect(flagged).toContain('New MCP server **acme-docs** from @acme/base — remote, docs.acme.dev; reads DOCS_TOKEN')
|
|
303
|
+
expect(flagged).toContain("@acme/base's MCP allowlist now also allows acme-docs")
|
|
304
|
+
expect(flagged.some((t) => t.startsWith('New always-loaded instruction **api-style**'))).toBe(true)
|
|
305
|
+
expect(flagged.some((t) => t.includes('+18%'))).toBe(true)
|
|
306
|
+
expect(reviewMarkdown({ base: 'origin/main', firstLock: false, lines })).toContain('**4 change(s) marked ⚠️ deserve a careful look.**')
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
it('flags a baseline whose contents changed under the same version', () => {
|
|
310
|
+
const head = lock({ layers: [{ id: 'opencastle', kind: 'core', version: '0.36.0' }, { id: '@acme/base', kind: 'baseline', version: '1.4.0', integrity: 'sha256-z' }] })
|
|
311
|
+
expect(diffLocks(lock(), head)).toEqual([expect.objectContaining({ level: 'review', text: expect.stringContaining('changed without a version change') })])
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
it('names who excluded a removed item, and flags loosened policy', () => {
|
|
315
|
+
const head = lock({ content: {}, excluded: { 'skills/deploy': 'project' }, policy: {} })
|
|
316
|
+
const texts = diffLocks(lock(), head).map((l) => `${l.level}:${l.text}`)
|
|
317
|
+
expect(texts).toContain('info:skill **deploy** removed — excluded by this project (was from this project)')
|
|
318
|
+
expect(texts).toContain('review:@acme/base no longer restricts which MCP servers may run')
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
describe('fleet: many repositories from their locks', () => {
|
|
323
|
+
it('counts versions and finds servers that run differently', () => {
|
|
324
|
+
const base = (v: string, sentry: string): Lock => ({
|
|
325
|
+
lockfileVersion: 1,
|
|
326
|
+
opencastle: '0.36.0',
|
|
327
|
+
targets: ['cursor'],
|
|
328
|
+
integrations: [],
|
|
329
|
+
layers: [{ id: 'opencastle', kind: 'core', version: '0.36.0' }, { id: '@acme/base', kind: 'baseline', version: v }],
|
|
330
|
+
content: {},
|
|
331
|
+
mcp: { Sentry: { from: 'plugin:sentry', transport: 'stdio', launch: `npx @sentry/mcp-server@${sentry}` } },
|
|
332
|
+
context: { tokens: 1, instructions: 0, index: 1 },
|
|
333
|
+
})
|
|
334
|
+
const report = buildFleet([
|
|
335
|
+
{ repo: 'shop', path: '/x', lock: base('1.5.0', '0.43.0') },
|
|
336
|
+
{ repo: 'api', path: '/y', lock: base('1.4.0', '0.42.0') },
|
|
337
|
+
{ repo: 'old', path: '/z', lock: null },
|
|
338
|
+
])
|
|
339
|
+
expect(report.versions['@acme/base']).toEqual({ '1.5.0': ['shop'], '1.4.0': ['api'] })
|
|
340
|
+
expect(Object.keys(report.spread.Sentry)).toHaveLength(2)
|
|
341
|
+
expect(report.withoutLock).toEqual(['old'])
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
describe('ci: the workflow a team commits', () => {
|
|
346
|
+
let project: string
|
|
347
|
+
beforeEach(() => {
|
|
348
|
+
project = mkdtempSync(join(tmpdir(), 'team-ci-plan-'))
|
|
349
|
+
})
|
|
350
|
+
afterEach(() => {
|
|
351
|
+
rmSync(project, { recursive: true, force: true })
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
it("runs the project's own OpenCastle when it has one, and installs first so baselines resolve", () => {
|
|
355
|
+
write(project, { 'package.json': JSON.stringify({ devDependencies: { opencastle: '^0.36.0' } }), 'package-lock.json': '{}' })
|
|
356
|
+
const plan = planCi(project, '0.36.0', '@acme/platform')
|
|
357
|
+
expect(plan.workflow).toContain('run: npm ci')
|
|
358
|
+
expect(plan.workflow).toContain('run: npx --no opencastle sync --check')
|
|
359
|
+
expect(plan.workflow).toContain('npx --no opencastle review --base origin/${{ github.base_ref }}')
|
|
360
|
+
expect(plan.workflow.indexOf('npm ci')).toBeLessThan(plan.workflow.indexOf('sync --check'))
|
|
361
|
+
expect(plan.codeowners?.block).toContain('/.opencastle/lock.json @acme/platform')
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
it('pins the version that compiled the project when it has none', () => {
|
|
365
|
+
write(project, { 'package.json': '{}', 'pnpm-lock.yaml': '' })
|
|
366
|
+
const plan = planCi(project, '0.36.0')
|
|
367
|
+
expect(plan.workflow).toContain('pnpm install --frozen-lockfile')
|
|
368
|
+
expect(plan.workflow).toContain('npx -y opencastle@0.36.0 sync --check')
|
|
369
|
+
expect(plan.pinned).toBe(false)
|
|
370
|
+
})
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
describe('what review found, kept fixed (compiler and commands)', () => {
|
|
374
|
+
let project: string
|
|
375
|
+
beforeEach(() => {
|
|
376
|
+
project = mkdtempSync(join(tmpdir(), 'team-review-fixes-'))
|
|
377
|
+
})
|
|
378
|
+
afterEach(() => {
|
|
379
|
+
rmSync(project, { recursive: true, force: true })
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
it("keeps an editor variable an editor variable in every target", async () => {
|
|
383
|
+
write(project, { '.opencastle/config.json': JSON.stringify({ mcpServers: { local: { command: 'node', args: ['${workspaceFolder}/tools/mcp.js'] } } }) })
|
|
384
|
+
const stack: StackConfig = { ides: ['cursor', 'vscode'], techTools: [], teamTools: [] }
|
|
385
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
|
|
386
|
+
try {
|
|
387
|
+
await rebuildMcpConfig(project, 'cursor', stack, undefined, src.mcp)
|
|
388
|
+
await rebuildMcpConfig(project, 'vscode', stack, undefined, src.mcp)
|
|
389
|
+
} finally {
|
|
390
|
+
src.dispose()
|
|
391
|
+
}
|
|
392
|
+
expect(JSON.parse(readFileSync(join(project, '.cursor', 'mcp.json'), 'utf8')).mcpServers.local.args).toEqual(['${workspaceFolder}/tools/mcp.js'])
|
|
393
|
+
const vscode = JSON.parse(readFileSync(join(project, '.vscode', 'mcp.json'), 'utf8'))
|
|
394
|
+
expect(vscode.servers.local.args).toEqual(['${workspaceFolder}/tools/mcp.js'])
|
|
395
|
+
expect(vscode.inputs).toBeUndefined()
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
it('takes back the VS Code input only a retired server asked for', async () => {
|
|
399
|
+
const stack: StackConfig = { ides: ['vscode'], techTools: [], teamTools: [] }
|
|
400
|
+
write(project, {
|
|
401
|
+
'.vscode/mcp.json': JSON.stringify({
|
|
402
|
+
servers: { 'acme-docs': { type: 'http', url: 'https://docs.acme.dev/mcp', headers: { Authorization: 'Bearer ${input:DOCS_TOKEN}' } } },
|
|
403
|
+
inputs: [
|
|
404
|
+
{ id: 'DOCS_TOKEN', type: 'promptString', description: 'DOCS_TOKEN for the acme-docs MCP server', password: true },
|
|
405
|
+
{ id: 'mine', type: 'promptString', description: 'kept' },
|
|
406
|
+
],
|
|
407
|
+
}),
|
|
408
|
+
})
|
|
409
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot, ['acme-docs'], ['DOCS_TOKEN'])
|
|
410
|
+
try {
|
|
411
|
+
await rebuildMcpConfig(project, 'vscode', stack, undefined, src.mcp)
|
|
412
|
+
} finally {
|
|
413
|
+
src.dispose()
|
|
414
|
+
}
|
|
415
|
+
const config = JSON.parse(readFileSync(join(project, '.vscode', 'mcp.json'), 'utf8'))
|
|
416
|
+
expect(config.servers['acme-docs']).toBeUndefined()
|
|
417
|
+
expect(config.inputs).toEqual([{ id: 'mine', type: 'promptString', description: 'kept' }])
|
|
418
|
+
})
|
|
419
|
+
|
|
420
|
+
it('never puts the URL — and whatever its query string holds — in a finding', () => {
|
|
421
|
+
const team = { expected: {}, definedIn: {}, retired: [], blocked: new Map(), policy: { ...emptyPolicy(), hostLists: [{ by: 'project', where: 'x', patterns: ['docs.acme.dev'] }] } }
|
|
422
|
+
const audit = auditMcpConfig(
|
|
423
|
+
{ mcpServers: { hand: { type: 'http', url: 'https://mcp.other.example/mcp?api_key=sk-proj-abcdefghijklmnopqrstuvwxyz' } } },
|
|
424
|
+
'claude-code',
|
|
425
|
+
undefined,
|
|
426
|
+
team,
|
|
427
|
+
)
|
|
428
|
+
const text = audit.findings.map(describeFinding).join('\n')
|
|
429
|
+
expect(text).toContain('mcp.other.example is not an allowed host')
|
|
430
|
+
expect(text).not.toContain('sk-proj')
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
it('warns about ${NAME} where the assistant only expands its own spelling', () => {
|
|
434
|
+
const audit = auditMcpConfig({ mcpServers: { mine: { command: 'node', args: ['x.js'], env: { TOKEN: '${TOKEN}' } } } }, 'cursor')
|
|
435
|
+
expect(audit.findings.map(describeFinding)).toEqual([
|
|
436
|
+
'mine: this assistant does not expand ${TOKEN}; it reaches the server as literal text (write ${env:TOKEN})',
|
|
437
|
+
])
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
it('refuses a lock it cannot read rather than crashing on it', () => {
|
|
441
|
+
expect(parseLock('{"lockfileVersion": 2}')).toBeNull()
|
|
442
|
+
expect(parseLock('{"lockfileVersion": 1, "layers": "x"}')).toBeNull()
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
it('flags a team server whose settings changed under the same launch line', () => {
|
|
446
|
+
const base = parseLock(serializeLock({
|
|
447
|
+
lockfileVersion: 1, opencastle: '1.0.0', targets: [], integrations: [], layers: [], content: {},
|
|
448
|
+
mcp: { tools: { from: 'project', transport: 'stdio', launch: 'node x.js', sha: 'aaaaaaaaaaaa' } },
|
|
449
|
+
context: { tokens: 1, instructions: 0, index: 1 },
|
|
450
|
+
}))!
|
|
451
|
+
const head = { ...base, mcp: { tools: { ...base.mcp.tools, sha: 'bbbbbbbbbbbb' } } }
|
|
452
|
+
expect(diffLocks(base, head)).toEqual([expect.objectContaining({ level: 'review', text: expect.stringContaining('has different settings') })])
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
it("summarises a project's first lock instead of listing OpenCastle's content", () => {
|
|
456
|
+
const head = parseLock(serializeLock({
|
|
457
|
+
lockfileVersion: 1, opencastle: '1.0.0', targets: ['cursor'], integrations: [],
|
|
458
|
+
layers: [{ id: 'opencastle', kind: 'core', version: '1.0.0' }],
|
|
459
|
+
content: { 'instructions/general': { from: 'opencastle', sha: 'a', tokens: 900 }, 'skills/a': { from: 'opencastle', sha: 'b' }, 'skills/mine': { from: 'project', sha: 'c' } },
|
|
460
|
+
mcp: {}, context: { tokens: 1000, instructions: 900, index: 100 },
|
|
461
|
+
}))!
|
|
462
|
+
const lines = diffLocks(null, head)
|
|
463
|
+
expect(lines.map((l) => l.text)).toEqual([
|
|
464
|
+
'skill **mine** from this project',
|
|
465
|
+
'and 2 item(s) from OpenCastle and its integrations',
|
|
466
|
+
'Every assistant loads ~1000 tokens before the task',
|
|
467
|
+
])
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
it('ci: installs from the root lockfile in a monorepo subdirectory, and watches it', () => {
|
|
471
|
+
execFileSync('git', ['init', '-q'], { cwd: project })
|
|
472
|
+
write(project, {
|
|
473
|
+
'package.json': JSON.stringify({ workspaces: ['apps/*'] }),
|
|
474
|
+
'package-lock.json': '{}',
|
|
475
|
+
'apps/web/package.json': JSON.stringify({ devDependencies: { opencastle: '^0.36.0' } }),
|
|
476
|
+
CODEOWNERS: '* @acme/everyone\n',
|
|
477
|
+
})
|
|
478
|
+
const plan = planCi(join(project, 'apps', 'web'), '0.36.0', '@acme/platform')
|
|
479
|
+
expect(plan.workflow).toContain('working-directory: apps/web')
|
|
480
|
+
expect(plan.workflow).toMatch(/run: npm ci\n\s+working-directory: \.\n/)
|
|
481
|
+
expect(plan.workflow).toContain("paths: ['apps/web/**', 'package.json', 'package-lock.json', '.github/workflows/opencastle-web.yml']")
|
|
482
|
+
// The CODEOWNERS GitHub already reads, not a new one that would shadow it.
|
|
483
|
+
expect(plan.codeowners?.path).toBe(join(project, 'CODEOWNERS'))
|
|
484
|
+
expect(plan.codeowners?.block).toContain('/apps/web/.opencastle/lock.json @acme/platform')
|
|
485
|
+
})
|
|
486
|
+
|
|
487
|
+
it('ci: gives pnpm a version when package.json does not name one', () => {
|
|
488
|
+
write(project, { 'package.json': '{}', 'pnpm-lock.yaml': '' })
|
|
489
|
+
expect(planCi(project, '0.36.0').workflow).toContain('version: 10')
|
|
490
|
+
write(project, { 'package.json': JSON.stringify({ packageManager: 'pnpm@9.12.0' }) })
|
|
491
|
+
expect(planCi(project, '0.36.0').workflow).not.toContain('version: 10')
|
|
492
|
+
})
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
describe('what the second review found, kept fixed', () => {
|
|
496
|
+
let project: string
|
|
497
|
+
beforeEach(() => {
|
|
498
|
+
project = mkdtempSync(join(tmpdir(), 'team-review-2-'))
|
|
499
|
+
})
|
|
500
|
+
afterEach(() => {
|
|
501
|
+
rmSync(project, { recursive: true, force: true })
|
|
502
|
+
})
|
|
503
|
+
|
|
504
|
+
it("leaves a user's input alone when a retired team server shared its name", async () => {
|
|
505
|
+
const stack: StackConfig = { ides: ['vscode'], techTools: [], teamTools: [] }
|
|
506
|
+
write(project, {
|
|
507
|
+
'.vscode/mcp.json': JSON.stringify({
|
|
508
|
+
servers: { 'my-gh': { type: 'http', url: 'https://gh.example/mcp', headers: { Authorization: 'Bearer ${input:GITHUB_TOKEN}' } } },
|
|
509
|
+
inputs: [{ id: 'GITHUB_TOKEN', type: 'promptString', description: 'GITHUB_TOKEN for the github MCP server', password: true }],
|
|
510
|
+
}),
|
|
511
|
+
})
|
|
512
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot, ['github'], ['GITHUB_TOKEN'])
|
|
513
|
+
try {
|
|
514
|
+
await rebuildMcpConfig(project, 'vscode', stack, undefined, src.mcp)
|
|
515
|
+
} finally {
|
|
516
|
+
src.dispose()
|
|
517
|
+
}
|
|
518
|
+
expect(JSON.parse(readFileSync(join(project, '.vscode', 'mcp.json'), 'utf8')).inputs.map((i: { id: string }) => i.id)).toEqual(['GITHUB_TOKEN'])
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
it('gives Claude Code and OpenCode a workspace they can resolve', async () => {
|
|
522
|
+
write(project, {
|
|
523
|
+
'.opencastle/config.json': JSON.stringify({ mcpServers: { local: { command: 'node', args: ['${workspaceFolder}/tools/mcp.js', '--home', '${userHome}'] } } }),
|
|
524
|
+
})
|
|
525
|
+
const stack: StackConfig = { ides: ['claude-code', 'opencode'], techTools: [], teamTools: [] }
|
|
526
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
|
|
527
|
+
try {
|
|
528
|
+
await rebuildMcpConfig(project, 'claude-code', stack, undefined, src.mcp)
|
|
529
|
+
await rebuildMcpConfig(project, 'opencode', stack, undefined, src.mcp)
|
|
530
|
+
} finally {
|
|
531
|
+
src.dispose()
|
|
532
|
+
}
|
|
533
|
+
expect(JSON.parse(readFileSync(join(project, '.mcp.json'), 'utf8')).mcpServers.local.args).toEqual(['./tools/mcp.js', '--home', '${HOME}'])
|
|
534
|
+
expect(JSON.parse(readFileSync(join(project, 'opencode.json'), 'utf8')).mcp.local.command).toEqual(['node', './tools/mcp.js', '--home', '{env:HOME}'])
|
|
535
|
+
})
|
|
536
|
+
|
|
537
|
+
it('copies a skill\'s own dotfiles and warns about a link it will not follow', () => {
|
|
538
|
+
const outside = mkdtempSync(join(tmpdir(), 'team-review-2-out-'))
|
|
539
|
+
try {
|
|
540
|
+
write(outside, { 'ext/SKILL.md': '---\ndescription: "x. Use when y."\n---\n' })
|
|
541
|
+
write(project, {
|
|
542
|
+
'.opencastle/skills/s/SKILL.md': '---\ndescription: "x. Use when y."\n---\n',
|
|
543
|
+
'.opencastle/skills/s/.env.example': 'A=1\n',
|
|
544
|
+
'.opencastle/skills/s/.DS_Store': 'junk',
|
|
545
|
+
})
|
|
546
|
+
symlinkSync(join(outside, 'ext'), join(project, '.opencastle', 'skills', 'ext'))
|
|
547
|
+
const resolved = resolveSources({ pkgRoot, projectRoot: project, stack: { ides: [], techTools: [], teamTools: [] } })
|
|
548
|
+
expect(resolved.issues.map((i) => i.message)).toContain('is a link to somewhere outside this layer and the project, so it is not compiled')
|
|
549
|
+
const src = materialize(resolved, pkgRoot)
|
|
550
|
+
try {
|
|
551
|
+
expect(readdirSync(join(src.root, 'skills', 's')).sort()).toEqual(['.env.example', 'SKILL.md'])
|
|
552
|
+
} finally {
|
|
553
|
+
src.dispose()
|
|
554
|
+
}
|
|
555
|
+
} finally {
|
|
556
|
+
rmSync(outside, { recursive: true, force: true })
|
|
557
|
+
}
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
it("does not move the lock over a server's description", () => {
|
|
561
|
+
const lockWith = (description?: string): string => {
|
|
562
|
+
write(project, { '.opencastle/config.json': JSON.stringify({ mcpServers: { s: { command: 'node', args: ['x.js'], ...(description && { description }) } } }) })
|
|
563
|
+
const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack: { ides: [], techTools: [], teamTools: [] } }), pkgRoot)
|
|
564
|
+
try {
|
|
565
|
+
return serializeLock(buildLockFor(src))
|
|
566
|
+
} finally {
|
|
567
|
+
src.dispose()
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
expect(lockWith('For people')).toBe(lockWith())
|
|
571
|
+
})
|
|
572
|
+
|
|
573
|
+
it('says sync removes a hand-added server a layer excluded, and why', () => {
|
|
574
|
+
const team = { expected: {}, definedIn: {}, retired: [], blocked: new Map([['acme-mine', 'excluded by project']]), policy: emptyPolicy() }
|
|
575
|
+
const audit = auditMcpConfig({ mcpServers: { 'acme-mine': { command: 'node', args: ['mine.js'] } } }, 'claude-code', undefined, team)
|
|
576
|
+
expect(audit.blockedByPolicy).toEqual(['acme-mine'])
|
|
577
|
+
})
|
|
578
|
+
})
|