Skip to content
Projects

Duskriver/dsh-opencode-go

View on GitHub

About

The best DSH plugin for opencode-go subscribers

Other Projects

How these counts are measured

Measured star growth

in 24h
+2
in 7 days
+27
in 15 days
+54
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.en.md

Original

DSH-OCGO

dsh-opencode-go

简体中文 · Highlights · Quick Start · Console · Architecture · FAQ · Advanced Guide · Development

OpenCode Go provider, live quota visibility, smart request-budget estimation, and multi-account failover for DeepSeek Harness (DSH). Built on Cordis, this plugin delivers full protocol conversion alongside an in-conversation quota pill, pre-output account failover, session-level prompt-cache affinity, an official workspace history dashboard, and an all-in-one sidebar console.

Supports Chinese and English, following DSH's interface language. The screenshots below show the default DSH Native (Dark) theme in Chinese (real redacted DSH Desktop captures alongside real plugin component views with sample data); you can switch to OpenCode Go Classic at any time under Appearance, and both themes follow the Host's light/dark scheme.

DSH Desktop overview: sidebar OpenCode Go entry, bottom-left sidebar quota card, and concentric dual-ring composer usage pill


✨ Highlights

  • 🧭 Sidebar Console (7 Sub-pages, opt-in): Enable Sidebar entry to add a hand-drawn go stone entry right after the plugin market in DSH's sidebar, opening a full-page console (Overview / Usage / Accounts / Models / Appearance / Advanced / About) with 0-account onboarding, inline account switching, and an interactive 7-day bar chart, sharing one state controller with Settings. Off by default; older hosts automatically stay on Settings + the in-place history dialog.
  • 🧮 Smart Per-Model Call Estimation & Workload Profiles: Assign each account's OpenCode Go tier (Go ($10) / Go Plus ($40) / Go Teams ($20)). Combining gateway /models rates, monthly tier caps, and the three quota windows, the plugin lets you compare Light Q&A / Coding / Long Agent workload profiles and subscription plans in the model detail card, surfaces bottleneck windows and Peak / Off-peak multipliers inside the composer popover, and shows a monthly alert badge when monthly usage reaches ≥ 80% or hits a limit.
  • 📊 5 Input Quota Pill Styles + 3×2 Live Sandbox + Bento Theme Previews: Keep subscription usage beside the chat composer in Badge (default), Concentric rings, Level fill, Dual mini-bars, or Minimal rings with an independent Show border toggle, rich Native / Classic Bento previews, a live 6th-tile sandbox, viewport collision clamping, and lazy per-account quota previews in the switcher.
  • 🛡️ Automatic Multi-Account Failover: Manage up to 20 accounts with whole-row multi-expand comparison, one-click Set as current, and drag-to-reorder priority. On HTTP 401/403, 429, or exhausted quota, the plugin silently retries backup accounts before output starts (temporary 429 cooldowns borrow backups without rewriting primary order).
  • 💰 Official Workspace History Dashboard: Powered directly by OpenCode Console's daily CSV across all clients in the selected workspace (UTC calendar days), with today / 7 / 30 / 90-day ranges, Token breakdown (interactive clickable legend filtering) / Request count / Usage amount trend modes, a sticky-column detail table with Cache hit rate, distribution cross-highlighting, and CSV export.
  • 🆓 Dual Dynamic Model Catalogs (Free is opt-in, off by default): Go and platform Free routes discover models independently from their /models endpoints, preserve overlapping IDs, support enabled/disabled filters, sorting (default / quota rate / context / release), one-click Enable all / Disable all with affected counts and Undo, 3-state input modality indicators, quick thinking-budget chips, and a guided Free-channel enable card.
  • ⚡ Connection Probe, Prompt-Cache Affinity & Single Save Gesture: Test draft gateway and proxy latency directly from Advanced via keyless /models discovery, read human-friendly unit conversions (≈ 5 min, ≈ 20.0 MB, ≈ 4.2 MP), reset individual fields, copy credential-free Markdown diagnostics from About, and keep every non-advanced edit applied immediately.

🚀 Quick Start

Requires DSH 0.2.1-rc.5 or later. See development for the validation workflow.

1. Install the plugin

💡 Release note: The repository carries the 0.5.4 release: a native DSH Go console plus a resident quota line above the composer (account + 5h xx% · W xx% · M xx%, auto-refreshed), including the fix for quota not loading after the first account switch. The package is the tracked dsh-opencode-go-0.5.4.tgz at the repository root.

Option A: Manual install from the tracked .tgz tarball (recommended for latest release / DS Bot & Desktop)

  1. Download the .tgz package: Download dsh-opencode-go-0.5.4.tgz (direct raw link) to a space-free local folder (e.g. ~/Downloads/dsh-opencode-go-0.5.4.tgz). If you cloned this repo, the tarball is already in the root directory.
  2. Install via DSH / DS Bot UI: Go to Plugins → Add plugin (remove any older dsh-opencode-go entry first — your saved keys and settings are preserved), paste the full local path to the .tgz file, click Install → Enable now, and fully restart the desktop app or dsh web.
  3. Or install via CLI:
    # Web profile (replace with your local .tgz path)
    dsh plugin --profile web add ./dsh-opencode-go-0.5.4.tgz
    
    # Headless profile
    dsh plugin --profile headless add ./dsh-opencode-go-0.5.4.tgz
    
    See the advanced guide for troubleshooting ERR_PNPM_MISSING_TARBALL_INTEGRITY and offline updates.

Option B: Install from npm (when npm has synced the latest release)

  1. Open Plugins → Add plugin, enter dsh-opencode-go, and click Install → Enable now.
  2. Or run dsh plugin --profile web add dsh-opencode-go and restart dsh web.

Install the plugin in DSH

2. First-time setup

  1. After restarting, open Settings → OpenCode Go and verify the version reads 0.5.4.
  2. Under Accounts, click Add account, enter a name and your OpenCode Go API key, and select your Subscription plan (for display-only request-count estimates).
  3. (Optional) Under Overview, enable Sidebar entry to add the hand-drawn go row to DSH's sidebar and unlock the full 7-tab console.
  4. Select any model under DSH OpenCode Go in a conversation and check live usage right beside the composer.

📱 DSH Go app (0.5.4)

In the DSH Go native UI:

  • A compact line account 5h xx% · W xx% · M xx% is kept above the composer (account name plus the three quota windows, on by default; separators tighten automatically when 100% values would exceed 24 characters); tap it to open the native console. The line uses the plugin's own transparent monochrome mark (native secondary-icon look).
  • The Go console capsule is kept as the management entry and fallback for older apps. It opens the same native page:
    • Quota: the default/session account's 5-hour, weekly and monthly used percentages, relative reset times, warning/rate-limit states and refresh. The console refreshes every 60 seconds while open and reads the new account immediately after a switch or removal.
    • Accounts: current-account dropdown, plan, auto-failover; add/remove account live in collapsed sections.
    • Models: search, paginated multi-select switches (8 per page), previous/next, enable/disable all, refresh catalog.
    • The three areas are tabs so the page stays compact; actionable list rows are gone, so a > no longer implies the wrong interaction.
  • The native settings form gains Keep the Go quota above the composer (on by default). Turning it off hides only the composer line; the console capsule and the Web usage pill are unaffected.

The API-key field is plain text (DSH Go views have no password input). The key is written to the host credential service on submit and immediately cleared; it is never echoed back or logged. The native settings page hides Web-only appearance/style fields and the fields now managed by the console, while the full DSH Go Web mode keeps the complete desktop-like UI. Requires the local engine + dsh-go bridge; SSH/relay hosts fall back to the Web entry.

Install 0.5.4: download dsh-opencode-go-0.5.4.tgz and use Plugins → Add plugin → local path in DSH Go.

Single Save gesture: Only Advanced settings (gateway URLs, proxy, timeouts, and image budgets) require clicking Save; every other toggle and option applies immediately.


🧭 Sidebar Console (7 Sub-pages)

Enabling Settings → OpenCode Go → Overview → Sidebar entry (sidebarEntry, off by default) registers a hand-drawn go stone entry after the plugin market in DSH's sidebar (the Settings nav row uses the same mark). Clicking it opens a full-page console in the main area:

OpenCode Go hand-drawn go entry in the DSH sidebar

OpenCode Go sidebar console Overview page with sample data

Tab What it covers
Overview UTC today's 4 KPIs (requests, tokens, cache hit rate, spend), current account 3-window quotas & auto-failover switch, Go / Free service status, fallback chain summary, 7-day token sparkline, and quick-link cards
Usage Full-page official workspace history dashboard with daily stacked token/request charts, model distribution rankings, detail table, and official CSV export
Accounts Add/rename/replace key/remove accounts, drag-to-reorder priority, per-account subscription tier selector, expanded Bento 3-window quota tiles, and automatic fallback
Models Independent Go / Free tabs, search & filters, one-click Enable all / Disable all, full-capacity request estimates, gateway pricing details, and context / max-output / thinking-budget overrides
Appearance Live DSH Native / OpenCode Go Classic theme preview, usage display mode, 5 input pill styles + border toggle preview, and sidebar quota toggle
Advanced Go / Free gateway URLs, HTTP(S)/SOCKS5 proxy, catalog refresh & timeout controls, and per-request image budgets (the only tab backed by the Save/Discard bar)
About Version, package & host metadata, sidebar slot status, live runtime diagnostics (service, Free, history, account count, last refresh), and project links
  • Graceful fallback: When the entry is off, or on hosts without the sidebar.panellist slot, no sidebar row is registered — Settings keeps full controls and the composer pill's Usage history button opens the built-in history dialog. Disabling the switch cleanly leaves the page before unregistering the slot pair.

🧮 Smart Per-Model Call Estimation

OpenCode Go shares percentage-based quotas across three windows (5-hour, weekly, and monthly). Using gateway-published tariffs, tier caps, and live multiplier schedules, the plugin translates percentages into concrete request estimates across three views:

  1. Per-account subscription tier (display-only): Under Accounts, choose Go ($10), Go Plus ($40), or Go Teams ($20). Strictly for UI conversion — never alters requests or upstream billing.
  2. Full-capacity request budgets in the Model card: Selecting any Go model under Models shows estimated full-capacity calls across the 5-hour (20%), weekly (50%), and monthly (100%) caps using a typical cached coding-agent request profile (1K input + 44K cache read + 450 output), plus peak-hour multiplier notes when scheduled multipliers apply.
  3. Live remaining calls in the composer Usage Pill popover: Computes ~N calls left (or 0 calls left) for the active Go model based on the tightest bottleneck window and any active UTC time-of-day multiplier (showing a Peak or Off-peak badge with multiplier details on hover).

Expanded composer usage pill popover showing three quota windows and live remaining call estimation for the active model

Models page: Go/Free channels, batch toggles, full-capacity request estimates, and gateway pricing details

Actual call counts vary with conversation length and prompt-cache hit rates; treat estimates as practical planning guidance.


📊 Input Quota Pill & Appearance

Open Appearance (in the console or Settings — all changes apply immediately):

Appearance settings: Native/Classic live theme previews, 5 input quota pill styles, and border toggle

  • 5 input quota styles + independent border toggle: Choose from Badge (default), Concentric rings, Level fill, Dual mini-bars, and Minimal rings with live previews, and combine any style with Show border (framed pill fill vs. borderless transparent look).
  • Display modes & smart polling: Auto (default) shows the pill only for DSH OpenCode Go models; Always keeps it visible with other providers; Off hides it and stops polling. Polls quietly every minute while visible, pauses when hidden, and refreshes immediately on return. Click the account chip in the popover to switch accounts in place.
  • Independent sidebar quota card: Enable Show quota in the sidebar to see all three windows in the expanded sidebar (or a compact icon when collapsed); open the account chip to search and preview any account read-only, and use the chip’s return segment to switch the view back to the conversation’s main account.
  • Two cohesive themes (appearanceTheme): DSH Native (default) follows DSH and third-party themes via public Host semantic tokens while keeping strong control borders and chart series on WCAG 1.4.11 (≥ 3:1) contrast values; OpenCode Go Classic keeps warm paper / charcoal surfaces and terracotta accents while following the Host's light/dark scheme.

🛡️ Multi-Account Management & Failover

Manage up to 20 accounts under Accounts:

Accounts page: drag reordering, subscription plans, expanded Bento quota tiles, and automatic fallback

  • Drag order = priority: The first account is the default for new conversations. The composer capsule changes the main account for this conversation. The sidebar account list lets you inspect any account's quota.
  • Pre-output automatic fallback: With Automatic fallback enabled, eligible quota, credential and rate-limit errors try available accounts in saved order. A serving backup becomes the conversation's main account after quota or credential failures. Transient rate limits borrow a backup for the request. Requests with output or billed usage and canceled requests are never re-sent.
  • 5-minute cooldown & credential isolation: Rejected keys cool down in memory for 5 minutes to avoid retry storms. Keys live exclusively in DSH's credential service and are never echoed back to the UI.

💰 Official Workspace History Dashboard

Open the Usage tab in the sidebar console for the full-page view (or click Usage history in the composer pill to open the built-in dialog when the sidebar entry is off or unsupported):

Full-page official workspace history dashboard with KPIs, daily stacked chart, and model breakdown (sample data)

  • Single official CSV source: Requests, input/output/cache tokens, official usage amount (summed directly from cost_micro_cents, where 1 USD = 100,000,000 units — not an extra Go charge), daily charts, and model tables all come from OpenCode Console's daily UTC CSV across Today / 7 / 30 / 90 days, with one-click Export CSV.
  • Independent viewing & privacy-first: Defaults to the active inference account and covers all clients in that key's workspace; switching the viewed account updates the three quota bars without changing your conversation account. Fetches on demand (30-second Host cache, no background polling); keys never leave the Host, and regular reports send only aggregate figures and provider / model / day to the browser. See usage analytics notes.

🆓 Free Channel (opt-in, off by default)

DSH OpenCode Free is an explicit opt-in and defaults to off to avoid unintended usage or ToS exposure. Enable it under Overview → Free channel (applied immediately, or set freeEnabled: true). While off, the plugin neither registers dsh-opencode-free, fetches freeBaseURL's catalog, nor exposes Free models; turning it off withdraws the route while allowing in-flight streams to finish.

When enabled:

  • Endpoint-bound key reuse: Saved Go keys are reused (and follow Automatic fallback) only when freeBaseURL is the official HTTPS endpoint (https://opencode.ai on default port) or shares the exact origin of baseURL (e.g., a shared reverse proxy). Any other custom or plaintext HTTP freeBaseURL falls back to anonymous Bearer public without reading or sending saved keys.
  • Official CLI UA & isolated Bun runtime: Requests use the official OpenCode CLI user agent (opencode/latest/2.2.5/cli) through a dedicated HTTP worker launched from version-pinned @oven/bun-*@1.4.4 optional platform packages (native binaries directly, no postinstall build scripts).
  • Isolated rate-limit cooldown: Honors upstream Retry-After and fails fast with FREE_COOLDOWN; shared Free quota or IP limits never rotate Go accounts.

⚠️ Risk: The Free channel relies on the upstream public Free entry point with an official CLI user agent. It may violate upstream terms of service or trigger rate limits / account restrictions. Use at your own discretion and avoid production or large-scale automation.


⚙️ Model Overrides & Advanced Settings

Model Catalog & Capacity Overrides

Under Models, manage OpenCode Go and Free catalogs separately:

  • Visibility & batch toggles: Non-deprecated models are enabled by default and deprecated ones default to disabled. Search by name/ID, filter by New in 7 days / Customized / Deprecated, and use Enable all / Disable all for atomic single-click updates across the current view (skipping configurationMissing models).
  • Pricing & capacity edits: Inspect /models input / output / cache-read / cache-write rates, context-tier pricing, and multiplier notes in the detail card (Free models display Free). Override context window, max output, and custom thinking budgets live with no restart.
  • Default output safety cap: Any model advertising an output capacity above 65,536 defaults to 65,536 tokens unless overridden by caller or settings (reported to DSH for compaction budgeting); smaller models keep their SDK defaults.

Grouped Advanced Settings (the only Save-gated tab)

Open Advanced to tune connection, timeout, and image parameters (click Save in the bottom bar to apply):

Advanced settings: connection and proxy, cache and timeouts, image handling, and reset

  • Connection & Proxy: Configure baseURL, freeBaseURL, and HTTP / HTTPS / SOCKS5 proxies (socks5://127.0.0.1:7890), applied to conversations, usage polling, history analytics, and catalog discovery.
  • Cache & Timeouts: Tune catalog refresh interval, streamIdleTimeoutMs, requestPreparationTimeoutMs, and requestTimeoutMs.
  • Request Retry: Configures the Go route's host-executed retry policy (defaults to normal mode with a 30,000 ms max delay / Retry-After cap to absorb common gateway rate limits); adjust retry mode, max retries, and max delay live under Advanced without restarting (Free keeps its passive cooldown behavior).
  • Image Handling: Configure per-request maxImages, encoded payload limit, pixel budget, and target image bytes (up to 4 images prepared in parallel).
  • Reset to defaults: Clears Advanced overrides without affecting saved accounts or credentials.

🛠️ Architecture & Verification

dsh-opencode-go dual-route protocol and pre-output failover architecture

Source modules are organized by domain, communicating between Host and browser via DSH Typert RPC:

Domain Modules
Plugin composition, settings & contracts index.ts, config.ts, contracts.ts
Inference, catalog, pricing & quota estimation adapter.ts, catalog.ts, pricing.ts, quota-estimate.ts, conversion.ts, google.ts, sdk-types.ts
Accounts, live quota, CSV analytics & transport accounts.ts, analytics.ts, transport.ts
Opt-in Free channel & Bun HTTP worker free-channel.ts, free-runtime.ts, free-transport.ts, free-http-worker.ts, free-policy.ts, free-protocol.ts, free-socks-tunnel.ts
Client registration, state & host slots client/index.ts, client/controller.ts, client/host-slots.ts, client/settings-nav-icon.tsx, client/pages/nav.ts
Sidebar console (7 sub-pages) client/pages/Page.tsx, OverviewPage.tsx, UsagePage.tsx, AccountsPage.tsx, ModelsPage.tsx, AppearancePage.tsx, AdvancedPage.tsx, AboutPage.tsx, types.ts, client/GoMark.tsx, client/build-info.ts
Settings, quota pills, dashboard & themes client/Section.tsx, client/UsagePill.tsx, client/AnalyticsDialog.tsx, client/presentation.ts

The x-opencode-session header carries a stable form of the conversation ID for gateway prompt-cache affinity (printable ASCII IDs pass through verbatim; non-printable or reserved-prefix IDs are hashed with sha256 + base64url, containing no message content).

Development requires Node.js ^22.19.0 || >=24.0.0, pinning DSH 0.2.1-rc.5 and Cordis 4.0.5 (runtime Cordis ^4.0.5):

npm ci
npm test
npm run typecheck
npm run check:dist
npm run pack:release
npm run check:pack
npm run verify

Per repository policy, every change touching packed files updates the single tracked root tarball (dsh-opencode-go-<version>.tgz) via npm run pack:release, and npm run check:pack verifies byte-for-byte parity in CI. See development for installed-consumer and Headless checks.


❓ FAQ

Q: Why does installing by package name still give an older version (e.g. 0.4.0) or a collapsed settings panel in DS Bot?

The npm registry may lag behind the repository. Download dsh-opencode-go-0.5.4.tgz locally, remove the older dsh-opencode-go entry (saved keys and settings remain intact), install from the local .tgz path, and fully restart DS Bot / DSH. See manual installation and offline updates.

Q: Why don't I see estimated call counts on a model or in the composer popover?

Estimates apply to Go channel models with published /models prices and monthly tier caps (Free or unpriced models omit estimates). The composer popover shows live remaining calls only when the active conversation model is a DSH OpenCode Go model and quota readings succeed. Verify each account's subscription plan under Accounts.

Q: Why is there no OpenCode Go entry in the sidebar?

The sidebar entry is opt-in and off by default. Enable Settings → OpenCode Go → Overview → Sidebar entry (applied immediately). On hosts that do not declare sidebar.panellist, the plugin keeps using Settings and the pill's built-in history dialog.

Q: Why is the usage pill hidden next to the chat input?

Auto mode displays the pill only while a DSH OpenCode Go model is selected. Switch Appearance → Usage display to Always (applied immediately) to keep it visible with other providers, and make sure a valid key is configured.

Q: Where is DSH OpenCode Free, or why does Free report MISSING_BUN_RUNTIME?

Free is opt-in and off by default — enable it under Overview → Free channel. Free uses @oven/bun-<platform>@1.4.4 optional packages; if optional dependencies were skipped (--omit=optional), reinstall with optional dependencies enabled (Go is unaffected).

Q: Why does a long conversation return HTTP 400?

Context plus output allowance likely exceeded the model's context window. Run /compact in the conversation or lower Max output under Models. Explicit context overflow errors are handed back to DSH's native recovery flow.

Q: What should I do about HTTP 429 rate limits when dispatching many parallel subagents on a single account?

Dispatching many parallel subagents on the same provider/model with a single account can trigger upstream rate limiting (often returning a 15–18s Retry-After). The plugin defaults the Go route's retry maxDelayMs cap to 30,000 ms (tunable under Advanced → Request retry, or via retryPolicy in a patch config). If rate limits persist, reduce subagent concurrency, stagger dispatches, or add multiple accounts with Automatic fallback enabled.


📦 Updates & Uninstall

Manual update via .tgz (recommended when npm is behind)

dsh plugin --profile web remove dsh-opencode-go
dsh plugin --profile web add /path/to/dsh-opencode-go-0.5.4.tgz

In DS Bot / DSH Desktop UI, remove the old plugin entry, add the local .tgz path, enable it, and fully quit and reopen the app.

Online update & uninstall

# Update from npm (replace web with headless for Headless profile)
dsh plugin --profile web update dsh-opencode-go --latest

# Uninstall
dsh plugin --profile web remove dsh-opencode-go

📚 More Documentation

Explore related projects

Loading…