feat: add opencode provider support (#1758)
Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: codex <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
This commit is contained in:
52 files changed
+4767
-268
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { describe, it, vi } from "vitest";
|
||||
|
||||
const childProcessMock = vi.hoisted(() => ({
|
||||
execFileSync: vi.fn((command: string, args: ReadonlyArray<string>) => {
|
||||
if (command === "which" && args[0] === "opencode") {
|
||||
return "/opt/homebrew/bin/opencode\n";
|
||||
}
|
||||
return "";
|
||||
}),
|
||||
spawn: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("node:child_process", () => childProcessMock);
|
||||
|
||||
describe("resolveOpenCodeBinaryPath", () => {
|
||||
it("returns absolute binary paths without PATH lookup", async () => {
|
||||
const { resolveOpenCodeBinaryPath } = await import("./opencodeRuntime.ts");
|
||||
|
||||
assert.equal(resolveOpenCodeBinaryPath("/usr/local/bin/opencode"), "/usr/local/bin/opencode");
|
||||
assert.equal(childProcessMock.execFileSync.mock.calls.length, 0);
|
||||
});
|
||||
|
||||
it("resolves command names through PATH", async () => {
|
||||
const { resolveOpenCodeBinaryPath } = await import("./opencodeRuntime.ts");
|
||||
|
||||
assert.equal(resolveOpenCodeBinaryPath("opencode"), "/opt/homebrew/bin/opencode");
|
||||
assert.deepEqual(childProcessMock.execFileSync.mock.calls[0], [
|
||||
"which",
|
||||
["opencode"],
|
||||
{
|
||||
encoding: "utf8",
|
||||
timeout: 3_000,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user