dsh-connect-opencode: Integrate Local OpenCode Free Models into the DSH Model Selector

Introduction

The conversational and agent capabilities of DeepSeek Harness (DSH) rely on the backends you select in “Settings > Models”. If you have OpenCode installed locally and have configured models with a cost of 0 in the provider directory, these resources are typically only used within the OpenCode client or the opencode serve workflow and will not automatically appear in the DSH model list.

The following introduces the community plugin dsh-connect-opencode (maintainer: serra006, current version: 0.1.2, MIT). It launches an isolated opencode serve --pure process locally, forwards requests via an OpenAI-compatible shim, and registers the free text models filtered from the OpenCode side into the DSH model selector. Tool execution is still handled by DSH, rather than OpenCode’s native tools like bash, read, or write.

What is this

The positioning of dsh-connect-opencode is to: bridge the local OpenCode (opencode serve) with DSH’s pi-ai model layer.

In the documentation, “Free” refers to: models in the OpenCode provider directory where cost.input, cost.output, cache.read, and cache.write are all 0, capable of text output, and not deprecated. Specific available models depend on your OpenCode configuration (including custom providers); if no models meet these criteria, the list in DSH will be empty.

The DSH ecosystem adopts an “Everything is a Plugin” philosophy; community directories like SkillHub are independent sites with no official affiliation to DeepSeek / High-Flyer. Before installing third-party plugins, it is recommended to review the source code and license yourself; plugins run locally with the permissions of the current DSH process.

Core Features

Model Discovery and Registration

The plugin fetches model information from OpenCode’s /provider directory, filters out entries that are entirely free (cost 0), support text output, and are not deprecated (covering both built-in Zen and custom providers), and refreshes the model list associated with the dsh-connect-opencode card in DSH “Settings > Models”.

Local Shim and Isolated Instance

The data flow is roughly as follows:

DSH (pi-ai) ──OpenAI Compatible──▶ Local shim of this plugin (127.0.0.1:<random port>)
                                  │  Protocol conversion (streaming / tool calls)
                                  ▼
                          opencode serve --pure (Isolated XDG directory + random port + Basic Auth)
  • Isolated Instance: The plugin starts opencode serve --pure on its own, without loading global plugins, and does not occupy the daily OpenCode sessions or state; data is stored in ~/.dsh/dsh-connect-opencode/.
  • Credential Reuse: To make custom providers and login states available in the isolated instance, the global opencode.json(c) and auth.json (API keys) are copied to this isolated directory. They are stored locally only and not uploaded.
  • Tool Authority belongs to DSH: All native OpenCode tools are set to deny; tool calls initiated by models are converted to OpenAI tool_calls and executed by DSH.

Configurable Options

After installation, a dsh-connect-opencode card is visible on the DSH “Settings > Models” page. You can also configure it directly in the profile root cordis.patch.yml:

Field Default Description
enabled true Whether to provide OpenCode models to DSH
binary "" Absolute path to the opencode executable; auto-discovered if empty
autoRefreshMin 15 Interval in minutes to re-fetch the official OpenCode model directory and refresh the free model list (0 = no refresh). Refreshing restarts the isolated instance during idle time (no ongoing conversations) without interrupting the current session

Example (from the original documentation):

- id: dsh-connect-opencode
  name: dsh-connect-opencode
  config:
    enabled: true
    autoRefreshMin: 10

Installation and Activation

Prerequisites

  1. DSH and OpenCode are installed (opencode located in ~/.opencode/bin, npm global, or PATH).
  2. At least one free model or provider is configured in OpenCode; you can check this using opencode models.

Node engine requirements (from package.json): ^22.19.0 || >=24.0.0.

Installation Methods

Recommended: DSH Plugin Market

Search for dsh-connect-opencode in the DSH Plugin Market and install with one click.

Manual Installation

Execute in the DSH profile directory:

npm install dsh-connect-opencode

Then, add "dsh-connect-opencode" to the end of the dsh.profile.bundles array in ~/.dsh/profiles/desktop/package.json and restart DSH.

Typical Usage

Interface and Configuration

After installing and restarting, open DSH “Settings > Models”, confirm that enabled is turned on in the dsh-connect-opencode card; set binary and autoRefreshMin as needed. Select the OpenCode free models provided by this plugin in the model selector to use for conversations.

CLI Self-Check

In the plugin package directory (or the bin path after global installation), you can use:

node bin/cli.js doctor   # Check if the opencode executable is found
node bin/cli.js models   # List discovered free models
node bin/cli.js chat "Hello"   # Send a message through the full chain

If the model list is empty, run node bin/cli.js models first to check discovery results; you need to configure providers with free tiers in OpenCode (such as OpenCode Zen free tier or custom free providers).

Use Cases and Notes

Who is it for

  • Users who have already configured free models in OpenCode and want to unify model selection in DSH while using DSH toolchains for agent development.
  • Scenarios requiring reuse of OpenCode login states and custom providers locally without mixing them with daily OpenCode sessions.

Free Models and Upstream Limitations

The plugin only bridges OpenCode’s own free models and does not provide additional quotas. Quotas, regional availability, and model existence are determined by OpenCode / models.dev and respective providers. Common situations mentioned in the documentation include:

  • Rate limiting (e.g., 429): Zen free tier is quota-based by exit IP and may be restricted during peak hours.
  • Region restrictions (REGION_BLOCKED).
  • Cost being 0 in the directory only indicates nominal free status, not guaranteed accessibility or long-term availability.
  • Free tier client restrictions (e.g., 403 FreeTierError): The plugin forwards via the official opencode serve; behavior may change if upstream policies change.

When encountering the above errors, the plugin passes through upstream errors and does not falsely report them as API key invalidation. You can switch to other free models or lower the reasoning tier.

Known Boundaries

  • Image Input: Only accepts base64 data URLs (PNG/JPEG/WebP/GIF), total request ≤ 8 MB.
  • Sampling Parameters: Does not forward temperature, max_tokens, etc.; reasoning tiers are only mapped when the model declares variants.
  • Protocol Compatibility: Field names for structured output on the OpenCode side may change with versions; if tool calls are abnormal, run bin/cli.js chat first to verify and submit an issue to the repository.

Security and License

Please read the source code and MIT license on the GitHub Repository before installing. The protocol layer is ported and simplified from ow-bridge (LaoDing, MIT); the plugin structure references dsh-connect-workbuddy (dingminhua, MIT).

Conclusion

dsh-connect-opencode integrates the free text models already configured in local OpenCode into the DSH model selector, completes protocol conversion via an isolated opencode serve --pure and a local OpenAI-compatible shim, and keeps tool execution on the DSH side. If you use both OpenCode and DSH, you can check the instructions and issues on the community directory or GitHub:

  • Directory Page: https://www.skillhub.cn/plugins/serra006/dsh-connect-opencode
  • GitHub: https://github.com/serra006/dsh-connect-opencode
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye