前言¶
在 DSH 裏讓智能體做分類、過濾、打分或「等到某條件成立」,常見做法是反覆調用大模型,每次把整段日誌或列表塞進上下文,既費 token,又讓主對話被噪聲佔滿。另一種做法是自己寫規則腳本,維護成本高,語義邊界也不好表達。
dsh-decision-tools 把判斷拆成兩個專用工具:一次調用裏用本地 Ollama 的 System One 接口輸出概率與置信度,材料可通過文件、glob 或其它工具的原始輸出傳入,不必進入你的會話上下文;需要等待時則用 monitor 輪詢來源,只觀察、不代爲執行操作。
這是什麼¶
dsh-decision-tools 是 DSH 社區插件,維護者爲 Dinosaur-MC,在目錄中歸類爲工作流。它向智能體註冊 decision 與 monitor 兩個工具:前者在一次調用內對最多 64 條條目或 64 個不同問題做有界判斷;後者按間隔對文件、命令、後臺任務或任務事件重複採樣,直到 rubric 判定命中或超時。判斷走本機 Ollama(/v1/systemone),README 寫明 judgement 本身不向雲廠商發請求,也無需 API key。
核心功能¶
decision:一次調用,一種模式¶
decision 需要 material,且只能選下面兩種模式之一。
Batch:rubric + items(1–64 條)+ type。同一標準獨立評判每條。type 爲 choice(多選一)、noul(是/否,布爾 value,概率在 probabilities.true)、或 score(0..N-1 刻度)。choice / score 需配合 criteria 提供標籤。
Mixed:questions(1–64 個),對同一 material 問不同問題,每項含 name、type、instructions,可選 criteria。
material 支持:內聯字符串;{ file: { path, startLine?, endLine? } };{ glob: { pattern, limit? } };{ images: [...] } 或 { text, images };{ tool: { name, arguments? } }。工具輸出不會進入上下文,完整文本會落到 material.spillPath。tool 不能與其它 material 形式混用,且會拒絕插件自身工具。圖片爲工作區內 PNG/JPEG/WebP(1–8 張,單張 ≤16 MiB,合計 raw ≤24 MiB),需具備視覺能力的模型(如 clef / clef-flash);默認的 tev1 / nimble 會返回不支持視覺。
可選參數包括 depth(quick / normal / deep)、model(固定模型並關閉容量選擇與升級)。返回結構含 results[]、coverage(是否截斷、失敗等)、cost(模型、token、耗時等)和 notes(首行常爲模型選擇說明)。confidence 表示集中度,不是準確率;低置信時應看 probabilities。
設計要點(README Why):評分標準(rubric)只發送一次,單次最多判 64 項,避免「每項一次調用」的反模式;材料與工具輸出可留在工作區側,主對話只讀答案。
monitor:輪詢直到條件成立¶
monitor 對單一 source 按 intervalMs(默認 5000)採樣,每次用同一 rubric 詢問,累計命中次數。mode 爲 once 時在達到 countThreshold 或 timeoutMs(默認 120000)後返回;continuous 則跑到截止時間並返回累計 count。插件不殺進程、不重試、不取消任何外部任務;後臺 monitor 可流式進度,並在觸發時發一行通知。
source 類型包括:job(後臺任務輸出)、file、glob、command(通過上游管道重跑 argv)、events(任務事件環緩衝)。必填還有 description(用於標識)。type 目前爲 noul;hitThreshold 默認 0.5;background 與 notify 等用於後臺與通知(如 Quick start 中的 notify: "inbox")。
環境與依賴¶
- 啓用本插件的 DSH 桌面端(見安裝)。
- 本機 Ollama 提供 decision 模型,默認
tev1:0.8b,可在單次調用用model覆蓋。 - package.json 要求 Node
^22.19.0 || >=24.0.0,DSH>=0.2.0-rc.2。 - 圖片判斷需視覺模型;無 API key。
默認配置快照:baseUrl = http://localhost:11434,defaultModel = tev1:0.8b,以及四檔 ladder;可通過 defaultModel、baseUrl、ladder: [{ model, numCtx }] 調整。倉庫提供 node scripts/list-models.mjs 查看已安裝模型與可粘貼的 ladder。
安裝與啓用¶
npm 包發佈後,在 web profile 下安裝:
dsh plugin --profile web add dsh-decision-tools
從本地 checkout 開發時,可 link 到 profile:
dsh plugin --profile web add link:/absolute/path/to/dsh-decision-tools
確認工具已註冊:
cordis_inspect_query(platform="host", provider="Tool", method="listTools")
插件會註冊配套 skill decision-usage,按需加載並文檔化各參數。當前 package 版本爲 0.4.0,許可證 MIT。
典型用法¶
下面示例均來自項目 README Quick start,可直接作爲工具調用的參數形狀參考。
1)用同一 rubric 過濾列表(batch / noul)
{ "material": "<the list or its context>", "rubric": "Is this a bug report?",
"items": ["app crashes on save", "please add dark mode"], "type": "noul" }
2)對單個文件問多個不同問題(mixed)
{ "material": { "file": { "path": "build.log", "startLine": 1, "endLine": 200 } },
"questions": [
{ "name": "ok", "type": "noul", "instructions": "Did the build succeed?" },
{ "name": "why", "type": "choice", "instructions": "What failed?",
"criteria": { "compile": "compile error", "test": "a test failed", "env": "missing dependency" } }
] }
3)評判其它工具輸出而不把輸出讀進對話
{ "material": { "tool": { "name": "git_bash", "arguments": { "command": "npm test" } } },
"rubric": "Did the test suite pass?", "items": ["the test suite output"], "type": "noul" }
4)截圖判斷(需 vision 模型)
{ "material": { "images": ["screenshots/checkout-error.png"] },
"model": "clef-flash:latest",
"questions": [ { "name": "has_error", "type": "noul", "instructions": "Does this screenshot show an error state?" } ] }
5)後臺等待任務結束並收到通知
{ "source": { "kind": "job", "id": "<jobId>" },
"rubric": "Did the job finish successfully?", "background": true, "notify": "inbox" }
適用場景與注意¶
適合需要在 DSH 工作流裏做本地、可重複的語義判斷的場景:工單分類、請求路由、候選排序、日誌是否表示失敗、構建是否成功等。monitor 適合等構建結束、某行日誌出現、任務失敗等「等到條件成立再通知」的流程;它只觀測,不會替你殺任務或改系統狀態。
使用前請在本機準備好 Ollama 與合適模型;視覺與純文本模型不要混用默認可用項。插件以當前 DSH 進程權限運行,command 類 source 會重跑主機命令,tool material 會調用其它工具——安裝前建議閱讀倉庫源碼與 MIT 許可證,確認符合你的安全策略。
DSH 生態強調「一切皆插件」;社區目錄 skillhub.cn 爲獨立站點,與 DeepSeek / 幻方無官方從屬關係,本文介紹的是社區維護的 dinosaur-mc/dsh-decision-tools。
結尾¶
dsh-decision-tools 把「要概率、不要長文」的判斷和「輪詢直到命中」的等待,收斂到兩個與 Ollama System One 對接的 DSH 工具,並儘量讓原始材料留在工作區側。目錄頁與源碼可從這裏繼續查看:
- 目錄頁:https://www.skillhub.cn/plugins/Dinosaur-MC/dsh-decision-tools
- GitHub:https://github.com/Dinosaur-MC/dsh-decision-tools