Platform
OpenCode (also affects all platforms on Windows)
context-mode version
1.0.103 (latest)
Debug script output
N/A — bug is in core executor, not hooks or plugins. Verified via direct code inspection and manual testing.
Exact prompt that triggered the bug
Any prompt that triggers ctx_execute(language: "shell", ...) on Windows, e.g.:
Run a shell command: echo "test"
Full error output
Two distinct symptoms:
-
Silent failure — no output returned:
ctx_execute(language: "shell", code: "echo test")
⎿ (no output)
JavaScript execution works fine in the same environment:
ctx_execute(language: "javascript", code: "console.log('test')")
⎿ test
-
Git Bash window pops up on top of workspace:
When shell execution is triggered, a Git Bash console window appears on top of the IDE/workspace because .sh files are associated with bash.exe on the system.
Steps to reproduce
- Run context-mode on Windows (native, not WSL)
- Ensure Git Bash is installed and
.sh files are associated with it
- Trigger any
ctx_execute with language: "shell"
- Observe: (a) no output returned, and/or (b) Git Bash window pops up
What I tried to fix it
- Set
SHELL environment variable in MCP config to C:/Git/bin/bash.exe — shell is found but execution still fails silently
- Verified
child_process.execSync works from JavaScript sandbox — confirms the shell binary is functional
- Inspected
src/executor.ts and src/runtime.ts source code
Root Cause Analysis
Three issues in the Windows shell execution path:
-
#writeScript uses .sh extension — On Windows, .sh files with a Git Bash association trigger a visible console window when accessed.
-
#spawn lacks windowsHide: true — Without this option, spawned console applications on Windows may create visible windows.
-
buildCommand passes script as direct argument — bash.exe script.sh causes MSYS2 path-mangling and file-association side effects. The existing comment in #spawn even says:
"On Windows with Git Bash, pass the script as bash -c "source /posix/path" rather than bash /path/to/script.sh."
But the code does NOT implement this — it passes the file path directly.
Proposed Fix
See PR: three minimal changes to src/executor.ts and src/runtime.ts:
- Write shell scripts without extension on Windows (
script instead of script.sh)
- Add
windowsHide: true to spawn options on Windows
- Use
bash -c "source 'filePath'" for shell commands on Windows
Operating System
Windows (PowerShell)
JS Runtime
Node.js v24.3.0
Platform
OpenCode (also affects all platforms on Windows)
context-mode version
1.0.103 (latest)
Debug script output
N/A — bug is in core executor, not hooks or plugins. Verified via direct code inspection and manual testing.
Exact prompt that triggered the bug
Any prompt that triggers
ctx_execute(language: "shell", ...)on Windows, e.g.:Full error output
Two distinct symptoms:
Silent failure — no output returned:
JavaScript execution works fine in the same environment:
Git Bash window pops up on top of workspace:
When shell execution is triggered, a Git Bash console window appears on top of the IDE/workspace because
.shfiles are associated withbash.exeon the system.Steps to reproduce
.shfiles are associated with itctx_executewithlanguage: "shell"What I tried to fix it
SHELLenvironment variable in MCP config toC:/Git/bin/bash.exe— shell is found but execution still fails silentlychild_process.execSyncworks from JavaScript sandbox — confirms the shell binary is functionalsrc/executor.tsandsrc/runtime.tssource codeRoot Cause Analysis
Three issues in the Windows shell execution path:
#writeScriptuses.shextension — On Windows,.shfiles with a Git Bash association trigger a visible console window when accessed.#spawnlackswindowsHide: true— Without this option, spawned console applications on Windows may create visible windows.buildCommandpasses script as direct argument —bash.exe script.shcauses MSYS2 path-mangling and file-association side effects. The existing comment in#spawneven says:But the code does NOT implement this — it passes the file path directly.
Proposed Fix
See PR: three minimal changes to
src/executor.tsandsrc/runtime.ts:scriptinstead ofscript.sh)windowsHide: trueto spawn options on Windowsbash -c "source 'filePath'"for shell commands on WindowsOperating System
Windows (PowerShell)
JS Runtime
Node.js v24.3.0