# DSH CodeBuddy CLI Connect [中文](./README.md) | English Reuse the CodeBuddy CLI (CodeBuddy Code) sign-in to bring its models (GLM-5.3, GLM-5.2, DeepSeek-V4-Pro, DeepSeek-V4-Flash, Kimi-K3, MiniMax-M3, Hy3, and more) into DeepSeek Harness — zero configuration, ready out of the box. ## Features - **Zero configuration**: sign in once with the CodeBuddy CLI, install the plugin, and the models appear in DSH. - **Follows re-login**: the plugin reads the CLI's own auth file (`CodeBuddyExtension/Data/Public/auth/Tencent-Cloud.coding-copilot.info`); signing in again in the CLI is picked up automatically. Other products' `.info` files in the same directory (e.g. the desktop IDE) rank as fallbacks by the `lastLogin` flag and file recency. - **Image input**: most models accept images — paste or drag one into the conversation; text-only models (e.g. GLM-5.1) report clearly that they do not support images. - **Thinking effort**: supported models expose a thinking-level selector (GLM-5.3 offers off / low / high / xhigh, GLM-5.3-Flash offers off / low / high / max). The control appears only for models whose upstream catalog declares an effort list; models without the selector use the upstream default. - **Credits and badges**: the billing multiplier (e.g. `GLM-5.2 · x0.79`) and promo badges ride the model name, synced from the server on every DSH start. Display only — it never affects the request that is sent. - **In-chat credit line**: one row always sits right below the composer box (next to the session stats strip), naming the current provider and model. On a CodeBuddy model it prefixes the remaining credit and appends the billing multiplier when the catalog knows one — e.g. `Credits 1,642 · Provider CodeBuddy · Model GLM-5.3 · x0.79` — and clicking it opens a details panel: total credit, per-package progress rows, the current model's rate, and a manual refresh. With another provider (say llm-pi-ai) the row reads `Provider llm-pi-ai · Model gpt-4o` - no multiplier, since the generic DSH model catalog carries no rate field, and no credit request. Because it shares the dock's flex line with the session stats, on a narrow window that extra segment can squeeze the host's rounds and token figures into ellipsis; the **Also show the line on other providers** switch at the top of the Available models tab (on by default) is how you reclaim that width ([#6](https://github.com/fu827707013/dsh-codebuddy-cli/issues/6)). Loading, signed-out and credit-error states each have their own wording, so the row never collapses while a CodeBuddy model stays selected. - **Daily check-in**: the account cards of Settings → Plugins → DSH CodeBuddy CLI Connect carry a Check in button that calls the CodeBuddy daily check-in endpoint and shows the outcome — success, already checked in today, or the failure reason — plus a checked-in badge per account. CN CodeBuddy accounts only (workbuddy.ai global accounts are told it is unavailable). The check-in reuses the plugin's local sign-in; the browser never sees token material. - **Multi-account management**: the Accounts tab of the settings card supports adding multiple CodeBuddy accounts via **OAuth QR-code/link sign-in**. Credentials for OAuth-added accounts are stored under `$DSH_HOME/.codebuddy-cli-accounts.json` and can be freely switched or deleted from the card. - **Account switching**: the Accounts tab lists every stored account with the active one marked **Current**; one click switches the plugin to that account — models, credit and check-in all follow the switched account immediately. With no OAuth-added account the original behavior is preserved (follow the CLI sign-in). - **Credit statistics**: the Credit statistics tab aggregates official request usage across all accounts — a summary of remaining/today/7-day/month usage, a daily stacked trend chart (hover a column to see that day's per-model usage), a per-model breakdown, and a credit-package / request-usage detail panel. Each card has its own account filter and range switch (30 days / today / 7 days / this month). - **Status card**: Settings → Plugins → DSH CodeBuddy CLI Connect shows the account, token expiry, remaining credit, and the models currently on a promo. The body is organized into four tabs — Accounts, Available models, Credit statistics, Remaining credit — with the remaining-credit tab switchable per account. - **Available models**: the same settings card lets you check which models the model pickers offer (setting `enabledModels`). CodeBuddy ships 15+ models and listing all of them fills the picker; uncheck the ones you do not use and only your own shortlist remains. Unchecking only stops a model from being *offered* — sessions and agent presets already pinned to it keep working — and checking nothing is the same as offering everything. ## Install Prerequisite: the CodeBuddy CLI is installed and signed in (the plugin reuses that sign-in). This plugin targets **DSH `0.2.1-rc.2` and above** (below `0.3.0`). Since `0.4.0` it supports only that generation: DSH `0.2.1` removed both settings installers (`installSettingsSection` / `settings.installSection`) in favour of managed forms derived from the plugin's Loader-entry Config schema, moved the `settings.plugins.tab` slot type into the settings shell, and made `SettingsForms` inject `configEditor` / `profileContext`. The plugin follows that contract and declares its host range through `engines.dsh`. **Still on DSH `0.1.x`? Install `0.3.0` instead** (`npm i dsh-codebuddy-cli@0.3.0`): that release carries the three-generation compatibility layer and runs on `0.1.2`, `0.1.5` and `0.1.7+`. Newer releases no longer support older hosts, and vice versa. ```sh # Web (recommended, ships prebuilt artifacts) dsh plugin --profile web add dsh-codebuddy-cli dsh web # Or install from GitHub source dsh plugin --profile web add github:fu827707013/dsh-codebuddy-cli dsh web # Desktop dsh plugin --profile desktop add dsh-codebuddy-cli dsh --profile desktop ``` **Manual update** to the latest release (`update` refreshes the version range in the profile's `package.json` and reinstalls): ```sh # Web dsh plugin --profile web update dsh-codebuddy-cli dsh web # Desktop dsh plugin --profile desktop update dsh-codebuddy-cli dsh --profile desktop ``` Restart the matching entry point afterwards (`dsh web` / DSH Desktop) so the new module is loaded; the version shown on the settings card confirms the update landed. After installing, switch to a CodeBuddy model in that interface's model picker. Under Web the settings card shows the account, token expiry, and remaining credit; under TUI the `authFile` path is configurable in `/settings`. > **TUI users: hold off for now.** The terminal interface plugin is not yet adapted to DSH 0.1.2, and a comparable plugin was measured to crash DSH on startup under TUI (`events is not iterable`). Wait for an adapted release of the terminal interface plugin before installing this one. The plugin is verified on the **Web** and **Desktop** profiles; TUI is unverified. > > As of **0.4.5**, write operations work in DSH Desktop (add/switch/delete accounts, save model selection, check in, read credit stats). Earlier versions answered `403 {"error":"origin-required"}` on save because the desktop shell strips the `Origin` header when forwarding to the Host. ## Auth-file location The plugin discovers the CodeBuddy CLI sign-in in this order: 1. the plugin's configured `authFile` path (editable in the Web settings card / `/settings`); 2. the `CODEBUDDY_CLI_AUTH_FILE` environment variable; 3. the platform default auth directory (scanning every `*.info` file: the CLI's own `Tencent-Cloud.coding-copilot.info` first, then files whose account carries `lastLogin: true`, then the most recently written): - Windows: `%LOCALAPPDATA%\CodeBuddyExtension\Data\Public\auth\` (falls back to `%APPDATA%`) - macOS: `~/Library/Application Support/CodeBuddyExtension/Data/Public/auth/` - Linux: `~/.config/CodeBuddyExtension/Data/Public/auth/` - WSL: the mounted Windows profile first Token refreshes are stored in `$DSH_HOME/.codebuddy-cli-auth.json`; the CLI's own auth file is **never written** — whichever side holds the fresher token wins. ## Command line ```sh dsh plugin --profile exec dsh-codebuddy-cli status # sign-in state and remaining credit dsh plugin --profile web exec dsh-codebuddy-cli status --json # machine-readable output dsh plugin --profile web exec dsh-codebuddy-cli doctor # secret-free environment diagnostics dsh plugin --profile web exec dsh-codebuddy-cli logout # clear the plugin-owned credential copy ``` `doctor` also reports whether the auth file was found and whether the host bundle process is alive (pid), and prints a hint for the next step. `logout` removes only the plugin's own copy; the CodeBuddy CLI keeps its sign-in. ## Known limitations - Verified on the **Windows** DSH Web profile (`0.2.1-rc.2`, Node 22+); macOS and Linux follow the same directory-probing logic but are untested. Under WSL the Windows environment variables must be visible, or set `CODEBUDDY_CLI_AUTH_FILE` explicitly. - Relies on the CodeBuddy CLI's client interface (not an official open API); CLI updates may require plugin adjustments. - The model list comes from the server and is refreshed on every DSH start; if that fetch fails the plugin falls back to its built-in static list (15 models) so models are selectable from the first launch. ## Disclaimer - This project is **for personal learning and research only**. It drives the user's own CodeBuddy account on their own machine; do not use it commercially or beyond reasonable personal use. - Users must comply with CodeBuddy's terms of service; any consequences (account restrictions, quota resets, service interruptions) are the user's own responsibility. - The author is not liable for any direct or indirect losses caused by using or misusing this project. - This project is not affiliated with, endorsed by, or connected to Tencent, CodeBuddy, or DeepSeek; names mentioned only describe compatibility and belong to their respective owners. ## Acknowledgments - [dsh-workbuddy-connect](https://github.com/corrinehu/dsh-workbuddy-connect) (MIT) — the reference for the upstream protocol implementation, DSH plugin structure, and provider registration. - [Sliverkiss/workbuddy2api](https://github.com/Sliverkiss/workbuddy2api) (MIT) — the original reference implementation of the upstream protocol. ## License [MIT](./LICENSE)