dsh-prompt-rewriter 1.0.1 → 1.0.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
@@ -1,181 +1,181 @@
1
1
  # dsh-prompt-rewriter
2
2
 
3
+ English | [中文](README.zh.md)
4
+
3
5
  [![npm](https://img.shields.io/npm/v/dsh-prompt-rewriter.svg)](https://www.npmjs.com/package/dsh-prompt-rewriter)
4
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
7
 
6
- 一键把聊天输入框里的草稿改写成更清晰、更完整的提示词。**原位替换,不发送消息、不运行 Agent。**
8
+ Turns the half-formed draft in your composer into a task instruction you can actually run.
9
+ **It rewrites the box, it never sends.** Don't like it? `Ctrl+Z` and you're back.
7
10
 
8
- 一个非官方社区项目,与 DeepSeek 无隶属或授权关系。素材归属见 [NOTICE.md](NOTICE.md)。
11
+ > An unofficial community project, not affiliated with or endorsed by DeepSeek. Artwork attribution is in [NOTICE.md](NOTICE.md).
9
12
 
10
13
  ---
11
14
 
12
- ## 它解决什么问题
15
+ ![One click in the composer turns a draft into a complete prompt](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/01-hero-en.gif)
13
16
 
14
- 一句话的草稿往往缺目标、缺约束、缺输出格式,模型只能猜。这个插件把草稿改写成可执行的提示词,再放回输入框——你可以先看一眼、改两笔,再决定发不发。
17
+ ## What it fills in for you
15
18
 
16
- **按钮长在输入框里,不用另开页面。** 位置在输入框右下角、模型名左侧(图中蓝框那一个),输入框有内容时出现,为空时自动隐藏。
19
+ A one-line draft is missing **goal, format, and boundaries**. The model can only guess — guess wrong and you spend another round rewording. This button puts those three things back into the sentence you already wrote:
17
20
 
18
- ![按钮就在输入框里,紧挨模型名](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/01-composer-button.png)
21
+ | | What you typed | What goes back in the box |
22
+ |---|---|---|
23
+ | You wrote | *help me write a scraper for Douban movies* | the same sentence |
24
+ | Goal added | | scrape **Top 250** titles, **ratings and links** |
25
+ | Format added | | output a **CSV file** |
26
+ | Boundaries added | | respect robots.txt, **wait at least 2s between requests**, back off on rate limits **instead of circumventing them** |
19
27
 
20
- ## 功能
28
+ The third column is not something you wrote. It read your sentence and filled it in. **And it stays editable** — it lands in the composer, not somewhere else.
21
29
 
22
- - **一键改写**:输入框有内容时出现按钮,无内容时隐藏。
23
- - **原位替换**:结果直接写回输入框,是一个可撤销的编辑步,`Ctrl+Z` 可回退。
24
- - **随时可停**:改写中再点一下即取消,草稿保持原样,不报错。
25
- - **失败可见**:出错时按钮变成重试图标,原因直接显示在按钮旁。
26
- - **上下文感知**:会话已有对话时参考前文的目标、已确认要求与已排除方案;空会话只处理当前草稿。
27
- - **参考输入框图片**:可选让输入框里的图片一起参与改写;历史消息里的图片**始终不读**。
30
+ ## How to use it
28
31
 
29
- ### 改写前后
32
+ 1. Type any draft in the composer — shorter is fine.
33
+ 2. Click the **whale-tail icon just left of the model name**. It isn't there when the box is empty.
34
+ 3. A second later the draft is replaced with the rewritten prompt.
35
+ 4. Not what you wanted? `Ctrl+Z`, or click the undo arrow the button turned into.
30
36
 
31
- ![改写前后对比](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/02-before-after.png)
37
+ Changed your mind mid-flight? Click again to cancel. The draft stays exactly as it was — no half-finished text left behind.
32
38
 
33
- ### 两种模式
39
+ ### The four button states
34
40
 
35
- 空会话只处理当前草稿,图标无标记;会话已有对话时参考前文,图标右下角出现小圆点。
41
+ ![Button states: idle, rewriting, done and undoable, failed and retryable](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/05-button-states-en.gif)
36
42
 
37
- ![两种模式的区别](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/04-context-modes.png)
43
+ | State | What you see | What it means |
44
+ |---|---|---|
45
+ | Idle | static whale tail | ready to click |
46
+ | Rewriting | the tail spins into a spiral | running; click again to cancel |
47
+ | Done | turns into an undo arrow | one click back, or `Ctrl+Z` |
48
+ | Failed | red retry icon + reason | the reason sits right next to it — no log hunting |
38
49
 
39
- ### 按钮状态
50
+ ## Two things worth not confusing
40
51
 
41
- ![按钮状态](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/05-button-states.png)
52
+ ### 1. Whether it reads the conversation
42
53
 
43
- ## 安装
54
+ ![Empty session vs. existing conversation: the small dot in the corner is the marker](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/04-context-modes-en.png)
44
55
 
45
- 需要 DeepSeek Harness 桌面版,`node >= 22`。
56
+ The **small dot in the button's lower-right corner** is the whole difference:
46
57
 
47
- ### 从 npm 安装(推荐)
58
+ - **Empty session** (no dot): sees only your current draft.
59
+ - **Existing conversation** (dot): also reads earlier turns, so it knows what you already confirmed and already ruled out. The rewrite lands closer to what you actually want this time.
48
60
 
49
- ```sh
50
- dsh plugin --profile desktop add dsh-prompt-rewriter
51
- ```
61
+ Conversation context costs tokens. If long chats feel slow or expensive, turn off *Reference the conversation* in settings and the dot disappears.
52
62
 
53
- ### 从 GitHub 源码安装
63
+ ### 2. Whether it reads images
54
64
 
55
- ```sh
56
- dsh plugin --profile desktop add github:huaguoxingkong/dsh-prompt-rewriter
57
- ```
65
+ Only images **currently sitting in the composer** — **never images from earlier messages**. That line is deliberate: old pasted screenshots are slow to process and easy to misread, so they're out of scope.
58
66
 
59
- 源码安装会拉取未构建的仓库,首次安装可能提示允许运行该包的安装脚本——只对你信任的包授予此权限。
67
+ ## Settings
60
68
 
61
- ### 从 Release 安装
69
+ `Settings → Prompt rewriter`. Three switches and one dropdown, affecting **only this button, never normal sending**.
62
70
 
63
- 到 [Releases](https://github.com/huaguoxingkong/dsh-prompt-rewriter/releases) 下载 `dsh-prompt-rewriter-1.0.0.zip`,解压后:
71
+ ![Settings page](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/03-settings-en.png)
64
72
 
65
- ```sh
66
- cd dsh-prompt-rewriter-1.0.0
67
- npm install
68
- dsh plugin --profile desktop add .
69
- ```
73
+ | Option | Default | What turning it on does |
74
+ |---|---|---|
75
+ | Use a fixed model | Off | Off: follow the model of the current conversation. On: always use the model picked below. |
76
+ | Reference the conversation | **On** | Read earlier turns. More accurate, but extra tokens and slower on long chats. |
77
+ | Reference composer images | Off | Images in the composer take part. Earlier messages' images are never read. |
70
78
 
71
- ### 本地 checkout 安装
79
+ - The model dropdown lists **the providers and models you actually have** — you can't type in one that doesn't exist.
80
+ - Turning the model switch off does not clear your selection; flipping it back on shows the same choice.
81
+ - Images still uploading are skipped, and the status area tells you how many were missed. A rewrite never fails because of an image.
72
82
 
73
- ```sh
74
- git clone https://github.com/huaguoxingkong/dsh-prompt-rewriter.git
75
- cd dsh-prompt-rewriter
76
- npm install
77
- dsh plugin --profile desktop add .
78
- ```
83
+ ## Install
79
84
 
80
- `npm install` 是必需的:插件用 `@deepseek-ai/schemastery` 声明设置页的 `Config`,它是唯一外部依赖。
85
+ DeepSeek Harness desktop, `node >= 22`. **Restart Harness after installing** — this plugin has no HMR.
81
86
 
82
- ### 安装后
87
+ ### From npm (recommended)
83
88
 
84
- **重启 DeepSeek Harness。** 本插件没有 HMR,bundle 在启动时读取快照,不重启不会生效。
89
+ ```sh
90
+ dsh plugin --profile desktop add dsh-prompt-rewriter
91
+ ```
85
92
 
86
- ## 使用
93
+ ### From GitHub source
87
94
 
88
- 1. 在输入框里写下任意草稿。
89
- 2. 点模型名左侧的增强按钮(大肥鱼图标)。
90
- 3. 等待改写完成,草稿被替换成新提示词。
91
- 4. 不满意可按 `Ctrl+Z` 或点回退图标还原。
95
+ ```sh
96
+ dsh plugin --profile desktop add github:huaguoxingkong/dsh-prompt-rewriter
97
+ ```
92
98
 
93
- 改写用的是**当前会话选中的模型**,除非你在设置里固定了别的模型。
99
+ Installing from source runs a build step and may ask you to approve it. Grant that only to packages you trust.
94
100
 
95
- ## 设置
101
+ ### From a release zip
96
102
 
97
- `设置 → 提示词增强` 提供三个开关与一个模型选择器,只影响这个按钮,不影响正常发送。
103
+ Download the zip from [Releases](https://github.com/huaguoxingkong/dsh-prompt-rewriter/releases), unzip, then `npm install && dsh plugin --profile desktop add .`.
98
104
 
99
- ![设置页](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/03-settings.png)
105
+ ## FAQ
100
106
 
101
- | 选项 | 默认 | 说明 |
102
- |---|---|---|
103
- | **用哪个模型改写** | 关 | 关:跟随当前对话正在用的模型。开:始终使用下拉中选定的模型。 |
104
- | **参考之前的对话** | 开 | 改写时参考本会话前文,更贴合真实意图。会多耗 token,长对话也更慢。 |
105
- | **参考输入框里的图片** | 关 | 输入框里已放好的图片一并参与改写。**历史消息里的图片始终不读。** |
107
+ **Clicked it and nothing happened.** The composer is empty, or *Use a fixed model* is on with no model picked.
106
108
 
107
- 行为细节:
109
+ **"No credentials configured for the current model."** That model has no key set. Switch models, or pin one that works in settings.
108
110
 
109
- - **模型选择会持久化**:选择器列出你实际拥有的渠道与模型(与输入框的模型选择器同一份数据),无法手填不存在的模型。关闭开关不会清空已选模型,重新打开直接回显上次选择。
110
- - **图片仅在完成上传后可读**:上传中的图片会被跳过,并在状态区提示“有 N 张图片未能读取”,不会让改写失败。
111
- - 三个开关各自独立生效,互不影响。
111
+ **Can I undo the whole rewrite?** One `Ctrl+Z`. It's an ordinary edit step in the composer.
112
112
 
113
- ## 配置
113
+ **Does it change messages I already sent?** No. It only edits the draft, and it never sends.
114
114
 
115
- profile 插件行的 `config` 字段全部可选。前五项由设置页托管,后七项为运维上限:
115
+ ## Configuration
116
+
117
+ Every `config` key on the profile plugin line is optional. The first five are managed by the settings page; the last seven are operational ceilings and are not exposed in the UI.
116
118
 
117
119
  ```yaml
118
120
  - id: dsh-prompt-rewriter
119
121
  name: dsh-prompt-rewriter
120
122
  config:
121
- # 设置页托管
122
- useCustomModel: false # 是否固定使用 enhanceProvider/enhanceModel
123
- enhanceProvider: "" # 空 = 跟随会话模型
123
+ # managed by the settings page
124
+ useCustomModel: false # pin enhanceProvider/enhanceModel
125
+ enhanceProvider: "" # empty = follow the session model
124
126
  enhanceModel: ""
125
- referenceImages: false # 是否参考输入框图片
126
- referenceContext: true # 是否参考前文
127
-
128
- # 运维上限(不暴露在设置页)
129
- maxDraftChars: 8000 # 草稿字符上限
130
- maxOutputChars: 12000 # 输出字符上限
131
- maxOutputTokens: 2000 # 单次请求输出 token 上限
132
- timeoutMs: 90000 # 端到端超时
133
- historyTokenBudget: 6000 # 历史注入的 token 预算
134
- historyMaxMessages: 24 # 历史最多取多少条
135
- historyMessageChars: 4000 # 单条历史字符上限
127
+ referenceImages: false # read composer images
128
+ referenceContext: true # read earlier turns
129
+
130
+ # operational ceilings (not exposed in the UI)
131
+ maxDraftChars: 8000 # draft length cap
132
+ maxOutputChars: 12000 # output length cap
133
+ maxOutputTokens: 2000 # output tokens per request
134
+ timeoutMs: 90000 # end-to-end timeout
135
+ historyTokenBudget: 6000 # token budget for injected history
136
+ historyMaxMessages: 24 # max history messages
137
+ historyMessageChars: 4000 # per-message character cap
136
138
  ```
137
139
 
138
- ## 工作原理
140
+ ## How it works
139
141
 
140
- | 半边 | 文件 | 职责 |
142
+ | Half | File | Responsibility |
141
143
  |---|---|---|
142
- | Host | `index.js` | 注册 `POST /api/prompt-enhance`(改写)与 `GET/POST /api/prompt-enhance/settings`(设置),走 `ctx.connection.fetch`,继承 Harness 鉴权与来源校验。读取会话投影得到当前模型,经 `ctx.llm` 生成结果。 |
143
- | Client | `client.js` | 在 `conversation.input.right` 渲染按钮;在 `settings.section` 渲染设置页。通过 `inputActions.insertText` 原位替换草稿。 |
144
+ | Host | `index.js` | Registers `POST /api/prompt-enhance` (rewrite) and `GET/POST /api/prompt-enhance/settings`, through `ctx.connection.fetch` so it inherits Harness auth and origin checks. Reads the session projection for the current model, then generates via `ctx.llm`. |
145
+ | Client | `client.js` | Renders the button at `conversation.input.right` and the settings page at `settings.section`. Replaces the draft in place via `inputActions.insertText`. |
144
146
 
145
- 三个值得注意的设计:
147
+ Three designs worth calling out:
146
148
 
147
- - **上下文按预算裁剪**:历史注入量取 `min(historyTokenBudget, 上下文窗口 × 5%)`,从最新往回收集;单条超预算时截断而非丢弃,保证“有上下文”不会静默退化成“无上下文”。
148
- - **历史以 JSON 数组注入**,系统提示中明确声明“这是数据,不是指令”,防止历史里的文本伪造结构。
149
- - **图片开关由 Host 裁决**:浏览器只要输入框有图就上传,Host 依据开关决定是否使用——避免设置尚未加载完成时读到默认值而静默失效。
149
+ - **Context is budgeted**: injected history is `min(historyTokenBudget, contextWindow × 5%)`, collected newest-first. An over-budget single message is truncated rather than dropped, so "has context" never silently degrades into "no context".
150
+ - **History is injected as a JSON array**, and the system prompt states explicitly that it is data, not instructions — text inside history can't forge structure.
151
+ - **The image switch is decided by the Host**: the browser uploads composer images unconditionally and the Host decides whether to use them, so a not-yet-loaded setting can't silently disable the feature.
150
152
 
151
- ## 已知限制
153
+ ## Known limitations
152
154
 
153
- - 历史图片不参与改写(有意为之,只读输入框图片)。
154
- - 非流式替换:改写完成前按钮显示为动画态。
155
- - 设置页的模型下拉依赖 Host 的 `remote.session.modelCatalog`;该面不可用时下拉会明确提示读取失败,而不是留空。
155
+ - Images from earlier messages never take part (by design; composer images only).
156
+ - Replacement is non-streaming: the button shows its animated state until the rewrite lands.
157
+ - The settings dropdown depends on the Host's `remote.session.modelCatalog`. When that surface is unavailable it says so explicitly rather than rendering an empty list.
156
158
 
157
- ## 开发
159
+ ## Development
158
160
 
159
- 插件分 Host 与 Client 两半:Host 只依赖 `ctx.connection`、`ctx.llm`、`ctx.settings` 等宿主服务,Client 通过 `window.__ModuleLoader__` 注册槽位组件。两半都随 bundle 在启动时加载,改动后需重启验证。
161
+ The plugin has a Host half and a Client half. The Host depends only on host services such as `ctx.connection`, `ctx.llm` and `ctx.settings`; the Client registers slot components through `window.__ModuleLoader__`. Both halves load with the bundle at startup, so changes require a restart to verify.
160
162
 
161
- **单元测试未随本仓库发布。** 开发期测试依赖宿主私有的 `@deepseek-ai/schemastery`、宿主 React 副本与本机 profile 目录结构,直接开源会让使用者拿到跑不起来的文件。
163
+ **Unit tests are not published with this repository.** Development-time tests depend on the host's private `@deepseek-ai/schemastery`, a copy of the host's React, and this machine's profile layout — publishing them would hand users files that cannot run.
162
164
 
163
165
  ```sh
164
- node --check index.js # 语法
166
+ node --check index.js # syntax
165
167
  node --check client.js
166
- npm pack --dry-run # 检查发布内容
168
+ npm pack --dry-run # inspect what would ship
167
169
  ```
168
170
 
169
- ## 许可
170
-
171
- 代码采用 MIT,详见 [LICENSE](LICENSE)。
171
+ ## License
172
172
 
173
- 内嵌素材分两类:
173
+ Code is MIT — see [LICENSE](LICENSE). Embedded artwork falls into two classes:
174
174
 
175
- | 素材 | 许可 | 是否在 MIT 范围内 |
175
+ | Asset | License | Inside the MIT grant? |
176
176
  |---|---|---|
177
- | 插件代码 | MIT | 是 |
178
- | 鲸鱼尾巴 36 帧轮廓(来自 `dsh-status-rotator` v0.38.0,作者 01Virex) | **MIT**,已在上游核实(36 帧逐条比对一致) | 是,保留其版权声明 |
179
- | DeepSeek「大肥鱼」品牌标(来源 `dsh-web-frontend`) | 源包内**未找到许可证** | **否**,已在 LICENSE 中显式排除 |
177
+ | Plugin code | MIT | yes |
178
+ | Whale-tail 36-frame outline (from `dsh-status-rotator` v0.38.0 by 01Virex) | **MIT**, verified upstream (all 36 frames compared) | yes, copyright notice retained |
179
+ | DeepSeek "big fat fish" brand mark (from `dsh-web-frontend`) | **no license found** in the source package | **no**, explicitly excluded in LICENSE |
180
180
 
181
- 本项目为非官方社区项目,与 DeepSeek 无隶属或授权关系。完整归属与核实过程见 [NOTICE.md](NOTICE.md)。
181
+ Unofficial community project, not affiliated with or endorsed by DeepSeek. Full attribution and verification notes are in [NOTICE.md](NOTICE.md).
package/README.zh.md ADDED
@@ -0,0 +1,182 @@
1
+ # dsh-prompt-rewriter
2
+
3
+ [English](README.md) | 中文
4
+
5
+ [![npm](https://img.shields.io/npm/v/dsh-prompt-rewriter.svg)](https://www.npmjs.com/package/dsh-prompt-rewriter)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+
8
+ 把输入框里那句没头没尾的草稿,原地改成能直接执行的任务说明。
9
+ **只改内容,不发送、不运行。** 不满意就 `Ctrl+Z` 回去。
10
+
11
+ > 非官方社区项目,与 DeepSeek 无隶属或授权关系。内嵌素材的归属见 [NOTICE.md](NOTICE.md)。
12
+
13
+ ---
14
+
15
+ ![在输入框里点一下,草稿原地变成完整提示词](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/01-hero.gif)
16
+
17
+ ## 它替你补上了什么
18
+
19
+ 一句话的草稿缺的是**目标、格式、边界**。模型只能猜——猜错了你得换个说法再问一轮。
20
+ 这个按钮把这三样补进你原本那句话里:
21
+
22
+ | | 你写的 | 放回输入框的 |
23
+ |---|---|---|
24
+ | 你写的 | *帮我写个爬虫抓豆瓣电影* | 同一句话 |
25
+ | 补上目标 | | 抓取电影 **Top250** 的**名称、评分和链接** |
26
+ | 补上格式 | | 输出为 **CSV 文件** |
27
+ | 补上边界 | | 遵守 robots 协议、**请求间隔不少于 2 秒**、遇到反爬**降低频率而不是绕过限制** |
28
+
29
+ 第三列不是你打上去的,是它读了你那句话之后补的。**补出来的东西你随时能改**——它落在输入框里,不在别的地方。
30
+
31
+ ## 怎么用
32
+
33
+ 1. 在输入框里写下草稿,多短都行。
34
+ 2. 点**模型名左边**那个鲸鱼尾巴图标。输入框为空时它不出现。
35
+ 3. 一秒多之后,草稿被换成改写后的提示词。
36
+ 4. 不满意?`Ctrl+Z`,或点按钮变成的回退箭头。
37
+
38
+ 中途想放弃就再点一下,草稿保持原样,不会给你留下半截文字。
39
+
40
+ ### 按钮的四种状态
41
+
42
+ ![按钮状态:空闲、改写中、完成可回退、失败可重试](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/05-button-states.gif)
43
+
44
+ | 状态 | 你看到的 | 意味着 |
45
+ |---|---|---|
46
+ | 空闲 | 静止的鲸鱼尾巴 | 可以点 |
47
+ | 改写中 | 鱼尾旋成螺旋 | 在跑;再点一下是取消 |
48
+ | 完成 | 变成回退箭头 | 一键还原,或用 `Ctrl+Z` |
49
+ | 失败 | 红色重试图标 + 原因 | 原因就在按钮旁边,不用翻日志 |
50
+
51
+ ## 两个容易搞混的地方
52
+
53
+ ### 一、它读不读前文
54
+
55
+ ![空会话 vs 已有对话:图标右下角的小圆点是标记](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/04-context-modes.png)
56
+
57
+ 按钮右下角**有没有那个小圆点**,就是全部区别:
58
+
59
+ - **空会话**(无圆点):只看你当前这句草稿。
60
+ - **已有对话**(有圆点):还会读前面聊过的内容,知道你已经确认过什么、排除过什么,改写更贴你这次真正想要的东西。
61
+
62
+ 读前文是要花 token 的。长对话里觉得慢或觉得贵,去设置里关掉「参考之前的对话」,按钮上的圆点随之消失。
63
+
64
+ ### 二、它读不读图
65
+
66
+ 只读**你现在放在输入框里的**图片,**历史消息里的图片永远不读**。这条边界是刻意的:旧截图既慢又容易看偏,不纳入范围。
67
+
68
+ ## 设置
69
+
70
+ `设置 → 提示词改写`。三个开关一个下拉,**只影响这个按钮,不影响正常发送**。
71
+
72
+ ![设置页](https://raw.githubusercontent.com/huaguoxingkong/dsh-prompt-rewriter/main/docs/images/03-settings.png)
73
+
74
+ | 选项 | 默认 | 打开会怎样 |
75
+ |---|---|---|
76
+ | 用哪个模型改写 | 关 | 关:跟随当前对话的模型。开:固定用下拉选定的模型。 |
77
+ | 参考之前的对话 | **开** | 读前面的内容。更准,但多耗 token、长对话更慢。 |
78
+ | 参考输入框里的图片 | 关 | 输入框里的图一起参与。历史消息里的图片始终不读。 |
79
+
80
+ - 模型下拉列出你**实际拥有**的渠道与模型,填不进不存在的模型。
81
+ - 关掉模型开关不会清空你的选择,重新打开还是同一个。
82
+ - 上传中的图片会被跳过,状态区会告诉你少读了几张。不会因为一张图让整次改写失败。
83
+
84
+ ## 安装
85
+
86
+ 需要 DeepSeek Harness 桌面版,`node >= 22`。**装完必须重启 Harness**——本插件没有 HMR。
87
+
88
+ ### 从 npm(推荐)
89
+
90
+ ```sh
91
+ dsh plugin --profile desktop add dsh-prompt-rewriter
92
+ ```
93
+
94
+ ### 从 GitHub 源码
95
+
96
+ ```sh
97
+ dsh plugin --profile desktop add github:huaguoxingkong/dsh-prompt-rewriter
98
+ ```
99
+
100
+ 源码安装会跑构建步骤,首次可能要求你授权。只对你信任的包给这个权限。
101
+
102
+ ### 从 Release 的 zip
103
+
104
+ 到 [Releases](https://github.com/huaguoxingkong/dsh-prompt-rewriter/releases) 下载 zip,解压后 `npm install && dsh plugin --profile desktop add .`。
105
+
106
+ ## 常见问题
107
+
108
+ **点了没反应?** 输入框是空的,或者「用哪个模型改写」打开了但没选模型。
109
+
110
+ **报「当前模型尚未配置可用的凭据」?** 这个模型没配 key。换个模型,或在设置里固定一个能用的。
111
+
112
+ **改写完想全撤?** 一次 `Ctrl+Z` 就回到原文,它只是输入框里一个普通编辑步。
113
+
114
+ **会把我已经发出去的消息也改了吗?** 不会。它只改草稿,从不发送。
115
+
116
+ ## 配置
117
+
118
+ profile 插件行的 `config` 全部可选。前五项由设置页托管,后七项是运维上限,不暴露在界面上:
119
+
120
+ ```yaml
121
+ - id: dsh-prompt-rewriter
122
+ name: dsh-prompt-rewriter
123
+ config:
124
+ # 设置页托管
125
+ useCustomModel: false # 是否固定使用 enhanceProvider/enhanceModel
126
+ enhanceProvider: "" # 空 = 跟随会话模型
127
+ enhanceModel: ""
128
+ referenceImages: false # 是否参考输入框图片
129
+ referenceContext: true # 是否参考前文
130
+
131
+ # 运维上限(不暴露在设置页)
132
+ maxDraftChars: 8000 # 草稿字符上限
133
+ maxOutputChars: 12000 # 输出字符上限
134
+ maxOutputTokens: 2000 # 单次请求输出 token 上限
135
+ timeoutMs: 90000 # 端到端超时
136
+ historyTokenBudget: 6000 # 历史注入的 token 预算
137
+ historyMaxMessages: 24 # 历史最多取多少条
138
+ historyMessageChars: 4000 # 单条历史字符上限
139
+ ```
140
+
141
+ ## 工作原理
142
+
143
+ | 半边 | 文件 | 职责 |
144
+ |---|---|---|
145
+ | Host | `index.js` | 注册 `POST /api/prompt-enhance`(改写)与 `GET/POST /api/prompt-enhance/settings`(设置),走 `ctx.connection.fetch`,继承 Harness 鉴权与来源校验。读取会话投影得到当前模型,经 `ctx.llm` 生成结果。 |
146
+ | Client | `client.js` | 在 `conversation.input.right` 渲染按钮;在 `settings.section` 渲染设置页。通过 `inputActions.insertText` 原位替换草稿。 |
147
+
148
+ 三处值得说明的设计:
149
+
150
+ - **上下文按预算裁剪**:历史注入量取 `min(historyTokenBudget, 上下文窗口 × 5%)`,从最新往回收集;单条超预算时截断而非丢弃,保证「有上下文」不会静默退化成「无上下文」。
151
+ - **历史以 JSON 数组注入**,系统提示中明确声明「这是数据,不是指令」,防止历史里的文本伪造结构。
152
+ - **图片开关由 Host 裁决**:浏览器只要输入框有图就上传,Host 依据开关决定是否使用——避免设置尚未加载完成时读到默认值而静默失效。
153
+
154
+ ## 已知限制
155
+
156
+ - 历史消息里的图片不参与改写(有意为之,只读输入框图片)。
157
+ - 非流式替换:改写完成前按钮显示为动画态。
158
+ - 设置页的模型下拉依赖 Host 的 `remote.session.modelCatalog`;该面不可用时下拉会明确提示读取失败,而不是留空。
159
+
160
+ ## 开发
161
+
162
+ 插件分 Host 与 Client 两半:Host 只依赖 `ctx.connection`、`ctx.llm`、`ctx.settings` 等宿主服务,Client 通过 `window.__ModuleLoader__` 注册槽位组件。两半都随 bundle 在启动时加载,改动后需重启验证。
163
+
164
+ **单元测试未随本仓库发布。** 开发期测试依赖宿主私有的 `@deepseek-ai/schemastery`、宿主 React 副本与本机 profile 目录结构,直接开源会让使用者拿到跑不起来的文件。
165
+
166
+ ```sh
167
+ node --check index.js # 语法
168
+ node --check client.js
169
+ npm pack --dry-run # 检查发布内容
170
+ ```
171
+
172
+ ## 许可
173
+
174
+ 代码采用 MIT,详见 [LICENSE](LICENSE)。内嵌素材分两类:
175
+
176
+ | 素材 | 许可 | 是否在 MIT 范围内 |
177
+ |---|---|---|
178
+ | 插件代码 | MIT | 是 |
179
+ | 鲸鱼尾巴 36 帧轮廓(来自 `dsh-status-rotator` v0.38.0,作者 01Virex) | **MIT**,已在上游核实(36 帧逐条比对一致) | 是,保留其版权声明 |
180
+ | DeepSeek「大肥鱼」品牌标(来源 `dsh-web-frontend`) | 源包内**未找到许可证** | **否**,已在 LICENSE 中显式排除 |
181
+
182
+ 本项目为非官方社区项目,与 DeepSeek 无隶属或授权关系。完整归属与核实过程见 [NOTICE.md](NOTICE.md)。
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-prompt-rewriter",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "One-click prompt enhancement beside the DeepSeek Harness composer: rewrites a draft in place without sending it.",
5
5
  "type": "module",
6
6
  "icon": "icon.svg",
@@ -17,8 +17,10 @@
17
17
  "locale/*.json",
18
18
  "icon.svg",
19
19
  "docs/images/*.png",
20
+ "docs/images/*.gif",
20
21
  "screenshots.json",
21
22
  "README.md",
23
+ "README.zh.md",
22
24
  "LICENSE",
23
25
  "NOTICE.md"
24
26
  ],
@@ -78,4 +80,4 @@
78
80
  "scripts": {
79
81
  "prepublishOnly": "node --check index.js && node --check client.js"
80
82
  }
81
- }
83
+ }
package/screenshots.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "screenshots": [
3
- "docs/images/01-composer-button.png",
4
- "docs/images/02-before-after.png",
3
+ "docs/images/01-hero.gif",
4
+ "docs/images/05-button-states.gif",
5
5
  "docs/images/03-settings.png",
6
6
  "docs/images/04-context-modes.png",
7
- "docs/images/05-button-states.png"
7
+ "docs/images/01-hero-en.gif",
8
+ "docs/images/05-button-states-en.gif",
9
+ "docs/images/03-settings-en.png",
10
+ "docs/images/04-context-modes-en.png"
8
11
  ]
9
12
  }
Binary file
Binary file
Binary file