@wzwjustdoit/dsh-plugin-git-bash 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +154 -2
- package/client.js +736 -0
- package/cordis.patch.yml +27 -0
- package/lib/agents.d.ts +5 -0
- package/lib/agents.d.ts.map +1 -0
- package/lib/agents.js +56 -0
- package/lib/agents.js.map +1 -0
- package/lib/discovery.d.ts +21 -0
- package/lib/discovery.d.ts.map +1 -0
- package/lib/discovery.js +122 -0
- package/lib/discovery.js.map +1 -0
- package/lib/index.d.ts +55 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +369 -0
- package/lib/index.js.map +1 -0
- package/native/CMakeLists.txt +58 -0
- package/native/bin/win32-x64/msys-token-guard-hook.dll +0 -0
- package/native/bin/win32-x64/msys-token-guard.exe +0 -0
- package/native/msys-token-guard-hook.cpp +470 -0
- package/native/msys-token-guard.cpp +671 -0
- package/native/vendor/detours/LICENSE.md +23 -0
- package/native/vendor/detours/README.dsh.md +13 -0
- package/native/vendor/detours/creatwth.cpp +1577 -0
- package/native/vendor/detours/detours.cpp +2364 -0
- package/native/vendor/detours/detours.h +1059 -0
- package/native/vendor/detours/detver.h +27 -0
- package/native/vendor/detours/disasm.cpp +4236 -0
- package/native/vendor/detours/image.cpp +2251 -0
- package/native/vendor/detours/modules.cpp +929 -0
- package/native/vendor/detours/uimports.cpp +269 -0
- package/package.json +120 -4
- package/scripts/build-native.mjs +35 -0
- package/scripts/dsh.desktop.startup/README.md +27 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.bat +28 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.sh +46 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.vbs +0 -0
- package/scripts/dsh.web.startup/README.md +33 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.bat +28 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.sh +48 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.vbs +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,155 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wzwjustdoit/dsh-plugin-git-bash
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
让 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 在 Windows 上默认使用 Git for Windows Bash,并保留 DSH 的 `read-only`、`workspace-write` 和 `danger-full-access` 权限语义。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## 使用方法
|
|
8
|
+
|
|
9
|
+
插件安装到 profile 后,`standard`、`code`、`cordis` 和 `minimal` preset 会使用 Git Bash 代替 PowerShell。前台命令、后台命令和 Web Agent preset 共用同一个 executor。
|
|
10
|
+
|
|
11
|
+
新建会话后可以运行以下命令确认 shell:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
printf 'shell=%s\nversion=%s\nmsystem=%s\n' "$BASH" "$BASH_VERSION" "$MSYSTEM"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`MSYSTEM` 应为 `MINGW64` 或 `MINGW32`。
|
|
18
|
+
|
|
19
|
+
Web 界面中的 Bash 工具行可以展开查看 command、cwd、stdout/stderr 和 exit status。`run_code` 内的 nested Bash 调用使用同一套 terminal 详情;过长的 command 会自动换行,output 则保留终端横向滚动,以维持日志和表格的列对齐。
|
|
20
|
+
|
|
21
|
+
插件只作为 bundle layer 安装到目标 profile,不修改 DSH 安装目录。
|
|
22
|
+
|
|
23
|
+
## 安装或更新
|
|
24
|
+
|
|
25
|
+
从 npm 安装固定版本到 Web profile:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
dsh plugin --profile web add @wzwjustdoit/dsh-plugin-git-bash@0.4.0
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
更新现有安装时使用同一条命令。安装完成后重启 `dsh web`,让 Host 和浏览器 client 同时加载新版本,然后新建会话。
|
|
32
|
+
|
|
33
|
+
安装最新版时可以省略版本号:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
dsh plugin --profile web add @wzwjustdoit/dsh-plugin-git-bash
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
开发本地版本时传入 checkout 路径:
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
dsh plugin --profile web add C:\path\to\dsh-git-bash
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 权限模式
|
|
46
|
+
|
|
47
|
+
### `read-only` 和 `workspace-write`
|
|
48
|
+
|
|
49
|
+
受限命令仍由 DSH Windows ACL sandbox 创建 `WRITE_RESTRICTED` token。插件在 sandbox 内先运行 native guard,再由 guard 启动 Git Bash:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
DSH ACL runner -> msys-token-guard.exe -> bash.exe -> child processes
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- `read-only` 可以启动 Git Bash,但不能写 workspace。
|
|
56
|
+
- `workspace-write` 只能写 DSH 授权的 workspace 和 private temp。
|
|
57
|
+
|
|
58
|
+
### `danger-full-access`
|
|
59
|
+
|
|
60
|
+
该模式不经过 native guard,也不进入 sandbox,直接以正常权限运行 Git Bash。它使用 `DSH_GIT_BASH_PATH`
|
|
61
|
+
|
|
62
|
+
## 配置与启动
|
|
63
|
+
|
|
64
|
+
插件会自动探测 Program Files、用户安装目录、Scoop、`GIT_INSTALL_ROOT` 以及 `PATH` 中的 Git Bash。Web GUI 中打开 `设置 -> 插件 -> 插件配置`,展开 `Git Bash` 卡片,可以看到**两个**路径字段:
|
|
65
|
+
|
|
66
|
+
| 卡片字段 | 对应配置 | 对应环境变量 |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Git Bash 可执行文件(启动脚本 / danger-full-access) | `executable` | `DSH_GIT_BASH_PATH` |
|
|
69
|
+
| Git Bash 可执行文件(read-only / workspace-write) | `confinedExecutable` | `DSH_GIT_BASH_PATH_CONFINED` |
|
|
70
|
+
|
|
71
|
+
每个字段都可以直接输入 `bash.exe` 路径,或通过 `选择 Git 安装目录` 调用系统路径选择窗口。保存后,后续 Bash 命令会立即使用新路径;恢复默认值会回到 profile 配置或自动探测结果。
|
|
72
|
+
|
|
73
|
+
### 配置两个环境变量(重要)
|
|
74
|
+
|
|
75
|
+
插件按用途读取两个环境变量,各指向一份 Git Bash:
|
|
76
|
+
|
|
77
|
+
| 环境变量 | 服务的场景 | 推荐配置 |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `DSH_GIT_BASH_PATH` | 启动脚本(`dsh web` / DSH desktop)、以及 `danger-full-access` 模式 | 你自己日常使用的那份 Git for Windows |
|
|
80
|
+
| `DSH_GIT_BASH_PATH_CONFINED` | `read-only`、`workspace-write` 受限模式 | 另一份**单独**的 Git for Windows(如 PortableGit 解压版),只用于受限模式 |
|
|
81
|
+
|
|
82
|
+
**为什么受限模式要用另一份:** `danger-full-access` 以正常(Medium)完整性运行,会让 MSYS2 在 `\BaseNamedObjects` 下创建 `msys-2.0S5-<Git安装路径哈希>`;受限模式的子进程被降到 Low 完整性,**无法打开**已存在的 Medium 对象。只要两份 Git 的安装路径不同,哈希就不同,两者各自创建各自的共享对象,互不干扰。若两份指向同一安装,受限模式会在 `danger-full-access` 运行期间报 `0xC0000022`。
|
|
83
|
+
|
|
84
|
+
**典型症状:** 受限模式下命令退出码为 127、且 stderr 出现 `NtCreateDirectoryObject(\BaseNamedObjects\msys-2.0S5-…): 0xC0000022`,通常就是两个变量指向了同一份 Git(或在受限模式运行期间有非沙箱 MSYS 进程持有它)。
|
|
85
|
+
|
|
86
|
+
**注意事项(请务必阅读):`DSH_GIT_BASH_PATH_CONFINED` 必须与 `DSH_GIT_BASH_PATH` 指向不同的 Git 安装路径。** 指向同一份会退回成"共用一份",受限模式将不可用。
|
|
87
|
+
|
|
88
|
+
未设置 `DSH_GIT_BASH_PATH_CONFINED` 时,受限模式回落到 `DSH_GIT_BASH_PATH` 与自动探测,行为与旧版本一致(此时两个用途共用一份 Git,可能遇到上面描述的问题)。
|
|
89
|
+
|
|
90
|
+
### 启动方式(重要)
|
|
91
|
+
|
|
92
|
+
**强烈建议用本仓库提供的启动脚本启动 DSH。** 原因:DSH 的 Windows ACL sandbox 需要主进程 token 的 default DACL 含当前用户 SID;由 `explorer.exe` / `cmd.exe` 直接派生的进程往往不含,会导致受限模式全部 `exit 125`(`dsh web`)或直接崩溃(DSH desktop)。经 Git Bash 启动可以让 MSYS2 把 DACL 重置为含用户 SID 的标准形状。
|
|
93
|
+
|
|
94
|
+
本仓库提供两套启动脚本,按你运行的形态选择:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
scripts/dsh.web.startup/ # dsh web(node 进程)
|
|
98
|
+
├── dsh.web.startup.gitbash.vbs
|
|
99
|
+
├── dsh.web.startup.gitbash.bat
|
|
100
|
+
└── dsh.web.startup.gitbash.sh
|
|
101
|
+
|
|
102
|
+
scripts/dsh.desktop.startup/ # DSH desktop(Electron GUI 程序)
|
|
103
|
+
├── dsh.desktop.startup.gitbash.vbs
|
|
104
|
+
├── dsh.desktop.startup.gitbash.bat
|
|
105
|
+
└── dsh.desktop.startup.gitbash.sh
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
用法:
|
|
109
|
+
|
|
110
|
+
1. 把对应的**整个目录**复制到任意位置(脚本内部按相对路径互相引用,可整体移动)。
|
|
111
|
+
2. 设置 `DSH_GIT_BASH_PATH`,指向你日常使用的 Git for Windows 的 `bash.exe`。用 DSH desktop 时,再按安装位置设置 `DSH_DESKTOP_EXE`(缺省指向 `Program Files`,详见该目录的 README)。
|
|
112
|
+
3. 双击 `*.bat` 前台启动;或 `*.vbs` 后台启动。
|
|
113
|
+
|
|
114
|
+
### 配置文件(可选)
|
|
115
|
+
|
|
116
|
+
`~/.dsh/profiles/web/cordis.patch.yml` 或 `~/.dsh/profiles/desktop/cordis.patch.yml` 中为 provider 配置 `executable` 与 `confinedExecutable`:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
- id: git-bash-shell
|
|
120
|
+
name: '@wzwjustdoit/dsh-plugin-git-bash'
|
|
121
|
+
config:
|
|
122
|
+
executable: D:\Apps\Git\bin\bash.exe
|
|
123
|
+
confinedExecutable: D:\dsh-git-runtime\usr\bin\bash.exe
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 平台支持
|
|
127
|
+
|
|
128
|
+
运行时要求:
|
|
129
|
+
|
|
130
|
+
- Windows x64
|
|
131
|
+
- Node.js 24 或更高版本
|
|
132
|
+
- DSH `0.2.0` 或更高版本
|
|
133
|
+
- Git for Windows x64
|
|
134
|
+
|
|
135
|
+
npm 包包含预编译的 `msys-token-guard.exe` 和 `msys-token-guard-hook.dll`,普通安装不需要 Visual Studio 或 CMake。当前 native guard 仅支持 `win32-x64`;其他架构在受限模式下返回 `SANDBOX_UNAVAILABLE`,不会降级到未隔离执行。
|
|
136
|
+
|
|
137
|
+
Microsoft Detours 4.0.1 源码按 MIT 许可存放在 `native/vendor/detours`,许可文本随 npm 包分发。Detours 的 DLL path 参数使用 Windows ANSI API,因此插件安装路径必须能由当前系统代码页无损表示,并且不能超过 `MAX_PATH`;不满足条件时 guard 会 fail closed。
|
|
138
|
+
|
|
139
|
+
## 开发
|
|
140
|
+
|
|
141
|
+
安装依赖并运行完整验证:
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
pnpm install
|
|
145
|
+
pnpm test
|
|
146
|
+
pnpm run pack:check
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
在 Windows 上重建 native artifact 还需要 Visual Studio C++ Build Tools 和 CMake 3.25 或更高版本。`pnpm test` 会以 C++20、静态 MSVC runtime、CFG、CET、ASLR 和 NX 构建 native guard,然后运行 Windows ACL permission matrix、fail-closed、Web client 和 package metadata 测试。
|
|
150
|
+
|
|
151
|
+
非 Windows 主机不会交叉编译 native guard,只会检查预编译 artifact 是否存在。
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|