Skip to content
dsh.fish
Bundle

dsh-prompt-optimization

DSH Prompt Optimization plugin: one-click prompt optimization in the composer input, with an optional dedicated optimizer model in Settings

Source
du-u-uck
License
MIT
Updated
Updated 16 hours ago

Readme

# DSH-Prompt-Optimization(提示词优化插件)

[English](README.en.md) | 中文

DeepSeek Harness Web 端插件:在对话框输入框旁提供「优化提示词」按钮,一键把当前草稿静默优化后直接覆盖回输入框,支持一键撤回;可在「设置 → 提示词优化」里单独固定优化所用模型(模型列表与「设置 → 模型」同源)。

## 安装

`sh
dsh plugin --profile web add github:du-u-uck/DSH-Prompt-Optimization
`

重启 DSH Web 后即可使用。

## 功能

| 功能 | 说明 |
| --- | --- |
| 一键优化 | 点击后把草稿交给宿主侧后台的模型调用,优化结果通过 `inputActions.setDraft` **直接覆盖输入框** |
| 撤回 | 优化成功后按钮变为「撤回」,再点一次恢复优化前的原始草稿(每个会话独立记忆) |
| 默认模型 | 未固定模型时,优先用**当前会话所选模型**,否则用部署默认模型 |
| 设置 → 提示词优化 | 新增设置分区,下拉列出「设置 → 模型」中已配置的全部提供商与模型;选择写回持久化设置命名空间,「跟随当前会话模型」为默认值。 |
---
## 优化前
![优化前](优化前.png)
## 优化后
![优化后](优化后.png)
---

## 架构

- **Host 半区(`lib/index.js`)**
  - `settings.register('dsh-prompt-optimization', …)`:持久化 `optimizerModel`(`{provider, model} | null`)。
  - `GET /api/dsh-prompt-optimization/models`:读 `llm.listProviders/listModels` + `agentDefaultModel.currentSelection()`,即设置页模型列表的同源数据。
  - `POST /api/dsh-prompt-optimization/optimize`:`{draft, provider, model}` → 固定 system 指令 + 单条用户消息的一次性 `llm.stream` 调用,聚合可见文本返回。双端均带 loopback 围栏(peer socket + Host 头)。
- **Client 半区(`lib/client.js`)**
  - `conversation.input.right`:按钮组件(读 `useInput` 草稿、写 `inputActions.setDraft`,会话级状态存模块 Map)。
  - `settings.section`:模型选择卡片,经 `ctx.settingsScope.bind('dsh-prompt-optimization')` 写持久化设置。

## 构建

```powershell
pnpm install
pnpm build      # 产出 lib/index.js(ESM,Node)+ lib/client.js(CJS closure factory,浏览器)
```
---
# 最推荐安装方式:把整个仓库文件夹扔给Agent,让它自己装

## 安装(本地 web profile)

```powershell
powershell -NoProfile -File scripts/install-web.ps1
# 等价于:
#   pnpm build
#   pnpm add "file:D:\...\prompt-optimization"   (在 web profile 目录下;dsh CLI 对含空格路径有限制)
#   把 "dsh-prompt-optimization" 写入 package.json 的 dsh.profile.bundles
#   重启 dsh web --profile web
```

卸载:

```powershell
# 在 C:\Users\asus\.dsh\profiles\web 下
pnpm remove dsh-prompt-optimization
# 并从 package.json 的 dsh.profile.bundles 删除 "dsh-prompt-optimization",重启
```


## 已知边界

- 覆盖输入框会丢失草稿中的引用 chip(`@文件` 等)——优化后文本为纯文本草稿;原始草稿(含 chip 的剪贴板投影)保存在撤回状态中,撤回时按文本恢复。
- 优化是「纯文本增强」:模型可能在语义上改写措辞,不会新增你在草稿里没有的需求;对结果不满意随时撤回。
- 一次优化请求的输入上限 256 KB、输出预算 4096 tokens、超时 120 s。

Install

dsh plugin --profile web add github:du-u-uck/DSH-Prompt-Optimization

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source