DeepSeek Harness (DSH) uses a plugin-based architecture. When writing or debugging prompts, it often takes repeated refinement to get an ideal response. dsh-prompt-optimizer aims to solve this problem by mounting an “Optimize” entry point into the Web GUI input toolbar, allowing users to polish or restructure the current draft before sending.
Plugin Overview¶
- Plugin Name:
dsh-prompt-optimizer - Maintainer: rayhanlu0519-a11y
- License: MIT
- Core Functionality: Adds a “✦ Optimize” button to the DSH Web GUI chat input toolbar (to the left of the model switcher button), supporting manual optimization and an “auto-optimize before sending” toggle.
Core Features¶
- UI Mounting: The plugin registers to the official
conversation.input.rightslot and renders in the bottom toolbar of the input box, directly to the left of the model switcher button. The color scheme automatically adapts to DSH light/dark themes. - Manual Optimization: Click the “✦ Optimize” button in the toolbar to optimize the current input box content. If the draft is empty, the button is disabled and shows a hint.
- Automatic Interception: After enabling the “auto-optimize before sending” toggle, the system intercepts
Enterkey presses and send button clicks before sending (during the document capture phase), first displaying a comparison result to decide whether to send. - Before/After Comparison and Fallback: A dialog shows the original text (read-only) and the optimized content (editable). Four options are provided: adopt and send, fill into the input box only, send original, and discard. If optimization fails or times out, the system automatically falls back to sending the original text without interrupting the conversation.
- Dual Backend Support:
DSH built-in routing: Reuses the harness’sctx.llm; no API key required.OpenAI-compatible: Supports/chat/completionsand is compatible with the configuration approach used by linshenkx/prompt-optimizer.
- Secure Storage: The API key is stored only on the host side in
~/.dsh/dsh-prompt-optimizer.json. The browser side only sees a masked value; the original content is not exposed.
Installation and Activation¶
Option 1: Install as a bundle (persistent)¶
Use this when the plugin must remain active after a restart.
pnpm pack
dsh plugin --profile web add ./dsh-prompt-optimizer-0.1.0.tgz
Option 2: Development injection (hot-swap)¶
Use this for local development and debugging. It requires DSH_CHECKOUT to point to a source checkout.
DSH_CHECKOUT=/path/to/dsh-checkout npm run build
dev_build_plugin <本目录>
dev_inject_plugin <本目录>
# 刷新 Web GUI 生效
Configuration¶
Click “⚙” in the input toolbar to open the settings panel:
| Setting | Description |
|---|---|
| Backend Mode | Choose DSH built-in routing (no key) or OpenAI-compatible provider |
| Provider | DeepSeek (https://api.deepseek.com/v1), OpenAI, or custom |
| API Key | Configure the key. It is actually stored in the host config file ~/.dsh/dsh-prompt-optimizer.json |
| Temperature | Controls output randomness, range 0–2 |
| Max Output | Output token limit, range 16–16384 |
| Rounds | Number of optimization rounds, range 1–3 (multiple rounds = refine the previous round’s result) |
Usage Examples¶
- Manual optimization: Enter a draft in the input box, click the “✦ Optimize” button in the toolbar, confirm the result in the dialog, and click “Adopt and send”.
- Automatic optimization: Enable the “Auto” toggle in settings, enter content, and press Enter directly. The system intercepts the send request and opens a comparison dialog for confirmation or editing before submitting.
- Connectivity test: Use the “Test connectivity” feature in the settings panel to verify that the API key and endpoint configuration are correct.
Performance and Notes¶
- Performance Overhead: The interception logic is O(1); there is no performance overhead when auto mode is disabled. The client bundle size is about 55 KB (gzip ≈ 12 KB).
- Development Dependency: Plugin development depends on DSH_CHECKOUT pointing to a DSH source checkout.
- License Compatibility: The plugin itself is licensed under MIT, while the project it is compatible with (e.g., prompt-optimizer) is AGPL-3.0. The plugin does not copy its source code or prompts; it only follows its OpenAI-compatible protocol.
For more details and source code, see the GitHub repository.