opencastle 1.1.0 → 1.2.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 +23 -6
- package/bin/cli.mjs +6 -0
- package/dist/cli/adapters/codex.d.ts +19 -6
- package/dist/cli/adapters/codex.d.ts.map +1 -1
- package/dist/cli/adapters/codex.js +24 -7
- package/dist/cli/adapters/codex.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +7 -0
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +59 -22
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/agent-plugin.d.ts +119 -0
- package/dist/cli/agent-plugin.d.ts.map +1 -0
- package/dist/cli/agent-plugin.js +449 -0
- package/dist/cli/agent-plugin.js.map +1 -0
- package/dist/cli/agent-plugin.test.d.ts +2 -0
- package/dist/cli/agent-plugin.test.d.ts.map +1 -0
- package/dist/cli/agent-plugin.test.js +227 -0
- package/dist/cli/agent-plugin.test.js.map +1 -0
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +99 -26
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/codex-target.test.d.ts +2 -0
- package/dist/cli/codex-target.test.d.ts.map +1 -0
- package/dist/cli/codex-target.test.js +154 -0
- package/dist/cli/codex-target.test.js.map +1 -0
- package/dist/cli/convoy/gates.d.ts +2 -20
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +3 -111
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/copy.d.ts +0 -8
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +0 -21
- 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 +2 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +4 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +5 -4
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +58 -34
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +8 -0
- package/dist/cli/layers.d.ts.map +1 -1
- package/dist/cli/layers.js +130 -13
- package/dist/cli/layers.js.map +1 -1
- package/dist/cli/layers.test.js +2 -2
- package/dist/cli/layers.test.js.map +1 -1
- package/dist/cli/legacy-install.test.js +8 -1
- package/dist/cli/legacy-install.test.js.map +1 -1
- package/dist/cli/lesson-command.test.d.ts +2 -0
- package/dist/cli/lesson-command.test.d.ts.map +1 -0
- package/dist/cli/lesson-command.test.js +100 -0
- package/dist/cli/lesson-command.test.js.map +1 -0
- package/dist/cli/lesson.d.ts +0 -9
- package/dist/cli/lesson.d.ts.map +1 -1
- package/dist/cli/lesson.js +212 -276
- package/dist/cli/lesson.js.map +1 -1
- package/dist/cli/lessons.d.ts +134 -0
- package/dist/cli/lessons.d.ts.map +1 -0
- package/dist/cli/lessons.js +493 -0
- package/dist/cli/lessons.js.map +1 -0
- package/dist/cli/lessons.test.d.ts +2 -0
- package/dist/cli/lessons.test.d.ts.map +1 -0
- package/dist/cli/lessons.test.js +214 -0
- package/dist/cli/lessons.test.js.map +1 -0
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +2 -0
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts.map +1 -1
- package/dist/cli/mcp-audit.js +7 -3
- package/dist/cli/mcp-audit.js.map +1 -1
- package/dist/cli/mcp-file.d.ts +37 -0
- package/dist/cli/mcp-file.d.ts.map +1 -0
- package/dist/cli/mcp-file.js +291 -0
- package/dist/cli/mcp-file.js.map +1 -0
- package/dist/cli/mcp-file.test.d.ts +2 -0
- package/dist/cli/mcp-file.test.d.ts.map +1 -0
- package/dist/cli/mcp-file.test.js +121 -0
- package/dist/cli/mcp-file.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +15 -0
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +123 -56
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/pack-plugins.d.ts +8 -0
- package/dist/cli/pack-plugins.d.ts.map +1 -0
- package/dist/cli/pack-plugins.js +70 -0
- package/dist/cli/pack-plugins.js.map +1 -0
- package/dist/cli/plugin-command.test.d.ts +2 -0
- package/dist/cli/plugin-command.test.d.ts.map +1 -0
- package/dist/cli/plugin-command.test.js +114 -0
- package/dist/cli/plugin-command.test.js.map +1 -0
- package/dist/cli/plugin.d.ts +30 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +291 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/promote-command.test.d.ts +2 -0
- package/dist/cli/promote-command.test.d.ts.map +1 -0
- package/dist/cli/promote-command.test.js +151 -0
- package/dist/cli/promote-command.test.js.map +1 -0
- package/dist/cli/promote.d.ts +12 -0
- package/dist/cli/promote.d.ts.map +1 -0
- package/dist/cli/promote.js +364 -0
- package/dist/cli/promote.js.map +1 -0
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +23 -4
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/secret-scan.d.ts +21 -0
- package/dist/cli/secret-scan.d.ts.map +1 -0
- package/dist/cli/secret-scan.js +114 -0
- package/dist/cli/secret-scan.js.map +1 -0
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +13 -3
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +2 -2
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/team-commands.test.js +2 -2
- package/dist/cli/team-commands.test.js.map +1 -1
- package/dist/cli/types.d.ts +5 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js +3 -0
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/unreadable-report.d.ts +7 -0
- package/dist/cli/unreadable-report.d.ts.map +1 -1
- package/dist/cli/unreadable-report.js +14 -0
- package/dist/cli/unreadable-report.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +73 -5
- package/dist/cli/update.js.map +1 -1
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js +32 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js.map +1 -0
- package/package.json +3 -1
- package/src/cli/adapters/codex.ts +25 -7
- package/src/cli/adapters/single-file-base.ts +69 -26
- package/src/cli/agent-plugin.test.ts +267 -0
- package/src/cli/agent-plugin.ts +469 -0
- package/src/cli/baseline.ts +99 -26
- package/src/cli/codex-target.test.ts +178 -0
- package/src/cli/convoy/gates.ts +9 -142
- package/src/cli/copy.ts +0 -25
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +2 -0
- package/src/cli/doctor.ts +5 -2
- package/src/cli/fixtures/lessons-template-1.0.md +70 -0
- package/src/cli/init.test.ts +59 -34
- package/src/cli/init.ts +5 -4
- package/src/cli/layers.test.ts +2 -2
- package/src/cli/layers.ts +144 -14
- package/src/cli/legacy-install.test.ts +11 -1
- package/src/cli/lesson-command.test.ts +117 -0
- package/src/cli/lesson.ts +215 -266
- package/src/cli/lessons.test.ts +254 -0
- package/src/cli/lessons.ts +540 -0
- package/src/cli/managed-paths.ts +2 -0
- package/src/cli/mcp-audit.ts +7 -3
- package/src/cli/mcp-file.test.ts +138 -0
- package/src/cli/mcp-file.ts +302 -0
- package/src/cli/mcp.ts +130 -60
- package/src/cli/pack-plugins.ts +70 -0
- package/src/cli/plugin-command.test.ts +125 -0
- package/src/cli/plugin.ts +309 -0
- package/src/cli/promote-command.test.ts +170 -0
- package/src/cli/promote.ts +371 -0
- package/src/cli/remove.ts +20 -4
- package/src/cli/secret-scan.ts +154 -0
- package/src/cli/sync-check.test.ts +2 -2
- package/src/cli/sync-check.ts +13 -3
- package/src/cli/team-commands.test.ts +2 -2
- package/src/cli/types.ts +5 -2
- package/src/cli/unreadable-report.ts +14 -0
- package/src/cli/update.ts +81 -5
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/agents/researcher.agent.md +1 -1
- package/src/orchestrator/customizations/LESSONS-LEARNED.md +10 -66
- package/src/orchestrator/customizations/README.md +2 -1
- package/src/orchestrator/customizations/logs/README.md +1 -1
- package/src/orchestrator/plugins/agent-plugins.test.ts +34 -0
- package/src/orchestrator/plugins/astro/mcp.json +9 -0
- package/src/orchestrator/plugins/astro/plugin.json +21 -0
- package/src/orchestrator/plugins/chrome-devtools/mcp.json +13 -0
- package/src/orchestrator/plugins/chrome-devtools/plugin.json +21 -0
- package/src/orchestrator/plugins/cloudflare/mcp.json +9 -0
- package/src/orchestrator/plugins/cloudflare/plugin.json +21 -0
- package/src/orchestrator/plugins/contentful/mcp.json +13 -0
- package/src/orchestrator/plugins/contentful/plugin.json +21 -0
- package/src/orchestrator/plugins/convex/mcp.json +15 -0
- package/src/orchestrator/plugins/convex/plugin.json +21 -0
- package/src/orchestrator/plugins/coolify/mcp.json +13 -0
- package/src/orchestrator/plugins/coolify/plugin.json +25 -0
- package/src/orchestrator/plugins/cypress/plugin.json +21 -0
- package/src/orchestrator/plugins/drizzle/plugin.json +21 -0
- package/src/orchestrator/plugins/expo/mcp.json +9 -0
- package/src/orchestrator/plugins/expo/plugin.json +21 -0
- package/src/orchestrator/plugins/figma/mcp.json +9 -0
- package/src/orchestrator/plugins/figma/plugin.json +21 -0
- package/src/orchestrator/plugins/hetzner/plugin.json +24 -0
- package/src/orchestrator/plugins/jira/mcp.json +9 -0
- package/src/orchestrator/plugins/jira/plugin.json +21 -0
- package/src/orchestrator/plugins/linear/mcp.json +9 -0
- package/src/orchestrator/plugins/linear/plugin.json +21 -0
- package/src/orchestrator/plugins/netlify/mcp.json +13 -0
- package/src/orchestrator/plugins/netlify/plugin.json +21 -0
- package/src/orchestrator/plugins/nextjs/mcp.json +13 -0
- package/src/orchestrator/plugins/nextjs/plugin.json +21 -0
- package/src/orchestrator/plugins/notion/mcp.json +9 -0
- package/src/orchestrator/plugins/notion/plugin.json +21 -0
- package/src/orchestrator/plugins/nx/mcp.json +14 -0
- package/src/orchestrator/plugins/nx/plugin.json +21 -0
- package/src/orchestrator/plugins/playwright/mcp.json +13 -0
- package/src/orchestrator/plugins/playwright/plugin.json +21 -0
- package/src/orchestrator/plugins/prisma/mcp.json +14 -0
- package/src/orchestrator/plugins/prisma/plugin.json +21 -0
- package/src/orchestrator/plugins/resend/mcp.json +13 -0
- package/src/orchestrator/plugins/resend/plugin.json +24 -0
- package/src/orchestrator/plugins/sanity/mcp.json +9 -0
- package/src/orchestrator/plugins/sanity/plugin.json +21 -0
- package/src/orchestrator/plugins/sentry/mcp.json +12 -0
- package/src/orchestrator/plugins/sentry/plugin.json +24 -0
- package/src/orchestrator/plugins/slack/mcp.json +13 -0
- package/src/orchestrator/plugins/slack/plugin.json +24 -0
- package/src/orchestrator/plugins/strapi/mcp.json +13 -0
- package/src/orchestrator/plugins/strapi/plugin.json +21 -0
- package/src/orchestrator/plugins/stripe/mcp.json +9 -0
- package/src/orchestrator/plugins/stripe/plugin.json +21 -0
- package/src/orchestrator/plugins/supabase/mcp.json +9 -0
- package/src/orchestrator/plugins/supabase/plugin.json +21 -0
- package/src/orchestrator/plugins/teams/plugin.json +24 -0
- package/src/orchestrator/plugins/trello/mcp.json +13 -0
- package/src/orchestrator/plugins/trello/plugin.json +25 -0
- package/src/orchestrator/plugins/turborepo/plugin.json +21 -0
- package/src/orchestrator/plugins/vercel/mcp.json +9 -0
- package/src/orchestrator/plugins/vercel/plugin.json +21 -0
- package/src/orchestrator/plugins/vitest/plugin.json +21 -0
- package/src/orchestrator/skill-config-links.test.ts +2 -1
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +1 -1
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
- package/src/orchestrator/skills/memory-merger/SKILL.md +17 -21
- package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +44 -23
- package/src/orchestrator/skills/self-improvement/SKILL.md +30 -15
- /package/src/orchestrator/plugins/astro/{SKILL.md → skills/astro-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/chrome-devtools/{SKILL.md → skills/browser-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cloudflare/{SKILL.md → skills/cloudflare-platform/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/contentful/{SKILL.md → skills/contentful-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/convex/{SKILL.md → skills/convex-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/coolify/{SKILL.md → skills/coolify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cypress/{SKILL.md → skills/cypress-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/drizzle/{SKILL.md → skills/drizzle-orm/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/expo/{SKILL.md → skills/expo-development/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/figma/{SKILL.md → skills/figma-design/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/hetzner/{SKILL.md → skills/hetzner-cloud/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/jira/{SKILL.md → skills/jira-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/linear/{SKILL.md → skills/linear-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/netlify/{SKILL.md → skills/netlify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nextjs/{SKILL.md → skills/nextjs-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/notion/{SKILL.md → skills/notion-knowledge-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nx/{SKILL.md → skills/nx-workspace/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/playwright/{SKILL.md → skills/playwright-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/prisma/{SKILL.md → skills/prisma-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/resend/{SKILL.md → skills/resend-email/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sanity/{SKILL.md → skills/sanity-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sentry/{SKILL.md → skills/sentry-monitoring/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/slack/{SKILL.md → skills/slack-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/strapi/{SKILL.md → skills/strapi-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/stripe/{SKILL.md → skills/stripe-payments/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/supabase/{SKILL.md → skills/supabase-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/teams/{SKILL.md → skills/teams-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/trello/{SKILL.md → skills/trello-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/turborepo/{SKILL.md → skills/turborepo-monorepo/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vercel/{SKILL.md → skills/vercel-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vitest/{SKILL.md → skills/vitest-testing/SKILL.md} +0 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { parse as parseToml } from 'smol-toml';
|
|
2
|
+
/**
|
|
3
|
+
* Reading and writing an MCP config file in whatever language it is written in.
|
|
4
|
+
*
|
|
5
|
+
* Every target but one keeps its servers in JSON. Codex CLI keeps them in
|
|
6
|
+
* `.codex/config.toml`, beside the rest of the project's Codex settings, and
|
|
7
|
+
* OpenCastle wrote `.codex/mcp.json` — a file Codex has never read — so no
|
|
8
|
+
* integration or team server reached Codex at all. The merge, strip, audit and
|
|
9
|
+
* drift logic all work on a parsed object; this is the one place that knows a
|
|
10
|
+
* config can be TOML, so none of them has to.
|
|
11
|
+
*
|
|
12
|
+
* `config.toml` is co-owned the way `opencode.json` is: the user's model,
|
|
13
|
+
* approval and sandbox settings sit beside our servers. Re-serialising it whole
|
|
14
|
+
* would restyle it and drop every comment, so a TOML write changes only the
|
|
15
|
+
* `[mcp_servers.<name>]` tables whose value changed and leaves every other byte
|
|
16
|
+
* as it was.
|
|
17
|
+
*/
|
|
18
|
+
/** Thrown when a TOML config is shaped so that a change cannot be made without rewriting the user's text. */
|
|
19
|
+
export class TomlEditError extends Error {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = 'TomlEditError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function isTomlConfig(rel) {
|
|
26
|
+
return rel.endsWith('.toml');
|
|
27
|
+
}
|
|
28
|
+
/** Parse a config's text. Throws, as `JSON.parse` does, when it does not parse. */
|
|
29
|
+
export function parseMcpConfigText(text, rel) {
|
|
30
|
+
if (isTomlConfig(rel))
|
|
31
|
+
return plain(parseToml(text));
|
|
32
|
+
return JSON.parse(text);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The text to write for `value`, given what the file held before (`null` when
|
|
36
|
+
* it is being created).
|
|
37
|
+
*/
|
|
38
|
+
export function serialiseMcpConfig(before, value, rel) {
|
|
39
|
+
if (isTomlConfig(rel))
|
|
40
|
+
return writeToml(before ?? '', value);
|
|
41
|
+
return before === null ? JSON.stringify(value, null, 2) + '\n' : serialiseLike(before, value);
|
|
42
|
+
}
|
|
43
|
+
// ── JSON ──────────────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* The indentation a file already uses, so merging into it does not restyle it.
|
|
46
|
+
*
|
|
47
|
+
* `JSON.stringify(x, null, 2)` re-indented every co-owned config we touched. A
|
|
48
|
+
* hand-written tab-indented `opencode.json` — OpenCode's entire project config —
|
|
49
|
+
* came back two-space indented from a merge that added one key, and never came back
|
|
50
|
+
* from the uninstall at all: 111 bytes in, 114 out, for a strip that took nothing
|
|
51
|
+
* of theirs. Byte fidelity is a claim this tool makes about co-owned files, and a
|
|
52
|
+
* JSON config is one of those.
|
|
53
|
+
*
|
|
54
|
+
* Read from the first indented line, which is what every formatter agrees on.
|
|
55
|
+
* Falls back to two spaces for a file we are creating or one written on a single
|
|
56
|
+
* line, which is what this always did.
|
|
57
|
+
*/
|
|
58
|
+
function indentOf(text) {
|
|
59
|
+
const m = /\n([ \t]+)\S/.exec(text);
|
|
60
|
+
if (m)
|
|
61
|
+
return m[1].includes('\t') ? '\t' : m[1].length;
|
|
62
|
+
// A config written on one line has no indentation, and expanding it to three is
|
|
63
|
+
// as much a restyle as collapsing it would be. `0` is what `JSON.stringify` takes
|
|
64
|
+
// for "no whitespace".
|
|
65
|
+
return text.trim().includes('\n') ? 2 : 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Re-serialise a config the way the file was already written.
|
|
69
|
+
*
|
|
70
|
+
* Indentation and line endings both, because `JSON.stringify` emits `\n` whatever
|
|
71
|
+
* it was handed and a CRLF config came back LF from a merge that added one key.
|
|
72
|
+
* The same rule `.gitignore` follows: a CRLF file stays CRLF.
|
|
73
|
+
*/
|
|
74
|
+
export function serialiseLike(original, value) {
|
|
75
|
+
const text = JSON.stringify(value, null, indentOf(original)) + '\n';
|
|
76
|
+
return /\r\n/.test(original) ? text.replace(/\n/g, '\r\n') : text;
|
|
77
|
+
}
|
|
78
|
+
// ── TOML ──────────────────────────────────────────────────────
|
|
79
|
+
const SERVERS = 'mcp_servers';
|
|
80
|
+
/** smol-toml builds objects with no prototype; the rest of the code expects plain ones. */
|
|
81
|
+
function plain(value) {
|
|
82
|
+
if (Array.isArray(value))
|
|
83
|
+
return value.map(plain);
|
|
84
|
+
if (value && typeof value === 'object' && !(value instanceof Date)) {
|
|
85
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, plain(v)]));
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
/** Key order is not meaning. */
|
|
90
|
+
function canonical(value) {
|
|
91
|
+
return JSON.stringify(value, (_key, v) => v && typeof v === 'object' && !Array.isArray(v) && !(v instanceof Date)
|
|
92
|
+
? Object.fromEntries(Object.entries(v).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))
|
|
93
|
+
: v);
|
|
94
|
+
}
|
|
95
|
+
function tomlKey(key) {
|
|
96
|
+
return /^[A-Za-z0-9_-]+$/.test(key) ? key : tomlString(key);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A TOML basic string. JSON's escapes are TOML's, except that TOML also forbids
|
|
100
|
+
* a raw DEL, which JSON leaves alone.
|
|
101
|
+
*/
|
|
102
|
+
function tomlString(s) {
|
|
103
|
+
return JSON.stringify(s).replace(/\u007f/g, '\\u007F');
|
|
104
|
+
}
|
|
105
|
+
function tomlValue(value) {
|
|
106
|
+
if (typeof value === 'string')
|
|
107
|
+
return tomlString(value);
|
|
108
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
109
|
+
return String(value);
|
|
110
|
+
if (Array.isArray(value))
|
|
111
|
+
return `[${value.map(tomlValue).join(', ')}]`;
|
|
112
|
+
if (value && typeof value === 'object') {
|
|
113
|
+
const fields = Object.entries(value).filter(([, v]) => v !== undefined);
|
|
114
|
+
return fields.length === 0 ? '{}' : `{ ${fields.map(([k, v]) => `${tomlKey(k)} = ${tomlValue(v)}`).join(', ')} }`;
|
|
115
|
+
}
|
|
116
|
+
throw new TomlEditError(`cannot write ${String(value)} as TOML`);
|
|
117
|
+
}
|
|
118
|
+
/** One server as a `[mcp_servers.<key>]` table. */
|
|
119
|
+
function serverTable(key, entry, eol) {
|
|
120
|
+
const lines = [`[${SERVERS}.${tomlKey(key)}]`];
|
|
121
|
+
for (const [k, v] of Object.entries((entry ?? {}))) {
|
|
122
|
+
if (v === undefined)
|
|
123
|
+
continue;
|
|
124
|
+
lines.push(`${tomlKey(k)} = ${tomlValue(v)}`);
|
|
125
|
+
}
|
|
126
|
+
return lines.join(eol) + eol;
|
|
127
|
+
}
|
|
128
|
+
const HEADER = /^[ \t]*\[\[?[ \t]*(.+?)[ \t]*\]\]?[ \t]*(?:#.*)?\r?\n?$/;
|
|
129
|
+
/** Split a dotted key into its parts, unquoting quoted ones. */
|
|
130
|
+
function splitKey(key) {
|
|
131
|
+
const parts = [];
|
|
132
|
+
let current = '';
|
|
133
|
+
let quote = null;
|
|
134
|
+
for (let i = 0; i < key.length; i++) {
|
|
135
|
+
const ch = key[i];
|
|
136
|
+
if (quote) {
|
|
137
|
+
if (ch === '\\' && quote === '"') {
|
|
138
|
+
current += key[++i] ?? '';
|
|
139
|
+
}
|
|
140
|
+
else if (ch === quote) {
|
|
141
|
+
quote = null;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
current += ch;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (ch === '"' || ch === "'") {
|
|
148
|
+
quote = ch;
|
|
149
|
+
}
|
|
150
|
+
else if (ch === '.') {
|
|
151
|
+
parts.push(current.trim());
|
|
152
|
+
current = '';
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
current += ch;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
parts.push(current.trim());
|
|
159
|
+
return parts;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The file as runs of lines, one per table.
|
|
163
|
+
*
|
|
164
|
+
* A line that looks like a header inside a multi-line string is not one; the
|
|
165
|
+
* string delimiters are tracked so it stays with the table it belongs to. Odd
|
|
166
|
+
* layouts this misreads are caught afterwards: every write is parsed back and
|
|
167
|
+
* compared with what was meant.
|
|
168
|
+
*/
|
|
169
|
+
function segments(text) {
|
|
170
|
+
const lines = text.split(/(?<=\n)/);
|
|
171
|
+
const out = [{ path: null, lines: [] }];
|
|
172
|
+
let open = null;
|
|
173
|
+
for (const line of lines) {
|
|
174
|
+
if (!open) {
|
|
175
|
+
const header = HEADER.exec(line);
|
|
176
|
+
if (header && !line.trimStart().startsWith('#')) {
|
|
177
|
+
out.push({ path: splitKey(header[1]), lines: [line] });
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
out[out.length - 1].lines.push(line);
|
|
182
|
+
for (const m of line.matchAll(/"""|'''/g)) {
|
|
183
|
+
if (!open)
|
|
184
|
+
open = m[0];
|
|
185
|
+
else if (open === m[0])
|
|
186
|
+
open = null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
/** The blank and comment lines a segment ends with — they introduce whatever follows it. */
|
|
192
|
+
function tailOf(seg) {
|
|
193
|
+
const tail = [];
|
|
194
|
+
for (let i = seg.lines.length - 1; i > 0; i--) {
|
|
195
|
+
const t = seg.lines[i].trim();
|
|
196
|
+
if (t === '' || t.startsWith('#'))
|
|
197
|
+
tail.unshift(seg.lines[i]);
|
|
198
|
+
else
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
return tail;
|
|
202
|
+
}
|
|
203
|
+
function serverOf(seg) {
|
|
204
|
+
return seg.path && seg.path[0] === SERVERS && seg.path.length >= 2 ? seg.path[1] : undefined;
|
|
205
|
+
}
|
|
206
|
+
function without(value, key) {
|
|
207
|
+
const { [key]: _drop, ...rest } = value;
|
|
208
|
+
return rest;
|
|
209
|
+
}
|
|
210
|
+
/** An empty `[mcp_servers]` and none at all say the same thing to Codex. */
|
|
211
|
+
function normalised(value) {
|
|
212
|
+
const v = value;
|
|
213
|
+
const servers = v[SERVERS];
|
|
214
|
+
return servers && typeof servers === 'object' && Object.keys(servers).length === 0 ? without(v, SERVERS) : v;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Write `value` over `before`, touching only the server tables that changed.
|
|
218
|
+
*
|
|
219
|
+
* Everything outside `[mcp_servers]` must be what the file already says —
|
|
220
|
+
* OpenCastle never edits a user's Codex settings — and the result is parsed
|
|
221
|
+
* back before it is returned, so a layout this cannot edit cleanly is refused
|
|
222
|
+
* rather than written wrong.
|
|
223
|
+
*/
|
|
224
|
+
function writeToml(before, value) {
|
|
225
|
+
const eol = /\r\n/.test(before) ? '\r\n' : '\n';
|
|
226
|
+
const old = (before.trim() === '' ? {} : plain(parseToml(before)));
|
|
227
|
+
if (canonical(without(old, SERVERS)) !== canonical(without(value, SERVERS))) {
|
|
228
|
+
throw new TomlEditError('only the [mcp_servers] tables of a Codex config are ours to change');
|
|
229
|
+
}
|
|
230
|
+
const oldServers = (old[SERVERS] ?? {});
|
|
231
|
+
const newServers = (value[SERVERS] ?? {});
|
|
232
|
+
const out = [];
|
|
233
|
+
const rewritten = new Set();
|
|
234
|
+
// Whether the file now ends where a dropped table used to be. The blank line
|
|
235
|
+
// that separated our first table from the user's last one was ours, written
|
|
236
|
+
// when we appended; left behind, an install and uninstall would not give the
|
|
237
|
+
// user back their file byte for byte.
|
|
238
|
+
let endsOnDrop = false;
|
|
239
|
+
for (const seg of segments(before)) {
|
|
240
|
+
const key = serverOf(seg);
|
|
241
|
+
if (key === undefined) {
|
|
242
|
+
out.push(...seg.lines);
|
|
243
|
+
endsOnDrop = false;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const tail = tailOf(seg);
|
|
247
|
+
if (!(key in newServers)) {
|
|
248
|
+
// A comment before the next table is about that table; keep it.
|
|
249
|
+
if (tail.some((l) => l.trim().startsWith('#')))
|
|
250
|
+
out.push(...tail);
|
|
251
|
+
endsOnDrop = true;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
endsOnDrop = false;
|
|
255
|
+
if (canonical(oldServers[key]) === canonical(newServers[key])) {
|
|
256
|
+
out.push(...seg.lines);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
// A changed server is written whole at its first table; its sub-tables go.
|
|
260
|
+
if (rewritten.has(key)) {
|
|
261
|
+
if (tail.some((l) => l.trim().startsWith('#')))
|
|
262
|
+
out.push(...tail);
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
rewritten.add(key);
|
|
266
|
+
out.push(serverTable(key, newServers[key], eol), ...tail);
|
|
267
|
+
}
|
|
268
|
+
let text = out.join('');
|
|
269
|
+
if (endsOnDrop)
|
|
270
|
+
text = text.trim() === '' ? '' : text.replace(/(\r?\n)+$/, eol);
|
|
271
|
+
const added = Object.keys(newServers).filter((k) => !(k in oldServers));
|
|
272
|
+
if (added.length > 0) {
|
|
273
|
+
if (text !== '' && !text.endsWith('\n'))
|
|
274
|
+
text += eol;
|
|
275
|
+
if (text.trim() !== '' && !/(\r?\n){2}$/.test(text))
|
|
276
|
+
text += eol;
|
|
277
|
+
text += added.map((k) => serverTable(k, newServers[k], eol)).join(eol);
|
|
278
|
+
}
|
|
279
|
+
let check;
|
|
280
|
+
try {
|
|
281
|
+
check = plain(parseToml(text));
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
throw new TomlEditError(`the edit would not parse — ${err.message}`);
|
|
285
|
+
}
|
|
286
|
+
if (canonical(normalised(check)) !== canonical(normalised(value))) {
|
|
287
|
+
throw new TomlEditError('its [mcp_servers] are written in a way this cannot edit line by line, e.g. as inline tables');
|
|
288
|
+
}
|
|
289
|
+
return text;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=mcp-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-file.js","sourceRoot":"","sources":["../../src/cli/mcp-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAE9C;;;;;;;;;;;;;;;GAeG;AAEH,6GAA6G;AAC7G,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF;AAED,MA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C,CAAA;IACxE,CAAC;IAED,IAAI,KAAc,CAAA;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAChC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,aAAa,CAAC,8BAA+B,GAAa,CAAC,OAAO,EAAE,CAAC,CAAA;IACjF,CAAC;IACD,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,aAAa,CAAC,6FAA6F,CAAC,CAAA;IACxH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-file.test.d.ts","sourceRoot":"","sources":["../../src/cli/mcp-file.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { parse as parseToml } from 'smol-toml';
|
|
3
|
+
import { parseMcpConfigText, serialiseMcpConfig, TomlEditError } from './mcp-file.js';
|
|
4
|
+
/**
|
|
5
|
+
* `.codex/config.toml` holds a user's whole Codex setup — model, approvals,
|
|
6
|
+
* sandbox, profiles — beside the MCP servers OpenCastle writes. These pin the
|
|
7
|
+
* promise the JSON configs already keep: our servers change, nothing of theirs
|
|
8
|
+
* does, byte for byte.
|
|
9
|
+
*/
|
|
10
|
+
const REL = '.codex/config.toml';
|
|
11
|
+
const USERS_OWN = `# My Codex setup
|
|
12
|
+
model = "gpt-5-codex"
|
|
13
|
+
approval_policy = "on-request"
|
|
14
|
+
|
|
15
|
+
[profiles.fast]
|
|
16
|
+
model = "gpt-5-codex-mini" # quick tasks
|
|
17
|
+
|
|
18
|
+
[mcp_servers.mine]
|
|
19
|
+
command = "my-server"
|
|
20
|
+
args = ["--port", "1234"]
|
|
21
|
+
|
|
22
|
+
[mcp_servers.mine.tools.dangerous]
|
|
23
|
+
approval_mode = "approve"
|
|
24
|
+
`;
|
|
25
|
+
function serversOf(text) {
|
|
26
|
+
return parseToml(text).mcp_servers ?? {};
|
|
27
|
+
}
|
|
28
|
+
describe('Codex config.toml', () => {
|
|
29
|
+
it('parses to a plain object with mcp_servers as the container', () => {
|
|
30
|
+
const parsed = parseMcpConfigText(USERS_OWN, REL);
|
|
31
|
+
expect(Object.getPrototypeOf(parsed)).toBe(Object.prototype);
|
|
32
|
+
expect(Object.keys(parsed.mcp_servers)).toEqual(['mine']);
|
|
33
|
+
});
|
|
34
|
+
it('adds a server after the user’s content and changes nothing of theirs', () => {
|
|
35
|
+
const value = parseMcpConfigText(USERS_OWN, REL);
|
|
36
|
+
value.mcp_servers.Linear = { url: 'https://mcp.linear.app/mcp' };
|
|
37
|
+
const text = serialiseMcpConfig(USERS_OWN, value, REL);
|
|
38
|
+
expect(text.startsWith(USERS_OWN)).toBe(true);
|
|
39
|
+
expect(text.slice(USERS_OWN.length)).toBe('\n[mcp_servers.Linear]\nurl = "https://mcp.linear.app/mcp"\n');
|
|
40
|
+
});
|
|
41
|
+
it('removes only the server it was asked to, with its sub-tables', () => {
|
|
42
|
+
const withOurs = USERS_OWN + '\n[mcp_servers.Sanity]\ncommand = "npx"\nargs = ["-y", "@sanity/mcp-server@1.2.3"]\n';
|
|
43
|
+
const value = parseMcpConfigText(withOurs, REL);
|
|
44
|
+
delete value.mcp_servers.Sanity;
|
|
45
|
+
expect(serialiseMcpConfig(withOurs, value, REL)).toBe(USERS_OWN);
|
|
46
|
+
});
|
|
47
|
+
it('gives the user their file back byte for byte after an add and a remove', () => {
|
|
48
|
+
const value = parseMcpConfigText(USERS_OWN, REL);
|
|
49
|
+
value.mcp_servers.Linear = { url: 'https://mcp.linear.app/mcp' };
|
|
50
|
+
const added = serialiseMcpConfig(USERS_OWN, value, REL);
|
|
51
|
+
const back = parseMcpConfigText(added, REL);
|
|
52
|
+
delete back.mcp_servers.Linear;
|
|
53
|
+
expect(serialiseMcpConfig(added, back, REL)).toBe(USERS_OWN);
|
|
54
|
+
});
|
|
55
|
+
it('rewrites a changed server in place and keeps the tables around it', () => {
|
|
56
|
+
const before = 'model = "x"\n\n[mcp_servers.Sentry]\nurl = "https://old.example/mcp"\n\n[profiles.a]\nmodel = "y"\n';
|
|
57
|
+
const value = parseMcpConfigText(before, REL);
|
|
58
|
+
value.mcp_servers.Sentry = { url: 'https://mcp.sentry.dev/mcp' };
|
|
59
|
+
const text = serialiseMcpConfig(before, value, REL);
|
|
60
|
+
expect(text).toBe('model = "x"\n\n[mcp_servers.Sentry]\nurl = "https://mcp.sentry.dev/mcp"\n\n[profiles.a]\nmodel = "y"\n');
|
|
61
|
+
});
|
|
62
|
+
it('quotes a server name that is not a bare key', () => {
|
|
63
|
+
const value = { mcp_servers: { 'Chrome DevTools': { command: 'npx', args: ['chrome-devtools-mcp@0.1.0'] } } };
|
|
64
|
+
const text = serialiseMcpConfig(null, value, REL);
|
|
65
|
+
expect(text).toContain('[mcp_servers."Chrome DevTools"]');
|
|
66
|
+
expect(serversOf(text)).toEqual(value.mcp_servers);
|
|
67
|
+
});
|
|
68
|
+
it('writes env, env_vars and headers as values Codex reads back the same', () => {
|
|
69
|
+
const entry = {
|
|
70
|
+
url: 'https://api.example.com/mcp',
|
|
71
|
+
bearer_token_env_var: 'EXAMPLE_TOKEN',
|
|
72
|
+
http_headers: { 'X-Tenant': 'acme' },
|
|
73
|
+
env_http_headers: { 'X-Key': 'EXAMPLE_KEY' },
|
|
74
|
+
};
|
|
75
|
+
const stdio = { command: 'npx', args: ['-y', 'x@1.0.0'], env: { MODE: 'ci "quoted"\\path' }, env_vars: ['API_TOKEN'] };
|
|
76
|
+
const value = { mcp_servers: { remote: entry, local: stdio } };
|
|
77
|
+
const text = serialiseMcpConfig(null, value, REL);
|
|
78
|
+
expect(serversOf(text)).toEqual(value.mcp_servers);
|
|
79
|
+
});
|
|
80
|
+
it('keeps CRLF line endings', () => {
|
|
81
|
+
const before = USERS_OWN.replace(/\n/g, '\r\n');
|
|
82
|
+
const value = parseMcpConfigText(before, REL);
|
|
83
|
+
value.mcp_servers.Linear = { url: 'https://mcp.linear.app/mcp' };
|
|
84
|
+
const text = serialiseMcpConfig(before, value, REL);
|
|
85
|
+
expect(text.startsWith(before)).toBe(true);
|
|
86
|
+
expect(text.replace(/\r\n/g, '')).not.toContain('\n');
|
|
87
|
+
});
|
|
88
|
+
it('does not mistake a header-like line inside a multi-line string for a table', () => {
|
|
89
|
+
const before = 'instructions = """\n[mcp_servers.fake]\nnot a table\n"""\n\n[mcp_servers.real]\ncommand = "a"\n';
|
|
90
|
+
const value = parseMcpConfigText(before, REL);
|
|
91
|
+
value.mcp_servers.real = { command: 'b' };
|
|
92
|
+
const text = serialiseMcpConfig(before, value, REL);
|
|
93
|
+
expect(text).toContain('[mcp_servers.fake]\nnot a table');
|
|
94
|
+
expect(serversOf(text)).toEqual({ real: { command: 'b' } });
|
|
95
|
+
});
|
|
96
|
+
it('refuses rather than rewrites servers written as inline tables', () => {
|
|
97
|
+
const before = '[mcp_servers]\nmine = { command = "a" }\n';
|
|
98
|
+
const value = parseMcpConfigText(before, REL);
|
|
99
|
+
value.mcp_servers.mine = { command: 'b' };
|
|
100
|
+
expect(() => serialiseMcpConfig(before, value, REL)).toThrow(TomlEditError);
|
|
101
|
+
});
|
|
102
|
+
it('refuses to change anything outside [mcp_servers]', () => {
|
|
103
|
+
const value = parseMcpConfigText(USERS_OWN, REL);
|
|
104
|
+
value.model = 'something-else';
|
|
105
|
+
expect(() => serialiseMcpConfig(USERS_OWN, value, REL)).toThrow(TomlEditError);
|
|
106
|
+
});
|
|
107
|
+
it('leaves no [mcp_servers] residue when the last of ours goes', () => {
|
|
108
|
+
const before = 'model = "x"\n\n[mcp_servers.Linear]\nurl = "https://mcp.linear.app/mcp"\n';
|
|
109
|
+
const value = parseMcpConfigText(before, REL);
|
|
110
|
+
delete value.mcp_servers;
|
|
111
|
+
expect(serialiseMcpConfig(before, value, REL)).toBe('model = "x"\n');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe('JSON configs are untouched by the TOML path', () => {
|
|
115
|
+
it('keeps the file’s indentation', () => {
|
|
116
|
+
const before = '{\n\t"mcpServers": {}\n}\n';
|
|
117
|
+
const text = serialiseMcpConfig(before, { mcpServers: { a: { command: 'x' } } }, '.mcp.json');
|
|
118
|
+
expect(text).toBe('{\n\t"mcpServers": {\n\t\t"a": {\n\t\t\t"command": "x"\n\t\t}\n\t}\n}\n');
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=mcp-file.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-file.test.js","sourceRoot":"","sources":["../../src/cli/mcp-file.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAErF;;;;;GAKG;AAEH,MAAM,GAAG,GAAG,oBAAoB,CAAA;AAEhC,MAAM,SAAS,GAAG;;;;;;;;;;;;;CAajB,CAAA;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAQ,SAAS,CAAC,IAAI,CAA+C,CAAC,WAAW,IAAI,EAAE,CAAA;AACzF,CAAC;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QACjD,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;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G,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAChF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,MAAM,GAAG,2EAA2E,CAAA;QAC1F,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAC7C,OAAO,KAAK,CAAC,WAAW,CAAA;QACxB,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IACtE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;IAC3D,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,MAAM,GAAG,4BAA4B,CAAA;QAC3C,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,WAAW,CAAC,CAAA;QAC7F,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/cli/mcp.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { type TeamMcpServer } from './team-config.js';
|
|
|
15
15
|
* syntax is confirmed.
|
|
16
16
|
*/
|
|
17
17
|
export declare function envRef(ide: IdeChoice, name: string): string;
|
|
18
|
+
export declare function containerKeyFor(ide: IdeChoice): string;
|
|
18
19
|
/** Key order is not meaning: compare two parsed JSON values as values. */
|
|
19
20
|
export declare function canonicalJson(value: unknown): string;
|
|
20
21
|
/**
|
|
@@ -112,6 +113,20 @@ teamKeys?: string[],
|
|
|
112
113
|
/** VS Code inputs those servers asked for. */
|
|
113
114
|
teamInputs?: string[]): boolean;
|
|
114
115
|
export declare function stripManagedMcpServers(projectRoot: string, ide: IdeChoice, createdByUs?: boolean, teamKeys?: string[], teamInputs?: string[]): Promise<'deleted' | 'stripped' | 'absent' | 'unreadable'>;
|
|
116
|
+
/**
|
|
117
|
+
* MCP configs a release before this one wrote where the assistant never looks.
|
|
118
|
+
*
|
|
119
|
+
* Codex CLI reads project servers only from `.codex/config.toml`; the
|
|
120
|
+
* `.codex/mcp.json` OpenCastle wrote for it was never loaded, so every server
|
|
121
|
+
* in it was one Codex did not have.
|
|
122
|
+
*/
|
|
123
|
+
export declare const LEGACY_MCP_CONFIGS: Partial<Record<IdeChoice, string>>;
|
|
124
|
+
/**
|
|
125
|
+
* Take our servers back out of a target's legacy MCP config, and delete it if
|
|
126
|
+
* we created it and nothing of the user's is left. Anything they added stays —
|
|
127
|
+
* it never reached the assistant either, and `sync` says where it belongs.
|
|
128
|
+
*/
|
|
129
|
+
export declare function retireLegacyMcpConfig(projectRoot: string, ide: IdeChoice, createdByUs?: boolean, teamKeys?: string[], teamInputs?: string[]): Promise<'deleted' | 'stripped' | 'absent' | 'unreadable'>;
|
|
115
130
|
export interface RebuildOutcome {
|
|
116
131
|
/** Integration servers moved to the current default. */
|
|
117
132
|
upgraded: string[];
|
package/dist/cli/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/cli/mcp.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAsC,MAAM,kCAAkC,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":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