dsh-input-optimizer: Rewrites drafts before sending and manages conversation branches

Preface

When writing prompts in DeepSeek Harness (DSH), common problems include unclear grammar and references, reversed step ordering, and constraints and goals scattered apart. The model takes things literally, so results deviate from your intent. Fixing and resending works, but there is no side path that “only rewrites the wording without answering for you”; the conversation log is append-only, and when you want to edit an already-sent message or switch to a different answer path, you have to track branches yourself.

The community plugin dsh-input-optimizer (maintainer: Xxsttb, category: model reasoning) is introduced below. It adds a four-pointed star button to the left of the model selector in the input box, and rewrites unsent drafts with the current conversation model (low reasoning effort by default); it also provides editing of sent messages, memory-free regeneration, a right-side memory tree, and disables misleading edits when tools have already modified the workspace. The code and documentation are marked as AI-generated at the user’s request.

What Is This

dsh-input-optimizer is a DeepSeek Harness plugin with package name dsh-input-optimizer, current version 1.0.0 (MIT). The Host side calls ctx.llm.stream() to perform draft rewriting; the Web client injects session UI, the right sidebar, and the settings page. It does not generate answers or add facts; what it returns is a clearer wording of the same request.

In the ecosystem, DSH emphasizes “everything is a plugin”; the SkillHub directory page is a community site with no official affiliation with DeepSeek / HF Trade (Hunyuan/High-Flyer). Source code and documentation are available in the GitHub repository.

Core Features

1. Rewrite Drafts Before Sending

Layout sketch:

[ ★ ] [ Model selector ] [ Send ]
  ^
  The button is here

After pressing the four-pointed star, the Host sends the current draft to the model selected in the current conversation (low reasoning effort by default), writes the rewritten result back into the input box, and you can review it before sending. Rewriting is a side-path call: it carries no session id, does not enter the conversation log, and does not trigger the agent-loop that listens for llm/stream.

Rewriting priorities (five goals from the README):

# Goal Meaning
1 Preserve intent Do not add answers, opinions, examples, or opening remarks
2 Fix language Grammar, spelling, punctuation, references, machine-translation tone; preserve the original language and register
3 Fix execution order Step order, prerequisites, separation of constraints and objects, etc.
4 Point out obvious implicit premises Do not invent new requirements
5 Tighten Remove filler and repetition

Hard rules include: code, commands, paths, identifiers, numbers, URLs, error messages, and citations are preserved byte-for-byte; Markdown structure and list markers are kept as-is; output rewrites only the body, with no Rewritten:-style prefixes.

Behavioral points:

  • If you keep editing while rewriting is in progress, the result will not overwrite the new input; the button will indicate that the draft has changed.
  • The entire draft is replaced; one undo can restore it.
  • Empty drafts are rejected before contacting the provider.

2. Edit Sent User Messages

Hovering over a user message reveals a pencil. Clicking it does not touch the draft in the input box; instead, it replaces the input box with an editing area, and the original message remains unchanged in the conversation.

  • Default Ctrl+Enter (Cmd+Enter on macOS) or click Send; a lone Enter inserts a line break.
  • Esc or the Cancel button abandons editing.
  • After sending, the Harness forks: the fork point is the event before that message; the edited text enters a new branch; the original message and original reply remain in the original conversation. A new session entry with an incremented title appears in the session list.

3. Re-Ask Without Inheriting Memory

Each model reply has a circular restart arrow next to it. It sends only that single user message in a brand-new session, without previous turns; the working directory is the same, but the model cannot see earlier context or the file state changed by the current reply. The original answer is kept unchanged; the new answer, like the edit branch, is included in the version record for the same question.

4. Memory Tree

The Memory tree tab in the right sidebar shows “every question and every answer it received,” rather than a full genealogy graph.

  • Streaming (default): grows in real time with the conversation you are currently reading.
  • Full: includes branches cut from earlier conversations in the version record.

Nodes display the complete question text; hovering shows a Q&A summary. When there are multiple answers, it marks the source (original, rewritten question, memory-free regeneration) and offers ‹ N/M › switching, sharing the same local selection state with the in-conversation arrows and inline blocks. The answer row can be opened with ↗ to open the corresponding conversation (restoring archived sessions first); a branch answer can be right-clicked for “Delete this branch” (removes it from the version record only, without deleting the Harness session on disk).

5. Block Edits That Would Mislead the Model

If a turn’s reply used tools that leave traces (such as write, edit, shell), or the @-mentioned file fingerprints do not match what the plugin first recorded, the pencil and regeneration are disabled with the reason shown. Editing/regeneration is allowed only when read-only tools (e.g., read, grep, web_fetch, etc. from the README whitelist) were used. Pure chat replies remain editable. The pencil on the first message of a conversation is disabled (it cannot be forked).

Environment Requirements

  • DeepSeek Harness 0.2.0-rc.2 or newer (dsh.engines.dsh in package.json).
  • A profile with the Web UI and settings service (desktop / web, etc.); the settings page depends on @deepseek-ai/dsh-settings and @deepseek-ai/dsh-config-editor.
  • At least one usable LLM provider.

Installation and Enablement

The plugin runs with the permissions of the current DSH process; before installing you should read the source code and the MIT license to confirm you accept its behavior. The README does not provide a dsh plugin add github:… form; you should use a local path or tarball.

In the repository checkout directory:

dsh plugin --profile <profile> add /absolute/path/to/dsh-input-optimizer

Or install after packaging (the profile’s actual storage form):

pnpm pack
dsh plugin --profile <profile> add ./dsh-input-optimizer-1.0.0.tgz

After reloading the application, you can verify the Host side:

curl http://127.0.0.1:19387/plugins/input-optimizer/models

A response of {"ok":true,"providers":[…]} indicates the Host is ready; the star button appears after the next page load.

Uninstall:

dsh plugin --profile <profile> remove dsh-input-optimizer

Settings may remain under the input-optimizer entry in the profile’s cordis.patch.yml, and must be manually deleted for a thorough cleanup. Do not use link: for installation and then switch to a tarball (it may wipe the source directory); do not manually edit the profile’s package.json / node_modules; always use dsh plugin add.

Settings

Open Settings → Input Optimizer. Configuration is written into the profile’s cordis.patch.yml and persists after restart.

Field Default Purpose
Rewrite instructions Built-in prompt System prompt for each rewrite; clear and save to restore default
Follow conversation model On On: use the current conversation model; Off: use the fixed provider/model below
Provider / Model Empty Used when following is off, or as a fallback when following is unavailable
Reasoning effort low none means do not send this field
Max output tokens 4096 0 means no limit
Timeout 60000 ms Wall-clock limit for a single rewrite
Send edit with Ctrl+Enter Options: Ctrl+Shift+Enter, Alt+Enter, or button only

Typical Usage

  1. Write a long prompt in the Composer, click the ★ to the left of the model selector, wait for the rewrite to finish, read through the input box, then click Send.
  2. Discover a sent user message was worded incorrectly: hover over the message → pencil → modify in the editing area → send with Ctrl+Enter, continuing the conversation in a new branch; use the ‹ N/M › next to the message or the memory tree to compare versions.
  3. Want a model reply to be answered “from scratch” with no context: click the restart arrow under that reply; the Harness switches to a new session; the original reply remains, and you can switch between reading them with the arrows under the same question.
  4. Need an overview of “multiple answers to the same question”: open the right-side Memory tree, switch between streaming/full modes, and use ↗ to enter archived branches to continue working.

Suitable Scenarios and Cautions

Suitable for: Those who frequently write multi-step agent prompts and need unified polishing before sending without changing intent; those who need to fine-tune questions after read-only tool turns, or compare memory-free re-answers with edit forks.

Cautions:

  • Rewriting is not a summarizer or Q&A engine; do not expect it to fill in requirements you did not write.
  • Editing/regeneration is disabled when files or shells have modified the workspace, to avoid a new branch’s model facing a directory that “has already been rewritten but it doesn’t know.”
  • The @file guard records fingerprints when the plugin first sees the message; it cannot determine “whether the file had already changed before the message was sent.”
  • The plugin and documentation are AI-assisted; review them yourself before production use.

Closing

dsh-input-optimizer turns “clarifying a draft before sending” into a side path beside the Composer, and brings editing, memory-free re-answering, and branch visualization into the same UI and local version record, making it suitable for developers who iterate on prompts and conversation paths in DSH over the long term.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye