@xyavid/dsh-prompt-polish
在输入框旁添加一键优化提示词按钮 适合需要快速将草稿改写为结构化提示词并支持一键撤回的Web端用户。
安裝
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:xyavid/dsh-prompt-polish說明文件
閱讀完整 README ↗Usage
Type a draft, then click the sparkle button left of the model name.
The three states
| State | Icon | Click behaviour | Hover text |
|---|---|---|---|
| Idle | ✦ sparkle | start polishing | 优化提示词 |
| Running | ↻ spinner (hover turns red) | cancel the in-flight call | 取消优化 |
| Done | ↺ undo arrow (accent colour) | restore the original draft | 撤回优化 |
What happens, step by step
- Local guards run first. Empty or whitespace-only drafts, attachment-only drafts (a chip's trailing zero-width space is folded away correctly), drafts over
maxInputChars, drafts containing/commandsor@references, and a composer in a non-plainphase are refused with a tooltip. Chips are refused because filling text back would destroy them. - The button spins while the host calls the model. Your draft is untouched during the call, so cancelling at any moment leaves exactly what you typed.
- On success the result is written back through the official editor API, the native undo stack stays intact (
Ctrl+Zworks), and the same button becomes the undo arrow. - Undo restores the original draft and returns the button to idle. If you keep typing after the result lands, the undo state retires itself so stale text can never overwrite your newer edits.
Interaction rules worth knowing
- Pressing send while a polish is running cancels the call and sends your original text.
- Editing the draft while a polish is running means the result is not written back; the button returns to idle and the hover text explains why.
- The undo affordance expires after
undoWindowMs(default 60 s). The button reads that value through the client settings mirror, and falls back to 60 s when the mirror is unavailable (see Known limitations). - Only one polish runs at a time per session, and a late response from a cancelled call is discarded.
Configuration
Everything lives on the prompt-polish composition entry, editable from Settings → 插件配置 or directly in that entry's config block in the profile's cordis.patch.yml. Since 0.1.7 the settings domain writes edits back to the profile patch, and the plugin reads the .volatile() references declared in its schema, so a save takes effect on the next call without a restart or a remount.
Defaults come from two places, in this order: the schema defaults below, overridden by the composition layer's config block in cordis.patch.yml, overridden by your settings section. Out of the box the composition layer pins enabled, temperature, maxOutputTokens, timeoutMs, and maxInputChars, so those five values are the effective defaults even if you never open the settings page.
| Field | Default | Applies | Description |
|---|---|---|---|
enabled | true | live | Master switch; off hides the button and disables the route |
strength | balanced | next call | conservative — fix and structure only; balanced — also fill in implicit prerequisites; aggressive — rewrite as a full task brief (length ceiling relaxed to ~1500 characters) |
temperature | 0.3 | next call | Lower keeps the rewrite more faithful to the original |
maxOutputTokens | 2048 | next call | Output budget of one call; truncated output is refused, never written back, so raise this when using aggressive with reasoning enabled |
maxInputChars | 12000 | next call | Input cap counted in Unicode code points (an emoji is one character); over-limit drafts are rejected, never truncated |
timeoutMs | 60000 | next call | End-to-end deadline of one call; timeout surfaces as a distinct message, not a generic failure |
systemPrompt | empty | next call | Your own strategy text; empty uses the built-in strategy |
strategyMode | replace-default | next call | replace-default swaps the built-in strategy out entirely (its hard rules — preserve intent, never fabricate, body-only output, mirror the input language — are not retained automatically); extend-default appends your text after the built-in strategy, keeping those rules in force |
undoWindowMs | 60000 | live | How long the undo affordance stays available (0 = forever); the button reads it through the client configForms mirror |
"Applies" mirrors the namespace's applies: 'live' registration: every field is re-read on each request, and
enabled / undoWindowMs additionally affect what the browser shows without a restart. Only changes to the
composition layer itself (a cordis.patch.yml edit) require reloading the profile directory, and patchReload: live
profiles pick those up on save too.
The same values can be set from the user patch layer without touching the plugin: