@alexpeng/dsh-custom-plugin 0.1.1 → 0.1.3
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 +97 -0
- package/README.i18n.yaml +2 -2
- package/README.md +37 -3
- package/README.zh.md +37 -3
- package/lib/client.js +343 -6
- package/lib/client.js.map +1 -1
- package/lib/index.js +76 -12
- package/lib/types/client/mermaid-code.d.ts +19 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/host-service.d.ts +17 -1
- package/lib/types/state.d.ts +6 -2
- package/package.json +20 -12
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format loosely
|
|
4
|
+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
|
|
5
|
+
follow [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## 0.1.3 — 2026-08-23
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Concurrent state saves are serialized per state file: two racing saves could
|
|
12
|
+
collide on the shared `.tmp` file and fail the rename on Windows; a failed
|
|
13
|
+
debounced save now surfaces in the status-tool diagnostics instead of being
|
|
14
|
+
swallowed silently.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- CI: bilingual README hash consistency check (`node scripts/check-readme-i18n.mjs`)
|
|
19
|
+
— editing one language without the other, or forgetting to re-record the
|
|
20
|
+
hashes in `README.i18n.yaml`, now fails the build instead of drifting silently.
|
|
21
|
+
- CI: Dependabot with monthly schedules (GitHub Actions and grouped npm
|
|
22
|
+
minor/patch bumps); workflow actions upgraded to current majors.
|
|
23
|
+
- `pnpm smoke` — post-build smoke script: headless Edge loads `lib/client.js`
|
|
24
|
+
against a stubbed module loader and asserts the registration handshake, plus
|
|
25
|
+
artifact contract checks (loader banner/footer, node-half ESM import,
|
|
26
|
+
patch row, local Mermaid engine).
|
|
27
|
+
- Tests: the balance key resolution chain (panel → environment → DSH
|
|
28
|
+
credentials, via a new credential-reader seam), state merge edge cases, and
|
|
29
|
+
concurrent-save serialization.
|
|
30
|
+
- Docs: the security section now states explicitly that the panel-pasted key
|
|
31
|
+
is stored in plaintext in the state file (same trust domain as DSH's own
|
|
32
|
+
credentials).
|
|
33
|
+
- This changelog (also shipped in the npm tarball).
|
|
34
|
+
|
|
35
|
+
## 0.1.2 — 2026-08-23
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- **Mermaid diagrams in assistant replies now render in place.** The rendering
|
|
40
|
+
entry previously hooked only user messages, so assistant-generated diagrams —
|
|
41
|
+
mindmaps in particular — never got an entry point. A `MutationObserver` now
|
|
42
|
+
scans GUI code blocks and renders ```mermaid``` fences where they are
|
|
43
|
+
(`MermaidInPlace`), without moving any React-owned nodes.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- Mermaid engine is a local runtime dependency served by the host; the CDN
|
|
48
|
+
mirrors are a fallback only. The source (`local` / `cdn`) is visible in the
|
|
49
|
+
status tool diagnostics.
|
|
50
|
+
|
|
51
|
+
### Added (repository-side)
|
|
52
|
+
|
|
53
|
+
- GitHub Actions CI (Node 22 + pnpm 11: typecheck / test / build), README
|
|
54
|
+
badges, and a bilingual screenshot gallery under `docs/`.
|
|
55
|
+
|
|
56
|
+
## 0.1.1 — 2026-08-22
|
|
57
|
+
|
|
58
|
+
### Security
|
|
59
|
+
|
|
60
|
+
- Mermaid rendering hardened: `securityLevel: strict` (was `loose`), and the
|
|
61
|
+
`/custom-plugin/mermaid.js` engine route is behind the same loopback trust
|
|
62
|
+
fence as every other route.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- Peak/off-peak pricing and daily usage buckets are computed in Beijing time
|
|
67
|
+
(UTC+8) regardless of the host machine's timezone; tests are
|
|
68
|
+
timezone-independent.
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
|
|
72
|
+
- `@deepseek-ai/dsh-tools` moved to `peerDependencies` and externalized from
|
|
73
|
+
the bundle — `lib/index.js` shrinks from ~245 KB to ~45 KB and shares the
|
|
74
|
+
harness instance at runtime.
|
|
75
|
+
- Dead code removed: unused `afterSeq` incremental timeline protocol and cache,
|
|
76
|
+
unused type re-exports, dead client state fields, unconditional startup log.
|
|
77
|
+
|
|
78
|
+
### Added
|
|
79
|
+
|
|
80
|
+
- Self-contained `prepare` script — GitHub source installs build themselves
|
|
81
|
+
(pnpm ≥ 10 users: allowlist the build script, see README).
|
|
82
|
+
- Package metadata: `repository`, `author`, `bugs`, `homepage`,
|
|
83
|
+
`engines` (Node ≥ 22); LICENSE copyright line filled in.
|
|
84
|
+
|
|
85
|
+
## 0.1.0 — 2026-08-22
|
|
86
|
+
|
|
87
|
+
Initial release: a personalization suite for the DSH web GUI, mounted through
|
|
88
|
+
the official profile mechanism without touching DSH source.
|
|
89
|
+
|
|
90
|
+
- Appearance: background palettes, liquid glass, weather effects
|
|
91
|
+
(rain / sakura / snow).
|
|
92
|
+
- Per-user-message timeline rail with stars and branching.
|
|
93
|
+
- Multi-level project folders; prompt library.
|
|
94
|
+
- Conversation export (JSON / Markdown / PDF with images).
|
|
95
|
+
- Mermaid rendering; quote reply.
|
|
96
|
+
- DeepSeek balance and daily token usage (peak/off-peak aware).
|
|
97
|
+
- `custom_plugin_status` agent-facing diagnostic tool.
|
package/README.i18n.yaml
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
# after editing either side, bring the other along and re-record the hashes:
|
|
4
4
|
# git hash-object --path README.md README.md
|
|
5
5
|
# git hash-object --path README.zh.md README.zh.md
|
|
6
|
-
README.md:
|
|
7
|
-
README.zh.md:
|
|
6
|
+
README.md: 1d7b7924ae361dcbd56c47d33f4747065532790b
|
|
7
|
+
README.zh.md: bd92979bde665e8371e76f4cf526ac6755d7ff42
|
package/README.md
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
# dsh-custom-plugin
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@alexpeng/dsh-custom-plugin)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](#install)
|
|
6
|
+
[](https://www.typescriptlang.org)
|
|
7
|
+
[](https://github.com/AlexPeng07/dsh-custom-plugin/actions/workflows/ci.yml)
|
|
8
|
+
|
|
3
9
|
English | [中文](README.zh.md)
|
|
4
10
|
|
|
5
11
|
Custom convenience suite for the DeepSeek Harness (DSH) Web GUI: personalization, weather FX, glass effects, a per-user-message timeline rail, project folders, prompts, conversation export, Mermaid rendering, quote reply, and DeepSeek balance / daily token usage.
|
|
6
12
|
|
|
7
13
|
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.
|
|
8
14
|
|
|
15
|
+
## Selected screenshots
|
|
16
|
+
|
|
17
|
+
<table>
|
|
18
|
+
<tr>
|
|
19
|
+
<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>
|
|
20
|
+
<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>
|
|
21
|
+
</tr>
|
|
22
|
+
<tr>
|
|
23
|
+
<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>
|
|
24
|
+
<td width="50%" valign="top"><b>Timeline rail with hover preview</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/timeline.png" alt="Timeline rail" width="100%"></td>
|
|
25
|
+
</tr>
|
|
26
|
+
<tr>
|
|
27
|
+
<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>
|
|
28
|
+
<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>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<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>
|
|
32
|
+
<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 FX" width="100%"></td>
|
|
33
|
+
</tr>
|
|
34
|
+
<tr>
|
|
35
|
+
<td width="50%" valign="top" align="center"><b>Sakura petals</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-sakura.gif" alt="Sakura FX" width="100%"></td>
|
|
36
|
+
<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 FX" width="100%"></td>
|
|
37
|
+
</tr>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
Weather FX is shown in dark mode, where only "no color" and "aurora" backgrounds are selectable.
|
|
41
|
+
|
|
9
42
|
## What it does
|
|
10
43
|
|
|
11
44
|
### Appearance
|
|
@@ -45,7 +78,7 @@ Tool rows carry the tool name and an argument digest (resolved from the paired t
|
|
|
45
78
|
|
|
46
79
|
### Mermaid
|
|
47
80
|
|
|
48
|
-
|
|
81
|
+
```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.
|
|
49
82
|
|
|
50
83
|
### Efficiency tools
|
|
51
84
|
|
|
@@ -126,18 +159,19 @@ Appearance and feature toggles (the `cfg` field, all with defaults):
|
|
|
126
159
|
| `starsOnly` | `false` | show only starred nodes |
|
|
127
160
|
| `quote` | `true` | selection quote reply |
|
|
128
161
|
| `antiScroll` | `false` | anti auto-scroll |
|
|
129
|
-
| `mermaid` | `true` | Mermaid render chips |
|
|
162
|
+
| `mermaid` | `true` | automatic in-place Mermaid rendering (plus render chips) |
|
|
130
163
|
| `formula` | `true` | LaTeX / MathML copy chips |
|
|
131
164
|
|
|
132
165
|
## Security model
|
|
133
166
|
|
|
134
167
|
- 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.
|
|
135
168
|
- The DeepSeek API key stays in the local state file (or reuses DSH's own credentials) and is only used to call the official DeepSeek balance endpoint.
|
|
169
|
+
- The panel-pasted key is stored in **plaintext** in `$DSH_HOME/custom-plugin-state.json` — the same trust domain as DSH's own `$DSH_HOME/.credentials.yaml` (also plaintext); protect `$DSH_HOME` accordingly.
|
|
136
170
|
- Conversation exports and timeline data stay on the local host.
|
|
137
171
|
|
|
138
172
|
## Known limitations
|
|
139
173
|
|
|
140
|
-
- Mermaid
|
|
174
|
+
- 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).
|
|
141
175
|
- The usage ledger folds token counts from live `session/event` records; a manual "scan" re-reads today's session logs when live events were missed.
|
|
142
176
|
- Cost estimates use DeepSeek's official peak/off-peak list prices and are indicative only.
|
|
143
177
|
- Dark-mode background restriction is deliberate: only "no color" and "aurora" are selectable in dark mode.
|
package/README.zh.md
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
# dsh-custom-plugin
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@alexpeng/dsh-custom-plugin)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](#安装)
|
|
6
|
+
[](https://www.typescriptlang.org)
|
|
7
|
+
[](https://github.com/AlexPeng07/dsh-custom-plugin/actions/workflows/ci.yml)
|
|
8
|
+
|
|
3
9
|
[English](README.md) | 中文
|
|
4
10
|
|
|
5
11
|
DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天气特效、玻璃效果、按用户消息的时间线导航、项目文件夹、提示词库、会话导出、Mermaid 渲染、引用回复,以及 DeepSeek 额度与今日 token 用量。
|
|
6
12
|
|
|
7
13
|
插件为双半区架构:宿主半区(`src/`)持有状态文档、注册 `/api/custom-plugin` 路由与 `custom_plugin_status` 智能体工具;浏览器半区(`src/client/`)通过 7 个官方 slot 的 8 处注入挂载 UI,以同源 fetch 与宿主通信。经官方 profile 机制挂载,不改 DSH 源码。
|
|
8
14
|
|
|
15
|
+
## 部分界面展示
|
|
16
|
+
|
|
17
|
+
<table>
|
|
18
|
+
<tr>
|
|
19
|
+
<td width="50%" valign="top"><b>「设置 → 个性化」整页外观配置</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/settings-appearance.png" alt="设置 → 个性化 整页外观配置" width="100%"></td>
|
|
20
|
+
<td width="50%" valign="top"><b>会话头部弹出的同一套面板(浅色主题)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/personalization-panel.png" alt="个性化弹窗面板" width="100%"></td>
|
|
21
|
+
</tr>
|
|
22
|
+
<tr>
|
|
23
|
+
<td width="50%" valign="top"><b>液态玻璃(Custom 面板位移折射)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/liquid-glass.png" alt="液态玻璃" width="100%"></td>
|
|
24
|
+
<td width="50%" valign="top"><b>时间线轨道与悬停预览</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/timeline.png" alt="时间线轨道" width="100%"></td>
|
|
25
|
+
</tr>
|
|
26
|
+
<tr>
|
|
27
|
+
<td width="50%" valign="top"><b>多级项目文件夹</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/project-folders.png" alt="项目文件夹" width="100%"></td>
|
|
28
|
+
<td width="50%" valign="top"><b>Mermaid 思维导图就地渲染</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/mermaid-mindmap.png" alt="Mermaid 思维导图" width="100%"></td>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<td width="50%" valign="top" align="center"><b>余额与今日分模型用量</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/balance-usage.png" alt="余额与用量面板" width="100%"></td>
|
|
32
|
+
<td width="50%" valign="top" align="center"><b>雨(三层景深)</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-rain.gif" alt="下雨特效" width="100%"></td>
|
|
33
|
+
</tr>
|
|
34
|
+
<tr>
|
|
35
|
+
<td width="50%" valign="top" align="center"><b>樱花</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-sakura.gif" alt="樱花特效" width="100%"></td>
|
|
36
|
+
<td width="50%" valign="top" align="center"><b>飘雪</b><br><img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/weather-snow.gif" alt="飘雪特效" width="100%"></td>
|
|
37
|
+
</tr>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
天气特效截自深色模式(深色下仅「无颜色」与「极光」背景可选)。
|
|
41
|
+
|
|
9
42
|
## 功能
|
|
10
43
|
|
|
11
44
|
### 外观个性化
|
|
@@ -45,7 +78,7 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
|
|
|
45
78
|
|
|
46
79
|
### Mermaid 渲染
|
|
47
80
|
|
|
48
|
-
|
|
81
|
+
聊天中的 ```mermaid 代码块(含助手回复,思维导图 / 流程图 / 时序图等)自动就地渲染为图表:代码块上方出现「图表 / 代码」切换工具条与 mermaid.live 兜底链接,流式输出期间内容完整后即预览,跟随 GUI 明暗主题重绘,渲染失败时保留原代码。检测依据代码块语言标签;无标签(流式中)时按内容启发式判断(关键字前缀 + 完整度检查,语言明确的代码块不会误触)。引擎优先读取随插件安装的本地 Mermaid 11 依赖(离线可用),缺失时回退 jsdelivr / fastly / unpkg 三镜像拉取并在宿主进程内缓存;用户消息下方的渲染按钮与模态窗口(多图切换)保持不变,mermaid.live 链接为 DEFLATE 压缩的 `#pako:` 格式,打开即还原图表。
|
|
49
82
|
|
|
50
83
|
### 效率工具
|
|
51
84
|
|
|
@@ -126,18 +159,19 @@ dsh plugin --profile web add link:F:/dsh-plugin-dev
|
|
|
126
159
|
| `starsOnly` | `false` | 只显示星标节点 |
|
|
127
160
|
| `quote` | `true` | 划词引用回复 |
|
|
128
161
|
| `antiScroll` | `false` | 防自动跳底 |
|
|
129
|
-
| `mermaid` | `true` | Mermaid
|
|
162
|
+
| `mermaid` | `true` | Mermaid 图表自动就地渲染(含消息下方渲染按钮) |
|
|
130
163
|
| `formula` | `true` | LaTeX / MathML 复制按钮 |
|
|
131
164
|
|
|
132
165
|
## 安全模型
|
|
133
166
|
|
|
134
167
|
- 浏览器仅通过回环地址上的 `/api/custom-plugin` 路由与宿主通信;每条路由同时校验回环 socket 地址、回环 Host 头与浏览器同源标记(`sec-fetch-site` / `Origin`),`X-Forwarded-For` 永不信任。
|
|
135
168
|
- DeepSeek API Key 只保存在本机状态文件(或沿用 DSH 自身凭据),仅用于调用 DeepSeek 官方余额接口。
|
|
169
|
+
- 面板粘贴的 Key 以**明文**保存在 `$DSH_HOME/custom-plugin-state.json`——与 DSH 自身的 `$DSH_HOME/.credentials.yaml`(同为明文)处于同一信任域,请相应保护 `$DSH_HOME` 目录。
|
|
136
170
|
- 会话导出与时间线数据全部停留在本机。
|
|
137
171
|
|
|
138
172
|
## 已知限制
|
|
139
173
|
|
|
140
|
-
- Mermaid
|
|
174
|
+
- Mermaid 引擎来自随插件安装的本地依赖,离线可用;仅当依赖缺失时回退 CDN 拉取(宿主在进程生命周期内缓存)。
|
|
141
175
|
- 用量账本折叠自实时 `session/event` 记录;错过实时事件时可手动「扫描」重读今日会话日志。
|
|
142
176
|
- 费用按 DeepSeek 官方峰谷单价估算,仅供参考。
|
|
143
177
|
- 深色模式下背景限制是刻意设计:仅「无颜色」与「极光」可选。
|