dsh-profile-lab:DSH 臨時 profile 實驗臺

前言

在 DeepSeek Harness(DSH)裏改插件或試新配置,常見顧慮是:裝錯包、改壞 profile,日常用的 desktop 或 headless 起不來。官方 --from-default-profile 只能從少數內置模板初始化,不能從現有 profile 克隆,也不方便「只建目錄、不啓動」。探針要手拼 DSH_HOME、環境變量和 dsh --profile;驗 HTTP 或 host 路由還要另起 web 進程;讀 session.v4.jsonl.zstd 又要自己解多幀 zstd。下面介紹社區插件 dsh-profile-lab(維護者 wqzhellohhwy,SkillHub 分類:工作流):用一組 tmpprofile_* 模型工具,把「建隔離環境 → 裝插件 → 跑會話 → 讀摘要 → 回收」收成有護欄的標準動作。

這是什麼

dsh-profile-lab 是掛在 DSH 宿主側的 Cordis 插件:註冊十個以 tmpprofile_ 開頭的模型工具,不聲明 dsh.client,沒有瀏覽器半側。inject 只寫 ['tools'](不寫 webServer),因此在 headless、tui 等沒有 HTTP 服務的 profile 裏不會整體 pending。運行時只依賴 Node 內置模塊(node:fs、node:path、node:child_process、node:zlib、node:crypto),無第三方運行時依賴。

它存在的直接理由:改插件時怕把本體改暴斃——先在隔離 profile 裏驗工具面、會話行爲和 HTTP 面,確認後再裝進日常 profile。

和老做法的對比

痛點 本插件做法
不能從現有 profile 克隆,目標目錄還不能已存在 tmpprofile_create:模板建或 clone: "desktop" 克隆(配置複製,node_modules 逐項鍊接)
只想建 profile、不想立刻啓動 內部用 --dump-config 短路 boot
手拼探針命令、自己翻 sessions/ tmpprofile_run:裝配 → 跑 headless → 返回 sessionId 與事件摘要
headless 驗不了 HTTP / 渲染路由 tmpprofile_web_start / web_probe / web_stop:駐留 web 實例、探路由、按 pid 回收
會話 zstd 多幀解碼重複寫腳本 tmpprofile_session:內置逐幀解碼,輸出 preset、工具面、上下文、token 等
清理靠自覺 tmpprofile_clean:白名單 + junction 感知刪除 + 默認 dry-run

核心功能:十個工具

工具名統一 tmpprofile_ 前綴,便於在 dsh-tool-manager 裏整組開關。

工具 作用 關鍵參數
tmpprofile_create 建隔離 profile(模板或克隆),可選裝包 name、template(默認 headless)、clone、packages、purpose、overwrite
tmpprofile_install 對已登記臨時 profile 追加安裝或移除 name、packages、remove
tmpprofile_run 同步跑 headless 探針(帶超時) name、task、sessionId、env、timeoutMs、json
tmpprofile_web_start 起駐留 web 實例 name、port、probePath、waitMs、cwd、env
tmpprofile_web_probe 對駐留實例發 HTTP 探針 name、path、method、timeoutMs
tmpprofile_web_stop 停駐留實例 name、waitMs
tmpprofile_session 讀會話日誌結構化摘要 sessionId 或 name、sections、limit
tmpprofile_list 列出本插件管理的與未登記的 profile —
tmpprofile_clean 清理(默認演練,需 confirm: true) names、confirm、sessions、archiveTo
tmpprofile_fingerprint 採集 profiles/ 指紋,自查是否誤碰其他 profile exclude

headless 探針 側重 host 側事實(裝配、哪個 entry 未激活、卡在等哪個服務)。web 實例 側重 HTTP/渲染面(端口在聽、host 路由註冊、頁面 HTML 可取)。兩者不是同一件事;驗 web 時 profile 的 bundles 需含 @deepseek-ai/dsh-web-app(可用 template: "web" 或從帶 web-app 的 profile 克隆)。

安裝與啓用

插件以當前 DSH 進程權限運行;安裝前請自行查看 GitHub 源碼與 MIT 許可證。package.json 要求 Node >=20、DSH >=0.2.0-rc.1、Cordis >=4.0.0-rc <5。

從 README 給出的安裝方式:

# 從本地目錄裝(開發態)
dsh plugin --profile desktop add link:C:/repository/dsh-profile-lab

# 或從 GitHub 裝
dsh plugin --profile desktop add github:<你的賬號>/dsh-profile-lab

裝完後重啓 DSH(插件在啓動時裝配)。桌面版 profile 由 Electron 獨佔管理,命令行直連可能被拒——可用桌面版插件頁安裝,或走應用內通道。

可選 Cordis 配置(cordis.patch.yml 行內 config,均可省略):

- insert:
    - id: dsh-profile-lab
      name: 'dsh-profile-lab'
      config:
        home: 'C:/Users/you/.dsh'      # 缺省 $DSH_HOME 或 ~/.dsh
        dshBin: ''                      # 顯式指定 dsh 的 lib/bin.js
        nodePath: ''                    # 顯式指定子進程 node
        tools:
          disabled: ['tmpprofile_fingerprint']   # 按名字關閉工具

典型用法

模型側常見閉環如下(參數爲 JSON 工具調用示意):

# A. host 面:裝配 + 工具面 + 會話行爲
tmpprofile_create  { name: "probeA", template: "headless", purpose: "驗證 dsh-xxx 的工具面", packages: ["link:C:/plugins/dsh-xxx"] }
tmpprofile_run     { name: "probeA", task: "只回復兩個字:OK" }
tmpprofile_session { name: "probeA", sections: ["preset","tools","contexts"] }

# B. 渲染 / HTTP 面:起真實例,探插件 host 路由
tmpprofile_create    { name: "webA", template: "web", packages: ["link:C:/plugins/dsh-xxx"] }
tmpprofile_web_start { name: "webA", probePath: "/api/dsh-xxx/status" }
tmpprofile_web_stop  { name: "webA" }

tmpprofile_clean   { names: ["probeA", "webA"], confirm: true }

tmpprofile_run 返回的 session.tools 來自磁盤完整會話日誌;headless 的 --json 只是投影,不能替代日誌裏的 tool/call 面。更多配方見倉庫 docs/RECIPES.md。

裝好後可在倉庫根目錄跑自檢(會真建臨時 profile、裝本插件、跑一次 headless 並清理):

node scripts/selfcheck.mjs

退出碼 0 表示在真實 DSH 裏能加載且工具可調用。

安全護欄與文件位置

以下爲刻意設計的安全護欄:只讀寫登記在 $DSH_HOME/profile-lab.json 的臨時 profile,內置名如 desktop、headless、rescue 等硬拒;刪目錄前先 lstat 解 junction/symlink,不跟隨鏈接刪源;tmpprofile_clean 默認 dry-run;overwrite: true 才把舊目錄挪到 profile-lab-trash/;跨進程鎖 $DSH_HOME/profile-lab.lock;操作追加 $DSH_HOME/profile-lab-log.jsonl。

內容 路徑
清單 $DSH_HOME/profile-lab.json
審計日誌 $DSH_HOME/profile-lab-log.jsonl
臨時 profile $DSH_HOME/profiles/<name>/

適用場景與限制

適合:開發 DSH 插件或改 Cordis 注入時,需要在隔離 profile 裏裝 link/GitHub 包、跑短任務、讀會話摘要,必要時起 web 驗路由,再一次性清理。

不適合或需注意:

  • 主力 profile 已無法啓動時,本插件也依賴宿主加載,不能替代 rescue / reserve。
  • 探針會話仍寫在同一 DSH_HOME 的 sessions/ / storages/ 下;要進程級數據隔離需獨立 DSH_HOME(插件尚未實現)。
  • web 探針驗到服務端與靜態 HTML;頁面內 JS 是否真正執行需自行用瀏覽器打開對應端口查看。
  • profiles/ 裏歷史手工目錄會出現在 unmanaged,不會自動刪除,需顯式納管後再操作。

DSH 社區採用「一切皆插件」思路;SkillHub(skillhub.cn)是社區目錄站點,與 DeepSeek / 幻方無官方從屬關係。

鏈接

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

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

小夜