fix(plugin): keep the shared launcher owner outside shipped source trees

This commit is contained in:
morluto
2026-10-13 21:47:15 +08:00
parent 3206274e0b
commit 42ce2c75ab
6 changed files with 5 additions and 6 deletions
+6
View File
@@ -0,0 +1,6 @@
/** Exact host argv for a pinned registry package's MCP entry point. */
export function packageRunnerCommand(
runner: "npx" | "bunx",
packageSpecifier: string,
platform: NodeJS.Platform,
): readonly string[];
+16
View File
@@ -0,0 +1,16 @@
/** Host argv shared by setup registrations and the source-only plugin launcher. */
export const packageRunnerCommand = (runner, packageSpecifier, platform) => {
if (runner !== "npx" && runner !== "bunx")
throw new Error("Unsupported package runner");
// Windows cmd.exe consumes these tokens itself. Package registrations use
// exact registry references, never shell expressions or arbitrary operands.
if (!/^[@A-Za-z0-9_./+-]+$/u.test(packageSpecifier))
throw new Error("Package runner requires a shell-safe registry reference");
const command =
runner === "npx"
? ["npx", "-y", packageSpecifier, "mcp"]
: ["bunx", packageSpecifier, "mcp"];
// npm's .cmd shim is not a native executable. Disable cmd AutoRun, matching
// the setup registration policy, and keep all dynamic values out of syntax.
return platform === "win32" ? ["cmd.exe", "/d", "/c", ...command] : command;
};
+1 -1
View File
@@ -5,7 +5,7 @@ import { mkdtemp, rm } from "node:fs/promises";
import { constants, tmpdir } from "node:os";
import { join } from "node:path";
import { packageRunnerCommand } from "../src/process/packageRunnerCommand.mjs";
import { packageRunnerCommand } from "./lib/packageRunnerCommand.mjs";
// The manifest owns this exact package pin; args[1] remains release-managed.
// No build, dependency installation or ambient latest-version lookup is needed