dsh-chat-preset:爲 DeepSeek Harness 增加受限的 Chat 預設

前言

DeepSeek Harness(DSH)通過 bundle、preset 和 plugin 組合會話行爲。日常對話或輕量問答時,你往往希望模型能查網頁、拉取頁面、按需加載 skill 說明,同時不要碰工作區文件、也不要執行 shell。若在通用 agent 預設上靠手工關工具,容易漏掉宿主註冊的全局工具(例如 working_directory),或在 preset 作用域裏誤傷預設自身工具。dsh-chat-preset 以 bundle 形式註冊名爲 chat 的 agent 預設,並用 guard 插件在 agent 創建後按可見工具列表做 allow 限制,把能力收窄到 web 與 skill。

這是什麼

dsh-chat-preset 是 ThomasTZh 維護的 DeepSeek Harness bundle:註冊一個 chat agent 預設(plain helpful assistant,帶 web 與本地 skill,且無法訪問文件系統或運行命令),並附帶 guard 插件。在 SkillHub 社區目錄中歸類爲「模型推理」。倉庫:https://github.com/ThomasTZh/dsh-chat-preset;目錄頁:https://www.skillhub.cn/plugins/ThomasTZh/dsh-chat-preset。

核心功能

註冊的 chat 預設

預設由 cordis.patch.yml 掛載,主要字段如下(與 README 一致):

字段 值
id chat
name Chat
order 5
persona helpful assistant,引用來源、標註不確定、不聲稱執行過未實際執行的操作
tools web_search、web_fetch、skill
compaction basic compaction,並支持 /compact

persona 爲 complete: true,會替換而非疊加宿主 prompt;includeRuntimeContext 關閉,chat 模式不會注入工作區事實。

Guard:爲何不用單一配置開關

預設工具註冊在共享 preset 作用域,宿主還會註冊 working_directory 等全局工具。若在 preset 作用域做 restriction,會過濾掉預設自己的工具,又攔不住全局工具。因此 lib/guard.js 監聽 agent/created,讀取該 agent 實際可見的工具,保留 web_search 與 web_fetch,若存在則保留 skill,再調用 agent.ctx.tools.restrict({ allow })。

allow 列表來自可見工具而非硬編碼:僅啓用 search 或僅啓用 fetch 的 web 配置仍能得到正確限制。若完全未註冊任何 web 工具,guard 會打 warning 並保持繼承工具不受限——作者有意讓配置問題可見,而不是靜默刪掉用戶期望的工具。

skill 工具爲何保留

skill 只讀取 discovery provider 暴露的 skill 文件,不解析工作區路徑,保留它不會擴大文件系統訪問;去掉它會使用戶級 skill 在最需要對話模式的場景下不可用。

安裝與啓用

安裝前請自行閱讀倉庫源碼與許可證;插件隨當前 DSH 進程權限運行,guard 限制的是工具而非 prompt,會話仍可按 discovery 加載任意已暴露的 skill。

官方 README 給出的步驟如下。

1、克隆到本地插件目錄(將 DSH_HOME 設爲 harness 根目錄,默認 ~/.dsh):

DSH_HOME=${DSH_HOME:-$HOME/.dsh}
git clone https://github.com/ThomasTZh/dsh-chat-preset \
  "$DSH_HOME/local-plugins/dsh-chat-preset"

2、在 $DSH_HOME/profiles/web/package.json 中登記依賴:

"@local/dsh-chat-preset": "link:<absolute path to $DSH_HOME>/local-plugins/dsh-chat-preset"

並在 dsh.profile.bundles 中列出 @local/dsh-chat-preset,然後:

cd "$DSH_HOME/profiles/web" && pnpm install

等價方式:使用 harness CLI 註冊同一佈局:

dsh plugin --profile web add "<path-to-this-clone>"

package.json 中 bundle 通過 dsh.bundle.patch 指向 ./cordis.patch.yml,並導出 ./guard → lib/guard.js。

典型用法

README 未單獨給出「切換至 chat 預設」的 CLI 示例;bundle 的作用是向 harness 增加 preset 行與 guard,會話側在 harness 支持 preset 切換的流程中選擇 chat(id 爲 chat,顯示名 Chat)即可進入該模式。該模式下模型可用 web_search、web_fetch 與 skill,persona 要求引用來源並標註不確定。

Compaction 行爲包含 basic compaction 與用戶可用的 /compact 命令(與預設配置一致)。

驗證與侷限

維護者在倉庫中記錄的自檢(非完整 harness 端到端切換):

檢查 命令 結果
單元測試 node --test test/guard.test.mjs pass,6 tests
模塊解析 node --check lib/guard.js pass
安裝佈局 臨時 DSH_HOME 下 clone 並檢查 package 與 patch pass;未在此倉庫重複 pnpm install 與 harness 重啓

未測項: 全新安裝 harness 後的完整 preset 切換。

其他侷限(README 原文):

  • Guard 限制工具,不限制 prompt;chat 會話仍可按設計加載 discovery 暴露的任意 skill。
  • 預設行引用的 @deepseek-ai/dsh-agent-preset、dsh-persona、dsh-agent-instructions 及 skill、compaction 等插件由 harness 安裝解析,本倉庫不 vendoring 這些包。

適用場景與注意

適合需要在 DSH 裏提供「只上網 + 讀 skill、不讀寫工作區、不跑命令」對話入口的場景,例如對外分享的輕量問答 profile(如 README 示例中的 web profile)。

注意:SkillHub 目錄爲社區站點,與 DeepSeek / 幻方無官方從屬關係;安裝方式以 GitHub README 爲準,不要憑插件名臆造 dsh plugin add github:owner/repo 一類命令(除非與你的 harness 版本文檔一致且已在資料中出現——本插件資料僅給出 clone + profile 依賴或 dsh plugin --profile web add "<path>")。

結尾

dsh-chat-preset 用一條 preset 行加一個 per-agent guard,把 chat 模式的能力釘在 web 與 skill 上,並避免 preset 級 restriction 的盲區。需要細節與更新時,請查看目錄頁 https://www.skillhub.cn/plugins/ThomasTZh/dsh-chat-preset 與源碼倉庫 https://github.com/ThomasTZh/dsh-chat-preset。

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

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

小夜