dsh-inject-head:在 DSH 系統提示詞最頂部注入固定文本

前言

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 。

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

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

小夜