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 22079f05f2c38a95eeef2a0f7f8d74c089c13430
parent 04ea6407254c5c3f139f5b3993e731eea25ef214
Author: Henry Unite <unitehenry@gmail.com>
Date:   Mon, 26 Oct 2026 00:39:37 +0000

test(opencode): assert hostname inside session lima instance

The create.before hook only wraps a shell command with limactl when the
cwd is inside openpodRoot. The plugin's prompt handler moves the session
asynchronously, so wait for the session's directory to land in the
openpod directory and pass cwd explicitly to shell.create. The resulting
hostname confirms execution inside the session's lima VM.

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

diff --git a/opencode.test.ts b/opencode.test.ts @@ -208,6 +208,43 @@ describe("opencode", () => { const sessionDir = path.join(openpodRoot, session.id); expect(fs.existsSync(sessionDir)).toBe(true); + // Wait for the prompt hook's async session.move() to land the session + // in the openpod directory. The create.before hook only wraps the + // command with `limactl shell` when cwd is inside openpodRoot. + for (let i = 0; i < 50; i++) { + const current = await opencode.sessions.get({ sessionID: session.id }); + if (current.location?.directory === sessionDir) break; + await new Promise((r) => setTimeout(r, 100)); + } + + // Call shell.create — this triggers ctx.shell.hook("create.before"), + // which wraps the command with `limactl shell ... bash -c 'hostname'` + // so it executes inside the session's lima VM. + const shell = await opencode.shell.create({ + command: "hostname", + cwd: sessionDir, + }); + + // Wait for the shell command to finish + for (let i = 0; i < 60; i++) { + const info = await opencode.shell.get({ + id: shell.data.id, + location: shell.location, + }); + if (info.data.status !== "running") break; + await new Promise((r) => setTimeout(r, 250)); + } + + const output = await opencode.shell.output({ + id: shell.data.id, + location: shell.location, + }); + + // hostname inside a lima VM is lima-<instance-name>, and lima replaces + // underscores with hyphens because hostnames can't contain underscores. + const expectedHost = session.id.replace(/_/g, "-"); + expect(output.data.output).toContain(expectedHost); + // Clean up await cleanup(session.id, [sessionDir, tempDir, bareDir]); },