anomalyco / anomalyco/opencode

[FEATURE]: Terminal/Shell compatibility layer for Windows (Git Bash + PowerShell)

Open
#42,733 0 comments 0 reactions 1 assignee View on GitHub

@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 with command 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:

  1. 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 (as nc -z), .NET ZipFile (as zip), perl
      one-liners (tree, rev, column), start (as open/xdg-open).
      Each fallback installs only when command -v fails, with a stub-aware
      guard for Microsoft Store python3/pip3 App Execution Aliases.
    • Structured results (BashFix.command, replacements, path_changes,
      warning) so UI/logs show exactly what changed.
  2. 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 $null no-op for comment-only input; return None (reject)
      when repair is unsafe rather than executing garbage.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.