wjc300000000-beep/dsh-plugin-open-source-first ↗★ 0

dsh-plugin-open-source-first

注入开源优先的系统提示词工作流插件 适合需要审计和优化工作流的用户,通过高优先级提示词引导模型。

套件
dsh-plugin-open-source-first
相容性
待驗證
版本
0.1.0
授權
MIT
最近更新
2026年10月18日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:wjc300000000-beep/dsh-plugin-open-source-first

2. 用应用自带 CLI 安装;--profile desktop 即当前桌面配置

DSH="/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" "$DSH" plugin --profile desktop add ./dsh-plugin-open-source-first-0.1.0.tgz


`dsh plugin add` 会做两件事:把包写进 `~/.dsh/profiles/desktop/package.json` 的依赖,并把
bundle 自动追加到 `dsh.profile.bundles`(已用本地测试包实测)。安装后**彻底退出应用(⌘Q)再重开**,
让 host 模块重新加载。

也可以直接安装目录(pnpm 会建 `link:` 依赖):

```sh
"$DSH" plugin --profile desktop add /absolute/path/to/dsh-plugin-open-source-first

也可以直接从 GitHub 安装(仓库无构建步骤、无运行时依赖):

"$DSH" plugin --profile desktop add github:wjc300000000-beep/dsh-plugin-open-source-first

已发布到 npm 后,安装名即可:"$DSH" plugin --profile desktop add dsh-plugin-open-source-first; 之后也可在 Web 侧边栏 Plugins 页确认 bundle 已选中。

确认 bundle 选择

~/.dsh/profiles/desktop/package.json 应出现:

{
  "dependencies": { "dsh-plugin-open-source-first": "link:..." },
  "dsh": { "profile": { "bundles": [ "...", "dsh-plugin-open-source-first" ] } }
}

卸载

"$DSH" plugin --profile desktop remove dsh-plugin-open-source-first

然后重启应用;必要时在 Plugins 页确认 bundle 已取消选择。


配置

bundle patch 里默认已写入 order: 50。要覆盖配置,在 ~/.dsh/profiles/desktop/cordis.patch.yml 追加一个按 id 定位的 patch 层:

- id: open-source-first
  config:
    enabled: true
    order: 50
    # sectionName: 'open-source-first:rule'
    # findPluginTool: find_dsh_plugin   # 强制指定;false 关闭收紧条款
字段默认含义
enabledtrue设为 false 时不注册任何 section
order50必须为有限数字;改动后需重载 profile
sectionNameopen-source-first:rule全局唯一;与其他插件撞名时改这里
findPluginTool自动检测字符串:强制使用该工具名;false:不追加收紧条款;不填:检测 ctx.tools.get('find_dsh_plugin', agent)

验证注入是否生效

1. 问模型

在对话框直接问:「系统提示里有没有『开源复用优先原则』这条?请复述三步流程。」 模型能复述即注入成功(软约束:注入一定发生,是否严格遵守无法 100% 保证)。

2. 查会话日志

DSH 会把渲染后的 system prompt 写进会话日志的 system/message 事件:

S=~/.dsh/sessions/--Users-ether-Documents-deepseek-harness-default-workspace--//session.v4.jsonl.zstd
zstdcat "$S" | grep -c "开源复用优先原则"

3. 跑真实服务集成测试

不启动应用、不调用 LLM,直接挂载真实的 @deepseek-ai/dsh-system-prompt 服务做装配:

ELECTRON_RUN_AS_NODE=1 "/Applications/DeepSeek Harness.app/Contents/MacOS/DeepSeek Harness" \
  --expose-internals scripts/verify-in-app.mjs

实测输出:

OK  live assembly order: deployment:persona-prefix -> open-source-first:rule -> verify:plan-marker -> verify:tool-marker -> deployment:persona-suffix
OK  rule length: 1401 chars

4. 安装后的实测记录

在 desktop profile 上执行 dsh plugin --profile desktop add ./dsh-plugin-open-source-first-0.1.0.tgz 之后,正在运行的应用通过 HMR 立即重组了 profile,本会话的系统提示词已包含该段(未重启): 最新 system/message 事件中,persona 在字符 50、规则在 111、TEAM_POLICY 在 1422, 即 persona(0) → open-source-first(50) → team policy(600),顺序符合预期。 仍建议彻底重开应用一次,以排除 HMR 的边界情况。

单元测试(假 ctx,覆盖 gating、配置、自动检测、disposer):

node --test test/index.test.mjs      # 12 passed

与现有开源插件的关系(先搜索过,再决定造什么)

写这个插件前,已对 npm 与 GitHub dsh-plugin 生态做过检索,结论:

项目结论
openharness-core-rule(npm 0.1.0)同款挂载写法:inject: ['systemPrompt']、order: 44、context.agent gating。但它注入的是固定的「五条铁律」,正文不可配置,不能承载这条开源复用规则;本插件的挂载代码即基于它的模式特化。它的 peer 依赖面向 cordis ^4.0.1 + client runtime 0.1.0-rc.6,在 0.2.1-rc.2 宿主上其 client 半可能被兼容性检查拒绝。
dsh-find-plugin(npm 0.4.0)互补而非重复:提供 find_dsh_plugin 工具(实时搜 GitHub dsh-plugin topic、按 star 排序、带安装命令)。本插件会自动检测并追加「优先用它」的条款。注意 0.4.0 的 peer range 覆盖到 0.1.7,未覆盖 0.2.1-rc.2。
dsh-prompt-studio / dsh-global-rules / dsh-rules分别是提示词优化 UI、编辑 $DSH_HOME/AGENTS.md、按文件 glob 激活规则;都不提供「以任意 order 注入任意 system-prompt section」的能力,不满足本需求。

因此按三档评估属于近似可特化:没有可直接安装的「开源复用优先」成品插件,但存在可复用的挂载模式 (openharness-core-rule)与互补工具(dsh-find-plugin),本插件在模式上特化、规则正文自写。

更轻量的零代码替代

如果不想装插件,还有两条路:

  1. persona 前缀(order 0):在 ~/.dsh/profiles/desktop/cordis.patch.yml 中覆盖 system-prompt 行:
    - id: system-prompt
      config:
        personaPrefix: |
          ## 开源复用优先原则
          ...
    
    生效位置更早(persona 槽),但和部署 persona 混在一起,且没有 context.agent gating。
  2. $DSH_HOME/AGENTS.md:写进用户全局指令文件,会被 dsh-agent-instructions 作为user 角色 的持久上下文注入(开头明确「不覆盖 system/developer/direct user 指令」),优先级弱于 system 段, 也不在 system prompt 中。适合轻量提醒,不适合硬约束。

文件结构

dsh-plugin-open-source-first/
├── package.json               # dsh.bundle.patch -> cordis.patch.yml
├── cordis.patch.yml           # 插入 id: open-source-first 行
├── lib/index.js               # 规则正文 + systemPrompt.section 注册
├── test/index.test.mjs        # node:test 单元测试
├── scripts/verify-in-app.mjs  # 对真实运行时服务的集成自检
└── README.md

开发

node --test test/index.test.mjs

ELECTRON_RUN_AS_NODE=1 "/Applications/DeepSeek Harness.app/Contents/MacOS/DeepSeek Harness" \
  --expose-internals scripts/verify-in-app.mjs

许可

MIT。挂载模式参考 MIT 许可的 openharness-core-rule;规则正文为本仓库原创。

配置

bundle patch 里默认已写入 order: 50。要覆盖配置,在 ~/.dsh/profiles/desktop/cordis.patch.yml 追加一个按 id 定位的 patch 层:

- id: open-source-first
  config:
    enabled: true
    order: 50
    # sectionName: 'open-source-first:rule'
    # findPluginTool: find_dsh_plugin   # 强制指定;false 关闭收紧条款
字段默认含义
enabledtrue设为 false 时不注册任何 section
order50必须为有限数字;改动后需重载 profile
sectionNameopen-source-first:rule全局唯一;与其他插件撞名时改这里
findPluginTool自动检测字符串:强制使用该工具名;false:不追加收紧条款;不填:检测 ctx.tools.get('find_dsh_plugin', agent)