mirror of
https://github.com/lemon07r/opencode-kimi-full.git
synced 2026-07-18 08:05:52 +02:00
e5fd91feba
opencode's getLegacyPlugins iterates every module export and throws on
non-function values. On Windows, Bun's standalone-binary dynamic imports
can produce module namespace objects with extra non-function metadata,
silently preventing the plugin from loading (the provider never appears
in `opencode auth login`).
Switch the default export from a bare Plugin function to the v1
PluginModule object ({ id, server }), which opencode's readV1Plugin
detects and handles before getLegacyPlugins ever runs. Also add
exports["./server"] for explicit entry point resolution.
24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
import { test, expect } from "bun:test"
|
|
import * as mod from "../src/index.ts"
|
|
|
|
// Regression guard for the 1.0.0 bug + the Windows loading fix:
|
|
// opencode's plugin loader first tries readV1Plugin (detect mode) on the
|
|
// default export. If it finds { id?, server } it uses the v1 path and
|
|
// never touches getLegacyPlugins. The legacy path iterates every export and
|
|
// throws "Plugin export is not a function" on any non-callable value — a
|
|
// problem that surfaced on Windows where Bun standalone dynamic imports can
|
|
// produce module namespaces with extra non-function metadata.
|
|
//
|
|
// This test ensures the module exports exactly one default PluginModule
|
|
// object with a callable `server` and no named exports.
|
|
test("src/index.ts exports exactly one default PluginModule object", () => {
|
|
const keys = Object.keys(mod)
|
|
expect(keys).toEqual(["default"])
|
|
const plugin = (mod as { default: unknown }).default
|
|
expect(typeof plugin).toBe("object")
|
|
expect(plugin).not.toBeNull()
|
|
const obj = plugin as Record<string, unknown>
|
|
expect(typeof obj.server).toBe("function")
|
|
expect("id" in obj).toBe(true)
|
|
})
|