Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/opencode/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ function getLegacyPlugins(mod: Record<string, unknown>) {
if (seen.has(entry)) continue
seen.add(entry)
const plugin = getServerPlugin(entry)
if (!plugin) throw new TypeError("Plugin export is not a function")
// Skip non-plugin exports (constants, helpers, etc.) instead of throwing —
// a single non-function export must not discard the module's real plugins.
if (!plugin) continue
result.push(plugin)
}

Expand Down
17 changes: 17 additions & 0 deletions packages/opencode/test/plugin/trigger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,21 @@ describe("plugin.trigger", () => {
}),
),
)

it.instance("loads a plugin module that also exports non-function values", () =>
withProject(
[
'export const VERSION = "1.0.0"',
"export const plugin = async () => ({",
` ${JSON.stringify(systemHook)}: (_input, output) => {`,
' output.system.unshift("sync")',
" },",
"})",
"",
].join("\n"),
Effect.gen(function* () {
expect(yield* triggerSystemTransform()).toEqual(["sync"])
}),
),
)
})
Loading