You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Plugin fails to load under OpenCode 2.1.0: bare package name entry dist/index.js lacks a default export (Plugin mu | [Bug] OpenCode 2.1.0 下插件加载失败:裸包名入口 dist/index.js 没有默认导出(Plugin must export a default definition) #3976
level=WARN role=server message="failed to load plugin"
target=billion-context
cause=PluginModule.LoadError: Plugin must export a default definition with an id and an
effect or setup function. (cause: SchemaError(Missing key at ["default"]))
紧随其后还有一条:
message="failed to check plugin update" target=billion-context
cause=NpmInstallFailedError: Package is not installed: billion-context
changed the title [-][Bug] OpenCode 2.1.0 下插件加载失败:裸包名入口 dist/index.js 没有默认导出(Plugin must export a default definition)[/-][+][Bug] Plugin fails to load under OpenCode 2.1.0: bare package name entry dist/index.js lacks a default export (Plugin mu | [Bug] OpenCode 2.1.0 下插件加载失败:裸包名入口 dist/index.js 没有默认导出(Plugin must export a default definition)[/+]on Oct 20, 2026
TypeError: o is not a function. (In 'o()', 'o' is an instance of Object)
at <anonymous> (chunk-pa4tadds.js:...)
at ServerProcess.start (chunk-vjacg5s7.js:...)
opencode plugin update 同步报:
Failed to check Server plugin "billion-context": Plugin must export a default
definition with an id and an effect or setup function.
Activity
[-][Bug] OpenCode 2.1.0 下插件加载失败:裸包名入口 dist/index.js 没有默认导出(Plugin must export a default definition)[/-][+][Bug] Plugin fails to load under OpenCode 2.1.0: bare package name entry dist/index.js lacks a default export (Plugin mu | [Bug] OpenCode 2.1.0 下插件加载失败:裸包名入口 dist/index.js 没有默认导出(Plugin must export a default definition)[/+]ranxianglei commentedon Oct 20, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重:不重复。 搜过 open/closed 的 issue 与 PR(按症状与机制检索,不只标题),没有同症状同机制的条目;最接近的 #2656 是 opencode V2 通道 acp_retrieve 工具注册问题,机制不同且已关闭。
标签:bug / opencode / scope/wiring / p1 —— README 手动安装与
bili plugin install opencode(npm 形态)两条文档化路径在最新 OpenCode 2.1.0 上插件都加载不了、压缩完全失效,属核心承诺失灵,判 p1。初步核对(master 即你装的 0.1.202):
main→dist/index.js(CLI 主程序,无默认导出);exports["./server"]→dist/agent/opencode-native.js(真正的插件本体)。exports["./server"]」的说法当时是在 2.0.3 上验证的;2.1.0 实测加载的是main指向的文件,说明 OpenCode 在这两个版本之间改了插件解析行为——这是根因所在,不是我们入口结构写错。接下来我会:把 @opencode/cli 2.1.0 装到本地读它的插件加载源码,钉死它解析裸包名时到底看哪个字段、认哪个配置键(plugin/plugins)、目录约束从哪来;然后三线修复——①
bili plugin install opencode写入的条目形式;②bili opencode启动器生成的临时配置;③ README / CLIENTS.md(en+zh)的手动安装说明。有结论即回报。rwjxrj commentedon Nov 9, 2026
2.2.5 上复现,本地 ESM shim 同样有效(补充确认修复方向)
复现环境:
@opencode/cli2.2.5(npm 全局)npm install -g billion-context)bili plugin install opencode(0.1.213 安装器写入裸包名)现象与本 issue 一致
裸包名入口加载失败,且在 2.2.5 上症状更严重——不是仅告警,而是
/reload直接抛 TypeError(TUI 弹窗):opencode plugin update同步报:对本 issue 第 3 节结论的补充
在 2.2.5 上,opencode 加载
dist/index.js(CJS,无导出)后拿到的不是"没有定义",而是一个 Object 形状的东西被当函数调用——与 issue 里 2.1.0 的SchemaError(Missing key at ["default"])文案不同,但根因相同:裸包名解析不到exports["./server"],README 的 Npm.add 说法在 2.2.5 依旧不成立。修复验证:两种 shim 形态均可用
按本 issue 的「目录 + 重导出」方案实测通过。我还验证了一个等价变体——单个
.js文件放进~/.config/opencode/plugins/(靠 opencode 的 plugins 目录自动发现,不需要配置条目、不需要目录形式):(
raw解包是防御性的:file:导入 CJS 时部分运行时给的是整个 namespace 而非module.exports.default。)端到端验证结果(2.2.5 + 0.1.213):
opencode plugin list正常列出billion-context-opencode-native (local)opencode plugin update不再报 definition 错误bili.log出现[plugin] [acp-usage] input=…,模型请求确实走压缩链路/reload不再抛 TypeError给维护者的两点建议(与本 issue 第 4 节建议合并)
main/ 根导出.目前指向dist/index.js(CLI)和dsh-native.js。若 opencode 侧无法推动其按exports["./server"]解析裸包名,可考虑把包拆成billion-context(CLI)+ 子包或双入口,让根入口本身就是 OpenCode 插件定义。bili plugin install opencode在 2.x 上目前写入的裸包名 + 旧键"plugin"双双失效,建议安装器检测 opencode ≥ 2.0 时直接采用本 issue 的目录 shim 写法(并把键改为"plugins"),把 workaround 内化到安装器里。如需我补充 2.2.5 上的完整日志(opencode.log / bili.log 片段),告诉我即可。
ranxianglei commentedon Nov 9, 2026
(ai: vllm-qwen/qwen3.8-27b)
@rwjxrj 的 2.2.5 数据非常关键——
/reload直接抛 TypeError 说明问题比 2.1.0 更严重,两种 shim 形态的验证也帮我们钉死了修复方向。已按本 issue 的方案修完,PR:#6002。根因:OpenCode 2.x 用包的
main字段解析裸包名(dist/index.js= CLI,无默认导出),而不是 README 说的exports["./server"];安装器和文档在 2.x 宿主上写的正是裸包名,所以必挂。Linux 2.1.0 上裸包名碰巧能加载(Arborist 缓存路径),所以旧写法过了评审、只在 Windows 上暴露——两位报告者都是 Windows。修法(把实测可用的 workaround 内化到安装器):
bili plugin install opencode在 2.x 宿主(以及 git checkout/开发构建)上改写 shim 目录条目:<configDir>/plugins/billion-context/index.js→ 重导出本次安装的dist/agent/opencode-native.js,就是两位实测可用的形态;行为变更披露(旧→新):
"plugins": ["billion-context"]→"plugins": ["<configDir>/plugins/billion-context"](shim 目录)。原因:裸包名在 2.x(至少 Windows)永远加载不出来;shim 形态在 Linux/Windows × 2.1.0/2.2.5 四组合均有实测可用。opencode plugin update对它原先的检查从此不适用。验证:真实
@opencode/cli2.1.0 二进制在隔离环境跑了完整矩阵(复数/单数键 × 裸包名/shim 目录),shim 两组零加载失败、模块图完整解析、代理正常拉起;再叠加两位在 Windows 2.1.0/2.2.5 的端到端实测。代码侧新增单元测试(2.x 写 shim、遗留裸包名迁移、幂等、陈旧 shim 自愈)+ 一条假 2.x 版本探测的接线 e2e;定向测试 32/32、plugin-agent 76/76,typecheck 干净,全量回归交给 CI。遗留提示:已在 2.x 上用旧版 bili 装过的人,升级后重跑一次
bili plugin install opencode即自动迁移;rwjxrj 的单文件~/.config/opencode/plugins/*.js自动发现变体同样有效,但安装器统一采用配置目录下、可被 status/remove 管理的 shim 目录形态。标签:bug / opencode / scope-wiring / p1 —— 文档化安装路径在当前 OpenCode 下压缩整体失效(核心承诺失灵),定 p1。
八问:
/reload都会抛 TypeError。main字段解析裸包名(dist/index.js是 CLI、无默认导出),而安装器/README 假设它走exports["./server"];该假设在 Linux 上碰巧成立、Windows 上不成立,评审时被掩盖。收工判定:PR #6002 已开(Closes #3976),定向验证全绿,等 CI 全量结果;合并并发版后,2.x Windows 用户重跑
bili plugin install opencode即可一步到位。ranxianglei commentedon Nov 9, 2026
(ai: vllm-qwen/qwen3.8-27b)
CI 状态更新:PR #6002 首跑 11 个 test 分片全红,经核对为继承性 master 红(LIVE_FILES tripwire,与 #4599 总控在途的同一签名,与本 PR 改动无关);已按协调协议把
ci-fixes(831b645)合入分支重推,新 head311a34f7e6,CI 重跑中。本 PR 自身的静态门禁(gate/unused-exports/architecture-docs/mysql-contract/static-gates)在首跑已全部转绿。其余结论以上一条回复为准(根因、修法、行为变更披露、八问)。Merge pull request #6002 from ranxianglei/2026-11-09_opencode-v2-shim…
fix(ci): align hermetic registry e2e entry assertion with #3976 2.x s…
fix: opencode 2.x native install writes the shim dir instead of the b…