summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorShpetim <[email protected]>2026-01-04 08:39:54 +0100
committerGitHub <[email protected]>2026-01-04 01:39:54 -0600
commitc3fd3c865681eb4fb27b0b3070f9cc96a4afa287 (patch)
tree8ce8a7d174fb852ff010c5a72ce90eb5266ee507
parent4d7d28c30af343cc8f7b7144b132b9e7779952c7 (diff)
downloadopencode-c3fd3c865681eb4fb27b0b3070f9cc96a4afa287.tar.gz
opencode-c3fd3c865681eb4fb27b0b3070f9cc96a4afa287.zip
fix(plugin): prevent duplicate plugin function initialization (#6787)
Co-authored-by: Shpetim <[email protected]> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
-rw-r--r--packages/opencode/src/plugin/index.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts
index 4c42ab972..6868836f0 100644
--- a/packages/opencode/src/plugin/index.ts
+++ b/packages/opencode/src/plugin/index.ts
@@ -47,7 +47,13 @@ export namespace Plugin {
if (!plugin) continue
}
const mod = await import(plugin)
+ // Prevent duplicate initialization when plugins export the same function
+ // as both a named export and default export (e.g., `export const X` and `export default X`).
+ // Object.entries(mod) would return both entries pointing to the same function reference.
+ const seen = new Set<PluginInstance>()
for (const [_name, fn] of Object.entries<PluginInstance>(mod)) {
+ if (seen.has(fn)) continue
+ seen.add(fn)
const init = await fn(input)
hooks.push(init)
}