CJYLZS/dsh-opencode-go-autosync

插件Plugin 原生Native ⭐ 3 数据Data

DeepSeek Harness 插件:一键把 models.opencode.ai/api.json 的 opencode-go 模型目录同步为 DSH 模型供应商 opencode-go-autosync。

catalog 简介 / catalog descriptioncatalog description:auto sync opencode-go models in dsh

项目介绍Project Overview

这是一个 DSH 插件,用于把 models.opencode.ai/api.json 中的 opencode-go 模型目录同步为 DSH 自定义供应商 opencode-go-autosync。它可一键创建或刷新模型列表,映射 contextWindow、maxTokens、reasoningEfforts 等字段,并支持可选定时同步;已有供应商时只覆盖 models,保留密钥与地址配置。当静态目录滞后、需要获取上游最新模型或富元数据时使用。插件不存储密钥,需另行配置 apiKeyEnv 对应的凭据或环境变量。

This DSH plugin syncs the opencode-go model catalog from models.opencode.ai/api.json into a DSH custom provider named opencode-go-autosync. It can create or refresh the provider in one click, maps fields such as contextWindow, maxTokens, and reasoningEfforts, and supports optional scheduled sync. When the provider already exists, only models are overwritten, preserving key and endpoint settings. Use it when the bundled static catalog is stale. The plugin does not store secrets; credentials must be configured separately through apiKeyEnv.

或使用命令行安装(适合开发者)Or use CLI install (for developers)

命令行安装CLI Install

dsh plugin --profile web add github:CJYLZS/dsh-opencode-go-autosync

CJYLZS/dsh-opencode-go-autosync 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-opencode-go-autosync

DeepSeek Harness 插件:一键把 models.opencode.ai/api.jsonopencode-go 模型目录同步为 DSH 模型供应商 opencode-go-autosync

已有 opencode-go-autosync 时只刷新模型列表;不存在时一键创建,无需手动更新 settings.yaml

为什么需要它

DSH 的 llm-pi-ai 通过 @earendil-works/pi-ai 的内置目录提供 opencode-go 供应商,其模型列表是 打包时 的静态快照(dist/providers/data/opencode-go.json,当前 19 个模型),只有随 pi-ai 发版、再随 DSH 升级才会更新。

而上游 https://models.opencode.ai/api.json 是动态目录(当前 opencode-go 28 个模型,持续新增/下线),二者会随时间产生缺口:新模型在设置页选不到,已下线模型的 contextWindow / reasoningEfforts 也可能过时。llm-pi-ai 文档亦明确标注 A route's catalog never refreshes itselfdiscoveryGET /models 也只返回 id,拿不到 contextWindow / reasoningEfforts / compat 等富元数据,因此否则需要手动维护 settings.yaml 中的模型列表。

本插件把这一转换搬进运行时:设置页一个按钮(可选定时)fetch(api.json) → 映射 → mutate llm-pi-ai.providers.opencode-go-autosync,首次创建自定义供应商并写入 api / baseURL / compat / apiKeyEnv,之后仅覆盖 models,保留你已配的密钥与地址,从此无需手动更新。


功能

  • 一键创建/更新:设置页按钮读取上游 https://models.opencode.ai/api.jsonopencode-go,写入 llm-pi-ai.providers.opencode-go-autosync
  • 只动模型列表:已存在供应商时,仅覆盖 models,保留你配过的 apiKeyEnv / baseURL / compat 等字段。
  • 完整字段映射limit.context→contextWindow / limit.output→maxTokens / modalities→input / reasoning+reasoning_options→reasoningEffortsnone→off:none,其余直通;非推理模型写 reasoningEfforts: false)。
  • 可选自动同步:配置 autoSync: true 后每 6 小时(可配)自动刷新一次。

安装

前置

  • DSH 已安装(pnpm dsh --help 可用),profile 建议 web

从 GitHub 安装

pnpm dsh plugin --profile web add github:CJYLZS/dsh-opencode-go-autosync

或先克隆再本地安装(注意 ./):

git clone https://github.com/CJYLZS/dsh-opencode-go-autosync.git
pnpm dsh plugin --profile web add file:./dsh-opencode-go-autosync
# 也可用绝对路径:pnpm dsh plugin --profile web add file:/abs/path/to/dsh-opencode-go-autosync

安装后重启 DSH:

pnpm dsh --profile web

卸载:

pnpm dsh plugin --profile web remove dsh-opencode-go-autosync

使用

  1. 打开 DSH 设置页 → Plugins,找到 Opencode Go 同步 卡片。
  2. 一键创建/更新。首次会创建 opencode-go-autosync,再次点击仅刷新模型列表。
  3. 预览上游 可不落盘查看上游模型数。

目标供应商名默认为 opencode-go-autosync,可在插件配置中改为任意名字(如 opencode-go-custom)。

API Key 配置

本插件不存密钥,只把供应商的 apiKeyEnv 指向一个环境变量名,密钥由 DSH 凭据体系解析。

1. 设置供应商的凭据引用

  • 设置页:模型 → 选中 opencode-go-autosyncapiKeyEnvOPENCODE_API_KEY(或 OPENCODE_GO_CUSTOM_API_KEY 等自定义名)。
  • 或直接编辑 ~/.dsh/settings.yaml
llm-pi-ai:
  providers:
    opencode-go-autosync:
      apiKeyEnv: OPENCODE_API_KEY
      api: openai-completions
      baseURL: https://opencode.ai/zen/go/v1
      compat:
        thinkingFormat: openai
        supportsReasoningEffort: true

插件首次创建时会自动写入上述 api / baseURL / compat / apiKeyEnv 默认值(apiKeyEnv 取上游 env[0],默认为 OPENCODE_API_KEY)。

2. 写入密钥值

任选其一(优先级:设置凭据 > 环境变量):

  • 推荐:DSH 设置页的凭据/密钥管理中,为 OPENCODE_API_KEY 填入真实 key(存入 ~/.dsh/.credentials.yaml,设置页脱敏显示)。
  • 或在启动 DSH 的环境中导出:
export OPENCODE_API_KEY="sk-..."
pnpm dsh --profile web
  • 或写入 ~/.dsh/.env / 项目 .env(被 loadLayeredEnv 载入):
OPENCODE_API_KEY=sk-...

验证:设置页中该供应商显示已配置;对话选 opencode-go-autosync 下任意模型可正常出流。

插件配置

cordis.patch.ymlopencode-go-syncconfig

字段 默认 说明
sourceURL https://models.opencode.ai/api.json 上游目录地址
sourceProvider opencode-go 上游 JSON 中的 provider key
targetProvider opencode-go-autosync 写入 llm-pi-ai.providers.<key> 的目标名
targetApiKeyEnv 上游 env[0] 覆盖目标的 apiKeyEnv(不设则用上游默认值)
targetBaseURL 上游 api 覆盖目标的 baseURL
targetCompat {thinkingFormat: openai, supportsReasoningEffort: true} 覆盖目标的 compat
extraIds [] 额外保留的私有模型 id(如 hy3-preview),上游没有时仍以空条目写入
autoSync false 是否定时自动同步
autoSyncIntervalMs 21600000 (6h) 自动同步间隔,最小 60s

示例(profiles/web/cordis.patch.yml 覆盖):

- id: opencode-go-sync
  config:
    extraIds: [hy3-preview, muse-spark-1.2]
    autoSync: true
    autoSyncIntervalMs: 43200000

常见问题

  • file:.tmp/... 安装失败 LINKED_PKG_DIR_NOT_FOUND:本地路径必须带 ./,写 file:./.tmp/...file:/abs/...
  • 上游拉取失败:按钮会回显 sync-failed: HTTP ...,检查网络或 sourceURL
  • 密钥未生效:确认 apiKeyEnv 指向的变量名与凭据/环境变量一致,且 DSH 已重启载入。

许可

MIT

上一个 Prev dsh-cliproxyapi-provider 下一个 Next dsh-interview