anomalyco / anomalyco/opencode
[FEATURE]: Terminal/Shell compatibility layer for Windows (Git Bash + PowerShell)
@Hona is already working on this.
Since Aug 15, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Summary
Sorry I am not a native English speaker, so I use AI to assistant this issue's grammar, but guarantee it is written by human.
Model-generated shell commands are executed verbatim. On Windows hosts this
fails often: commands written for macOS/Linux or cmd.exe don't run in Git
Bash or PowerShell. Request a shell compatibility layer that transparently
repairs commands before execution, as implemented in kimix.
Problem
- Git Bash lacks commands models commonly emit (
pbcopy,xclip,
xdg-open,wget,zip,nc,pgrep/pkill,tasklist,tree,rev,
column,gtimeout, …). Each call dies withcommand not found, wasting a
tool round-trip or derailing the task. - Windows paths and cmd syntax break Bash: backslash paths (
D:\foo\bar)
are mangled as escapes; cmd flags (/d) are misinterpreted. - PowerShell commands often arrive structurally broken: unclosed quotes,
here-strings, block comments, trailing comments, backtick continuations, or
--%— any of which can swallow the runner's try/catch wrapper.
The agent has no defense: failures surface as raw shell errors and the model
must guess its way out.
Proposed solution
A deterministic pre-execution compatibility pass with two scanners:
-
Bash fixer (Git Bash)
- Conservative scanner over executable/argument positions only (skipping
quotes, here-docs, command substitutions); rewrites drive-absolute and
relative backslash paths to forward slashes, preserving glob
metacharacters. - Bash-function fallbacks for missing commands, built on tools Windows
already ships:clip.exe,powershell.exe Get-Process,curl(as
wget),/dev/tcp(asnc -z), .NETZipFile(aszip), perl
one-liners (tree,rev,column),start(asopen/xdg-open).
Each fallback installs only whencommand -vfails, with a stub-aware
guard for Microsoft Storepython3/pip3App Execution Aliases. - Structured results (
BashFix.command,replacements,path_changes,
warning) so UI/logs show exactly what changed.
- Conservative scanner over executable/argument positions only (skipping
-
PowerShell fixer
- Validate quoting state (normal / single / double / here-string /
comment / block-comment); repair by appending the missing closer. - Append a newline after trailing comments, backtick continuations, and
--%so the execution wrapper isn't commented out, joined, or passed
literally to a native command. - Insert a
$nullno-op for comment-only input; returnNone(reject)
when repair is unsafe rather than executing garbage.
- Validate quoting state (normal / single / double / here-string /
Why not just prompt the model?
Prompting reduces but never eliminates these errors — models regress under
long contexts and mixed training data. A deterministic shim catches 100% of
covered cases at zero token cost, and its structured warnings teach the model
and user what was fixed.
Reference implementation
kimix ships this as src/kimix/tools/file/bash/{bash_fix.py, bash_tool.py, pwsh_fix.py, process_pwsh.py} (vendored mirror: bin/kimix_native/_shell_compat.py
— ~2600 lines, self-contained, stdlib-only). The vendored copy proves the
feature can be adopted with no new dependencies. Happy to contribute a port if
there is interest.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.