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 c20a215ae54be5654aa7470657947d1edc00a194
parent 38bdceb5bd07e6a61ad439451c2044822f702edb
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 25 Oct 2026 02:21:43 +0000

refactor(cleanup): extract limactl operations and directory removal into private functions

- Define stopLima, deleteLima, and removePodDirectory as inner functions
  within initCleanup scope
- Call them from execute
- No behavior change; improves readability and testability
- Tests pass, format/lint clean

Diffstat:
Mcontext/cleanup.ts | 26++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/context/cleanup.ts b/context/cleanup.ts @@ -12,14 +12,7 @@ export function initCleanup(openpodRoot: string, logger?: Logger): Cleanup { const log = (message: string, level?: string) => logger?.log?.(message, level); - async function execute(sessionID: string): Promise<void> { - if (!sessionID || typeof sessionID !== "string") return; - - const limaName = sessionID; - const podDir = path.join(openpodRoot, sessionID); - - log(`[cleanup] starting for ${sessionID}`); - + function stopLima(limaName: string): void { // best-effort stop (ignore errors) try { spawnSync("limactl", ["stop", limaName, "--force"], { stdio: "ignore" }); @@ -27,7 +20,9 @@ export function initCleanup(openpodRoot: string, logger?: Logger): Cleanup { } catch { // ignore } + } + function deleteLima(limaName: string): void { // delete the lima instance try { const result = spawnSync("limactl", ["delete", limaName, "--force"], { @@ -37,7 +32,9 @@ export function initCleanup(openpodRoot: string, logger?: Logger): Cleanup { } catch (err) { log(`[cleanup] limactl delete error for ${limaName}: ${err}`); } + } + function removePodDirectory(podDir: string): void { // remove the openpod directory try { if (fs.existsSync(podDir)) { @@ -51,5 +48,18 @@ export function initCleanup(openpodRoot: string, logger?: Logger): Cleanup { } } + async function execute(sessionID: string): Promise<void> { + if (!sessionID || typeof sessionID !== "string") return; + + const limaName = sessionID; + const podDir = path.join(openpodRoot, sessionID); + + log(`[cleanup] starting for ${sessionID}`); + + stopLima(limaName); + deleteLima(limaName); + removePodDirectory(podDir); + } + return { execute }; }