Airrcat/dsh-yuzuha-prompts-manager ↗★ 1

dsh-prompt-manager

DeepSeek Harness plugin: first-injection assembly inspector + user-managed standing prompts (host plugin + web conversation-view panel) 提供系统提示词模拟装配检查(估算Token与体积)及常驻提示词管理。适合需要精细调试系统提示词结构、监控工具Schema体积的开发者和高级用户。

Package
dsh-prompt-manager
Compatibility
Unverified
Version
0.1.0
License
MIT
Last updated
Aug 14, 2026

Other repositories with this package name

Install

This plugin has no verified bundle, or compatibility checks failed. Read the repository notes first. Read the full README ↗

dsh-prompt-manager

DeepSeek Harness 的「提示词管理」插件:一个宿主 + 浏览器双面插件,为 dsh web profile 提供独立面板(会话视图里的「提示词管理」标签页)。

声明:本插件由 DeepSeek Harness 的 deepseek-v4-pro-max 模式制作。

功能

1. 首次注入装配检查

通过真实的系统提示词注册表做模拟装配(ctx.systemPrompt.assemble(),不是自己拼字符串):

  • 系统提示词每个段的名称、装配顺序、字符数与 token 估算,可展开查看插值后的全文; 本插件写入的段(user:prompt-manager)单独计入「你管理的提示词」统计并高亮;
  • 运行时上下文快照的每个条目与整条快照(存在时才显示);
  • 提示词变量表(model、cwd 等)与本次模拟的值;
  • 工具 schema 清单(数量 + 描述),并按每个工具的序列化 JSON(name + description + parameters)汇总 schema 序列化体积(字符 + token 估算);
  • 汇总:系统提示词、你管理的提示词、工具 schema 序列化体积,以及三部分合计的 首次注入总长度(字符 + 估算 token)。

装配按当前会话的 agent 作用域进行:含该 agent(preset 层)贡献的段、工具与 model、cwd 等变量;未能在本次装配代入的变量保留占位符并在面板中单独标注。

2. 提示词管理

  • 增删改、启用/禁用、上下排序一批要注入给模型的常驻提示词;
  • 保存后作为 order 50 的段(user:prompt-manager,persona 之后、工具引导之前)挂入 系统提示词注册表,下一次装配即生效,无需重启(每个模型步骤都会重新装配);
  • 空正文或被禁用的条目不注入(段为空时整体消失);
  • 数据保存在 $DSH_HOME/prompt-manager/prompts.json,与插件本体分离。

结构

  • lib/index.js — 宿主插件入口:热加载 runner(watch lib/runtime.js → 动态 import → 重挂;POST /prompt-manager/reload 手动触发)
  • lib/runtime.js — 宿主逻辑(可热加载):注入 user:prompt-manager 段 + 下面两条路由 (经 webServer 注册,与 /plugins、/api 前缀不冲突):
    • GET /prompt-manager/state — 提示词列表 + 按当前会话 agent 作用域的模拟装配结果
    • POST /prompt-manager/prompts — body {prompts: [...]},校验、持久化并重挂段
  • 两个文件都只使用 node 内建模块,无第三方 import
  • lib/client.js — 浏览器插件(__ModuleLoader__ 包,React 18)
    • 注册 conversation.view 槽位,为每个会话视图添加「提示词管理」标签页
    • 通过 fetch 调用上述两条路由
  • package.json — dsh.client 声明让 dsh-client-modules 扫描到浏览器面并注入 window.__DSH_BOOT__;宿主面由 main 提供

安装到某个 profile

git clone https://github.com/Airrcat/dsh-yuzuha-prompts-manager.git
# 把包登记为 profile 的本地依赖(dsh plugin 会把参数转发给 profile 目录下的 pnpm)
dsh plugin --profile  add file:../dsh-prompt-manager

然后在 $DSH_HOME/profiles//cordis.patch.yml 的数组里插入插件行:

- insert:
    - id: prompt-manager
      name: 'dsh-prompt-manager'

重启 dsh --profile (loader 在重启时拾取新行;hmr 行在 web profile 中默认禁用), 刷新页面后,会话视图切换栏(聊天 / 轨迹那排)会出现「提示词管理」标签。

热加载

  • 浏览器面:已挂载的 client-hmr 行会轮询 lib/client.js(默认 500ms),文件变化后 通过 /plugins/events SSE 把新 bundle 推给所有打开的页面,无需刷新。
  • 宿主面:入口 runner 用 fs.watch 监听 lib/runtime.js,变化后自动 dispose 旧代、 re-import 并重挂(出错自动回滚到上一代)。面板里也有「重载宿主」按钮 (POST /prompt-manager/reload)。
  • 修改 lib/index.js 或 package.json 本身仍需要重启 dsh。

注意事项

  • token 数量为估算(CJK 字符 ≈ 1 token,其余 ≈ 4 字符 / token),仅用于体量判断。
  • 装配按当前会话(面板所在会话)的 agent 作用域进行;无活动 agent 时退化为全局层装配。
  • 「会话首个用户消息」不在模拟范围内。
  • 若日后在 profile 目录运行 pnpm install / dsh plugin install,pnpm 可能清掉未经 登记的文件式依赖:用 dsh plugin --profile add file: 重新登记即可。

License

MIT