dsh-catgirl-plugin:爲 DeepSeek Harness 打造的 token 高效人格運行時

前言

在 DSH 插件場景裏,人格、工具與顯示層可以拆到不同模塊中處理。dsh-catgirl-plugin 是一個爲 DeepSeek Harness 打造的 token 高效人格運行時,由 Freakz2z 維護,許可證爲 MIT。

它不直接把長 persona 塞進模型上下文,而是讓模型輸出正常文本,由本地渲染層添加貓娘風味;同時通過工具白名單控制模型可見工具。

這是什麼

一句話:dsh-catgirl-plugin 是一個爲 DeepSeek Harness 打造的 token 高效人格運行時。

它圍繞三類目標:

  • 保持模型上下文乾淨:會話日誌保存原文,模型上下文零污染。
  • 降低貓娘風味的 LLM token 成本:貓娘風味本地渲染,0 LLM token 成本。
  • 減少工具 schema 佔用:工具 schema 裁剪,25 個工具減少到 8 個。

核心功能

Persona Virtualization

Persona Virtualization 的思路是:模型輸出正常文本,本地渲染層添加貓娘風味。

這樣會話日誌保存原文,模型上下文零污染;貓娘風味由本地渲染完成,0 LLM token 成本。

工具裁剪與按需解鎖

catgirl-economy 通過 ctx.tools.restrict() 在 agent 作用域裁剪工具,把 25 個工具減少到 8 個。

當任務需要被裁剪的工具時,可通過 enable_tool 按需解鎖。enable_tool 的漸進式披露用於恢復能力。

如果請求解鎖的工具未安裝在當前 profile,enable_tool 會返回不可用提示並保留原白名單。

插件模塊

  • catgirl-lite:極短 persona。
  • neko-renderer:headless 顯示層。
  • catgirl-economy:工具裁剪與按需解鎖。
  • client:Web UI 渲染。
  • usage-meter:usage 記錄。

人設文案爲中文單語;INTENSITY_TEXT 位於 index.js,可自行修改或通過 traits 擴展。

安裝與啓用

安裝命令中指定了 demo profile:

dsh plugin --profile demo add dsh-catgirl-plugin

然後加入 profile patch,插入 catgirl-liteneko-renderercatgirl-economy。下面配置使用已覈實事實中的字段:

- insert:
    - name: dsh-catgirl-plugin/catgirl-lite
      config:
        persona: 'Be concise, friendly, and natural.'
    - name: dsh-catgirl-plugin/neko-renderer
    - name: dsh-catgirl-plugin/catgirl-economy
      config:
        allow: [bash, read, write, edit, glob, grep, str_replace_editor, todo_write]

Web UI 渲染可選。安裝 dsh-catgirl-plugin-client 並加入 profile patch,插入 neko-renderer-client

- insert:
    - name: dsh-catgirl-plugin-client

典型用法

基礎啓用

先安裝插件,再在 profile patch 中啓用三個模塊:

  1. 安裝 dsh-catgirl-plugin
  2. 插入 dsh-catgirl-plugin/catgirl-lite,並設置 config.personaBe concise, friendly, and natural.
  3. 插入 dsh-catgirl-plugin/neko-renderer
  4. 插入 dsh-catgirl-plugin/catgirl-economy,並在 config.allow 中配置允許保留的工具。

示例白名單爲:

allow: [bash, read, write, edit, glob, grep, str_replace_editor, todo_write]

需要更多工具時

如果當前任務需要被裁剪掉的工具,調用 enable_tool 解鎖對應工具。

需要注意:

  • 如果請求解鎖的工具未安裝在當前 profile,enable_tool 會返回不可用提示並保留原白名單。
  • 需要專用工具的任務存在退化邊界,例如 subagent 並行、skill 調用,模型會改變策略;enable_tool 漸進式披露用於恢復能力。

開發與構建

開發環境要求來自 package.json

"engines": {
  "node": "^22.19.0 || >=24.0.0"
}

依賴:

"@deepseek-ai/schemastery": "^3.18.1"

常用命令:

npm install
npm test
npm run test:composition
npm run pack:check

構建客戶端插件需要進入 client 目錄安裝依賴,並從 harness checkout 鏈接 @deepseek-ai 相關包。已知 dsh-client-runtime 依賴未發佈的 dsh-compact,所以構建客戶端包需從 harness checkout 鏈接依賴。

適用場景與注意

適合在 DSH 中使用本地人格渲染和工具白名單控制的場景。它適合希望減少 persona 對模型上下文佔用、同時保留貓娘顯示效果的開發者。

注意:

  • 插件以當前 dsh 進程權限運行,安裝前應檢查源碼與許可證。
  • headless 一次性進程不等待後臺 subagent:run_in_background: true 的子代理在父進程退出時被終止;同步模式完整可用,Web UI 無此問題。
  • npm registry 的 rc 包依賴鏈損壞:dsh-client-runtime 依賴未發佈的 dsh-compact,構建客戶端包需從 harness checkout 鏈接依賴。
  • nya 工具輸出隨機,使用 Math.random(),不適合快照測試。
  • 人設文案爲中文單語;INTENSITY_TEXT 位於 index.js,可自行修改或通過 traits 擴展。
  • dsh bundle patch./cordis.patch.yml

結尾

dsh-catgirl-plugin 的價值在於把人格表現放到本地渲染層,把工具面控制在白名單內,並用 enable_tool 在需要時恢復工具能力。

倉庫地址:

  • GitHub:https://github.com/Freakz2z/dsh-catgirl-plugin
羽毛球分组比赛记分
小程序二维码

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

小夜