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 6ea43db5d02234bfa7aa21f099605e66c2b0686e
parent fa9f7c807ee35c51e74368bf951ba66c22d24717
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 25 Oct 2026 20:34:16 +0000

test(opencode): should create openpod instance for new session

Add E2E test for the happy path: a git repo with a remote origin.
The handler clones the repo into ~/.local/share/openpod/ and creates
a lima instance. Verifies the directory exists and limactl list
contains the session ID. Uses a 2-minute timeout to accommodate
lima VM creation.

Diffstat:
Mopencode.test.ts | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+), 0 deletions(-)

diff --git a/opencode.test.ts b/opencode.test.ts @@ -114,4 +114,70 @@ describe("opencode", () => { // ignore cleanup failures } }); + + it( + "should create openpod directory and lima instance for new session", + { timeout: 120_000 }, + async () => { + // Create a temp git repo with a remote origin + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openpod-e2e-")); + const bareDir = fs.mkdtempSync(path.join(os.tmpdir(), "openpod-bare-")); + execSync("git init --bare", { cwd: bareDir, stdio: "ignore" }); + execSync("git init", { cwd: tempDir, stdio: "ignore" }); + execSync(`git remote add origin ${bareDir}`, { + cwd: tempDir, + stdio: "ignore", + }); + + // Register the plugin and create a session, then move it to the git dir + await opencode.plugin(openpod); + const session = await opencode.sessions.create(); + + await opencode.sessions.move({ + sessionID: session.id, + directory: tempDir, + }); + + // Wait for the move to take effect + await new Promise((r) => setTimeout(r, 200)); + + // Trigger a prompt via the session API to fire the prompt hook. + await opencode.sessions.prompt({ + sessionID: session.id, + text: "hello", + }); + + // Verify the openpod directory was created (cloned) + const sessionDir = path.join(openpodRoot, session.id); + expect(fs.existsSync(sessionDir)).toBe(true); + + // Verify a lima instance was created for this session + const listOutput = execSync("limactl list", { encoding: "utf8" }); + expect(listOutput).toContain(session.id); + + // Clean up: remove lima instance and cloned directory + try { + execSync(`limactl delete --force ${session.id}`, { + stdio: "ignore", + }); + } catch { + // ignore cleanup failures + } + try { + fs.rmSync(sessionDir, { recursive: true, force: true }); + } catch { + // ignore + } + try { + fs.rmSync(tempDir, { recursive: true, force: true }); + } catch { + // ignore + } + try { + fs.rmSync(bareDir, { recursive: true, force: true }); + } catch { + // ignore + } + }, + ); });