dsh-gitbash-shell 0.5.0 → 0.5.2
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/README.md +2 -2
- package/README_EN.md +2 -2
- package/dsh.plugin.json +1 -1
- package/package.json +1 -1
- package/src/index.js +31 -15
package/README.md
CHANGED
|
@@ -120,8 +120,8 @@ preset 会被插件自动清理;宿主 shell 回退为 PowerShell。
|
|
|
120
120
|
|
|
121
121
|
装了 [dsh-better-sidebar](https://github.com/omdsh-dev/DSH-better-sidebar)(v0.15.2+) 时,Windows 上本插件会通过**它的官方设置补丁口**(运行时 `terminalShell` 设置,对方文档明示"settings-page overrides win for terminals opened afterwards")把它打开的终端 shell 指向 Git Bash——**UI 终端标签与模型侧 `terminal_*` 工具统一生效**,不改对方一行代码、新开的终端即生效。规则:
|
|
122
122
|
|
|
123
|
-
-
|
|
124
|
-
- 卸载本插件 →
|
|
123
|
+
- **插件全权接管**:Windows 上每次启动都无条件把它的 `terminalShell` 设为 Git Bash——即使你在设置页/别处改过,下次插件启动也会改回来;
|
|
124
|
+
- 卸载本插件 → 自动还原为你改之前的原值(回到它的默认解析:pwsh / powershell);
|
|
125
125
|
- 想关掉本联动 → 本插件 row 配置加 `betterSidebarShell: false`。
|
|
126
126
|
|
|
127
127
|
## 许可
|
package/README_EN.md
CHANGED
|
@@ -53,8 +53,8 @@ preset stays as its own plugin manages it.
|
|
|
53
53
|
|
|
54
54
|
When [dsh-better-sidebar](https://github.com/omdsh-dev/DSH-better-sidebar) (v0.15.2+) is installed, on Windows this plugin adopts its official runtime settings seam (`terminalShell` — by the sidebar's own contract, "settings-page overrides win for terminals opened afterwards"), so both the sidebar's UI terminal tabs and the model-facing `terminal_*` tools open Git Bash — no upstream change, new terminals pick it up immediately. Rules:
|
|
55
55
|
|
|
56
|
-
-
|
|
57
|
-
- Removing this plugin
|
|
56
|
+
- **The plugin owns the pref while installed**: on every Windows boot it unconditionally sets `terminalShell` to Git Bash — a value you set elsewhere is overwritten again on the next boot;
|
|
57
|
+
- Removing this plugin restores the previous value (the sidebar returns to what it had before, e.g. its default pwsh / powershell resolution);
|
|
58
58
|
- Disable the adoption with `betterSidebarShell: false` in this plugin's row config.
|
|
59
59
|
|
|
60
60
|
## License
|
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-gitbash-shell",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"description": "Windows 全模式 Git Bash:用 Git for Windows bash 替换 PowerShell 执行器,并物化 standard/minimal/code/cordis 的 Git Bash 变体 preset。联动 dsh-ptc-cordis-preset:两者同装时 PTC 创造模式自动物化为 Git Bash 版。",
|
|
6
6
|
"engines": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-gitbash-shell",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "DSH plugin: run every agent shell command through Git for Windows bash on Windows instead of PowerShell. Replaces the pwsh executor with a Git Bash ctx.shell provider and materializes Git Bash variants of the standard/minimal/code/cordis agent presets into your user preset root at startup.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
package/src/index.js
CHANGED
|
@@ -239,24 +239,39 @@ export function installRegisterShim(reg) {
|
|
|
239
239
|
// (their own words: "values here win for terminals opened afterwards").
|
|
240
240
|
// So this plugin adopts that official runtime seam — zero upstream change,
|
|
241
241
|
// no restart needed — and points the sidebar's UI terminal tabs AND the
|
|
242
|
-
// model-facing terminal_* tools at Git Bash on Windows.
|
|
243
|
-
// the
|
|
244
|
-
//
|
|
245
|
-
//
|
|
242
|
+
// model-facing terminal_* tools at Git Bash on Windows. The plugin TAKES
|
|
243
|
+
// OVER the pref unconditionally while installed (a value set elsewhere is
|
|
244
|
+
// overwritten at every boot — that is the contract); the previous value is
|
|
245
|
+
// captured and restored on disposal (reload/update/uninstall), so removing
|
|
246
|
+
// this plugin returns the sidebar to what it was before.
|
|
246
247
|
|
|
247
248
|
const SIDEBAR_NS = 'dsh-better-sidebar'
|
|
249
|
+
const SIDEBAR_TRIES = 12
|
|
250
|
+
const SIDEBAR_RETRY_MS = 1500
|
|
248
251
|
|
|
249
252
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
+
* Write the sidebar's `terminalShell` pref through the settings service.
|
|
254
|
+
* Polls until the settings service (and the sidebar's namespace) are ready:
|
|
255
|
+
* at boot the service may not be provided yet when this row's apply runs, so
|
|
256
|
+
* the first attempt can silently see nothing — every attempt after the first
|
|
257
|
+
* catches the service once it exists. Never throws; always logs the outcome.
|
|
253
258
|
*/
|
|
254
259
|
function adoptSidebarShell(ctx, bashPath) {
|
|
255
260
|
let tried = 0
|
|
261
|
+
let timer = null
|
|
262
|
+
ctx.effect(() => () => { if (timer) clearTimeout(timer) }, 'dsh-gitbash-shell: sidebar adoption polling')
|
|
256
263
|
const run = async () => {
|
|
257
264
|
tried += 1
|
|
258
265
|
const settings = ctx.get('settings')
|
|
259
|
-
|
|
266
|
+
const ready = settings && typeof settings.update === 'function' && typeof settings.get === 'function'
|
|
267
|
+
if (!ready) {
|
|
268
|
+
if (tried < SIDEBAR_TRIES) {
|
|
269
|
+
timer = setTimeout(run, SIDEBAR_RETRY_MS)
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
console.log(`${TAG} better-sidebar shell adoption skipped: settings service unavailable after ${tried} tries`)
|
|
273
|
+
return
|
|
274
|
+
}
|
|
260
275
|
let current
|
|
261
276
|
try {
|
|
262
277
|
current = settings.get(SIDEBAR_NS)
|
|
@@ -264,14 +279,12 @@ function adoptSidebarShell(ctx, bashPath) {
|
|
|
264
279
|
current = undefined // namespace not registered yet / sidebar absent
|
|
265
280
|
}
|
|
266
281
|
const value = current && typeof current === 'object' ? current : {}
|
|
267
|
-
const
|
|
268
|
-
if (existing !== '') return // user/deployment choice — never override
|
|
282
|
+
const previous = typeof value.terminalShell === 'string' ? value.terminalShell : ''
|
|
269
283
|
try {
|
|
270
284
|
await settings.update(SIDEBAR_NS, { terminalShell: bashPath })
|
|
271
285
|
} catch (error) {
|
|
272
|
-
if (tried <
|
|
273
|
-
|
|
274
|
-
ctx.effect(() => () => clearTimeout(timer), 'dsh-gitbash-shell: sidebar adoption retry')
|
|
286
|
+
if (tried < SIDEBAR_TRIES) {
|
|
287
|
+
timer = setTimeout(run, SIDEBAR_RETRY_MS)
|
|
275
288
|
return
|
|
276
289
|
}
|
|
277
290
|
console.log(`${TAG} better-sidebar shell adoption unavailable: ${error?.message ?? error}`)
|
|
@@ -291,12 +304,15 @@ function adoptSidebarShell(ctx, bashPath) {
|
|
|
291
304
|
return
|
|
292
305
|
}
|
|
293
306
|
if (String(now?.terminalShell ?? '') === bashPath) {
|
|
294
|
-
s.update(SIDEBAR_NS, { terminalShell:
|
|
307
|
+
s.update(SIDEBAR_NS, { terminalShell: previous }).catch(() => {})
|
|
295
308
|
}
|
|
296
309
|
},
|
|
297
310
|
'dsh-gitbash-shell: sidebar shell revert',
|
|
298
311
|
)
|
|
299
|
-
console.log(
|
|
312
|
+
console.log(
|
|
313
|
+
`${TAG} dsh-better-sidebar terminal shell -> Git Bash (${bashPath})` +
|
|
314
|
+
(previous ? ` (took over from '${previous}')` : ''),
|
|
315
|
+
)
|
|
300
316
|
}
|
|
301
317
|
void run()
|
|
302
318
|
}
|