commit aa1c13ef582a1a7a9aefd7f89393a9397145866f
parent eb65f83a072bc0dcc4c7d3f8a04aa44961be03f4
Author: Henry Unite <unitehenry@gmail.com>
Date: Mon, 19 Oct 2026 20:59:26 +0000
fix: address review comments
- Move registerCommand call out of registerController into index.ts (top level, consistent with other registers)
- Include cleanupOpenpod (bound wrapper) in the composed OpenpodContext
- Remove direct import of cleanupOpenpod from controller.ts; consume via deps
- Loosen param type on low-level cleanupOpenpod to avoid requiring the bound method on internal deps
- Make cleanupOpenpod optional on base OpenpodContext type
Diffstat:
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/command.ts b/command.ts
@@ -7,7 +7,7 @@ import type { OpenpodContext } from "./setup";
export async function cleanupOpenpod(
sessionID: string,
- deps: OpenpodContext,
+ deps: { writeLog: (message: string, level?: string) => void; openpodRoot: string },
): Promise<void> {
const { writeLog, openpodRoot } = deps;
if (!sessionID || typeof sessionID !== "string") return;
@@ -67,7 +67,7 @@ export async function clearAllOpenpod(
for (const entry of entries) {
if (entry.isDirectory()) {
const sessionID = entry.name;
- await cleanupOpenpod(sessionID, deps);
+ await deps.cleanupOpenpod?.(sessionID);
}
}
diff --git a/controller.ts b/controller.ts
@@ -1,5 +1,4 @@
import type { Plugin } from "@opencode/plugin";
-import { cleanupOpenpod, registerCommand } from "./command";
import type { OpenpodContext } from "./setup";
@@ -7,8 +6,6 @@ export async function registerController(
ctx: Plugin.Context,
deps: OpenpodContext,
): Promise<() => void> {
- await registerCommand(ctx, deps);
-
// Listen for session removal (via events, since there is no ctx.session.hook("remove"))
// and clean up the corresponding openpod directory + lima instance.
const controller = new AbortController();
@@ -25,7 +22,7 @@ export async function registerController(
props.info?.id ??
(ev as any).sessionID;
if (sessionID) {
- void cleanupOpenpod(sessionID, deps);
+ void deps.cleanupOpenpod?.(sessionID);
}
}
}
diff --git a/index.ts b/index.ts
@@ -1,5 +1,6 @@
import { Plugin } from "@opencode/plugin";
+import { cleanupOpenpod, registerCommand } from "./command";
import { registerPrompt } from "./prompt";
import { registerShell } from "./shell";
import { registerController } from "./controller";
@@ -8,10 +9,15 @@ import { registerSetup } from "./setup";
export default Plugin.define({
id: "openpod",
async setup(ctx) {
- const openpod = await registerSetup();
+ const base = await registerSetup();
+ const openpod = {
+ ...base,
+ cleanupOpenpod: (sessionID: string) => cleanupOpenpod(sessionID, base),
+ } as const;
await registerPrompt(ctx, openpod);
await registerShell(ctx, openpod);
+ await registerCommand(ctx, openpod);
return await registerController(ctx, openpod);
},
diff --git a/setup.ts b/setup.ts
@@ -25,6 +25,7 @@ function writeLog(message: string, level: string = "info"): void {
export type OpenpodContext = {
writeLog: (message: string, level?: string) => void;
openpodRoot: string;
+ cleanupOpenpod?: (sessionID: string) => Promise<void>;
};
function isCommandAvailable(command: string): boolean {