opencode-visual-cache icon indicating copy to clipboard operation
opencode-visual-cache copied to clipboard

V2 (opencode 2.x) 下插件未激活(server 入口 schema 校验失败)且 DeepSeek 余额不自动复用 auth.json

Open aiev opened this issue 2 months ago • 0 comments

环境

  • opencode 2.0.14(V2,Linux)
  • opencode-visual-cache 1.7.1(在 ~/.config/opencode/cli.json 的 plugins 中声明)
  • 同一配置下 1.7.3-oc2 可以正常加载/显示面板

问题 1:V2 下插件未激活,面板不显示

V2 的服务端会解析 cli.json 中每个插件的 server 入口(Host.resolve:先试 ./server),并用 PluginModule schema 校验默认导出。当前 dist/server.js 导出的是 V1 形态:

const mod = { id: "opencode-visual-cache", server }

缺少 V2 要求的 setup/effect,校验直接失败:

timestamp=2026-09-22T06:21:27.248Z level=INFO run=06c27266 msg="loading plugin" id=opencode-visual-cache@latest entrypoint=.../node_modules/opencode-visual-cache/dist/server.js
timestamp=2026-09-22T06:21:27.249Z level=WARN run=06c27266 message="failed to load plugin" target=opencode-visual-cache@latest cause="Cause([Fail(PluginModule.LoadError: Plugin must export a default definition with an id and an effect or setup function. (cause: SchemaError(Missing key\n  at [\"default\"][\"effect\"]\nMissing key\n  at [\"default\"][\"setup\"])))])"

结果:插件没有激活,侧边栏/底部栏不渲染。

对照:1.7.3-oc2 的 ./server 恰好指向 dist/v2.js(带 setup),虽然随后在服务端因 context.renderer.terminalWidth 抛错,但模块通过了校验、插件仍被激活——所以面板能显示。1.7.1 是卡在校验层。

问题 2:V2 下 DeepSeek 余额一直显示「API Key not set」

auth.json 里已有 deepseek 凭据(type: "api",key 存在),但 V2 的 context.data.location.provider.list() 返回的 Provider.Info 不含 key / options.apiKey(V2 API schema 只有 id / canonical / integrationID / name / activation / package / settings / headers / body),findOpencodeKeyV2() 因此拿不到 key,余额区长期显示未配置。

OpenAI 正常是因为代码里单独读取了 auth.json 的 OAuth token;DeepSeek 等 API key 提供商没有对应分支。

期望

  1. V2 下能正常加载激活(补一个空的 setup 或调整 ./server 导出)。
  2. 余额自动复用凭据时,auth.json 的 api.key 与 oauth.access 都被支持。

修复 PR:见关联链接。

aiev avatar Sep 22 '26 15:09 aiev