dsh-plugin-git-bash:让 DSH 在 Windows 上默认使用 Git Bash

前言

在 DSH 的插件化扩展中,Windows 上的 shell 环境会影响命令执行的细节。dsh-plugin-git-bash 解决的是一个问题:让 DeepSeek Harness(DSH)在 Windows 上默认使用 Git for Windows Bash,同时保留 DSH 原有的 read-onlyworkspace-writedanger-full-access 权限语义。

这个插件由 inmny 维护,npm 包名为 dsh-plugin-git-bash,GitHub 仓库为 dsh-git-bash,许可证为 MIT。

这是什么

dsh-plugin-git-bash 是一个安装到 DSH profile 的 bundle layer,用来把 DSH 在 Windows 上的默认 shell 切到 Git for Windows Bash。

插件安装到 profile 后,standardcodecordisminimal preset 会使用 Git Bash 代替 PowerShell。前台命令、后台命令和 Web Agent preset 共用同一个 executor。

它只作为 bundle layer 安装到目标 profile,不修改 DSH 安装目录。

核心功能

下面介绍插件已经明确支持的能力。

  • 在 Windows 上让 DSH 默认使用 Git for Windows Bash。
  • 保留 DSH 的 read-onlyworkspace-writedanger-full-access 权限语义。
  • 安装到 profile 后,standardcodecordisminimal preset 使用 Git Bash 代替 PowerShell。
  • 前台命令、后台命令和 Web Agent preset 共用同一个 executor。
  • 自动探测 Program Files、用户安装目录和 Scoop 中的 Git Bash,并支持手动配置 bash.exe 路径。
  • Web GUI 中可展开 Bash 工具行,查看 commandcwdstdout/stderrexit status
  • npm 包包含 win32-x64 预编译的 msys-token-guard.exemsys-token-guard-hook.dll

安装与启用

运行时要求:

  • Windows x64
  • Node.js 24 或更高版本
  • DSH 0.1.0-rc.7
  • Git for Windows x64

先安装固定版本到 Web profile:

dsh plugin --profile web add dsh-plugin-git-bash@0.3.1

安装完成后重启 dsh web,让 Host 和浏览器 client 同时加载新版本,然后新建会话。

安装最新版时可以省略版本号:

dsh plugin --profile web add dsh-plugin-git-bash

开发本地版本时传入 checkout 路径:

dsh plugin --profile web add C:\path\to\dsh-git-bash

验证 shell

新建会话后运行下面的命令,确认当前 shell 已经是 Git Bash 环境:

printf 'shell=%s\nversion=%s\nmsystem=%s\n' "$BASH" "$BASH_VERSION" "$MSYSTEM"

其中 MSYSTEM 应为 MINGW64MINGW32

Web GUI 中也可以展开 Bash 工具行,查看该次命令的 commandcwdstdout/stderrexit status

配置 bash.exe 路径

插件会自动探测 Program Files、用户安装目录和 Scoop 中的 Git Bash。

无 GUI 场景可以在启动 DSH 前设置 DSH_GIT_BASH_PATH

$env:DSH_GIT_BASH_PATH = 'D:\Apps\Git\bin\bash.exe'
dsh web

也可以在 profile 的 cordis.patch.yml 中为 provider 配置 executable

- id: git-bash-shell
  name: dsh-plugin-git-bash
  config:
    executable: D:\Apps\Git\bin\bash.exe

权限模式

read-onlyworkspace-write

受限模式下,DSH Windows ACL sandbox 会创建 WRITE_RESTRICTED token。插件在 sandbox 内先运行 native guard,再由 guard 启动 Git Bash:

DSH ACL runner -> msys-token-guard.exe -> bash.exe -> child processes

具体语义是:

  • read-only 可以启动 Git Bash,但不能写 workspace。
  • workspace-write 只能写 DSH 授权的 workspace 和 private temp。

danger-full-access

danger-full-access 不经过 native guard,直接运行 Git Bash,与插件 0.1.x 的执行方式一致。

平台支持与限制

npm 包包含预编译的 msys-token-guard.exemsys-token-guard-hook.dll,普通安装不需要 Visual Studio 或 CMake。

当前 native guard 仅支持 win32-x64。其他架构在受限模式下会返回 SANDBOX_UNAVAILABLE,不会降级到未隔离执行。

Microsoft Detours 4.0.1 源码按 MIT 许可存放在 native/vendor/detours,许可文本随 npm 包分发。由于 Detours 的 DLL path 参数使用 Windows ANSI API,插件安装路径必须能由当前系统代码页无损表示,并且不能超过 MAX_PATH;不满足条件时 guard 会 fail closed。

适用场景与注意

这个插件适合以下场景:

  • 需要在 Windows 上把 DSH 的默认 shell 统一为 Git Bash。
  • 需要保留 DSH 的 read-onlyworkspace-writedanger-full-access 权限语义。
  • 需要在 Web GUI 中查看 Bash 命令的执行详情。

安装前要注意:

  • 插件最终运行在 DSH 进程所获得的系统权限范围内,安装前应检查源码、许可证和依赖。
  • 当前 native guard 仅支持 win32-x64
  • 安装路径必须满足 Windows ANSI API 的代码页要求和 MAX_PATH 限制。
  • danger-full-access 不经过 native guard,会直接运行 Git Bash,使用前应明确该权限范围。

结尾

dsh-plugin-git-bash 的价值比较具体:它把 DSH 在 Windows 上的默认 shell 切到 Git for Windows Bash,同时保留 DSH 的权限语义,并在受限模式下通过 native guard 维持 sandbox 隔离路径。

GitHub:https://github.com/inmny/dsh-git-bash

目录页链接未在已核实资料中确认,本文不写具体地址;如果社区目录收录,可搜索 dsh-plugin-git-bash。社区目录是独立站点,与 DeepSeek / 幻方无官方从属关系。

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

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

小夜