Airrcat/dsh-yuzuha-prompts-manager

插件Plugin 原生Native ⭐ 2 MIT cat_label.deepseek-harnesscat_label.deepseek-harness

a plugin for manage prompts in deepseek harness.

项目介绍Project Overview

这是 DeepSeek Harness 的提示词管理插件,宿主加浏览器双面运行,在会话视图提供「提示词管理」面板。它可用真实注册表模拟首次注入装配,展示系统提示词段、变量、工具 schema 与字符/token 体量,并支持增删改、排序、启停常驻提示词,保存后下次装配即生效。适合需要检查注入体积或维护常驻提示词时使用;token 为估算值,且不含会话首个用户消息。

This is a prompt-management plugin for DeepSeek Harness, running on both host and browser and adding a “Prompt Management” tab to the conversation view. It simulates first-injection assembly through the real system-prompt registry, showing prompt segments, variables, tool schemas, and estimated character/token size. It also supports creating, editing, deleting, ordering, enabling, and disabling persistent prompts, which take effect on the next assembly. Use it to inspect injection size or manage standing prompts; token counts are estimates and the first user message is excluded.

或使用命令行安装(适合开发者)Or use CLI install (for developers)

命令行安装CLI Install

dsh plugin --profile web add github:Airrcat/dsh-yuzuha-prompts-manager

Airrcat/dsh-yuzuha-prompts-manager 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-prompt-manager

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

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

功能

1. 首次注入装配检查

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

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

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

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.jsondsh.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 <name> add file:../dsh-prompt-manager

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

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

重启 dsh --profile <name>(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.jspackage.json 本身仍需要重启 dsh。

注意事项

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

License

MIT

上一个 Prev dsh-quant-workbench 下一个 Next blocker-notify