Introduction¶
DeepSeek Harness (DSH) adopts the philosophy that “everything is a plugin.” When developing agents or debugging models, developers often need to rewrite vague drafts into structured, executable prompts. dsh-prompt-refiner is an input bar “Prompt Refinement” plugin designed to address issues such as chaotic prompt structures, high refinement costs (especially regarding thinking token billing), and a lack of monitoring data.
Core Features¶
The plugin provides the following capabilities:
* Structured Rewriting: Rewrites input text into a “Goal / Background / Steps / Requirements / [Assumptions]” structure.
* Cost Routing: The refinement process can be routed to cheaper models (e.g., deepseek-v4-flash) instead of following the session’s default model.
* Result Caching: Caches refinement results based on an LRU strategy, allowing zero-cost reuse for identical inputs.
* Token Statistics: Displays usage in the panel and persists data to disk as JSONL, supporting queries via GET /prompt-refine/stats.
* Thinking Effort Control: Defaults to off to avoid unnecessary thinking token consumption.
* Comparison Panel: Displays the original text alongside the rewritten result, with the assumptions section highlighted independently.
* Sanitization and Validation: Includes result length guardrails; truncation due to max-tokens is marked as a failure and discarded.
Installation and Configuration¶
The plugin offers two installation methods: Dynamic Mode (installation-free) and Static Mode (recommended).
Dynamic Mode (Preview)¶
In the DSH “Cordis Dynamic Plugins” panel:
1. Create a new plugin;
2. Paste the full content of src/host.js into code.host, and the full content of src/client.js into code.client;
3. Activate and authorize; a ✨ button will appear in the input bar.
Note: The dynamic version is limited to following the session’s default model selection, caches only in memory, and does not persist statistics to disk.
Static Mode (Recommended)¶
Install using the npm package:
npm publish # 或先在本地 npm pack
dsh plugin --profile web add dsh-prompt-refiner
After installation, register the plugin line in ~/.dsh/profiles/web/cordis.patch.yml:
- insert:
- id: dsh-prompt-refiner
name: 'dsh-prompt-refiner'
Takes effect after restarting the dsh web service.
Configuration File¶
Edit $DSH_HOME/prompt-refiner/config.json (default: ~/.dsh/prompt-refiner/config.json). The priority for configuration items is: cordis entry > config.json > built-in defaults.
{
"model": "deepseek-v4-flash", // 优化器模型;null = 跟随会话当前模型
"provider": null, // null = 跟随会话当前 provider
"reasoningEffort": "off", // 思考档位:'off'|'low'|'high'|'max'
"maxTokens": 2048,
"temperature": 0.3,
"minChars": 0,
"maxChars": 8000,
"resultMaxChars": 4000, // 结果长度护栏
"cacheMax": 200,
"cacheTtlMs": 86400000,
"metrics": true // 统计落盘开关
}
Key Configuration Notes: Thinking Effort¶
The DeepSeek adapter counts model thinking tokens under outputTokens. If the effort level is not explicitly specified, the adapter defaults to high, causing refinement tasks to generate large amounts of unnecessary thinking content.
The plugin defaults to sending reasoningEffort: 'off' and displays the actually effective level in the panel (e.g., Thinking off). If the requested level is not supported, the plugin automatically falls back to the most cost-effective level supported by the model.
Statistics and Monitoring¶
The plugin provides two types of data feedback:
1. Persisted File: $DSH_HOME/prompt-refiner/metrics.jsonl. A record is appended for each refinement, including timestamp, model, cache hit status, skip status, actual thinking effort level, character count, input/output/thinking tokens, and duration.
2. API Query: GET /prompt-refine/stats. Used to summarize memory accumulation since host startup and the location of the persisted directory.
3. Panel Display: Displays model, character count changes, duration, cache status, thinking effort level, and token statistics in real-time.
Known Limitations and Differences¶
- Differences from dsh-prompt-optimize-plugin: This plugin completes the cost control layer. Compared to
dsh-prompt-optimize-plugin, this plugin supports cost routing (using cheaper models), LRU caching, statistics persistence, and default off thinking effort (to prevent unnecessary billing). - Result Truncation: If a result is truncated due to
max-tokens, it is marked as a failure and discarded; incomplete prompts will not be applied. - Unverified Items:
- CLI usage with local path mounting (pointing directly to this directory without publishing) has not yet been verified.
- The visual appearance of the panel in a real browser needs human verification.
- The implementation status of the Phase A route (auto-interception).
Summary¶
dsh-prompt-refiner is a DSH plugin focused on prompt structuring and cost control. By defaulting to off thinking effort, supporting cache routing, and providing comprehensive statistics persistence, it helps developers effectively control Token consumption during prompt refinement.
Catalog Page: https://www.skillhub.cn/plugins/glh5835/dsh-prompt-refiner
GitHub: https://github.com/glh5835/dsh-prompt-refiner