DSH Prompt Optimization (dsh-prompt-optimizer): Rewriting Draft Prompts in the Input Box

Introduction

When writing prompts in DeepSeek Harness (DSH), the common practice is to first write structured copy elsewhere, then paste it into the chat input box; or repeatedly manually edit the title, constraints, and output format against a colloquial draft. There are also independent prompt optimization tools in the community, but they often open a separate workspace, disconnecting from the current conversation and model.

@infcel/dsh-prompt-optimizer (repo infcel/dsh-prompt-optimizer) integrates “optimization” into the Harness composer: a new ✦ Optimize button appears on the right side of the input box. It uses the current conversation’s default model to rewrite the draft into a clearer structured prompt and writes it back into the input box; one undo restores the original. The maintainer is infcel, categorized as “Model Inference” in the plugin directory.

What is This

The plugin positioning can be summarized as: A prompt rewriting assistant on the DSH input side. It only changes the wording and structure of the draft, not executing the tasks within the prompt for you; calls rely on the host’s llm.stream() and agentDefaultModel.currentSelection(), no need to configure a separate set of API Keys (similar to the “one-click optimization next to the input box” product form of linshenkx/prompt-optimizer, but templates and implementation are original to this repo).

Current npm package version is 1.1.2, license MIT. Runtime requirements see package.json engines: DSH ≥ 0.2.0-rc.1, Node ^22.19.0 or ≥24.0.0.

Core Features

Optimization Process Inside the Input Box

  1. Write a sentence or a paragraph of draft in the composer.
  2. Click the ✦ Optimize on the right side of the input box to open the floating panel.
  3. Select a mode (or use “Auto”), optional output language (Follow original / Simplified Chinese / English).
  4. Streaming generate results; after confirmation, fill back via insertText, ⌘Z (Windows: Ctrl+Z) one-step undo.

When a selection exists, only the selected segment is optimized; if there is no selection, the whole paragraph is processed. Iterative mode allows filling in an “intent for this change”; leaving it empty and clicking optimize will not send a request.

Five Modes

Mode Applicable Situation
Auto Classified by Host side lib/heuristic.js rules (via POST /classify, 300ms debounce)
Structured Needs role-based prompts that can be reused long-term (# Role and sections like capabilities/constraints/process)
Analytical Complex tasks requiring background and verifiable criteria
Polish Short sentences are vague, want to condense into a natural language paragraph ready to send
Iterative Have a draft, want to fine-tune based on modification intent while preserving structure

“Auto” judgment summary: Very long with skeleton -> Structured; Very long with step/process words -> Analytical; Under 400 words and no # headers -> Polish; others default to Analytical.

Edge Cases (Explicit in README)

  • {{variable}} characters are preserved character-by-character; if a variable is missing after generation, it will be indicated in metadata.
  • If the draft contains an @ reference chip, to avoid coordinate misalignment, optimize the whole paragraph uniformly, and the panel displays a corresponding banner.
  • If you change the input box during generation, the replacement will be blocked; you need to choose “Overwrite with new result” or cancel.
  • Single draft upper limit 20k characters (/meta limits.maxChars); very long opens panel and warns.
  • No history saved, no disk logs; preferences stored in localStorage key dsh.prompt-optimizer.prefs ({mode, language}).

The plugin only registers two slots: conversation.input.right and conversation.input.overlay. Styles use host tokens, requests are limited to same-origin /api/dsh-prompt-optimizer/*.

Installation and Enablement

bundle/patch are snapshotted when Harness starts. After installation, you need to restart to verify the button.

Desktop

On the plugin management page click Add Plugin, fill in package name @infcel/dsh-prompt-optimizer; or called by agent:

plugin_manager(action: "install_bundle", target: "@infcel/dsh-prompt-optimizer")

web / Custom profile

Desktop’s profile is exclusively owned by Electron, dsh plugin --profile desktop add will report “managed exclusively”; the following commands are for web or custom profiles:

dsh plugin --profile web add @infcel/dsh-prompt-optimizer

Offline Package or Local Directory

Method install target
NPM package name @infcel/dsh-prompt-optimizer
Offline tgz (output of npm run release) /absolute/path/infcel-dsh-prompt-optimizer-1.1.1.tgz (README example filename, subject to your local build)
Development source code directory Absolute path of this repo

Post-Installation Verification

Restart Harness → ✦ Optimize appears on the right side of the input box → Write a draft and click to test. You can also check the “Prompt Optimization” entry on the plugin management page; in list_plugins, include:prompt-optimizer should be enabled=true and fiberPhase=active.

Typical Usage

Polish a short instruction. In the composer, write “Help me refactor this function, make it fast”, select “Polish” or “Auto”, after generation Ctrl+Enter (macOS: ⌘Enter) replaces it into the input box, then fine-tune as needed.

Structured role prompt. The draft is long and contains “You are…” or variable placeholders. Select “Structured” to get a version with sections like “Expert in / Not responsible for”, “Must / Prohibited / Output”, etc., for easy reuse.

Partial rewrite. Select a small section within a paragraph, click optimize, only that paragraph is replaced, the rest remains unchanged.

Iterate existing prompt. Select “Iterative”, write in the extra input box something like “Make it shorter, keep variables, add a ‘Do Not Do’ list”, then click optimize.

Applicable Scenarios and Notes

Who is it for: Developers who frequently write prompts in DSH, want to minimize switching to external tools, and have configured the Harness default model.

Not suitable to replace: The plugin does not execute prompts, does not render media, does not provide a template library or favorites; it also does not fill in values for {{variables}}.

Permissions and Security: The plugin runs with the current DSH process permissions, and model calls go through the host session. It is advisable to read the repository source code and MIT license before installing; the community directory skillhub.cn is an independent site with no official affiliation to DeepSeek / Hypothesis.

Failures and Fallbacks: When the host lacks model service, the panel warns and does not initiate a request; upstream 429 can be retried or the original text copied; accessing API routes while not logged in results in 401 (GUI session only). Disabling the plugin takes effect immediately:

plugin_manager(action: "set_plugin", target: "include:prompt-optimizer", enabled: false)

Uninstall example:

plugin_manager(action: "remove_bundle", target: "@infcel/dsh-prompt-optimizer")

After modifying client.js, a hard refresh (⇧⌘R) is recommended; modifying the Host side requires restarting Harness.

Conclusion

@infcel/dsh-prompt-optimizer brings prompt optimization into the DSH input box: using the current conversation model to stream rewrite drafts, supporting various structures and polish strategies, fill-back is undoable, and it handles selection, @ references, and draft conflicts clearly. If you are looking for “Model Inference” type tools in the Harness ecosystem, you can view instructions and updates from the directory page or GitHub repository.

  • Directory page: https://www.skillhub.cn/plugins/infcel/dsh-prompt-optimizer
  • GitHub: https://github.com/infcel/dsh-prompt-optimizer
  • npm: https://www.npmjs.com/package/@infcel/dsh-prompt-optimizer
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye