diff options
| author | Dax Raad <[email protected]> | 2026-01-01 23:15:04 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2026-01-01 23:15:04 -0500 |
| commit | 038cff4a93bb39238534898b4790229773c4ff22 (patch) | |
| tree | 9a320d9faf11482e72d5368c9aa4c98695d2a4d0 | |
| parent | 741cb9c0efe0bad60da39a291eb705a019926a7b (diff) | |
| download | opencode-038cff4a93bb39238534898b4790229773c4ff22.tar.gz opencode-038cff4a93bb39238534898b4790229773c4ff22.zip | |
core: improve plugin loading to handle builtin plugin failures gracefully
| -rw-r--r-- | packages/opencode/src/plugin/index.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts index 18a621fbb..9b9d3266a 100644 --- a/packages/opencode/src/plugin/index.ts +++ b/packages/opencode/src/plugin/index.ts @@ -11,6 +11,8 @@ import { Flag } from "../flag/flag" export namespace Plugin { const log = Log.create({ service: "plugin" }) + const BUILTIN = ["[email protected]", "[email protected]"] + const state = Instance.state(async () => { const client = createOpencodeClient({ baseUrl: "http://localhost:4096", @@ -29,8 +31,7 @@ export namespace Plugin { } const plugins = [...(config.plugin ?? [])] if (!Flag.OPENCODE_DISABLE_DEFAULT_PLUGINS) { - plugins.push("[email protected]") - plugins.push("[email protected]") + plugins.push(...BUILTIN) } for (let plugin of plugins) { log.info("loading plugin", { path: plugin }) @@ -38,7 +39,11 @@ export namespace Plugin { const lastAtIndex = plugin.lastIndexOf("@") const pkg = lastAtIndex > 0 ? plugin.substring(0, lastAtIndex) : plugin const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest" - plugin = await BunProc.install(pkg, version) + plugin = await BunProc.install(pkg, version).catch((err) => { + if (BUILTIN.includes(pkg)) return "" + throw err + }) + if (!plugin) continue } const mod = await import(plugin) for (const [_name, fn] of Object.entries<PluginInstance>(mod)) { |
