
零依賴測試套件完全指南如何在本地跑綠dsh-anchored-standard的194個測試【免費(fèi)下載鏈接】dsh-anchored-standardTwo-phase DeepSeek Harness preset: Minimal-aligned bootstrap, then full Standard tools (Project2 98/99)項(xiàng)目地址: https://gitcode.com/gh_mirrors/ds/dsh-anchored-standarddsh-anchored-standard是 DeepSeek Harness 的兩階段錨定預(yù)設(shè)Minimal 對齊引導(dǎo) Standard 完整工具它最大的工程亮點(diǎn)之一就是零依賴測試套件不安裝任何第三方測試框架只用 Node.js 內(nèi)置的node:test和node:assert一條npm test命令就能在本地把全部 194 個測試跑綠。本文手把手帶你從零到全綠。為什么是零依賴很多項(xiàng)目的測試要先npm install下載 Jest、Mocha 等框架而這里一個依賴都沒有package.json 中沒有dependenciestest腳本就是node --test全部測試文件位于 test/ 目錄只importNode 內(nèi)置模塊node:test、node:assert/strict、node:fs、node:child_process等所有斷言都基于內(nèi)存 mock測試通過假的agent、假的listener直接驅(qū)動插件邏輯不發(fā)真實(shí)模型請求、不訪問網(wǎng)絡(luò)這意味著無需 npm install、斷網(wǎng)也能跑、秒級出結(jié)果非常適合新手理解插件的每個行為分支。跑測試前只需要一個前提唯一的環(huán)境要求寫在 package.json 的engines字段里engines: { node: 22.19.0 }檢查一下你的版本node -v?v22.19.0及以上直接進(jìn)入下一步? 版本偏低先升級 Node否則部分測試可能被跳過或失敗測試總數(shù)對不上 不需要初始化 git 子模塊、不需要 API Key、不需要任何配置——克隆倉庫即可git clone https://gitcode.com/gh_mirrors/ds/dsh-anchored-standard一條命令跑綠全部測試進(jìn)入倉庫根目錄后npm test它等價于node --test會自動發(fā)現(xiàn) test/ 下全部 20 個*.test.mjs文件并逐個執(zhí)行。全綠時的收尾摘要長這樣具體耗時隨機(jī)器而定1..N # tests 194 # suites 0 # pass 194 # fail 0 # cancelled 0 # skipped 0 # todo 0 # duration_ms 6000.12看到# fail 0且退出碼為 0就說明你的環(huán)境完全跑綠了。20個測試文件都覆蓋了什么測試與插件一一對應(yīng)每個模式目錄preset/、zero-anchored-standard/、prefab/等里的插件都會通過 shared/ 單一來源分發(fā)測試則直接導(dǎo)入這些本地實(shí)現(xiàn)。按覆蓋重點(diǎn)大致分四類類別代表測試文件驗(yàn)證的核心行為錨定與晉升test/context-gate.test.mjs、test/tool-bootstrap.test.mjs、test/zero-tool-bootstrap.test.mjs引導(dǎo)期壓制自動注入、首次tool/call/assistant/message觸發(fā)晉升、晉升后目錄切換錨點(diǎn)輪變體test/anchor-turn.test.mjs、test/wire-think.test.mjs、test/toolchoice-adapter.test.mjs零工具錨點(diǎn)輪、你是誰自述輪、tool_choice: none線路條件工具與網(wǎng)關(guān)test/custom-bash.test.mjs、test/dev-tool-search.test.mjs、test/skill-search.test.mjs、test/eternal-minimal.test.mjs常駐 bash、按需解鎖工具、dshx網(wǎng)關(guān)截獲與輸出截斷組裝與完整性test/prefab-install.test.mjs、test/prefab-instantiate.test.mjs、test/self-containment.test.mjsPrefab 安裝與實(shí)例化、模式目錄自包含、shared/物化副本一致性進(jìn)階只跑一個文件或按名字過濾調(diào)試單個插件時不必全量執(zhí)行# 只跑 context-gate 的 21 個用例 node --test test/context-gate.test.mjs # 只跑名字里包含 promotion 的用例 node --test --test-name-pattern promotion讓檢查更嚴(yán)格npm run check倉庫還內(nèi)置了一個更完整的檢查腳本先校驗(yàn) scripts/sync-modes.mjs 的--check確認(rèn)各模式目錄里的物化副本與 shared/ 源文件完全一致再跑全部測試npm run check這正是項(xiàng)目不變量所依賴的組合每個模式目錄都可單獨(dú)拷貝安裝插件副本必須由npm run sync生成而不是手改。常見紅燈排查清單 現(xiàn)象原因解決方法測試數(shù)少于 194、出現(xiàn) skippedNode 版本低于 22.19.0升級 Node 后重跑materialized copies match shared/ sources失敗模式目錄副本與shared/源不一致運(yùn)行npm run sync重新物化報Unknown key fails at preset mount相關(guān)斷言測試期望配置鍵在掛載時嚴(yán)格校驗(yàn)說明是預(yù)期行為檢查你是否誤改了 agent.cordis.yml 類配置結(jié)構(gòu)懷疑網(wǎng)絡(luò)問題基本可以排除該套件完全離線可關(guān)網(wǎng)驗(yàn)證記住原則測試斷言失敗時先看not ok N - 用例名那一行對照 test/ 中同名文件定位 mock 數(shù)據(jù)99% 的情況與 Node 版本或shared/副本過期有關(guān)。小結(jié)dsh-anchored-standard的測試套件是零依賴實(shí)踐的教科書級示例內(nèi)置node:test承擔(dān)運(yùn)行器、node:assert承擔(dān)斷言、mock 替代真實(shí)模型調(diào)用20 個測試文件把錨定、晉升、Prefab 等全部機(jī)制釘死在本地行為上。只要裝好 Node ≥ 22.19.0敲下npm test看到# fail 0你就已經(jīng)和倉庫的 CI 基線完全對齊了?!久赓M(fèi)下載鏈接】dsh-anchored-standardTwo-phase DeepSeek Harness preset: Minimal-aligned bootstrap, then full Standard tools (Project2 98/99)項(xiàng)目地址: https://gitcode.com/gh_mirrors/ds/dsh-anchored-standard創(chuàng)作聲明:本文部分內(nèi)容由AI輔助生成(AIGC),僅供參考