DeepSeek Harness 插件:在 Windows 上用 Git Bash 替換 PowerShell

前言

DeepSeek Harness(DSH)在 Windows 上的默認配置通常依賴 PowerShell (pwsh)。對於習慣 POSIX 語法或需要 Git Bash 的開發者來說,這有時會導致模型生成不兼容的命令。dsh-gitbash 插件解決了這個問題,它不新增模式或工具,而是將 DSH 現有的 bash 工具直接指向 Git for Windows Bash,並隱藏 PowerShell。

插件簡介

dsh-gitbash 是 DeepSeek Harness 的一個 bundle 插件,由 yunuo110 維護,採用 MIT 許可證。其設計目標是讓模型在 Windows 上自然使用 Git Bash,同時保持 DSH 的架構簡潔。

核心功能

該插件主要包含以下能力:
* 不新增模式、不新增工具:插件不註冊 gitbash 工具,模型看到的仍然是 DSH 原生的 bash 工具。
* 默認 Git Bash:在 Windows 上,bash 工具通過 Git\bin\bash.exe -lc <command> 執行。
* 隱藏 PowerShell:pwsh 從 prompt 中隱藏,且舊緩存嘗試調用時會被 guard 拒絕。
* 動態描述:bash 工具的描述被改寫爲 Git Bash/MSYS2 規則,引導模型使用 bash 語法。
* Windows 專用:非 Windows 系統上插件爲 no-op,不影響原生 bash。
* 自動探測路徑:插件會自動探測 Git Bash 的安裝路徑。

安裝與啓用

在插件倉庫根目錄執行以下命令進行安裝。新版 DSH 的 dsh plugin 命令會將參數轉發給 pnpm,安裝前請確保已安裝 pnpm。

dsh plugin --profile web add github:yunuo110/dsh-gitbash

安裝完成後,DSH 會自動執行以下操作:
1. 將 dsh-gitbash 作爲 bundle 加入 ~/.dsh/profiles/web。
2. 在 Windows 上提供 Git Bash shell executor。
3. 重新啓用 host 層 tool-bash。
4. 禁用 pwsh-sandbox / tool-pwsh。

注意:安裝後需要完整重啓 DSH,新建會話和舊對話都會使用同一個 bash 工具。

配置

默認情況下,插件會自動探測 Git Bash 的路徑(順序:環境變量 GIT_BASH -> Program Files / Program Files (x86) / ProgramW6432 / LocalAppData / Scoop -> PATH,排除 System32 的 WSL bash)。

如需固定路徑或調整超時等參數,可以在 profile 的 cordis.patch.yml 中覆蓋插件配置:

- id: dsh-gitbash
  config:
    shellPath: 'C:\Program Files\Git\bin\bash.exe'
    timeoutMs: 120000
    maxTimeoutMs: 600000
    maxOutputBytes: 64000
    maxSpillBytes: 67108864
    graceMs: 3000
字段 默認 說明
shellPath 自動探測 固定 Git Bash 路徑
timeoutMs 120000 單條命令默認超時
maxTimeoutMs 600000 超時上限
maxOutputBytes 64000 stdout 內存保留字節數
maxSpillBytes 67108864 spill 文件上限
graceMs 3000 SIGTERM → SIGKILL 寬限

典型用法

在安裝並重啓 DSH 後,模型看到的工具描述會指向 Git Bash。模型可以直接使用 POSIX/bash 語法執行命令。

示例場景:
* 查看 git 狀態:模型調用 bash 工具執行 git status。
* 運行測試:模型調用 bash 工具執行 npm test。
* 修改權限:如果當前會話沙箱不是完全訪問,第一次調用可能失敗。模型需要按提示將 sandbox_permissions 設置爲 danger-full-access。

JSON 調用示例:

{
  "command": "git status",
  "description": "查看 git 狀態",
  "sandbox_permissions": "danger-full-access",
  "justification": "Git Bash 無法在受限沙箱中啓動,需要完全訪問以執行 git 狀態檢查。"
}

兼容性與注意

  • 環境要求:DeepSeek Harness 0.1.2-rc.1(兼容 0.1.0-rc.6 起的同一套 shell/工具 seam),Node.js 22.19+。
  • 工具行爲:每次調用都是新的非交互式 bash.exe -lc,不保留 cd / export / alias 狀態。
  • 語法:使用 POSIX/bash 語法($VAR、${VAR}),避免使用 PowerShell 的 $env:VAR。
  • 許可證:MIT。

結語

dsh-gitbash 通過 patch 和配置注入的方式,實現了在 Windows 上無縫切換到 Git Bash 的需求,降低了模型在 Windows 環境下的命令執行門檻。如需查看源碼或提交問題,請訪問 GitHub。

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

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

小夜