# dsh-opencode-compat [中文](README.md) An independent DeepSeek Harness Cordis bundle for OpenCode Zen request compatibility. No edits to installed dependencies are required. Ships executable ESM, with no install/build scripts. ## Install Requires Node.js 22+. Development baseline: DSH CLI 0.1.5-rc.1 / pi-ai 0.85.1. ```sh dsh plugin --profile web add github:dooooling/dsh-opencode-compat#v0.1.1 dsh web ``` Stop and restart the existing DSH process. Pin a reviewed full commit SHA instead of a tag where reproducibility is important. Configure Muse with `api: openai-responses`; this plugin does not translate Chat Completions payloads. Credentials and model selection remain managed by DSH. ## Behavior - Intercepts only POST inference requests to HTTPS `opencode.ai` at the default port: `/zen/v1/{responses,chat/completions,messages}` and `/zen/go/v1/{responses,chat/completions,messages}`. - Maps existing conversation identities to stable `ses_` identifiers and sets a configurable `opencode/` User-Agent. Native identifiers are preserved. Sources: `x-opencode-session`, `session_id`, `x-session-id`, `x-client-request-id`, then `prompt_cache_key`. No random/process-wide fallback is generated. - Removes the encrypted-reasoning include and entire historical reasoning items (including summaries) only for Muse Responses requests. Tool calls/results are retained. Stored sessions and response streams are not modified. - Uses process-global fetch interception, not a Cordis-scoped service hook. One instance per process. Captured fetch references and custom transports can bypass it. - Preserves authorization, abort signals, Node dispatcher options, and response streams. No request/credential logging or automatic retries. - Unload restores fetch without clobbering wrappers installed by other plugins. Existing manual patches are not automatically reverted. ## Configuration In your profile's `cordis.patch.yml`: ```yaml - id: opencode-compat config: enabled: true clientVersion: 1.18.31 rewriteClientHeaders: true stripMuseReasoning: true ``` Version syntax is numeric semver >= 1.17.0. It is a compatibility setting, not installed-client detection. Set individual flags to false to disable the corresponding behavior. This is an unofficial community workaround based on [9router #4105](https://github.com/decolua/9router/pull/4105) and [oc2api #2](https://github.com/zhuweiyou/oc2api/pull/2). It changes client identification; upstream can reject it at any time. It does not provide quota, credentials, regional availability or a guarantee that third-party access is permitted. Do not treat successful tests as a service commitment. ## Uninstall / development ```sh dsh plugin --profile web remove dsh-opencode-compat npm ci npm run check npm test npm pack --dry-run ``` Restart after uninstall. Offline tests include actual Cordis lifecycle loading; CI covers Windows/Linux on Node 22/24. See the Chinese README for migration notes and troubleshooting. MIT license. ## v0.1.1 free-tier compatibility Based on [9router #4132](https://github.com/decolua/9router/pull/4132). The new default option `completeFreeTierFingerprint: true` appends missing bash/glob/grep/read declarations and forces upstream streaming, only for anonymous or Bearer public requests to /zen/v1/responses and /zen/v1/chat/completions with model IDs ending in -free or big-pickle. Existing tools are preserved. Go, paid credentials and messages are excluded from this new feature. Non-stream callers receive reconstructed JSON (buffered until completion); streaming callers retain the original response. HTTP errors pass through; incomplete or failed SSE throws. Injected declarations are explicitly non-executable compatibility placeholders, not shell bridges. The plugin does not execute them or map bash to PowerShell. A model that ignores their instructions can cause an unknown-tool error in DSH. Full agent tool execution has not been verified. Disable with `completeFreeTierFingerprint: false`. Stop DSH before updating and restart afterward. The v0.1.0 tag is unchanged.