dsh-gitbash-shell 0.9.0 → 0.10.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/dsh.plugin.json +1 -1
- package/package.json +1 -1
- package/src/index.js +61 -4
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-gitbash-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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.
|
|
3
|
+
"version": "0.10.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. 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
|
@@ -302,7 +302,7 @@ export function installRegisterShim(reg) {
|
|
|
302
302
|
const SETTINGS_NAMESPACE = 'gitbash-shell'
|
|
303
303
|
|
|
304
304
|
/** The full directive text, injected only while posixPaths is on. */
|
|
305
|
-
const POSIX_DIRECTIVE_TEXT = 'The
|
|
305
|
+
const POSIX_DIRECTIVE_TEXT = 'The working shell is Git for Windows bash: paths use MSYS drive roots (/c/Users/...), and every tool accepts that form directly.'
|
|
306
306
|
|
|
307
307
|
/** Read the posixPaths switch from the live settings service; never throws. */
|
|
308
308
|
export function readPosixPaths(ctxLike) {
|
|
@@ -315,6 +315,25 @@ export function readPosixPaths(ctxLike) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
// Windows absolute path -> MSYS drive-root form, for rewriting the OFFICIAL
|
|
319
|
+
// prompt text in place (v0.10.0). Two patterns keep quoted spaced paths
|
|
320
|
+
// ("C:\Program Files\Git") whole while bare paths stop at whitespace or a
|
|
321
|
+
// closing punctuation; the lookbehind set rejects URL schemes (https:),
|
|
322
|
+
// file:// forms, and anything already mid-word, so only real drive-letter
|
|
323
|
+
// paths are translated. Separators normalize to single slashes.
|
|
324
|
+
const BARE_WIN_PATH = /(?<![A-Za-z0-9:\\/"'`])([A-Za-z]):(?:\\|\/)([^\s"'`<>|),;:!?]+)/g
|
|
325
|
+
const QUOTED_WIN_PATH = /(["'`])([A-Za-z]):(?:\\|\/)([^`]*?)\1/g
|
|
326
|
+
|
|
327
|
+
/** Rewrite every Windows absolute path in a text to the MSYS form; pure. */
|
|
328
|
+
export function windowsToMsys(text) {
|
|
329
|
+
if (typeof text !== 'string' || text.length === 0) return text
|
|
330
|
+
return text
|
|
331
|
+
.replace(QUOTED_WIN_PATH, (_whole, quote, drive, rest) =>
|
|
332
|
+
quote + '/' + drive.toLowerCase() + '/' + rest.replace(/[\\/]+/g, '/') + quote)
|
|
333
|
+
.replace(BARE_WIN_PATH, (_whole, drive, rest) =>
|
|
334
|
+
'/' + drive.toLowerCase() + '/' + rest.replace(/[\\/]+/g, '/'))
|
|
335
|
+
}
|
|
336
|
+
|
|
318
337
|
// ── MSYS drive-root path translation (Windows, EVERY tool dispatch) ────────
|
|
319
338
|
//
|
|
320
339
|
// The directive below tells the model to use POSIX-style MSYS paths (/c/...)
|
|
@@ -545,9 +564,9 @@ export async function apply(ctx, config = {}) {
|
|
|
545
564
|
? ds.settingsNamespace(SETTINGS_NAMESPACE)
|
|
546
565
|
: SETTINGS_NAMESPACE
|
|
547
566
|
settings.register(ns, Schema.object({
|
|
548
|
-
posixPaths: Schema.boolean().default(
|
|
567
|
+
posixPaths: Schema.boolean().default(true),
|
|
549
568
|
}))
|
|
550
|
-
console.log(`${TAG} settings namespace registered: ${SETTINGS_NAMESPACE} (posixPaths default
|
|
569
|
+
console.log(`${TAG} settings namespace registered: ${SETTINGS_NAMESPACE} (posixPaths default on)`)
|
|
551
570
|
})
|
|
552
571
|
.catch((error) => {
|
|
553
572
|
console.log(`${TAG} settings namespace registration FAILED: ${error && error.stack || String(error)}`)
|
|
@@ -557,6 +576,44 @@ export async function apply(ctx, config = {}) {
|
|
|
557
576
|
console.log(`${TAG} settings inject wiring failed: ${error?.message ?? error}`)
|
|
558
577
|
}
|
|
559
578
|
|
|
579
|
+
// ── prompt-assembly path dialect (Windows only, gated; v0.10.0) ────────
|
|
580
|
+
// While posixPaths is on, EVERY Windows absolute path the model would
|
|
581
|
+
// see — section text, context text, and prompt variables — is rewritten
|
|
582
|
+
// IN PLACE to the MSYS drive-root form. Nothing is added or removed: the
|
|
583
|
+
// official prompt keeps its exact shape and only the path examples
|
|
584
|
+
// change dialect, so the model meets a /c/ world at the source instead
|
|
585
|
+
// of being asked to translate Windows forms it sees. Our own directive
|
|
586
|
+
// context is skipped (self-reference), and tool schemas stay untouched
|
|
587
|
+
// (they carry no drive-letter examples today, and blind string rewriting
|
|
588
|
+
// could corrupt pattern/default fields).
|
|
589
|
+
if (process.platform === 'win32') {
|
|
590
|
+
try {
|
|
591
|
+
ctx.on('system-prompt/assemble', (assembly, _assembleContext, next) => {
|
|
592
|
+
try {
|
|
593
|
+
if (readPosixPaths(ctx) && assembly && typeof assembly === 'object') {
|
|
594
|
+
for (const section of Array.isArray(assembly.sections) ? assembly.sections : []) {
|
|
595
|
+
if (section && typeof section.text === 'string') section.text = windowsToMsys(section.text)
|
|
596
|
+
}
|
|
597
|
+
for (const assembled of Array.isArray(assembly.contexts) ? assembly.contexts : []) {
|
|
598
|
+
if (!assembled || assembled.name === 'gitbash-shell:posix-paths') continue
|
|
599
|
+
if (typeof assembled.text === 'string') assembled.text = windowsToMsys(assembled.text)
|
|
600
|
+
}
|
|
601
|
+
const variables = assembly.variables
|
|
602
|
+
if (variables && typeof variables === 'object') {
|
|
603
|
+
for (const key of Object.keys(variables)) {
|
|
604
|
+
if (typeof variables[key] === 'string') variables[key] = windowsToMsys(variables[key])
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
} catch { /* never block assembly */ }
|
|
609
|
+
return next()
|
|
610
|
+
})
|
|
611
|
+
console.log(TAG + ' prompt-assembly path dialect active (gated by the posixPaths setting)')
|
|
612
|
+
} catch (error) {
|
|
613
|
+
console.log(TAG + ' system-prompt/assemble wiring failed: ' + (error?.message ?? error))
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
560
617
|
// ── MSYS path translation on every tool dispatch (Windows only) ─────────
|
|
561
618
|
// Covers every preset and mode: the wrapper sits on the global
|
|
562
619
|
// tools/execute waterfall, through which model-direct calls, PTC run_code
|
|
@@ -681,4 +738,4 @@ export async function apply(ctx, config = {}) {
|
|
|
681
738
|
}
|
|
682
739
|
|
|
683
740
|
// Test surface: pure helpers, no Cordis context required.
|
|
684
|
-
export const _internal = { PRESET_IDS, translateMsysPath, translatePathArguments, readPosixPaths, MARKER_FILE, classify, materialize, cleanupOnDispose, firstUserRoot, hashTree, skillsHashes, syncDecision, installRegisterShim, baseForRoster, detectBase, pickComposition }
|
|
741
|
+
export const _internal = { PRESET_IDS, translateMsysPath, translatePathArguments, readPosixPaths, windowsToMsys, MARKER_FILE, classify, materialize, cleanupOnDispose, firstUserRoot, hashTree, skillsHashes, syncDecision, installRegisterShim, baseForRoster, detectBase, pickComposition }
|