fix: support Windows agent command shims

This commit is contained in:
2026-08-20 17:34:30 +08:00
parent 4387cedf76
commit 7416dfea1a
8 changed files with 43 additions and 16 deletions
+14 -1
View File
@@ -4,7 +4,7 @@ import os from "node:os";
import path from "node:path";
import test from "node:test";
import { parse } from "jsonc-parser";
import { configureAgents, type CommandResult, type CommandRunner, defaultSkillPath, launchCommand, unconfigureAgents } from "../src/agents.js";
import { configureAgents, type CommandResult, type CommandRunner, defaultSkillPath, launchCommand, SpawnCommandRunner, unconfigureAgents } from "../src/agents.js";
import { resolveClientOptions } from "../src/config.js";
class FakeRunner implements CommandRunner {
@@ -45,6 +45,19 @@ test("Agent Skill paths use each client's user-level discovery directory", () =>
assert.equal(defaultSkillPath("opencode", env), path.join("C:\\Config", "opencode", "skills", "crafttable"));
});
test("command runner launches Windows command shims", { skip: process.platform !== "win32" }, async () => {
const directory = await mkdtemp(path.join(os.tmpdir(), "crafttable-mcp-shim-test-"));
const shim = path.join(directory, "fixture.cmd");
await writeFile(shim, "@echo off\r\necho shim:%1\r\n", "utf8");
try {
const result = await new SpawnCommandRunner().run(shim, ["ok"]);
assert.equal(result.code, 0);
assert.match(result.stdout, /shim:"?ok"?/);
} finally {
await rm(directory, { recursive: true, force: true });
}
});
test("Codex and Claude adapters add, detect idempotency, replace conflicts, remove, and dry-run", async () => {
const directory = await mkdtemp(path.join(os.tmpdir(), "crafttable-mcp-cli-agent-test-"));
const skillSource = await createSkillFixture(directory);