@alexpeng/dsh-custom-plugin 0.1.6 → 0.4.1

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 CHANGED
@@ -4,6 +4,58 @@ All notable changes to this project are documented here. The format loosely
4
4
  follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
5
5
  follow [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## 0.4.1 — 2026-09-09
8
+
9
+ ### Fixed
10
+
11
+ - **Fresh installs show nothing after a "successful" install.** `keytar` (a
12
+ native optional dependency) tripped pnpm 11's strict build-script gate, so
13
+ `dsh plugin add` exited non-zero and the harness never reconciled the bundle
14
+ layer — the package sat inert in `dependencies` with no host half and no
15
+ browser half. `keytar` is no longer a dependency: the OS-keyring adapter
16
+ still detects a `keytar` module present in the profile's `node_modules`, and
17
+ users who want the OS keyring can add it themselves
18
+ (`dsh plugin --profile web add keytar`).
19
+ - The browser half now waits for the `slots` service (a child fiber) before
20
+ mounting its surfaces instead of reading it synchronously: newer dsh builds
21
+ activate the slots provider after this plugin's entry, and the synchronous
22
+ read lost that race every time, logging "slots service unavailable" and
23
+ skipping all UI. The mount stays fail-soft — the GUI boots even when the
24
+ service never appears.
25
+
26
+ ## 0.4.0 — 2026-09-03
27
+
28
+ ### Added
29
+
30
+ - 7 / 30 / 90-day usage trends, per-model summaries, CSV export, and local monthly CNY budget warnings.
31
+ - Versioned, secret-free state backup with previewed merge/replace import and automatic recovery copies.
32
+ - Editable, tagged, sortable favorite prompts with usage recency, `{{variable}}` templates, and JSON / Markdown portability.
33
+ - Indexed current-session search and a Ctrl/Cmd+K command palette backed by DSH's official search APIs.
34
+
35
+ ### Changed
36
+
37
+ - Batch archive skips running sessions and reports separate success and failure counts.
38
+ - Existing prompt and config documents are normalized for the new optional fields.
39
+
40
+ ### Fixed
41
+
42
+ - State-dependent routes now wait for the initial local state load; usage events
43
+ arriving during an import, edit, or usage scan are queued and persisted instead
44
+ of racing a stale snapshot.
45
+ - Backup imports reject malformed counters/configuration, honor imported folder
46
+ parents and sibling order, and keep the 5 MiB document boundary distinct from
47
+ the JSON request envelope.
48
+ - Search hits carry their session id and archive batches retain per-item errors;
49
+ stale cross-session clicks and swallowed archive failures now surface clearly.
50
+ - Malformed persisted peak counters, invalid calendar buckets, failed usage
51
+ rebuilds, and partial state edits are handled without presenting or keeping
52
+ a misleading snapshot; backup requests now validate their envelope fields.
53
+
54
+ ### Security
55
+
56
+ - Backups exclude API keys and credential metadata; imports preserve the active credential.
57
+ - Archive restore remains deferred until DSH exposes an official API.
58
+
7
59
  ## 0.1.6 — 2026-09-02
8
60
 
9
61
  ### Fixed
package/README.i18n.yaml CHANGED
@@ -1,7 +1,7 @@
1
- # Bilingual-pair consistency record: the git blob hash of each README as of
1
+ # Bilingual-pair consistency record: the git blob hash of each README as of
2
2
  # the last confirmed-consistent state. Both languages carry equal authority;
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: 8acfa513bc8a4ecdcd5b87334f719d81fe7287f8
7
- README.zh.md: 5ef3c4476fdf89af363a4c44995a99d6d6235a6d
6
+ README.md: eb2b863638b101a7b1a768233e687218ec913549
7
+ README.zh.md: ec3625b6ef3a95adc4ce9519a6cda7c775e51f97
package/README.md CHANGED
@@ -9,10 +9,14 @@
9
9
 
10
10
  English | [中文](README.zh.md)
11
11
 
12
- 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.
12
+ Custom convenience suite for the DeepSeek Harness (DSH) Web GUI: personalization, weather FX, glass effects, a per-user-message timeline rail, 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.
13
13
 
14
14
  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.
15
15
 
16
+ <p align="center">
17
+ <img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/overview.png" alt="dsh-custom-plugin overview" width="100%">
18
+ </p>
19
+
16
20
  ## Selected screenshots
17
21
 
18
22
  <table>
@@ -38,7 +42,7 @@ The plugin is dual-face: the host half (`src/`) owns the state document, registe
38
42
  </tr>
39
43
  </table>
40
44
 
41
- Weather FX is shown in dark mode, where only "no color" and "aurora" backgrounds are selectable.
45
+ Weather FX is shown in dark mode, where only "no color" and "aurora" backgrounds are selectable. 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.
42
46
 
43
47
  ## What it does
44
48
 
@@ -65,7 +69,7 @@ A multi-level folder tree persisted in the `$DSH_HOME` state file, shared across
65
69
 
66
70
  ### Prompts
67
71
 
68
- A prompt library with add / copy / delete, search, and a "Prompts" button in the session header for one-click insertion into the input box.
72
+ 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.
69
73
 
70
74
  ### Conversation export
71
75
 
@@ -77,6 +81,8 @@ Export the current session in three formats (file names carry a date stamp):
77
81
 
78
82
  Tool rows carry the tool name and an argument digest (resolved from the paired tool/call events).
79
83
 
84
+ 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.
85
+
80
86
  ### Mermaid
81
87
 
82
88
  ```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.
@@ -86,7 +92,10 @@ Tool rows carry the tool name and an argument digest (resolved from the paired t
86
92
  - **Quote reply**: select text in the conversation and a "quote reply" button inserts it as a blockquote into the input box;
87
93
  - **Anti auto-scroll**: force `scroll-behavior: auto` so sends never yank the view to the bottom (off by default);
88
94
  - **Formula copy**: LaTeX / MathML copy chips under matching messages (MathML pastes into Word);
89
- - **Batch archive**: select sessions and archive them in bulk with a confirmation guard (logs stay in storage).
95
+ - **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.
96
+ - **Session search**: search current-session user, assistant, and tool content through DSH's official index and jump to the containing turn; superseded requests are cancelled.
97
+ - **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.
98
+ - **Reliable archive**: running sessions are unavailable by default and batch completion reports separate success and failure counts.
90
99
 
91
100
  ### Balance and usage
92
101
 
@@ -97,6 +106,7 @@ A balance badge sits in the session header (clickable to pin); the balance panel
97
106
  - **Today's usage**: per-model input / output / cache token counters and call counts, folded live from `session/event` records.
98
107
  - **Cost estimate**: DeepSeek's current official peak/off-peak table — 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-v4-flash` / `deepseek-v4-flash-vision-exp` ¥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.
99
108
  - **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.
109
+ - **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.
100
110
 
101
111
  ### Settings entry
102
112
 
@@ -162,11 +172,13 @@ Appearance and feature toggles (the `cfg` field, all with defaults):
162
172
  | `antiScroll` | `false` | anti auto-scroll |
163
173
  | `mermaid` | `true` | automatic in-place Mermaid rendering (plus render chips) |
164
174
  | `formula` | `true` | LaTeX / MathML copy chips |
175
+ | `monthlyBudgetCny` | `0` | Monthly CNY budget; `0` disables warnings |
176
+ | `budgetWarningPercent` | `80` | Monthly warning threshold (1–100) |
165
177
 
166
178
  ## Security model
167
179
 
168
180
  - 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.
169
- - The browser never receives the saved DeepSeek API key. New panel keys use the optional OS credential store through `keytar`; older plaintext state keys are migrated on startup when that store is available.
181
+ - 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`.
170
182
  - 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.
171
183
  - Conversation exports and timeline data stay on the local host.
172
184
 
@@ -174,10 +186,11 @@ Appearance and feature toggles (the `cfg` field, all with defaults):
174
186
 
175
187
  - 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).
176
188
  - 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.
177
- - 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 estimated as off-peak until rescanned.
178
- - OS credential storage depends on the optional `keytar` backend; when it cannot be loaded, the compatibility state-file fallback is used.
189
+ - 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.
190
+ - 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.
179
191
  - Cost estimates use DeepSeek's official peak/off-peak list prices and are indicative only.
180
192
  - Dark-mode background restriction is deliberate: only "no color" and "aurora" are selectable in dark mode.
193
+ - DSH currently exposes no archive-restore API; the plugin does not bypass that boundary by editing the underlying registry.
181
194
 
182
195
  ## Development
183
196
 
package/README.zh.md CHANGED
@@ -9,10 +9,14 @@
9
9
 
10
10
  [English](README.md) | 中文
11
11
 
12
- DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天气特效、玻璃效果、按用户消息的时间线导航、项目文件夹、提示词库、会话导出、Mermaid 渲染、引用回复,以及 DeepSeek 额度与今日 token 用量。
12
+ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天气特效、玻璃效果、按用户消息的时间线导航、项目文件夹、增强提示词库、会话导出与会话搜索、Mermaid 渲染、引用回复、7/30/90 天用量分析、预算与无密钥本地备份,以及 Ctrl/Cmd+K 快捷面板。
13
13
 
14
14
  插件为双半区架构:宿主半区(`src/`)持有状态文档、注册 `/api/custom-plugin` 路由与 `custom_plugin_status` 智能体工具;浏览器半区(`src/client/`)通过 7 个官方 slot 的 8 处注入挂载 UI,以同源 fetch 与宿主通信。经官方 profile 机制挂载,不改 DSH 源码。
15
15
 
16
+ <p align="center">
17
+ <img src="https://github.com/AlexPeng07/dsh-custom-plugin/raw/main/docs/overview.png" alt="dsh-custom-plugin 总览" width="100%">
18
+ </p>
19
+
16
20
  ## 部分界面展示
17
21
 
18
22
  <table>
@@ -38,7 +42,7 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
38
42
  </tr>
39
43
  </table>
40
44
 
41
- 天气特效截自深色模式(深色下仅「无颜色」与「极光」背景可选)。
45
+ 天气特效截自深色模式(深色下仅「无颜色」与「极光」背景可选)。额度历史、备份导入预览、会话搜索与快捷面板属于同一套动态面板,需在 DSH 内打开对应页查看;仓库未另附固定截图。
42
46
 
43
47
  ## 功能
44
48
 
@@ -65,7 +69,7 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
65
69
 
66
70
  ### 提示词库
67
71
 
68
- 提示词支持新增 / 复制 / 删除 / 搜索;会话顶部的「提示词」按钮一键把提示词插入输入框。
72
+ 提示词支持新增、编辑、复制、删除、搜索、收藏、标签和拖拽排序,并记录最近使用与使用次数。正文可使用 `{{变量名}}`;插入前会弹出变量表单。提示词库可用版本化 JSON 或以二级标题分段的 Markdown 导入导出。
69
73
 
70
74
  ### 会话导出
71
75
 
@@ -77,6 +81,8 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
77
81
 
78
82
  工具调用行携带工具名与参数摘要(从配对的 tool/call 事件解析)。
79
83
 
84
+ 插件状态可导出为版本化 JSON 备份,包含外观、文件夹、提示词、星标、用量和预算,不包含 API Key 或凭据元数据。导入前显示冲突预览,支持合并或覆盖非敏感状态,并自动保留恢复副本。
85
+
80
86
  ### Mermaid 渲染
81
87
 
82
88
  聊天中的 ```mermaid 代码块(含助手回复,思维导图 / 流程图 / 时序图等)自动就地渲染为图表:代码块上方出现「图表 / 代码」切换工具条与 mermaid.live 兜底链接,流式输出期间内容完整后即预览,跟随 GUI 明暗主题重绘,渲染失败时保留原代码。检测依据代码块语言标签;无标签(流式中)时按内容启发式判断(关键字前缀 + 完整度检查,语言明确的代码块不会误触)。引擎优先读取随插件安装的本地 Mermaid 11 依赖(离线可用),缺失时回退 jsdelivr / fastly / unpkg 三镜像拉取并在宿主进程内缓存;用户消息下方的渲染按钮与模态窗口(多图切换)保持不变,mermaid.live 链接为 DEFLATE 压缩的 `#pako:` 格式,打开即还原图表。
@@ -86,7 +92,10 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
86
92
  - **引用回复**:选中对话文本后出现「引用回复」按钮,以引用块插入输入框;
87
93
  - **防自动跳转**:强制 `scroll-behavior: auto`,发送消息不再把视图拽到底部(默认关闭);
88
94
  - **公式复制**:含公式的消息下方显示 LaTeX / MathML 复制按钮(MathML 可直接粘贴进 Word);
89
- - **批量归档**:勾选多个会话批量归档,带确认守卫(日志仍保留在存储中)。
95
+ - **批量归档**:勾选多个会话批量归档,运行中会话默认不可选,并分别报告成功与失败数量;DSH 尚未公开恢复接口,插件不提供恢复入口。
96
+ - **会话搜索**:通过 DSH 官方索引搜索当前会话的用户、助手和工具内容,点击结果跳转到所属轮次。
97
+ - **快捷面板**:在非编辑状态按 `Ctrl+K` / `Cmd+K`,统一搜索会话、工作区、提示词和常用功能。
98
+ - **可靠归档**:运行中的会话默认不可选,批量操作分别报告成功与失败数量。
90
99
 
91
100
  ### 额度与用量
92
101
 
@@ -97,6 +106,7 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
97
106
  - **今日用量**:按模型统计输入 / 输出 / 缓存 token 与调用次数,实时折叠自 `session/event` 事件。
98
107
  - **费用估算**:按 DeepSeek 当前官方峰谷价目估算——高峰为北京时间周一至周五 9–12、14–18 时;其余时间(含周末)均为空闲时段,按半价计:`deepseek-v4-flash` / `deepseek-v4-flash-vision-exp` ¥3 / ¥9,`deepseek-v4-pro` ¥9 / ¥27(每百万 tokens 输入 / 输出,缓存写入 ¥0.1 / ¥0.3;已停用的 `deepseek-chat` / `deepseek-reasoner` 按 v4-flash 计),仅供参考。
99
108
  - **扫描**:「扫描今日会话日志」重放全部会话、按事件自身时间戳归入今日(跨午夜会话不丢量),完成后显示扫描到的活跃会话数。
109
+ - **历史与预算**:查看 7 / 30 / 90 天趋势和按模型汇总,导出 UTF-8 CSV;可设置人民币月预算与预警比例。
100
110
 
101
111
  ### 设置入口
102
112
 
@@ -162,11 +172,13 @@ dsh plugin --profile web add link:F:/dsh-plugin-dev
162
172
  | `antiScroll` | `false` | 防自动跳底 |
163
173
  | `mermaid` | `true` | Mermaid 图表自动就地渲染(含消息下方渲染按钮) |
164
174
  | `formula` | `true` | LaTeX / MathML 复制按钮 |
175
+ | `monthlyBudgetCny` | `0` | 人民币月预算;`0` 表示关闭提醒 |
176
+ | `budgetWarningPercent` | `80` | 月预算预警百分比(1–100) |
165
177
 
166
178
  ## 安全模型
167
179
 
168
180
  - 浏览器仅通过回环地址上的 `/api/custom-plugin` 路由与宿主通信;每条路由同时校验回环 socket 地址、回环 Host 头与浏览器同源标记(`sec-fetch-site` / `Origin`),`X-Forwarded-For` 永不信任。
169
- - 浏览器永远不会收到已保存的 DeepSeek API Key。面板新输入的 Key 优先通过可选的 `keytar` 写入系统凭据存储;旧版状态文件中的明文 Key 会在系统存储可用时启动迁移。
181
+ - 浏览器永远不会收到已保存的 DeepSeek API Key。面板新输入的 Key 在 `keytar` 存在时优先写入系统凭据存储;旧版状态文件中的明文 Key 会在系统存储可用时启动迁移。`keytar` 不再作为本插件的依赖发布(原生模块会触发 pnpm 11 的严格构建门禁,导致整个插件包安装后无法激活);需要系统钥匙串的用户可自行加入 profile:`dsh plugin --profile web add keytar`。
170
182
  - 如果系统凭据存储不可用,插件会兼容回退到 `$DSH_HOME/custom-plugin-state.json`;请相应保护 `$DSH_HOME` 目录。DSH 自身的 `$DSH_HOME/.credentials.yaml` 明文凭据仍可复用。
171
183
  - 会话导出与时间线数据全部停留在本机。
172
184
 
@@ -174,10 +186,11 @@ dsh plugin --profile web add link:F:/dsh-plugin-dev
174
186
 
175
187
  - Mermaid 引擎来自随插件安装的本地依赖,离线可用;仅当依赖缺失时回退 CDN 拉取(宿主在进程生命周期内缓存)。
176
188
  - 用量账本折叠自实时 `session/event` 记录,只保留最近 90 个北京时间日;错过实时事件时可手动「扫描」,扫描最多并发读取 4 个会话日志。
177
- - 额度面板会显示峰/闲 token 与费用分布,并提供官方价目链接;没有峰时字段的历史行会先按闲时估算,重新扫描后可更新。
178
- - 系统凭据存储依赖可选的 `keytar` 后端;无法加载时使用兼容的状态文件回退。
189
+ - 额度面板会显示峰/闲 token 与费用分布,并提供官方价目链接;没有峰时字段的历史行会标记为“不精确”,不计入费用总额,重新扫描后可更新。
190
+ - 系统凭据存储会在宿主启动时检测 profile `node_modules` 中的 `keytar` 模块;无法加载时使用兼容的状态文件回退。
179
191
  - 费用按 DeepSeek 官方峰谷单价估算,仅供参考。
180
192
  - 深色模式下背景限制是刻意设计:仅「无颜色」与「极光」可选。
193
+ - DSH 当前没有公开的归档恢复接口;插件不会绕过官方边界修改底层注册表。
181
194
 
182
195
  ## 开发
183
196