dsh-gitbash-shell 0.21.0 → 0.21.1

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.21.0",
3
+ "version": "0.21.1",
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.21.0",
3
+ "version": "0.21.1",
4
4
  "description": "Windows 上让 agent 的每条 shell 命令改经 Git for Windows bash 执行;物化四个内置预设的 Git Bash 变体,统一 MSYS 盘根路径方言,侧栏终端接管可开关。· Run every agent shell command through Git for Windows bash on Windows; materialize Git Bash variants of the built-in presets, unify the MSYS drive-root path dialect, and adopt the sidebar terminal behind a switch.",
5
5
  "type": "module",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -696,18 +696,12 @@ const PATH_DIALECT_KEY = 'DSH_PATH_DIALECT'
696
696
  const PATH_DIALECT_VALUE = 'msys'
697
697
  const PATH_DIALECT_DESCRIPTION = 'Path dialect for tool calls and tool results: MSYS drive roots (/c/Users/...) plus the bash-native mounts (~, /tmp, /dev/null, /usr); every tool accepts these forms directly.'
698
698
 
699
- // v0.21.0 — line endings for the MODEL's git commands. Windows Git defaults to
700
- // core.autocrlf=true, so an LF file the model writes comes back CRLF after a
701
- // checkout (scripts break on the stray \r, byte assertions fail); a Linux guest
702
- // has autocrlf=false. GIT_CONFIG_* are per-invocation settings: they reach only
703
- // the commands this plugin's shell runs, never the user's own terminal, and a
704
- // repository's .gitattributes still wins.
705
- const GIT_CONFIG_COUNT_KEY = 'GIT_CONFIG_COUNT'
706
- const GIT_CONFIG_KEY_0 = 'GIT_CONFIG_KEY_0'
707
- const GIT_CONFIG_VALUE_0 = 'GIT_CONFIG_VALUE_0'
708
- const GIT_CONFIG_KEY_1 = 'GIT_CONFIG_KEY_1'
709
- const GIT_CONFIG_VALUE_1 = 'GIT_CONFIG_VALUE_1'
710
- const GIT_EOL_DESCRIPTION = 'Git line endings for model-run commands: core.autocrlf=false / core.eol=lf, matching a Linux guest (the user own git config is untouched).'
699
+ // v0.21.1 — line endings for the MODEL's git commands live in the EXECUTOR
700
+ // (src/shell.js, withParityEnv): Windows Git defaults to core.autocrlf=true, so
701
+ // an LF file the model writes comes back CRLF after a checkout (scripts break on
702
+ // the stray \r, byte assertions fail), while a Linux guest has autocrlf=false.
703
+ // They cannot ride the shell-env registry below: that registry accepts DSH_*
704
+ // facts only, and a non-DSH key throws the whole contribution away.
711
705
 
712
706
  /** Read the posixPaths switch from the live settings service; never throws. */
713
707
  export function readPosixPaths(ctxLike) {
@@ -1700,29 +1694,16 @@ export async function apply(ctx, config = {}) {
1700
1694
  if (!shellEnv || typeof shellEnv.register !== 'function') return
1701
1695
  const unregister = shellEnv.register({
1702
1696
  name: 'gitbash-shell',
1703
- variables: {
1704
- [PATH_DIALECT_KEY]: { description: PATH_DIALECT_DESCRIPTION },
1705
- [GIT_CONFIG_COUNT_KEY]: { description: GIT_EOL_DESCRIPTION },
1706
- [GIT_CONFIG_KEY_0]: { description: GIT_EOL_DESCRIPTION },
1707
- [GIT_CONFIG_VALUE_0]: { description: GIT_EOL_DESCRIPTION },
1708
- [GIT_CONFIG_KEY_1]: { description: GIT_EOL_DESCRIPTION },
1709
- [GIT_CONFIG_VALUE_1]: { description: GIT_EOL_DESCRIPTION },
1710
- },
1697
+ // The registry accepts DSH_* FACTS ONLY (a non-DSH key makes the
1698
+ // whole contribution throw — learned in v0.21.0, see CHANGELOG):
1699
+ // git line endings and anything else non-DSH_* ride the executor's
1700
+ // own env layer (src/shell.js), not this registry.
1701
+ variables: { [PATH_DIALECT_KEY]: { description: PATH_DIALECT_DESCRIPTION } },
1711
1702
  resolve() {
1712
- const dialect = readDialectSettings(envCtx)
1713
- if (dialect.posixPaths !== true) return {}
1714
- const values = { [PATH_DIALECT_KEY]: PATH_DIALECT_VALUE }
1715
- if (dialect.gitAutocrlf === true) {
1716
- values[GIT_CONFIG_COUNT_KEY] = '2'
1717
- values[GIT_CONFIG_KEY_0] = 'core.autocrlf'
1718
- values[GIT_CONFIG_VALUE_0] = 'false'
1719
- values[GIT_CONFIG_KEY_1] = 'core.eol'
1720
- values[GIT_CONFIG_VALUE_1] = 'lf'
1721
- }
1722
- return values
1703
+ return readPosixPaths(envCtx) ? { [PATH_DIALECT_KEY]: PATH_DIALECT_VALUE } : {}
1723
1704
  },
1724
1705
  })
1725
- envCtx.effect(() => unregister, 'dsh-gitbash-shell: shellEnv path-dialect fact')
1706
+ envCtx.effect(() => unregister, 'dsh-gitbash-shell: shellEnv path-dialect fact')
1726
1707
  console.log(`${TAG} shellEnv fact registered: ${PATH_DIALECT_KEY} (gated by the posixPaths setting)`)
1727
1708
  } catch (error) {
1728
1709
  console.log(`${TAG} shellEnv fact registration failed: ${error?.message ?? error}`)
package/src/shell.js CHANGED
@@ -128,7 +128,41 @@ export class GitBashSandboxExecutor extends SandboxBashExecutor {
128
128
  * #1, see the file header): route them through the unconfined argv path
129
129
  * and label the result honestly so callers can tell.
130
130
  */
131
+ /**
132
+ * Linux-parity environment for the MODEL's shell (v0.21.1). The official
133
+ * shell-env registry accepts DSH_* facts only — registering anything else
134
+ * throws and takes the whole contribution (including DSH_PATH_DIALECT) down
135
+ * with it — so non-DSH parity facts are merged into the trusted dshEnv map
136
+ * HERE, right before the spawn. Windows Git defaults to core.autocrlf=true,
137
+ * so an LF file the model writes comes back CRLF after a checkout (scripts
138
+ * break on the stray \r, byte assertions fail); a Linux guest has
139
+ * autocrlf=false. GIT_CONFIG_* are per-invocation settings: only the
140
+ * commands this executor runs see them, the user's own terminal and a
141
+ * repository's .gitattributes are untouched.
142
+ * @param {object} spec the shell request
143
+ * @returns {object} the request with the parity facts merged in
144
+ */
145
+ withParityEnv(spec) {
146
+ try {
147
+ const settings = this.ctx && typeof this.ctx.get === 'function' ? this.ctx.get('settings') : undefined
148
+ const value = settings && typeof settings.get === 'function' ? settings.get('gitbash-shell') : undefined
149
+ if (!value || value.posixPaths !== true || value.gitAutocrlf === false) return spec
150
+ const dshEnv = {
151
+ ...(spec.dshEnv === undefined ? {} : spec.dshEnv),
152
+ GIT_CONFIG_COUNT: '2',
153
+ GIT_CONFIG_KEY_0: 'core.autocrlf',
154
+ GIT_CONFIG_VALUE_0: 'false',
155
+ GIT_CONFIG_KEY_1: 'core.eol',
156
+ GIT_CONFIG_VALUE_1: 'lf',
157
+ }
158
+ return { ...spec, dshEnv }
159
+ } catch {
160
+ return spec
161
+ }
162
+ }
163
+
131
164
  async run(spec) {
165
+ spec = this.withParityEnv(spec)
132
166
  const policy = spec.sandboxPolicy
133
167
  if (policy === undefined) return super.run(spec)
134
168
  const { mode } = policy
@@ -149,6 +183,7 @@ export class GitBashSandboxExecutor extends SandboxBashExecutor {
149
183
  }
150
184
 
151
185
  start(spec) {
186
+ spec = this.withParityEnv(spec)
152
187
  const policy = spec.sandboxPolicy
153
188
  if (policy === undefined) return super.start(spec)
154
189
  const { mode } = policy