fix(plugins): validate Codex companion launch metadata

This commit is contained in:
morluto
2026-10-14 01:23:15 +08:00
parent b7dabdbc4f
commit a85bfed8dc
15 changed files with 315 additions and 99 deletions
@@ -24,9 +24,24 @@ const pluginManifestPaths = [
".codex-plugin/plugin.json",
] as const;
const pluginManifest = (version: string, launch = `rea-agents@${version}`) => ({
const pluginManifest = (version: string, launch = version) => ({
version,
mcpServers: { rea: { args: ["-y", launch, "mcp"] } },
mcpServers: {
rea: {
command: "node",
args: ["${CLAUDE_PLUGIN_ROOT}/scripts/plugin-mcp-launcher.mjs", launch],
},
},
});
const codexServerConfig = (version: string, launch = version) => ({
mcpServers: {
rea: {
command: "node",
args: ["./scripts/plugin-mcp-launcher.mjs", launch],
startup_timeout_sec: 30,
},
},
});
async function metadata(
@@ -40,9 +55,12 @@ async function metadata(
for (const path of pluginManifestPaths)
await mkdir(join(directory, dirname(path)), { recursive: true });
const files = {
...Object.fromEntries(
pluginManifestPaths.map((path) => [path, pluginManifest(version)]),
),
".claude-plugin/plugin.json": pluginManifest(version),
".codex-plugin/plugin.json": {
version,
mcpServers: "./.mcp.json",
},
".mcp.json": codexServerConfig(version),
"package.json": { name: "rea-agents", version },
"package-lock.json": { version, packages: { "": { version } } },
".release-please-manifest.json": { ".": version },
@@ -581,27 +599,15 @@ it.each([
});
it.each(
pluginManifestPaths.flatMap((path) => [
{
path,
stale: "version",
manifest: pluginManifest("5.1.0", "rea-agents@6.0.0"),
failure: "declares 5.1.0; release branch requires 6.0.0",
},
{
path,
stale: "server launch",
manifest: pluginManifest("6.0.0", "rea-agents@5.1.0"),
failure:
"launches rea-agents@5.1.0; release branch requires rea-agents@6.0.0",
},
{
path,
stale: "server launch without the package name",
manifest: pluginManifest("6.0.0", "6.0.0"),
failure: "launches 6.0.0; release branch requires rea-agents@6.0.0",
},
]),
pluginManifestPaths.map((path) => ({
path,
stale: "version",
manifest:
path === ".codex-plugin/plugin.json"
? { version: "5.1.0", mcpServers: "./.mcp.json" }
: pluginManifest("5.1.0"),
failure: "declares 5.1.0; release branch requires 6.0.0",
})),
)("rejects a plugin $stale in $path", async ({ path, manifest, failure }) => {
const f = await fixture();
await candidate(f, "6.0.0");
@@ -614,6 +620,29 @@ it.each(
});
});
it.each([
{
path: ".claude-plugin/plugin.json",
manifest: pluginManifest("6.0.0", "5.1.0"),
},
{
path: ".mcp.json",
manifest: codexServerConfig("6.0.0", "5.1.0"),
},
])("reads the release pin from $path", async ({ path, manifest }) => {
const f = await fixture();
await candidate(f, "6.0.0");
await writeFile(join(f.directory, path), JSON.stringify(manifest));
await git(f.directory, ["add", "."]);
await git(f.directory, ["commit", "-m", "chore: stale plugin launch"]);
await expect(verify(f)).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining(
`launches version 5.1.0; release branch requires 6.0.0`,
),
});
});
it("checks a publish merge using its pre-release first parent baseline", async () => {
const f = await fixture();
const sourceSha = await candidate(f, "6.0.0");