fix(plugins): load Codex MCP server from root config
This commit is contained in:
@@ -16,17 +16,7 @@
|
|||||||
"mcp-server"
|
"mcp-server"
|
||||||
],
|
],
|
||||||
"skills": "./skills",
|
"skills": "./skills",
|
||||||
"mcpServers": {
|
"mcpServers": "./.mcp.json",
|
||||||
"rea": {
|
|
||||||
"command": "node",
|
|
||||||
"args": [
|
|
||||||
"./scripts/plugin-mcp-launcher.mjs",
|
|
||||||
"rea-agents@6.4.0"
|
|
||||||
],
|
|
||||||
"startup_timeout_sec": 30,
|
|
||||||
"cwd": "."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"interface": {
|
"interface": {
|
||||||
"displayName": "REA",
|
"displayName": "REA",
|
||||||
"shortDescription": "Reverse engineer anything with agents",
|
"shortDescription": "Reverse engineer anything with agents",
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"rea": {
|
||||||
|
"command": "node",
|
||||||
|
"args": [
|
||||||
|
"./scripts/plugin-mcp-launcher.mjs",
|
||||||
|
"rea-agents@6.4.0"
|
||||||
|
],
|
||||||
|
"cwd": "."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-1
@@ -242,7 +242,9 @@ tag remains in main's ancestry. Keep the released tag unchanged.
|
|||||||
The synchronization must include `.release-please-manifest.json`,
|
The synchronization must include `.release-please-manifest.json`,
|
||||||
`package.json`, both root versions in `package-lock.json`, `CHANGELOG.md`,
|
`package.json`, both root versions in `package-lock.json`, `CHANGELOG.md`,
|
||||||
`server.json`, both plugin manifests (`.claude-plugin/plugin.json` and
|
`server.json`, both plugin manifests (`.claude-plugin/plugin.json` and
|
||||||
`.codex-plugin/plugin.json`), and the versioned documentation examples. Run
|
`.codex-plugin/plugin.json`), the Codex server declaration (`.mcp.json`), both
|
||||||
|
marketplaces (`.claude-plugin/marketplace.json` and
|
||||||
|
`.agents/plugins/marketplace.json`), and the versioned documentation examples. Run
|
||||||
`npm run docs:generate`, `npm run docs:check`, and the release configuration
|
`npm run docs:generate`, `npm run docs:check`, and the release configuration
|
||||||
tests against the combined tree. After the merge, verify that the released
|
tests against the combined tree. After the merge, verify that the released
|
||||||
tag is an ancestor of main:
|
tag is an ancestor of main:
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
"scripts/prepare.mjs",
|
"scripts/prepare.mjs",
|
||||||
".claude-plugin/plugin.json",
|
".claude-plugin/plugin.json",
|
||||||
".codex-plugin/plugin.json",
|
".codex-plugin/plugin.json",
|
||||||
|
".mcp.json",
|
||||||
"skills",
|
"skills",
|
||||||
"README.md",
|
"README.md",
|
||||||
"DISCLAIMER.md",
|
"DISCLAIMER.md",
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "json",
|
"type": "json",
|
||||||
"path": ".codex-plugin/plugin.json",
|
"path": ".mcp.json",
|
||||||
"jsonpath": "$.mcpServers.rea.args[1]"
|
"jsonpath": "$.mcpServers.rea.args[1]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import { mkdtemp, rm } from "node:fs/promises";
|
import { access, mkdtemp, rm } from "node:fs/promises";
|
||||||
import { constants, tmpdir } from "node:os";
|
import { constants, tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
import { packageRunnerCommand } from "./lib/packageRunnerCommand.mjs";
|
import { packageRunnerCommand } from "./lib/packageRunnerCommand.mjs";
|
||||||
|
|
||||||
@@ -26,6 +27,32 @@ if (
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function launch(packageSpecifier) {
|
async function launch(packageSpecifier) {
|
||||||
|
// npm installs already carry the release-pinned runtime. Run it in this
|
||||||
|
// process so the plugin keeps the caller's working directory and the
|
||||||
|
// runtime retains ownership of provider and worker cleanup.
|
||||||
|
const { default: bundledPackage } = await import("../package.json", {
|
||||||
|
with: { type: "json" },
|
||||||
|
});
|
||||||
|
let bundledRuntimeMatchesPin =
|
||||||
|
packageSpecifier === `${bundledPackage.name}@${bundledPackage.version}`;
|
||||||
|
if (bundledRuntimeMatchesPin) {
|
||||||
|
try {
|
||||||
|
await access(new URL("../dist/mcp/main.js", import.meta.url));
|
||||||
|
} catch (cause) {
|
||||||
|
if (!isMissing(cause)) throw cause;
|
||||||
|
bundledRuntimeMatchesPin = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bundledRuntimeMatchesPin) {
|
||||||
|
process.argv = [
|
||||||
|
process.execPath,
|
||||||
|
fileURLToPath(new URL("./rea.mjs", import.meta.url)),
|
||||||
|
"mcp",
|
||||||
|
];
|
||||||
|
await import("./rea.mjs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const [command, ...args] = packageRunnerCommand(
|
const [command, ...args] = packageRunnerCommand(
|
||||||
"npx",
|
"npx",
|
||||||
packageSpecifier,
|
packageSpecifier,
|
||||||
@@ -93,3 +120,12 @@ async function launch(packageSpecifier) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isMissing(cause) {
|
||||||
|
return (
|
||||||
|
typeof cause === "object" &&
|
||||||
|
cause !== null &&
|
||||||
|
"code" in cause &&
|
||||||
|
cause.code === "ENOENT"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,21 +71,38 @@ export async function verifyPackagePack({ root, workspace }) {
|
|||||||
const manifest = JSON.parse(
|
const manifest = JSON.parse(
|
||||||
(await exec("tar", ["-xOf", tarball, `package/${path}`])).stdout,
|
(await exec("tar", ["-xOf", tarball, `package/${path}`])).stdout,
|
||||||
);
|
);
|
||||||
|
const serverConfig = path.startsWith(".codex")
|
||||||
|
? JSON.parse(
|
||||||
|
(
|
||||||
|
await exec("tar", [
|
||||||
|
"-xOf",
|
||||||
|
tarball,
|
||||||
|
"package/.mcp.json",
|
||||||
|
])
|
||||||
|
).stdout,
|
||||||
|
)
|
||||||
|
: manifest;
|
||||||
|
const expectedArgs = [
|
||||||
|
`${path.startsWith(".claude") ? "${CLAUDE_PLUGIN_ROOT}/" : "./"}scripts/plugin-mcp-launcher.mjs`,
|
||||||
|
`${packedManifest.name}@${packedManifest.version}`,
|
||||||
|
];
|
||||||
if (
|
if (
|
||||||
manifest.version !== packedManifest.version ||
|
manifest.version !== packedManifest.version ||
|
||||||
manifest.skills !== "./skills" ||
|
manifest.skills !== "./skills" ||
|
||||||
manifest.mcpServers?.rea?.command !== "node" ||
|
(path.startsWith(".codex")
|
||||||
(path.startsWith(".codex") && manifest.mcpServers?.rea?.cwd !== ".") ||
|
? manifest.mcpServers !== "./.mcp.json" ||
|
||||||
JSON.stringify(manifest.mcpServers?.rea?.args) !==
|
serverConfig.mcpServers?.rea?.cwd !== "."
|
||||||
JSON.stringify([
|
: false) ||
|
||||||
`${path.startsWith(".claude") ? "${CLAUDE_PLUGIN_ROOT}/" : "./"}scripts/plugin-mcp-launcher.mjs`,
|
serverConfig.mcpServers?.rea?.command !== "node" ||
|
||||||
`${packedManifest.name}@${packedManifest.version}`,
|
JSON.stringify(serverConfig.mcpServers?.rea?.args) !==
|
||||||
])
|
JSON.stringify(expectedArgs)
|
||||||
)
|
)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Packaged plugin ${path} does not match the exact runtime and canonical skill release`,
|
`Packaged plugin ${path} does not match the exact runtime and canonical skill release`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (!packedFiles.includes("package/.mcp.json"))
|
||||||
|
throw new Error("Packaged Codex MCP server declaration is missing");
|
||||||
for (const path of [
|
for (const path of [
|
||||||
"scripts/plugin-mcp-launcher.mjs",
|
"scripts/plugin-mcp-launcher.mjs",
|
||||||
"scripts/lib/packageRunnerCommand.mjs",
|
"scripts/lib/packageRunnerCommand.mjs",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const launcher = fileURLToPath(
|
|||||||
new URL("../../../scripts/plugin-mcp-launcher.mjs", import.meta.url),
|
new URL("../../../scripts/plugin-mcp-launcher.mjs", import.meta.url),
|
||||||
);
|
);
|
||||||
|
|
||||||
const start = (path: string, packageSpecifier = "rea-agents@6.4.0") => {
|
const start = (path: string, packageSpecifier = "rea-agents@6.4.0-rc.1") => {
|
||||||
const child = spawn(process.execPath, [launcher, packageSpecifier], {
|
const child = spawn(process.execPath, [launcher, packageSpecifier], {
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const pluginManifests = [
|
|||||||
".claude-plugin/plugin.json",
|
".claude-plugin/plugin.json",
|
||||||
".codex-plugin/plugin.json",
|
".codex-plugin/plugin.json",
|
||||||
] as const;
|
] as const;
|
||||||
|
const pluginServerConfig = ".mcp.json";
|
||||||
|
|
||||||
describe("release configuration", () => {
|
describe("release configuration", () => {
|
||||||
it("keeps doctor and setup runtime support aligned with package engines", async () => {
|
it("keeps doctor and setup runtime support aligned with package engines", async () => {
|
||||||
@@ -54,13 +55,16 @@ describe("release configuration", () => {
|
|||||||
path: "server.json",
|
path: "server.json",
|
||||||
jsonpath: "$.packages[0].version",
|
jsonpath: "$.packages[0].version",
|
||||||
},
|
},
|
||||||
...pluginManifests.flatMap((path) =>
|
...pluginManifests.map((path) => ({
|
||||||
["$.version", "$.mcpServers.rea.args[1]"].map((jsonpath) => ({
|
type: "json",
|
||||||
type: "json",
|
path,
|
||||||
path,
|
jsonpath: "$.version",
|
||||||
jsonpath,
|
})),
|
||||||
})),
|
{
|
||||||
),
|
type: "json",
|
||||||
|
path: pluginServerConfig,
|
||||||
|
jsonpath: "$.mcpServers.rea.args[1]",
|
||||||
|
},
|
||||||
...[
|
...[
|
||||||
".claude-plugin/marketplace.json",
|
".claude-plugin/marketplace.json",
|
||||||
".agents/plugins/marketplace.json",
|
".agents/plugins/marketplace.json",
|
||||||
@@ -164,7 +168,11 @@ describe("plugin manifests", () => {
|
|||||||
files: string[];
|
files: string[];
|
||||||
};
|
};
|
||||||
expect(pkg.files).toEqual(
|
expect(pkg.files).toEqual(
|
||||||
expect.arrayContaining([...pluginManifests, "skills"]),
|
expect.arrayContaining([
|
||||||
|
...pluginManifests,
|
||||||
|
pluginServerConfig,
|
||||||
|
"skills",
|
||||||
|
]),
|
||||||
);
|
);
|
||||||
for (const path of pluginManifests)
|
for (const path of pluginManifests)
|
||||||
expect(await readJson(path)).toMatchObject({ skills: "./skills" });
|
expect(await readJson(path)).toMatchObject({ skills: "./skills" });
|
||||||
@@ -186,7 +194,7 @@ describe("plugin manifests", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each(pluginManifests)(
|
it.each(pluginManifests)(
|
||||||
"pins the plugin manifest %s and its server launch to the package version",
|
"pins the plugin manifest %s and Codex's server config path",
|
||||||
async (path) => {
|
async (path) => {
|
||||||
const packageJson = (await readJson("package.json")) as {
|
const packageJson = (await readJson("package.json")) as {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -195,20 +203,33 @@ describe("plugin manifests", () => {
|
|||||||
|
|
||||||
expect(await readJson(path)).toMatchObject({
|
expect(await readJson(path)).toMatchObject({
|
||||||
version: packageJson.version,
|
version: packageJson.version,
|
||||||
mcpServers: {
|
...(path.startsWith(".codex")
|
||||||
rea: {
|
? { mcpServers: `./${pluginServerConfig}` }
|
||||||
command: "node",
|
: {}),
|
||||||
args: [
|
|
||||||
`${path.startsWith(".claude") ? "${CLAUDE_PLUGIN_ROOT}/" : "./"}scripts/plugin-mcp-launcher.mjs`,
|
|
||||||
`${packageJson.name}@${packageJson.version}`,
|
|
||||||
],
|
|
||||||
...(path.startsWith(".codex") ? { cwd: "." } : {}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it("pins the plugin server launch from the shared MCP declaration", async () => {
|
||||||
|
const packageJson = (await readJson("package.json")) as {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(await readJson(pluginServerConfig)).toMatchObject({
|
||||||
|
mcpServers: {
|
||||||
|
rea: {
|
||||||
|
command: "node",
|
||||||
|
args: [
|
||||||
|
"./scripts/plugin-mcp-launcher.mjs",
|
||||||
|
`${packageJson.name}@${packageJson.version}`,
|
||||||
|
],
|
||||||
|
cwd: ".",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it.each(pluginManifests)(
|
it.each(pluginManifests)(
|
||||||
"stores %s in the form Release Please rewrites it to",
|
"stores %s in the form Release Please rewrites it to",
|
||||||
async (path) => {
|
async (path) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user