@alexpeng/dsh-custom-plugin 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ # Bilingual-pair consistency record: the git blob hash of each README as of
2
+ # the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record the hashes:
4
+ # git hash-object --path README.md README.md
5
+ # git hash-object --path README.zh.md README.zh.md
6
+ README.md: 28399b52bad61a07d8a943751972d5dc202320ec
7
+ README.zh.md: 833a310d825c35941114181fda189aca2d034a4b
package/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # dsh-custom-plugin
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ 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
+
7
+ 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 nine official slots and talks to the host over same-origin fetch. Mounted through the official profile mechanism — no DSH source changes.
8
+
9
+ ## What it does
10
+
11
+ ### Appearance
12
+
13
+ - **Background colors**: 20 muted low-saturation palettes (each with a matching tab color, `天青灰` by default) plus "no color" (follows the GUI default theme) and the high-saturation aurora gradient. In dark mode only "no color" and "aurora" stay selectable; the other colors are disabled and the plugin text turns white for readability.
14
+ - **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.
15
+ - **Glass**: frosted glass on every Custom surface, or liquid glass (Chromium displacement refraction, no chromatic dispersion, slight backdrop blur; Safari/Firefox fall back to frosted). A global-glass option applies backdrop blur to dialogs, menus, tooltips and listboxes.
16
+
17
+ ### Timeline navigation
18
+
19
+ Every direct user message gets a node on a right-side (or left-side) rail:
20
+
21
+ - hover for a preview popover (overflow-aware positioning) with LaTeX / MathML / Mermaid markers rendered inline;
22
+ - click to jump to that message (the chat scrollport is driven directly, so rows inside nested scrollers still land centered);
23
+ - drag the thumb or wheel over the rail to scroll (the rail replaces the native scrollbar);
24
+ - nodes can be starred (and the rail can show only starred ones), forked into a new session at that message, or copied in full.
25
+
26
+ Nodes are sourced from the rendered user-message rows (DOM positioning) and refresh automatically after history loads; the rail keeps up to 400 tail nodes.
27
+
28
+ ### Project folders
29
+
30
+ 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.
31
+
32
+ ### Prompts
33
+
34
+ A prompt library with add / copy / delete, search, and a "Prompts" button in the session header for one-click insertion into the input box.
35
+
36
+ ### Conversation export
37
+
38
+ Export the current session in three formats (file names carry a date stamp):
39
+
40
+ - **JSON**: standard `messages` structure (user / assistant / tool), with a meta block carrying the session title, creation time, working directory and export time — importable elsewhere;
41
+ - **Markdown**: role-sectioned plain text;
42
+ - **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).
43
+
44
+ Tool rows carry the tool name and an argument digest (resolved from the paired tool/call events).
45
+
46
+ ### Mermaid
47
+
48
+ When a message contains a ```mermaid block, a render chip appears under it; the modal renders the diagram with the host-fetched Mermaid 11 engine (jsdelivr / fastly / unpkg mirror fallback, cached for the host process lifetime, preloadable from the Mermaid tab), plus a mermaid.live fallback link (DEFLATE-compressed `#pako:` format that restores the diagram on open).
49
+
50
+ ### Efficiency tools
51
+
52
+ - **Quote reply**: select text in the conversation and a "quote reply" button inserts it as a blockquote into the input box;
53
+ - **Anti auto-scroll**: force `scroll-behavior: auto` so sends never yank the view to the bottom (off by default);
54
+ - **Formula copy**: LaTeX / MathML copy chips under matching messages (MathML pastes into Word);
55
+ - **Batch archive**: select sessions and archive them in bulk with a confirmation guard (logs stay in storage).
56
+
57
+ ### Balance and usage
58
+
59
+ A balance badge sits in the session header (clickable to pin); the balance panel provides:
60
+
61
+ - **Balance**: the official `https://api.deepseek.com/user/balance` endpoint, CNY preferred, granted and topped-up balances listed separately, with the account availability flag.
62
+ - **Key resolution order**: pasted in the panel (stored only in the local state file) → environment variables `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN` → the DSH credentials file `$DSH_HOME/.credentials.yaml` (reuses the DeepSeek key already configured in DSH — no duplicate setup).
63
+ - **Today's usage**: per-model input / output / cache token counters and call counts, folded live from `session/event` records.
64
+ - **Cost estimate**: DeepSeek's official peak/off-peak table (effective 2026-08-17) — peak hours (Beijing 09:00–12:00 / 14:00–18:00) at full price, off-peak at half: `deepseek-v4-flash` ¥3 / ¥9, `deepseek-v4-pro` ¥9 / ¥27 (CNY per 1M tokens in / out, cache writes ¥0.1 / ¥0.3; the retired `deepseek-chat` / `deepseek-reasoner` price as v4-flash). Indicative only.
65
+ - **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.
66
+
67
+ ### Settings entry
68
+
69
+ 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.
70
+
71
+ ### Agent integration
72
+
73
+ 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.
74
+
75
+ ## Install
76
+
77
+ 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).
78
+
79
+ ### From npm
80
+
81
+ ```sh
82
+ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
83
+ # restart dsh web
84
+ ```
85
+
86
+ The registry tarball ships prebuilt output — no source build on the installing machine.
87
+
88
+ ### Local link (development)
89
+
90
+ ```sh
91
+ # build (run from this repo root)
92
+ pnpm install
93
+ pnpm build
94
+ # add to the web profile. The link path must not contain spaces: on Windows,
95
+ # create a space-free directory junction first and link to the junction path
96
+ dsh plugin --profile web add link:F:/dsh-plugin-dev
97
+ # restart dsh web
98
+ ```
99
+
100
+ 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.
101
+
102
+ ## Config
103
+
104
+ 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, the API key, and the per-day usage ledger. Writes are atomic (temp file + rename), so a crash never truncates the document.
105
+
106
+ Appearance and feature toggles (the `cfg` field, all with defaults):
107
+
108
+ | Key | Default | Meaning |
109
+ |---|---|---|
110
+ | `bg` | `天青灰` | `default` (no color) / `aurora` / one of the 20 palette names |
111
+ | `weather` | `none` | `none` / `snow` / `rain` / `sakura` |
112
+ | `glass` | `true` | master glass toggle for Custom surfaces |
113
+ | `glassMode` | `frost` | `frost` frosted / `liquid` displacement glass |
114
+ | `globalGlass` | `true` | blur global overlays (dialogs/menus/tooltips) |
115
+ | `timeline` | `true` | timeline rail toggle |
116
+ | `timelineLeft` | `false` | rail on the left |
117
+ | `starsOnly` | `false` | show only starred nodes |
118
+ | `quote` | `true` | selection quote reply |
119
+ | `antiScroll` | `false` | anti auto-scroll |
120
+ | `mermaid` | `true` | Mermaid render chips |
121
+ | `formula` | `true` | LaTeX / MathML copy chips |
122
+
123
+ ## Security model
124
+
125
+ - 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.
126
+ - 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.
127
+ - Conversation exports and timeline data stay on the local host.
128
+
129
+ ## Known limitations
130
+
131
+ - Mermaid rendering needs a reachable CDN on first use (the host caches the engine for its lifetime).
132
+ - 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.
133
+ - Cost estimates use DeepSeek's official peak/off-peak list prices and are indicative only.
134
+ - Dark-mode background restriction is deliberate: only "no color" and "aurora" are selectable in dark mode.
135
+
136
+ ## Development
137
+
138
+ ```sh
139
+ pnpm typecheck # type check
140
+ pnpm test # vitest unit tests
141
+ pnpm build # build the node ESM library and the browser bundle into lib/
142
+ ```
143
+
144
+ ## License
145
+
146
+ 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).
package/README.zh.md ADDED
@@ -0,0 +1,146 @@
1
+ # dsh-custom-plugin
2
+
3
+ [English](README.md) | 中文
4
+
5
+ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天气特效、玻璃效果、按用户消息的时间线导航、项目文件夹、提示词库、会话导出、Mermaid 渲染、引用回复,以及 DeepSeek 额度与今日 token 用量。
6
+
7
+ 插件为双半区架构:宿主半区(`src/`)持有状态文档、注册 `/api/custom-plugin` 路由与 `custom_plugin_status` 智能体工具;浏览器半区(`src/client/`)通过 9 个官方 slot 注入 UI,以同源 fetch 与宿主通信。经官方 profile 机制挂载,不改 DSH 源码。
8
+
9
+ ## 功能
10
+
11
+ ### 外观个性化
12
+
13
+ - **背景颜色**:20 组低饱和典雅色(每组合配 tab 栏色,默认「天青灰」),另有「无颜色」(跟随 GUI 默认主题)与高饱和「极光」渐变。深色模式下仅「无颜色」与「极光」可选,其余颜色禁用,插件文字自动转白保证可读性。
14
+ - **天气特效**:画布渲染、不挡交互,一键切换——飘雪、电影感雨滴(三层景深 + 地面溅起)、樱花飘落;关闭时自动清空画布。
15
+ - **玻璃效果**:所有 Custom 面板默认毛玻璃;可切换液态玻璃(Chromium 位移折射,无色散、轻微背景模糊;Safari/Firefox 自动回退毛玻璃)。「全局浮层玻璃」对弹窗、菜单、提示框、下拉框统一加模糊。
16
+
17
+ ### 时间线导航
18
+
19
+ 每条用户消息在右侧(或左侧)轨道生成一个节点:
20
+
21
+ - 悬停弹出预览卡(自动防溢出定位),卡内直接显示 LaTeX / MathML / Mermaid 标记;
22
+ - 点击跳转到对应消息(直接驱动聊天滚动容器,消息位于嵌套滚动区时也能居中);
23
+ - 拖动滑块或在轨道上滚轮滚动(轨道替代原生滚动条);
24
+ - 节点支持星标(可只显示星标)、在该消息处创建分支会话、一键复制全文。
25
+
26
+ 节点按渲染出的用户消息行定位(DOM 行 sourcing),加载历史后自动刷新;轨道尾部最多保留 400 个节点。
27
+
28
+ ### 项目文件夹
29
+
30
+ 多级文件夹树,保存在 `$DSH_HOME` 状态文件中,跨工作区共享。任意工作区与会话都可收纳进文件夹;支持拖拽排序(插入前 / 内部 / 插入后)、重命名、删除与「添加当前会话」。
31
+
32
+ ### 提示词库
33
+
34
+ 提示词支持新增 / 复制 / 删除 / 搜索;会话顶部的「提示词」按钮一键把提示词插入输入框。
35
+
36
+ ### 会话导出
37
+
38
+ 导出当前会话为三种格式(文件名带日期戳):
39
+
40
+ - **JSON**:标准 `messages` 结构(user / assistant / tool),meta 携带会话标题、创建时间、工作目录与导出时间,可导入其他工具;
41
+ - **Markdown**:按角色分块的纯文本;
42
+ - **PDF**:A4 打印版式 HTML,浏览器打开后打印另存为 PDF;图片以 base64 内嵌(最多 30 张、总量 12 MB、单张 ≤ 4 MB)。
43
+
44
+ 工具调用行携带工具名与参数摘要(从配对的 tool/call 事件解析)。
45
+
46
+ ### Mermaid 渲染
47
+
48
+ 消息中出现 ```mermaid 代码块时,下方显示渲染按钮:模态窗口内用宿主拉取的 Mermaid 11 引擎渲染(jsdelivr / fastly / unpkg 三镜像回退,引擎在宿主进程内缓存,可在 Mermaid 页预加载);另附 mermaid.live 兜底链接(DEFLATE 压缩的 `#pako:` 格式,打开即还原图表)。
49
+
50
+ ### 效率工具
51
+
52
+ - **引用回复**:选中对话文本后出现「引用回复」按钮,以引用块插入输入框;
53
+ - **防自动跳转**:强制 `scroll-behavior: auto`,发送消息不再把视图拽到底部(默认关闭);
54
+ - **公式复制**:含公式的消息下方显示 LaTeX / MathML 复制按钮(MathML 可直接粘贴进 Word);
55
+ - **批量归档**:勾选多个会话批量归档,带确认守卫(日志仍保留在存储中)。
56
+
57
+ ### 额度与用量
58
+
59
+ 会话头部常驻额度徽标(可点击固定),额度面板提供:
60
+
61
+ - **余额**:调用官方 `https://api.deepseek.com/user/balance` 接口,优先显示 CNY,赠送与充值余额分列,并显示账户可用状态。
62
+ - **Key 解析顺序**:面板粘贴(仅存本机状态文件)→ 环境变量 `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN` → DSH 凭据文件 `$DSH_HOME/.credentials.yaml`(自动复用 DSH 已配置的 DeepSeek key,无需重复填写)。
63
+ - **今日用量**:按模型统计输入 / 输出 / 缓存 token 与调用次数,实时折叠自 `session/event` 事件。
64
+ - **费用估算**:按 DeepSeek 官方峰谷价目(2026-08-17 生效)估算——高峰时段(北京时间 9–12 / 14–18 时)全价,空闲时段半价:`deepseek-v4-flash` ¥3 / ¥9,`deepseek-v4-pro` ¥9 / ¥27(每百万 tokens 输入 / 输出,缓存写入 ¥0.1 / ¥0.3;已停用的 `deepseek-chat` / `deepseek-reasoner` 按 v4-flash 计),仅供参考。
65
+ - **扫描**:「扫描今日会话日志」重放全部会话、按事件自身时间戳归入今日(跨午夜会话不丢量),完成后显示扫描到的活跃会话数。
66
+
67
+ ### 设置入口
68
+
69
+ 「设置 > 个性化」页提供外观与工具开关的整页配置;会话头部与侧边栏底部的「个性化」按钮打开同一套面板弹框。
70
+
71
+ ### 智能体集成
72
+
73
+ `custom_plugin_status` 工具报告:外观配置、今日按模型用量、余额、时间线样本、Mermaid 引擎加载情况、状态文件路径与客户端诊断。插件不注入任何系统提示。
74
+
75
+ ## 安装
76
+
77
+ 前置:Node 22+、pnpm,以及 `dsh` CLI(官方 npm 包 `@deepseek-ai/dsh`;未全局安装时,可用 `npx @deepseek-ai/dsh` 代替 `dsh`)。
78
+
79
+ ### 从 npm 安装
80
+
81
+ ```sh
82
+ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
83
+ # 重启 dsh web
84
+ ```
85
+
86
+ registry 上是预构建产物,安装端无需从源码构建。
87
+
88
+ ### 本地链接(开发)
89
+
90
+ ```sh
91
+ # 构建(本仓库根目录执行)
92
+ pnpm install
93
+ pnpm build
94
+ # 装入 web profile。链接路径不能含空格:Windows 上若源码路径含空格,
95
+ # 先创建无空格目录联接(如 F:\dsh-plugin-dev),再链接到联接路径
96
+ dsh plugin --profile web add link:F:/dsh-plugin-dev
97
+ # 重启 dsh web
98
+ ```
99
+
100
+ 包按官方组合包协议声明 manifest:`package.json` 的 `dsh.bundle.patch` 指向 `cordis.patch.yml` 配置层(行 id `custom-plugin`),`dsh.client` 声明浏览器半区。`dsh plugin add` 在 profile 目录内转发给 pnpm,安装后因该声明被自动加入 `dsh.profile.bundles`;浏览器半区经官方客户端模块系统按同一行加载。
101
+
102
+ ## 配置
103
+
104
+ 插件读写 `$DSH_HOME/custom-plugin-state.json` 单个 JSON 文档(默认 `~/.dsh`,可用 `DSH_HOME` 环境变量覆盖),包含外观配置、文件夹、提示词、星标、API Key 与按日用量账本;写入为原子写(临时文件 + 重命名),崩溃不会截断文档。
105
+
106
+ 外观与功能开关(`cfg` 字段,均有默认值):
107
+
108
+ | 配置项 | 默认值 | 说明 |
109
+ |---|---|---|
110
+ | `bg` | `天青灰` | `default`(无颜色)/ `aurora`(极光)/ 20 组调色板名之一 |
111
+ | `weather` | `none` | `none` / `snow` / `rain` / `sakura` |
112
+ | `glass` | `true` | Custom 面板玻璃总开关 |
113
+ | `glassMode` | `frost` | `frost` 毛玻璃 / `liquid` 液态玻璃 |
114
+ | `globalGlass` | `true` | 全局浮层(弹窗/菜单/提示)加模糊 |
115
+ | `timeline` | `true` | 时间线轨道开关 |
116
+ | `timelineLeft` | `false` | 轨道放左侧 |
117
+ | `starsOnly` | `false` | 只显示星标节点 |
118
+ | `quote` | `true` | 划词引用回复 |
119
+ | `antiScroll` | `false` | 防自动跳底 |
120
+ | `mermaid` | `true` | Mermaid 渲染按钮 |
121
+ | `formula` | `true` | LaTeX / MathML 复制按钮 |
122
+
123
+ ## 安全模型
124
+
125
+ - 浏览器仅通过回环地址上的 `/api/custom-plugin` 路由与宿主通信;每条路由同时校验回环 socket 地址、回环 Host 头与浏览器同源标记(`sec-fetch-site` / `Origin`),`X-Forwarded-For` 永不信任。
126
+ - DeepSeek API Key 只保存在本机状态文件(或沿用 DSH 自身凭据),仅用于调用 DeepSeek 官方余额接口。
127
+ - 会话导出与时间线数据全部停留在本机。
128
+
129
+ ## 已知限制
130
+
131
+ - Mermaid 首次渲染需要能访问 CDN(宿主在进程生命周期内缓存引擎)。
132
+ - 用量账本折叠自实时 `session/event` 记录;错过实时事件时可手动「扫描」重读今日会话日志。
133
+ - 费用按 DeepSeek 官方峰谷单价估算,仅供参考。
134
+ - 深色模式下背景限制是刻意设计:仅「无颜色」与「极光」可选。
135
+
136
+ ## 开发
137
+
138
+ ```sh
139
+ pnpm typecheck # 类型检查
140
+ pnpm test # vitest 单元测试
141
+ pnpm build # 构建 node ESM 库与浏览器 bundle 到 lib/
142
+ ```
143
+
144
+ ## 许可证
145
+
146
+ Apache-2.0。部分代码参考 [Nagi-ovo/voyager](https://github.com/Nagi-ovo/voyager) 与 [unovue/inspira-ui](https://github.com/unovue/inspira-ui)。
@@ -0,0 +1,13 @@
1
+ # dsh-custom-plugin bundle patch: inserts the dual-face plugin row into the web
2
+ # profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
3
+ # manifest field) over dsh-base; activate with
4
+ # `dsh plugin --profile <name> add link:~/code/dsh-custom-plugin`.
5
+ #
6
+ # The row is a bare plugin by package name: the node half (exports ".") runs
7
+ # in the host process (state store, /api/custom-plugin routes, the
8
+ # custom_plugin_status agent tool), and the `dsh.client` declaration in
9
+ # package.json makes the browser half (exports "./client", served at
10
+ # /plugins/custom-plugin/client.js) load in the web GUI.
11
+ - insert:
12
+ - id: custom-plugin
13
+ name: '@alexpeng/dsh-custom-plugin'