fix(omo-codex): write local installer command shims on Windows

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-26 11:18:47 +09:00
parent 22bcb4b45a
commit 3de8bb2578
2 changed files with 55 additions and 3 deletions
@@ -7,6 +7,7 @@ import { tmpdir } from "node:os";
import { mkdtemp } from "node:fs/promises";
import { installMarketplaceLocally } from "./install-local.mjs";
import { linkCachedPluginBins } from "./install/cache.mjs";
async function makeTempDir() {
return mkdtemp(join(tmpdir(), "codex-plugins-install-"));
@@ -208,3 +209,26 @@ test("#given bad plugin source path #when installing #then rejects traversal", a
/local plugin source path must start with \.\//,
);
});
test("#given Windows platform #when linking cached plugin bins #then writes command shims", async () => {
const root = await makeTempDir();
const pluginRoot = join(root, "plugin");
const binDir = join(root, "bin");
await mkdir(pluginRoot, { recursive: true });
await writeJson(join(pluginRoot, "package.json"), {
name: "@example/alpha",
bin: {
alpha: "./dist/cli.js",
},
});
await mkdir(join(pluginRoot, "dist"), { recursive: true });
await writeFile(join(pluginRoot, "dist", "cli.js"), "#!/usr/bin/env node\n");
const linked = await linkCachedPluginBins({ binDir, pluginRoot, platform: "win32" });
assert.deepEqual(linked, [{ name: "alpha", path: join(binDir, "alpha.cmd"), target: join(pluginRoot, "dist", "cli.js") }]);
const shim = await readFile(join(binDir, "alpha.cmd"), "utf8");
assert.match(shim, /@echo off/);
assert.match(shim, new RegExp(`node "${join(pluginRoot, "dist", "cli.js").replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}" %\\*`));
});