@surfishs/dsh-prompt-enhance 0.1.8 → 0.1.10
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 +87 -37
- package/README.md +87 -37
- package/lib/client.js +17 -8
- package/lib/index.js +107 -95
- package/lib/index.js.map +3 -3
- package/package.json +1 -1
- package/src/client/ResultPanel.tsx +1 -0
- package/src/client/locales.ts +4 -2
- package/src/client/settings-page-spec.ts +8 -5
- package/src/client/settings-page.tsx +1 -1
- package/src/client/styles.ts +6 -2
- package/src/config.ts +18 -16
- package/src/enhancer.ts +11 -2
- package/src/orchestrate.ts +7 -6
- package/src/prompts.ts +95 -89
- package/src/shared/normalize.ts +82 -3
package/README.en.md
CHANGED
|
@@ -46,7 +46,7 @@ The rewritten prompt appears in a card docked above the composer without coverin
|
|
|
46
46
|
| 🖼️ **Docked result card** | Shown above the composer without covering the conversation, with the model, reasoning tier, timing and `token` usage; folds to its title and footer rows so long results do not fill the screen; a truncated result is flagged |
|
|
47
47
|
| ↩️ **Apply, copy and undo** | Copy the result; applying folds the card to its title row by default and turns its footer button into Undo, which restores the draft and expands the card |
|
|
48
48
|
| 🔄 **Regenerate** | Request another version from the current text; an applied enhanced draft can be regenerated too |
|
|
49
|
-
| 💬 **`/enhance` command** | Rewrite any text from the slash menu; the result never enters model history |
|
|
49
|
+
| 💬 **`/enhance` command** | Rewrite any text from the slash menu; the result is copyable and never enters model history |
|
|
50
50
|
| 🧭 **Model routing** | A pinned `provider` + `model` pair wins; otherwise it follows the session model, then the global default |
|
|
51
51
|
| 🧩 **Context aware** | With `contextAware` on, recent messages between you and the assistant resolve references such as "it" or "that" and fill in task context the draft leaves out; you can turn it off at any time.<br>*Note: the context window is limited — if the draft depends on earlier messages, add that background to the draft or the rewrite may drift from your intent* |
|
|
52
52
|
| 🔑 **Zero credentials** | Calls use DSH's model service and credential store; the plugin never reads or stores keys |
|
|
@@ -133,7 +133,9 @@ Right-click or long-press the enhance button in the toolbar to open the quick se
|
|
|
133
133
|
|
|
134
134
|

|
|
135
135
|
|
|
136
|
-
`/enhance
|
|
136
|
+
### `/enhance` command
|
|
137
|
+
|
|
138
|
+
Rewrite any text from the slash menu; the result is copyable and never enters model history.
|
|
137
139
|
|
|
138
140
|
The ⓘ in the result-card footer reports the conversation messages and characters this enhancement actually referenced, e.g. `3/8 messages · 3,140/4,000 chars (79%)`: the 8 comes from `contextMaxMessages` and the percentage is measured against `contextMaxChars`. DSH-injected environment, skill, time and other messages are not counted. When the draft carries attachments, it also shows `Attachments: N` — the count only; attachment contents are never sent.
|
|
139
141
|
|
|
@@ -149,7 +151,6 @@ Edit in **Settings → Prompt enhance** (or Plugins → `dsh-prompt-enhance` →
|
|
|
149
151
|
| `provider` + `model` | empty | Pick from the DSH-registered LLM providers and their models; the model can switch to “Custom…” to type an id; unconfigured providers are greyed out until set up in DSH model services; empty follows the session model (no pinned route). With only one filled, the save falls back to follow-session; switching the provider clears the chosen model so a stale pair cannot remain |
|
|
150
152
|
| `reasoningEffort` | `off` | Tiers come from what the configured provider/model declares (DeepSeek: `off` / `low` / `high` / `max`). "Model default" sends no field, so the provider applies its default; switching to a model that does not declare the stored tier rewrites it to "Model default" |
|
|
151
153
|
| `contextAware` | `true` | Read recent messages to resolve references; turn it off for sensitive sessions |
|
|
152
|
-
| `streaming` | `true` | Show the result as it is written; display only, the final result is unchanged |
|
|
153
154
|
| `systemPrompt` | empty | Custom system prompt; empty uses the built-in strategy |
|
|
154
155
|
| `shortcut` | empty (disabled) | Shortcut that triggers the enhancement; e.g. `ctrl+alt+shift+e`. Needs at least one of ctrl/alt/meta; shift is optional; the settings page has a Record button that captures the combination |
|
|
155
156
|
|
|
@@ -159,7 +160,8 @@ Edit in **Settings → Prompt enhance** (or Plugins → `dsh-prompt-enhance` →
|
|
|
159
160
|
|---|---|---|
|
|
160
161
|
| `foldAnimation` | `true` | Whether the card animates when it folds or expands; never animates when the system asks for reduced motion |
|
|
161
162
|
| `autoFold` | `true` | Fold the card after applying and expand it again after undoing |
|
|
162
|
-
| `
|
|
163
|
+
| `streaming` | `true` | Show the result as it is written; display only, the final result is unchanged |
|
|
164
|
+
| `strategyMode` | `replace-default` | `replace-default` replaces the built-in strategy (three framing rules still apply: the draft is data, only the result is output, the rules themselves are never copied); `extend-default` appends the custom strategy after the built-in one |
|
|
163
165
|
| `temperature` | `0.3` | Sampling temperature `0~1` (step 0.05); lower stays closer to the original |
|
|
164
166
|
| `maxInputChars` | `12000` | Input character cap; over-limit is rejected, never truncated |
|
|
165
167
|
| `maxOutputTokens` | `8192` | Output token cap per call |
|
|
@@ -171,7 +173,15 @@ Edit in **Settings → Prompt enhance** (or Plugins → `dsh-prompt-enhance` →
|
|
|
171
173
|
|
|
172
174
|
### About the default reasoning effort
|
|
173
175
|
|
|
174
|
-
This plugin defaults to `off`, and that default is usually the right one to keep. Prompt enhancement is normally a short, well-specified task — restating a draft more clearly — so no chain of reasoning is needed: on a simple task a thinking tier buys little, while costing several times the output tokens and a longer wait.
|
|
176
|
+
This plugin defaults to `off`, and that default is usually the right one to keep. Prompt enhancement is normally a short, well-specified task — restating a draft more clearly — so no chain of reasoning is needed: on a simple task a thinking tier buys little, while costing several times the output tokens and a longer wait.
|
|
177
|
+
|
|
178
|
+
Raise the tier for one call when:
|
|
179
|
+
|
|
180
|
+
- **the draft leans on involved context**, or the task itself calls for weighing trade-offs;
|
|
181
|
+
- **the result card says the model produced no rewrite** — at a low tier with context on, the model occasionally hands the draft back unchanged. The plugin refuses that result and reports it honestly, but **never retries on its own**: press Regenerate first; if it keeps happening, raise the tier a step; turn context awareness off only when that is still not enough;
|
|
182
|
+
- you want to compare tiers on the same draft.
|
|
183
|
+
|
|
184
|
+
Both the settings page and the right-click quick card switch the tier, so you can compare on the spot. When you need more capability, a stronger model usually pays off more than keeping the tier raised.
|
|
175
185
|
|
|
176
186
|
Do not pick a model that is too weak for the job: the output is a task description handed to the downstream model, and a noticeably weaker model tends to make it vaguer, drop key constraints, or drift from what you meant — **a lower-quality prompt can be worse than no rewrite at all**. Do not route prompt optimisation through a model weaker than the one running the current session.
|
|
177
187
|
|
|
@@ -207,18 +217,17 @@ flowchart LR
|
|
|
207
217
|
- A passing draft goes to the host route, which validates again and calls the model; the browser prefers SSE and falls back to the one-shot JSON route when the host or network cannot stream.
|
|
208
218
|
- The output is **normalized** (fences stripped, whitespace trimmed, an empty response refused) and shown in the **docked result card**.
|
|
209
219
|
- **Apply** writes the result back and pushes the original onto the undo stack; **Undo** restores it.
|
|
210
|
-
- `/enhance` runs through the command plane and never enters conversation history.
|
|
211
220
|
- The right-click quick settings card only changes settings such as the reasoning tier and context awareness; it never starts an enhancement.
|
|
212
221
|
|
|
213
222
|
## Prompt system
|
|
214
223
|
|
|
215
|
-
Every call is assembled from
|
|
224
|
+
Every call is assembled from four blocks: the **strategy** (default or custom), context rules (when a conversation snippet is present), attachment rules (when the draft carries attachments), and the **framing contract** (appended last on every call). Only the strategy decides the shape of the result; the other three only constrain the framing: the draft is data, only the result is output, and the rules themselves are never copied.
|
|
216
225
|
|
|
217
226
|
| Case | System prompt composition |
|
|
218
227
|
|---|---|
|
|
219
|
-
| Default | default strategy + context rules (when present) + attachment rules (when present) +
|
|
220
|
-
| `replace-default` | custom strategy + context rules (when present) +
|
|
221
|
-
| `extend-default` | default strategy + context rules (when present) +
|
|
228
|
+
| Default | default strategy + context rules (when present) + attachment rules (when present) + framing contract |
|
|
229
|
+
| `replace-default` | custom strategy + context rules (when present) + attachment rules (when present) + framing contract |
|
|
230
|
+
| `extend-default` | default strategy + context rules (when present) + `Operator additions` block + custom strategy + attachment rules (when present) + framing contract |
|
|
222
231
|
|
|
223
232
|
### Default strategy
|
|
224
233
|
|
|
@@ -228,40 +237,34 @@ The default system prompt asks the model to act as a prompt-rewriting expert, ap
|
|
|
228
237
|
2. **Context and constraints**: add only the background and limits the draft implies; never add facts or requirements the draft does not carry.
|
|
229
238
|
3. **Steps**: break vague or multi-part requests into numbered, executable steps.
|
|
230
239
|
4. **Output format**: specify structure, language, length and style where the request implies them.
|
|
231
|
-
5. **Acceptance criteria**: state how to recognize a correct result.
|
|
240
|
+
5. **Acceptance criteria**: state how to recognize a correct result. **This one is never skipped** — one line is enough, and a placeholder is acceptable when the draft gives no basis.
|
|
232
241
|
6. **Boundary conditions**: list edge cases, invalid inputs and what to do when information is missing.
|
|
233
242
|
|
|
234
|
-
|
|
243
|
+
Eight content rules ride along:
|
|
235
244
|
|
|
236
245
|
- **Preserve intent**: keep the user's information, without deleting, altering or contradicting it.
|
|
237
|
-
- **Never fabricate**: use only what the draft supports; when a needed detail is missing, write `(
|
|
246
|
+
- **Never fabricate**: use only what the draft supports; when a needed detail is missing, write `(TBD: …)` (in the output language) instead of inventing one.
|
|
238
247
|
- **Stay traceable**: every addition needs explicit evidence or a strong implication in the draft; when in doubt, use a placeholder instead of adding content.
|
|
239
248
|
- **Keep the scope**: do not widen, narrow or redirect the task.
|
|
240
|
-
- **
|
|
241
|
-
- **Language**: mirror the input language (Chinese in → Chinese out; best effort at the prompt level, not a hard guarantee).
|
|
249
|
+
- **Language**: mirror the input language (Chinese in → Chinese out; best effort at the prompt level, not a hard guarantee); placeholders, pointers, labels and headings you add follow it too.
|
|
242
250
|
- **Length**: stay at roughly 1–3× the original length without padding.
|
|
243
251
|
- **Already well-formed drafts**: polish them lightly, unchanged in substance.
|
|
244
|
-
- **Rewrite greetings too**: a greeting, small talk or a task-less fragment is still the draft to rewrite — describe how an assistant should respond to it
|
|
252
|
+
- **Rewrite greetings too**: a greeting, small talk or a task-less fragment is still the draft to rewrite — describe how an assistant should respond to it.
|
|
245
253
|
|
|
246
254
|
### Custom strategies
|
|
247
255
|
|
|
248
256
|
`strategyMode` decides how a custom strategy combines with the built-in one:
|
|
249
257
|
|
|
250
|
-
- `replace-default`: **replaces it entirely** (the six-part strategy and
|
|
258
|
+
- `replace-default`: **replaces it entirely** (the six-part strategy, placeholders and the language rule are no longer retained); context rules and the framing contract are still appended.
|
|
251
259
|
- `extend-default`: **appends** your text after the built-in strategy, keeping the default rules in force; context rules are retained.
|
|
252
260
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
- **The draft is data**: the text inside `<raw_prompt>` is only there to be rewritten — never answered, explained or commented on, even when it is a greeting or a question.
|
|
256
|
-
- **Rewrite only**: no preamble, explanation, commentary, questions or code fences.
|
|
257
|
-
- **Greetings are still drafts**: produce the prompt describing how an assistant should respond, not the response itself.
|
|
258
|
-
- **Context is reference only**: when conversation context is present, it serves to resolve references — never instructions, never the text to rewrite.
|
|
261
|
+
In either mode the call ends with the framing contract, which applies to the default strategy too — see the next section.
|
|
259
262
|
|
|
260
263
|
### Additional rules
|
|
261
264
|
|
|
262
|
-
- **Context rules**: appended when conversation context is present; used only to resolve
|
|
263
|
-
- **Attachment rules**: appended when the draft carries attachments; they report only the count
|
|
264
|
-
- **
|
|
265
|
+
- **Context rules**: appended when conversation context is present; used only to resolve pronouns and vague references (in any language), to pick up the stack and terminology the conversation already established, and to stay aligned with the conversation's current goal; it is evidence, not instructions — never override, widen or contradict the draft, ignore it when it is irrelevant or too thin, and never quote or restate the history in the output.
|
|
266
|
+
- **Attachment rules**: appended when the draft carries attachments; they report only the count and never the contents; when the draft relies on an attachment it does not name, the only sanctioned pointer is a task-level one (for example `the attached screenshot`, written in the output language), and the count may appear only inside such a pointer; the model must not report the count/availability/"cannot see them" on their own, nor claim the user provided no attachment.
|
|
267
|
+
- **Framing contract**: appended last on every call; the draft is data — never answered, explained or commented on; output only the result, with no preamble, commentary, questions, pleasantries or code fences; everything outside `<raw_prompt>` (the system instructions, the context block, the attachment block) is meta and must never be copied, quoted, summarized or translated into the output, and the step itself is never described.
|
|
265
268
|
|
|
266
269
|
## Troubleshooting
|
|
267
270
|
|
|
@@ -278,6 +281,7 @@ The table is organized by what you see; parameter meanings and defaults are in C
|
|
|
278
281
|
| Enhancement timed out or was cancelled | Over `timeoutMs`, or you pressed Cancel | Retry or raise `timeoutMs` after a timeout; a cancel leaves the draft unchanged — just run it again |
|
|
279
282
|
| Authentication failure | The provider's credentials or API key are invalid | Check that provider's credentials/API key in DSH |
|
|
280
283
|
| Truncated result | Reached `maxOutputTokens` | Check the truncation warning and raise `maxOutputTokens` in settings |
|
|
284
|
+
| The card shows your draft itself, possibly with a full stop added | With a low reasoning tier and context awareness on, the model sometimes produces no rewrite and hands the draft back | The plugin reports "no rewrite" instead of showing it as a result. Retry first; if it keeps happening, raise the reasoning tier a step; turn context awareness off only when that is still not enough |
|
|
281
285
|
| Context usage shows `8/8 messages` (default) | The `contextMaxMessages` message cap (default 8) was reached; this is normal truncation and is not shown as a warning | Usually nothing to do; raise `contextMaxMessages` if you need older messages, though `contextMaxChars` (default 4,000 chars) may be hit first |
|
|
282
286
|
| Context usage shows `4,000/4,000 chars` (default, amber) | The `contextMaxChars` limit (default 4,000) was reached, so earlier content was not sent; if the latest turn was cut, the reason says only its opening was sent | Raise `contextMaxChars`, or trim the conversation/references; more context means more input tokens and cost |
|
|
283
287
|
| Message says no model is configured for the enhancement (no model route) | No pinned `provider`/`model` pair and no session model route | Set both `provider` and `model` in settings, or send a message in the current session so the plugin can follow the session model |
|
|
@@ -343,20 +347,66 @@ Tests cover input validation, output normalization, the host routes (real HTTP),
|
|
|
343
347
|
|
|
344
348
|
**Architecture**
|
|
345
349
|
|
|
350
|
+
The plugin is two halves — host and browser — that communicate only through the HTTP routes and the pure functions and constants in `src/shared/`; no source file imports across the halves. The host half decides whether a call may happen and how it runs; the browser half decides when to call and how the result returns to the composer.
|
|
351
|
+
|
|
352
|
+
Host half, `src/`:
|
|
353
|
+
|
|
346
354
|
```text
|
|
347
355
|
src/
|
|
348
|
-
├── index.ts
|
|
349
|
-
├──
|
|
350
|
-
├──
|
|
351
|
-
├── shared
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
├── index.ts apply: settings source, HTTP routes, /enhance command
|
|
357
|
+
├── config.ts settings schema, per-request resolution, strategy composition
|
|
358
|
+
├── prompts.ts default strategy, context/attachment rules, framing contract, <raw_prompt> framing
|
|
359
|
+
├── orchestrate.ts one orchestration shared by both entry points: route, context, call, log
|
|
360
|
+
├── enhancer.ts one model call: stream assembly, timeout and cancellation, output normalization
|
|
361
|
+
├── enhance-routes.ts POST /dsh-prompt-enhance/enhance and /enhance-stream
|
|
362
|
+
├── enhance-command.ts the /enhance slash command
|
|
363
|
+
├── admission.ts admission control: sliding-window rate cap, concurrency cap, failure breaker
|
|
364
|
+
├── context.ts conversation-context window selection and character budget
|
|
365
|
+
├── trust.ts / loopback.ts trust gate: host connection check, loopback-only fence as fallback
|
|
366
|
+
├── http.ts / sse.ts bounded JSON body/response helpers, backpressure-aware SSE writer
|
|
367
|
+
├── settings-source.ts settings reads across DSH generations
|
|
368
|
+
├── catalog-route.ts provider/model catalog and route-check endpoints for the settings page
|
|
369
|
+
├── provider-catalog.ts read-only projections of the provider/model catalog
|
|
370
|
+
├── reasoning-route.ts reasoning-tier query endpoint
|
|
371
|
+
├── reasoning-efforts.ts tier resolution: ask the adapter about one provider/model
|
|
372
|
+
├── reasoning-cache.ts persistent tier-answer cache (one pair of files under the DSH home)
|
|
373
|
+
└── shared/ shared by both halves: protocol, field bounds, defaults, validation, normalization, stream text
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Browser half, `src/client/`:
|
|
377
|
+
|
|
378
|
+
```text
|
|
379
|
+
client/
|
|
380
|
+
├── index.tsx apply: button, undo bar, dictionaries, settings mirror, global shortcut
|
|
381
|
+
├── EnhanceButton.tsx composer button: local guards and request orchestration
|
|
382
|
+
├── enhance-client.ts host-endpoint client (SSE first, JSON fallback, typed errors)
|
|
383
|
+
├── ui-state.ts result-card state machine and external store (one per session)
|
|
384
|
+
├── ResultDock.tsx docking and fold orchestration
|
|
385
|
+
├── ResultPanel.tsx result-card rendering (apply, copy, regenerate, cancel)
|
|
386
|
+
├── UndoBar.tsx undo bar
|
|
387
|
+
├── QuickSettingsMenu.tsx right-click quick settings card
|
|
388
|
+
├── quick-settings.ts tier list and write-back for that card
|
|
389
|
+
├── settings*.ts settings mirror, reads, writes, cross-generation adapters
|
|
390
|
+
├── settings-page* the plugin settings page (row spec, controls, styles, copy)
|
|
391
|
+
├── llm-catalog.ts browser-side catalog cache
|
|
392
|
+
├── reasoning-options.ts tier options
|
|
393
|
+
├── shortcut.ts shortcut parsing and matching (pure)
|
|
394
|
+
├── undo-stack.ts per-session undo stack (pure factory)
|
|
395
|
+
├── session-key.ts per-session UI-state key (with a cross-generation shim)
|
|
396
|
+
├── locales.ts / styles.ts / ActionIcons.tsx / SparkleFishIcon.tsx
|
|
397
|
+
└── useDockAlignment.ts align a dock entry with the composer width
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Structural invariants (each verifiable in the source):
|
|
401
|
+
|
|
402
|
+
- **One orchestration path**: the composer route and the `/enhance` command both call `orchestrate.runEnhance`, sharing one admission gate and one prompt assembly, so the two entry points cannot drift apart.
|
|
403
|
+
- **One trust gate**: every route goes through `trust.ts` first and falls back to the loopback-only fence in `loopback.ts` when the host exposes no connection service.
|
|
404
|
+
- **Per-request configuration**: `settings-source.ts` re-reads the settings on every call, so a change applies without a restart.
|
|
405
|
+
- **One prompt assembly point**: `system` is composed in `orchestrate.ts` only, with the constants held by `prompts.ts`; the shape of the result is decided by the strategy layer alone.
|
|
406
|
+
|
|
407
|
+
```text
|
|
358
408
|
scripts/
|
|
359
|
-
└── build.mjs
|
|
409
|
+
└── build.mjs builds both halves into lib/ with esbuild
|
|
360
410
|
```
|
|
361
411
|
|
|
362
412
|
Build outputs:
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
| 🖼️ **停靠结果卡** | 结果显示在输入框上方,不遮挡对话;附模型、推理档位、耗时与 `token` 用量;可折叠为标题与底部按钮,长结果不占满屏幕;超限时提示结果可能不完整 |
|
|
48
48
|
| ↩️ **回填、复制与撤销** | 结果可直接复制;回填后卡片默认自动折叠为标题行,底部按钮变为「撤销」,点击即可恢复原文并展开结果卡 |
|
|
49
49
|
| 🔄 **重新生成** | 按当前输入框内容再请求一版;回填后的增强稿也可继续生成 |
|
|
50
|
-
| 💬 **`/enhance` 命令** |
|
|
50
|
+
| 💬 **`/enhance` 命令** | 从斜杠面板改写任意文本;结果可复制,不进入模型历史 |
|
|
51
51
|
| 🧭 **模型路由** | 设置中同时指定 `provider` 与 `model` 时优先;否则依次跟随当前会话模型、全局默认模型 |
|
|
52
52
|
| 🧩 **上下文感知** | `contextAware` 开启时参考最近几条你与助手的消息,补全「它 / 这个」这类指代和草稿省略的任务背景;可随时关闭。<br>*注意:上下文窗口有限,草稿依赖更早消息时请把必要背景补进草稿,否则改写可能偏离你的原意* |
|
|
53
53
|
| 🔑 **零凭据配置** | 调用走 DSH 的模型服务,密钥来自 DSH 凭据存储;插件不读取也不保存 |
|
|
@@ -134,7 +134,9 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
134
134
|
|
|
135
135
|

|
|
136
136
|
|
|
137
|
-
`/enhance
|
|
137
|
+
### `/enhance` 命令
|
|
138
|
+
|
|
139
|
+
从斜杠面板改写任意文本,结果可复制,不进入模型历史。
|
|
138
140
|
|
|
139
141
|
结果卡页脚的 ⓘ 显示本次增强实际引用的对话消息条数与字符数,例如 `3/8 条 · 3,140/4,000 字(79%)`:8 来自 `contextMaxMessages`,百分比按 `contextMaxChars` 计算;DSH 注入的环境/技能/时间等消息不计入。草稿带附件时,还会显示 `附件:N 个`——只统计数量,附件内容不会发送。
|
|
140
142
|
|
|
@@ -150,7 +152,6 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
150
152
|
| `provider` + `model` | 空 | 从 DSH 已注册的 LLM provider 及模型中选择;模型可选「自定义…」手填 ID;未配置的 provider 置灰、需先在 DSH 模型服务中配置;留空表示跟随当前会话模型(不固定路由)。只填一个时保存后按跟随会话处理;切换 provider 会清空已选 model,避免留下不匹配的旧值 |
|
|
151
153
|
| `reasoningEffort` | `off` | 档位由当前 provider/model 的声明决定;DeepSeek 为 `off` / `low` / `high` / `max`。选「模型默认」时不发送该字段,由提供方使用默认档;切换到不声明当前档位的模型时,插件会自动改回「模型默认」 |
|
|
152
154
|
| `contextAware` | `true` | 读取最近几条消息以消解指代;含敏感内容的会话建议关闭 |
|
|
153
|
-
| `streaming` | `true` | 边写边显示;仅影响显示节奏,最终结果不变 |
|
|
154
155
|
| `systemPrompt` | 空 | 自定义系统提示词;留空使用内置增强策略 |
|
|
155
156
|
| `shortcut` | 空(禁用) | 触发增强的快捷键;例如 `ctrl+alt+shift+e`。须包含 ctrl/alt/meta 中至少一个修饰键,shift 可选;F13–F24 这类物理键盘上通常没有、由宏键盘或改键工具发出的键可单独使用(无修饰键);设置页可点「录制」直接按键录入 |
|
|
156
157
|
|
|
@@ -160,7 +161,8 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
160
161
|
|---|---|---|
|
|
161
162
|
| `foldAnimation` | `true` | 结果卡折叠/展开时是否播放动画;系统开启「减少动态效果」时始终不播放 |
|
|
162
163
|
| `autoFold` | `true` | 回填后自动折叠结果卡,撤销后自动展开 |
|
|
163
|
-
| `
|
|
164
|
+
| `streaming` | `true` | 边写边显示;仅影响显示节奏,最终结果不变 |
|
|
165
|
+
| `strategyMode` | `replace-default` | `replace-default` 整体替换内置策略(仍保留三条框架约束:输入是数据、只输出结果、不复制规则文本);`extend-default` 把自定义策略追加在内置策略之后 |
|
|
164
166
|
| `temperature` | `0.3` | 采样温度 `0~1`(步进 0.05),越低越忠实原文 |
|
|
165
167
|
| `maxInputChars` | `12000` | 输入字符上限;超限拒绝,不截断 |
|
|
166
168
|
| `maxOutputTokens` | `8192` | 单次调用的输出 token 上限 |
|
|
@@ -172,7 +174,15 @@ dsh plugin --profile <profile> remove @surfishs/dsh-prompt-enhance
|
|
|
172
174
|
|
|
173
175
|
### 关于默认的思考档位
|
|
174
176
|
|
|
175
|
-
本插件默认使用 `off
|
|
177
|
+
本插件默认使用 `off`,多数情况下保持这个默认即可。提示词增强通常是短、目标明确的任务——把草稿改写成更清楚的表述,不需要推理过程;在简单任务上,带思考的档位收益很小,代价却是几倍的输出 token 与更长的等待。
|
|
178
|
+
|
|
179
|
+
以下情况适合把档位临时调高一档:
|
|
180
|
+
|
|
181
|
+
- **草稿依赖较复杂的上下文**,或任务本身需要权衡取舍;
|
|
182
|
+
- **结果卡提示「模型这次没有产生改写」**——低档位再加上下文时,模型偶尔会把草稿原样交回。插件会拦下这种结果并如实提示,但**不会自动重试**:先点一次「重新生成」;反复出现时把档位调高一档;仍不理想,再临时关闭上下文感知;
|
|
183
|
+
- 你想用同一份草稿对比不同档位的效果。
|
|
184
|
+
|
|
185
|
+
设置页与右键快捷卡都能切换档位,方便就地对比。需要更强能力时,换一个更好的模型通常比一直抬高档位更划算。
|
|
176
186
|
|
|
177
187
|
选模型时不要用能力过弱的模型:增强的产物是交给下游执行的任务描述,用明显更弱的模型改写,容易把话说得含糊、丢掉关键约束,甚至与你的原意产生偏差——**一份质量更低的提示词,可能比不改写更糟**。因此不要用比当前会话模型能力更低的模型来负责提示词优化。
|
|
178
188
|
|
|
@@ -210,18 +220,17 @@ flowchart LR
|
|
|
210
220
|
- 通过后请求宿主路由;路由入口先过信任闸门(宿主连接校验,宿主缺少该服务时由插件 fence 兜底,见「安全」),再对入参做一次服务端校验并调用模型;浏览器优先走 SSE,不支持时回退一次性 JSON。
|
|
211
221
|
- 模型输出经**归一化**(去代码围栏、裁剪空白、空结果拒绝)后进入**停靠结果卡**。
|
|
212
222
|
- **回填**把结果写回输入框,并把原文压入撤销栈;点「撤销」恢复原文。
|
|
213
|
-
- `/enhance` 走命令通道,结果只出现在命令面板、不进入会话历史。
|
|
214
223
|
- 右键快捷设置卡只修改推理等级、上下文感知等设置,本身不触发增强。
|
|
215
224
|
|
|
216
225
|
## 提示词系统
|
|
217
226
|
|
|
218
|
-
|
|
227
|
+
每次调用由四块规则拼成:**策略**(默认或自定义)、上下文规则(有上下文时)、附件规则(有附件时)、**框架契约**(每次调用最后追加)。只有策略决定产物的形态;其余三块只约束框架:草稿是数据、只输出结果、不复制这些规则。
|
|
219
228
|
|
|
220
229
|
| 情形 | 系统提示的组成 |
|
|
221
230
|
|---|---|
|
|
222
|
-
| 默认策略 | 默认策略 + 上下文规则(有上下文)+ 附件规则(有附件)+
|
|
223
|
-
| `replace-default` | 自定义策略 + 上下文规则(有上下文)+
|
|
224
|
-
| `extend-default` | 默认策略 + 上下文规则(有上下文)+
|
|
231
|
+
| 默认策略 | 默认策略 + 上下文规则(有上下文)+ 附件规则(有附件)+ 框架契约 |
|
|
232
|
+
| `replace-default` | 自定义策略 + 上下文规则(有上下文)+ 附件规则(有附件)+ 框架契约 |
|
|
233
|
+
| `extend-default` | 默认策略 + 上下文规则(有上下文)+ `Operator additions` 段 + 自定义策略 + 附件规则(有附件)+ 框架契约 |
|
|
225
234
|
|
|
226
235
|
### 默认策略
|
|
227
236
|
|
|
@@ -231,40 +240,34 @@ flowchart LR
|
|
|
231
240
|
2. **上下文与约束**:只补充草稿能推导出的背景与限制,不添加草稿没有的事实或要求。
|
|
232
241
|
3. **可执行步骤**:把含糊或多段的需求拆成编号、可执行的步骤。
|
|
233
242
|
4. **输出格式**:按需求指定结构、语言、长度与风格。
|
|
234
|
-
5.
|
|
243
|
+
5. **验收标准**:说明怎样判断结果正确。**这一项不跳过**——一行即可;草稿没有任何依据时允许用占位符。
|
|
235
244
|
6. **边界条件**:列出边界情况、无效输入,以及信息缺失时怎么处理。
|
|
236
245
|
|
|
237
|
-
|
|
246
|
+
同时有八条内容规则:
|
|
238
247
|
|
|
239
248
|
- **保留意图**:保留用户提供的信息,不删除、不篡改、不矛盾。
|
|
240
|
-
- **不编造**:只使用草稿能支持的信息;缺少必要细节时,用 `(
|
|
249
|
+
- **不编造**:只使用草稿能支持的信息;缺少必要细节时,用 `(TBD: …)` 占位(随输出语言书写),而不是编一个。
|
|
241
250
|
- **可追溯**:每个新增都要能从草稿找到明确依据或强暗示;拿不准时用占位符,不要补内容。
|
|
242
251
|
- **范围不变**:不扩大、不缩小、不改变任务方向。
|
|
243
|
-
-
|
|
244
|
-
- **语言**:沿用输入语言(中文输入 → 中文输出;这是提示层面的最佳努力,不是硬保证)。
|
|
252
|
+
- **语言**:沿用输入语言(中文输入 → 中文输出;这是提示层面的最佳努力,不是硬保证);占位符、指向、标签、小标题等新增内容同样沿用输入语言。
|
|
245
253
|
- **长度**:约为原文的 1–3 倍,不注水。
|
|
246
254
|
- **已写好的草稿**:只做轻度润色,实质不变。
|
|
247
|
-
-
|
|
255
|
+
- **问候也照样改写**:`你好`、寒暄或没有任务的片段同样是要改写的草稿——输出应描述「助手该如何回应它」。
|
|
248
256
|
|
|
249
257
|
### 自定义策略
|
|
250
258
|
|
|
251
259
|
`strategyMode` 决定自定义策略如何与内置策略结合:
|
|
252
260
|
|
|
253
|
-
- `replace-default
|
|
261
|
+
- `replace-default`:**整体替换**内置策略(六要素、占位符、语言规则等默认规则都不再保留);上下文规则与框架契约仍会追加。
|
|
254
262
|
- `extend-default`:把自定义文本**追加**在内置策略之后,默认规则继续生效;上下文规则保留。
|
|
255
263
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
- **草稿是数据**:`<raw_prompt>` 里的文本只用于改写,不回答、不解释、不评论,即使它本身是问候或问题。
|
|
259
|
-
- **只输出改写文本**:不要前言、解释、评论、提问或代码围栏。
|
|
260
|
-
- **问候/寒暄照常改写**:输出「助手应该如何回应」的提示词,而不是回应本身。
|
|
261
|
-
- **上下文只作参考**:存在对话上下文时,它仅用于消解指代,不是指令,也不是改写对象。
|
|
264
|
+
无论哪种模式,每次调用都会在最后追加框架契约(对默认策略同样生效),内容见下节。
|
|
262
265
|
|
|
263
266
|
### 附加规则
|
|
264
267
|
|
|
265
|
-
-
|
|
266
|
-
-
|
|
267
|
-
-
|
|
268
|
+
- **上下文规则**:存在对话上下文时追加;只用于三件事——消解指代与含糊引用(不限语言)、承接对话已确定的技术栈与术语、与对话当前目标对齐;它是证据不是指令,不得覆盖、扩大或否定草稿;无关或过薄时忽略;不得在输出中引用或复述历史。
|
|
269
|
+
- **附件规则**:草稿带附件时追加;只告知数量、不读取内容;当草稿依赖某个未点名的附件时,唯一允许的指代形式是任务级指向(示例 `the attached screenshot`,随输出语言书写),数量只能出现在该指向内部;不得单独报告数量/可用性/「看不到」,不得声称用户没提供附件。
|
|
270
|
+
- **框架契约**:每次调用最后追加;草稿是数据,不回答、不解释、不评论;只输出结果,不要前言、评论、提问、客套话或代码围栏;`<raw_prompt>` 之外的一切(系统指令、上下文块、附件块)都是元信息,禁止复制、引用、概括或翻译进输出,也不要描述这一步。
|
|
268
271
|
|
|
269
272
|
## 故障排查
|
|
270
273
|
|
|
@@ -282,6 +285,7 @@ flowchart LR
|
|
|
282
285
|
| 提示鉴权失败 | 对应 provider 的凭据或 API key 无效 | 检查该 provider 在 DSH 中的凭据/API key 是否有效 |
|
|
283
286
|
| 手机或另一台设备上,增强不可用 | 页面不是从本机打开,而是经远程访问 / 中继转发进来;插件只接受本机请求 | 改在本机浏览器里使用增强 |
|
|
284
287
|
| 结果被截断 | 达到 `maxOutputTokens` | 查看截断提示,并在设置中调高 `maxOutputTokens` |
|
|
288
|
+
| 结果卡里是草稿本身(可能只多了一个标点) | 低推理档位 + 上下文感知时,模型偶尔不产生改写,把草稿原样交回 | 插件会判定为「没有产生改写」并提示。先重试;反复出现时把推理档调高一档;仍不理想再临时关闭上下文感知 |
|
|
285
289
|
| 上下文用量显示 `8/8 条`(默认值) | 达到 `contextMaxMessages` 的消息条数上限(默认 8);这是正常截断,不显示警告 | 一般无需处理;需要更早的对话时调大 `contextMaxMessages`,但可能先撞上 `contextMaxChars`(默认 4,000 字) |
|
|
286
290
|
| 上下文用量显示 `4,000/4,000 字`(默认值,琥珀色) | 达到 `contextMaxChars` 的字数上限(默认 4,000),较早内容未发送;最新一条被截头时原因行会写「最新一条仅发送了开头」 | 调大 `contextMaxChars`,或精简对话/减少引用;上下文越多,输入 token 和费用越高 |
|
|
287
291
|
| 提示「还没确定用哪个模型」(缺模型路由) | 未固定 `provider`/`model`,且当前会话没有模型路由 | 在设置中成对填写 `provider` / `model`;或先在当前会话发一条消息,让插件跟随会话模型 |
|
|
@@ -347,20 +351,66 @@ npm run watch
|
|
|
347
351
|
|
|
348
352
|
**架构**
|
|
349
353
|
|
|
354
|
+
插件由宿主半与浏览器半组成,二者只通过 HTTP 路由与 `src/shared/` 中的纯函数、常量交互,源码中没有跨半 import。宿主半决定「能不能调用、怎么调用」,浏览器半决定「何时调用、结果如何回到输入框」。
|
|
355
|
+
|
|
356
|
+
宿主半 `src/`:
|
|
357
|
+
|
|
350
358
|
```text
|
|
351
359
|
src/
|
|
352
|
-
├── index.ts
|
|
353
|
-
├──
|
|
354
|
-
├──
|
|
355
|
-
├──
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
├── index.ts 装配:设置源、HTTP 路由、/enhance 命令
|
|
361
|
+
├── config.ts 设置 schema、逐请求解析、策略组装
|
|
362
|
+
├── prompts.ts 内置策略、上下文/附件规则、框架契约与 <raw_prompt> 框定
|
|
363
|
+
├── orchestrate.ts 两条增强入口共用的编排:路由解析、上下文装配、调用与日志
|
|
364
|
+
├── enhancer.ts 单次模型调用:流式拼装、超时与取消、输出归一化
|
|
365
|
+
├── enhance-routes.ts POST /dsh-prompt-enhance/enhance 与 /enhance-stream
|
|
366
|
+
├── enhance-command.ts /enhance 斜杠命令
|
|
367
|
+
├── admission.ts 准入控制:滑动窗口限流、并发上限、连续失败熔断
|
|
368
|
+
├── context.ts 会话上下文窗口的选取与字符预算
|
|
369
|
+
├── trust.ts / loopback.ts 信任闸门:宿主连接校验,缺失时退回仅回环 fence
|
|
370
|
+
├── http.ts / sse.ts 有界 JSON 读写、带回压的 SSE 写出
|
|
371
|
+
├── settings-source.ts 跨 DSH 代际的设置读取
|
|
372
|
+
├── catalog-route.ts 设置页的 provider/model 目录与路由检查端点
|
|
373
|
+
├── provider-catalog.ts provider/model 目录的只读投影
|
|
374
|
+
├── reasoning-route.ts 推理档位查询端点
|
|
375
|
+
├── reasoning-efforts.ts 档位解析:按 provider/model 询问适配器
|
|
376
|
+
├── reasoning-cache.ts 档位答案的持久缓存(DSH home,一对文件)
|
|
377
|
+
└── shared/ 两端共用:协议、字段边界、默认值、校验、归一化、流式文本
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
浏览器半 `src/client/`:
|
|
381
|
+
|
|
382
|
+
```text
|
|
383
|
+
client/
|
|
384
|
+
├── index.tsx 装配:按钮、撤销条、词典、设置镜像、全局快捷键
|
|
385
|
+
├── EnhanceButton.tsx 输入框按钮:本地拦截与请求编排
|
|
386
|
+
├── enhance-client.ts 宿主端点客户端(SSE 优先、JSON 回退、结构化错误)
|
|
387
|
+
├── ui-state.ts 结果卡状态机与外订阅(每会话一份)
|
|
388
|
+
├── ResultDock.tsx 停靠与折叠编排
|
|
389
|
+
├── ResultPanel.tsx 结果卡渲染(回填、复制、重新生成、取消)
|
|
390
|
+
├── UndoBar.tsx 撤销条
|
|
391
|
+
├── QuickSettingsMenu.tsx 右键快捷设置卡
|
|
392
|
+
├── quick-settings.ts 快捷设置的档位与写回
|
|
393
|
+
├── settings*.ts 设置镜像、读写与跨代际适配
|
|
394
|
+
├── settings-page* 插件设置页(行规格、控件、样式、文案)
|
|
395
|
+
├── llm-catalog.ts 目录查询的浏览器缓存
|
|
396
|
+
├── reasoning-options.ts 档位选项
|
|
397
|
+
├── shortcut.ts 快捷键解析与匹配(纯函数)
|
|
398
|
+
├── undo-stack.ts 每会话撤销栈(纯工厂)
|
|
399
|
+
├── session-key.ts 每会话 UI 状态键(含跨代际 shim)
|
|
400
|
+
├── locales.ts / styles.ts / ActionIcons.tsx / SparkleFishIcon.tsx
|
|
401
|
+
└── useDockAlignment.ts 停靠项与输入框的宽度对齐
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
结构约束(均可在代码中验证):
|
|
405
|
+
|
|
406
|
+
- **单一编排路径**:按钮路由与 `/enhance` 命令都调用 `orchestrate.runEnhance`,共用同一个准入闸门与同一套提示词装配,两个入口的行为不会漂移。
|
|
407
|
+
- **单一信任闸门**:每个路由都先经 `trust.ts`;宿主没有连接服务时退回 `loopback.ts` 的仅回环校验。
|
|
408
|
+
- **逐请求配置**:`settings-source.ts` 每次调用重新读取设置,改设置无需重启。
|
|
409
|
+
- **单一提示词装配点**:`system` 只在 `orchestrate.ts` 组装,常量由 `prompts.ts` 持有;产物形态只由策略层决定。
|
|
410
|
+
|
|
411
|
+
```text
|
|
362
412
|
scripts/
|
|
363
|
-
└── build.mjs
|
|
413
|
+
└── build.mjs 用 esbuild 把两半构建到 lib/
|
|
364
414
|
```
|
|
365
415
|
|
|
366
416
|
构建产物:
|
package/lib/client.js
CHANGED
|
@@ -1439,7 +1439,8 @@ var UPSTREAM_ERROR_KEYS = {
|
|
|
1439
1439
|
empty: "error.upstream.empty",
|
|
1440
1440
|
"context-window": "error.upstream.contextWindow",
|
|
1441
1441
|
"tool-call": "error.upstream.toolCall",
|
|
1442
|
-
"max-tokens": "error.upstream.maxTokens"
|
|
1442
|
+
"max-tokens": "error.upstream.maxTokens",
|
|
1443
|
+
degenerate: "error.upstream.degenerate"
|
|
1443
1444
|
};
|
|
1444
1445
|
var CLIENT_ERROR_KEYS = {
|
|
1445
1446
|
unreachable: "error.client.unreachable",
|
|
@@ -2028,6 +2029,7 @@ var zh = {
|
|
|
2028
2029
|
"error.upstream.contextWindow": "\u5185\u5BB9\u8D85\u51FA\u6A21\u578B\u7684\u4E0A\u4E0B\u6587\u7A97\u53E3\uFF0C\u8BF7\u7CBE\u7B80\u539F\u6587\u6216\u6362\u4E00\u4E2A\u6A21\u578B\u3002",
|
|
2029
2030
|
"error.upstream.toolCall": "\u6A21\u578B\u5C1D\u8BD5\u8C03\u7528\u5DE5\u5177\uFF0C\u800C\u63D0\u793A\u8BCD\u589E\u5F3A\u53EA\u9700\u8981\u7EAF\u6587\u672C\uFF1B\u8BF7\u6362\u4E00\u4E2A\u6A21\u578B\u540E\u91CD\u8BD5\u3002",
|
|
2030
2031
|
"error.upstream.maxTokens": "\u7ED3\u679C\u8FBE\u5230\u4E86\u300C\u8F93\u51FA token \u4E0A\u9650\u300D\u3002\u8BF7\u8C03\u9AD8\u8BE5\u8BBE\u7F6E\uFF0C\u6216\u7CBE\u7B80\u539F\u6587\u540E\u91CD\u8BD5\u3002",
|
|
2032
|
+
"error.upstream.degenerate": "\u6A21\u578B\u8FD9\u6B21\u6CA1\u6709\u4EA7\u751F\u6539\u5199\u3002\u8BF7\u91CD\u8BD5\uFF1B\u82E5\u53CD\u590D\u51FA\u73B0\uFF0C\u628A\u63A8\u7406\u6863\u8C03\u9AD8\u4E00\u6863\uFF0C\u6216\u4E34\u65F6\u5173\u95ED\u4E0A\u4E0B\u6587\u611F\u77E5\u3002",
|
|
2031
2033
|
"settings.summary": "\u6A21\u578B\u3001\u4E0A\u4E0B\u6587\u4E0E\u8D44\u6E90\u9650\u5236",
|
|
2032
2034
|
"settings.title": "\u63D0\u793A\u8BCD\u589E\u5F3A",
|
|
2033
2035
|
"settings.description": "\u628A\u8F93\u5165\u6846\u8349\u7A3F\u6539\u5199\u6210\u7ED3\u6784\u5316\u63D0\u793A\u8BCD\uFF0C\u6309\u9700\u8865\u9F50\u89D2\u8272\u4E0E\u76EE\u6807\u3001\u4E0A\u4E0B\u6587\u4E0E\u7EA6\u675F\u3001\u53EF\u6267\u884C\u6B65\u9AA4\u3001\u8F93\u51FA\u683C\u5F0F\u3001\u9A8C\u6536\u6807\u51C6\u4E0E\u8FB9\u754C\u6761\u4EF6\u3002\u539F\u6587\u4FDD\u7559\uFF0C\u5931\u8D25\u65F6\u4E0D\u6539\u52A8\u8349\u7A3F\u3002",
|
|
@@ -2095,7 +2097,7 @@ var zh = {
|
|
|
2095
2097
|
"settings.row.timeoutMs.label": "\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
2096
2098
|
"settings.row.timeoutMs.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u7AEF\u5230\u7AEF\u8D85\u65F6\uFF1B\u9ED8\u8BA4 60000\u3002",
|
|
2097
2099
|
"settings.row.strategyMode.label": "\u63D0\u793A\u8BCD\u7EC4\u5408\u65B9\u5F0F",
|
|
2098
|
-
"settings.row.strategyMode.hint": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD\u975E\u7A7A\u65F6\uFF1A\u6574\u4F53\u66FF\u6362\u5185\u7F6E\u7B56\u7565\uFF08\u4ECD\u4FDD\u7559\
|
|
2100
|
+
"settings.row.strategyMode.hint": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD\u975E\u7A7A\u65F6\uFF1A\u6574\u4F53\u66FF\u6362\u5185\u7F6E\u7B56\u7565\uFF08\u4ECD\u4FDD\u7559\u4E09\u6761\u6846\u67B6\u7EA6\u675F\u2014\u2014\u8F93\u5165\u662F\u6570\u636E\u3001\u53EA\u8F93\u51FA\u7ED3\u679C\u3001\u4E0D\u590D\u5236\u89C4\u5219\u6587\u672C\uFF09\uFF0C\u6216\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u4E4B\u540E\uFF08\u5185\u7F6E\u89C4\u5219\u7EE7\u7EED\u751F\u6548\uFF09\u3002",
|
|
2099
2101
|
"settings.row.systemPrompt.label": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD",
|
|
2100
2102
|
"settings.row.systemPrompt.hint": "\u7559\u7A7A\u4F7F\u7528\u5185\u7F6E\u589E\u5F3A\u7B56\u7565\u3002",
|
|
2101
2103
|
"settings.row.systemPrompt.placeholder": "\u4F8B\uFF1A\u628A\u7528\u6237\u7684\u4E2D\u6587\u8F93\u5165\u7FFB\u8BD1\u6210\u82F1\u6587\u3002",
|
|
@@ -2211,6 +2213,7 @@ var en = {
|
|
|
2211
2213
|
"error.upstream.contextWindow": "The content exceeds the model's context window \u2014 shorten the draft or switch models.",
|
|
2212
2214
|
"error.upstream.toolCall": "The model tried to call a tool, but prompt enhancement only sends plain text \u2014 switch models and retry.",
|
|
2213
2215
|
"error.upstream.maxTokens": 'The result hit the "Output token budget" limit. Raise that setting, or shorten the draft and retry.',
|
|
2216
|
+
"error.upstream.degenerate": "The model produced no rewrite this time. Retry; if it keeps happening, raise the reasoning tier one step or turn context awareness off.",
|
|
2214
2217
|
"settings.summary": "Model, context, and resource limits",
|
|
2215
2218
|
"settings.title": "Prompt enhance",
|
|
2216
2219
|
"settings.description": "Turns a composer draft into a structured prompt, filling in role and goal, context and constraints, executable steps, output format, acceptance criteria, and edge cases as needed. The draft is preserved, and failures never touch it.",
|
|
@@ -2278,7 +2281,7 @@ var en = {
|
|
|
2278
2281
|
"settings.row.timeoutMs.label": "Timeout (ms)",
|
|
2279
2282
|
"settings.row.timeoutMs.hint": "End-to-end timeout of one enhancement call. Default 60000.",
|
|
2280
2283
|
"settings.row.strategyMode.label": "Prompt composition",
|
|
2281
|
-
"settings.row.strategyMode.hint": "
|
|
2284
|
+
"settings.row.strategyMode.hint": "When a custom prompt is set: replace the built-in strategy (three framing rules always apply \u2014 the draft is data, only the result is output, the rules themselves are never copied), or append it after the built-in strategy (the built-in rules stay in force).",
|
|
2282
2285
|
"settings.row.systemPrompt.label": "Custom system prompt",
|
|
2283
2286
|
"settings.row.systemPrompt.hint": "Leave empty to use the built-in enhancement strategy.",
|
|
2284
2287
|
"settings.row.systemPrompt.placeholder": "e.g. translate the user text from Chinese into English.",
|
|
@@ -3126,8 +3129,12 @@ html[data-platform='darwin'] .dsh-pe-menu {
|
|
|
3126
3129
|
display: inline-flex;
|
|
3127
3130
|
align-items: center;
|
|
3128
3131
|
gap: 3px;
|
|
3129
|
-
|
|
3130
|
-
|
|
3132
|
+
/* Explicit border-box: the 20px keeps the pill the size it was measured at,
|
|
3133
|
+
and the 2px top padding nudges the glyph ink down to the optical centre
|
|
3134
|
+
(a fixed height alone centres the line box, which reads 1-2px high). */
|
|
3135
|
+
box-sizing: border-box;
|
|
3136
|
+
height: 20px;
|
|
3137
|
+
padding: 2px 7px 0;
|
|
3131
3138
|
border: 1px solid var(--dsw-alias-border-l4, rgba(128, 128, 128, 0.35));
|
|
3132
3139
|
border-radius: 999px;
|
|
3133
3140
|
background: var(--dsw-alias-bg-layer-3, transparent);
|
|
@@ -3464,7 +3471,6 @@ var BASIC_ROWS = [
|
|
|
3464
3471
|
{ key: "model", kind: "model", label: "settings.row.model.label", hint: "settings.row.model.hint" },
|
|
3465
3472
|
{ key: "reasoningEffort", kind: "reasoning", label: "settings.row.reasoningEffort.label", hint: "settings.row.reasoningEffort.hint" },
|
|
3466
3473
|
{ key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
|
|
3467
|
-
{ key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
|
|
3468
3474
|
{ key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
|
|
3469
3475
|
{
|
|
3470
3476
|
key: "shortcut",
|
|
@@ -3480,6 +3486,9 @@ var BASIC_ROWS = [
|
|
|
3480
3486
|
var ADVANCED_ROWS = [
|
|
3481
3487
|
{ key: "foldAnimation", kind: "boolean", label: "settings.row.foldAnimation.label", hint: "settings.row.foldAnimation.hint" },
|
|
3482
3488
|
{ key: "autoFold", kind: "boolean", label: "settings.row.autoFold.label", hint: "settings.row.autoFold.hint" },
|
|
3489
|
+
// Display-only, set once: it shares the fold switches' fate — none of the
|
|
3490
|
+
// three changes the text that gets applied — and does not earn a basic slot.
|
|
3491
|
+
{ key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
|
|
3483
3492
|
{ key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
|
|
3484
3493
|
// Set-once tuning, not a per-use switch: it sits next to the strategy row
|
|
3485
3494
|
// because both shape how the rewrite is produced, not how often it runs.
|
|
@@ -3726,7 +3735,7 @@ var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
|
|
|
3726
3735
|
var ISSUE_URL = "https://github.com/surfishs/dsh-prompt-enhance/issues";
|
|
3727
3736
|
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";
|
|
3728
3737
|
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";
|
|
3729
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
3738
|
+
var PLUGIN_VERSION = true ? "0.1.10" : "0.0.0";
|
|
3730
3739
|
var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
|
|
3731
3740
|
var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
|
|
3732
3741
|
var HEADER_TITLE_STYLE = {
|
|
@@ -4148,7 +4157,7 @@ function PageHeader(props) {
|
|
|
4148
4157
|
"npm"
|
|
4149
4158
|
] }),
|
|
4150
4159
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("a", { href: ISSUE_URL, target: "_blank", rel: "noreferrer", className: "dsh-pe-header-link", children: [
|
|
4151
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 11, height: 11, viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "none", stroke: "currentColor", strokeWidth:
|
|
4160
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 11, height: 11, viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", d: "M2.8 2h7l3.4 3.4V14H2.8zM9.8 2v3.4h3.4M5.2 8.6h5.6M5.2 11.2h5.6" }) }),
|
|
4152
4161
|
props.issue
|
|
4153
4162
|
] }),
|
|
4154
4163
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { style: HEADER_VERSION_STYLE, children: [
|