@alexpeng/dsh-custom-plugin 0.9.3 → 0.10.0

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +1687 -866
  2. package/NOTICE +71 -0
  3. package/README.i18n.yaml +7 -7
  4. package/README.md +344 -335
  5. package/README.zh.md +309 -302
  6. package/lib/client.js +9458 -2063
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +233 -99
  9. package/lib/types/balance.d.ts +44 -0
  10. package/lib/types/client/api.d.ts +13 -8
  11. package/lib/types/client/bg-ascii.d.ts +397 -0
  12. package/lib/types/client/bg-field.d.ts +60 -0
  13. package/lib/types/client/bg-focus.d.ts +63 -0
  14. package/lib/types/client/bg-layer.d.ts +152 -0
  15. package/lib/types/client/bg-ocean.d.ts +31 -0
  16. package/lib/types/client/bg-params.d.ts +142 -0
  17. package/lib/types/client/bg-pointer.d.ts +107 -0
  18. package/lib/types/client/bg-shader.d.ts +329 -0
  19. package/lib/types/client/bg-wake.d.ts +57 -0
  20. package/lib/types/client/custom.d.ts +4 -1
  21. package/lib/types/client/index.d.ts +1 -1
  22. package/lib/types/client/palette.d.ts +100 -0
  23. package/lib/types/client/panel-bounds.d.ts +65 -0
  24. package/lib/types/client/styles.d.ts +9 -4
  25. package/lib/types/client/ui/anchor.d.ts +55 -0
  26. package/lib/types/client/ui/appearance-controls.d.ts +24 -0
  27. package/lib/types/client/ui/command-model.d.ts +28 -0
  28. package/lib/types/client/ui/folders-model.d.ts +31 -0
  29. package/lib/types/client/ui/index-bridge.d.ts +6 -0
  30. package/lib/types/client/ui/overlays.d.ts +66 -0
  31. package/lib/types/client/ui/primitives.d.ts +93 -0
  32. package/lib/types/client/ui/prompt-model.d.ts +37 -0
  33. package/lib/types/host-service.d.ts +68 -15
  34. package/lib/types/pricing.d.ts +8 -4
  35. package/lib/types/protocol.d.ts +48 -2
  36. package/lib/types/usage.d.ts +8 -4
  37. package/locale/en.json +1 -1
  38. package/locale/zh.json +1 -1
  39. package/package.json +106 -105
package/README.md CHANGED
@@ -1,335 +1,344 @@
1
- # dsh-custom-plugin
2
-
3
- [![npm version](https://img.shields.io/npm/v/%40alexpeng%2Fdsh-custom-plugin?style=flat-square)](https://www.npmjs.com/package/@alexpeng/dsh-custom-plugin)
4
- [![license](https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square)](LICENSE)
5
- [![Node](https://img.shields.io/badge/node-%3E%3D22-339933?style=flat-square)](#install)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
7
- [![CI](https://github.com/AlexPeng07/dsh-custom-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/AlexPeng07/dsh-custom-plugin/actions/workflows/ci.yml)
8
- [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
9
-
10
- <p align="center">
11
- <img src="https://www.npm.bet/svg?q=%40alexpeng%2Fdsh-custom-plugin&amp;timeRange=last-month&amp;grouping=day&amp;metric=downloads&amp;zeroMode=estimated" alt="npm downloads, last month" width="560">
12
- </p>
13
-
14
- English | [中文](README.zh.md)
15
-
16
- Custom convenience suite for the DeepSeek Harness (DSH) Web GUI: personalization, weather FX, glass effects, project folders, enhanced prompts, conversation export/search, Mermaid rendering, quote reply, 7/30/90-day usage analytics, budget and key-free local backups, plus a Ctrl/Cmd+K command palette.
17
-
18
- The plugin is dual-face: the host half (`src/`) owns the state document, registers the `/api/custom-plugin` routes and the `custom_plugin_status` agent tool; the browser half (`src/client/`) injects its UI through eight injections into seven official slots and talks to the host over same-origin fetch. Mounted through the official profile mechanism — no DSH source changes.
19
-
20
- <p align="center">
21
- <img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/overview.png" alt="dsh-custom-plugin overview" width="100%">
22
- </p>
23
-
24
- ## Selected screenshots
25
-
26
- <table>
27
- <tr>
28
- <td width="50%" valign="top"><b>Settings → 个性化: the full-page appearance config</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/settings-appearance.png" alt="Settings → 个性化 full appearance page" width="100%"></td>
29
- <td width="50%" valign="top"><b>The same panel as a popover from the session header (light theme)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/personalization-panel.png" alt="Personalization popover" width="100%"></td>
30
- </tr>
31
- <tr>
32
- <td width="50%" valign="top"><b>Liquid glass (displacement refraction on Custom surfaces)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/liquid-glass.png" alt="Liquid glass" width="100%"></td>
33
- <td width="50%" valign="top"><b>Multi-level project folders</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/project-folders.png" alt="Project folders" width="100%"></td>
34
- </tr>
35
- <tr>
36
- <td width="50%" valign="top"><b>Mermaid mindmap rendered in place</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/mermaid-mindmap.png" alt="Mermaid mindmap" width="100%"></td>
37
- <td width="50%" valign="top" align="center"><b>Balance and today's per-model usage</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/balance-usage.png" alt="Balance and usage panel" width="100%"></td>
38
- </tr>
39
- <tr>
40
- <td width="50%" valign="top" align="center"><b>Rain (three depth layers)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-rain.gif" alt="Rain effect" width="100%"></td>
41
- <td width="50%" valign="top" align="center"><b>Sakura</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-sakura.gif" alt="Sakura effect" width="100%"></td>
42
- </tr>
43
- <tr>
44
- <td width="50%" valign="top" align="center"><b>Snow</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-snow.gif" alt="Snow effect" width="100%"></td>
45
- </tr>
46
- </table>
47
-
48
- Weather FX is shown in dark mode. Usage history, backup-import previews, session search, and the command palette are dynamic views of the same panel; open them inside DSH to inspect the live UI — no additional fixed screenshots are included.
49
-
50
- ## What it does
51
-
52
- ### Appearance
53
-
54
- - **Background colors**: 20 muted low-saturation palettes (each with a matching tab color, `天青灰` by default) plus "no color" (follows the GUI default theme). Every palette works in both themes; dark mode derives the same family's dark variant (hue and low saturation kept, lightness dropped onto the dark ramp), and the swatch preview shows what the current theme will actually paint.
55
- - **Weather FX**: canvas-rendered, pointer-transparent one-click overlays — falling snow, cinematic rain (three depth layers with splashes), and drifting sakura petals; turning it off clears the canvas.
56
- - **Glass**: frosted glass on every Custom surface, or liquid glass (edge displacement refraction chained with a slight blur + saturation so text over large panels stays readable; engines without SVG-referencing backdrop filters fall back to frosted). A global-glass option extends the same treatment to dialogs, menus, tooltips, listboxes and the system settings window — displaced as well in liquid mode.
57
-
58
- ### Project folders
59
-
60
- A multi-level folder tree persisted in the `$DSH_HOME` state file, shared across workspaces. Any workspace or session can be folded in; folders support drag-to-reorder (before / inside / after), rename, delete, and add-current-session shortcuts.
61
-
62
- ### Prompts
63
-
64
- A prompt library with add / edit / copy / delete, search, favorites, tags, drag sorting, recency and use counts. `{{variable}}` placeholders open a fill-in form before insertion. The library supports versioned JSON and heading-based Markdown import/export.
65
-
66
- ### Conversation export
67
-
68
- Export the current session in three formats (file names carry a date stamp):
69
-
70
- - **JSON**: standard `messages` structure (user / assistant / tool), with a meta block carrying the session title, creation time, working directory and export time — importable elsewhere;
71
- - **Markdown**: role-sectioned plain text;
72
- - **PDF**: an A4 print-layout HTML opened in the browser and saved as PDF; images embed as base64 (up to 30 images, 12 MB total, 4 MB each).
73
-
74
- Tool rows carry the tool name and an argument digest (resolved from the paired tool/call events).
75
-
76
- Plugin state can be exported as a versioned JSON backup containing appearance, folders, prompts, stars, usage, and budget settings. API keys and credential metadata are excluded. Imports show a conflict preview, support merge or non-secret replacement, and create a recovery copy first.
77
-
78
- ### Mermaid
79
-
80
- ```mermaid blocks anywhere in the chat — assistant replies included (mindmaps, flowcharts, sequence diagrams, …) — render in place automatically: a diagram/code toggle bar with a mermaid.live fallback link appears above the block, streaming blocks preview once their content is complete, diagrams re-render on GUI theme flips, and a failed render keeps the raw code. Detection keys off the fence language label; with a blank label (mid-stream) a content heuristic decides (keyword prefix + completeness checks, so blocks labeled with a real language are never touched). The engine loads from the mermaid 11 dependency installed with the plugin (works offline), falling back to jsdelivr / fastly / unpkg mirrors and caching in the host process; the render chips under user messages and the multi-diagram modal stay, and the mermaid.live link uses the DEFLATE-compressed `#pako:` format that restores the diagram on open.
81
-
82
- ### Efficiency tools
83
-
84
- - **Quote reply**: select text in the conversation and a "quote reply" button inserts it as a blockquote into the input box;
85
- - **Anti auto-scroll**: force `scroll-behavior: auto` so sends never yank the view to the bottom (off by default);
86
- - **Formula copy**: LaTeX / MathML copy chips under matching messages (MathML pastes into Word);
87
- - **Batch archive**: select sessions and archive them in bulk; running sessions are unavailable and completion reports separate success/failure counts. DSH exposes no restore API yet, so the plugin provides no restore entry point.
88
- - **Session search**: search current-session user, assistant, and tool content and jump to the containing turn; superseded requests are cancelled. DSH's event index is used when the deployment opens one, and otherwise the plugin scans the session log it already read (the panel says which path answered).
89
- - **Command palette**: press `Ctrl+K` / `Cmd+K` outside editors to search sessions, workspaces, prompts, and common actions; cross-session content search uses DSH's official API and reports its own unavailability.
90
- - **Reliable archive**: running sessions are unavailable by default and batch completion reports separate success and failure counts.
91
-
92
- ### Balance and usage
93
-
94
- A usage badge sits in the session header (clickable to pin): with an API key configured it shows the official balance; without one it shows the local cost estimate (e.g. `≈¥0.42`) and today's call count. The panel provides:
95
-
96
- - **Usage and cost (default section, key-free)**: today's and historical usage, budget and the cost estimate all come from local session records — no key required.
97
- - **Balance query (collapsible opt-in, needs an API key)**: the official `https://api.deepseek.com/user/balance` endpoint, CNY preferred, granted and topped-up balances listed separately, with the account availability flag; with no key configured the section stays collapsed and shows no error. The host's outbound call goes over the machine's direct connection (system proxy settings are not read); when a local proxy or security suite intermittently TLS-intercepts HTTPS, the query fails with a readable reason ("TLS certificate verification failed") and retries automatically (8s/30s/30s, with the 60s poll as the backstop) — hover the header pill to see the reason.
98
- - **Key resolution order**: the system credential store (when available) → the legacy plugin state-file key → environment variables `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN` (values must start with `sk-`) → the DSH credentials file `$DSH_HOME/.credentials.yaml` (reuses the DeepSeek key already configured in DSH — no duplicate setup). Account-login Desktop installs have no sk- key; that is a normal state.
99
- - **Today's usage**: per-model input / output / cache token counters and call counts, folded live from `session/event` records.
100
- - **Cost estimate**: DeepSeek's current official peak/off-peak table (checked 2026-09-30) — peak hours are Beijing Monday–Friday 09:00–12:00 / 14:00–18:00; all other hours, including weekends, are off-peak at half price: `deepseek-flash` (the retired names `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp` still route at Flash pricing) peaks at ¥2 / ¥8, `deepseek-v4-pro` ¥9 / ¥27 (CNY per 1M tokens, peak in / out). Indicative only.
101
- - **Scan**: "scan today's session logs" replays every session and buckets usage events by their own timestamp (cross-midnight sessions keep contributing today's usage), reporting how many active sessions were scanned.
102
- - **History and budget**: inspect 7 / 30 / 90-day trends and per-model totals, export UTF-8 CSV, and set a local monthly CNY budget with an in-plugin warning threshold.
103
-
104
- ### Settings entry
105
-
106
- The Settings → 个性化 section provides the full appearance and tool-toggle page; the 个性化 buttons in the session header and the sidebar footer open the same panel as a popover.
107
-
108
- ### Agent integration
109
-
110
- The `custom_plugin_status` tool reports appearance config, today's per-model usage, balance, a timeline sample, Mermaid engine state, the state file path and client diagnostics. The plugin never injects system-prompt announcements.
111
-
112
- ## Compatibility
113
-
114
- | plugin release | dsh it was built and verified against | status |
115
- | --- | --- | --- |
116
- | 0.9.x | any dsh at or above 0.1.7-rc.2 (open-ended; verified on 0.1.7-rc.2, 0.2.0-rc.2, 0.2.1-rc.2 and 0.2.1-rc.3) | this release |
117
- | 0.8.x | dsh 0.1.7-rc.2, dsh 0.2.0-rc.2 and dsh 0.2.1-rc.2 (measured window) | previous; refused on dsh 0.2.1-rc.3 and later |
118
- | 0.7.x | dsh 0.1.7-rc.2 and dsh 0.2.0-rc.2 | previous; refused on dsh 0.2.1-rc.2 |
119
- | 0.6.x | dsh 0.1.7-rc.2 and dsh 0.2.0-rc.2 | previous; refused on dsh 0.2.1-rc.2 |
120
- | 0.5.x | dsh 0.1.7-rc.2 (peer range `>=0.1.7-rc.2 <0.2.0-0`) | fine on 0.1.x; refused on any 0.2.x host, including dsh Desktop |
121
- | 0.4.2 | dsh 0.1.1-rc.1 … 0.1.6 era | superseded; do not expect it to work on 0.1.7+ |
122
-
123
- 0.1.7 changed the plugin-facing contracts this suite depends on (session
124
- navigation moved to `ctx.uiWorkspace`, the session list stopped publishing the
125
- viewed session, and the message model dropped the `tool-result` content block),
126
- so neither release substitutes for the other. dsh 0.2.1-alpha.4 changed the
127
- compatibility gate itself: it reads `engines.dsh` first and falls back to the
128
- `@deepseek-ai/dsh-*` peer ranges only when `engines.dsh` is absent. This package
129
- declares the same **open lower bound** (`>=0.1.7-rc.2`) in both places, so every
130
- newer dsh release is admitted without waiting for a plugin release; older hosts
131
- read the peers, newer hosts read `engines.dsh`, and `pnpm smoke` fails if the
132
- two ever disagree. Verified versions are evidence, not a gate: see the table and
133
- CHANGELOG. A scheduled canary installs the published plugin into the newest dsh
134
- from npm `latest`/`next`, boots it, and runs the live probes, so an actual API
135
- break shows up as an issue instead of a user-visible refusal. Runtimes
136
- predating that gate load the bundle anyway and degrade instead: on 0.1.1-rc.2,
137
- 7 of 8 slot registrations succeed, the turn-tail entry is rejected (that slot
138
- became a list slot back in 0.1.6-alpha.2), and the open-session / branch /
139
- cross-session actions report their service as missing rather than throwing.
140
-
141
- ## Install
142
-
143
- Prerequisites: Node 22+, pnpm, and the `dsh` CLI (the official `@deepseek-ai/dsh` npm package; `npx @deepseek-ai/dsh` stands in for `dsh` when it is not installed globally). This release admits **every dsh release at or above 0.1.7-rc.2**: `engines.dsh` and the `@deepseek-ai/dsh-tools` peer are both an open lower bound, so dsh 0.2.1-alpha.4 and later (which read `engines.dsh` first) and older hosts (which read the peers) agree that no newer release is refused. 0.9.0 was built and tested on 0.2.1-rc.3. Its artifact was installed with Desktop's own CLI into an isolated 0.2.1-rc.3 profile **with no compatibility exemption**, then booted for real: a 71-row boot graph, all five `dsh.client.inject` targets, the client bundle served at 200,371 bytes, the local Mermaid engine (3,572,661 bytes), the state / usage / backup routes, a UTF-8 round trip and the desktop-forward trust shape all passed (16 live probes pass, 1 skip; the skip is timeline/export/search on a profile with no session, covered by unit tests). 0.8.0 ran the same probes on 0.2.1-rc.2 (70 rows); 0.6.0 ran them on 0.2.0-rc.2 (66 rows) and 0.1.7-rc.2 (65 rows), 18 of 19 each; 0.7.0 additionally passed the desktop-shape probe **on a real Desktop install** (see "On dsh Desktop" below). What stays unverified is what was always unverified: the per-turn chips (Mermaid render, LaTeX) need a real model reply, so a credential-free scratch home cannot reach them, and slot rendering still needs a browser pass. The host gate cannot distinguish "verified" from "unverified", so an explicit upper bound would refuse users on every dsh release until this package published again; the open range plus the scheduled canary replace that waiting with automatic detection. If a host below the floor is ever needed, install the matching older plugin release (`0.5.0` targets 0.1.7-rc.2).
144
-
145
- ### From npm
146
-
147
- ```sh
148
- dsh plugin --profile web add @alexpeng/dsh-custom-plugin
149
- # restart dsh web
150
- ```
151
-
152
- The registry tarball ships prebuilt output — no source build on the installing machine.
153
-
154
- ### On dsh Desktop
155
-
156
- dsh Desktop is an Electron shell around the same Web application, and it bundles
157
- **exactly dsh 0.2.1-rc.3** as of 2026-10-23 — the desktop release line pins the
158
- shell and the runtime together, so a Desktop install is always one exact 0.2.x
159
- runtime. 0.9.0's open range admits rc.3 and every later Desktop build, with no
160
- compatibility exemption; 0.8.0 and earlier used a measured window and are refused
161
- on rc.3 by the same gate a 0.2.x Web profile prints.
162
-
163
- Measured against 0.2.1-rc.3: the boot graph carries our row and all five inject
164
- targets (71 module rows), our client bundle is served at 200,371 bytes, the
165
- Mermaid engine loads locally, and the live host probes pass 16 / skip 1 (the
166
- session-path skip needs a real session). The access fence shares the platform
167
- fence's trust semantics: a loopback socket naming a loopback Host, a
168
- non-`cross-site` marker, and an Origin that is absent or matches the Host
169
- authority. The shell forwards renderer requests to its own Host after deleting
170
- `host`, `origin`, `sec-fetch-site` and `cookie`, then attaches its own
171
- credential — that unmarked shape is accepted outright (through 0.6.0 the fence
172
- additionally required a same-origin marker and rejected exactly this shape with
173
- `forbidden`; fixed in 0.7.0 with fence-level unit tests). Foreign-origin and
174
- cross-site requests are still 403. **The 0.7.0 artifact was probed route by
175
- route on a real Desktop install in the desktop forward shape** (state / debug /
176
- backup / usage scan / the Mermaid engine preload and script routes all 200;
177
- foreign-origin and cross-site probes still 403), 0.8.0 repeated the same shape
178
- against a booted 0.2.1-rc.2 host, and 0.9.0 repeats it on rc.3. The visual pass inside the Desktop
179
- window (liquid glass look, panel layout, pattern removal) belongs to whoever
180
- installs it.
181
-
182
- Managing the desktop profile takes the `dsh` command that ships with Desktop, not
183
- the npm one — the public CLI refuses the reserved `desktop` profile:
184
-
185
- 1. Start Desktop once so the profile exists, then quit it fully (closing the
186
- window only hides it; on Windows use the tray).
187
- 2. `dsh plugin --profile desktop add @alexpeng/dsh-custom-plugin`
188
- 3. Reopen Desktop. The in-app Plugin Manager installs and updates against the
189
- same profile using Desktop's own bundled pnpm, if you would rather not open a
190
- terminal.
191
-
192
- Appearance, prompt library, project folders, stars and usage all live in
193
- `$DSH_HOME/custom-plugin-state.json`, which Desktop and Web share by design —
194
- each keeps its own `profiles/<name>` for code, never for that file — so
195
- switching between the two shows the same data. Both hosts can therefore write it
196
- at once, which is why the state replace names its temp file after the writing
197
- process.
198
-
199
- ### From GitHub (source install)
200
-
201
- ```sh
202
- dsh plugin --profile web add github:AlexPeng07/dsh-custom-plugin
203
- # restart dsh web
204
- ```
205
-
206
- Git installs pull sources; the `prepare` script builds `lib/` on the installing machine. pnpm ≥10 asks you to approve that build once — copy the exact package key it prints into the profile's `pnpm-workspace.yaml` under `allowBuilds`, then re-run the add. The npm route above skips the build-approval step.
207
-
208
- ### Local link (development)
209
-
210
- ```sh
211
- # build (run from this repo root)
212
- pnpm install
213
- pnpm build
214
- # add to the web profile. The link path must not contain spaces: on Windows,
215
- # create a space-free directory junction first and link to the junction path
216
- dsh plugin --profile web add link:F:/dsh-plugin-dev
217
- # restart dsh web
218
- ```
219
-
220
- The package declares its manifest per the official bundle protocol: `dsh.bundle.patch` in `package.json` points at the `cordis.patch.yml` config layer (row id `custom-plugin`) and `dsh.client` declares the browser half. `dsh plugin add` forwards to pnpm inside the profile directory; the installed package joins `dsh.profile.bundles` automatically because of that declaration, and the browser half loads via the official client module system from the same row.
221
-
222
- ## Config
223
-
224
- The plugin reads and writes one JSON document at `$DSH_HOME/custom-plugin-state.json` (`~/.dsh` by default, overridable via the `DSH_HOME` environment variable): appearance config, folders, prompts, stars, legacy compatibility data, and a 90-day per-day usage ledger. Writes are atomic (temp file + rename), so a crash never truncates the document.
225
-
226
- Appearance and feature toggles (the `cfg` field, all with defaults):
227
-
228
- | Key | Default | Meaning |
229
- |---|---|---|
230
- | `bg` | `天青灰` | `default` (no color) / one of the 20 palette names (both themes; a stored `aurora` migrates to `default`) |
231
- | `weather` | `none` | `none` / `snow` / `rain` / `sakura` |
232
- | `glass` | `true` | master glass toggle for Custom surfaces |
233
- | `glassMode` | `frost` | `frost` frosted / `liquid` displacement glass |
234
- | `globalGlass` | `true` | blur global overlays (dialogs/menus/tooltips) |
235
- | `quote` | `true` | selection quote reply |
236
- | `antiScroll` | `false` | anti auto-scroll |
237
- | `mermaid` | `true` | automatic in-place Mermaid rendering (plus render chips) |
238
- | `formula` | `true` | LaTeX / MathML copy chips |
239
- | `monthlyBudgetCny` | `0` | Monthly CNY budget; `0` disables warnings |
240
- | `budgetWarningPercent` | `80` | Monthly warning threshold (1–100) |
241
-
242
- ## Security model
243
-
244
- - The browser talks to the host only through loopback `/api/custom-plugin` routes; every route checks a loopback socket address, a loopback Host header, and browser same-origin markers (`sec-fetch-site` / `Origin`). `X-Forwarded-For` is never trusted.
245
- - The browser never receives the saved DeepSeek API key. New panel keys use the OS credential store through `keytar` when it is present; older plaintext state keys are migrated on startup when that store is available. `keytar` ships as no dependency of this plugin (a native module would trip pnpm 11's strict build gate and silently keep the whole bundle from activating); users who want the OS keyring can add it to the profile themselves: `dsh plugin --profile web add keytar`.
246
- - If the OS credential store is unavailable, the plugin keeps a compatibility fallback in `$DSH_HOME/custom-plugin-state.json`; protect `$DSH_HOME` accordingly. DSH's own `$DSH_HOME/.credentials.yaml` remains a supported plaintext fallback.
247
- - Conversation exports and timeline data stay on the local host.
248
-
249
- ## Known limitations
250
-
251
- - The Mermaid engine comes from the dependency installed with the plugin and works offline; only a missing dependency falls back to a CDN fetch (cached for the host process lifetime).
252
- - The usage ledger folds token counts from live `session/event` records, retains 90 Beijing calendar days, and a manual "scan" re-reads today's session logs with four concurrent reads when live events were missed.
253
- - The balance panel shows the peak/off-peak token and cost split plus a link to the official pricing page; legacy rows without peak counters are marked inexact and excluded from cost totals until rescanned.
254
- - OS credential storage detects a `keytar` module present in the profile's `node_modules` when the host starts; when it cannot be loaded, the compatibility state-file fallback is used.
255
- - Cost estimates use DeepSeek's official peak/off-peak list prices and are indicative only.
256
- - Palettes derive a same-family dark variant in dark mode (hue and low saturation kept).
257
- - DSH currently exposes no archive-restore API; the plugin does not bypass that boundary by editing the underlying registry.
258
- - The command palette owns `Ctrl+K` / `Cmd+K` (no Alt/Shift, ignored inside editors). dsh's own default on the **web** profile is `Ctrl+Alt+K` (the desktop default is plain `Ctrl+K`), so nothing collides out of the box — but dsh 0.1.7 lets you rebind host shortcuts, and if you assign a host command to plain `Ctrl+K`, both fire. Keep the palette key reserved, or pick another binding there.
259
- - dsh's shipped `web` profile composes its session-query index with `openAt: never`, so full-text search is off unless the deployment enables it. In-session search therefore answers from a direct log scan (ordered, capped at 100 hits) and the palette's cross-session search shows dsh's own refusal.
260
-
261
- ## Development
262
-
263
- ```sh
264
- pnpm typecheck # type check
265
- pnpm test # vitest unit tests
266
- pnpm build # build the node ESM library and the browser bundle into lib/
267
- pnpm check:readme # bilingual README hash consistency
268
- pnpm smoke # post-build contract checks: loader handshake, manifest
269
- # fields dsh reads, patch row, local Mermaid engine,
270
- # real-engine Mermaid error-path DOM regression
271
- pnpm canary # published plugin against the newest dsh from npm latest/next
272
- # (needs npm, bash and curl; --plugin <tgz> tests a local build)
273
- pnpm bench:mermaid # synthetic long-turn Mermaid scan/render benchmark (headless Edge)
274
- ```
275
-
276
- `scripts/live-dsh-check.sh` is a separate, manual probe against a **running**
277
- isolated dsh profile (`DSH_HOME=… DSH_PORT=… bash scripts/live-dsh-check.sh`):
278
- it exercises the host half on real session data — timeline, the three export
279
- formats, the search scan path, usage scan, backup, the Mermaid engine route, the
280
- client→host diagnostic ring, a UTF-8 state round trip that restores and then
281
- verifies your prompt library, and the three trust-fence shapes (an unmarked
282
- loopback request passes, a foreign Origin and a cross-site marker are
283
- rejected). It refuses to run against a
284
- real `~/.dsh` unless you set `ALLOW_REAL_DSH_HOME=1`, reports `PASS`/`FAIL` per
285
- probe, counts and names anything it `SKIP`s, and exits non-zero on any failure.
286
- The main CI job has no harness to talk to; the scheduled `compat-canary`
287
- workflow runs this probe against the newest dsh from npm `latest`/`next` and
288
- opens an issue on failure. Run it manually when you want detail on a release;
289
- slot registration and rendering still need the browser pass described above.
290
-
291
- `scripts/desktop-shape-probe.mjs` is a third probe, aimed at a **running dsh
292
- Desktop**. Desktop 0.2.1+ asks the OS for its port, so pass the port it printed
293
- (or is listening on) as `DSH_PORT` — older releases listened on 19387. It probes
294
- state / debug / backup / usage scan / the Mermaid engine and script routes in the
295
- exact header shape the desktop shell forwards (loopback Host, no `origin`, no
296
- `sec-fetch-site`), then runs timeline, the three export formats and search
297
- against the first session the host has registered; the foreign-origin and
298
- cross-site probes must still come back 403. The usage-scan probe rewrites
299
- today's usage ledger, so point `DSH_HOME` at a scratch home when that matters;
300
- the other probes are read-only. If the GUI has no session yet, send one message
301
- there and re-run.
302
-
303
- Checking a new dsh release takes four commands, and never touches your own
304
- harness home:
305
-
306
- ```bash
307
- mkdir -p /tmp/dshnext && cd /tmp/dshnext && npm init -y && npm i @deepseek-ai/dsh@<version>
308
- DSH_HOME=/tmp/dshnext-home node node_modules/@deepseek-ai/dsh/lib/bin.js plugin --profile web add <packed.tgz>
309
- DSH_HOME=/tmp/dshnext-home node node_modules/@deepseek-ai/dsh/lib/bin.js --profile web --no-open --port 13999 &
310
- DSH_HOME=/tmp/dshnext-home DSH_PORT=13999 COOKIE_JAR=/tmp/dshnext/jar.txt bash scripts/live-dsh-check.sh
311
- ```
312
-
313
- The range is an open lower bound, so the second command accepts any release at
314
- or above `0.1.7-rc.2`; no compatibility exemption is needed. The scheduled canary
315
- runs these same steps against the newest of npm `latest`/`next`; to test a local
316
- build before releasing, run
317
- `node scripts/compat-canary.mjs <version> --plugin <packed.tgz>`.
318
-
319
- For a **dsh Desktop** release, start one step earlier, because the repository
320
- cannot tell you what an installer runs: Desktop pins its shell and
321
- `@deepseek-ai/dsh` to one exact version and ships the whole runtime inside
322
- `resources/app.asar`. Read it off the installed app instead — the command is
323
- read-only, and it prints that version together with whether the declared
324
- `engines.dsh` / peer range admits it (and which gate dsh will actually read):
325
-
326
- ```bash
327
- node scripts/desktop-runtime.mjs "D:/DSH" # the installation dir
328
- node scripts/desktop-runtime.mjs "D:/DSH/resources/app.asar" # or the archive itself
329
- ```
330
-
331
- Then run the four commands above against the version it names.
332
-
333
- ## License
334
-
335
- Apache-2.0. Portions of the code reference [Nagi-ovo/voyager](https://github.com/Nagi-ovo/voyager) and [unovue/inspira-ui](https://github.com/unovue/inspira-ui).
1
+ # dsh-custom-plugin
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40alexpeng%2Fdsh-custom-plugin?style=flat-square)](https://www.npmjs.com/package/@alexpeng/dsh-custom-plugin)
4
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square)](LICENSE)
5
+ [![Node](https://img.shields.io/badge/node-%3E%3D22-339933?style=flat-square)](#install)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
7
+ [![CI](https://github.com/AlexPeng07/dsh-custom-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/AlexPeng07/dsh-custom-plugin/actions/workflows/ci.yml)
8
+ [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
9
+
10
+ <p align="center">
11
+ <img src="https://www.npm.bet/svg?q=%40alexpeng%2Fdsh-custom-plugin&amp;timeRange=last-month&amp;grouping=day&amp;metric=downloads&amp;zeroMode=estimated" alt="npm downloads, last month" width="560">
12
+ </p>
13
+
14
+ English | [中文](README.zh.md)
15
+
16
+ Custom convenience suite for the DeepSeek Harness (DSH) Web GUI: personalization, weather FX, background motion, glass effects, project folders, enhanced prompts, conversation export/search, Mermaid rendering, 7/30/90-day usage analytics, budget and key-free local backups, plus a Ctrl/Cmd+K command palette.
17
+
18
+ The plugin is dual-face: the host half (`src/`) owns the state document, registers the `/api/custom-plugin` routes and the `custom_plugin_status` agent tool; the browser half (`src/client/`) injects its UI through eight injections into seven official slots and talks to the host over same-origin fetch. Mounted through the official profile mechanism — no DSH source changes.
19
+
20
+ <p align="center">
21
+ <img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/overview.png" alt="dsh-custom-plugin overview" width="100%">
22
+ </p>
23
+
24
+ ## Selected screenshots
25
+
26
+ <table>
27
+ <tr>
28
+ <td width="50%" valign="top"><b>Settings → 个性化: the full-page appearance config</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/settings-appearance.png" alt="Settings → 个性化 full appearance page" width="100%"></td>
29
+ <td width="50%" valign="top"><b>The same panel as a popover from the session header (light theme)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/personalization-panel.png" alt="Personalization popover" width="100%"></td>
30
+ </tr>
31
+ <tr>
32
+ <td width="50%" valign="top"><b>Liquid glass (displacement refraction on Custom surfaces)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/liquid-glass.png" alt="Liquid glass" width="100%"></td>
33
+ <td width="50%" valign="top"><b>Multi-level project folders</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/project-folders.png" alt="Project folders" width="100%"></td>
34
+ </tr>
35
+ <tr>
36
+ <td width="50%" valign="top"><b>Mermaid mindmap rendered in place</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/mermaid-mindmap.png" alt="Mermaid mindmap" width="100%"></td>
37
+ <td width="50%" valign="top" align="center"><b>Balance and today's per-model usage</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/balance-usage.png" alt="Balance and usage panel" width="100%"></td>
38
+ </tr>
39
+ <tr>
40
+ <td width="50%" valign="top" align="center"><b>Rain (three depth layers)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-rain.gif" alt="Rain effect" width="100%"></td>
41
+ <td width="50%" valign="top" align="center"><b>Sakura</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-sakura.gif" alt="Sakura effect" width="100%"></td>
42
+ </tr>
43
+ <tr>
44
+ <td width="50%" valign="top" align="center"><b>Snow</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-snow.gif" alt="Snow effect" width="100%"></td>
45
+ </tr>
46
+ </table>
47
+
48
+ Weather FX is shown in dark mode. Usage history, backup-import previews, session search, and the command palette are dynamic views of the same panel; open them inside DSH to inspect the live UI — no additional fixed screenshots are included.
49
+
50
+ ## What it does
51
+
52
+ ### Appearance
53
+
54
+ - **Background colors**: 20 muted low-saturation palettes (each with a matching tab color, `天青灰` by default) plus "no color" (follows the GUI default theme). Every palette works in both themes; dark mode derives the same family's dark variant (hue and low saturation kept, lightness dropped onto the dark ramp), and the swatch preview shows what the current theme will actually paint.
55
+ - **Weather FX**: canvas-rendered, pointer-transparent one-click overlays — falling snow, cinematic rain (three depth layers with splashes), and drifting sakura petals; turning it off clears the canvas.
56
+ - **Glass**: frosted glass on every Custom surface, or liquid glass (a rounded-rect SDF displacement map refracts all four edges, with a restrained blur + saturation, a 1px specular rim and the host fill at ~70% so text over large panels stays readable; engines without SVG-referencing backdrop filters fall back to frosted). When a background renderer is live, the glass switches to a centre-solid / edge-clear radial fill and a contrast-boosted backdrop so the animation stays visible at the rim without hurting the copy. A global-glass option extends the same treatment to dialogs, menus, tooltips, listboxes and the system settings window — displaced as well in liquid mode.
57
+ - **Native surfaces**: the header's 个性化 button opens only a compact appearance popover anchored to it — flipped upward when the viewport runs short, never a draggable window — while folders, prompts, search, export, Mermaid, efficiency, usage and data management all live in the 个性化 section of DSH Settings. Popovers, menus and settings cards use the host's menu material, elevation shadows, radius scale and type scale, with 150–220 ms open/close motion that starts from the anchor's edge (toasts also animate out in place) and respects the system's reduced-motion preference.
58
+ - **Background motion**: a full-page animated layer beneath the content, in two independent tiers — ASCII glyph grids (`flow`, `rain`, `ocean`, `starfield`, `ripple`, plus the zero-animation `static`) and 光影 (the shader tier: one full-screen WebGL1 shader per style, `liquid`, `grain`; a page without WebGL falls back to the ASCII tier and says so). The panel switches tier and preset, tunes density, speed, frame rate, font size and opacity — intensity instead of font/opacity on the shader tier — and "restore defaults" resets only those six parameter overrides back to "follow the current preset"; the tier and preset themselves are never changed by that button, and the panel says so next to it. Every slider clamps to the active preset's declared range. Ink strength is a separate three-step choice (柔和 / 标准 / 强烈) that scales the ink step without touching density, speed or frame rate, and the **avoid-the-copy** switch (避让正文, on by default) fades the texture behind the reading column while the page edges keep full strength — turning it off makes the whole page uniform. While the effect is on, the shell's page fills become translucent so the texture shows; with glass on, cards and popovers become glass over that texture — the centre keeps enough tint for the copy while the edges reveal the animation — and dialogs stay opaque. `ocean`, `flow`, `rain`, `ripple` and `starfield` respond to the pointer. The `ocean` preset lives inside the conversation column, so the water is visible behind the messages; drag to leave ripples, click for a splash, and the fish school scatters and regroups. `flow` stays a page-level background, but the pointer now stirs its fog: dragging bends and thickens the noise along the path, and a click pushes a ring through it. `rain` reads the pointer as wind: a flick slants the falling trails and a click parts the curtain to both sides, then it slowly closes again. In `ripple`, a click drops a new ring where it lands and a drag leaves a trail of small ones. `starfield` keeps its sparse character — a press lights a small burst of stars and a drag scatters a thin trail, both fading out in about a second. The shader tier's `liquid` also follows the pointer: moving it twists the ink cloud and a click sends a ring outward, while `grain` stays a static speck field by design. The other presets are still page-level backgrounds.
59
+
60
+ <img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/background-motion-panel.png" alt="Background motion panel with the character tier active" width="360">
61
+
62
+ ### Project folders
63
+
64
+ A multi-level folder tree persisted in the `$DSH_HOME` state file, shared across workspaces. Any workspace or session can be folded in; folders support drag-to-reorder (before / inside / after) plus move-up/down buttons, inline rename (double-click or the pencil), delete confirmation, search over names and references, and add-current-session shortcuts. Empty and no-match states both say what to do next.
65
+
66
+ ### Prompts
67
+
68
+ Add and edit in a single form dialog (name, body, tags, favorite; `Ctrl/⌘+Enter` saves) instead of three chained prompts. The list supports search, tag and favorite filters, and manual / recent / use-count / name sorting, with recency and use counts recorded. Deletes can be undone from the toast for five seconds; imports preview valid, skipped and conflicting records before merging or replacing. A dirty editor asks "discard changes / keep editing" before Escape, mask click or Cancel closes it. `{{variable}}` placeholders open a fill-in form before insertion. The library supports versioned JSON and heading-based Markdown import/export.
69
+
70
+ ### Conversation export
71
+
72
+ Pick a format card to export the current session; the panel shows read → assemble → write steps, can cancel mid-flight, reports the file name and size on success, and retries after a failure (file names carry a date stamp):
73
+
74
+ - **JSON**: standard `messages` structure (user / assistant / tool), with a meta block carrying the session title, creation time, working directory and export time — importable elsewhere;
75
+ - **Markdown**: role-sectioned plain text;
76
+ - **PDF**: an A4 print-layout HTML opened in the browser and saved as PDF; images embed as base64 (up to 30 images, 12 MB total, 4 MB each).
77
+
78
+ Tool rows carry the tool name and an argument digest (resolved from the paired tool/call events).
79
+
80
+ Plugin state can be exported as a versioned JSON backup containing appearance, folders, prompts, stars, usage, and budget settings. API keys and credential metadata are excluded. Imports show a conflict preview, support merge or non-secret replacement, and create a recovery copy first.
81
+
82
+ ### Mermaid
83
+
84
+ ```mermaid blocks anywhere in the chat — assistant replies included (mindmaps, flowcharts, sequence diagrams, …) — render in place automatically: a diagram/code toggle bar with a mermaid.live fallback link appears above the block, streaming blocks preview once their content is complete, diagrams re-render on GUI theme flips, and a failed render keeps the raw code. Detection keys off the fence language label; with a blank label (mid-stream) a content heuristic decides (keyword prefix + completeness checks, so blocks labeled with a real language are never touched). The engine loads from the mermaid 11 dependency installed with the plugin (works offline), falling back to jsdelivr / fastly / unpkg mirrors and caching in the host process; the render chips under user messages and the multi-diagram modal stay, and the mermaid.live link uses the DEFLATE-compressed `#pako:` format that restores the diagram on open.
85
+
86
+ ### Efficiency tools
87
+
88
+ - **Anti auto-scroll**: force `scroll-behavior: auto` so sends never yank the view to the bottom (off by default);
89
+ - **Formula copy**: LaTeX / MathML copy chips under matching messages (MathML pastes into Word);
90
+ - **Batch archive**: select sessions and archive them in bulk; running sessions are unavailable and completion reports separate success/failure counts. DSH exposes no restore API yet, so the plugin provides no restore entry point.
91
+ - **Session search**: switch between the current session and all sessions; current-session search filters user, assistant and tool content and jumps to the containing turn with ↑/↓/Enter keyboard navigation; superseded requests are cancelled. DSH's event index is used when the deployment opens one, and otherwise the plugin scans the session log it already read (the panel says which path answered).
92
+ - **Command palette**: press `Ctrl+K` / `Cmd+K` outside editors to search sessions, workspaces, prompts, and common actions; cross-session content search uses DSH's official API and reports its own unavailability.
93
+ - **Reliable archive**: running sessions are unavailable by default and batch completion reports separate success and failure counts.
94
+
95
+ ### Balance and usage
96
+
97
+ A usage badge sits in the session header (click to open, click again to close): a signed-in DSH account shows the same official balance as Settings → 账号与余额; otherwise it shows the local cost estimate (e.g. `≈¥0.42`) plus today's call count. The card is a one-screen summary — available balance, today's totals, the per-model table and the monthly budget — with 刷新 / 扫描日志 / 完整用量 in its footer — 完整用量 opens the settings page directly — and the full ledger lives in Settings → 个性化 → 用量与额度. It provides:
98
+
99
+ - **Usage and cost (local, no credentials)**: today's and historical usage, budget and the cost estimate all come from local session records.
100
+ - **Balance (DSH account only)**: read through the host account service — the same recharge + bonus wallet query Settings → 账号与余额 renders. The balance block shows granted / topped-up amounts, a zero-balance hint, and the account service's 用量明细 / 充值 links. Signed out: the card keeps the local estimate and points to Settings → 账号与余额. A wallet query that is still settling is shown as loading and retried; a failed query retries without hiding the local estimate. There is no API-key form.
101
+ - **Today's usage**: per-model input / output / cache token counters and call counts, folded live from `session/event` records.
102
+ - **Cost estimate**: DeepSeek's official peak/off-peak table (checked 2026-11-14, CNY per 1M tokens). Peak hours are Beijing weekdays 09:00–12:00 / 14:00–18:00, excluding Chinese statutory holidays; all other times — weekends, holidays and other hours — are off-peak at exactly half price. `deepseek-flash`: peak ¥2 input (cache hit ¥0.04), ¥8 output; `deepseek-v4-pro`: ¥9 input (cache hit ¥0.30), ¥27 output. Cache writes are charged at the cache-miss input price. Indicative only.
103
+ - **Scan**: "scan today's session logs" replays every session and buckets usage events by their own timestamp (cross-midnight sessions keep contributing today's usage), reporting how many active sessions were scanned.
104
+ - **History and budget**: inspect 7 / 30 / 90-day trends and per-model totals, export UTF-8 CSV, and set a local monthly CNY budget with an in-plugin warning threshold and a usage-ratio bar. The settings card shows when it last refreshed and offers a retry when the query fails.
105
+
106
+ ### Settings entry
107
+
108
+ Settings → 个性化 is the full management page: a section nav above the content (appearance, folders, prompts, search, export, extensions, usage and balance, data and about) that wraps inside the narrow host panel, followed by native settings cards. The header's 个性化 button opens only the compact appearance popover: anchored to the button and flipped upward when the viewport runs short; `Escape` or a click outside closes it and focus returns to the trigger. The popover cannot be dragged and never covers the bottom composer. Its 完整设置 footer, the balance card's 完整用量 and the other management links open Settings directly: the plugin walks the host's real entry controls (account menu → 设置) and selects 个性化 plus the requested section, falling back to the `Ctrl+Alt+,` hint only when that path is unavailable. The 项目 button in the sidebar footer opens the folder popover.
109
+
110
+ ### Agent integration
111
+
112
+ The `custom_plugin_status` tool reports appearance config, today's per-model usage, balance, a timeline sample, Mermaid engine state, the state file path and client diagnostics. The plugin never injects system-prompt announcements.
113
+
114
+ ## Compatibility
115
+
116
+ | plugin release | dsh it was built and verified against | status |
117
+ | --- | --- | --- |
118
+ | 0.9.x | any dsh at or above 0.1.7-rc.2 (open-ended; verified on 0.1.7-rc.2, 0.2.0-rc.2, 0.2.1-rc.2, 0.2.1-rc.3, 0.2.1-rc.4 and 0.2.1-rc.5) | this release |
119
+ | 0.8.x | dsh 0.1.7-rc.2, dsh 0.2.0-rc.2 and dsh 0.2.1-rc.2 (measured window) | previous; refused on dsh 0.2.1-rc.3 and later |
120
+ | 0.7.x | dsh 0.1.7-rc.2 and dsh 0.2.0-rc.2 | previous; refused on dsh 0.2.1-rc.2 |
121
+ | 0.6.x | dsh 0.1.7-rc.2 and dsh 0.2.0-rc.2 | previous; refused on dsh 0.2.1-rc.2 |
122
+ | 0.5.x | dsh 0.1.7-rc.2 (peer range `>=0.1.7-rc.2 <0.2.0-0`) | fine on 0.1.x; refused on any 0.2.x host, including dsh Desktop |
123
+ | 0.4.2 | dsh 0.1.1-rc.1 … 0.1.6 era | superseded; do not expect it to work on 0.1.7+ |
124
+
125
+ 0.1.7 changed the plugin-facing contracts this suite depends on (session
126
+ navigation moved to `ctx.uiWorkspace`, the session list stopped publishing the
127
+ viewed session, and the message model dropped the `tool-result` content block),
128
+ so neither release substitutes for the other. dsh 0.2.1-alpha.4 changed the
129
+ compatibility gate itself: it reads `engines.dsh` first and falls back to the
130
+ `@deepseek-ai/dsh-*` peer ranges only when `engines.dsh` is absent. This package
131
+ declares the same **open lower bound** (`>=0.1.7-rc.2`) in both places, so every
132
+ newer dsh release is admitted without waiting for a plugin release; older hosts
133
+ read the peers, newer hosts read `engines.dsh`, and `pnpm smoke` fails if the
134
+ two ever disagree. Verified versions are evidence, not a gate: see the table and
135
+ CHANGELOG. A scheduled canary installs the published plugin into the newest dsh
136
+ from npm `latest`/`next`, boots it, and runs the live probes, so an actual API
137
+ break shows up as an issue instead of a user-visible refusal. Runtimes
138
+ predating that gate load the bundle anyway and degrade instead: on 0.1.1-rc.2,
139
+ 7 of 8 slot registrations succeed, the turn-tail entry is rejected (that slot
140
+ became a list slot back in 0.1.6-alpha.2), and the open-session / branch /
141
+ cross-session actions report their service as missing rather than throwing.
142
+
143
+ ## Install
144
+
145
+ Prerequisites: Node 22+, pnpm, and the `dsh` CLI (the official `@deepseek-ai/dsh` npm package; `npx @deepseek-ai/dsh` stands in for `dsh` when it is not installed globally). This release admits **every dsh release at or above 0.1.7-rc.2**: `engines.dsh` and the `@deepseek-ai/dsh-tools` peer are both an open lower bound, so dsh 0.2.1-alpha.4 and later (which read `engines.dsh` first) and older hosts (which read the peers) agree that no newer release is refused. 0.9.0 was built and tested on 0.2.1-rc.3. Its artifact was installed with Desktop's own CLI into an isolated 0.2.1-rc.3 profile **with no compatibility exemption**, then booted for real: a 71-row boot graph, all five `dsh.client.inject` targets, the client bundle served at 200,371 bytes, the local Mermaid engine (3,572,661 bytes), the state / usage / backup routes, a UTF-8 round trip and the desktop-forward trust shape all passed (16 live probes pass, 1 skip; the skip is timeline/export/search on a profile with no session, covered by unit tests). On 2026-10-30 the build-and-test cohort moved to 0.2.1-rc.5 (the 11-entry client seed table is unchanged), and the published 0.9.3 artifact was re-verified there: 71 boot rows, all five inject targets, 208,217 bytes served, 16 live probes pass and 1 skips, plus a live Desktop 0.2.1-rc.5 host passing the desktop-shape probe 11 / 0. 0.8.0 ran the same probes on 0.2.1-rc.2 (70 rows); 0.6.0 ran them on 0.2.0-rc.2 (66 rows) and 0.1.7-rc.2 (65 rows), 18 of 19 each; 0.7.0 additionally passed the desktop-shape probe **on a real Desktop install** (see "On dsh Desktop" below). What stays unverified is what was always unverified: the per-turn chips (Mermaid render, LaTeX) need a real model reply, so a credential-free scratch home cannot reach them, and slot rendering still needs a browser pass. The host gate cannot distinguish "verified" from "unverified", so an explicit upper bound would refuse users on every dsh release until this package published again; the open range plus the scheduled canary replace that waiting with automatic detection. If a host below the floor is ever needed, install the matching older plugin release (`0.5.0` targets 0.1.7-rc.2).
146
+
147
+ ### From npm
148
+
149
+ ```sh
150
+ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
151
+ # restart dsh web
152
+ ```
153
+
154
+ The registry tarball ships prebuilt output — no source build on the installing machine.
155
+
156
+ ### On dsh Desktop
157
+
158
+ dsh Desktop is an Electron shell around the same Web application, and it bundles
159
+ **exactly dsh 0.2.1-rc.5** as of 2026-10-29 — the desktop release line pins the
160
+ shell and the runtime together, so a Desktop install is always one exact 0.2.x
161
+ runtime. 0.9.0's open range admits rc.5 and every later Desktop build, with no
162
+ compatibility exemption; 0.8.0 and earlier used a measured window and are refused
163
+ on rc.5 by the same gate a 0.2.x Web profile prints.
164
+
165
+ Measured against 0.2.1-rc.5 with the published 0.9.3 artifact: the boot graph
166
+ carries our row and all five inject targets (71 module rows), our client bundle
167
+ is served at 208,217 bytes, the Mermaid engine loads locally, and the live host
168
+ probes pass 16 / skip 1 (the session-path skip needs a real session). On a
169
+ running Desktop 0.2.1-rc.5 host the desktop-shape probe passed 11 / 0 (one
170
+ session-dependent chain skipped). The access fence shares the platform
171
+ fence's trust semantics: a loopback socket naming a loopback Host, a
172
+ non-`cross-site` marker, and an Origin that is absent or matches the Host
173
+ authority. The shell forwards renderer requests to its own Host after deleting
174
+ `host`, `origin`, `sec-fetch-site` and `cookie`, then attaches its own
175
+ credential — that unmarked shape is accepted outright (through 0.6.0 the fence
176
+ additionally required a same-origin marker and rejected exactly this shape with
177
+ `forbidden`; fixed in 0.7.0 with fence-level unit tests). Foreign-origin and
178
+ cross-site requests are still 403. **The 0.7.0 artifact was probed route by
179
+ route on a real Desktop install in the desktop forward shape** (state / debug /
180
+ backup / usage scan / the Mermaid engine preload and script routes all 200;
181
+ foreign-origin and cross-site probes still 403), 0.8.0 repeated the same shape
182
+ against a booted 0.2.1-rc.2 host, 0.9.0 repeated it on rc.3, and 0.9.3 repeated
183
+ it on a live rc.5 Desktop host (11 / 0). The visual pass inside the Desktop
184
+ window (liquid glass look, panel layout, pattern removal) belongs to whoever
185
+ installs it.
186
+
187
+ Managing the desktop profile takes the `dsh` command that ships with Desktop, not
188
+ the npm one — the public CLI refuses the reserved `desktop` profile:
189
+
190
+ 1. Start Desktop once so the profile exists, then quit it fully (closing the
191
+ window only hides it; on Windows use the tray).
192
+ 2. `dsh plugin --profile desktop add @alexpeng/dsh-custom-plugin`
193
+ 3. Reopen Desktop. The in-app Plugin Manager installs and updates against the
194
+ same profile using Desktop's own bundled pnpm, if you would rather not open a
195
+ terminal.
196
+
197
+ Appearance, prompt library, project folders, stars and usage all live in
198
+ `$DSH_HOME/custom-plugin-state.json`, which Desktop and Web share by design —
199
+ each keeps its own `profiles/<name>` for code, never for that file — so
200
+ switching between the two shows the same data. Both hosts can therefore write it
201
+ at once, which is why the state replace names its temp file after the writing
202
+ process.
203
+
204
+ ### From GitHub (source install)
205
+
206
+ ```sh
207
+ dsh plugin --profile web add github:AlexPeng07/dsh-custom-plugin
208
+ # restart dsh web
209
+ ```
210
+
211
+ Git installs pull sources; the `prepare` script builds `lib/` on the installing machine. pnpm ≥10 asks you to approve that build once — copy the exact package key it prints into the profile's `pnpm-workspace.yaml` under `allowBuilds`, then re-run the add. The npm route above skips the build-approval step.
212
+
213
+ ### Local link (development)
214
+
215
+ ```sh
216
+ # build (run from this repo root)
217
+ pnpm install
218
+ pnpm build
219
+ # add to the web profile. The link path must not contain spaces: on Windows,
220
+ # create a space-free directory junction first and link to the junction path
221
+ dsh plugin --profile web add link:F:/dsh-plugin-dev
222
+ # restart dsh web
223
+ ```
224
+
225
+ The package declares its manifest per the official bundle protocol: `dsh.bundle.patch` in `package.json` points at the `cordis.patch.yml` config layer (row id `custom-plugin`) and `dsh.client` declares the browser half. `dsh plugin add` forwards to pnpm inside the profile directory; the installed package joins `dsh.profile.bundles` automatically because of that declaration, and the browser half loads via the official client module system from the same row.
226
+
227
+ ## Config
228
+
229
+ The plugin reads and writes one JSON document at `$DSH_HOME/custom-plugin-state.json` (`~/.dsh` by default, overridable via the `DSH_HOME` environment variable): appearance config, folders, prompts, stars, legacy compatibility data, and a 90-day per-day usage ledger. Writes are atomic (temp file + rename), so a crash never truncates the document.
230
+
231
+ Appearance and feature toggles (the `cfg` field, all with defaults):
232
+
233
+ | Key | Default | Meaning |
234
+ |---|---|---|
235
+ | `bg` | `天青灰` | `default` (no color) / one of the 20 palette names (both themes; a stored `aurora` migrates to `default`) |
236
+ | `bgFx` | `none` | `none` / `ascii` / `shader` (labelled 关闭 / 字符 / 光影 in the panel); the shader tier falls back to ASCII when the page has no WebGL |
237
+ | `bgFxPreset` | `flow` | the active tier's preset: `flow`/`rain`/`ocean`/`starfield`/`ripple`/`static` for ASCII, `liquid`/`grain` for the shader tier; an id from the other tier resets to that tier's default |
238
+ | `bgStrength` | `standard` | ink strength `soft` / `standard` / `strong` (柔和 / 标准 / 强烈), multipliers 0.45 / 0.62 / 0.9; scales the ink step only, density/speed/frame rate are unaffected. `standard` is the shipped default and matches the depth the earlier build used for 柔和 |
239
+ | `bgFocus` | `true` | 避让正文: fade the texture behind the reading column and keep the page edges dense; `false` makes the whole page uniform and takes the mask out of the render pipeline |
240
+ | `bgDensity`, `bgSpeed`, `bgFps`, `bgFontPx`, `bgOpacity`, `bgIntensity` | `-1` | panel overrides; `-1` follows the preset, anything else is clamped to the active preset's declared range (ASCII uses five, shader uses density/speed/fps/intensity) |
241
+ | `weather` | `none` | `none` / `snow` / `rain` / `sakura` |
242
+ | `glass` | `true` | master glass toggle for Custom surfaces |
243
+ | `glassMode` | `frost` | `frost` frosted / `liquid` displacement glass |
244
+ | `globalGlass` | `true` | blur global overlays (dialogs/menus/tooltips) |
245
+ | `antiScroll` | `false` | anti auto-scroll |
246
+ | `mermaid` | `true` | automatic in-place Mermaid rendering (plus render chips) |
247
+ | `formula` | `true` | LaTeX / MathML copy chips |
248
+ | `monthlyBudgetCny` | `0` | Monthly CNY budget; `0` disables warnings |
249
+ | `budgetWarningPercent` | `80` | Monthly warning threshold (1–100) |
250
+
251
+ ## Security model
252
+
253
+ - The browser talks to the host only through loopback `/api/custom-plugin` routes; every route checks a loopback socket address, a loopback Host header, and browser same-origin markers (`sec-fetch-site` / `Origin`). `X-Forwarded-For` is never trusted.
254
+ - The browser never receives DeepSeek credentials. Balance is read by the host through DSH's own account service (`deepseekAccount` — the same recharge + bonus wallet query Settings → 账号与余额 renders), and the browser receives only the wallet amounts and the account page links. The balance module accepts no API key, ships no key form and performs no key lookup of its own.
255
+ - Older state documents may still carry a legacy `apiKey` field from versions before this change. It is never used as a balance source, is never sent to the browser and never enters a backup; the balance module works without it.
256
+ - Conversation exports and timeline data stay on the local host.
257
+
258
+ ## Known limitations
259
+
260
+ - The Mermaid engine comes from the dependency installed with the plugin and works offline; only a missing dependency falls back to a CDN fetch (cached for the host process lifetime).
261
+ - The usage ledger folds token counts from live `session/event` records, retains 90 Beijing calendar days, and a manual "scan" re-reads today's session logs with four concurrent reads when live events were missed.
262
+ - The usage panel shows the peak/off-peak token and cost split plus a link to the official pricing page; rows without peak counters are marked inexact and excluded from cost totals until rescanned.
263
+ - Balance comes only from the DSH account wallet: a signed-out account, or a host without the account service, shows the local cost estimate and a pointer to Settings → 账号与余额 instead of a balance. There is no API-key fallback.
264
+ - Cost estimates use DeepSeek's official peak/off-peak list prices and are indicative only; the statutory-holiday calendar is checked in with the same rule and must be extended when the next State Council notice ships.
265
+ - Palettes derive a same-family dark variant in dark mode (hue and low saturation kept).
266
+ - DSH currently exposes no archive-restore API; the plugin does not bypass that boundary by editing the underlying registry.
267
+ - The command palette owns `Ctrl+K` / `Cmd+K` (no Alt/Shift, ignored inside editors). dsh's own default on the **web** profile is `Ctrl+Alt+K` (the desktop default is plain `Ctrl+K`), so nothing collides out of the box — but dsh 0.1.7 lets you rebind host shortcuts, and if you assign a host command to plain `Ctrl+K`, both fire. Keep the palette key reserved, or pick another binding there.
268
+ - dsh's shipped `web` profile composes its session-query index with `openAt: never`, so full-text search is off unless the deployment enables it. In-session search therefore answers from a direct log scan (ordered, capped at 100 hits) and the palette's cross-session search shows dsh's own refusal.
269
+
270
+ ## Development
271
+
272
+ ```sh
273
+ pnpm typecheck # type check
274
+ pnpm test # vitest unit tests
275
+ pnpm build # build the node ESM library and the browser bundle into lib/
276
+ pnpm check:readme # bilingual README hash consistency
277
+ pnpm smoke # post-build contract checks: loader handshake, manifest
278
+ # fields dsh reads, patch row, local Mermaid engine,
279
+ # real-engine Mermaid error-path DOM regression
280
+ pnpm canary # published plugin against the newest dsh from npm latest/next
281
+ # (needs npm, bash and curl; --plugin <tgz> tests a local build)
282
+ pnpm bench:mermaid # synthetic long-turn Mermaid scan/render benchmark (headless Edge)
283
+ ```
284
+
285
+ `scripts/live-dsh-check.sh` is a separate, manual probe against a **running**
286
+ isolated dsh profile (`DSH_HOME=… DSH_PORT=… bash scripts/live-dsh-check.sh`):
287
+ it exercises the host half on real session data — timeline, the three export
288
+ formats, the search scan path, usage scan, backup, the Mermaid engine route, the
289
+ client→host diagnostic ring, a UTF-8 state round trip that restores and then
290
+ verifies your prompt library, and the three trust-fence shapes (an unmarked
291
+ loopback request passes, a foreign Origin and a cross-site marker are
292
+ rejected). It refuses to run against a
293
+ real `~/.dsh` unless you set `ALLOW_REAL_DSH_HOME=1`, reports `PASS`/`FAIL` per
294
+ probe, counts and names anything it `SKIP`s, and exits non-zero on any failure.
295
+ The main CI job has no harness to talk to; the scheduled `compat-canary`
296
+ workflow runs this probe against the newest dsh from npm `latest`/`next` and
297
+ opens an issue on failure. Run it manually when you want detail on a release;
298
+ slot registration and rendering still need the browser pass described above.
299
+
300
+ `scripts/desktop-shape-probe.mjs` is a third probe, aimed at a **running dsh
301
+ Desktop**. Desktop 0.2.1+ asks the OS for its port, so pass the port it printed
302
+ (or is listening on) as `DSH_PORT` — older releases listened on 19387. It probes
303
+ state / debug / backup / usage scan / the Mermaid engine and script routes in the
304
+ exact header shape the desktop shell forwards (loopback Host, no `origin`, no
305
+ `sec-fetch-site`), then runs timeline, the three export formats and search
306
+ against the first session the host has registered; the foreign-origin and
307
+ cross-site probes must still come back 403. The usage-scan probe rewrites
308
+ today's usage ledger, so point `DSH_HOME` at a scratch home when that matters;
309
+ the other probes are read-only. If the GUI has no session yet, send one message
310
+ there and re-run.
311
+
312
+ Checking a new dsh release takes four commands, and never touches your own
313
+ harness home:
314
+
315
+ ```bash
316
+ mkdir -p /tmp/dshnext && cd /tmp/dshnext && npm init -y && npm i @deepseek-ai/dsh@<version>
317
+ DSH_HOME=/tmp/dshnext-home node node_modules/@deepseek-ai/dsh/lib/bin.js plugin --profile web add <packed.tgz>
318
+ DSH_HOME=/tmp/dshnext-home node node_modules/@deepseek-ai/dsh/lib/bin.js --profile web --no-open --port 13999 &
319
+ DSH_HOME=/tmp/dshnext-home DSH_PORT=13999 COOKIE_JAR=/tmp/dshnext/jar.txt bash scripts/live-dsh-check.sh
320
+ ```
321
+
322
+ The range is an open lower bound, so the second command accepts any release at
323
+ or above `0.1.7-rc.2`; no compatibility exemption is needed. The scheduled canary
324
+ runs these same steps against the newest of npm `latest`/`next`; to test a local
325
+ build before releasing, run
326
+ `node scripts/compat-canary.mjs <version> --plugin <packed.tgz>`.
327
+
328
+ For a **dsh Desktop** release, start one step earlier, because the repository
329
+ cannot tell you what an installer runs: Desktop pins its shell and
330
+ `@deepseek-ai/dsh` to one exact version and ships the whole runtime inside
331
+ `resources/app.asar`. Read it off the installed app instead — the command is
332
+ read-only, and it prints that version together with whether the declared
333
+ `engines.dsh` / peer range admits it (and which gate dsh will actually read):
334
+
335
+ ```bash
336
+ node scripts/desktop-runtime.mjs "D:/DSH" # the installation dir
337
+ node scripts/desktop-runtime.mjs "D:/DSH/resources/app.asar" # or the archive itself
338
+ ```
339
+
340
+ Then run the four commands above against the version it names.
341
+
342
+ ## License
343
+
344
+ Apache-2.0. Portions of the code reference [Nagi-ovo/voyager](https://github.com/Nagi-ovo/voyager) and [unovue/inspira-ui](https://github.com/unovue/inspira-ui).