@surfishs/dsh-prompt-enhance 0.1.2 → 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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![npm](https://img.shields.io/npm/v/@surfishs/dsh-prompt-enhance.svg)](https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance)
5
5
  [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](./LICENSE)
6
6
 
7
- **DeepSeek Harness Web GUI 的「提示词增强」插件** —— 一键把输入框草稿改写为结构化提示词(角色与目标、可执行步骤、输出格式、验收标准、边界条件)。原文保留,失败不改草稿。
7
+ **DeepSeek Harness Web GUI 的「提示词增强」插件** —— 一键把输入框草稿改写为结构化提示词:角色与目标、上下文与约束、可执行步骤、输出格式、验收标准、边界条件。以原文为准,不改变原意、不凭空编造需求;信息不足时留占位,草稿不会被改动。
8
8
 
9
9
  简体中文 | [English](./README.en.md)
10
10
 
@@ -14,43 +14,50 @@
14
14
 
15
15
  ## 为什么需要它
16
16
 
17
- 写提示词最费劲的往往不是想法,而是补成适合模型执行的样子:角色(助手扮演谁)、交付物(最终交付什么)、输出格式(结构、语言、长度与风格)、合格标准(怎样判断结果正确)。
17
+ 好的提示词会讲清四件事:让模型扮演谁、交付什么、以什么格式、怎样算合格——多数草稿没写这些。
18
18
 
19
- 本插件在输入框加入「提示词增强」按钮,点击即调用 harness LLM 服务生成规范提示词。
19
+ 插件在输入框工具栏加了一个「提示词增强」按钮:点一下,草稿就会交给 DSH 的模型服务,按上面那四件事改写成结构化提示词。
20
20
 
21
- 增强结果展示在对话框上方且不遮挡对话;不直接替换原文,可回填、复制、重新生成或撤销,原文安全。
21
+ 结果出现在输入框上方的停靠卡里,不遮挡对话;草稿不会被直接替换——你可以回填、复制、重新生成或撤销,原文随时可恢复。
22
22
 
23
- 开启上下文感知后参照最近几轮对话消解指代,自主理解任务需求。
23
+ 开启上下文感知后,插件会把最近几轮你和助手的对话提供给模型参考,帮助它理解指代与任务背景(比如「它」「这个」指什么、草稿省略了哪些前提),让改写更贴近你原本的意思。统计只计入你本人发送的消息与助手回复,DSH 注入的环境、技能、时间等说明不算对话轮次。可在设置页或右键快捷卡里随时关闭。
24
+
25
+ > **注意**:它只参考最近几轮对话。如果草稿依赖的话题已经不在最近几轮里,请把必要背景补进草稿,否则改写可能偏离你的原意。
24
26
 
25
27
  ## 功能一览
26
28
 
27
29
  | 功能 | 说明 |
28
30
  |---|---|
29
- | 🐋 **一键增强** | 输入框工具栏按钮(左上角带星芒的 DeepSeek 鲸鱼标识);快捷键默认关闭,可在设置中指定 |
30
- | 🖼️ **停靠结果卡** | 结果显示在输入框上方,不遮挡对话;附模型、耗时与 `token` 用量,超限时提示结果可能不完整 |
31
- | ↩️ **回填、复制与撤销** | 回填后可直接撤销;关闭卡片后,输入框上方仍保留撤销条 |
32
- | 🔄 **重新生成** | 按当前输入框内容再请求一版;回填后也可对增强稿继续生成 |
31
+ | 🐋 **一键增强** | 输入框工具栏按钮(带星芒的 DeepSeek 鲸鱼标识);快捷键默认关闭,可在设置中指定 |
32
+ | 🎛️ **右键快捷设置** | 右键或长按输入框按钮打开小卡片:切换推理等级(点进去选档位)与上下文感知;模型行只读,显示固定路由或「跟随会话」;不用打开设置页即可调整 |
33
+ | 🖼️ **停靠结果卡** | 结果显示在输入框上方,不遮挡对话;附模型、推理档位、耗时与 `token` 用量;可折叠为标题与底部按钮,长结果不占满屏幕;超限时提示结果可能不完整 |
34
+ | ↩️ **回填、复制与撤销** | 结果可直接复制;回填后卡片默认自动折叠为标题行,底部按钮变为「撤销」,点击即可恢复原文并展开结果卡 |
35
+ | 🔄 **重新生成** | 按当前输入框内容再请求一版;回填后的增强稿也可继续生成 |
33
36
  | 💬 **`/enhance` 命令** | 斜杠面板直接改写任意文本;结果不进入模型历史 |
34
37
  | 🧭 **模型路由** | 设置中同时指定 `provider` 与 `model` 时优先;否则依次跟随当前会话模型、全局默认模型 |
35
- | 🧩 **上下文感知** | `contextAware` 开启时参考最近几轮对话补全「它 / 这个」这类指代,可随时关闭 |
36
- | 🔑 **零凭据配置** | 调用走 harness LLM 服务,密钥来自 harness 凭据存储;插件不读取也不保存 |
37
- | 🛡️ **草稿安全** | 空输入、仅附件、超长、含命令或文件引用都在本地拦截,不发请求;上游失败映射为可读提示;失败绝不改动草稿 |
38
- | ⚙️ **配置热生效** | 字段改完自动保存,常用项在前、其余收进「高级设置」;改动对下一次调用立即生效,无需重启 |
38
+ | 🧩 **上下文感知** | `contextAware` 开启时参考最近几轮对话补全「它 / 这个」这类指代(DSH 注入的环境/技能/时间等消息不计入),可随时关闭 |
39
+ | 🔑 **零凭据配置** | 调用走 DSH 的模型服务,密钥来自 DSH 凭据存储;插件不读取也不保存 |
40
+ | 🛡️ **草稿安全** | 空输入、仅附件、超长、含命令或文件引用都在本地拦截;上游失败给出可读提示,且不改动草稿 |
41
+ | ⚙️ **配置热生效** | 字段改完自动保存,常用项在前、其余收进「高级设置」;下一次调用立即生效 |
39
42
 
40
43
  ## 环境要求
41
44
 
42
45
  | 项目 | 要求 |
43
46
  |---|---|
44
- | dsh | `>= 0.1.1-rc.2 < 0.3.0`,已在 `0.2.2-rc.3` 验证 |
45
- | Node(仅源码构建) | `^22.19.0 \|\| >=24.0.0` |
47
+ | DSH | `>= 0.1.1-rc.2 < 0.3.0`,已在 `0.2.2-rc.3` 验证 |
48
+ | Node(仅从源码构建时需要) | `^22.19.0 \|\| >=24.0.0` |
49
+
50
+ 超出该范围的 DSH 版本未经验证,可能无法加载或工作异常。
46
51
 
47
52
  ## 安装
48
53
 
49
- 装之前请确认包名。npm 上的 `dsh-prompt-enhance`(无 scope)是上游原项目,本插件是它的重写分支,包名是 `@surfishs/dsh-prompt-enhance`。本插件的安装源是本仓库 `surfishs/dsh-prompt-enhance`。**不要**执行 `dsh plugin add dsh-prompt-enhance`。
54
+ 安装前请先确认包名:npm 上的 `dsh-prompt-enhance`(无 scope)是上游原项目,本插件是它的重写版,包名是 `@surfishs/dsh-prompt-enhance`。安装时请使用本仓库 `surfishs/dsh-prompt-enhance`。**不要**执行 `dsh plugin add dsh-prompt-enhance`。
55
+
56
+ DSH 桌面版与 Web 版使用同一个插件包,安装方式相同,只是 profile 名不同:桌面版通常是 `desktop`,Web 版通常是 `web`。把下方命令里的 `<profile>` 换成你的 profile 名。
50
57
 
51
58
  ### 让 Agent 帮你安装
52
59
 
53
- 不用自己敲命令。把下面整段发给能操作本机终端的 Agent(DSH 桌面版、Web 版都可以):
60
+ 不用自己敲命令。把下面整段发给能操作本机终端的 Agent(DSH 桌面版或 Web 版均可):
54
61
 
55
62
  ```text
56
63
  帮我安装 DeepSeek Harness 插件 @surfishs/dsh-prompt-enhance。
@@ -69,9 +76,7 @@ dsh plugin --profile <profile> add @surfishs/dsh-prompt-enhance
69
76
  # 重启 dsh
70
77
  ```
71
78
 
72
- > `<profile>` 换成你的 profile 名:桌面版通常是 `desktop`,Web 版通常是 `web`。
73
-
74
- 从 GitHub 安装(`lib/` 已随仓库提交,无需本地构建):
79
+ 从 GitHub 安装(`lib/` 已提交到仓库,无需在本地构建):
75
80
 
76
81
  ```bash
77
82
  dsh plugin --profile <profile> add github:surfishs/dsh-prompt-enhance
@@ -95,16 +100,20 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
95
100
 
96
101
  1. **开始**:在输入框写下草稿,点工具栏的增强按钮(或你设置的快捷键)。
97
102
  2. **查看结果**:结果出现在输入框上方的停靠卡里,可以:
98
- - **回填**:写回输入框,卡片保持打开并显示「已替换」;
103
+ - **回填**:写回输入框,卡片默认自动折叠为标题行,底部按钮变为「撤销」;
99
104
  - **复制**:复制结果;
100
105
  - **重新生成**:按当前输入再生成一版。
101
- 3. **撤销**:回填后点「撤销」恢复;关闭卡片后,输入框上方仍保留撤销条。
106
+ 3. **撤销**:点卡片底部的「撤销」恢复原文,同时展开结果卡。
102
107
  4. **关闭**:发送消息时卡片自动收起,按 `Esc` 也可以关闭。
103
108
 
104
- 输入为空或只有附件时,按钮会变灰、不可点;超长或含命令或文件引用会被本地拒绝。输出达到 Token 上限时,会提示结果可能不完整。
109
+ 右键或长按工具栏的增强按钮,可打开快捷设置卡:推理等级点进去选档位,上下文感知可直接开关;模型行只读,显示固定的 provider/model 或「跟随会话」。完整设置仍在设置页。
110
+
111
+ 输入为空或只有附件时,按钮会变灰、不可点;超长、含命令或文件引用的草稿会被本地拒绝。输出达到 token 上限时,会提示结果可能不完整。
105
112
 
106
113
  `/enhance <文本>`:从斜杠面板改写任意文本,结果可复制,不进入模型历史。
107
114
 
115
+ 结果卡页脚的 ⓘ 显示本次增强实际引用的对话轮次与字符数,例如 `3/8 条 · 3,140/4,000 字(79%)`:8 来自 `contextMaxMessages`,百分比按 `contextMaxChars` 计算;DSH 注入的环境/技能/时间等消息不计入。
116
+
108
117
  ## 配置
109
118
 
110
119
  在 **设置 → 提示词增强**(或 插件面板 → `dsh-prompt-enhance` → **配置**)编辑。全部字段:
@@ -112,45 +121,118 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
112
121
  | 字段 | 默认 | 说明 |
113
122
  |---|---|---|
114
123
  | `enabled` | `true` | 总开关;关闭后隐藏输入框按钮,并停用命令与快捷键 |
115
- | `provider` + `model` | 空 | 从 DSH 已注册的 LLM provider 及模型中选择;模型可选「自定义…」手填 ID;未配置的 provider 置灰、需先在 DSH 模型服务中配置;留空表示跟随当前会话模型(不指定)。只填一个时保存后按跟随会话处理 |
124
+ | `provider` + `model` | 空 | 从 DSH 已注册的 LLM provider 及模型中选择;模型可选「自定义…」手填 ID;未配置的 provider 置灰、需先在 DSH 模型服务中配置;留空表示跟随当前会话模型(不固定路由)。只填一个时保存后按跟随会话处理;切换 provider 会清空已选 model,避免留下不匹配的旧值 |
116
125
  | `temperature` | `0.3` | 采样温度 `0~1`(步进 0.05),越低越忠实原文 |
117
- | `reasoningEffort` | `off` | 档位由当前 provider/model 的声明决定;DeepSeek 为 `off` / `low` / `high` / `max`。未声明档位的路由会自动省略该字段(即跟随提供方默认);`inherit` 表示不传该字段 |
126
+ | `reasoningEffort` | `off` | 档位由当前 provider/model 的声明决定;DeepSeek 为 `off` / `low` / `high` / `max`。选「模型默认」时不发送该字段,由提供方使用默认档;切换到不声明当前档位的模型时,插件会自动改回「模型默认」 |
118
127
  | `maxOutputTokens` | `8192` | 单次调用的输出 token 上限 |
119
128
  | `maxInputChars` | `12000` | 输入字符上限;超限拒绝,不截断 |
120
129
  | `timeoutMs` | `60000` | 单次调用端到端超时(毫秒) |
121
130
  | `systemPrompt` | 空 | 自定义系统提示词;留空使用内置增强策略 |
122
131
  | `strategyMode` | `replace-default` | `replace-default` 整体替换内置策略(仍保留最小输出契约);`extend-default` 把自定义策略追加在内置策略之后 |
123
- | `shortcut` | 空(禁用) | 触发快捷键;例 `ctrl+alt+shift+e`。须包含 ctrl/alt/meta 中至少一个修饰键,shift 可选 |
132
+ | `shortcut` | 空(禁用) | 触发增强的快捷键;例如 `ctrl+alt+shift+e`。须包含 ctrl/alt/meta 中至少一个修饰键,shift 可选;设置页可点「录制」直接按键录入 |
124
133
  | `streaming` | `true` | 边写边显示;仅影响显示节奏,最终结果不变 |
134
+ | `foldAnimation` | `true` | 结果卡折叠/展开时是否播放动画;系统开启「减少动态效果」时始终不播放 |
135
+ | `autoFold` | `true` | 回填后自动折叠结果卡,撤销后自动展开 |
125
136
  | `contextAware` | `true` | 读取最近对话以消解指代;含敏感内容的会话建议关闭 |
126
- | `contextMaxMessages` | `8` | 参考的最近消息条数;`0` 表示不参考 |
127
- | `contextMaxChars` | `4000` | 历史片段的字符预算;`0` 表示不参考 |
137
+ | `contextMaxMessages` | `8` | 计入的对话轮次上限(仅你发送的消息与助手回复;DSH 注入消息不计入);`0` 表示不参考 |
138
+ | `contextMaxChars` | `4000` | 对话片段的字符预算(DSH 注入消息不计入);`0` 表示不参考 |
128
139
  | `maxConcurrent` | `2` | 同时进行的增强上限;达到上限时新请求会提示稍后再试 |
129
- | `rateLimitPerMinute` | `10` | 每分钟增强次数上限(滑动窗口);超限时提示稍后再试 |
140
+ | `rateLimitPerMinute` | `10` | 每分钟成功增强次数上限,按任意连续 60 秒计算;超限时提示稍后再试 |
130
141
 
131
- 输入为空或只有附件时按钮灰掉,不发起请求;结果被截断时调高 `maxOutputTokens`。
142
+ 输入为空或只有附件时按钮变灰、不可点,不发起请求;结果被截断时调高 `maxOutputTokens`。
132
143
 
133
144
  ## 安全
134
145
 
135
- - **仅本机可访问**:增强路由由本机 DSH 宿主提供,只接受回环地址和本地 `Host` / `Origin`,不接受外部来源。
136
- - **不保存模型密钥**:插件不读取或存储模型 API key,调用走宿主已有的 LLM 配置。
137
- - **上下文按需发送**:`contextAware` 开启时,最近几轮 user/assistant 文本和当前草稿会发给当前配置的模型服务商(默认最多 8 条消息、4000 字符);system、reasoning、工具结果和附件不会进入上下文。关闭后只发送草稿。
146
+ - **仅本机可访问**:增强路由由本机 DSH 宿主提供,只接受来自本机的请求(连接来自回环地址,且 `Host` / `Origin` 指向本机),外部来源一律拒绝。
147
+ - **不要经反向代理暴露**:代理后的外部请求会以回环地址到达,`Host` / `Origin` 校验随之失效;请只在本机直连使用,不要把本插件的路由放在反向代理后面。
148
+ - **提示注入边界**:草稿被包在 `<raw_prompt>` 标签里,草稿内出现的闭合标签会被中和;这能降低标签逃逸风险,但提示词层面的边界是**最佳努力,不是硬保证**。
149
+ - **不保存模型密钥**:插件不读取或存储模型 API key,调用复用 DSH 已有的模型配置与凭据。
150
+ - **上下文仅在开启时发送**:`contextAware` 开启时,最近几轮 user/assistant 文本和当前草稿会发给当前配置的模型服务商(默认最多 8 条消息、4000 字符);系统消息、模型推理内容、工具结果和附件不会进入上下文;只统计你本人发送的消息与助手回复,DSH 注入的环境/技能/时间等上下文不会计入,也不会消耗这段预算。关闭后只发送草稿。
138
151
  - **敏感会话**:如果内容不能外发,请关闭 `contextAware`,或改用你信任的本地/私有模型服务。
139
- - **本机档位缓存**:插件会把「当前路由声明了哪些推理档位」的查询结果按 provider/model 分别缓存到 `$DSH_HOME/dsh-prompt-enhance/reasoning-efforts/` 目录(未设置 `DSH_HOME` 时为 `~/.dsh/…`),每条缓存 30 天后自动失效并重新探测。文件内容只有 provider、model 与档位信息,不含 API key、草稿或对话内容;也可在设置页点「重新获取档位」立即刷新,或直接删除该目录。
152
+ - **本机档位缓存**:插件把「当前路由声明了哪些推理档位」按 provider/model 缓存在 `$DSH_HOME/dsh-prompt-enhance/reasoning-efforts/`(未设置 `DSH_HOME` 时为 `~/.dsh/…`),30 天后自动失效并重新探测。缓存文件只含 provider、model 与档位信息,不含 API key、草稿或对话内容;可在设置页点「刷新」立即重新探测,或直接删除该目录。
153
+ - **上限按进程计**:`maxConcurrent` 与 `rateLimitPerMinute` 由每个 DSH 进程各自维护,多开进程或多次挂载时配额分别计算,不是全局限流。
154
+
155
+ ## 工作原理
156
+
157
+ ```mermaid
158
+ flowchart LR
159
+ A[输入框草稿] --> B{本地校验<br/>空 / 仅附件 / 超长 / 含命令或文件引用}
160
+ B -- 拒绝 --> R[结果卡:可读错误<br/>草稿不被改动]
161
+ B -- 通过 --> C["POST /dsh-prompt-enhance/enhance<br/>流式为 /dsh-prompt-enhance/enhance-stream"]
162
+ C --> D["ctx.llm.stream<br/>按设置解析出的路由调用模型"]
163
+ D --> E[归一化:去代码围栏、裁剪空白<br/>空结果拒绝]
164
+ E --> F[结果卡:停靠在输入框上方]
165
+ F -- 回填 --> G["写回输入框<br/>原文进入撤销栈"]
166
+ F -- 复制 / 关闭 --> H[草稿保持不变]
167
+ G --> U[撤销:恢复原文]
168
+ ```
169
+
170
+ - **宿主端(Host half)**:声明设置项,在宿主 Web 服务挂 `POST /dsh-prompt-enhance/enhance`(流式 `/dsh-prompt-enhance/enhance-stream`),注册 `/enhance` 命令,并通过 `ctx.llm.stream` 调模型;路由按「设置里的 `provider`/`model` → 当前会话记录的模型 → harness 默认模型」解析。
171
+ - **浏览器端(Browser half)**:输入框按钮、右键快捷设置卡、停靠结果卡、撤销条与快捷键都在这一半,它同时把设置镜像到界面。
172
+ - 点按钮后先在**本地拦截**:空输入、仅附件、超长、含命令或文件引用的草稿直接拒绝,不发请求。
173
+ - 通过后请求宿主路由;宿主再校验一次并调用模型,浏览器优先走 SSE,不支持时回退一次性 JSON。
174
+ - 模型输出经**归一化**(去代码围栏、裁剪空白、空结果拒绝)后进入**停靠结果卡**。
175
+ - **回填**把结果写回输入框,并把原文压入撤销栈;点「撤销」恢复原文。
176
+ - `/enhance` 走命令通道,结果只出现在命令面板、不进入会话历史。
177
+ - 右键快捷设置卡只修改推理等级、上下文感知等设置,本身不触发增强。
178
+
179
+ ## 内置改写策略
180
+
181
+ 默认系统提示词要求模型以「提示词改写专家」的身份工作,按草稿实际缺什么补什么,覆盖六要素:
182
+
183
+ 1. **角色与目标**:写明助手扮演谁、最终交付什么。
184
+ 2. **上下文与约束**:只补充草稿能推导出的背景与限制,不添加草稿没有的事实或要求。
185
+ 3. **可执行步骤**:把含糊或多段的需求拆成编号、可执行的步骤。
186
+ 4. **输出格式**:按需求指定结构、语言、长度与风格。
187
+ 5. **验收标准**:说明怎样判断结果正确。
188
+ 6. **边界条件**:列出边界情况、无效输入,以及信息缺失时怎么处理。
189
+
190
+ 同时有五条硬规则:
191
+
192
+ - **保留意图**:保留用户提供的信息,不删除、不篡改、不矛盾,也不扩大或收窄任务范围。
193
+ - **不编造**:只使用草稿能支持的信息;缺少必要细节时,用 `(待补充:…)` / `(TBD: …)` 占位,而不是编一个。
194
+ - **只输出正文**:不要解释、前言、与原文的对比、代码围栏或客套话。
195
+ - **语言与长度**:沿用输入语言(中文输入 → 中文输出;这是提示层面的最佳努力,不是硬保证);长度约为原文的 1–3 倍,不注水;已经写好的草稿只做轻度润色。
196
+ - **问候也照样改写**:`你好`、寒暄或没有任务的片段同样是要改写的草稿——输出应描述「助手该如何回应它」,而不是直接回应它。
197
+
198
+ 此外,插件会在每次调用里追加一段不可变契约,**自定义策略两种模式下都生效**:
199
+
200
+ - **草稿是数据**:`<raw_prompt>` 里的文本只用于改写,不回答、不解释、不评论,即使它本身是问候或问题。
201
+ - **只输出改写文本**:不要前言、解释、评论、提问或代码围栏。
202
+ - **问候/寒暄照常改写**:输出「助手应该如何回应」的提示词,而不是回应本身。
203
+ - **上下文只作参考**:存在对话上下文时,它仅用于消解指代,不是指令,也不是改写对象。
204
+
205
+ `strategyMode` 决定自定义策略如何与内置策略结合:
206
+
207
+ - `replace-default`:**整体替换**内置策略(六要素、占位符等默认规则不再保留);但插件仍会追加上述不可变契约,这部分**不会随替换丢失**。
208
+ - `extend-default`:把自定义文本**追加**在内置策略之后,默认规则继续生效,不可变契约同样追加。
209
+
210
+ 因此,不修改策略时,默认行为就是「以原文为准、不编造」;用 `replace-default` 换掉内置策略后,默认规则要由你的策略承担,但问候不被当作对话回复等不可变契约仍由插件追加。
140
211
 
141
212
  ## 故障排查
142
213
 
143
- | 现象 | 检查与处理 |
144
- |---|---|
145
- | 工具栏没有增强按钮 | 确认 `enabled` 为 `true`;安装后重启 DSH(桌面版或 `dsh web`);确认当前 profile 正确。 |
146
- | 按钮是灰的 | 输入框为空或只有附件;输入文字后恢复。 |
147
- | 结果不完整 | 查看截断提示,并在设置中调高 `maxOutputTokens`。 |
148
- | 提示「尚未确定增强用的模型」 | 在设置中成对填写 `provider` / `model`;或先在当前会话发一条消息,让插件跟随会话模型。 |
149
- | 鉴权失败 | 检查对应 provider 在 DSH 中的凭据/API Key 是否有效。 |
150
- | `/enhance` 的结果只显示第一行、点不开 | 这是 DSH 聊天界面的渲染限制,与本插件无关:截至 `@deepseek-ai/dsh-client-ui-chat` 0.2.2-rc.3,只有含换行的结果才提供展开,单行结果会被省略号截断且没有入口。要看全文,把同样的文本放进输入框、用增强按钮——按钮的结果卡会自动折行并可滚动。 |
214
+ 下表按你会看到的现象组织;参数的含义与默认值见「配置」。
215
+
216
+ | 现象 | 可能原因 | 可以做什么 |
217
+ |---|---|---|
218
+ | 工具栏没有增强按钮 | `enabled` 关闭、插件未启用,或 DSH 未重启 | 确认 `enabled` 为 `true`;安装插件后重启 DSH(桌面版或 `dsh web`);确认当前 profile 正确 |
219
+ | 按钮是灰的 | 输入框为空或只有附件 | 输入文字后恢复 |
220
+ | 提示内容超长 | 超过 `maxInputChars` | 精简草稿,或在设置中调大 `maxInputChars` |
221
+ | 提示包含命令或文件引用 | 草稿里有 `/命令` 或 `@引用`;回填会破坏它们 | 改为纯文本后重试 |
222
+ | 提示「已有 N 个增强正在进行」 | 达到 `maxConcurrent` | 等其中一个完成后再试;多个会话同时增强时也会触发 |
223
+ | 提示「每分钟最多 N 次增强」 | 达到 `rateLimitPerMinute` | 按提示等待,或在设置中调大该值 |
224
+ | 提示增强超时,或增强被取消 | 超过 `timeoutMs`,或你点了「取消」 | 超时可重试或调大 `timeoutMs`;取消不会改动原输入,重新点增强即可 |
225
+ | 提示鉴权失败 | 对应 provider 的凭据或 API key 无效 | 检查该 provider 在 DSH 中的凭据/API key 是否有效 |
226
+ | 结果被截断 | 达到 `maxOutputTokens` | 查看截断提示,并在设置中调高 `maxOutputTokens` |
227
+ | 上下文用量显示 `8/8 条`(默认值) | 达到 `contextMaxMessages` 的轮次上限(默认 8);这是正常截断,不显示警告 | 一般无需处理;需要更早的对话时调大 `contextMaxMessages`,但可能先撞上 `contextMaxChars`(默认 4,000 字) |
228
+ | 上下文用量显示 `4,000/4,000 字`(默认值,琥珀色) | 达到 `contextMaxChars` 的字数上限(默认 4,000),较早内容未发送;最新一条被截头时原因行会写「最新一条仅发送了开头」 | 调大 `contextMaxChars`,或精简对话/减少引用;上下文越多,输入 token 和费用越高 |
229
+ | 提示「还没确定用哪个模型」(缺模型路由) | 未固定 `provider`/`model`,且当前会话没有模型路由 | 在设置中成对填写 `provider` / `model`;或先在当前会话发一条消息,让插件跟随会话模型 |
230
+ | `/enhance` 的结果只显示第一行、点不开 | DSH 聊天界面的渲染限制,与本插件无关 | 把同样的文本放进输入框,用增强按钮;结果卡会自动折行并可滚动 |
151
231
 
152
232
  ## 开发
153
233
 
234
+ **常用命令**
235
+
154
236
  ```bash
155
237
  npm install
156
238
  npm run typecheck
@@ -158,8 +240,35 @@ npm run lint
158
240
  npm run format:check
159
241
  npm test
160
242
  npm run build
243
+ npm run watch
161
244
  ```
162
245
 
246
+ 测试覆盖输入校验、输出归一化、宿主路由(真实 HTTP)、设置与快捷设置状态机,以及 React 组件行为。
247
+
248
+ **架构**
249
+
250
+ ```text
251
+ src/
252
+ ├── index.ts 宿主装配:设置节、路由与 /enhance 命令
253
+ ├── prompts.ts 默认策略、不可变契约与 <raw_prompt> 框定
254
+ ├── enhance-routes.ts POST /dsh-prompt-enhance/enhance 与 SSE 流
255
+ ├── shared/ 两端共用:协议、输入校验、输出归一化
256
+ └── client/
257
+ ├── EnhanceButton.tsx 输入框按钮、本地拦截与请求编排
258
+ ├── QuickSettingsMenu.tsx 右键快捷设置卡(模型、档位、上下文)
259
+ ├── ResultPanel.tsx 停靠结果卡(回填、复制、重新生成、取消)
260
+ └── UndoBar.tsx 撤销条(恢复原文)
261
+ scripts/
262
+ └── build.mjs 构建两半到 lib/
263
+ ```
264
+
265
+ 构建产物:
266
+
267
+ - `lib/index.js`:宿主半(ESM,包导入保持 external,由 DSH 插件加载器解析 `@deepseek-ai/*`);
268
+ - `lib/client.js`:浏览器半(CJS,包在 `window.__ModuleLoader__.load({ id, factory })` 外壳里)。
269
+
270
+ `lib/` **随仓库提交**,从 GitHub 安装时无需本地构建。CI 会在每次 push 时从 `src/` 重新构建并比对 `lib/`,不一致就失败——所以改完源码要跑 `npm run build`,把 `lib/` 和源码一起提交。
271
+
163
272
  详见 [CONTRIBUTING.md](./CONTRIBUTING.md)。
164
273
 
165
274
  ## 许可证
Binary file
Binary file
package/lib/client.js CHANGED
@@ -109,10 +109,28 @@ function parseUsage(value) {
109
109
  ...cacheWriteTokens === void 0 ? {} : { cacheWriteTokens }
110
110
  };
111
111
  }
112
+ function parseContextUsage(value) {
113
+ const record = value;
114
+ if (record === null || typeof record !== "object") return void 0;
115
+ const integer = (field) => typeof field === "number" && Number.isInteger(field) && field >= 0;
116
+ if (!integer(record.usedTurns) || !integer(record.maxTurns) || !integer(record.usedChars) || !integer(record.maxChars) || !integer(record.droppedTurns) || record.limitedBy !== null && record.limitedBy !== "turns" && record.limitedBy !== "chars" || typeof record.cutTurn !== "boolean") {
117
+ return void 0;
118
+ }
119
+ return {
120
+ usedTurns: record.usedTurns,
121
+ maxTurns: record.maxTurns,
122
+ usedChars: record.usedChars,
123
+ maxChars: record.maxChars,
124
+ droppedTurns: record.droppedTurns,
125
+ limitedBy: record.limitedBy,
126
+ cutTurn: record.cutTurn
127
+ };
128
+ }
112
129
  function parseResult(value) {
113
130
  const record = value;
114
131
  if (record !== null && typeof record === "object" && typeof record.text === "string" && record.text !== "" && typeof record.provider === "string" && record.provider !== "" && typeof record.model === "string" && record.model !== "" && typeof record.elapsedMs === "number" && Number.isFinite(record.elapsedMs)) {
115
132
  const usage = parseUsage(record.usage);
133
+ const context = parseContextUsage(record.context);
116
134
  return {
117
135
  text: record.text,
118
136
  provider: record.provider,
@@ -128,7 +146,8 @@ function parseResult(value) {
128
146
  // Same trap as runcated above: rebuilding the object field by field
129
147
  // drops anything not listed here, so a new result field has to be added
130
148
  // in this exact place or the UI silently never sees it.
131
- ...typeof record.reasoningEffort === "string" ? { reasoningEffort: record.reasoningEffort } : {}
149
+ ...typeof record.reasoningEffort === "string" ? { reasoningEffort: record.reasoningEffort } : {},
150
+ ...context === void 0 ? {} : { context }
132
151
  };
133
152
  }
134
153
  throw new EnhanceClientError({ code: "internal", params: { reason: "malformed" } });
@@ -1472,6 +1491,47 @@ function capitalizeEffort(value) {
1472
1491
  function totalTokensOf(usage) {
1473
1492
  return usage.totalTokens ?? usage.inputTokens + usage.outputTokens + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0);
1474
1493
  }
1494
+ function ContextUsageInfo(props) {
1495
+ const { usage, t } = props;
1496
+ const [open, setOpen] = (0, import_react5.useState)(false);
1497
+ const limited = usage !== void 0 && (usage.cutTurn || usage.limitedBy === "chars");
1498
+ const percent = usage !== void 0 && usage.maxChars > 0 ? Math.round(usage.usedChars / usage.maxChars * 100) : 0;
1499
+ const stats = usage === void 0 ? t("panel.contextUnused") : t("panel.contextStats", {
1500
+ turns: usage.usedTurns,
1501
+ maxTurns: usage.maxTurns,
1502
+ chars: formatTokens(usage.usedChars),
1503
+ maxChars: formatTokens(usage.maxChars),
1504
+ percent
1505
+ });
1506
+ const reason = usage === void 0 ? "" : usage.cutTurn ? t("panel.contextCut") : usage.limitedBy === "chars" ? t("panel.contextCharsLimited") : "";
1507
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "dsh-pe-context-wrap", children: [
1508
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1509
+ "button",
1510
+ {
1511
+ type: "button",
1512
+ className: `dsh-pe-context${limited ? " is-limited" : ""}`,
1513
+ "aria-label": t("panel.contextUsage"),
1514
+ "aria-expanded": open,
1515
+ onMouseEnter: () => setOpen(true),
1516
+ onMouseLeave: () => setOpen(false),
1517
+ onFocus: () => setOpen(true),
1518
+ onBlur: () => setOpen(false),
1519
+ onClick: () => setOpen((value) => !value),
1520
+ onKeyDown: (event) => {
1521
+ if (event.key === "Escape") setOpen(false);
1522
+ },
1523
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "dsh-pe-context-icon", viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: [
1524
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "2.2", y: "3.4", width: "11.6", height: "9.2", rx: "2.2", fill: "none", stroke: "currentColor", strokeWidth: "1.2" }),
1525
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.2 6.6h5.6M5.2 9.2h3.8", fill: "none", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
1526
+ ] })
1527
+ }
1528
+ ),
1529
+ open && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { role: "tooltip", className: "dsh-pe-context-tip", children: [
1530
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-context-stats", children: stats }),
1531
+ reason !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-context-reason", children: reason })
1532
+ ] })
1533
+ ] });
1534
+ }
1475
1535
  function ResultPanel(props) {
1476
1536
  const { state, t, onApply, onCancel, onRetry, applied = false, onUndo, onRegenerate, regenerated = false, collapsed = false, onToggleCollapsed, foldAnimation = true } = props;
1477
1537
  const [copied, setCopied] = (0, import_react5.useState)("idle");
@@ -1557,6 +1617,7 @@ function ResultPanel(props) {
1557
1617
  ] })
1558
1618
  ] }) }),
1559
1619
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("footer", { className: "dsh-pe-foot", children: [
1620
+ state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ContextUsageInfo, { usage: state.result?.context, t }),
1560
1621
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "dsh-pe-grow" }),
1561
1622
  state.phase === "result" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "dsh-pe-btn-action plain dsh-pe-btn-floor", onClick: onRegenerate, disabled: onRegenerate === void 0, children: [
1562
1623
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RegenerateIcon, {}),
@@ -1856,7 +1917,7 @@ var zh = {
1856
1917
  "menu.effortsNone": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D",
1857
1918
  "menu.effortsFailed": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D",
1858
1919
  "menu.effort": "\u63A8\u7406\u7B49\u7EA7",
1859
- "menu.effortDefault": "\u4E0D\u6307\u5B9A",
1920
+ "menu.effortDefault": "\u6A21\u578B\u9ED8\u8BA4",
1860
1921
  "menu.context": "\u4E0A\u4E0B\u6587\u611F\u77E5",
1861
1922
  "menu.contextOn": "\u5F00",
1862
1923
  "menu.contextOff": "\u5173",
@@ -1880,10 +1941,15 @@ var zh = {
1880
1941
  "panel.retry": "\u91CD\u8BD5",
1881
1942
  "panel.stale.warn": "\u8349\u7A3F\u5DF2\u6539\u52A8\uFF0C\u5F53\u524D\u7ED3\u679C\u57FA\u4E8E\u65E7\u6587\u672C\u3002\u300C\u91CD\u65B0\u751F\u6210\u300D\u4F1A\u6309\u5F53\u524D\u6587\u672C\u91CD\u8DD1\uFF1B\u56DE\u586B\u4ECD\u4F1A\u8986\u76D6\u5F53\u524D\u8F93\u5165\uFF08\u53EF\u64A4\u9500\uFF09\u3002",
1882
1943
  "panel.truncated": "\u8F93\u51FA\u88AB\u622A\u65AD\uFF08\u8FBE\u5230\u8F93\u51FA\u4E0A\u9650\uFF09\uFF0C\u7ED3\u679C\u53EF\u80FD\u4E0D\u5B8C\u6574\u3002\u53EF\u5728\u8BBE\u7F6E\u91CC\u8C03\u9AD8\u300C\u8F93\u51FA token \u4E0A\u9650\u300D\u540E\u91CD\u65B0\u751F\u6210\u3002",
1944
+ "panel.contextUsage": "\u4E0A\u4E0B\u6587\u7528\u91CF",
1945
+ "panel.contextStats": "\u4E0A\u4E0B\u6587 {turns}/{maxTurns} \u6761 \xB7 {chars}/{maxChars} \u5B57\uFF08{percent}%\uFF09",
1946
+ "panel.contextCharsLimited": "\u5DF2\u8FBE\u5B57\u6570\u4E0A\u9650\uFF0C\u8F83\u65E9\u5185\u5BB9\u672A\u53D1\u9001",
1947
+ "panel.contextCut": "\u5DF2\u8FBE\u5B57\u6570\u4E0A\u9650\uFF0C\u6700\u65B0\u4E00\u6761\u4EC5\u53D1\u9001\u4E86\u5F00\u5934",
1948
+ "panel.contextUnused": "\u672C\u6B21\u672A\u4F7F\u7528\u4E0A\u4E0B\u6587",
1883
1949
  "panel.model": "\u6A21\u578B\uFF1A{provider} / {model}",
1884
1950
  "panel.elapsed": "\u8017\u65F6 {ms}",
1885
1951
  "panel.tokens": "{total} tokens",
1886
- "panel.effortDefault": "\u4E0D\u6307\u5B9A",
1952
+ "panel.effortDefault": "\u6A21\u578B\u9ED8\u8BA4",
1887
1953
  "panel.tokens.input": "\u8F93\u5165 {count}",
1888
1954
  "panel.tokens.output": "\u8F93\u51FA {count}",
1889
1955
  "panel.tokens.cacheRead": "\u7F13\u5B58\u8BFB\u53D6 {count}",
@@ -1900,7 +1966,7 @@ var zh = {
1900
1966
  "error.rejected": "\u589E\u5F3A\u8BF7\u6C42\u88AB\u62D2\u7EDD\u3002\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u51FA\u73B0\uFF0C\u8BF7\u68C0\u67E5\u63D2\u4EF6\u8BBE\u7F6E\u3002",
1901
1967
  "error.timeout": "\u589E\u5F3A\u8D85\u65F6\uFF08{seconds} \u79D2\uFF09\u3002\u53EF\u76F4\u63A5\u91CD\u8BD5\uFF0C\u6216\u5230\u8BBE\u7F6E\u91CC\u8C03\u9AD8\u300C\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09\u300D\uFF1B\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
1902
1968
  "error.unconfigured": "\u8FD8\u6CA1\u786E\u5B9A\u7528\u54EA\u4E2A\u6A21\u578B\uFF1A\u8BF7\u5728\u63D2\u4EF6\u8BBE\u7F6E\u91CC\u586B\u5199 provider \u548C model\uFF08\u4E24\u9879\u90FD\u8981\u586B\uFF09\uFF0C\u6216\u5728\u5F53\u524D\u4F1A\u8BDD\u5148\u53D1\u4E00\u6761\u6D88\u606F\u4EE5\u8DDF\u968F\u4F1A\u8BDD\u6A21\u578B\u3002",
1903
- "error.effortUnsupported": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u6863\u4F4D\u300C{effort}\u300D\uFF0C\u8BF7\u6539\u9009\u5176\u5B83\u6863\u4F4D\uFF0C\u6216\u6539\u7528\u300C\u4E0D\u6307\u5B9A\u300D\u3002",
1969
+ "error.effortUnsupported": "\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u6240\u9009\u63A8\u7406\u6863\u4F4D\u300C{effort}\u300D\uFF0C\u8BF7\u6539\u9009\u5176\u5B83\u6863\u4F4D\uFF0C\u6216\u6539\u7528\u300C\u6A21\u578B\u9ED8\u8BA4\u300D\u3002",
1904
1970
  "error.upstream": "\u6A21\u578B\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF1B\u82E5\u4E0B\u65B9\u6709\u8BE6\u60C5\uFF0C\u8BF7\u6309\u8BE6\u60C5\u5904\u7406\uFF0C\u5426\u5219\u53EF\u76F4\u63A5\u91CD\u8BD5\u3002\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
1905
1971
  "error.internal": "\u589E\u5F3A\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u82E5\u53CD\u590D\u5931\u8D25\uFF0C\u8BF7\u67E5\u770B dsh \u8FD0\u884C\u65E5\u5FD7\u3002\u539F\u8F93\u5165\u672A\u6539\u52A8\u3002",
1906
1972
  "error.client.unreachable": "\u65E0\u6CD5\u8FDE\u63A5\u5BBF\u4E3B\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 dsh web \u6B63\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002",
@@ -1974,7 +2040,7 @@ var zh = {
1974
2040
  "settings.row.temperature.label": "\u6E29\u5EA6",
1975
2041
  "settings.row.temperature.hint": "\u91C7\u6837\u6E29\u5EA6\uFF080~1\uFF0C\u6B65\u8FDB 0.05\uFF09\uFF0C\u8D8A\u4F4E\u8D8A\u5FE0\u5B9E\u539F\u6587\uFF1B\u9ED8\u8BA4 0.3\u3002",
1976
2042
  "settings.row.reasoningEffort.label": "\u63A8\u7406\u9884\u7B97",
1977
- "settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\u300C\u4E0D\u6307\u5B9A\u300D\u8868\u793A\u4E0D\u4F20\u8BE5\u5B57\u6BB5\u3002",
2043
+ "settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\u300C\u6A21\u578B\u9ED8\u8BA4\u300D\u8868\u793A\u4E0D\u53D1\u9001\u8BE5\u5B57\u6BB5\uFF0C\u7531\u63D0\u4F9B\u65B9\u4F7F\u7528\u9ED8\u8BA4\u6863\u3002",
1978
2044
  "settings.row.maxOutputTokens.label": "\u8F93\u51FA token \u4E0A\u9650",
1979
2045
  "settings.row.maxOutputTokens.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u8F93\u51FA\u9884\u7B97\uFF1B\u9ED8\u8BA4 8192\u3002",
1980
2046
  "settings.row.maxInputChars.label": "\u8F93\u5165\u5B57\u7B26\u4E0A\u9650",
@@ -1999,7 +2065,7 @@ var zh = {
1999
2065
  "settings.row.shortcut.placeholder": "\u4F8B\uFF1Actrl+alt+shift+e",
2000
2066
  "settings.strategy.replace": "\u66FF\u6362\u5185\u7F6E\u7B56\u7565",
2001
2067
  "settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
2002
- "settings.reasoning.inherit": "\u4E0D\u6307\u5B9A",
2068
+ "settings.reasoning.inherit": "\u6A21\u578B\u9ED8\u8BA4",
2003
2069
  "settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
2004
2070
  "settings.reasoning.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u5217\u8868\uFF1B\u5DF2\u4FDD\u5B58\u7684\u6863\u4F4D\u4ECD\u4F1A\u7167\u5E38\u53D1\u9001\u3002",
2005
2071
  "settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\uFF1B\u8C03\u7528\u65F6\u4E0D\u53D1\u9001\u6863\u4F4D\uFF0C\u7531\u63D0\u4F9B\u65B9\u51B3\u5B9A\u3002",
@@ -2024,7 +2090,7 @@ var en = {
2024
2090
  "menu.effortsNone": "This model declares no reasoning tiers",
2025
2091
  "menu.effortsFailed": "Could not read this model tiers",
2026
2092
  "menu.effort": "Reasoning effort",
2027
- "menu.effortDefault": "Not specified",
2093
+ "menu.effortDefault": "Model default",
2028
2094
  "menu.context": "Context awareness",
2029
2095
  "menu.contextOn": "on",
2030
2096
  "menu.contextOff": "off",
@@ -2048,10 +2114,15 @@ var en = {
2048
2114
  "panel.retry": "Retry",
2049
2115
  "panel.stale.warn": "Draft changed \u2014 this result uses the earlier text. Regenerate re-runs on the current draft; Apply still overwrites the input (undoable).",
2050
2116
  "panel.truncated": 'Output was cut at the output limit, so the result may be incomplete. Raise "Output token budget" in the settings, then regenerate.',
2117
+ "panel.contextUsage": "Context usage",
2118
+ "panel.contextStats": "Context {turns}/{maxTurns} turns \xB7 {chars}/{maxChars} chars ({percent}%)",
2119
+ "panel.contextCharsLimited": "Character cap reached; earlier turns were not sent",
2120
+ "panel.contextCut": "Character limit reached; only the opening of the latest turn was sent",
2121
+ "panel.contextUnused": "No conversation context was used for this call",
2051
2122
  "panel.model": "Model: {provider} / {model}",
2052
2123
  "panel.elapsed": "{ms} elapsed",
2053
2124
  "panel.tokens": "{total} tokens",
2054
- "panel.effortDefault": "Not specified",
2125
+ "panel.effortDefault": "Model default",
2055
2126
  "panel.tokens.input": "Input {count}",
2056
2127
  "panel.tokens.output": "Output {count}",
2057
2128
  "panel.tokens.cacheRead": "Cache read {count}",
@@ -2068,7 +2139,7 @@ var en = {
2068
2139
  "error.rejected": "The enhance request was rejected. Retry later; if it persists, check the plugin settings.",
2069
2140
  "error.timeout": 'The enhancement timed out ({seconds}s). Retry, or raise "Timeout (ms)" in the settings; your draft is untouched.',
2070
2141
  "error.unconfigured": "No model is configured for the enhancement: fill in both provider and model in the plugin settings, or send a message in the current session first to follow the session model.",
2071
- "error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "Not specified".',
2142
+ "error.effortUnsupported": 'This model does not support the selected reasoning effort "{effort}". Choose another tier, or use "Model default".',
2072
2143
  "error.upstream": "The model provider returned an error. If there is detail below, act on it; otherwise retry. Your draft is untouched.",
2073
2144
  "error.internal": "Enhancement failed. Retry; if it keeps failing, check the dsh logs. Your draft is untouched.",
2074
2145
  "error.client.unreachable": "Cannot reach the host service \u2014 make sure dsh web is running, then retry.",
@@ -2142,7 +2213,7 @@ var en = {
2142
2213
  "settings.row.temperature.label": "Temperature",
2143
2214
  "settings.row.temperature.hint": "Sampling temperature (0\u20131, step 0.05); lower stays closer to the original. Default 0.3.",
2144
2215
  "settings.row.reasoningEffort.label": "Reasoning effort",
2145
- "settings.row.reasoningEffort.hint": 'Tier choices come from what the configured provider/model declares; custom models are read on demand. "Not specified" omits the field.',
2216
+ "settings.row.reasoningEffort.hint": 'Tier choices come from what the configured provider/model declares; custom models are read on demand. "Model default" means the field is omitted and the provider applies its default.',
2146
2217
  "settings.row.maxOutputTokens.label": "Output token budget",
2147
2218
  "settings.row.maxOutputTokens.hint": "Output budget for one enhancement call. Default 8192.",
2148
2219
  "settings.row.maxInputChars.label": "Input character cap",
@@ -2167,7 +2238,7 @@ var en = {
2167
2238
  "settings.row.shortcut.placeholder": "e.g. ctrl+alt+shift+e",
2168
2239
  "settings.strategy.replace": "Replace the built-in strategy",
2169
2240
  "settings.strategy.extend": "Append after the built-in strategy",
2170
- "settings.reasoning.inherit": "Not specified",
2241
+ "settings.reasoning.inherit": "Model default",
2171
2242
  "settings.reasoning.loading": "Reading this model\u2019s tiers\u2026",
2172
2243
  "settings.reasoning.unavailable": "Could not read this model\u2019s tier list; your saved tier is still sent.",
2173
2244
  "settings.reasoning.noTiers": "This model declares no reasoning tiers; calls omit the field and let the provider decide.",
@@ -2598,6 +2669,112 @@ html[data-platform='darwin'] .dsh-pe-menu {
2598
2669
  border-top: 1px solid var(--pe-separator);
2599
2670
  }
2600
2671
  .dsh-pe-foot .dsh-pe-grow { flex: 1; }
2672
+
2673
+ /* The context-usage button sits at the quiet end of the footer, opposite the
2674
+ actions. Its tooltip opens upward into the card body, so no portal is needed
2675
+ and the card's own overflow clipping stays out of the way. */
2676
+ .dsh-pe-context-wrap {
2677
+ position: relative;
2678
+ display: inline-flex;
2679
+ }
2680
+ .dsh-pe-context {
2681
+ box-sizing: border-box;
2682
+ display: inline-flex;
2683
+ flex: none;
2684
+ align-items: center;
2685
+ justify-content: center;
2686
+ width: 28px;
2687
+ height: 28px;
2688
+ padding: 0;
2689
+ border: 0;
2690
+ border-radius: 8px;
2691
+ background: transparent;
2692
+ /* The glyph carries the state on its own: grey when the window is healthy,
2693
+ amber when it had to cut something. The precise counts stay in the
2694
+ tooltip. */
2695
+ --pe-context-accent: var(--dsw-alias-label-tertiary, #8a8a8a);
2696
+ color: var(--pe-context-accent);
2697
+ cursor: default;
2698
+ }
2699
+ .dsh-pe-context:hover { background: var(--pe-hover); }
2700
+ .dsh-pe-context.is-limited {
2701
+ --pe-context-accent: #b45309;
2702
+ color: var(--pe-context-accent);
2703
+ }
2704
+ /* The warning lives in the glyph alone by default; the amber tint appears on
2705
+ hover or keyboard focus, matching the plain state's on-demand background. */
2706
+ .dsh-pe-context.is-limited:hover,
2707
+ .dsh-pe-context.is-limited:focus-visible {
2708
+ background: rgba(180, 83, 9, 0.1);
2709
+ }
2710
+ .dsh-pe-context-icon {
2711
+ position: relative;
2712
+ z-index: 1;
2713
+ display: block;
2714
+ width: 20px;
2715
+ height: 20px;
2716
+ color: var(--pe-context-accent);
2717
+ }
2718
+ .dsh-pe-context-tip {
2719
+ position: absolute;
2720
+ left: 0;
2721
+ bottom: calc(100% + 8px);
2722
+ z-index: 5;
2723
+ display: flex;
2724
+ flex-direction: column;
2725
+ gap: 2px;
2726
+ box-sizing: border-box;
2727
+ width: max-content;
2728
+ max-width: min(340px, calc(100vw - 40px));
2729
+ padding: 6px 10px;
2730
+ border-radius: var(--dsw-radius-sm, 6px);
2731
+ background: var(--dsw-alias-tooltip-bg, #2f2f2f);
2732
+ color: var(--dsw-alias-tooltip-label, #ffffff);
2733
+ font-size: 13px;
2734
+ line-height: 20px;
2735
+ font-variant-numeric: tabular-nums;
2736
+ white-space: normal;
2737
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
2738
+ pointer-events: none;
2739
+ animation: dsh-pe-context-tip-in 140ms ease-out;
2740
+ }
2741
+ /* The bubble needs an anchor: it floats above the icon and would otherwise
2742
+ read as disconnected from the footer. */
2743
+ .dsh-pe-context-tip::after {
2744
+ content: '';
2745
+ position: absolute;
2746
+ left: 12px;
2747
+ bottom: -5px;
2748
+ width: 0;
2749
+ height: 0;
2750
+ border-left: 5px solid transparent;
2751
+ border-right: 5px solid transparent;
2752
+ border-top: 5px solid var(--dsw-alias-tooltip-bg, #2f2f2f);
2753
+ }
2754
+ @keyframes dsh-pe-context-tip-in {
2755
+ from {
2756
+ opacity: 0;
2757
+ transform: translateY(2px);
2758
+ }
2759
+ }
2760
+ @media (prefers-reduced-motion: reduce) {
2761
+ .dsh-pe-context-tip { animation: none; }
2762
+ }
2763
+ /* The stats line is one unit: a wrap that leaves the percentage alone reads
2764
+ as a layout bug. The reason line may wrap freely. */
2765
+ .dsh-pe-context-tip .dsh-pe-context-stats { white-space: nowrap; }
2766
+ .dsh-pe-context-tip .dsh-pe-context-reason { color: #f2c185; }
2767
+ /* Narrow viewports: the card itself is close to the viewport width, so the
2768
+ fixed tooltip width would clip. Give it a viewport-relative cap and let the
2769
+ stats line wrap instead of overflowing. */
2770
+ @media (max-width: 560px) {
2771
+ .dsh-pe-context-tip {
2772
+ min-width: 0;
2773
+ width: 230px;
2774
+ max-width: calc(100vw - 40px);
2775
+ }
2776
+ .dsh-pe-context-tip .dsh-pe-context-stats { white-space: normal; }
2777
+ }
2601
2778
  .dsh-pe-btn-action {
2602
2779
  box-sizing: border-box;
2603
2780
  display: inline-flex;
@@ -3403,7 +3580,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
3403
3580
  var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
3404
3581
  var GITHUB_MARK = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z";
3405
3582
  var NPM_MARK = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
3406
- var PLUGIN_VERSION = true ? "0.1.2" : "0.0.0";
3583
+ var PLUGIN_VERSION = true ? "0.1.3" : "0.0.0";
3407
3584
  var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
3408
3585
  var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
3409
3586
  var HEADER_TITLE_STYLE = {