dsh-gitbash-shell 0.4.3 → 0.5.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/README.md CHANGED
@@ -75,7 +75,7 @@ bundle patch(`cordis.patch.yml`)应用三个改动:
75
75
  default: ptc-cordis # 或 standard-gitbash / minimal-gitbash
76
76
  ```
77
77
 
78
- ## 配置
78
+ ## 配置(执行器)
79
79
 
80
80
  `gitbash-executor` 行支持:
81
81
 
@@ -116,6 +116,14 @@ preset 会被插件自动清理;宿主 shell 回退为 PowerShell。
116
116
  > 切换生效后若 `ptc-cordis` 目录已存在且被旧版本物化,删除
117
117
  > `~/.dsh/.agent-presets/ptc-cordis` 并重启,即由新逻辑重新物化。
118
118
 
119
+ ## 与 dsh-better-sidebar 联动
120
+
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
+
123
+ - 你在设置页或 `cordis.patch.yml` 里手动设置过 shell → **尊重你的选择**,绝不覆盖;
124
+ - 卸载本插件 → 自动把该设置还原为空(回到它的默认解析:pwsh / powershell);
125
+ - 想关掉本联动 → 本插件 row 配置加 `betterSidebarShell: false`。
126
+
119
127
  ## 许可
120
128
 
121
129
  MIT © KannaKuron。参考与致敬:[dsh-ptc-cordis-preset](https://github.com/KannaKuron/dsh-ptc-cordis-preset)。
package/README_EN.md CHANGED
@@ -49,6 +49,14 @@ the PTC preset is materialized as Git Bash automatically (tool-bash on,
49
49
  tool-pwsh off) — no extra mode, no manual edits. Without this plugin the PTC
50
50
  preset stays as its own plugin manages it.
51
51
 
52
+ ## Cooperation with dsh-better-sidebar
53
+
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
+
56
+ - A shell you set yourself (settings page / `cordis.patch.yml`) is respected, never overridden;
57
+ - Removing this plugin reverts the pref to empty (the sidebar returns to its default pwsh / powershell resolution);
58
+ - Disable the adoption with `betterSidebarShell: false` in this plugin's row config.
59
+
52
60
  ## License
53
61
 
54
62
  MIT © KannaKuron. Inspired by
package/dsh.plugin.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-gitbash-shell",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "main": "./src/index.js",
5
- "description": "Windows 全模式 Git Bash:用 Git for Windows bash 替换 PowerShell 执行器,并物化 standard/minimal/code/cordis 的 Git Bash 变体 preset",
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": {
7
7
  "dsh": ">=0.0.1"
8
8
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gitbash-shell",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
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
@@ -232,6 +232,75 @@ export function installRegisterShim(reg) {
232
232
  }
233
233
  }
234
234
 
235
+ // ── dsh-better-sidebar shell cooperation ───────────────────────────────────
236
+ //
237
+ // dsh-better-sidebar (v0.15.2+) resolves its terminal shell PER OPEN: a
238
+ // settings-page `terminalShell` value wins over the yaml/plugin default
239
+ // (their own words: "values here win for terminals opened afterwards").
240
+ // So this plugin adopts that official runtime seam — zero upstream change,
241
+ // no restart needed — and points the sidebar's UI terminal tabs AND the
242
+ // model-facing terminal_* tools at Git Bash on Windows. A terminal shell
243
+ // the user set themselves is respected (we only fill an empty field), and
244
+ // the write is reverted on disposal (reload/update/uninstall), so removing
245
+ // this plugin returns the sidebar to its auto/default shell.
246
+
247
+ const SIDEBAR_NS = 'dsh-better-sidebar'
248
+
249
+ /**
250
+ * Fill the sidebar's `terminalShell` pref through the settings service.
251
+ * One-shot; retries once after a short delay in case the sidebar's
252
+ * namespace registration lands a beat after our row ran. Never throws.
253
+ */
254
+ function adoptSidebarShell(ctx, bashPath) {
255
+ let tried = 0
256
+ const run = async () => {
257
+ tried += 1
258
+ const settings = ctx.get('settings')
259
+ if (!settings || typeof settings.update !== 'function') return
260
+ let current
261
+ try {
262
+ current = settings.get(SIDEBAR_NS)
263
+ } catch {
264
+ current = undefined // namespace not registered yet / sidebar absent
265
+ }
266
+ const value = current && typeof current === 'object' ? current : {}
267
+ const existing = typeof value.terminalShell === 'string' ? value.terminalShell.trim() : ''
268
+ if (existing !== '') return // user/deployment choice — never override
269
+ try {
270
+ await settings.update(SIDEBAR_NS, { terminalShell: bashPath })
271
+ } catch (error) {
272
+ if (tried < 2) {
273
+ const timer = setTimeout(run, 1500)
274
+ ctx.effect(() => () => clearTimeout(timer), 'dsh-gitbash-shell: sidebar adoption retry')
275
+ return
276
+ }
277
+ console.log(`${TAG} better-sidebar shell adoption unavailable: ${error?.message ?? error}`)
278
+ return
279
+ }
280
+ let reverted = false
281
+ ctx.effect(
282
+ () => () => {
283
+ if (reverted) return
284
+ reverted = true
285
+ const s = ctx.get('settings')
286
+ if (!s || typeof s.update !== 'function') return
287
+ let now
288
+ try {
289
+ now = s.get(SIDEBAR_NS)
290
+ } catch {
291
+ return
292
+ }
293
+ if (String(now?.terminalShell ?? '') === bashPath) {
294
+ s.update(SIDEBAR_NS, { terminalShell: '' }).catch(() => {})
295
+ }
296
+ },
297
+ 'dsh-gitbash-shell: sidebar shell revert',
298
+ )
299
+ console.log(`${TAG} dsh-better-sidebar terminal shell -> Git Bash (${bashPath})`)
300
+ }
301
+ void run()
302
+ }
303
+
235
304
  // ── plugin ──────────────────────────────────────────────────────────────────
236
305
 
237
306
  /** First user-trust root: the roster's authoring target. */
@@ -305,6 +374,14 @@ export async function apply(ctx, config = {}) {
305
374
  const disposeGitBash = ctx.provide('gitBash', gitBashCapability)
306
375
  ctx.effect(() => disposeGitBash, 'dsh-gitbash-shell: gitBash capability')
307
376
 
377
+ // ── dsh-better-sidebar terminal adoption (Windows only) ────────────────
378
+ // The sidebar resolves its terminal shell through the settings seam per
379
+ // open; adopt it through that seam (see adoptSidebarShell for rationale).
380
+ // Disable with `betterSidebarShell: false` in the plugin row config.
381
+ if (config.betterSidebarShell !== false && process.platform === 'win32') {
382
+ adoptSidebarShell(ctx, gitBashCapability.bashPath)
383
+ }
384
+
308
385
  const roots = ctx.agentPresets?.roots ?? []
309
386
  const userRoot = firstUserRoot(roots)
310
387
  if (!userRoot) {