dsh-prompt-deck
Verifieddsh-prompt-deck · v0.2.1 · MIT · Web UI
dsh-prompt-deck — local prompt deck for DSH: a composer button opens a searchable prompt-card panel; clicking a card appends it to the input draft.
Install
dsh plugin add dsh-prompt-deck Confirm the layer applied with dsh --profile default --dump-config — see the install guide.
Source
Tags
Creators
Readme
dsh-prompt-deck
提示词卡组 — a local prompt deck for DeepSeek Harness (DSH). 本地提示词管理插件:搜索、查看、新建、编辑、删除提示词卡片,一键追加到输入框。
A dual-half DSH plugin: a button beside the composer opens the deck in the right Sidebar; clicking a card appends its content to the input draft — it never overwrites what you already typed.
输入框旁的「提示词」按钮 → 右侧面板打开卡组 tab;点击卡片追加注入输入框,
不覆盖已有草稿。数据全部存在本地 ~/.dsh/prompt-deck.json。
Features / 功能
- 右侧面板 tab(
sidebar.right.pane.tab,会话级)——搜索、列表、新建、编辑、删除(二次确认) - 行内展开看全文 —— 卡片左侧 ▸ 原地展开完整内容,可直接「追加到输入框」
- 点击卡片注入 —— 追加到当前草稿,保留已有输入;搜索框回车注入首个匹配
- 导入/导出 —— 一键下载 JSON 备份(含回收站数据);导入按 id 合并、冲突跳过、重复导入幂等
- 回收站 —— 删除进回收站,可恢复或永久删除,防手滑
- 标签/分组 —— 卡片可打标签、设分组;点击 chip / 下拉即时过滤
- 引导页入口 —— 右侧栏「新标签页」的 guide 页有直达入口卡片
- 首次运行种子数据 —— 文件不存在时写入 4 张示例卡;只播一次,删除不回种
- 错误处理 —— 加载/保存/删除失败显示横幅与「重试」,损坏的存储文件报 500 而不静默覆盖
Structure / 结构
src/index.ts HOST half — /__prompt-deck/* routes + storage glue (存储层在 store.ts) (tsc → dist/)
src/store.ts HOST half — card type, JSON store IO, seeds, trash & import merge (pure functions)
lib/client.js BROWSER half — composer button + right-Sidebar tab body (loaded via exports["./client"])
cordis.patch.yml bundle layer — inserts the host row into a profile
debug.patch.yml dev overlay — pnpm dev boots with the local src/index.ts
Mounting seams / 挂载缝隙:
| Seam | Kind | Role |
|---|---|---|
conversation.input.left |
list, session | launcher button beside the composer |
sidebar.right.pane.tab |
keyed, session | the deck body inside the right Sidebar tab |
ctx.sidebarRightTabs |
tab type registry | kind: 'prompt-deck' + guide entry |
ctx.webServer |
host routes | JSON API under /__prompt-deck/ |
双半通讯:浏览器半 fetch('/__prompt-deck/...') → 宿主半路由 → ~/.dsh/prompt-deck.json。
Quick start / 快速开始
pnpm install
pnpm run build # tsc → dist/index.js
# Boot the web profile with the local source overlay:
pnpm dev # = dsh web --patch ./debug.patch.yml
Or install the built plugin into a profile (run from the plugin's parent directory —
dsh plugin add <dir> anchors relative paths to the invoking directory):
dsh plugin --profile my-profile add ./dsh-prompt-deck
dsh --profile my-profile
pnpm dev的--patch(launcher 参数)必须放在 app 参数(如--no-open)之前,否则报unknown option。
Verify / 验证
curl http://127.0.0.1:3080/dsh-prompt-deck/ping # 200 {"ok":true,...}
curl http://127.0.0.1:3080/__prompt-deck/list # 200 {"ok":true,"prompts":[...]}
In the UI: type something into the composer → click 提示词 → search → click a card → the content is appended below your draft.
- 改
lib/client.js(浏览器半):刷新页面即生效。 - 改
src/index.ts(宿主半):需要重启服务(不热重载)。
HTTP routes / 宿主路由
| Route | Method | Body | Result |
|---|---|---|---|
/__prompt-deck/list |
GET | — | { ok, prompts };文件缺失时用种子数据初始化 |
/__prompt-deck/save |
POST | { id?, title, content, tags?, group? } |
upsert one card → { ok, prompt } |
/__prompt-deck/delete |
POST | { id } |
软删除(移入回收站)→ { ok, id, deletedAt } |
/__prompt-deck/restore |
POST | { id } |
恢复 → { ok, id } |
/__prompt-deck/purge |
POST | { id } |
永久删除 → { ok, id } |
/__prompt-deck/export |
GET | — | 全量备份(含回收站)→ { ok, version, exportedAt, prompts } |
/__prompt-deck/import |
POST | prompts[] 或 { prompts } |
按 id 合并 → { ok, added, skipped, invalid } |
/dsh-prompt-deck/ping |
GET | — | health check |
Storage guarantees: every read-modify-write runs through one promise chain (no interleaved writes), writes land via tmp-file + rename (a crash never leaves a half-written store), and a corrupted file fails loudly (500) instead of being overwritten.
Data shape / 数据形状:~/.dsh/prompt-deck.json 中每张卡片含 tags: string[]、
group: string 与可选的 deletedAt(存在即在回收站);v0.1 的旧文件直接兼容——
缺失字段在解析时自动补默认值。
Theme & Skin Compatibility / 主题与皮肤兼容
This plugin follows the DSH Web styling contract
(docs/web-styling.md):
all colors come from --dsw-alias-* design tokens (literals only as fallbacks), with no
per-theme CSS selectors. It also implements the
dsh-web Skin Center compatibility contract
L1 (token coverage) + L2 (semantic attributes data-dsh-plugin / data-dsh-part / data-dsh-surface).
本插件遵循 DSH Web 样式契约:全部颜色经 --dsw-alias-* 设计令牌引用(字面量仅作兜底),
无按主题分支的 CSS 选择器;并实现 dsh-web 皮肤中心兼容契约 L1(令牌覆盖)+ L2(语义属性)。
注意:
data-dsh-plugin是 dsh-web 维护的闭合枚举——发布前到 dsh-web issues 注册你的插件 id,否则下游皮肤匹配不到。
Pitfalls / 坑
- 浏览器半必须用
window.__ModuleLoader__.load({ factory: (require) => ... }), 用require('react')等取依赖,不要写裸 ESM import(加载器只认 factory 形态)。 exports["./client"]必须指向浏览器半文件,加载器靠它发现 client bundle。- Session 级插槽的标准 props(
useInput/inputActions)由框架自动下发—— 右面板 tab 体也能直接setDraft注入,不需要自己桥接。 - 版本线对齐:所有
@deepseek-ai/dsh-*包保持同一版本线(当前0.2.0-rc.2), 避免 pnpm 装两份模块。 @deepseek-ai/cordis是 peerDependency:只import type { Context }(编译期擦除), 运行时 ctx 由宿主传入。- Pure ESM:package.json 须
"type": "module";tsc 用module: esnext+moduleResolution: bundler保留 bare specifier。 - 注册是 effect:
ctx.slots.register()/ctx.on()卸载自动清理;自己申请的资源 (定时器/连接)要包ctx.effect(() => { ...; return cleanup })。 - 加载顺序靠服务依赖(
export const inject = [...]),不靠文件顺序。 dsh plugin add <dir>的相对路径锚定「调用目录」——在插件父目录执行。- Node 版本:DSH 要求
^22.19.0 || >=24.0.0。
发布命令
npm publish --registry=https://registry.npmjs.org/