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 828cf8cacb38936dbdcb0718997d57de42a56507
parent 83bd956746a07563f35e86a4f948f34f37aef351
Author: Henry Unite <unitehenry@gmail.com>
Date:   Mon, 19 Oct 2026 19:54:56 +0000

refactor: move create.before shell hook registration to shell.ts
Diffstat:
Ashell.ts | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/shell.ts b/shell.ts @@ -0,0 +1,39 @@ +import type { Plugin } from "@opencode/plugin"; +import * as path from "node:path"; + +export async function registerShell( + ctx: Plugin.Context, + deps: { writeLog: (message: string) => void; openpodRoot: string }, +): Promise<void> { + const { writeLog, openpodRoot } = deps; + + function getLimaName(dir: string): string | null { + try { + writeLog(`get lima name for ${openpodRoot} ${dir}`); + const rel = path.relative(openpodRoot, dir); + if (rel.startsWith("..") || path.isAbsolute(rel)) { + return null; + } + const first = rel.split(path.sep).find((p) => p.length > 0); + return first || null; + } catch { + return null; + } + } + + writeLog("registering create.before"); + + await ctx.shell.hook("create.before", async (event) => { + const limaName = getLimaName(event.cwd); + + if (limaName) { + const originalCommand = event.command; + const escapedCwd = event.cwd.replace(/'/g, "'''"); + const escapedCmd = originalCommand.replace(/'/g, "'''"); + event.command = `limactl shell --preserve-env --workdir='${escapedCwd}' ${limaName} bash -c '${escapedCmd}'`; + writeLog( + `redirected shell command for lima ${limaName} (cwd=${event.cwd})`, + ); + } + }); +}