From Zero to One: Build and Deploy a DeepSeek Harness Prompt Optimizer Plugin

This article walks through the complete process of creating a DeepSeek Harness (DSH) plugin that adds an "AI Optimize" button to the chat UI, explains the DSH architecture, shows how to develop, test, package, publish to npm, and install the plugin, and provides concrete code snippets and request/response examples.

Ubiquitous Tech
Ubiquitous Tech
Ubiquitous Tech
From Zero to One: Build and Deploy a DeepSeek Harness Prompt Optimizer Plugin

DeepSeek Harness (DSH) overview

DSH is an extensible AI agent framework that separates Host (server‑side capabilities) and Client (browser UI) via a plugin architecture based on Slot, Remote, and Typert RPC mechanisms. All components—including models, tools, strategies, storage, and UI—are treated as interchangeable plugins.

Prompt‑optimization plugin

The plugin dsh‑ai‑prompt‑optimizer adds a “✨ AI 优化” button next to the chat input. When clicked, it reads the current draft, invokes the default model configured in DSH, receives a structured prompt that fills in task goal, context, constraints, and expected output format, and inserts the result back into the input box without sending automatically.

Development steps

Install DSH globally: npm install -g @deepseek-ai/dsh and start the web UI with dsh web.

Create a JavaScript plugin project with two files. Host.js implements server‑side logic: receives the draft, calls the model via ctx.llm.stream(...), and returns the optimized prompt.

Inject a React button into the chat UI using a Slot on the input box’s right side.

Register a type‑safe RPC method with Typert Remote, e.g. ctx.tools.register('promptOptimizer', handler).

Iterative refinement

Version 1 generated prompts by simple string concatenation.

Version 2 called the AI model directly via ctx.llm.stream.

Version 3 fixed a compatibility error (“unsupported provider request field at /temperature”) by removing the unsupported temperature field from the request payload.

Example RPC request

{"type":"client-request","rpcId":"6b77f21b-c3ad-46f9-89d3-8d817ee74420","method":"promptOptimizer/optimize","payload":{"args":{"request":{"draft":"今天的天气不错,我想做个系统"}}}}

Example RPC response

{"type":"server-response","rpcId":"6b77f21b-c3ad-46f9-89d3-8d817ee74420","result":{"ok":true,"value":{"ok":true,"prompt":"xxxxxxxxxx"}}}

Open‑source repository

Source code: https://github.com/wuchubuzai2018/dsh-ai-prompt-optimizer

Publishing to npm

Create an npm account and generate an access token.

Add the token to a local .npmrc file (do not commit this file).

Run npm login and then npm publish. Ensure the version follows semantic versioning.

Installation methods

From npm: dsh plugin --profile web add dsh-ai-prompt-optimizer From local source: clone the repo, run pnpm install, then dsh plugin --profile web add . Directly from GitHub:

dsh plugin --profile web add github:<owner>/<repo>

Uninstall

Remove the plugin with dsh plugin --profile web remove dsh-ai-prompt-optimizer.

Key observations

The plugin demonstrates the full DSH plugin lifecycle: architecture basics, coding, debugging, packaging, and distribution.

Using ctx.llm.stream enables streaming model calls without hard‑coding API keys.

Typert Remote provides type‑safe communication between the browser and Host.

Slot injection allows UI extensions without modifying core DSH code.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaScriptAI AgentPrompt OptimizationnpmDeepSeek HarnessDSH Plugin
Ubiquitous Tech
Written by

Ubiquitous Tech

A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.