@surfishs/dsh-prompt-enhance 0.0.8 → 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/README.en.md +33 -19
- package/README.md +33 -19
- package/docs/images/panel-en-915.png +0 -0
- package/docs/images/panel.png +0 -0
- package/icon.svg +14 -0
- package/lib/client.js +123 -68
- package/lib/index.js +208 -131
- package/lib/index.js.map +3 -3
- package/package.json +5 -2
- package/src/admission.ts +146 -0
- package/src/client/EnhanceButton.tsx +34 -15
- package/src/client/ResultDock.tsx +1 -1
- package/src/client/SparkleFishIcon.tsx +22 -7
- package/src/client/UndoBar.tsx +1 -1
- package/src/client/enhance-client.ts +6 -0
- package/src/client/globals.d.ts +3 -0
- package/src/client/locales.ts +5 -4
- package/src/client/settings-page-spec.ts +9 -1
- package/src/client/styles.ts +34 -30
- package/src/client/useDockAlignment.ts +128 -44
- package/src/config.ts +28 -22
- package/src/enhance-command.ts +32 -10
- package/src/enhance-routes.ts +52 -101
- package/src/enhancer.ts +64 -15
- package/src/http.ts +37 -6
- package/src/index.ts +6 -2
- package/src/reasoning-cache.ts +153 -63
- package/src/shared/normalize.ts +26 -14
- package/src/client/SparkleIcon.tsx +0 -23
package/README.en.md
CHANGED
|
@@ -12,29 +12,42 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
## Why you need it
|
|
16
|
+
|
|
17
|
+
A prompt is rarely the hard part; shaping it for a model to execute is: the role (who the assistant plays), the deliverable (what it must hand over), the output format (structure, language, length, style), and the acceptance criteria (how to tell the result is right).
|
|
18
|
+
|
|
19
|
+
This plugin adds a Prompt enhance button to the composer; clicking it calls your harness LLM service to produce a properly structured prompt.
|
|
20
|
+
|
|
21
|
+
The enhanced result appears above the composer without covering the conversation; it does not replace the original text by itself — fill it back, copy it, regenerate it, or undo it, and the original stays safe.
|
|
22
|
+
|
|
23
|
+
With context awareness on, it also reads the last few turns to resolve pronouns and works out what you need on its own.
|
|
24
|
+
|
|
25
|
+
## Feature overview
|
|
26
|
+
|
|
27
|
+
| Feature | What it does |
|
|
28
|
+
|---|---|
|
|
29
|
+
| 🐋 **One-click enhance** | The composer toolbar button (the DeepSeek whale mark whose upper-left corner carries a sparkle); the shortcut is off by default and can be set in the settings |
|
|
30
|
+
| 🖼️ **Docked result card** | The result appears above the composer without covering the conversation, with the model, timing and `token` usage; a truncated result is marked as possibly incomplete |
|
|
31
|
+
| ↩️ **Apply, copy and undo** | Undo right after applying; once the card is closed, the undo bar remains above the composer |
|
|
32
|
+
| 🔄 **Regenerate** | Requests another version from the current composer text; after applying, it regenerates the enhanced draft as well |
|
|
33
|
+
| 💬 **`/enhance` command** | Rewrites any text from the slash menu; the result never enters model history |
|
|
34
|
+
| 🧭 **Model routing** | A pinned `provider` + `model` pair wins; otherwise it follows the current session model, then the global default model |
|
|
35
|
+
| 🧩 **Context aware** | With `contextAware` on, recent turns resolve references such as "it" or "that"; it can be turned off |
|
|
36
|
+
| 🔑 **Zero credentials** | Calls go through the harness LLM service and its credential store; the plugin neither reads nor stores keys |
|
|
37
|
+
| 🛡️ **Draft safety** | Empty, attachment-only, over-length and command-or-reference drafts are blocked locally before any request; upstream failures map to readable messages; a failure never touches the draft |
|
|
38
|
+
| ⚙️ **Live settings** | Fields save automatically, common rows come first and the rest fold into Advanced settings; changes apply to the next call with no restart |
|
|
27
39
|
|
|
28
40
|
## Requirements
|
|
29
41
|
|
|
30
|
-
| | |
|
|
42
|
+
| Item | Requirement |
|
|
31
43
|
|---|---|
|
|
32
|
-
| dsh | `>= 0.1.1-rc.2 < 0.3.0` |
|
|
44
|
+
| dsh | `>= 0.1.1-rc.2 < 0.3.0`, verified on `0.2.2-rc.3` |
|
|
33
45
|
| Node (source builds only) | `^22.19.0 \|\| >=24.0.0` |
|
|
34
|
-
| Plugin | `0.0.x` |
|
|
35
46
|
|
|
36
47
|
## Install
|
|
37
48
|
|
|
49
|
+
Check the package name first. `dsh-prompt-enhance` on npm (no scope) is the upstream project and this plugin is a rewrite of it; this plugin is `@surfishs/dsh-prompt-enhance`. Install from this repository (`surfishs/dsh-prompt-enhance`). **Do not** run `dsh plugin add dsh-prompt-enhance`.
|
|
50
|
+
|
|
38
51
|
### Let an agent install it
|
|
39
52
|
|
|
40
53
|
No command line needed. Send the block below to an agent that can run commands on your machine (DSH desktop or web):
|
|
@@ -56,14 +69,14 @@ dsh plugin --profile <profile> add @surfishs/dsh-prompt-enhance
|
|
|
56
69
|
# restart dsh
|
|
57
70
|
```
|
|
58
71
|
|
|
72
|
+
> Replace `<profile>` with your profile name: usually `desktop` for the desktop app and `web` for the web build.
|
|
73
|
+
|
|
59
74
|
From GitHub (the built `lib/` is committed, so no local build happens):
|
|
60
75
|
|
|
61
76
|
```bash
|
|
62
77
|
dsh plugin --profile <profile> add github:surfishs/dsh-prompt-enhance
|
|
63
78
|
```
|
|
64
79
|
|
|
65
|
-
Replace `<profile>` with your profile name: usually `desktop` for the desktop app and `web` for the web build.
|
|
66
|
-
|
|
67
80
|
From a local checkout (development):
|
|
68
81
|
|
|
69
82
|
```bash
|
|
@@ -88,7 +101,7 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
88
101
|
3. **Undo**: after applying, click Undo to restore; after closing the card, the undo bar remains above the composer.
|
|
89
102
|
4. **Close**: sending the draft closes the card automatically; Escape also closes it.
|
|
90
103
|
|
|
91
|
-
An empty or attachment-only draft dims the button and makes it unclickable; over-length
|
|
104
|
+
An empty or attachment-only draft dims the button and makes it unclickable; over-length drafts and drafts containing commands or file references are rejected locally. A result that hits the token cap is marked as possibly incomplete.
|
|
92
105
|
|
|
93
106
|
`/enhance <text>`: rewrite any text from the slash menu; the result is copyable and never enters model history.
|
|
94
107
|
|
|
@@ -123,7 +136,7 @@ An empty or attachment-only draft dims the button and starts no request; raise `
|
|
|
123
136
|
- **No model keys stored**: the plugin does not read or store model API keys; calls use the host's existing LLM configuration.
|
|
124
137
|
- **Context sent only when enabled**: with `contextAware` on, the most recent user/assistant text and the current draft are sent to the configured model provider (default: up to 8 messages and 4,000 characters); system messages, reasoning, tool results and attachments are excluded. With it off, only the draft is sent.
|
|
125
138
|
- **Sensitive conversations**: if the content must not leave the machine, turn off `contextAware` or use a local/private model route you trust.
|
|
126
|
-
- **Local tier cache**: the plugin caches "which reasoning tiers does this route declare"
|
|
139
|
+
- **Local tier cache**: the plugin caches "which reasoning tiers does this route declare" per provider/model under `$DSH_HOME/dsh-prompt-enhance/reasoning-efforts/` (`~/.dsh/…` when `DSH_HOME` is unset), and each entry expires and is re-probed after 30 days. The files hold only the provider, the model and the tier metadata — no API key, draft or conversation text. Refresh them from the settings page's tier-refresh control, or delete the directory.
|
|
127
140
|
|
|
128
141
|
## Troubleshooting
|
|
129
142
|
|
|
@@ -134,6 +147,7 @@ An empty or attachment-only draft dims the button and starts no request; raise `
|
|
|
134
147
|
| Truncated result | Check the truncation warning and raise `maxOutputTokens` in settings. |
|
|
135
148
|
| "No model resolved for enhancement" | Set both `provider` and `model` in settings, or send a message in the current session so the plugin can follow the session route. |
|
|
136
149
|
| Authentication failure | Check the provider credentials/API key configured in DSH. |
|
|
150
|
+
| `/enhance` shows only the first line and cannot be expanded | A rendering limit of the DSH chat UI, not this plugin: as of `@deepseek-ai/dsh-client-ui-chat` 0.2.2-rc.3, only results containing a newline get an expand control, so a single-line result is ellipsized with no way to open it. To read the whole result, put the same text in the composer and use the enhance button — the button's card wraps and scrolls. |
|
|
137
151
|
|
|
138
152
|
## Development
|
|
139
153
|
|
package/README.md
CHANGED
|
@@ -12,29 +12,42 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
## 为什么需要它
|
|
16
|
+
|
|
17
|
+
写提示词最费劲的往往不是想法,而是补成适合模型执行的样子:角色(助手扮演谁)、交付物(最终交付什么)、输出格式(结构、语言、长度与风格)、合格标准(怎样判断结果正确)。
|
|
18
|
+
|
|
19
|
+
本插件在输入框加入「提示词增强」按钮,点击即调用 harness LLM 服务生成规范提示词。
|
|
20
|
+
|
|
21
|
+
增强结果展示在对话框上方且不遮挡对话;不直接替换原文,可回填、复制、重新生成或撤销,原文安全。
|
|
22
|
+
|
|
23
|
+
开启上下文感知后参照最近几轮对话消解指代,自主理解任务需求。
|
|
24
|
+
|
|
25
|
+
## 功能一览
|
|
26
|
+
|
|
27
|
+
| 功能 | 说明 |
|
|
28
|
+
|---|---|
|
|
29
|
+
| 🐋 **一键增强** | 输入框工具栏按钮(左上角带星芒的 DeepSeek 鲸鱼标识);快捷键默认关闭,可在设置中指定 |
|
|
30
|
+
| 🖼️ **停靠结果卡** | 结果显示在输入框上方,不遮挡对话;附模型、耗时与 `token` 用量,超限时提示结果可能不完整 |
|
|
31
|
+
| ↩️ **回填、复制与撤销** | 回填后可直接撤销;关闭卡片后,输入框上方仍保留撤销条 |
|
|
32
|
+
| 🔄 **重新生成** | 按当前输入框内容再请求一版;回填后也可对增强稿继续生成 |
|
|
33
|
+
| 💬 **`/enhance` 命令** | 斜杠面板直接改写任意文本;结果不进入模型历史 |
|
|
34
|
+
| 🧭 **模型路由** | 设置中同时指定 `provider` 与 `model` 时优先;否则依次跟随当前会话模型、全局默认模型 |
|
|
35
|
+
| 🧩 **上下文感知** | `contextAware` 开启时参考最近几轮对话补全「它 / 这个」这类指代,可随时关闭 |
|
|
36
|
+
| 🔑 **零凭据配置** | 调用走 harness LLM 服务,密钥来自 harness 凭据存储;插件不读取也不保存 |
|
|
37
|
+
| 🛡️ **草稿安全** | 空输入、仅附件、超长、含命令或文件引用都在本地拦截,不发请求;上游失败映射为可读提示;失败绝不改动草稿 |
|
|
38
|
+
| ⚙️ **配置热生效** | 字段改完自动保存,常用项在前、其余收进「高级设置」;改动对下一次调用立即生效,无需重启 |
|
|
27
39
|
|
|
28
40
|
## 环境要求
|
|
29
41
|
|
|
30
|
-
| | |
|
|
42
|
+
| 项目 | 要求 |
|
|
31
43
|
|---|---|
|
|
32
|
-
| dsh | `>= 0.1.1-rc.2 < 0.3.0` |
|
|
44
|
+
| dsh | `>= 0.1.1-rc.2 < 0.3.0`,已在 `0.2.2-rc.3` 验证 |
|
|
33
45
|
| Node(仅源码构建) | `^22.19.0 \|\| >=24.0.0` |
|
|
34
|
-
| 插件 | `0.0.x` |
|
|
35
46
|
|
|
36
47
|
## 安装
|
|
37
48
|
|
|
49
|
+
装之前请确认包名。npm 上的 `dsh-prompt-enhance`(无 scope)是上游原项目,本插件是它的重写分支,包名是 `@surfishs/dsh-prompt-enhance`。本插件的安装源是本仓库 `surfishs/dsh-prompt-enhance`。**不要**执行 `dsh plugin add dsh-prompt-enhance`。
|
|
50
|
+
|
|
38
51
|
### 让 Agent 帮你安装
|
|
39
52
|
|
|
40
53
|
不用自己敲命令。把下面整段发给能操作本机终端的 Agent(DSH 桌面版、Web 版都可以):
|
|
@@ -56,14 +69,14 @@ dsh plugin --profile <profile> add @surfishs/dsh-prompt-enhance
|
|
|
56
69
|
# 重启 dsh
|
|
57
70
|
```
|
|
58
71
|
|
|
72
|
+
> `<profile>` 换成你的 profile 名:桌面版通常是 `desktop`,Web 版通常是 `web`。
|
|
73
|
+
|
|
59
74
|
从 GitHub 安装(`lib/` 已随仓库提交,无需本地构建):
|
|
60
75
|
|
|
61
76
|
```bash
|
|
62
77
|
dsh plugin --profile <profile> add github:surfishs/dsh-prompt-enhance
|
|
63
78
|
```
|
|
64
79
|
|
|
65
|
-
`<profile>` 换成你的 profile 名:桌面版通常是 `desktop`,Web 版通常是 `web`。
|
|
66
|
-
|
|
67
80
|
从本地检出(开发用):
|
|
68
81
|
|
|
69
82
|
```bash
|
|
@@ -88,7 +101,7 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
88
101
|
3. **撤销**:回填后点「撤销」恢复;关闭卡片后,输入框上方仍保留撤销条。
|
|
89
102
|
4. **关闭**:发送消息时卡片自动收起,按 `Esc` 也可以关闭。
|
|
90
103
|
|
|
91
|
-
|
|
104
|
+
输入为空或只有附件时,按钮会变灰、不可点;超长或含命令或文件引用会被本地拒绝。输出达到 Token 上限时,会提示结果可能不完整。
|
|
92
105
|
|
|
93
106
|
`/enhance <文本>`:从斜杠面板改写任意文本,结果可复制,不进入模型历史。
|
|
94
107
|
|
|
@@ -123,7 +136,7 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
123
136
|
- **不保存模型密钥**:插件不读取或存储模型 API key,调用走宿主已有的 LLM 配置。
|
|
124
137
|
- **上下文按需发送**:`contextAware` 开启时,最近几轮 user/assistant 文本和当前草稿会发给当前配置的模型服务商(默认最多 8 条消息、4000 字符);system、reasoning、工具结果和附件不会进入上下文。关闭后只发送草稿。
|
|
125
138
|
- **敏感会话**:如果内容不能外发,请关闭 `contextAware`,或改用你信任的本地/私有模型服务。
|
|
126
|
-
-
|
|
139
|
+
- **本机档位缓存**:插件会把「当前路由声明了哪些推理档位」的查询结果按 provider/model 分别缓存到 `$DSH_HOME/dsh-prompt-enhance/reasoning-efforts/` 目录(未设置 `DSH_HOME` 时为 `~/.dsh/…`),每条缓存 30 天后自动失效并重新探测。文件内容只有 provider、model 与档位信息,不含 API key、草稿或对话内容;也可在设置页点「重新获取档位」立即刷新,或直接删除该目录。
|
|
127
140
|
|
|
128
141
|
## 故障排查
|
|
129
142
|
|
|
@@ -134,6 +147,7 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
134
147
|
| 结果不完整 | 查看截断提示,并在设置中调高 `maxOutputTokens`。 |
|
|
135
148
|
| 提示「尚未确定增强用的模型」 | 在设置中成对填写 `provider` / `model`;或先在当前会话发一条消息,让插件跟随会话模型。 |
|
|
136
149
|
| 鉴权失败 | 检查对应 provider 在 DSH 中的凭据/API Key 是否有效。 |
|
|
150
|
+
| `/enhance` 的结果只显示第一行、点不开 | 这是 DSH 聊天界面的渲染限制,与本插件无关:截至 `@deepseek-ai/dsh-client-ui-chat` 0.2.2-rc.3,只有含换行的结果才提供展开,单行结果会被省略号截断且没有入口。要看全文,把同样的文本放进输入框、用增强按钮——按钮的结果卡会自动折行并可滚动。 |
|
|
137
151
|
|
|
138
152
|
## 开发
|
|
139
153
|
|
|
Binary file
|
package/docs/images/panel.png
CHANGED
|
Binary file
|
package/icon.svg
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
|
|
2
|
+
<!-- DeepSeek whale with a four-point sparkle at its upper-left corner.
|
|
3
|
+
Arrangement: the whale and the star share one rigid shift, the star is
|
|
4
|
+
scaled to 0.72 and sits further out of the whale's silhouette. The pair is
|
|
5
|
+
drawn at 1.2027 of that arrangement and centred on its ink mass, so the
|
|
6
|
+
glyph fills 94% of this canvas and reads centred instead of drifting to
|
|
7
|
+
the lower right. The star tip keeps a 0.10-unit margin, which leaves the
|
|
8
|
+
mass 0.6 units right of dead centre - invisible at row size, and the
|
|
9
|
+
alternative would clip the tip.
|
|
10
|
+
src/client/SparkleFishIcon.tsx draws the composer mark in its own 26x20
|
|
11
|
+
glyph box; keep the two in sync when the mark changes. -->
|
|
12
|
+
<path d="M22.9168 1.43018C22.6713 1.31018 22.5658 1.53918 22.4223 1.65519C22.3733 1.69269 22.3318 1.74169 22.2903 1.78669C21.9317 2.1697 21.5127 2.42121 20.9657 2.39121C20.1657 2.34621 19.4827 2.59771 18.8787 3.20973C18.7502 2.45521 18.3236 2.0047 17.6746 1.71569C17.3351 1.56568 16.9916 1.41518 16.7536 1.08867C16.5876 0.856163 16.5421 0.597155 16.4591 0.341647C16.4061 0.187643 16.3536 0.0301382 16.1761 0.00363739C15.9836 -0.0263635 15.9081 0.135141 15.8326 0.270145C15.5306 0.822162 15.4136 1.43018 15.4251 2.0462C15.4516 3.43174 16.0366 4.53527 17.1991 5.3203C17.3311 5.4103 17.3651 5.5003 17.3236 5.63181C17.2441 5.90231 17.1501 6.16482 17.0671 6.43533C17.0141 6.60784 16.9351 6.64584 16.7501 6.57033C16.1121 6.30383 15.5611 5.90931 15.074 5.4328C14.2475 4.63328 13.5 3.75075 12.568 3.05973C12.349 2.89822 12.13 2.74822 11.9034 2.60522C10.9524 1.68169 12.028 0.923165 12.277 0.833162C12.5375 0.739159 12.3675 0.41615 11.5259 0.42015C10.6844 0.42365 9.91439 0.705658 8.93286 1.08117C8.78935 1.13767 8.63835 1.17867 8.48384 1.21267C7.59332 1.04367 6.66829 1.00617 5.70226 1.11517C3.88321 1.31768 2.43016 2.1777 1.36213 3.64575C0.0790928 5.4103 -0.222916 7.41536 0.146595 9.50642C0.535106 11.7105 1.66014 13.535 3.38869 14.9616C5.18125 16.4406 7.24581 17.1657 9.60138 17.0266C11.0319 16.9441 12.6245 16.7526 14.421 15.2321C14.874 15.4576 15.3496 15.5476 16.1381 15.6151C16.7456 15.6716 17.3306 15.5851 17.7836 15.4911C18.4931 15.3411 18.4441 14.6841 18.1876 14.5636C16.1081 13.595 16.5646 13.9891 16.1496 13.67C17.2061 12.42 18.8202 10.1979 19.3182 7.17235C19.3672 6.83834 19.4297 6.36783 19.4222 6.09732C19.4182 5.93231 19.4562 5.86831 19.6447 5.84931C20.1657 5.78931 20.6712 5.64681 21.1357 5.3913C22.4833 4.65528 23.0268 3.44624 23.1548 1.9972C23.1738 1.77569 23.1508 1.54668 22.9168 1.43018ZM11.1749 14.4736C9.15936 12.889 8.18184 12.3675 7.77832 12.39C7.40081 12.4125 7.46881 12.8445 7.55182 13.126C7.63882 13.404 7.75182 13.5955 7.91033 13.8396C8.01983 14.0011 8.09533 14.2411 7.80083 14.4216C7.15181 14.8231 6.02327 14.2866 5.97027 14.2601C4.65673 13.4865 3.5587 12.4655 2.78467 11.069C2.03715 9.72493 1.60314 8.28289 1.53164 6.74384C1.51264 6.37233 1.62214 6.24082 1.99215 6.17332C2.47916 6.08332 2.98118 6.06432 3.46769 6.13582C5.52476 6.43633 7.27581 7.35586 8.74385 8.8129C9.58188 9.64243 10.2159 10.634 10.8689 11.6025C11.5634 12.631 12.3105 13.611 13.262 14.4146C13.598 14.6961 13.866 14.9101 14.1225 15.0681C13.349 15.1546 12.058 15.1731 11.1749 14.4746L11.1749 14.4736ZM12.141 8.25988C12.141 8.09488 12.273 7.96338 12.439 7.96338C12.4765 7.96338 12.5105 7.97088 12.541 7.98188C12.5825 7.99688 12.6205 8.01938 12.6505 8.05338C12.7035 8.10588 12.7335 8.18088 12.7335 8.25988C12.7335 8.42489 12.6015 8.55639 12.4355 8.55639C12.2695 8.55639 12.141 8.42489 12.141 8.25988ZM15.1415 9.79893C14.949 9.87793 14.7565 9.94544 14.5715 9.95294C14.2845 9.96794 13.9715 9.85143 13.8015 9.70893C13.5375 9.48742 13.3485 9.36342 13.2695 8.97691C13.2355 8.8119 13.2545 8.55639 13.2845 8.40989C13.3525 8.09438 13.277 7.89187 13.0545 7.70787C12.8735 7.55786 12.643 7.51636 12.39 7.51636C12.2955 7.51636 12.209 7.47486 12.1445 7.44136C12.039 7.38886 11.9519 7.25735 12.035 7.09585C12.0615 7.04335 12.19 6.91584 12.22 6.89334C12.5635 6.69784 12.9595 6.76184 13.326 6.90834C13.6655 7.04735 13.9225 7.30236 14.292 7.66287C14.6695 8.09838 14.7375 8.21838 14.9525 8.54539C15.1225 8.8009 15.277 9.06341 15.3831 9.36392C15.4471 9.55142 15.3641 9.70493 15.1415 9.79893Z" transform="translate(7.7334 9.8278) scale(1.13114)" fill="#1C1E24"/>
|
|
13
|
+
<path d="M5.715 0 L7.2 4.2 L11.43 5.715 L7.2 7.2 L5.715 11.43 L4.2 7.2 L0 5.715 L4.2 4.2 Z" transform="translate(0.0921 4.7040) scale(0.86594)" fill="#1C1E24"/>
|
|
14
|
+
</svg>
|
package/lib/client.js
CHANGED
|
@@ -118,7 +118,13 @@ function parseResult(value) {
|
|
|
118
118
|
provider: record.provider,
|
|
119
119
|
model: record.model,
|
|
120
120
|
elapsedMs: record.elapsedMs,
|
|
121
|
-
...usage === void 0 ? {} : { usage }
|
|
121
|
+
...usage === void 0 ? {} : { usage },
|
|
122
|
+
// Carried explicitly, not optional-by-accident: the panel's "output hit
|
|
123
|
+
// the token cap" warning is driven by this flag alone, so rebuilding the
|
|
124
|
+
// object without it left the host setting it, the wire carrying it, and
|
|
125
|
+
// the UI never seeing it. Only `true` is ever normalized in, matching the
|
|
126
|
+
// host, which sets the field solely on a capped finish.
|
|
127
|
+
...record.truncated === true ? { truncated: true } : {}
|
|
122
128
|
};
|
|
123
129
|
}
|
|
124
130
|
throw new EnhanceClientError({ code: "internal", params: { reason: "malformed" } });
|
|
@@ -249,11 +255,13 @@ async function requestEnhance(body, signal) {
|
|
|
249
255
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
250
256
|
var FISH_PATH = "M22.9168 1.43018C22.6713 1.31018 22.5658 1.53918 22.4223 1.65519C22.3733 1.69269 22.3318 1.74169 22.2903 1.78669C21.9317 2.1697 21.5127 2.42121 20.9657 2.39121C20.1657 2.34621 19.4827 2.59771 18.8787 3.20973C18.7502 2.45521 18.3236 2.0047 17.6746 1.71569C17.3351 1.56568 16.9916 1.41518 16.7536 1.08867C16.5876 0.856163 16.5421 0.597155 16.4591 0.341647C16.4061 0.187643 16.3536 0.0301382 16.1761 0.00363739C15.9836 -0.0263635 15.9081 0.135141 15.8326 0.270145C15.5306 0.822162 15.4136 1.43018 15.4251 2.0462C15.4516 3.43174 16.0366 4.53527 17.1991 5.3203C17.3311 5.4103 17.3651 5.5003 17.3236 5.63181C17.2441 5.90231 17.1501 6.16482 17.0671 6.43533C17.0141 6.60784 16.9351 6.64584 16.7501 6.57033C16.1121 6.30383 15.5611 5.90931 15.074 5.4328C14.2475 4.63328 13.5 3.75075 12.568 3.05973C12.349 2.89822 12.13 2.74822 11.9034 2.60522C10.9524 1.68169 12.028 0.923165 12.277 0.833162C12.5375 0.739159 12.3675 0.41615 11.5259 0.42015C10.6844 0.42365 9.91439 0.705658 8.93286 1.08117C8.78935 1.13767 8.63835 1.17867 8.48384 1.21267C7.59332 1.04367 6.66829 1.00617 5.70226 1.11517C3.88321 1.31768 2.43016 2.1777 1.36213 3.64575C0.0790928 5.4103 -0.222916 7.41536 0.146595 9.50642C0.535106 11.7105 1.66014 13.535 3.38869 14.9616C5.18125 16.4406 7.24581 17.1657 9.60138 17.0266C11.0319 16.9441 12.6245 16.7526 14.421 15.2321C14.874 15.4576 15.3496 15.5476 16.1381 15.6151C16.7456 15.6716 17.3306 15.5851 17.7836 15.4911C18.4931 15.3411 18.4441 14.6841 18.1876 14.5636C16.1081 13.595 16.5646 13.9891 16.1496 13.67C17.2061 12.42 18.8202 10.1979 19.3182 7.17235C19.3672 6.83834 19.4297 6.36783 19.4222 6.09732C19.4182 5.93231 19.4562 5.86831 19.6447 5.84931C20.1657 5.78931 20.6712 5.64681 21.1357 5.3913C22.4833 4.65528 23.0268 3.44624 23.1548 1.9972C23.1738 1.77569 23.1508 1.54668 22.9168 1.43018ZM11.1749 14.4736C9.15936 12.889 8.18184 12.3675 7.77832 12.39C7.40081 12.4125 7.46881 12.8445 7.55182 13.126C7.63882 13.404 7.75182 13.5955 7.91033 13.8396C8.01983 14.0011 8.09533 14.2411 7.80083 14.4216C7.15181 14.8231 6.02327 14.2866 5.97027 14.2601C4.65673 13.4865 3.5587 12.4655 2.78467 11.069C2.03715 9.72493 1.60314 8.28289 1.53164 6.74384C1.51264 6.37233 1.62214 6.24082 1.99215 6.17332C2.47916 6.08332 2.98118 6.06432 3.46769 6.13582C5.52476 6.43633 7.27581 7.35586 8.74385 8.8129C9.58188 9.64243 10.2159 10.634 10.8689 11.6025C11.5634 12.631 12.3105 13.611 13.262 14.4146C13.598 14.6961 13.866 14.9101 14.1225 15.0681C13.349 15.1546 12.058 15.1731 11.1749 14.4746L11.1749 14.4736ZM12.141 8.25988C12.141 8.09488 12.273 7.96338 12.439 7.96338C12.4765 7.96338 12.5105 7.97088 12.541 7.98188C12.5825 7.99688 12.6205 8.01938 12.6505 8.05338C12.7035 8.10588 12.7335 8.18088 12.7335 8.25988C12.7335 8.42489 12.6015 8.55639 12.4355 8.55639C12.2695 8.55639 12.141 8.42489 12.141 8.25988ZM15.1415 9.79893C14.949 9.87793 14.7565 9.94544 14.5715 9.95294C14.2845 9.96794 13.9715 9.85143 13.8015 9.70893C13.5375 9.48742 13.3485 9.36342 13.2695 8.97691C13.2355 8.8119 13.2545 8.55639 13.2845 8.40989C13.3525 8.09438 13.277 7.89187 13.0545 7.70787C12.8735 7.55786 12.643 7.51636 12.39 7.51636C12.2955 7.51636 12.209 7.47486 12.1445 7.44136C12.039 7.38886 11.9519 7.25735 12.035 7.09585C12.0615 7.04335 12.19 6.91584 12.22 6.89334C12.5635 6.69784 12.9595 6.76184 13.326 6.90834C13.6655 7.04735 13.9225 7.30236 14.292 7.66287C14.6695 8.09838 14.7375 8.21838 14.9525 8.54539C15.1225 8.8009 15.277 9.06341 15.3831 9.36392C15.4471 9.55142 15.3641 9.70493 15.1415 9.79893Z";
|
|
251
257
|
var STAR_PATH = "M5.715 0 L7.2 4.2 L11.43 5.715 L7.2 7.2 L5.715 11.43 L4.2 7.2 L0 5.715 L4.2 4.2 Z";
|
|
258
|
+
var FISH_TRANSFORM = "translate(6.4976 4.3528) scale(0.78502)";
|
|
259
|
+
var STAR_TRANSFORM = "translate(1.1944 0.7969) scale(0.60097)";
|
|
252
260
|
function SparkleFishIcon(props) {
|
|
253
261
|
const size = props.size ?? 15;
|
|
254
262
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: size * 1.3, height: size, viewBox: "0 0 26 20", fill: "none", "aria-hidden": "true", focusable: "false", style: { display: "block", flexShrink: 0 }, children: [
|
|
255
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform:
|
|
256
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: STAR_PATH, transform:
|
|
263
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: FISH_TRANSFORM, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: FISH_PATH, fill: "currentColor" }) }),
|
|
264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: STAR_PATH, transform: STAR_TRANSFORM, fill: "currentColor" }),
|
|
257
265
|
props.spinning === true ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("animate", { attributeName: "opacity", values: "1;0.35;1", dur: "1.1s", repeatCount: "indefinite" }) : null
|
|
258
266
|
] });
|
|
259
267
|
}
|
|
@@ -512,8 +520,9 @@ function serverSessionId(maybeSessionId) {
|
|
|
512
520
|
|
|
513
521
|
// src/client/EnhanceButton.tsx
|
|
514
522
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
515
|
-
|
|
516
|
-
|
|
523
|
+
var OCCURRENCES_UNKNOWN = -1;
|
|
524
|
+
function occurrenceCountOf(value) {
|
|
525
|
+
return Array.isArray(value) ? value.length : OCCURRENCES_UNKNOWN;
|
|
517
526
|
}
|
|
518
527
|
function stringOf(value) {
|
|
519
528
|
return typeof value === "string" ? value : "";
|
|
@@ -524,7 +533,7 @@ function EnhanceButton(props) {
|
|
|
524
533
|
const wireId = serverSessionId(sessionId);
|
|
525
534
|
const draft = useInput((state) => stringOf(state.draft));
|
|
526
535
|
const phase = useInput((state) => state.phase);
|
|
527
|
-
const occurrenceCount = useInput((state) =>
|
|
536
|
+
const occurrenceCount = useInput((state) => occurrenceCountOf(state.occurrences));
|
|
528
537
|
const settings = (0, import_react2.useSyncExternalStore)(subscribeClientSettings, getClientSettings);
|
|
529
538
|
const panel = (0, import_react2.useSyncExternalStore)(subscribe, getPanel);
|
|
530
539
|
const rootRef = (0, import_react2.useRef)(null);
|
|
@@ -547,6 +556,11 @@ function EnhanceButton(props) {
|
|
|
547
556
|
openError(uiKey, source, { code: "rejected", localized: message });
|
|
548
557
|
return;
|
|
549
558
|
}
|
|
559
|
+
if (occurrenceCount === OCCURRENCES_UNKNOWN) {
|
|
560
|
+
const unknown = t("error.chipsUnknown");
|
|
561
|
+
openError(uiKey, source, { code: "rejected", localized: unknown });
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
550
564
|
if (occurrenceCount > 0) {
|
|
551
565
|
const occurrences = t("error.occurrences");
|
|
552
566
|
openError(uiKey, source, { code: "rejected", localized: occurrences });
|
|
@@ -600,6 +614,7 @@ function EnhanceButton(props) {
|
|
|
600
614
|
{
|
|
601
615
|
ref: rootRef,
|
|
602
616
|
type: "button",
|
|
617
|
+
"data-dsh-pe-key": uiKey,
|
|
603
618
|
className: `dsh-pe-btn${busy ? " is-busy" : ""}${otherBusy && !empty ? " is-blocked" : ""}${empty && !busy ? " is-empty" : ""}`,
|
|
604
619
|
title: busy ? t("button.busy") : otherBusy ? t("button.otherBusy") : empty ? t("button.emptyTitle") : t("button.title"),
|
|
605
620
|
"aria-label": busy ? t("button.busy") : otherBusy ? t("button.otherBusy") : empty ? t("button.emptyTitle") : t("button.title"),
|
|
@@ -827,44 +842,81 @@ function ResultPanel(props) {
|
|
|
827
842
|
|
|
828
843
|
// src/client/useDockAlignment.ts
|
|
829
844
|
var import_react4 = require("react");
|
|
830
|
-
|
|
845
|
+
var EDITOR_SELECTOR = 'textarea, [contenteditable="true"], [role="textbox"]';
|
|
846
|
+
var SESSION_ANCHOR_ATTRIBUTE = "data-dsh-pe-key";
|
|
847
|
+
var CARD_MIN_WIDTH = 360;
|
|
848
|
+
var CARD_MIN_HEIGHT = 48;
|
|
849
|
+
var CARD_MIN_RADIUS = 4;
|
|
850
|
+
var CARD_MAX_DEPTH = 12;
|
|
851
|
+
var CARD_MAX_VIEWPORT_SHARE = 0.8;
|
|
852
|
+
var CARD_CENTER_TOLERANCE = 40;
|
|
853
|
+
var EDITOR_BELOW_SLACK = 4;
|
|
854
|
+
function isCardSurface(node, minWidth) {
|
|
855
|
+
const rect = node.getBoundingClientRect();
|
|
856
|
+
if (rect.width < minWidth || rect.width <= CARD_MIN_WIDTH || rect.height <= CARD_MIN_HEIGHT) return false;
|
|
857
|
+
const style = getComputedStyle(node);
|
|
858
|
+
return (parseFloat(style.borderTopLeftRadius) || 0) >= CARD_MIN_RADIUS && style.backgroundColor !== "rgba(0, 0, 0, 0)";
|
|
859
|
+
}
|
|
860
|
+
function cardAround(start) {
|
|
861
|
+
let node = start.parentElement;
|
|
862
|
+
for (let depth = 0; depth < CARD_MAX_DEPTH && node !== null; depth++) {
|
|
863
|
+
if (isCardSurface(node, 0)) return node.getBoundingClientRect();
|
|
864
|
+
node = node.parentElement;
|
|
865
|
+
}
|
|
866
|
+
return void 0;
|
|
867
|
+
}
|
|
868
|
+
function editorsIn(scope) {
|
|
869
|
+
return Array.from(scope.querySelectorAll(EDITOR_SELECTOR));
|
|
870
|
+
}
|
|
871
|
+
function useDockAlignment(active, uiKey) {
|
|
831
872
|
const rootRef = (0, import_react4.useRef)(null);
|
|
832
873
|
(0, import_react4.useEffect)(() => {
|
|
833
874
|
if (!active) return;
|
|
834
875
|
const root = rootRef.current;
|
|
835
876
|
if (root === null) return;
|
|
836
877
|
let frame = 0;
|
|
837
|
-
const
|
|
838
|
-
const parent = root.parentElement;
|
|
839
|
-
if (parent === null) return;
|
|
840
|
-
root.style.transform = "";
|
|
841
|
-
const rootRect = root.getBoundingClientRect();
|
|
842
|
-
const editors = Array.from(document.querySelectorAll('textarea, [contenteditable="true"], [role="textbox"]'));
|
|
843
|
-
const editor = editors.find((node2) => {
|
|
844
|
-
const rect = node2.getBoundingClientRect();
|
|
845
|
-
return rect.width > 0 && rect.height > 0 && rect.top >= rootRect.bottom - 4;
|
|
846
|
-
});
|
|
847
|
-
if (editor === void 0) {
|
|
848
|
-
root.style.width = "";
|
|
849
|
-
root.style.marginLeft = "";
|
|
850
|
-
root.style.transform = "";
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
878
|
+
const cardFromEditor = (editor) => {
|
|
853
879
|
const editorRect = editor.getBoundingClientRect();
|
|
854
880
|
const candidates = [];
|
|
855
881
|
let node = editor;
|
|
856
|
-
for (let depth = 0; depth <
|
|
857
|
-
|
|
858
|
-
const style = getComputedStyle(node);
|
|
859
|
-
if (rect.width >= editorRect.width && rect.width > 360 && rect.height > 48 && (parseFloat(style.borderTopLeftRadius) || 0) >= 4 && style.backgroundColor !== "rgba(0, 0, 0, 0)") {
|
|
860
|
-
candidates.push({ node, rect });
|
|
861
|
-
}
|
|
882
|
+
for (let depth = 0; depth < CARD_MAX_DEPTH && node !== null; depth++) {
|
|
883
|
+
if (isCardSurface(node, editorRect.width)) candidates.push(node.getBoundingClientRect());
|
|
862
884
|
node = node.parentElement;
|
|
863
885
|
}
|
|
886
|
+
const widest = (list) => list.sort((a, b) => b.width - a.width)[0];
|
|
887
|
+
if (candidates.length === 0) return void 0;
|
|
864
888
|
const editorCenter = editorRect.left + editorRect.width / 2;
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
|
|
889
|
+
const centered = candidates.filter((rect) => rect.width <= window.innerWidth * CARD_MAX_VIEWPORT_SHARE && Math.abs(rect.left + rect.width / 2 - editorCenter) < CARD_CENTER_TOLERANCE);
|
|
890
|
+
return widest(centered) ?? widest(candidates);
|
|
891
|
+
};
|
|
892
|
+
const editorBelow = (scope, rootRect) => editorsIn(scope).find((node) => {
|
|
893
|
+
const rect = node.getBoundingClientRect();
|
|
894
|
+
return rect.width > 0 && rect.height > 0 && rect.top >= rootRect.bottom - EDITOR_BELOW_SLACK;
|
|
895
|
+
});
|
|
896
|
+
const cardForThisEntry = () => {
|
|
897
|
+
if (uiKey !== void 0) {
|
|
898
|
+
const anchor = Array.from(document.querySelectorAll(`[${SESSION_ANCHOR_ATTRIBUTE}]`)).find((node) => node.getAttribute(SESSION_ANCHOR_ATTRIBUTE) === uiKey);
|
|
899
|
+
if (anchor !== void 0) {
|
|
900
|
+
const anchored = cardAround(anchor);
|
|
901
|
+
if (anchored !== void 0) return anchored;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
const rootRect = root.getBoundingClientRect();
|
|
905
|
+
const parent = root.parentElement;
|
|
906
|
+
const scoped = parent === null ? void 0 : editorBelow(parent, rootRect);
|
|
907
|
+
if (scoped !== void 0) {
|
|
908
|
+
const rect = cardFromEditor(scoped);
|
|
909
|
+
if (rect !== void 0) return rect;
|
|
910
|
+
}
|
|
911
|
+
const anywhere = editorBelow(document, rootRect);
|
|
912
|
+
return anywhere === void 0 ? void 0 : cardFromEditor(anywhere);
|
|
913
|
+
};
|
|
914
|
+
const apply2 = (cardRect) => {
|
|
915
|
+
if (cardRect === void 0) {
|
|
916
|
+
root.style.width = "";
|
|
917
|
+
root.style.marginLeft = "";
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
868
920
|
const width = `${cardRect.width}px`;
|
|
869
921
|
if (root.style.width !== width) root.style.width = width;
|
|
870
922
|
const afterWidth = root.getBoundingClientRect();
|
|
@@ -872,6 +924,10 @@ function useDockAlignment(active) {
|
|
|
872
924
|
const marginLeft = `${cardRect.left - (afterWidth.left - currentMargin)}px`;
|
|
873
925
|
if (root.style.marginLeft !== marginLeft) root.style.marginLeft = marginLeft;
|
|
874
926
|
};
|
|
927
|
+
const align = () => {
|
|
928
|
+
root.style.transform = "";
|
|
929
|
+
apply2(cardForThisEntry());
|
|
930
|
+
};
|
|
875
931
|
const schedule = () => {
|
|
876
932
|
cancelAnimationFrame(frame);
|
|
877
933
|
frame = requestAnimationFrame(align);
|
|
@@ -886,7 +942,7 @@ function useDockAlignment(active) {
|
|
|
886
942
|
window.removeEventListener("resize", schedule);
|
|
887
943
|
observer?.disconnect();
|
|
888
944
|
};
|
|
889
|
-
}, [active]);
|
|
945
|
+
}, [active, uiKey]);
|
|
890
946
|
return rootRef;
|
|
891
947
|
}
|
|
892
948
|
|
|
@@ -896,7 +952,7 @@ function ResultDock(props) {
|
|
|
896
952
|
const { t, sessionId, useInput, inputActions } = props;
|
|
897
953
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
898
954
|
const panel = (0, import_react5.useSyncExternalStore)(subscribe, getPanel);
|
|
899
|
-
const rootRef = useDockAlignment(panel !== void 0 && panel.sessionId === uiKey);
|
|
955
|
+
const rootRef = useDockAlignment(panel !== void 0 && panel.sessionId === uiKey, uiKey);
|
|
900
956
|
const [undone, setUndone] = (0, import_react5.useState)(false);
|
|
901
957
|
const [regenerated, setRegenerated] = (0, import_react5.useState)(false);
|
|
902
958
|
const [pendingRegenerate, setPendingRegenerate] = (0, import_react5.useState)(false);
|
|
@@ -1025,7 +1081,7 @@ function UndoBar(props) {
|
|
|
1025
1081
|
}, [draft, entry, uiKey]);
|
|
1026
1082
|
const panel = getPanel();
|
|
1027
1083
|
const visible = (panel === void 0 || panel.sessionId !== uiKey) && entry !== void 0 && entry.applied === draft;
|
|
1028
|
-
const rootRef = useDockAlignment(visible);
|
|
1084
|
+
const rootRef = useDockAlignment(visible, uiKey);
|
|
1029
1085
|
if (!visible) return null;
|
|
1030
1086
|
const undo = () => {
|
|
1031
1087
|
inputActions.setDraft(entry.original);
|
|
@@ -1083,8 +1139,8 @@ var zh = {
|
|
|
1083
1139
|
"undo.dismiss": "\u5173\u95ED\u63D0\u793A",
|
|
1084
1140
|
"error.empty": "\u8F93\u5165\u6846\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u8F93\u5165\u8981\u589E\u5F3A\u7684\u63D0\u793A\u8BCD\u3002",
|
|
1085
1141
|
"error.tooLong": "\u5185\u5BB9\u5171 {count} \u4E2A\u5B57\u7B26\uFF0C\u8D85\u8FC7 {max} \u4E2A\u5B57\u7B26\u4E0A\u9650\uFF08\u6309 Unicode \u5B57\u7B26\u6570\u7EDF\u8BA1\uFF0C\u4E0D\u662F token \u6570\uFF09\u3002\u4E3A\u907F\u514D\u6539\u53D8\u539F\u610F\u4E0D\u4F1A\u81EA\u52A8\u622A\u65AD\uFF0C\u8BF7\u7CBE\u7B80\u540E\u518D\u8BD5\u3002",
|
|
1086
|
-
"error.attachmentsOnly": "\u8F93\u5165\u6846\u53EA\u9644\u52A0\u4E86\u9644\u4EF6\uFF08\u56FE\u7247\u6216\u6587\u4EF6\uFF09\uFF0C\u8BF7\u8865\u5145\u8981\u589E\u5F3A\u7684\u6587\u672C\u3002",
|
|
1087
1142
|
"error.occurrences": "\u8F93\u5165\u5185\u5BB9\u5305\u542B\u547D\u4EE4\u6216\u6587\u4EF6\u5F15\u7528\uFF0C\u6682\u4E0D\u652F\u6301\u589E\u5F3A\uFF1B\u8BF7\u5148\u79FB\u9664\u540E\u518D\u8BD5\u3002",
|
|
1143
|
+
"error.chipsUnknown": "\u65E0\u6CD5\u8BFB\u53D6\u8F93\u5165\u6846\u7684\u5F15\u7528\u72B6\u6001\uFF08\u5BBF\u4E3B\u672A\u63D0\u4F9B\u5F15\u7528\u4FE1\u606F\uFF09\u3002\u4E3A\u907F\u514D\u8986\u76D6\u5DF2\u6DFB\u52A0\u7684\u547D\u4EE4\u6216\u6587\u4EF6\u5F15\u7528\uFF0C\u672C\u6B21\u589E\u5F3A\u5DF2\u963B\u6B62\uFF1B\u8BF7\u6E05\u7A7A\u8F93\u5165\u6846\u540E\u8F93\u5165\u7EAF\u6587\u672C\u8349\u7A3F\uFF0C\u6216\u5347\u7EA7 DSH \u540E\u91CD\u8BD5\u3002",
|
|
1088
1144
|
"error.phase": "\u5F53\u524D\u8F93\u5165\u6B63\u88AB\u5360\u7528\uFF08\u63D0\u4EA4\u4E2D\uFF09\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
1089
1145
|
"error.disabled": "\u63D0\u793A\u8BCD\u589E\u5F3A\u5DF2\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u5173\u95ED\u3002",
|
|
1090
1146
|
"error.rejected": "\u589E\u5F3A\u8BF7\u6C42\u88AB\u62D2\u7EDD\u3002",
|
|
@@ -1182,7 +1238,7 @@ var zh = {
|
|
|
1182
1238
|
"settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
|
|
1183
1239
|
"settings.reasoning.inherit": "\u63D0\u4F9B\u65B9\u9ED8\u8BA4",
|
|
1184
1240
|
"settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
|
|
1185
|
-
"settings.reasoning.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\
|
|
1241
|
+
"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",
|
|
1186
1242
|
"settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\uFF0C\u8C03\u7528\u65F6\u5C06\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u3002",
|
|
1187
1243
|
"settings.reasoning.unsupported": "\u5F53\u524D\u503C\u300C{effort}\u300D\u4E0D\u5728\u8BE5\u6A21\u578B\u652F\u6301\u7684\u6863\u4F4D\u4E2D\u3002",
|
|
1188
1244
|
"settings.reasoning.current": "\u5F53\u524D\u503C\uFF1A{value}",
|
|
@@ -1229,8 +1285,8 @@ var en = {
|
|
|
1229
1285
|
"undo.dismiss": "Dismiss",
|
|
1230
1286
|
"error.empty": "The input box is empty \u2014 type a prompt to enhance first.",
|
|
1231
1287
|
"error.tooLong": "The draft is {count} characters, above the {max} cap (Unicode characters, not tokens). It is never auto-truncated (that would change your meaning) \u2014 please shorten it.",
|
|
1232
|
-
"error.attachmentsOnly": "The composer only has attachments; add the text you want enhanced.",
|
|
1233
1288
|
"error.occurrences": "The draft contains commands or file references, which are not supported yet \u2014 remove them first.",
|
|
1289
|
+
"error.chipsUnknown": "The composer reference state could not be read on this host, so the enhancement was blocked to avoid overwriting a command or file reference. Clear the input box and type plain text, or update DSH, then retry.",
|
|
1234
1290
|
"error.phase": "The input box is busy (submitting) \u2014 try again in a moment.",
|
|
1235
1291
|
"error.disabled": "Prompt enhance is disabled in the plugin settings.",
|
|
1236
1292
|
"error.rejected": "The enhance request was rejected.",
|
|
@@ -1328,7 +1384,7 @@ var en = {
|
|
|
1328
1384
|
"settings.strategy.extend": "Append after the built-in strategy",
|
|
1329
1385
|
"settings.reasoning.inherit": "Provider default",
|
|
1330
1386
|
"settings.reasoning.loading": "Reading this model\u2019s tiers\u2026",
|
|
1331
|
-
"settings.reasoning.unavailable": "Could not read this model\u2019s
|
|
1387
|
+
"settings.reasoning.unavailable": "Could not read this model\u2019s tier list; your saved tier is still sent.",
|
|
1332
1388
|
"settings.reasoning.noTiers": "This model declares no reasoning tiers; calls follow the provider default.",
|
|
1333
1389
|
"settings.reasoning.unsupported": "The current value \u201C{effort}\u201D is not one of this model\u2019s tiers.",
|
|
1334
1390
|
"settings.reasoning.current": "Current value: {value}",
|
|
@@ -1347,16 +1403,19 @@ var CSS = `
|
|
|
1347
1403
|
.dsh-pe-dock { width: 100%; }
|
|
1348
1404
|
.dsh-pe-panel {
|
|
1349
1405
|
box-sizing: border-box;
|
|
1350
|
-
--pe-bg: #1f2127;
|
|
1351
|
-
--pe-fg: #e6e8ee;
|
|
1352
|
-
--pe-fg-dim: rgba(230, 232, 238, 0.55);
|
|
1353
|
-
--pe-border: rgba(127, 127, 127, 0.35);
|
|
1354
|
-
--pe-separator: rgba(127, 127, 127, 0.25);
|
|
1406
|
+
--pe-bg: var(--dsw-alias-bg-layer-1, #1f2127);
|
|
1407
|
+
--pe-fg: var(--dsw-alias-label-primary, #e6e8ee);
|
|
1408
|
+
--pe-fg-dim: var(--dsw-alias-label-secondary, rgba(230, 232, 238, 0.55));
|
|
1409
|
+
--pe-border: var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.35));
|
|
1410
|
+
--pe-separator: var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.25));
|
|
1411
|
+
/* No hover token exists: a neutral grey alpha is already theme-agnostic. */
|
|
1355
1412
|
--pe-hover: rgba(127, 127, 127, 0.18);
|
|
1356
|
-
--pe-danger: #ffb4a8;
|
|
1357
|
-
--pe-warn-fg: #e8c07d;
|
|
1358
|
-
|
|
1359
|
-
|
|
1413
|
+
--pe-danger: var(--dsw-alias-state-error-primary, #ffb4a8);
|
|
1414
|
+
--pe-warn-fg: var(--dsw-alias-state-warn-primary, #e8c07d);
|
|
1415
|
+
/* Tints of the themed warning color, so the banner cannot keep an amber cast
|
|
1416
|
+
from the other scheme. */
|
|
1417
|
+
--pe-warn-border: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 35%, transparent);
|
|
1418
|
+
--pe-warn-bg: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e8c07d) 12%, transparent);
|
|
1360
1419
|
display: flex;
|
|
1361
1420
|
flex-direction: column;
|
|
1362
1421
|
width: 100%;
|
|
@@ -1368,20 +1427,6 @@ var CSS = `
|
|
|
1368
1427
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 14px rgba(0, 0, 0, 0.05);
|
|
1369
1428
|
overflow: hidden;
|
|
1370
1429
|
}
|
|
1371
|
-
@media (prefers-color-scheme: light) {
|
|
1372
|
-
.dsh-pe-panel {
|
|
1373
|
-
--pe-bg: #ffffff;
|
|
1374
|
-
--pe-fg: #1c1e24;
|
|
1375
|
-
--pe-fg-dim: rgba(28, 30, 36, 0.55);
|
|
1376
|
-
--pe-border: rgba(0, 0, 0, 0.18);
|
|
1377
|
-
--pe-separator: rgba(0, 0, 0, 0.12);
|
|
1378
|
-
--pe-hover: rgba(0, 0, 0, 0.08);
|
|
1379
|
-
--pe-danger: #a63a2e;
|
|
1380
|
-
--pe-warn-fg: #8a5a00;
|
|
1381
|
-
--pe-warn-border: rgba(176, 122, 0, 0.4);
|
|
1382
|
-
--pe-warn-bg: rgba(230, 158, 60, 0.15);
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
1430
|
.dsh-pe-head {
|
|
1386
1431
|
display: flex;
|
|
1387
1432
|
align-items: center;
|
|
@@ -1473,7 +1518,7 @@ var CSS = `
|
|
|
1473
1518
|
.dsh-pe-spin.small { width: 11px; height: 11px; border-width: 1px; }
|
|
1474
1519
|
.dsh-pe-spin {
|
|
1475
1520
|
width: 22px; height: 22px; border-radius: 50%;
|
|
1476
|
-
border: 2px solid var(--pe-separator); border-top-color: #6ea8ff;
|
|
1521
|
+
border: 2px solid var(--pe-separator); border-top-color: var(--dsw-alias-brand-primary, #6ea8ff);
|
|
1477
1522
|
animation: dsh-pe-spin 0.9s linear infinite;
|
|
1478
1523
|
}
|
|
1479
1524
|
.dsh-pe-foot {
|
|
@@ -1504,10 +1549,20 @@ var CSS = `
|
|
|
1504
1549
|
.dsh-pe-btn-action.primary {
|
|
1505
1550
|
min-width: 112px;
|
|
1506
1551
|
border-color: transparent;
|
|
1507
|
-
|
|
1508
|
-
|
|
1552
|
+
/* Fill and label are a PAIR: the alias layer flips brand-primary from
|
|
1553
|
+
near-black (light theme) to near-white (dark theme), so the label has to
|
|
1554
|
+
flip with it \u2014 a hardcoded foreground turns the dark theme into
|
|
1555
|
+
white-on-white. label-primary-inverted is the color the shell itself
|
|
1556
|
+
paints onto an inverted surface; the fallback chain keeps an inverted label
|
|
1557
|
+
on hosts that predate that token. */
|
|
1558
|
+
background: var(--dsw-alias-brand-primary, #3f76e1);
|
|
1559
|
+
color: var(--dsw-alias-label-primary-inverted, var(--dsw-alias-bg-base, #ffffff));
|
|
1560
|
+
}
|
|
1561
|
+
.dsh-pe-btn-action.primary:hover {
|
|
1562
|
+
/* Blend toward the panel surface, not toward white: in the dark theme white
|
|
1563
|
+
IS the fill, so a white-ward blend would show no hover change at all. */
|
|
1564
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary, #3f76e1) 88%, var(--dsw-alias-bg-layer-1, #1f2127));
|
|
1509
1565
|
}
|
|
1510
|
-
.dsh-pe-btn-action.primary:hover { background: #4d82ec; }
|
|
1511
1566
|
.dsh-pe-btn-action.plain { background: transparent; color: inherit; }
|
|
1512
1567
|
.dsh-pe-btn-action.plain:hover { background: var(--pe-hover); }
|
|
1513
1568
|
.dsh-pe-btn-action.dsh-pe-copy { min-width: 96px; }
|
|
@@ -2046,7 +2101,7 @@ var SETTINGS_SECTION_ORDER = 70;
|
|
|
2046
2101
|
var SETTINGS_SECTION_LABEL = "\u63D0\u793A\u8BCD\u589E\u5F3A";
|
|
2047
2102
|
var SETTINGS_ROW_CONFIG_SLOT = "plugins.row.config";
|
|
2048
2103
|
var SETTINGS_NAMESPACE = "dsh-prompt-enhance";
|
|
2049
|
-
var SETTINGS_BUNDLE = "@surfishs/dsh-prompt-enhance";
|
|
2104
|
+
var SETTINGS_BUNDLE = true ? "@surfishs/dsh-prompt-enhance" : "@surfishs/dsh-prompt-enhance";
|
|
2050
2105
|
var SETTINGS_ROW_ID = "dsh-prompt-enhance";
|
|
2051
2106
|
var SETTINGS_ROW_CONFIG_KEY = `${SETTINGS_BUNDLE}#${SETTINGS_ROW_ID}`;
|
|
2052
2107
|
function settingsBooleanField(key) {
|
|
@@ -2338,7 +2393,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
|
|
|
2338
2393
|
var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
|
|
2339
2394
|
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";
|
|
2340
2395
|
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";
|
|
2341
|
-
var PLUGIN_VERSION = true ? "0.0
|
|
2396
|
+
var PLUGIN_VERSION = true ? "0.1.0" : "0.0.0";
|
|
2342
2397
|
var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
|
|
2343
2398
|
var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
|
|
2344
2399
|
var HEADER_TITLE_STYLE = {
|