DeepSeek Harness Plugin

Cloud017/dsh-prompt-reforge

Stars ★ 0 Downloads (30d) 831 Category UI Enhancements Added 2026-10-22 npm dsh-prompt-reforge

Adds a reforge control to the DSH composer that rewrites the current draft into a sharper prompt in place, as one undoable edit, with one-click revert and cancellation.

Install

# from npm (prebuilt)

dsh plugin --profile web add dsh-prompt-reforge

# from a prebuilt release tarball

dsh plugin --profile web add "https://github.com/Cloud017/dsh-prompt-reforge/releases/latest/download/dsh-prompt-reforge.tgz"

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:Cloud017/dsh-prompt-reforge

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

A composer control for DeepSeek Harness (DSH) that rewrites the draft you are typing into a sharper, more specific prompt — then lets you put the original back with one click.

It sits in the composer toolbar next to the model selector. No panel, no modal: the rewritten prompt lands in the editor you are already looking at.

[ + ]  [ permission ]            [ ✨ ]  [ ▾ model ]
                                   │
                                   └─ press to reforge, press again to revert

The primary README is in Chinese (README.md); this is the English mirror.

What it does

Step What you see
Empty draft The button stays inert and says "Write something first, then reforge it."
No model selected Inert, with "Pick a model first, then reforge."
Model list failed to load Still clickable — the click retries the load. "The model list failed to load. Click to retry."
Draft with reference chips Inert — rewriting would drop the chips. "Remove reference chips before reforging."
Ready The button arms. Press it.
Rewriting Spinner, "Reforging…". Press again to cancel.
Rewritten The draft is replaced. The same button now reads "Restore the original draft".
You keep typing The backup is dropped, so a revert can never silently swallow your edit.
You type while it rewrites The result is discarded rather than overwriting you, and the tooltip says so.
Failure The draft is left untouched and the tooltip carries the reason.
Host unreachable The draft is left untouched: "The DSH host is not reachable. Is it still running?"

The rewrite runs against the model and provider already selected for that session, so the result matches the assistant you are about to talk to. Your draft is never sent anywhere else.

Install

From the DSH plugin manager, by package name:

plugin_manager action=install_bundle target=dsh-prompt-reforge

Or point it at the release tarball:

plugin_manager action=install_bundle target=https://github.com/Cloud017/dsh-prompt-reforge/releases/download/v0.3.0/dsh-prompt-reforge-0.3.0.tgz

Or at a local checkout:

plugin_manager action=install_bundle target=<absolute path to this directory>

Or from the GUI: Plugins → Add plugin → Install third-party plugin, paste the package name, the release URL, the repository URL, or a local directory, then restart DSH. The tarball alias dsh-prompt-reforge.tgz on the same release tracks the newest version, so a pinned URL can be replaced with .../latest/download/dsh-prompt-reforge.tgz.

Once installed, dsh.profile.bundles gains one entry. The plugin adds exactly one host row; it does not change your model routing, providers, or default model.

How it works

Two halves, both shipped in this package:

  • Host half (lib/index.js) registers one POST /plugins/dsh-prompt-reforge/enhance route on the harness web server. It validates the request, calls ctx.llm.stream() on the session's routed model, and returns the normalized text. It refuses non-loopback requests and non-JSON bodies, caps the body at 256 KiB and the draft at 20 000 characters, and aborts the model call if the browser disconnects or the 60 s budget runs out.
  • Browser half (lib/client.js) registers a control into the conversation.input.right slot. It owns the button state machine, talks to the route with fetch, and writes the result back through the composer's inputActions.insertText, falling back to inputActions.setDraft when the editor API is unavailable or refuses the edit.

The browser bundle declares no dependency beyond React from the module loader; the host half imports nothing from @deepseek-ai/* and reaches the LLM runtime through ctx.get('llm').

Why the state lives outside React

Button state is keyed by session and kept in a module-level map rather than component state. Composer seats are unmounted and remounted freely (switching sessions, resizing, layout changes), and a rewrite in flight must survive that. Aborts are tracked by AbortController identity rather than by a sequence counter, so a late response from a cancelled call can never overwrite the draft.

Subscriptions are keyed by session too, so a rewrite in one session does not re-render the control in another.

A rewrite writes the whole draft as a single insertText span, so it lands as one undo step instead of destroying the editor's history. The live draft is read from a ref at the moment the model answers: if it no longer matches what was sent, the result is dropped and the tooltip says why, because silently overwriting someone's typing is worse than losing a rewrite.

Request contract

POST /plugins/dsh-prompt-reforge/enhance

{ "draft": "rough text", "provider": "workbuddy", "model": "deepseek-v4.1-flash", "sessionId": "session-…" }

Success: 200 { "ok": true, "text": "…" }

Failure: { "ok": false, "error": { "code": "…", "message": "…" } }

Status Code Meaning
400 invalid_body Body was not a JSON object
400 empty_draft Nothing to rewrite
400 missing_route provider or model missing
403 request_not_trusted Non-loopback Host or foreign Origin
405 method_not_allowed Not a POST
413 body_too_large / draft_too_long Over the size caps
415 unsupported_media_type Content-Type is neither JSON nor absent
499 aborted The browser went away
502 empty_result / upstream code The model produced nothing usable
503 llm_unavailable No LLM runtime in this composition
504 timeout Exceeded the 60 s budget

The browser half has one more code that maps to no status: unreachable — the request never reached the host at all (DSH exited, port changed).

Configuration

Nothing to configure. Caps live at the top of lib/index.js and lib/client.js if you want to fork them:

Constant Default Where
MAX_DRAFT_CHARS 20 000 both halves must agree
MAX_BODY_BYTES 256 KiB host
MAX_TOKENS 2 048 host
TIMEOUT_MS 60 000 host
LENGTH_BUDGET 800 characters prompt (lib/prompts.js)

Development

node --test          # 84 tests, no dependencies beyond Node

The suite covers the prompt pipeline, the route (including loopback rejection driven straight over a socket, since fetch cannot forge a Host header), and the button state machine against a minimal React stand-in — no DOM, no browser.

Layout:

lib/index.js     host half: route, validation, LLM call, error mapping
lib/http.js      loopback guard, JSON responses, bounded body reader
lib/llm.js       stream consumption and failure classification
lib/prompts.js   system prompt, user template, output normalization
lib/client.js    browser half: the composer control
locale/          plugin-list metadata
test/            node:test suites

Compatibility

DSH 0.2.1-rc.1 and newer within 0.3.0, written as >=0.2.1-rc.1 <0.3.0-0 || >=0.2.2-0 <0.3.0-0 — the two branches exist because a plain range does not match its own prereleases, so 0.2.2-rc.1 would otherwise be rejected.

The @deepseek-ai/* peer dependencies are declared optional: they are provided by the harness composition, never installed by this package, and a composition missing one degrades the feature instead of failing the client.

License

MIT © Cloud017

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.