@mars-sea/dsh-commandcode-provider 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +59 -135
- package/README.zh-CN.md +58 -136
- package/lib/client.js +154 -23
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +16 -2
- package/lib/index.js +37 -7
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.6.2] - 2026-08-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Stored API keys can now be cleared, not just replaced.** A "Clear stored key" action on the default key and on every account stages a removal (with a visible "will be cleared on save" badge and an undo); saving unsets the credential through the Host's `credentials.unset`, so the account reports unconfigured again and falls back to its other key sources. Previously a bad key could only be overwritten, never removed.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **Free models now lead the model picker.** Models whose deals mark them free (currently Ox Alpha and Laguna S 2.1) sort ahead of every paid tier — they cost no credits and work on any account, so they make the best defaults. The rest of the order is unchanged: Go → GOAT → Pro → Provider/Max, alphabetical within each tier.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **An invalid or expired API key no longer hides behind "Some endpoint data unavailable".** When every account endpoint rejects with 401 (wrong/expired key), the usage card now shows a prominent "API key invalid or expired" banner with an actionable hint instead of the generic partial-data note; a total 5xx or network outage gets their own distinct banners too. The `/commandcode` command surfaces the same cause up front. Partial failures keep the existing degraded view.
|
|
20
|
+
- **Retry and credential failure messages are now bilingual (English + 中文).** The harness UI renders these messages verbatim inside its retry/turn-error chrome, so the "all accounts exhausted" rate-limit error, the all-401 credential error, and the single-account 401 error now carry both readings in one string — no more parsing an English-only wall of text to learn when your window resets.
|
|
21
|
+
|
|
7
22
|
## [0.6.1] - 2026-08-22
|
|
8
23
|
|
|
9
24
|
### Added
|
package/README.md
CHANGED
|
@@ -10,145 +10,67 @@
|
|
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
|
11
11
|
[](https://www.npmjs.com/package/@mars-sea/dsh-commandcode-provider)
|
|
12
12
|
|
|
13
|
-
Unofficial [DeepSeek Harness](https://deepseek-harness.github.io/deepseek-harness/) LLM provider plugin for **Command Code**, ported from [pi-commandcode-provider](https://github.com/patlux/pi-commandcode-provider) (MIT).
|
|
13
|
+
Unofficial [DeepSeek Harness](https://deepseek-harness.github.io/deepseek-harness/) LLM provider plugin for **Command Code**, ported from [pi-commandcode-provider](https://github.com/patlux/pi-commandcode-provider) (MIT).
|
|
14
14
|
|
|
15
15
|
> This is a community integration. You need your own Command Code account and API key or subscription, and Command Code's terms apply. This project is not affiliated with Command Code, Inc.
|
|
16
16
|
|
|
17
17
|
## What you get
|
|
18
18
|
|
|
19
|
-
- **Plugin bundle**
|
|
20
|
-
- **Dedicated
|
|
21
|
-
- **Multi-account rotation
|
|
22
|
-
- **API key
|
|
23
|
-
- **Model-picker annotations
|
|
24
|
-
- **Plan-aware picker
|
|
25
|
-
- **Reasoning-effort support**
|
|
26
|
-
- **Image input
|
|
19
|
+
- **Plugin bundle** — install into any dsh profile with `dsh plugin add`; registers a `commandcode` provider route with a live model catalog.
|
|
20
|
+
- **Dedicated settings page** — API key, connection options, a live account-usage card, and a "Hide out-of-plan models" toggle.
|
|
21
|
+
- **Multi-account rotation** — when one account hits its usage limit, requests switch to the next account automatically. See [Account rotation](#account-rotation).
|
|
22
|
+
- **Flexible API key setup** — via the settings page, an environment variable, or the official CLI login file.
|
|
23
|
+
- **Model-picker annotations** — minimum plan, active deal or `FREE` badge, peak/off-peak state, image support, and context window; free models listed first.
|
|
24
|
+
- **Plan-aware picker** — models above your subscription tier are hidden by default (toggleable).
|
|
25
|
+
- **Reasoning-effort support** — models with selectable reasoning effort levels expose them in the picker.
|
|
26
|
+
- **Image input** — Vision-capable models accept images.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## Getting an API key
|
|
31
|
-
|
|
32
|
-
Command Code API keys never expire. The easiest path is the official CLI (Node.js 22+):
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
npm i -g command-code@latest
|
|
36
|
-
cmd login # macOS/Linux; native Windows: cmdc login
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
`cmd login` opens a browser to authenticate; the key is written to `~/.commandcode/auth.json` — picked up automatically as a last-resort fallback. Alternatively create a key in the browser ([Command Code Studio](https://commandcode.ai/studio/auth/cli)) and paste it into **Settings → Command Code**, or `export COMMANDCODE_API_KEY="user_..."`.
|
|
28
|
+
See [Screenshots](#screenshots) below for what the UI looks like.
|
|
40
29
|
|
|
41
30
|
## Install
|
|
42
31
|
|
|
43
|
-
### From npm (recommended)
|
|
44
|
-
|
|
45
|
-
The bare name `dsh-commandcode-provider` is taken by an unrelated package, so this plugin is published as **`@mars-sea/dsh-commandcode-provider`**:
|
|
46
|
-
|
|
47
32
|
```sh
|
|
48
|
-
dsh plugin --profile web add @mars-sea/dsh-commandcode-provider
|
|
33
|
+
dsh plugin --profile web add @mars-sea/dsh-commandcode-provider@latest
|
|
49
34
|
```
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
# Pin a release tag (recommended — readable and immutable)
|
|
55
|
-
dsh plugin --profile web add github:Mars-Sea/dsh-commandcode-provider#v0.2.2
|
|
56
|
-
# Or pin any exact commit by its SHA
|
|
57
|
-
dsh plugin --profile web add github:Mars-Sea/dsh-commandcode-provider#<full-commit-sha>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
The `#<ref>` suffix pins one exact revision (pnpm git-dependency syntax). Without it the install tracks the default branch, so a later push can silently change what you get.
|
|
61
|
-
|
|
62
|
-
A git install fetches **sources**, so the package's `prepare` script builds `lib/` after install. pnpm ≥10 blocks that script by default — run the `add`, then copy the **exact package key pnpm prints** into `~/.dsh/profiles/web/pnpm-workspace.yaml`:
|
|
63
|
-
|
|
64
|
-
```yaml
|
|
65
|
-
allowBuilds:
|
|
66
|
-
'@mars-sea/dsh-commandcode-provider@github:Mars-Sea/dsh-commandcode-provider#<full-commit-sha>': true
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
and re-run the `add`.
|
|
70
|
-
|
|
71
|
-
### From a local checkout
|
|
36
|
+
## Updating
|
|
72
37
|
|
|
73
38
|
```sh
|
|
74
|
-
|
|
75
|
-
npm run build # git/tarball installs do this via `prepare` automatically
|
|
76
|
-
dsh plugin --profile web add /path/to/dsh-commandcode-provider
|
|
39
|
+
dsh plugin --profile web add @mars-sea/dsh-commandcode-provider@latest
|
|
77
40
|
```
|
|
78
41
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
### What the install does
|
|
82
|
-
|
|
83
|
-
`dsh plugin add` links the package into the profile (pnpm records it under the **true package name** `@mars-sea/dsh-commandcode-provider`), appends that name to `dsh.profile.bundles`, and activates the `cordis.patch.yml` layer:
|
|
84
|
-
|
|
85
|
-
```yaml
|
|
86
|
-
- insert:
|
|
87
|
-
- id: llm-commandcode
|
|
88
|
-
name: "@mars-sea/dsh-commandcode-provider"
|
|
89
|
-
config:
|
|
90
|
-
apiKeyEnv: COMMANDCODE_API_KEY
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
The patch `name` must be the **full package specifier, quoted** — the loader imports it as a module from the profile's `node_modules`, where pnpm only links the scoped name. A bare name fails with `ERR_MODULE_NOT_FOUND` and crashes the app on boot; an unquoted `@mars-sea/...` fails YAML parsing (see [Troubleshooting](#troubleshooting)).
|
|
94
|
-
|
|
95
|
-
Verify the composed layer, then (re)start the web app:
|
|
96
|
-
|
|
97
|
-
```sh
|
|
98
|
-
dsh --profile web --dump-config # shows a "# == @mars-sea/dsh-commandcode-provider" layer
|
|
99
|
-
dsh web # or restart your running instance
|
|
100
|
-
```
|
|
42
|
+
Then restart the web app.
|
|
101
43
|
|
|
102
|
-
##
|
|
44
|
+
## Getting an API key
|
|
103
45
|
|
|
104
|
-
The
|
|
46
|
+
The easiest path is the official CLI (Node.js 22+):
|
|
105
47
|
|
|
106
48
|
```sh
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# GitHub (pinned): point at the new tag — no uninstall needed, pnpm swaps it in place
|
|
111
|
-
dsh plugin --profile web add github:Mars-Sea/dsh-commandcode-provider#v0.2.2
|
|
112
|
-
|
|
113
|
-
# local checkout: pull, rebuild, restart
|
|
114
|
-
git -C /path/to/dsh-commandcode-provider pull
|
|
115
|
-
npm run build --prefix /path/to/dsh-commandcode-provider
|
|
116
|
-
dsh web
|
|
49
|
+
npm i -g command-code@latest
|
|
50
|
+
cmd login # macOS/Linux; native Windows: cmdc login
|
|
117
51
|
```
|
|
118
52
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
> **`update` says "Already up to date" but the version did not move (pnpm ≥ 11)?** pnpm 11's `minimumReleaseAge` supply-chain policy can refuse a freshly published version. Pin the exact version instead: `dsh plugin --profile web add @mars-sea/dsh-commandcode-provider@0.2.2` (or `pnpm config set minimumReleaseAge 0 --location project` inside the profile directory).
|
|
122
|
-
|
|
123
|
-
> **Upgrading from ≤0.1.6** (or a broken hand-edited profile): if you *copied* the old patch row into your profile's own `cordis.patch.yml`, that copy still wins over the bundle layer — fix it to `name: "@mars-sea/dsh-commandcode-provider"` or remove it (see [Troubleshooting](#troubleshooting)).
|
|
124
|
-
|
|
125
|
-
> **To uninstall instead**: `dsh plugin --profile web remove @mars-sea/dsh-commandcode-provider` (the **scoped** name — pnpm records the dependency under its real name). Your API key in the dsh credential store and `~/.commandcode/auth.json` are left untouched.
|
|
53
|
+
Alternatively, create a key in the browser ([Command Code Studio](https://commandcode.ai/studio/auth/cli)) and paste it into **Settings → Command Code**, or `export COMMANDCODE_API_KEY="user_..."`.
|
|
126
54
|
|
|
127
55
|
## Verify it works
|
|
128
56
|
|
|
129
|
-
After restart
|
|
57
|
+
After restart, enter your API key in **Settings → Command Code** and save; **Settings → Models** shows a **Command Code** card, and the model picker lists the live catalog under **commandcode**. Send a message with a model your plan includes.
|
|
130
58
|
|
|
131
59
|
## Usage dashboard
|
|
132
60
|
|
|
133
|
-
The plugin registers a `/commandcode` slash command
|
|
61
|
+
The plugin registers a `/commandcode` slash command showing per-account usage:
|
|
134
62
|
|
|
135
63
|
```text
|
|
136
64
|
/commandcode (or /commandcode status)
|
|
137
65
|
```
|
|
138
66
|
|
|
139
|
-

|
|
140
|
-
|
|
141
|
-
Each endpoint degrades independently — a temporary failure of one leaves the rest visible and notes the failure inline.
|
|
142
|
-
|
|
143
67
|
## Account rotation
|
|
144
68
|
|
|
145
69
|
With several Command Code subscriptions, the plugin **switches to the next account automatically** when one hits its usage limit:
|
|
146
70
|
|
|
147
|
-
- **
|
|
148
|
-
- **
|
|
149
|
-
- **
|
|
150
|
-
- **Manual switching**: the **Active account** dropdown on the same card pins the preferred account (persisted as the `activeAccount` setting) — effective on the next request after saving. If the pinned account is exhausted, requests still rotate to another usable account, and once its window resets the pinned account serves again.
|
|
151
|
-
- **Per-account reporting**: the settings page's **Account usage** card renders one section per account with **Active / Cooling down / Invalid key** badges; `/commandcode` prints one dashboard section per account.
|
|
71
|
+
- **Setup** — use the **Account rotation** card at Settings → **Command Code** to add accounts with a label and API key; the top-level key always serves first as the `default` account.
|
|
72
|
+
- **Manual switching** — the **Active account** dropdown pins a preferred account; if it is exhausted, requests fall back to other accounts and return once its window resets.
|
|
73
|
+
- **Status** — the **Account usage** card and `/commandcode` report per-account state.
|
|
152
74
|
|
|
153
75
|
The equivalent YAML (`$DSH_HOME/settings.yaml` or composition config):
|
|
154
76
|
|
|
@@ -163,53 +85,33 @@ llm-commandcode:
|
|
|
163
85
|
apiKeyEnv: COMMANDCODE_API_KEY_3
|
|
164
86
|
```
|
|
165
87
|
|
|
166
|
-
Each account may also carry a literal `apiKey` in composition config (winning over its `apiKeyEnv`); key literals are never stored in the settings document.
|
|
167
|
-
|
|
168
88
|
## Configure
|
|
169
89
|
|
|
170
|
-
**Settings → Command Code**
|
|
90
|
+
**Settings → Command Code** covers the API key, API base URL, working directory, and request/stream timeouts; once a key is saved, a live **Account usage** card appears at the top of the page.
|
|
171
91
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
<img src="assets/screenshots/settings-page.png" alt="Command Code settings page with the account usage card" width="640">
|
|
175
|
-
|
|
176
|
-
The same knobs live in `$DSH_HOME/settings.yaml` (per-request overrides, no restart):
|
|
92
|
+
The same options live in `$DSH_HOME/settings.yaml` (changes apply immediately, no restart):
|
|
177
93
|
|
|
178
94
|
```yaml
|
|
179
95
|
llm-commandcode:
|
|
180
|
-
apiKeyEnv: COMMANDCODE_API_KEY # credential reference
|
|
96
|
+
apiKeyEnv: COMMANDCODE_API_KEY # credential reference
|
|
181
97
|
apiBase: https://api.commandcode.ai
|
|
182
|
-
workingDir: /path/to/project #
|
|
98
|
+
workingDir: /path/to/project # optional
|
|
183
99
|
modelsCachePath: ~/.commandcode/models-cache.json
|
|
184
|
-
requestTimeoutMs: 60000 #
|
|
185
|
-
streamIdleTimeoutMs: 300000 #
|
|
100
|
+
requestTimeoutMs: 60000 # default 60s
|
|
101
|
+
streamIdleTimeoutMs: 300000 # default 300s
|
|
186
102
|
```
|
|
187
103
|
|
|
188
|
-
The composition-entry config (`cordis.patch.yml`) accepts the same keys; a literal `apiKey` there takes precedence over the credential reference.
|
|
189
|
-
|
|
190
|
-
## Troubleshooting
|
|
191
|
-
|
|
192
|
-
- **`Command Code API request to .../alpha/generate failed` with retries** — a **transport-layer failure**: `fetch()` never got an HTTP response (a 401/403/429 would say "API error"). Since 0.1.8 the message names the real root cause (`ECONNREFUSED`, `ENOTFOUND`, `CERT_HAS_EXPIRED`, `socket hang up`, …). Common causes: **a required proxy** (Node's `fetch`/undici ignores `HTTP_PROXY`/`HTTPS_PROXY` — configure a dispatcher or whitelist `api.commandcode.ai`), **connection reset/throttled** (firewall, GFW-style interference, unstable Wi-Fi), **TLS interception** (corporate MITM), or a transient blip retry recovers from.
|
|
193
|
-
- **A long generation stops mid-stream** — since 0.1.8 the adapter aborts after `requestTimeoutMs` (60s) with no first byte, and treats a stream stalling past `streamIdleTimeoutMs` (300s by default) as dead. Both surface as `TIMEOUT` with the stall duration; tune the knobs for slow-but-stable networks.
|
|
194
|
-
- **"Reconnects" when a reasoning model thinks for a long time** — the stream idle watchdog used to default to 120s, which is shorter than a frontier reasoning model's silent thinking phase (xhigh/max effort can stay quiet for minutes, and the official CLI sets no idle cap at all). Since 0.2.3 the default is **300s**; if you still hit spurious timeouts on very long thinking, raise `streamIdleTimeoutMs` in the `llm-commandcode` section or on the settings page.
|
|
195
|
-
- **Boot crash: `ERR_MODULE_NOT_FOUND: Cannot find package 'dsh-commandcode-provider'`** — the patch row's `name` is the bare name, but pnpm only links the scoped name. Fix the row to `name: "@mars-sea/dsh-commandcode-provider"` — note the **quotes** (an unquoted `@`-prefixed scalar fails YAML parsing) — then restart.
|
|
196
|
-
- **`MODEL_NOT_IN_PLAN` (403)** — the model isn't in your plan. Pick an open-weight model or upgrade; the error names the model and links the docs.
|
|
197
|
-
- **`MISSING_CREDENTIAL`** — no key anywhere. Store one via the settings page, `export COMMANDCODE_API_KEY`, set `config.apiKey`, or run `command-code login`. The route and catalog stay browsable without a key.
|
|
198
|
-
- **Models card shows "not configured" but requests work** — the key came from `~/.commandcode/auth.json` (the `cmd login` fallback), not the credential store. Paste it into the card once; both coexist fine.
|
|
199
|
-
- **A reasoning model returns no visible text on short requests** — it consumes output tokens on reasoning first; a small `maxTokens` can be exhausted before visible text. Normal.
|
|
200
|
-
- **`allowBuilds` errors on `dsh plugin add` from git** — copy the exact package key pnpm printed into `pnpm-workspace.yaml` and re-run (see [Install](#from-github)).
|
|
201
|
-
|
|
202
104
|
## Notes & limitations
|
|
203
105
|
|
|
204
|
-
- **Image input is model-gated
|
|
205
|
-
-
|
|
206
|
-
- **No `stop` sequences**
|
|
207
|
-
- Reasoning blocks are
|
|
208
|
-
- The catalog
|
|
106
|
+
- **Image input is model-gated** — only Vision models accept images; text-only models refuse them.
|
|
107
|
+
- Switching to a text-only model in an image-bearing session is rejected by dsh — pick a model marked *`Image`* or remove the images first.
|
|
108
|
+
- **No `stop` sequences** — requests carrying one fail.
|
|
109
|
+
- Reasoning blocks are not replayed into later turns; only tool calls with a paired tool result are replayed.
|
|
110
|
+
- The model catalog is browsable without a key; chat requests need one.
|
|
209
111
|
|
|
210
112
|
## Permissions & privacy
|
|
211
113
|
|
|
212
|
-
|
|
114
|
+
The plugin only communicates between your local dsh profile and your Command Code account: locally it touches only the credential store and the models cache (plus `~/.commandcode/auth.json` as a last-resort fallback); on the network it calls only the Command Code API. No telemetry.
|
|
213
115
|
|
|
214
116
|
## Disabling / uninstalling
|
|
215
117
|
|
|
@@ -220,7 +122,7 @@ This plugin operates entirely within your dsh profile and your Command Code acco
|
|
|
220
122
|
dsh plugin --profile web remove @mars-sea/dsh-commandcode-provider
|
|
221
123
|
```
|
|
222
124
|
|
|
223
|
-
|
|
125
|
+
Your API key in the dsh credential store and `~/.commandcode/auth.json` are left untouched.
|
|
224
126
|
|
|
225
127
|
## Development
|
|
226
128
|
|
|
@@ -230,6 +132,14 @@ npm run typecheck # tsc --noEmit
|
|
|
230
132
|
npm run build # tsdown -> lib/
|
|
231
133
|
```
|
|
232
134
|
|
|
135
|
+
To try a local build in a profile:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
dsh plugin --profile web add /path/to/dsh-commandcode-provider
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
After changing `src/`, re-run `npm run build` and restart the app.
|
|
142
|
+
|
|
233
143
|
## Community & feedback
|
|
234
144
|
|
|
235
145
|
- <img src="https://cdn.simpleicons.org/github/111827" width="16" alt="GitHub" /> [GitHub Repository](https://github.com/Mars-Sea/dsh-commandcode-provider)
|
|
@@ -240,3 +150,17 @@ npm run build # tsdown -> lib/
|
|
|
240
150
|
## License
|
|
241
151
|
|
|
242
152
|
MIT — see [LICENSE](./LICENSE). Portions ported from [pi-commandcode-provider](https://github.com/patlux/pi-commandcode-provider) (MIT).
|
|
153
|
+
|
|
154
|
+
## Screenshots
|
|
155
|
+
|
|
156
|
+
**Model picker** — plan tier, deal/FREE, peak/off-peak, Image and context annotations:
|
|
157
|
+
|
|
158
|
+
<img src="assets/screenshots/model-picker.png" alt="Model picker with plan, deal, image and context annotations" width="420">
|
|
159
|
+
|
|
160
|
+
**Usage dashboard** — `/commandcode` per-account report:
|
|
161
|
+
|
|
162
|
+

|
|
163
|
+
|
|
164
|
+
**Settings page** — API key, connection knobs, account rotation and the live account-usage card:
|
|
165
|
+
|
|
166
|
+
<img src="assets/screenshots/settings-page.png" alt="Command Code settings page with the account usage card" width="640">
|
package/README.zh-CN.md
CHANGED
|
@@ -10,145 +10,65 @@
|
|
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
|
11
11
|
[](https://www.npmjs.com/package/@mars-sea/dsh-commandcode-provider)
|
|
12
12
|
|
|
13
|
-
非官方 [DeepSeek Harness](https://deepseek-harness.github.io/deepseek-harness/) 的 LLM provider 插件,用于 **Command Code**,移植自 [pi-commandcode-provider](https://github.com/patlux/pi-commandcode-provider)(MIT
|
|
13
|
+
非官方 [DeepSeek Harness](https://deepseek-harness.github.io/deepseek-harness/) 的 LLM provider 插件,用于 **Command Code**,移植自 [pi-commandcode-provider](https://github.com/patlux/pi-commandcode-provider)(MIT 协议)。
|
|
14
14
|
|
|
15
15
|
> 这是一个社区集成。你需要自己的 Command Code 账号、API key 或订阅,并遵守 Command Code 的服务条款。本项目与 Command Code, Inc. 无关。
|
|
16
16
|
|
|
17
17
|
## 功能一览
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- **
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
<img src="assets/screenshots/model-picker.png" alt="带套餐、折扣、图片与上下文标注的模型选择器" width="250">
|
|
29
|
-
|
|
30
|
-
## 获取 API key
|
|
31
|
-
|
|
32
|
-
Command Code 的 API key 永不过期。最简单的途径是官方 CLI(Node.js 22+):
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
npm i -g command-code@latest
|
|
36
|
-
cmd login # macOS/Linux;Windows 原生版:cmdc login
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
`cmd login` 会打开浏览器认证;成功后 key 写入 `~/.commandcode/auth.json`——本插件会自动读取(最后兜底)。也可以直接在浏览器创建 key([Command Code Studio](https://commandcode.ai/studio/auth/cli))并粘贴到 **设置 → Command Code**,或 `export COMMANDCODE_API_KEY="user_..."`。
|
|
19
|
+
- **插件包**:一条 `dsh plugin add` 命令安装到任意 dsh 配置,注册 `commandcode` provider 路由,带实时模型目录。
|
|
20
|
+
- **专属设置页**:API key 输入、连接参数、实时「账户用量」卡片和「隐藏套餐外模型」开关。
|
|
21
|
+
- **多账户轮换**:一个账户用量打满后,请求自动切换到下一个账户。详见[多账户轮换](#多账户轮换)。
|
|
22
|
+
- **key 配置灵活**:设置页填写、环境变量或官方 CLI 登录文件均可。
|
|
23
|
+
- **模型选择器标注**:每个模型标注最低套餐、折扣/FREE 徽章、峰谷时段、图片支持与上下文长度,免费模型置顶。
|
|
24
|
+
- **按套餐过滤**:默认隐藏超出订阅套餐的模型,可一键关闭。
|
|
25
|
+
- **推理强度支持**:支持推理强度的模型可在选择器中选择档位。
|
|
26
|
+
- **图片输入**:Vision 模型支持发送图片。
|
|
40
27
|
|
|
41
28
|
## 安装
|
|
42
29
|
|
|
43
|
-
### 从 npm 安装(推荐)
|
|
44
|
-
|
|
45
|
-
npm 上裸名 `dsh-commandcode-provider` 已被无关包占用,因此本插件以 **`@mars-sea/dsh-commandcode-provider`** 发布:
|
|
46
|
-
|
|
47
30
|
```sh
|
|
48
|
-
dsh plugin --profile web add @mars-sea/dsh-commandcode-provider
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 从 GitHub 安装
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
# 推荐:锁定发布 tag(可读、不可变)
|
|
55
|
-
dsh plugin --profile web add github:Mars-Sea/dsh-commandcode-provider#v0.2.2
|
|
56
|
-
# 或按完整 commit SHA 锁定任意提交
|
|
57
|
-
dsh plugin --profile web add github:Mars-Sea/dsh-commandcode-provider#<完整-commit-sha>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
`#<ref>` 后缀把源码锁定到**某一个精确版本**(pnpm 的 git 依赖语法)。不加 `#` 则跟随默认分支,后续 push 会悄悄改变你装到的内容。
|
|
61
|
-
|
|
62
|
-
git 安装会拉取**源码**,因此包的 `prepare` 脚本会在安装后构建 `lib/`。pnpm ≥10 默认阻止该脚本——先运行 `add`,再把 pnpm 打印的**确切包 key** 复制到 `~/.dsh/profiles/web/pnpm-workspace.yaml`:
|
|
63
|
-
|
|
64
|
-
```yaml
|
|
65
|
-
allowBuilds:
|
|
66
|
-
'@mars-sea/dsh-commandcode-provider@github:Mars-Sea/dsh-commandcode-provider#<完整-commit-sha>': true
|
|
31
|
+
dsh plugin --profile web add @mars-sea/dsh-commandcode-provider@latest
|
|
67
32
|
```
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### 从本地检出安装
|
|
34
|
+
## 更新
|
|
72
35
|
|
|
73
36
|
```sh
|
|
74
|
-
|
|
75
|
-
npm run build # git/压缩包安装通过 `prepare` 自动执行
|
|
76
|
-
dsh plugin --profile web add /path/to/dsh-commandcode-provider
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
修改 `src/` 后需重新运行 `npm run build` 并重启应用。
|
|
80
|
-
|
|
81
|
-
### 安装做了什么
|
|
82
|
-
|
|
83
|
-
`dsh plugin add` 会把包链接到配置目录(pnpm 按**真实包名** `@mars-sea/dsh-commandcode-provider` 记录),追加到 `dsh.profile.bundles`,并激活 `cordis.patch.yml` 层:
|
|
84
|
-
|
|
85
|
-
```yaml
|
|
86
|
-
- insert:
|
|
87
|
-
- id: llm-commandcode
|
|
88
|
-
name: "@mars-sea/dsh-commandcode-provider"
|
|
89
|
-
config:
|
|
90
|
-
apiKeyEnv: COMMANDCODE_API_KEY
|
|
37
|
+
dsh plugin --profile web add @mars-sea/dsh-commandcode-provider@latest
|
|
91
38
|
```
|
|
92
39
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
验证合成后的层,然后(重新)启动 Web 应用:
|
|
96
|
-
|
|
97
|
-
```sh
|
|
98
|
-
dsh --profile web --dump-config # 会显示 "# == @mars-sea/dsh-commandcode-provider" 层
|
|
99
|
-
dsh web # 或重启你正在运行的实例
|
|
100
|
-
```
|
|
40
|
+
然后重启 Web 应用。
|
|
101
41
|
|
|
102
|
-
##
|
|
42
|
+
## 获取 API key
|
|
103
43
|
|
|
104
|
-
|
|
44
|
+
最简单的途径是官方 CLI(Node.js 22+):
|
|
105
45
|
|
|
106
46
|
```sh
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# GitHub(按 tag):指向新 tag——无需先卸载,pnpm 会就地替换
|
|
111
|
-
dsh plugin --profile web add github:Mars-Sea/dsh-commandcode-provider#v0.2.2
|
|
112
|
-
|
|
113
|
-
# 本地检出:拉取、重新构建、重启
|
|
114
|
-
git -C /path/to/dsh-commandcode-provider pull
|
|
115
|
-
npm run build --prefix /path/to/dsh-commandcode-provider
|
|
116
|
-
dsh web
|
|
47
|
+
npm i -g command-code@latest
|
|
48
|
+
cmd login # macOS/Linux;Windows 原生版:cmdc login
|
|
117
49
|
```
|
|
118
50
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
> **`update` 提示 "Already up to date" 但版本没变(pnpm ≥ 11)?** pnpm 11 的 `minimumReleaseAge` 供应链策略可能拒绝刚发布的新版本。请改用显式版本:`dsh plugin --profile web add @mars-sea/dsh-commandcode-provider@0.2.2`(或在 profile 目录里 `pnpm config set minimumReleaseAge 0 --location project`)。
|
|
122
|
-
|
|
123
|
-
> **从 ≤0.1.6 升级**(或手改坏的 profile):如果你之前**手工复制**过旧的 patch 行到你 profile 自己的 `cordis.patch.yml`,那份拷贝会覆盖 bundle 层——请改成 `name: "@mars-sea/dsh-commandcode-provider"` 或删掉它(见[故障排查](#故障排查))。
|
|
124
|
-
|
|
125
|
-
> **想卸载而不是升级**:`dsh plugin --profile web remove @mars-sea/dsh-commandcode-provider`(用 **scoped** 名——pnpm 按真实包名记录依赖)。你在 dsh 凭据库和 `~/.commandcode/auth.json` 里的 API key 不受影响。
|
|
51
|
+
也可以在 [Command Code Studio](https://commandcode.ai/studio/auth/cli) 创建 key 后粘贴到 **设置 → Command Code**,或 `export COMMANDCODE_API_KEY="user_..."`。
|
|
126
52
|
|
|
127
53
|
## 验证是否生效
|
|
128
54
|
|
|
129
|
-
|
|
55
|
+
重启后,在 **设置 → Command Code** 填入 API key 并保存;**设置 → Models** 出现 **Command Code** 卡片,模型选择器在 **commandcode** 下列出实时目录。选择套餐内包含的模型发送消息即可。
|
|
130
56
|
|
|
131
57
|
## 用量面板
|
|
132
58
|
|
|
133
|
-
|
|
59
|
+
插件注册了 `/commandcode` 斜杠命令,显示各账户的用量状态:
|
|
134
60
|
|
|
135
61
|
```text
|
|
136
62
|
/commandcode (或 /commandcode status)
|
|
137
63
|
```
|
|
138
64
|
|
|
139
|
-

|
|
140
|
-
|
|
141
|
-
每个端点独立降级——某个端点临时失败不会影响其他数据,并会在末尾内联提示失败。
|
|
142
|
-
|
|
143
65
|
## 多账户轮换
|
|
144
66
|
|
|
145
67
|
有多个 Command Code 订阅时,插件可以在一个账户达到用量限额后**自动切换到下一个账户**:
|
|
146
68
|
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
- **手动切换**:同一张卡片上的「当前使用账户」下拉框可以**手动指定优先账户**(持久化为 `activeAccount` 设置项),保存后下次请求即生效;所选账户耗尽时仍自动回落到其他可用账户,窗口重置后自动回到所选账户。
|
|
151
|
-
- **按账户展示**:设置页的「账户用量」卡片按账户分区显示,带「当前使用 / 限额冷却中 / 密钥无效」徽章;`/commandcode` 命令同样按账户输出。
|
|
69
|
+
- **配置**:在 **设置 → Command Code** 的「多账户轮换」卡片添加账户并填写备注名与 API key;顶层 key 始终是第一顺位的 `default` 账户。
|
|
70
|
+
- **手动切换**:卡片上的「当前使用账户」下拉框可指定优先账户;所选账户耗尽时自动回落到其他账户,窗口重置后自动恢复。
|
|
71
|
+
- **状态展示**:「账户用量」卡片与 `/commandcode` 均按账户分别显示状态。
|
|
152
72
|
|
|
153
73
|
等价的 YAML(`$DSH_HOME/settings.yaml` 或组合配置):
|
|
154
74
|
|
|
@@ -163,53 +83,33 @@ llm-commandcode:
|
|
|
163
83
|
apiKeyEnv: COMMANDCODE_API_KEY_3
|
|
164
84
|
```
|
|
165
85
|
|
|
166
|
-
组合配置里每个账户也可写字面量 `apiKey`(优先于其 `apiKeyEnv`);设置文档中永不存储密钥字面量。
|
|
167
|
-
|
|
168
86
|
## 配置
|
|
169
87
|
|
|
170
|
-
**设置 → Command Code**
|
|
88
|
+
**设置 → Command Code** 可配置 API key、API 地址、工作目录与请求/流超时;配置好 key 后,页面顶部会显示实时「账户用量」卡片。
|
|
171
89
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
<img src="assets/screenshots/settings-page.png" alt="Command Code 设置页面(含账户用量卡片)" width="640">
|
|
175
|
-
|
|
176
|
-
同一组选项也位于 `$DSH_HOME/settings.yaml`(按请求覆盖,无需重启):
|
|
90
|
+
同一组选项也位于 `$DSH_HOME/settings.yaml`(修改即刻生效,无需重启):
|
|
177
91
|
|
|
178
92
|
```yaml
|
|
179
93
|
llm-commandcode:
|
|
180
|
-
apiKeyEnv: COMMANDCODE_API_KEY #
|
|
94
|
+
apiKeyEnv: COMMANDCODE_API_KEY # 凭据引用
|
|
181
95
|
apiBase: https://api.commandcode.ai
|
|
182
|
-
workingDir: /path/to/project #
|
|
96
|
+
workingDir: /path/to/project # 可选
|
|
183
97
|
modelsCachePath: ~/.commandcode/models-cache.json
|
|
184
|
-
requestTimeoutMs: 60000 #
|
|
185
|
-
streamIdleTimeoutMs: 300000 #
|
|
98
|
+
requestTimeoutMs: 60000 # 默认 60s
|
|
99
|
+
streamIdleTimeoutMs: 300000 # 默认 300s
|
|
186
100
|
```
|
|
187
101
|
|
|
188
|
-
组合入口配置(`cordis.patch.yml`)接受相同的键;那里的字面量 `apiKey` 优先于凭据引用。
|
|
189
|
-
|
|
190
|
-
## 故障排查
|
|
191
|
-
|
|
192
|
-
- **`Command Code API request to .../alpha/generate failed`,且不停重试** ——这是**传输层失败**:`fetch()` 根本没拿到 HTTP 响应(401/403/429 会显示 "API error")。0.1.8 起错误消息会点名**真实根因**(`ECONNREFUSED`、`ENOTFOUND`、`CERT_HAS_EXPIRED`、`socket hang up` 等)。常见原因:**需要代理**(Node 的 `fetch`/undici 不读取 `HTTP_PROXY`/`HTTPS_PROXY`——配置 dispatcher 或把 `api.commandcode.ai` 加入白名单)、**连接被中途重置/限速**(防火墙、GFW 类干扰、Wi-Fi 不稳)、**TLS 被中间人替换**(企业 MITM),或只是重试能恢复的瞬时抖动。
|
|
193
|
-
- **长回答生成到一半中断** ——0.1.8 起,adapter 会在 `requestTimeoutMs`(60s)内拿不到首字节时中止,并在流停顿超过 `streamIdleTimeoutMs`(默认 300s)时判为死连接。两者都以 `TIMEOUT` 呈现并附带停顿时长;网络慢但稳定可调大这两个值。
|
|
194
|
-
- **推理模型思考较久时"反复重连"** ——流空闲看门狗原默认 120s,比前沿推理模型(xhigh/max effort)的静默思考期还短——它们可以数分钟不吐 token,而官方 CLI 根本不设空闲上限。0.2.3 起默认改为 **300s**;若极长思考仍触发误判,在 `llm-commandcode` 配置段或设置页调大 `streamIdleTimeoutMs`。
|
|
195
|
-
- **启动崩溃:`ERR_MODULE_NOT_FOUND: Cannot find package 'dsh-commandcode-provider'`** ——patch 行的 `name` 是裸名,但 pnpm 只链接带 scope 的名字。改成 `name: "@mars-sea/dsh-commandcode-provider"`——注意**必须加引号**(不引号的 `@` 开头标量会导致 YAML 解析失败)——然后重启。
|
|
196
|
-
- **`MODEL_NOT_IN_PLAN` (403)** ——所选模型不在你的套餐内。选一个开放权重模型或升级套餐;错误会指明模型并附官方文档链接。
|
|
197
|
-
- **`MISSING_CREDENTIAL`** ——任何地方都没有 key。在设置页存一个、`export COMMANDCODE_API_KEY`、设置 `config.apiKey`,或运行 `command-code login`。没有 key 时路由与目录仍可浏览。
|
|
198
|
-
- **Models 卡片显示"未配置"但请求可用** ——key 来自 `~/.commandcode/auth.json`(`cmd login` 兜底),而非凭据存储。把它粘贴到卡片一次即可;两者可共存。
|
|
199
|
-
- **推理模型在短请求下不返回可见文本** ——它先消耗输出 token 做推理;`maxTokens` 较小时可能在可见文本前就用完。属正常现象。
|
|
200
|
-
- **git 安装时 `dsh plugin add` 报 `allowBuilds` 错误** ——把 pnpm 打印的确切包 key 复制到 `pnpm-workspace.yaml` 并重新运行(见[从 GitHub 安装](#从-github-安装))。
|
|
201
|
-
|
|
202
102
|
## 注意事项与限制
|
|
203
103
|
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
- **不支持 `stop`
|
|
207
|
-
-
|
|
208
|
-
-
|
|
104
|
+
- **图片输入按模型能力限制**:仅 Vision 模型接受图片,纯文本模型会直接拒绝。
|
|
105
|
+
- 含图片的会话切换到纯文本模型会被 dsh 拒绝——请改选带 *`Image`* 标记的模型,或先移除图片。
|
|
106
|
+
- **不支持 `stop` 序列**:携带它的请求会报错。
|
|
107
|
+
- 推理块不会重放到后续轮次;只有带配对工具结果的工具调用会被重放。
|
|
108
|
+
- 模型目录无需 key 即可浏览;对话请求需要 key。
|
|
209
109
|
|
|
210
110
|
## 权限与隐私
|
|
211
111
|
|
|
212
|
-
|
|
112
|
+
本插件只在本地与你的 Command Code 账号之间通信:本地仅读写凭据存储与模型缓存文件(兜底读取 `~/.commandcode/auth.json`);网络仅访问 Command Code API。无遥测。
|
|
213
113
|
|
|
214
114
|
## 关闭 / 卸载
|
|
215
115
|
|
|
@@ -220,7 +120,7 @@ llm-commandcode:
|
|
|
220
120
|
dsh plugin --profile web remove @mars-sea/dsh-commandcode-provider
|
|
221
121
|
```
|
|
222
122
|
|
|
223
|
-
|
|
123
|
+
你在 dsh 凭据库和 `~/.commandcode/auth.json` 中的 API key 不会被改动。
|
|
224
124
|
|
|
225
125
|
## 开发
|
|
226
126
|
|
|
@@ -230,6 +130,14 @@ npm run typecheck # tsc --noEmit
|
|
|
230
130
|
npm run build # tsdown -> lib/
|
|
231
131
|
```
|
|
232
132
|
|
|
133
|
+
在 profile 里试用本地构建:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
dsh plugin --profile web add /path/to/dsh-commandcode-provider
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
修改 `src/` 后需重新运行 `npm run build` 并重启应用。
|
|
140
|
+
|
|
233
141
|
## 社区与反馈
|
|
234
142
|
|
|
235
143
|
- <img src="https://cdn.simpleicons.org/github/111827" width="16" alt="GitHub" /> [GitHub 仓库](https://github.com/Mars-Sea/dsh-commandcode-provider)
|
|
@@ -240,3 +148,17 @@ npm run build # tsdown -> lib/
|
|
|
240
148
|
## 许可证
|
|
241
149
|
|
|
242
150
|
MIT —— 见 [LICENSE](./LICENSE)。部分内容移植自 [pi-commandcode-provider](https://github.com/patlux/pi-commandcode-provider)(MIT)。
|
|
151
|
+
|
|
152
|
+
## 界面截图
|
|
153
|
+
|
|
154
|
+
**模型选择器** —— 套餐档位、折扣/FREE、峰谷时段、Image 与上下文标注:
|
|
155
|
+
|
|
156
|
+
<img src="assets/screenshots/model-picker.png" alt="带套餐、折扣、图片与上下文标注的模型选择器" width="420">
|
|
157
|
+
|
|
158
|
+
**用量面板** —— `/commandcode` 的分账户报告:
|
|
159
|
+
|
|
160
|
+

|
|
161
|
+
|
|
162
|
+
**设置页** —— API 密钥、连接参数、多账户轮换与实时账户用量卡片:
|
|
163
|
+
|
|
164
|
+
<img src="assets/screenshots/settings-page.png" alt="Command Code 设置页面(含账户用量卡片)" width="640">
|