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 5e45152a53b27ce0d0eaef2db67546173ec2ffbe
parent 94dcf8c231c67d732cb68b9892eef10011f67012
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sat, 24 Oct 2026 23:04:18 +0000

refactor(context): rename createLog to initLog returning Logger type

- Introduce exported type Logger = (message: string, level?: string) => void
- Rename createLog -> initLog (returns Logger)
- Use Logger type in OpenpodContext and createCleanup
- Improves type safety and naming consistency (init* pattern)

Diffstat:
Mcontext/cleanup.ts | 4+++-
Mcontext/index.ts | 6+++---
Mcontext/log.ts | 4+++-
3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/context/cleanup.ts b/context/cleanup.ts @@ -2,11 +2,13 @@ import * as fs from "node:fs"; import { spawnSync } from "node:child_process"; import * as path from "node:path"; +import type { Logger } from "./log"; + export type Cleanup = (sessionID: string) => Promise<void>; export function createCleanup( openpodRoot: string, - log: (message: string, level?: string) => void, + log: Logger, ): Cleanup { return async function cleanup(sessionID: string): Promise<void> { if (!sessionID || typeof sessionID !== "string") return; diff --git a/context/index.ts b/context/index.ts @@ -1,12 +1,12 @@ import * as os from "node:os"; import * as path from "node:path"; -import { createLog } from "./log"; +import { initLog, type Logger } from "./log"; import { isCommandAvailable } from "./command"; import { createCleanup } from "./cleanup"; export type OpenpodContext = { - log: (message: string, level?: string) => void; + log: Logger; openpodRoot: string; cleanup: (sessionID: string) => Promise<void>; }; @@ -14,7 +14,7 @@ export type OpenpodContext = { export async function init(): Promise<OpenpodContext> { const openpodRoot = path.join(os.homedir(), ".local", "share", "openpod"); - const log = createLog(openpodRoot); + const log = initLog(openpodRoot); const cleanup = createCleanup(openpodRoot, log); if (!isCommandAvailable("limactl")) { diff --git a/context/log.ts b/context/log.ts @@ -1,7 +1,9 @@ import * as fs from "node:fs"; import * as path from "node:path"; -export function createLog(openpodRoot: string) { +export type Logger = (message: string, level?: string) => void; + +export function initLog(openpodRoot: string): Logger { const logDir = path.join(openpodRoot, ".log"); const logFile = path.join(logDir, "openpod.log");