refactor(plugin): migrate to V1 PluginModule format

Convert the default export from the legacy callable Plugin to the V1 PluginModule shape (`{ id, server }`) documented by opencode's plugin SDK. This aligns oh-my-openagent with the canonical plugin entry format and removes plugin-format legacy debt.

Drop the module-level `let activePluginDispose` cleanup guard: opencode instantiates plugins in a scope-bound Layer per server and dynamic-imports fresh modules on reload, so module-level state is not preserved across reloads. Individual managers already register their own SIGINT/SIGTERM cleanup (skill-mcp-manager, background-agent process-cleanup), so the orphaned createPluginDispose call provided no runtime value.

Remove the non-standard `name` return field that opencode's Hooks interface does not include. The PluginModule's `id` now carries the plugin identity instead.

Drop the unused `lspManager` import that only fed the orphaned createPluginDispose.

Update src/index.test.ts and src/index.telemetry.test.ts to call `plugin.server(ctx)` instead of `plugin(ctx)`, and assert the V1 shape.
This commit is contained in:
YeonGyu-Kim
2026-04-18 01:37:46 +09:00
parent 2892ca4adf
commit 1b10ab36d2
3 changed files with 40 additions and 40 deletions
+4 -3
View File
@@ -125,12 +125,13 @@ describe("OhMyOpenCodePlugin telemetry isolation", () => {
const { default: plugin } = await import(`./index?telemetry=${Date.now()}-${Math.random()}`)
// when
const result = await plugin({
const result = await plugin.server({
directory: "/tmp/project",
client: {},
} as Parameters<typeof plugin>[0])
} as Parameters<typeof plugin.server>[0])
// then
expect(result).toMatchObject({ name: "oh-my-openagent" })
expect(typeof result).toBe("object")
expect(result).not.toBeNull()
})
})