dsh-turn-notify:DSH 每輪 Agent 結束時的 Windows 桌面角標提醒

前言

在 DeepSeek Harness(DSH)裏跑長任務時,開發者常常會把窗口切到別處寫代碼或查文檔,等 agent 一輪跑完再切回來。沒有顯式反饋時,只能反覆切回主窗口確認狀態。dsh-turn-notify 是社區維護的客戶端類 bundle 插件:在 每一輪 agent 任務結束 時,於 Windows 桌面右下角彈出一張會自動消失的 WPF 提示卡片,展示會話名、完成狀態與耗時。與瀏覽器 Notification 或系統 Toast 的常見做法不同,本插件在 host 側訂閱 DSH 的會話事件,在獨立渲染進程裏用 PowerShell + WPF 畫卡片,並針對 DSH 插件宿主(plain-node 子進程)和高壓安全軟件環境做了實測取捨。

這是什麼

  • 名稱:dsh-turn-notify(GitHub:koolook123/dsh-turn-notify)
  • 維護者:koolook123
  • 分類:客戶端(SkillHub 目錄歸類)
  • 許可證:MIT(README 與 package.json 一致)
  • 當前發佈:GitHub Release v1.0.0;公共 npm 上的包名 dsh-turn-notify 已被其他項目佔用,本插件默認通過 GitHub / bundle 方式安裝,未使用該 npm 名發佈

插件只在 Windows 上工作:process.platform !== 'win32' 時直接靜默退出。非 Windows 環境無需安裝。

核心功能

事件與文案

插件在 host 側訂閱 session/event 流中的 turn/start 與 turn/end:

  1. turn/start:記錄該會話本輪開始時間。
  2. turn/end:計算耗時,按結束原因生成正文(如「消息完成」「本輪失敗」「達到 token 上限」「本輪已停止」),再拉起渲染進程顯示卡片。

彈窗帶隊列:同一時刻只保留一張卡片,新一輪會替換排隊中的舊內容,避免疊多個窗口。

文案示例(來自 README):

DeepSeek Harness · 復盤 A 股收盤數據
消息完成 · 耗時 1m23s

實現要點(爲何是 PowerShell + WPF)

README 中記錄了在 DSH 插件宿主下的實測結論,摘要如下:未打包 Win32 進程下 Windows Toast 易被靜默丟棄;插件宿主無法 require('electron') 使用 BrowserWindow;隱藏式啓動 PowerShell 可能被 HIPS 攔截;detached: true 會導致宿主誤判子進程過早退出;高 DPI 下須用 SystemParameters.WorkArea 與 SetProcessDPIAware();toast.ps1 須保留 UTF-8 BOM 供 PowerShell 5.1 正確解析中文。

環境要求

  • Windows
  • PowerShell 5.1+,可加載 PresentationFramework / PresentationCore / WindowsBase / System.Windows.Forms
  • Node.js 18+(ESM)
  • DeepSeek Harness,且 profile 支持 dsh.bundle.patch

安裝與啓用

社區插件目錄頁:https://www.skillhub.cn/plugins/koolook123/dsh-turn-notify
源碼與說明:https://github.com/koolook123/dsh-turn-notify

下列命令來自官方 README,請按原文執行,不要自行拼接其他 dsh plugin add 形式。

方式一:從 GitHub 安裝 bundle(推薦)

在 profile 目錄(默認 ~/.dsh/profiles/desktop)執行:

cd ~/.dsh/profiles/desktop
pnpm add github:koolook123/dsh-turn-notify

將包名寫入該目錄 package.json 的 dsh.profile.bundles:

"dsh": {
  "profile": {
    "bundles": [
      "@deepseek-ai/dsh-base",
      "@deepseek-ai/dsh-web-app",
      "dsh-turn-notify"
    ]
  }
}

DSH 會讀取包內 dsh.bundle.patch 指向的 cordis.patch.yml 併合並掛載。修改後需重啓 DSH(插件宿主爲常駐子進程,熱更新不生效)。

cd ~/.dsh/profiles/desktop
pnpm add link:C:/path/to/dsh-turn-notify

同樣在 dsh.profile.bundles 中加入 dsh-turn-notify,並重啓 DSH。

方式三:手動寫入 cordis.patch.yml

部分 DSH 版本對 bundle 裸包名解析基準與 profile 目錄不一致,可能靜默加載失敗。可在 profile 的 cordis.patch.yml 中插入掛載段,並將 name 寫成相對路徑,例如:

- insert:
    - id: turn-notify
      name: ./node_modules/dsh-turn-notify/lib/index.js
      config:
        enabled: true
        seconds: 6
        width: 380
        bottomMargin: 24
        rightMargin: 24
        notifyOnSuccess: true
        notifyOnError: true
        minDurationSec: 0
        showSessionTitle: true
        maxBodyChars: 160

同時保證 package.json 的 dependencies 中已有對應包(github: 或 link: 形式)。

配置項

可在安裝後編輯 profile 裏的 cordis.patch.yml(或與包內 cordis.patch.yml 默認值對照修改):

鍵 默認值 說明
enabled true 總開關
seconds 6 卡片停留秒數(含淡入淡出)
width 380 卡片寬度(DIP)
bottomMargin / rightMargin 24 / 24 距右下角邊距(DIP)
notifyOnSuccess true 正常結束時彈窗
notifyOnError true error / interrupted 結束時彈窗
minDurationSec 0 最短耗時閾值,短於此不彈;0 表示每輪都彈
showSessionTitle true 標題是否帶會話名
maxBodyChars 160 正文字符上限
debounceMs 400 兩次彈窗最小間隔
script 自動探測 自定義渲染腳本路徑,優先級高於包內 toast.ps1

script 解析順序:配置路徑 → 包內 toast.ps1 → ~/.dsh/plugins/dsh-turn-notify/toast.ps1。

典型用法與自檢

不依賴 DSH 時,可手動觸發一次卡片,驗證 PowerShell 與 WPF 環境:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File toast.ps1 \
  -Title "DeepSeek Harness" -Body "消息完成 · 耗時 12s" -Seconds 6

(toast.ps1 路徑以你 clone 或 node_modules 中的實際位置爲準。)

排查問題時,README 建議查看:

  • Host:~/.dsh/turn-notify-debug.log(訂閱、turn/end、渲染進程退出碼等)
  • 渲染:~/.dsh/turn-notify-wpf.log(顯示座標、關閉、異常)

DSH_HOME 可覆蓋日誌目錄前綴;未設置時使用 %USERPROFILE%\.dsh。

語法與 BOM 快檢:

node --check lib/index.js
xxd -l 3 toast.ps1

xxd 前三字節應爲 efbbbf(UTF-8 BOM)。

適用場景與注意

適合:在 Windows 上使用 DSH 桌面 profile,希望 agent 每輪結束有本地視覺反饋、又不想一直盯着主窗口的開發者。

不適用:Linux / macOS;不需要任何桌面通知的場景(可將 enabled 設爲 false 或不要裝入 bundles)。

安全與權限:插件以當前 DSH 進程及其子進程權限運行,會 spawn PowerShell 執行包內腳本。安裝前應瀏覽 lib/index.js 與 toast.ps1,確認行爲與 MIT 許可證可接受。SkillHub 爲社區目錄,與 DeepSeek / 幻方無官方從屬關係;星標、下載數據以各站點當時展示爲準(目錄當前星標爲 0)。

若彈窗「閃一下就沒了」,README 提到常見原因包括向 PowerShell 傳入空的 -LogPath、去掉 toast.ps1 的 BOM,或被安全軟件攔截非最小化方式以外的隱藏啓動——對應修復見上文實現要點與日誌文件。

結尾

dsh-turn-notify 把 DSH「每輪 agent 結束」這一時刻接到 Windows 右下角的一張短駐卡片上,用會話事件驅動,而不是輪詢 UI。按 README 在 profile 中 pnpm add github:koolook123/dsh-turn-notify 並寫入 dsh.profile.bundles 後重啓 DSH 即可啓用;更多細節與發佈說明見 GitHub 倉庫,索引頁見 SkillHub 插件頁。

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

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

小夜