opencastle 0.38.1 → 1.0.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 +81 -1
- 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 +1 -1
- package/dist/cli/adapters/claude-code.d.ts.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.map +1 -1
- package/dist/cli/adapters/single-file-base.js +30 -43
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +3 -2
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +19 -71
- 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/bootstrap.d.ts +1 -0
- package/dist/cli/bootstrap.d.ts.map +1 -1
- package/dist/cli/bootstrap.js +1 -1
- package/dist/cli/bootstrap.js.map +1 -1
- 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/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/explain.d.ts +3 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +210 -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 +135 -94
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +26 -25
- 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/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 +3 -2
- 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 +219 -13
- 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 +16 -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 +204 -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 +3 -1
- package/src/cli/adapters/rules-dir-base.ts +23 -44
- package/src/cli/adapters/single-file-base.ts +43 -46
- package/src/cli/adapters/vscode.ts +28 -71
- package/src/cli/baseline.ts +289 -0
- package/src/cli/bootstrap.ts +1 -1
- package/src/cli/ci.ts +289 -0
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +5 -0
- package/src/cli/doctor.ts +92 -6
- package/src/cli/explain.ts +210 -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 +27 -27
- package/src/cli/init.ts +135 -93
- 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/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 +8 -2
- 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 +245 -14
- 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 +19 -1
- package/src/cli/update.ts +217 -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/customizations/README.md +1 -1
- package/src/orchestrator/plugins/chrome-devtools/SKILL.md +1 -1
- package/src/orchestrator/plugins/chrome-devtools/config.ts +11 -1
- package/src/orchestrator/plugins/contentful/SKILL.md +1 -1
- package/src/orchestrator/plugins/contentful/config.ts +11 -1
- package/src/orchestrator/plugins/convex/SKILL.md +1 -1
- package/src/orchestrator/plugins/convex/config.ts +11 -1
- package/src/orchestrator/plugins/coolify/config.ts +14 -1
- package/src/orchestrator/plugins/cypress/SKILL.md +1 -1
- package/src/orchestrator/plugins/figma/SKILL.md +18 -14
- package/src/orchestrator/plugins/figma/config.ts +24 -13
- package/src/orchestrator/plugins/jira/SKILL.md +2 -2
- package/src/orchestrator/plugins/linear/SKILL.md +6 -14
- package/src/orchestrator/plugins/linear/config.ts +27 -17
- package/src/orchestrator/plugins/netlify/SKILL.md +1 -1
- 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/SKILL.md +1 -1
- package/src/orchestrator/plugins/playwright/config.ts +11 -1
- package/src/orchestrator/plugins/prisma/SKILL.md +1 -1
- package/src/orchestrator/plugins/prisma/config.ts +17 -2
- package/src/orchestrator/plugins/resend/config.ts +17 -1
- package/src/orchestrator/plugins/sanity/SKILL.md +1 -1
- package/src/orchestrator/plugins/sentry/config.ts +13 -1
- package/src/orchestrator/plugins/slack/config.ts +20 -1
- package/src/orchestrator/plugins/strapi/SKILL.md +1 -1
- package/src/orchestrator/plugins/strapi/config.ts +11 -1
- package/src/orchestrator/plugins/supabase/SKILL.md +1 -1
- package/src/orchestrator/plugins/trello/SKILL.md +1 -1
- package/src/orchestrator/plugins/trello/config.ts +21 -1
- package/src/orchestrator/plugins/types.ts +24 -0
- package/src/orchestrator/plugins/vercel/SKILL.md +1 -1
- package/src/orchestrator/plugins/vitest/SKILL.md +1 -1
- package/src/orchestrator/skill-config-links.test.ts +30 -0
- package/src/orchestrator/skills/git-workflow/SKILL.md +1 -1
package/src/cli/sync-check.ts
CHANGED
|
@@ -4,8 +4,13 @@ import { tmpdir } from 'node:os'
|
|
|
4
4
|
import { readManifest } from './manifest.js'
|
|
5
5
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
6
6
|
import { detectRepoInfo, mergeStackIntoRepoInfo } from './detect.js'
|
|
7
|
-
import { getMcpConfigRelPath } from './mcp.js'
|
|
8
|
-
import { resolveStack } from './stack-config.js'
|
|
7
|
+
import { getMcpConfigRelPath, expectedTeamEntries } from './mcp.js'
|
|
8
|
+
import { resolveStack, getIncludedMcpServers } from './stack-config.js'
|
|
9
|
+
import { auditMcpConfig, describeFindingUnder, remedyFor, isFailure, type TeamAuditContext } from './mcp-audit.js'
|
|
10
|
+
import { resolveSources, materialize, hasErrors, cliVersionOf, type CompileSource } from './layers.js'
|
|
11
|
+
import { parseVersion, compareVersions } from './version-range.js'
|
|
12
|
+
import { buildLock, serializeLock, LOCK_REL, priorTeam } from './lock.js'
|
|
13
|
+
import { PLUGINS } from '../orchestrator/plugins/index.js'
|
|
9
14
|
import { gitignoreNeedsRebuild } from './gitignore.js'
|
|
10
15
|
import {
|
|
11
16
|
carriesLegacyBody,
|
|
@@ -16,6 +21,7 @@ import {
|
|
|
16
21
|
diagnoseManagedFile,
|
|
17
22
|
} from './managed-block.js'
|
|
18
23
|
import { c } from './prompt.js'
|
|
24
|
+
import { reportToGitHub, COMPARISON_FAILED } from './github-report.js'
|
|
19
25
|
import type { CliContext, IdeChoice, StackConfig } from './types.js'
|
|
20
26
|
|
|
21
27
|
/**
|
|
@@ -29,18 +35,33 @@ import type { CliContext, IdeChoice, StackConfig } from './types.js'
|
|
|
29
35
|
*/
|
|
30
36
|
|
|
31
37
|
/**
|
|
38
|
+
* `outdated` is an MCP config holding a server entry still exactly as an
|
|
39
|
+
* earlier release wrote it, whose default has since changed — a retired
|
|
40
|
+
* package, an `@latest`, a shape the assistant cannot load. `sync` moves those
|
|
41
|
+
* entries forward and leaves everything else in the file alone.
|
|
42
|
+
*
|
|
32
43
|
* `unreducible` is the state no command will change: a co-owned file holding
|
|
33
44
|
* more than one block *and* a marker that pairs with nothing. It is drift, so
|
|
34
45
|
* CI must fail — but the remedy is a person, and printing "Fix: opencastle
|
|
35
46
|
* sync" beside it made the check permanently red on a command that by design
|
|
36
47
|
* refuses to touch the file.
|
|
37
48
|
*/
|
|
38
|
-
export type DriftKind = 'missing' | 'changed' | 'extra' | 'unreducible'
|
|
49
|
+
export type DriftKind = 'missing' | 'changed' | 'extra' | 'unreducible' | 'outdated'
|
|
39
50
|
|
|
40
51
|
export interface Drift {
|
|
41
52
|
ide: string
|
|
42
53
|
path: string
|
|
43
54
|
kind: DriftKind
|
|
55
|
+
/**
|
|
56
|
+
* Set on drift the MCP audit found. A broken server only a person can fix is
|
|
57
|
+
* a reason for CI to fail, but not a reason for `sync` to recompile or for
|
|
58
|
+
* the status line to say generated files are stale — neither is true of it.
|
|
59
|
+
*
|
|
60
|
+
* `team` is a problem in the team's own sources — a config that will not
|
|
61
|
+
* parse, a baseline that is not installed, a policy the sources break. The
|
|
62
|
+
* comparison cannot run until it is fixed, and `sync` refuses to compile.
|
|
63
|
+
*/
|
|
64
|
+
origin?: 'mcp' | 'team' | 'version'
|
|
44
65
|
/** The classifier's own words, so the checker and `doctor` cannot diverge. */
|
|
45
66
|
detail?: string
|
|
46
67
|
/** What resolves it, per entry — these do not share a remedy. */
|
|
@@ -55,6 +76,14 @@ export interface CheckReport {
|
|
|
55
76
|
checked: number
|
|
56
77
|
}
|
|
57
78
|
|
|
79
|
+
/** The plugin ids behind server keys, for an `opencastle add` line. */
|
|
80
|
+
function pluginIds(servers: string[]): string[] {
|
|
81
|
+
const ids = Object.values(PLUGINS)
|
|
82
|
+
.filter((p) => p.mcpServerKey && servers.includes(p.mcpServerKey))
|
|
83
|
+
.map((p) => p.id)
|
|
84
|
+
return [...new Set(ids)]
|
|
85
|
+
}
|
|
86
|
+
|
|
58
87
|
/** Every file under a directory, relative to it, sorted for stable output. */
|
|
59
88
|
function filesUnder(root: string): string[] {
|
|
60
89
|
const out: string[] = []
|
|
@@ -237,14 +266,81 @@ export async function buildCheckReport(pkgRoot: string, projectRoot: string): Pr
|
|
|
237
266
|
const stack: StackConfig = resolveStack({ ...manifest, ides })
|
|
238
267
|
const repoInfo = manifest.repoInfo ?? mergeStackIntoRepoInfo(await detectRepoInfo(projectRoot), stack)
|
|
239
268
|
|
|
269
|
+
// An older OpenCastle than the one that compiled the project cannot say
|
|
270
|
+
// whether the project is right: its output is not the project's. Comparing
|
|
271
|
+
// anyway reported every changed file and prescribed a `sync` that refuses.
|
|
272
|
+
{
|
|
273
|
+
const running = cliVersionOf(pkgRoot)
|
|
274
|
+
const mine = parseVersion(running)
|
|
275
|
+
const theirs = parseVersion(manifest.version)
|
|
276
|
+
if (mine && theirs && compareVersions(mine, theirs) < 0) {
|
|
277
|
+
return {
|
|
278
|
+
installed: true,
|
|
279
|
+
ides,
|
|
280
|
+
checked: 0,
|
|
281
|
+
drift: [
|
|
282
|
+
{
|
|
283
|
+
ide: 'all',
|
|
284
|
+
path: '.opencastle/manifest.json',
|
|
285
|
+
kind: 'unreducible',
|
|
286
|
+
origin: 'version',
|
|
287
|
+
detail: `compiled by OpenCastle ${manifest.version}; this is ${running}, so nothing was compared`,
|
|
288
|
+
fix: `run the project's version — npx opencastle@${manifest.version} sync --check, or add opencastle to devDependencies`,
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// The team's layers, resolved exactly as `sync` resolves them. A problem in
|
|
296
|
+
// them — a baseline not installed, a config that does not parse, a server
|
|
297
|
+
// the policy forbids — means there is nothing to compare against: say that,
|
|
298
|
+
// once, instead of reporting every generated file as drifted.
|
|
299
|
+
const resolved = resolveSources({ pkgRoot, projectRoot, stack, repoInfo })
|
|
300
|
+
if (hasErrors(resolved)) {
|
|
301
|
+
return {
|
|
302
|
+
installed: true,
|
|
303
|
+
ides,
|
|
304
|
+
checked: 0,
|
|
305
|
+
drift: resolved.issues
|
|
306
|
+
.filter((i) => i.level === 'error')
|
|
307
|
+
.map((i) => ({
|
|
308
|
+
ide: 'all',
|
|
309
|
+
path: i.where,
|
|
310
|
+
kind: 'unreducible' as const,
|
|
311
|
+
detail: i.message,
|
|
312
|
+
fix: i.fix ?? 'fix it, then run opencastle sync',
|
|
313
|
+
origin: 'team' as const,
|
|
314
|
+
})),
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const source = materialize(resolved, pkgRoot, ...priorTeam(projectRoot))
|
|
318
|
+
try {
|
|
319
|
+
return await compareProject(pkgRoot, projectRoot, ides, stack, repoInfo, source)
|
|
320
|
+
} finally {
|
|
321
|
+
source.dispose()
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async function compareProject(
|
|
326
|
+
pkgRoot: string,
|
|
327
|
+
projectRoot: string,
|
|
328
|
+
ides: IdeChoice[],
|
|
329
|
+
stack: StackConfig,
|
|
330
|
+
repoInfo: ReturnType<typeof mergeStackIntoRepoInfo>,
|
|
331
|
+
source: CompileSource,
|
|
332
|
+
): Promise<CheckReport> {
|
|
333
|
+
const { resolved } = source
|
|
240
334
|
const drift: Drift[] = []
|
|
241
335
|
let checked = 0
|
|
336
|
+
// The servers a rebuild keeps, so what the MCP audit predicts is what `sync` does.
|
|
337
|
+
const included = getIncludedMcpServers(stack, repoInfo)
|
|
242
338
|
|
|
243
339
|
for (const ide of ides) {
|
|
244
340
|
const adapter = await IDE_ADAPTERS[ide]()
|
|
245
341
|
const scratch = mkdtempSync(join(tmpdir(), `opencastle-check-${ide}-`))
|
|
246
342
|
try {
|
|
247
|
-
await adapter.install(pkgRoot, scratch, stack, repoInfo)
|
|
343
|
+
await adapter.install(pkgRoot, scratch, stack, repoInfo, source)
|
|
248
344
|
// Framework and merged paths are compared. Customizable paths are the
|
|
249
345
|
// user's by design — reporting those as drift would make the check useless.
|
|
250
346
|
// Merged paths must be included or the root instruction file, the one file
|
|
@@ -258,6 +354,34 @@ export async function buildCheckReport(pkgRoot: string, projectRoot: string): Pr
|
|
|
258
354
|
}
|
|
259
355
|
}
|
|
260
356
|
|
|
357
|
+
// The lock: what every assistant is given, as `sync` would record it now.
|
|
358
|
+
// Compared like any generated file, because it is one — a stale lock is a
|
|
359
|
+
// review of something other than what was compiled.
|
|
360
|
+
{
|
|
361
|
+
const expected = serializeLock(buildLock(source, { ides, stack, repoInfo }))
|
|
362
|
+
const abs = resolve(projectRoot, LOCK_REL)
|
|
363
|
+
checked++
|
|
364
|
+
if (!existsSync(abs)) {
|
|
365
|
+
drift.push({ ide: 'all', path: LOCK_REL, kind: 'missing', detail: 'records what every assistant is given; sync writes it' })
|
|
366
|
+
} else {
|
|
367
|
+
let actual: string | null = null
|
|
368
|
+
try {
|
|
369
|
+
actual = normaliseEndings(readFileSync(abs, 'utf8'))
|
|
370
|
+
} catch (err) {
|
|
371
|
+
drift.push({
|
|
372
|
+
ide: 'all',
|
|
373
|
+
path: LOCK_REL,
|
|
374
|
+
kind: 'unreducible',
|
|
375
|
+
detail: `cannot be read — ${(err as Error).message}`,
|
|
376
|
+
fix: 'fix the permissions or delete the file, then run opencastle sync; this one needs a person',
|
|
377
|
+
})
|
|
378
|
+
}
|
|
379
|
+
if (actual !== null && actual !== expected) {
|
|
380
|
+
drift.push({ ide: 'all', path: LOCK_REL, kind: 'changed', detail: 'does not match what the sources compile to' })
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
261
385
|
// A whole instruction set from an older release, sitting above our block.
|
|
262
386
|
//
|
|
263
387
|
// `sameContent` compares the block and finds it correct, so this passed the
|
|
@@ -367,11 +491,20 @@ export async function buildCheckReport(pkgRoot: string, projectRoot: string): Pr
|
|
|
367
491
|
// split closed for `.gitignore`, on the other customizable path.
|
|
368
492
|
{
|
|
369
493
|
const seen = new Set<string>()
|
|
494
|
+
const definedIn = Object.fromEntries([...resolved.servers.values()].map((s) => [s.key, s.where]))
|
|
495
|
+
const teamFor = (ide: IdeChoice): TeamAuditContext => ({
|
|
496
|
+
expected: expectedTeamEntries(source.mcp, ide),
|
|
497
|
+
definedIn,
|
|
498
|
+
retired: source.mcp.retired,
|
|
499
|
+
blocked: resolved.blocked,
|
|
500
|
+
policy: resolved.policy,
|
|
501
|
+
})
|
|
370
502
|
for (const ide of ides) {
|
|
371
503
|
const rel = getMcpConfigRelPath(ide as IdeChoice)
|
|
372
504
|
if (seen.has(rel)) continue
|
|
373
505
|
seen.add(rel)
|
|
374
506
|
const abs = resolve(projectRoot, rel)
|
|
507
|
+
const team = teamFor(ide)
|
|
375
508
|
// `existsSync` is false both for a file that is absent and for one whose
|
|
376
509
|
// parent we cannot read, and only the first is a reason to skip. Asking
|
|
377
510
|
// for the stat separates them: an error here is a fault to report, not an
|
|
@@ -389,12 +522,20 @@ export async function buildCheckReport(pkgRoot: string, projectRoot: string): Pr
|
|
|
389
522
|
detail: `cannot be read — ${(err as Error).message}`,
|
|
390
523
|
fix: `fix the permissions on ${rel}, then run opencastle sync; this one needs a person`,
|
|
391
524
|
})
|
|
525
|
+
continue
|
|
392
526
|
}
|
|
393
527
|
}
|
|
528
|
+
// No config is fine until the team defines servers every assistant
|
|
529
|
+
// should have: then the file is output `sync` owes.
|
|
530
|
+
const owed = Object.keys(team.expected)
|
|
531
|
+
if (owed.length > 0) {
|
|
532
|
+
drift.push({ ide, path: rel, kind: 'outdated', detail: `the team's servers sync writes: ${owed.join(', ')}`, fix: 'opencastle sync', origin: 'mcp' })
|
|
533
|
+
}
|
|
394
534
|
continue
|
|
395
535
|
}
|
|
536
|
+
let parsed: unknown
|
|
396
537
|
try {
|
|
397
|
-
JSON.parse(readFileSync(abs, 'utf8'))
|
|
538
|
+
parsed = JSON.parse(readFileSync(abs, 'utf8'))
|
|
398
539
|
} catch (err) {
|
|
399
540
|
drift.push({
|
|
400
541
|
ide,
|
|
@@ -403,6 +544,51 @@ export async function buildCheckReport(pkgRoot: string, projectRoot: string): Pr
|
|
|
403
544
|
detail: `cannot be read — ${(err as Error).message}`,
|
|
404
545
|
fix: `fix or delete ${rel}, then run opencastle sync; this one needs a person`,
|
|
405
546
|
})
|
|
547
|
+
continue
|
|
548
|
+
}
|
|
549
|
+
// What the servers in it launch, read by the same audit `doctor` runs, so
|
|
550
|
+
// the two cannot disagree: `doctor` failed on a remote server Claude Code
|
|
551
|
+
// never loads while this reported every file matching its source, and CI —
|
|
552
|
+
// the one place a team would see it — stayed green.
|
|
553
|
+
const audit = auditMcpConfig(parsed, ide as IdeChoice, included, team)
|
|
554
|
+
// Everything `sync` would change in the file, in one entry: entries it
|
|
555
|
+
// moves forward, and plugin servers the stack dropped, which it deletes.
|
|
556
|
+
// Leaving the second out let `doctor` say "sync removes it" while this
|
|
557
|
+
// passed and `sync` short-circuited — a remedy that did nothing.
|
|
558
|
+
const teamKeys = new Set(Object.keys(team.expected))
|
|
559
|
+
const container = (parsed as Record<string, unknown> | null)?.[ide === 'opencode' ? 'mcp' : ide === 'vscode' ? 'servers' : 'mcpServers']
|
|
560
|
+
const present = new Set(container && typeof container === 'object' ? Object.keys(container as object) : [])
|
|
561
|
+
const pluginOutdated = audit.outdated.filter((k) => !teamKeys.has(k))
|
|
562
|
+
const teamMissing = audit.outdated.filter((k) => teamKeys.has(k) && !present.has(k))
|
|
563
|
+
const teamDiffers = audit.outdated.filter((k) => teamKeys.has(k) && present.has(k))
|
|
564
|
+
const changes = [
|
|
565
|
+
pluginOutdated.length > 0 ? `still an earlier OpenCastle default: ${pluginOutdated.join(', ')}` : '',
|
|
566
|
+
teamMissing.length > 0 ? `missing the team's servers, which sync adds: ${teamMissing.join(', ')}` : '',
|
|
567
|
+
teamDiffers.length > 0 ? `not as the team config defines them, so sync writes: ${teamDiffers.join(', ')}` : '',
|
|
568
|
+
audit.removed.length > 0
|
|
569
|
+
? `not in this project's stack, so sync removes: ${audit.removed.join(', ')} ` +
|
|
570
|
+
`(opencastle add ${pluginIds(audit.removed).join(' ')} keeps them)`
|
|
571
|
+
: '',
|
|
572
|
+
audit.blockedByPolicy.length > 0
|
|
573
|
+
? `sync removes ${audit.blockedByPolicy.map((k) => `${k} (${resolved.blocked.get(k) ?? "refused by the team's MCP policy"})`).join(', ')}`
|
|
574
|
+
: '',
|
|
575
|
+
audit.retired.length > 0 ? `no longer defined by any team layer, so sync removes: ${audit.retired.join(', ')}` : '',
|
|
576
|
+
].filter(Boolean)
|
|
577
|
+
if (changes.length > 0) {
|
|
578
|
+
drift.push({ ide, path: rel, kind: 'outdated', detail: changes.join('; '), fix: 'opencastle sync', origin: 'mcp' })
|
|
579
|
+
}
|
|
580
|
+
// Failures `sync` will not clear — an entry someone edited, or their own.
|
|
581
|
+
// Unpinned ones are warnings in `doctor` and are not drift here either.
|
|
582
|
+
const stuck = audit.findings.filter((f) => isFailure(f, resolved.policy) && f.sync === 'keeps')
|
|
583
|
+
if (stuck.length > 0) {
|
|
584
|
+
drift.push({
|
|
585
|
+
ide,
|
|
586
|
+
path: rel,
|
|
587
|
+
kind: 'unreducible',
|
|
588
|
+
detail: stuck.map((f) => describeFindingUnder(f, resolved.policy)).join('; '),
|
|
589
|
+
fix: remedyFor(stuck, rel),
|
|
590
|
+
origin: 'mcp',
|
|
591
|
+
})
|
|
406
592
|
}
|
|
407
593
|
}
|
|
408
594
|
}
|
|
@@ -485,26 +671,62 @@ function render(report: CheckReport): void {
|
|
|
485
671
|
const missing = report.drift.filter((d) => d.kind === 'missing')
|
|
486
672
|
const changed = report.drift.filter((d) => d.kind === 'changed')
|
|
487
673
|
const extra = report.drift.filter((d) => d.kind === 'extra')
|
|
674
|
+
const outdated = report.drift.filter((d) => d.kind === 'outdated')
|
|
488
675
|
const unreducible = report.drift.filter((d) => d.kind === 'unreducible')
|
|
489
676
|
|
|
490
|
-
|
|
677
|
+
// A broken MCP server nobody generated is not a file that "differs from its
|
|
678
|
+
// source"; say what it is when it is all there is.
|
|
679
|
+
const mcpOnly = report.drift.every((d) => d.origin === 'mcp' && d.kind === 'unreducible')
|
|
680
|
+
const teamOnly = report.drift.every((d) => d.origin === 'team')
|
|
681
|
+
const olderCli = report.drift.some((d) => d.origin === 'version')
|
|
682
|
+
console.log(
|
|
683
|
+
olderCli
|
|
684
|
+
? `\n ${c.red('✗')} This OpenCastle is older than the one that compiled the project.\n`
|
|
685
|
+
: teamOnly
|
|
686
|
+
? `\n ${c.red('✗')} The team's sources have ${report.drift.length} problem(s), so nothing could be compared.\n`
|
|
687
|
+
: mcpOnly
|
|
688
|
+
? `\n ${c.red('✗')} ${report.drift.length} MCP config(s) have a server only a person can fix.\n`
|
|
689
|
+
: `\n ${c.red('✗')} ${report.drift.length} file(s) differ from their sources.\n`,
|
|
690
|
+
)
|
|
491
691
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
692
|
+
// The lock is not edited by anyone; when it differs, the sources moved and
|
|
693
|
+
// nobody has synced. Filed under "edited in place" it told people they had
|
|
694
|
+
// an edit to lose.
|
|
695
|
+
const lockDrift = [...changed, ...missing].filter((d) => d.path === LOCK_REL)
|
|
696
|
+
const changedFiles = changed.filter((d) => d.path !== LOCK_REL)
|
|
697
|
+
const missingFiles = missing.filter((d) => d.path !== LOCK_REL)
|
|
698
|
+
if (lockDrift.length > 0) {
|
|
699
|
+
console.log(` ${c.bold('Sources changed since the last sync')}`)
|
|
700
|
+
for (const d of lockDrift) console.log(` ${c.yellow('~')} ${d.path} ${c.dim(`(${d.detail ?? d.kind})`)}`)
|
|
495
701
|
console.log('')
|
|
496
702
|
}
|
|
497
|
-
if (
|
|
703
|
+
if (changedFiles.length > 0) {
|
|
704
|
+
console.log(` ${c.bold('Differs from a fresh compile')} ${c.dim('(an edit here is lost on the next sync — make it in .opencastle/)')}`)
|
|
705
|
+
for (const d of changedFiles) console.log(` ${c.yellow('~')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
706
|
+
console.log('')
|
|
707
|
+
}
|
|
708
|
+
if (missingFiles.length > 0) {
|
|
498
709
|
console.log(` ${c.bold('Never generated')}`)
|
|
499
|
-
for (const d of
|
|
710
|
+
for (const d of missingFiles) console.log(` ${c.red('-')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
500
711
|
console.log('')
|
|
501
712
|
}
|
|
502
713
|
if (extra.length > 0) {
|
|
503
|
-
console.log(` ${c.bold('
|
|
714
|
+
console.log(` ${c.bold('Not produced by any source')} ${c.dim('(removed on the next sync)')}`)
|
|
504
715
|
for (const d of extra) console.log(` ${c.red('+')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
505
716
|
console.log('')
|
|
506
717
|
}
|
|
507
718
|
|
|
719
|
+
if (outdated.length > 0) {
|
|
720
|
+
console.log(
|
|
721
|
+
` ${c.bold('MCP servers sync would change')} ${c.dim('(integration defaults move forward, team servers are written as defined; entries you added or edited stay yours)')}`,
|
|
722
|
+
)
|
|
723
|
+
for (const d of outdated) {
|
|
724
|
+
console.log(` ${c.yellow('~')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
725
|
+
if (d.detail) console.log(` ${c.dim(d.detail)}`)
|
|
726
|
+
}
|
|
727
|
+
console.log('')
|
|
728
|
+
}
|
|
729
|
+
|
|
508
730
|
if (unreducible.length > 0) {
|
|
509
731
|
console.log(` ${c.bold('Needs a person')} ${c.dim('(no command will change these)')}`)
|
|
510
732
|
// The classifier's sentence, not a second one written here. The hard-coded
|
|
@@ -525,7 +747,12 @@ function render(report: CheckReport): void {
|
|
|
525
747
|
// Only when something here is actually fixable by it. `sync` was printed
|
|
526
748
|
// unconditionally, so a file the writer refuses to touch produced a red check
|
|
527
749
|
// recommending the command that refuses — CI red forever on a no-op.
|
|
528
|
-
if (report.drift.length > unreducible.length) {
|
|
750
|
+
if (report.drift.length > unreducible.length && unreducible.length > 0) {
|
|
751
|
+
// Both kinds: `sync` alone may not clear the rest — the lock, for one, is
|
|
752
|
+
// held back while an MCP config cannot be read.
|
|
753
|
+
console.log(` ${c.bold('Fix:')} ${c.dim('the ones that need a person first, then')} ${c.cyan('opencastle sync')}`)
|
|
754
|
+
console.log(` ${c.dim('To keep an edit, move it into .opencastle/ instead — that directory is yours.')}\n`)
|
|
755
|
+
} else if (report.drift.length > unreducible.length) {
|
|
529
756
|
console.log(` ${c.bold('Fix:')} ${c.cyan('opencastle sync')}`)
|
|
530
757
|
console.log(` ${c.dim('To keep an edit, move it into .opencastle/ instead — that directory is yours.')}\n`)
|
|
531
758
|
} else {
|
|
@@ -553,13 +780,14 @@ export async function runCheck({ pkgRoot, args }: CliContext): Promise<void> {
|
|
|
553
780
|
ide: 'all',
|
|
554
781
|
path: (err as Error).message,
|
|
555
782
|
kind: 'unreducible',
|
|
556
|
-
detail:
|
|
783
|
+
detail: COMPARISON_FAILED,
|
|
557
784
|
fix: 'fix the path named above, then run opencastle sync; this one needs a person',
|
|
558
785
|
},
|
|
559
786
|
],
|
|
560
787
|
}
|
|
561
788
|
if (args.includes('--json')) console.log(JSON.stringify(failure, null, 2))
|
|
562
789
|
else render(failure)
|
|
790
|
+
reportToGitHub(failure, process.cwd(), { json: args.includes('--json') })
|
|
563
791
|
process.exit(1)
|
|
564
792
|
}
|
|
565
793
|
|
|
@@ -568,6 +796,9 @@ export async function runCheck({ pkgRoot, args }: CliContext): Promise<void> {
|
|
|
568
796
|
} else {
|
|
569
797
|
render(report)
|
|
570
798
|
}
|
|
799
|
+
// On GitHub Actions only: annotations on the files in the pull request, and a
|
|
800
|
+
// table on the run's summary page. Everywhere else this is a no-op.
|
|
801
|
+
reportToGitHub(report, process.cwd(), { json: args.includes('--json') })
|
|
571
802
|
|
|
572
803
|
if (!report.installed || report.drift.length > 0) process.exit(1)
|
|
573
804
|
}
|
package/src/cli/sync.ts
CHANGED
|
@@ -20,6 +20,8 @@ const SYNC_HELP = `
|
|
|
20
20
|
--check Report drift and exit non-zero; writes nothing (for CI)
|
|
21
21
|
--dry-run Preview what would change
|
|
22
22
|
--force Sync even when versions match
|
|
23
|
+
--allow-downgrade Recompile with this OpenCastle even though a newer one
|
|
24
|
+
compiled the project
|
|
23
25
|
--reconfigure Re-run IDE and stack selection
|
|
24
26
|
--yes Skip the confirmation prompt
|
|
25
27
|
--json Machine-readable output (with --check)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The team-facing paths, driven through the CLI the way a person and a CI job
|
|
3
|
+
* would drive them.
|
|
4
|
+
*
|
|
5
|
+
* Two promises are checked end to end here because each one failed in
|
|
6
|
+
* development in a way unit tests did not see: `doctor` prescribed `sync` for a
|
|
7
|
+
* stale MCP server and `sync` then reported nothing to do; and drift has to show
|
|
8
|
+
* up where a pull request's author will read it, not only in a job log.
|
|
9
|
+
*/
|
|
10
|
+
import { mkdtempSync, writeFileSync, readFileSync, rmSync, existsSync, appendFileSync } from 'node:fs'
|
|
11
|
+
import { tmpdir } from 'node:os'
|
|
12
|
+
import { join, resolve } from 'node:path'
|
|
13
|
+
import { execFileSync } from 'node:child_process'
|
|
14
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
15
|
+
|
|
16
|
+
const repoRoot = resolve(import.meta.dirname, '..', '..')
|
|
17
|
+
const cli = join(repoRoot, 'bin', 'cli.mjs')
|
|
18
|
+
const built = existsSync(join(repoRoot, 'dist', 'cli', 'doctor.js'))
|
|
19
|
+
|
|
20
|
+
function run(dir: string, args: string[], env: NodeJS.ProcessEnv = {}): { code: number; out: string } {
|
|
21
|
+
// GitHub's own variables are stripped, so a run of this suite inside Actions
|
|
22
|
+
// does not report to the job it is running in.
|
|
23
|
+
const base = { ...process.env }
|
|
24
|
+
for (const k of Object.keys(base)) if (k.startsWith('GITHUB_')) delete base[k]
|
|
25
|
+
try {
|
|
26
|
+
const out = execFileSync('node', [cli, ...args], {
|
|
27
|
+
cwd: dir,
|
|
28
|
+
encoding: 'utf8',
|
|
29
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
30
|
+
env: { ...base, ...env },
|
|
31
|
+
})
|
|
32
|
+
return { code: 0, out }
|
|
33
|
+
} catch (err) {
|
|
34
|
+
const e = err as { status?: number; stdout?: string; stderr?: string }
|
|
35
|
+
return { code: e.status ?? 1, out: `${e.stdout ?? ''}${e.stderr ?? ''}` }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe.skipIf(!built)('a stale MCP default is fixed by the command doctor names', () => {
|
|
40
|
+
let dir: string
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
dir = mkdtempSync(join(tmpdir(), 'team-mcp-'))
|
|
43
|
+
execFileSync('git', ['init', '-q'], { cwd: dir })
|
|
44
|
+
writeFileSync(join(dir, 'CLAUDE.md'), '# Ours\n')
|
|
45
|
+
writeFileSync(join(dir, 'package.json'), JSON.stringify({ dependencies: { '@supabase/supabase-js': '^2.0.0' } }))
|
|
46
|
+
expect(run(dir, ['init', '--yes']).code).toBe(0)
|
|
47
|
+
})
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
rmSync(dir, { recursive: true, force: true })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('doctor and CI both fail on it, sync at the same version fixes it, both pass', () => {
|
|
53
|
+
// What every release before this one wrote into .mcp.json for Supabase.
|
|
54
|
+
writeFileSync(
|
|
55
|
+
join(dir, '.mcp.json'),
|
|
56
|
+
JSON.stringify({ mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } }, null, 2) + '\n',
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
const before = run(dir, ['doctor'])
|
|
60
|
+
expect(before.code).toBe(1)
|
|
61
|
+
expect(before.out).toContain('opencastle sync fixes Supabase')
|
|
62
|
+
// The check a team runs in CI must not be green over what doctor fails.
|
|
63
|
+
const check = run(dir, ['sync', '--check'])
|
|
64
|
+
expect(check.code).toBe(1)
|
|
65
|
+
expect(check.out).toContain('still an earlier OpenCastle default: Supabase')
|
|
66
|
+
|
|
67
|
+
const sync = run(dir, ['sync', '--yes'])
|
|
68
|
+
expect(sync.code).toBe(0)
|
|
69
|
+
expect(sync.out).toContain('Moved 1 MCP server(s) to the current default: Supabase')
|
|
70
|
+
|
|
71
|
+
const config = JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8'))
|
|
72
|
+
expect(config.mcpServers.Supabase).toEqual({ type: 'http', url: 'https://mcp.supabase.com/mcp' })
|
|
73
|
+
expect(run(dir, ['doctor']).code).toBe(0)
|
|
74
|
+
expect(run(dir, ['sync', '--check']).code).toBe(0)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('an edited entry: the remedy doctor names brings back the current default', () => {
|
|
78
|
+
// Edited since OpenCastle wrote it, so sync must leave it — and doctor must
|
|
79
|
+
// not say otherwise.
|
|
80
|
+
writeFileSync(
|
|
81
|
+
join(dir, '.mcp.json'),
|
|
82
|
+
JSON.stringify({ mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp', note: 'ours' } } }, null, 2) + '\n',
|
|
83
|
+
)
|
|
84
|
+
const doctor = run(dir, ['doctor'])
|
|
85
|
+
expect(doctor.code).toBe(1)
|
|
86
|
+
expect(doctor.out).toContain('delete the entry and run opencastle sync --force')
|
|
87
|
+
expect(run(dir, ['sync', '--check']).code).toBe(1)
|
|
88
|
+
|
|
89
|
+
// Follow it literally.
|
|
90
|
+
const config = JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8'))
|
|
91
|
+
delete config.mcpServers.Supabase
|
|
92
|
+
writeFileSync(join(dir, '.mcp.json'), JSON.stringify(config, null, 2) + '\n')
|
|
93
|
+
expect(run(dir, ['sync', '--force', '--yes']).code).toBe(0)
|
|
94
|
+
const after = JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8'))
|
|
95
|
+
expect(after.mcpServers.Supabase).toEqual({ type: 'http', url: 'https://mcp.supabase.com/mcp' })
|
|
96
|
+
expect(run(dir, ['doctor']).code).toBe(0)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('a plugin server the stack dropped: doctor, CI and sync agree it goes', () => {
|
|
100
|
+
// An old Figma default in a project whose stack has no Figma.
|
|
101
|
+
const config = JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8'))
|
|
102
|
+
config.mcpServers.Figma = {
|
|
103
|
+
command: 'npx',
|
|
104
|
+
args: ['-y', '@anthropic/figma-mcp@latest'],
|
|
105
|
+
env: { FIGMA_ACCESS_TOKEN: '${FIGMA_ACCESS_TOKEN}' },
|
|
106
|
+
}
|
|
107
|
+
writeFileSync(join(dir, '.mcp.json'), JSON.stringify(config, null, 2) + '\n')
|
|
108
|
+
|
|
109
|
+
const doctor = run(dir, ['doctor'])
|
|
110
|
+
expect(doctor.code).toBe(1)
|
|
111
|
+
expect(doctor.out).toContain('opencastle sync removes Figma')
|
|
112
|
+
const check = run(dir, ['sync', '--check'])
|
|
113
|
+
expect(check.code).toBe(1)
|
|
114
|
+
expect(check.out).toContain('so sync removes: Figma')
|
|
115
|
+
|
|
116
|
+
const sync = run(dir, ['sync', '--yes'])
|
|
117
|
+
expect(sync.out).toContain('Removed 1 MCP server(s)')
|
|
118
|
+
expect(JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8')).mcpServers.Figma).toBeUndefined()
|
|
119
|
+
expect(run(dir, ['doctor']).code).toBe(0)
|
|
120
|
+
expect(run(dir, ['sync', '--check']).code).toBe(0)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('a broken server of the user’s own fails CI, and sync leaves the repo alone', () => {
|
|
124
|
+
const config = JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8'))
|
|
125
|
+
config.mcpServers.context7 = { url: 'https://mcp.context7.com/mcp' }
|
|
126
|
+
writeFileSync(join(dir, '.mcp.json'), JSON.stringify(config, null, 2) + '\n')
|
|
127
|
+
|
|
128
|
+
const check = run(dir, ['sync', '--check'])
|
|
129
|
+
expect(check.code).toBe(1)
|
|
130
|
+
expect(check.out).toContain('only a person can fix')
|
|
131
|
+
expect(check.out).toContain('fix context7 by hand')
|
|
132
|
+
|
|
133
|
+
// Recompiling cannot fix it, so sync must not rewrite committed files for it.
|
|
134
|
+
const manifest = join(dir, '.opencastle', 'manifest.json')
|
|
135
|
+
const before = readFileSync(manifest, 'utf8')
|
|
136
|
+
const sync = run(dir, ['sync', '--yes'])
|
|
137
|
+
expect(sync.out).toContain('Everything matches its sources')
|
|
138
|
+
expect(readFileSync(manifest, 'utf8')).toBe(before)
|
|
139
|
+
|
|
140
|
+
// And the front door does not call it stale output.
|
|
141
|
+
expect(run(dir, []).out).not.toContain('no longer match their sources')
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('leaves a server someone wrote, and says so', () => {
|
|
145
|
+
const own = { command: 'npx', args: ['-y', 'our-internal-mcp'] }
|
|
146
|
+
const config = JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8'))
|
|
147
|
+
config.mcpServers.Ours = own
|
|
148
|
+
writeFileSync(join(dir, '.mcp.json'), JSON.stringify(config, null, 2) + '\n')
|
|
149
|
+
|
|
150
|
+
const doctor = run(dir, ['doctor'])
|
|
151
|
+
expect(doctor.code).toBe(0)
|
|
152
|
+
expect(doctor.out).toContain('fix Ours by hand')
|
|
153
|
+
|
|
154
|
+
run(dir, ['sync', '--yes'])
|
|
155
|
+
expect(JSON.parse(readFileSync(join(dir, '.mcp.json'), 'utf8')).mcpServers.Ours).toEqual(own)
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
describe.skipIf(!built)('sync --check on GitHub Actions', () => {
|
|
160
|
+
let dir: string
|
|
161
|
+
beforeEach(() => {
|
|
162
|
+
dir = mkdtempSync(join(tmpdir(), 'team-ci-'))
|
|
163
|
+
execFileSync('git', ['init', '-q'], { cwd: dir })
|
|
164
|
+
writeFileSync(join(dir, 'CLAUDE.md'), '# Ours\n')
|
|
165
|
+
expect(run(dir, ['init', '--yes']).code).toBe(0)
|
|
166
|
+
})
|
|
167
|
+
afterEach(() => {
|
|
168
|
+
rmSync(dir, { recursive: true, force: true })
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it('annotates the drifted file and writes the run summary', () => {
|
|
172
|
+
const agent = join(dir, '.claude', 'agents', 'developer.agent.md')
|
|
173
|
+
expect(existsSync(agent)).toBe(true)
|
|
174
|
+
appendFileSync(agent, '\nedited in place\n')
|
|
175
|
+
const summary = join(dir, 'summary.md')
|
|
176
|
+
|
|
177
|
+
const r = run(dir, ['sync', '--check'], { GITHUB_ACTIONS: 'true', GITHUB_STEP_SUMMARY: summary, GITHUB_WORKSPACE: dir })
|
|
178
|
+
expect(r.code).toBe(1)
|
|
179
|
+
expect(r.out).toMatch(/::error file=\.claude\/agents\/developer\.agent\.md,title=Generated file differs from its source::/)
|
|
180
|
+
expect(readFileSync(summary, 'utf8')).toContain('`.claude/agents/developer.agent.md`')
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('keeps --json parseable', () => {
|
|
184
|
+
const r = run(dir, ['sync', '--check', '--json'], { GITHUB_ACTIONS: 'true' })
|
|
185
|
+
expect(r.code).toBe(0)
|
|
186
|
+
expect(() => JSON.parse(r.out)).not.toThrow()
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('prints no workflow commands anywhere else', () => {
|
|
190
|
+
appendFileSync(join(dir, '.claude', 'agents', 'developer.agent.md'), '\nedited\n')
|
|
191
|
+
const r = run(dir, ['sync', '--check'])
|
|
192
|
+
expect(r.code).toBe(1)
|
|
193
|
+
expect(r.out).not.toContain('::error')
|
|
194
|
+
})
|
|
195
|
+
})
|