/** * Cross-platform shell resolution for the bash tool + background process * manager. * * The agent writes shell commands assuming POSIX `bash` semantics (`&&`, pipes, * `ls`, `grep`, `$(...)`, single-quoting, …). On macOS/Linux that's just * `bash`. On Windows there are three cases, and getting this wrong is the root * of the "files not mounted / different environment" class of bugs: * * 1. Git Bash (Git for Windows) — a REAL POSIX bash that operates on the * native Windows filesystem. `D:\proj` is reachable as `/d/proj` AND the * spawned process honors the Windows `cwd`. This is what we want, so we * detect and prefer it. * * 2. WSL bash (`C:\Windows\System32\bash.exe`) — the Windows Subsystem for * Linux launcher. It runs commands inside a SEPARATE Linux distro whose * filesystem is not the project tree (`D:\proj` ≈ `/mnt/d/proj`, and a * raw `D:\proj` cwd lands you somewhere else entirely). Commands appear to * run "in a different project / sandbox". We deliberately SKIP it. * * 3. No bash at all — bare `spawn("bash", …)` fails with `spawn bash ENOENT`, * so every shell command the agent runs errors out. We fall back to * `cmd.exe` so commands can at least run (with different semantics, which * the agent is told about). * * The resolver is pure: filesystem + env + platform are injected so it can be * unit-tested for every OS from any host. */ export interface ShellResolution { /** Executable to spawn (never goes through a shell wrapper itself). */ file: string; /** Args that run the given command string as one shell command. */ args: string[]; /** True when `file` is a cmd.exe fallback (non-POSIX semantics). */ isCmdFallback: boolean; } export interface ResolveShellOpts { platform?: NodeJS.Platform; env?: NodeJS.ProcessEnv; /** Injected for testability; defaults to fs.existsSync. */ exists?: (p: string) => boolean; } /** * Resolve the shell executable + args to run a single command string. * * `GG_BASH` env override always wins (point it at any POSIX bash, e.g. a custom * Git Bash or msys2 install). Otherwise: non-Windows → `bash`; Windows → Git * Bash if found, else `cmd.exe`. */ export declare function resolveShell(command: string, opts?: ResolveShellOpts): ShellResolution; //# sourceMappingURL=shell.d.ts.map