DSH-Inject-Head: Injecting Fixed Text at the Top of the DSH System Prompt

前言

DeepSeek Harness(DSH)会把身份、部署 persona、工具与策略等拼成一份系统提示词。若你希望在所有回合里,模型第一眼看到的不是默认的 harness 身份,而是一段固定的说明——例如「用英文回答」「优先短答」——通常只能改 preset、改 persona,或依赖各插件各自插 section,位置和覆盖范围并不统一。

dsh-inject-head 由维护者 HYBB-rash 发布,分类为模型推理,零依赖,只改一处文本源即可在下一轮组装生效,无需重启 harness。社区目录页:https://www.skillhub.cn/plugins/HYBB-rash/dsh-inject-head ;源码与说明:https://github.com/HYBB-rash/dsh-inject-head 。目录站点为社区独立收录,与 DeepSeek / 幻方无官方从属关系。

这是什么

插件在每一份 DeepSeek Harness 系统提示词的最上方注入一段固定文本;对按 section 组装的 preset 自动生效。对声明 complete: true 的 preset(例如 minimal),主机在组装末尾会丢弃其它 section,需通过变量 {{inject_head}} 接入,文本仍由同一来源驱动。

组装后的结构示意(资料原文):

your text                                  ← line 1, this plugin
You are an AI agent that helps the user…   ← harness identity
…deployment persona, tools, policies…

DSH 为何需要两种机制

DSH 按 (order, name) 升序排列 section,再用空行拼接非空段。本插件注册的全局 section 为 operator:head,order 为 -5000,位于 harness:identity(-1000)与 deployment persona(0)之上:

Section Order
operator:head(本插件) -5000
harness:identity -1000
deployment:persona-prefix 0
tools / policies 1000 … 9900
deployment:persona-suffix 10200

complete: true 的 preset 在末尾执行 sections: [ownPersona] 并丢弃其余 section,任何 section 都无法进入最终 prompt,这是主机行为,不是插件缺陷。

因此插件从同一文本源注册两件事:

  1. 全局 section operator:head(order -5000),interpolate: false,避免你写的 {} 或 {{…}} 破坏组装;
  2. 提示词变量 inject_head。

按 section 组装的 preset 会自动带上这段文本。对 complete: true preset,在其 persona 前缀中加一行即可:

prefix: >-
  {{inject_head}}

  You are a helpful software engineer assistant.

核心功能

  • 单一文本源,四级优先级(高者优先):环境变量 DSH_INJECT_HEAD_TEXT(内联,trim)、DSH_INJECT_HEAD_FILE(UTF-8 文件路径,trim)、默认文件 $DSH_HOME/inject-head.md(即 ~/.dsh/inject-head.md)、以及 index.mjs 中的 DEFAULT_TEXT(默认为空字符串,不注入)。
  • 改文本后下一轮组装即生效;文件内容按 mtime 缓存。清空文件则静默停止注入;删除文件则不注入。
  • 环境变量适合让文本随 shell 走,便于按项目覆盖,而不绑在 home 目录。
  • 包声明 dsh.bundle.patch,作为普通 bundle 安装;Node.js 要求 >=20。许可证 MIT © 2026 Herman Hong,当前 package 版本 1.0.0。

安装与启用

插件以 bundle 形式安装。资料中的步骤如下:克隆仓库后,用插件管理器的 install_bundle 指向克隆目录的绝对路径,或手动写入 profile 的 package.json 并 link 到 node_modules,首次 link 后需重启 harness 一次;之后只改注入文本无需重启。

git clone https://github.com/HYBB-rash/dsh-inject-head.git

在 ~/.dsh/profiles/<profile>/package.json 中示例:

{
  "dependencies": {
    "dsh-inject-head": "link:/absolute/path/to/dsh-inject-head"
  },
  "dsh": {
    "profile": {
      "bundles": ["…", "dsh-inject-head"]
    }
  }
}

将包 link 进该 profile 的 node_modules 后重启 harness 一次。安装前请自行阅读仓库源码与 LICENSE;插件在当前 dsh 进程权限下运行,勿在未审阅的情况下启用不可信 bundle。

典型用法

默认路径配置示例:

mkdir -p ~/.dsh
printf 'Answer in English. Prefer short answers.\n' > ~/.dsh/inject-head.md

验证插件是否加载:

dsh --profile "$DSH_PROFILE" --dump-config

插件行应显示为 inject-head,name 指向 index.mjs。若要核对组装结果,可让 agent 回答「system prompt 的第一行是什么」,应与你的文本一致。

仓库自带测试:

npm test    # 9/9 passed

适用场景与注意

适合:需要在所有(或大部分)preset 下统一置顶指令的开发者;对 standard / ptc / cordis 等按 section 组装的 preset,改 inject-head.md 即可。

边界与风险:

  • complete: true preset 必须在 persona 里写 {{inject_head}},插件无法直接向其中插入 section。
  • 若其它插件对某 preset 的 persona 做精确字符串校验,你在 prefix 里加入 {{inject_head}} 可能导致该插件静默失效;可换 preset 或放弃覆盖该 preset。
  • 注入内容属于系统提示词的一部分,会进入会话历史;导出或分享会话时可见,不要写入密钥。
  • 每轮都会占用 token;一行很短时可忽略,长段落则成本明显。

结尾

dsh-inject-head 用 operator:head 与 inject_head 两条路径,把同一段固定文本推到系统提示最顶;普通 preset 开箱即用,complete: true preset 用一行 {{inject_head}} 对齐。维护与 issue:https://github.com/HYBB-rash/dsh-inject-head ;目录介绍:https://www.skillhub.cn/plugins/HYBB-rash/dsh-inject-head 。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye