openpod

An opencode plugin that spins up a dedicated virtual machine for each session to isolate agent work.
git clone https://unitehenry.com/git/openpod.git
Log | Files | Refs | README

commit 3952bf4cabf72ac26ab875bdc550da9e6bbba673
parent 9a6ab8e8d44520f62c9c0ef958ac5160ecb25d68
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 25 Oct 2026 17:26:41 +0000

test(opencode): init opencode suite

Diffstat:
Mopencode.test.ts | 76++++++++++++++--------------------------------------------------------------
1 file changed, 14 insertions(+), 62 deletions(-)

diff --git a/opencode.test.ts b/opencode.test.ts @@ -1,70 +1,22 @@ -import { describe, it, expect, vi } from "vitest"; - -// Mutable flag closed over by the module mock below -let failLimactlCheck = false; - -vi.mock("node:child_process", async (importOriginal) => { - const actual = await importOriginal<typeof import("node:child_process")>(); - return { - ...actual, - execSync: (command: string | Buffer, options?: any) => { - const cmd = String(command); - if (failLimactlCheck && (cmd.includes("limactl") || /command -v/.test(cmd) || cmd.includes("where"))) { - console.error("[MOCK] blocking limactl check for:", cmd); - const err: any = new Error("command not found"); - err.status = 1; - throw err; - } - if (cmd.includes("limactl") || /command -v/.test(cmd)) { - console.error("[MOCK] allowing real check for:", cmd); - } - return actual.execSync(command, options); - }, - }; -}); +import { OpenCode } from "@opencode/sdk" +import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; describe("opencode", () => { - it("Opencode plugin cant register without limactl", async () => { - failLimactlCheck = true; - try { - vi.resetModules(); - const [sdk, ctxMod] = await Promise.all([ - import("@opencode/sdk"), - import("./context"), - ]); - const FreshOpenCode = sdk.OpenCode; + let opencode: Awaited<ReturnType<typeof OpenCode.create>>; - // The real openpod plugin's setup calls init() which checks for limactl. - // This is what prevents the plugin from registering when limactl is missing. - await expect(ctxMod.init()).rejects.toThrow(/`limactl` is not installed/); - - // We can still create the host (SDK does not reject on plugin setup failure), - // but the registration effectively fails because init threw. - const failingPlugin = { - id: "openpod", - async setup() { - await ctxMod.init(); - }, - } as any; + beforeEach(async () => { + opencode = await OpenCode.create(); + }); - const opencode = await FreshOpenCode.create({ plugins: [failingPlugin] }); - expect(opencode).toBeDefined(); - } finally { - failLimactlCheck = false; - } + afterEach(async () => { + await opencode?.close?.(); }); - it("Opencode plugin is registered correctly after limactl is installed", async () => { - // In this environment (and in CI) limactl is present. - // Successful creation without throwing means the plugin registered. - vi.resetModules(); - const [sdk, mod] = await Promise.all([ - import("@opencode/sdk"), - import("./index"), - ]); - const FreshOpenCode = sdk.OpenCode; - const plugin = mod.default; - await using opencode = await FreshOpenCode.create({ plugins: [plugin] }); - expect(opencode).toBeDefined(); + it("Opencode plugin cant register without limactl", async () => { + // TODO: temporarily unlink `limactl` from path + // TODO: Call await opencode.plugin(plugin) to register another plugin after startup. + console.log(opencode); + // TODO: assert limactl error is thrown + // TODO: cleanup finally - link `limactl` from path }); });