dsh-gitbash-shell 0.10.3 → 0.10.4

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/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-gitbash-shell",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "main": "./src/index.js",
5
5
  "description": "Windows 全模式 Git Bash:用 Git for Windows bash 替换 PowerShell 执行器,并物化 standard/minimal/code/cordis 的 Git Bash 变体 preset。双 era 适配 dsh <= 0.1.1(内置 id 'code')与 >= 0.1.2(改名 'ptc'),启动探测自动选择,preset id 永不变。联动:dsh-ptc-cordis-preset(两者同装时 PTC 创造模式自动物化为 Git Bash 版)+ dsh-better-sidebar(终端 UI 标签与模型 terminal_* 工具自动切到 Git Bash)。",
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gitbash-shell",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
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. On Windows it also adopts dsh-better-sidebar's terminal shell (UI tabs and the model-facing terminal_* tools) through the sidebar's official settings seam, and pairs with dsh-ptc-cordis-preset so the PTC Creation-mode preset materializes as its Git Bash variant. Ships both composition eras for dsh <= 0.1.1 (built-in preset id 'code') and dsh >= 0.1.2 (renamed id 'ptc') — the era is probed per boot and re-materialized automatically after a dsh upgrade, in either upgrade order; preset ids never change so pinned sessions stay valid.",
5
5
  "type": "module",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -334,6 +334,57 @@ export function windowsToMsys(text) {
334
334
  '/' + drive.toLowerCase() + '/' + rest.replace(/[\\/]+/g, '/'))
335
335
  }
336
336
 
337
+ /** Normalize backslash separators in a RELATIVE result path to slashes; pure. */
338
+ function posixSeparators(value) {
339
+ return typeof value === 'string' && value.includes(String.fromCharCode(92))
340
+ ? value.split(String.fromCharCode(92)).join('/')
341
+ : value
342
+ }
343
+
344
+ /**
345
+ * Rewrite result METADATA path fields to the MSYS dialect (pure, 0.10.4).
346
+ * Only the well-known metadata fields per tool are touched — read/write/edit
347
+ * `path` (absolute, via windowsToMsys), glob `paths[]` and grep
348
+ * `matches[].path` (workspace-relative, separator-normalized). File CONTENT
349
+ * (read lines, grep match text) and error results are never modified: the
350
+ * tool result is data, only its path metadata changes dialect so the model
351
+ * never meets a Windows-form path flowing back from a successful call.
352
+ * @returns {object} a new value when any field changed, the input otherwise.
353
+ */
354
+ export function rewriteResultPaths(name, value) {
355
+ if (!value || typeof value !== 'object') return value
356
+ if (name === 'read' || name === 'read_image' || name === 'write' || name === 'edit') {
357
+ if (typeof value.path === 'string' && value.path !== '') {
358
+ const out = windowsToMsys(value.path)
359
+ if (out !== value.path) return { ...value, path: out }
360
+ }
361
+ return value
362
+ }
363
+ if (name === 'glob' && Array.isArray(value.paths)) {
364
+ let changed = false
365
+ const paths = value.paths.map((p) => {
366
+ if (typeof p !== 'string') return p
367
+ const out = posixSeparators(windowsToMsys(p))
368
+ if (out === p) return p
369
+ changed = true
370
+ return out
371
+ })
372
+ return changed ? { ...value, paths } : value
373
+ }
374
+ if (name === 'grep' && Array.isArray(value.matches)) {
375
+ let changed = false
376
+ const matches = value.matches.map((m) => {
377
+ if (!m || typeof m !== 'object' || typeof m.path !== 'string') return m
378
+ const out = posixSeparators(windowsToMsys(m.path))
379
+ if (out === m.path) return m
380
+ changed = true
381
+ return { ...m, path: out }
382
+ })
383
+ return changed ? { ...value, matches } : value
384
+ }
385
+ return value
386
+ }
387
+
337
388
  // ── MSYS drive-root path translation (Windows, EVERY tool dispatch) ────────
338
389
  //
339
390
  // The directive below tells the model to use POSIX-style MSYS paths (/c/...)
@@ -643,6 +694,38 @@ export async function apply(ctx, config = {}) {
643
694
  }
644
695
  }
645
696
 
697
+ // ── result-path dialect on tools/post-execute (Windows only, gated; v0.10.4) ──
698
+ // Successful results carry Windows-form path METADATA (read.path, glob
699
+ // paths[], grep matches[].path) out of the Node fs layer. The official
700
+ // post-execute waterfall allows replacing the value projection, so while
701
+ // posixPaths is on those metadata fields flow back in the MSYS dialect and
702
+ // the model never sees a Windows path echoed by a successful call. File
703
+ // content and error results are untouched (see rewriteResultPaths).
704
+ if (process.platform === 'win32') {
705
+ try {
706
+ ctx.on('tools/post-execute', (exec, result, next) => {
707
+ let patch
708
+ try {
709
+ if (readPosixPaths(ctx) && result && result.isError === false && result.value && typeof result.value === 'object') {
710
+ const value = rewriteResultPaths(exec && exec.name, result.value)
711
+ if (value !== result.value) patch = value
712
+ }
713
+ } catch { /* never block a result */ }
714
+ const chain = next()
715
+ if (patch === undefined) return chain
716
+ return chain.then((decision) => {
717
+ try {
718
+ if (decision && decision.kind === 'accept') return { ...decision, value: patch }
719
+ } catch { /* keep the downstream decision */ }
720
+ return decision
721
+ })
722
+ })
723
+ console.log(TAG + ' result-path dialect active on tools/post-execute')
724
+ } catch (error) {
725
+ console.log(TAG + ' tools/post-execute wiring failed: ' + (error?.message ?? error))
726
+ }
727
+ }
728
+
646
729
  // ── Unified POSIX path directive (Windows Git Bash, EVERY session) ─────
647
730
  // ONE path style for every tool: MSYS drive roots (/c/Users/...). Bash
648
731
  // digests them natively; the file tools receive the drive-letter form
@@ -747,4 +830,4 @@ export async function apply(ctx, config = {}) {
747
830
  }
748
831
 
749
832
  // Test surface: pure helpers, no Cordis context required.
750
- export const _internal = { PRESET_IDS, translateMsysPath, translatePathArguments, readPosixPaths, windowsToMsys, MARKER_FILE, classify, materialize, cleanupOnDispose, firstUserRoot, hashTree, skillsHashes, syncDecision, installRegisterShim, baseForRoster, detectBase, pickComposition }
833
+ export const _internal = { PRESET_IDS, translateMsysPath, translatePathArguments, readPosixPaths, windowsToMsys, rewriteResultPaths, MARKER_FILE, classify, materialize, cleanupOnDispose, firstUserRoot, hashTree, skillsHashes, syncDecision, installRegisterShim, baseForRoster, detectBase, pickComposition }