dsh-pi-composer
把 PI-Desktop 的输入框控件搬进 DeepSeek Harness 的 composer:模型选择、推理强度、提示词历史回溯与提示词改写。
中文 | English

功能
插件在 composer 上占用三个插槽,各自独立工作。
1. 模型选择座位 — conversation.input.model
以 priority: -20 注册,覆盖内置的模型控件(数值越低越优先渲染),因此输入框里看到的是这个 chip。
- chip 显示当前模型与推理等级(
DeepSeek V4 Pro · high)。 - 菜单有两栏:根面板是当前模型单元格加推理强度滑块;点进模型面板是搜索框加按 provider 分组的模型列表。
- 列表每行右侧显示上下文窗口(
1M、262.1K、128K),支持推理与图片输入的模型带徽标。 - 选中一行会向模型目录提交
{ provider, model },然后退回根面板。 - 搜索同时匹配模型 id、名称与 provider 名称。
- 目录不可用或会话是子代理时,chip 变成惰性状态而不是消失;渲染异常会写进 slots 台账而不是让整个座位被撤下。
2. 提示词历史回溯 — conversation.input.left
不渲染任何控件,只接管键盘:草稿为空时按 ↑ 从最近一条已发送提示往回走(最多 40 条),↓ 往前走并在越界时清空草稿;一旦手动编辑草稿,回溯立即结束。
3. 提示词改写 — conversation.input.right
一个 Sparkles 按钮,落在 composer 工具栏的 right 座位(宿主把它渲染在模型 chip 左侧,见下方截图)。
- 点击后立即出现撤销按钮;改写失败或返回空内容时撤销按钮仍保留,点撤销即恢复原文。以
/开头的草稿不改写。 - 若 localStorage 键
pi_composer_custom_providers_v1里有可用的自定义 Provider,草稿会 POST 到它的 OpenAI 兼容/v1/chat/completions(7 秒超时,草稿会离开本机)。 - 没有可用配置时改用内置的启发式改写模板(把草稿补全为「任务目标 + 交付要求」形态),只在本地完成,不发起网络请求。
- 注意:本插件目前没有任何界面会写入该键——模型面板底部的「添加模型服务」入口在样式里是
display: none,Provider Studio 面板没有接线。要用自定义 Provider,得自己往 localStorage 写这个键。
主题与语言
- 颜色令牌只声明在
:root,跟随宿主的深色标记body[data-ds-dark-theme](DSH 主题包写入的就是这个标记),也支持prefers-color-scheme: dark。 - 注册 zh / en 两套字典,键集完全一致,跟随宿主 locale;改写按钮的
title/aria文案目前是硬编码中文,英文界面下也会显示中文。
安装
插件市场(收录后):设置 → 插件市场,搜索 dsh-pi-composer 一键安装。
命令行(自管 profile):
dsh plugin --profile <profile> add https://github.com/pomelo-ccc/dsh-pi-composer/releases/download/v1.1.2/dsh-pi-composer-1.1.2.tgz
这条 URL 钉住了 tag 与文件名,发下一个版本时换成新的 tag / 文件名即可(latest/download/<版本无关文件名> 虽然看起来更省事,但 pnpm 会按 URL 缓存解析结果,URL 背后内容一变,重新安装就会报 ERR_PNPM_MISSING_TARBALL_INTEGRITY;实测如此)。
Desktop 应用的 desktop profile 由 Electron 应用独占管理,CLI 会拒绝写入,请在插件市场里安装。
手动接入:把仓库目录作为 link: 依赖加入 profile 的 package.json,并在 dsh.profile.bundles 里列出本包。
截图
四张截图都用本仓库的 client.js 在无头 Chromium 中挂载真实组件渲染,模型目录使用示例数据(DeepSeek 账号 / DeepSeek / 阿里百炼 三组,共 4 个模型),深浅色分别用宿主的 body[data-ds-dark-theme] 标记切换。
| 根面板(浅色) | 模型面板(浅色) | 模型面板(深色) | 根面板(深色) |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
兼容性
engines.dsh:>=0.1.0-rc.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0- 需要宿主提供 composer 与
slots/locale服务;dsh.client.inject已声明dsh-client-ui-conversation、dsh-client-ui-model-selection、dsh-client-locale。 - 没有 npm 依赖;
react/react-dom由宿主客户端模块加载器提供。
移植来源
结构、类名、CSS 规则、图标字形、token 格式与交互契约以 PI-Desktop 的实现为蓝本:
apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
apps/desktop/src/features/chat/composer/ComposerModelList.tsx
apps/desktop/src/features/chat/composer/ThinkingLevelSlider.tsx
apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts
apps/desktop/src/features/chat/composer/hooks/useComposerInputHistory.ts
apps/desktop/src/components/settings/AnchoredMenu.tsx
apps/desktop/src/styles/composer*.css
packages/shared/src/model-catalog.ts
本仓库自己写的部分:颜色层与设计令牌(DSH 里没有 PI-Desktop 的 --ds-* 调色板,这里自带浅色 / 深色两套令牌,由宿主深色标记切换)、DSH 客户端接线(模块加载器入口、插槽注册、目录映射、locale 注册)以及测试。移植范围与原创部分逐文件列在 NOTICE。
开发
npm test
测试在 Node vm 里按浏览器模块加载器的方式加载 client.js,用最小 hook 运行时驱动组件,断言注册 id、声明式注入、chip 文案、两栏菜单结构、搜索过滤、选择提交、滑块的键盘规则与历史监听器。
License
GNU Lesser General Public License v3.0(SPDX LGPL-3.0-only),全文见 LICENSE。
本仓库是 PI-Desktop(https://github.com/vastsa/PI-Desktop,同为 LGPL-3.0)部分实现的移植;移植了哪些文件、哪些是本仓库原创,见 NOTICE。
English
Composer controls for DeepSeek Harness, ported from PI-Desktop.
- Model seat (
conversation.input.model, priority-20, shadows the built-in control): a chip showingmodel · effort, a two-pane menu (root pane: current model cell + reasoning-effort slider; model pane: search plus provider-grouped model list with context-window formatting and reasoning/vision badges), and selection that submits{ provider, model }to the model directory. - Prompt history (
conversation.input.left): no visible control; an empty draft plus ↑ walks back through up to 40 accepted prompts, ↓ walks forward, and editing the draft ends the browse. - Prompt rewrite (
conversation.input.right): a Sparkles button with undo, sitting left of the model chip. With a usable custom provider in localStorage keypi_composer_custom_providers_v1the draft is POSTed to its OpenAI-compatible/v1/chat/completions(7s timeout); otherwise a built-in heuristic template rewrites it locally with no network request. No UI in this plugin writes that key yet. - Theming: colour tokens live on
:rootonly and follow the host's dark markerbody[data-ds-dark-theme], plusprefers-color-scheme: dark. Dictionaries ship in zh and en (the rewrite button's titles are still hardcoded Chinese).
Install via the plugin market, or:
dsh plugin --profile <profile> add https://github.com/pomelo-ccc/dsh-pi-composer/releases/download/v1.1.2/dsh-pi-composer-1.1.2.tgz
Screenshots are rendered from this repository's real client.js in headless Chromium against a sample model directory; dark shots use the host's body[data-ds-dark-theme] marker.
LGPL-3.0 (SPDX LGPL-3.0-only) — see LICENSE and NOTICE for the ported scope.



还没有评论,来写第一条。