@blundergoat/goat-flow
Version:
AI coding agent harness and local dashboard for Claude Code, OpenAI Codex, Google Antigravity, and GitHub Copilot - setup audits, guardrails, structured skills, deny hooks, and persistent learning loops.
112 lines • 4.93 kB
TypeScript
/**
* Cross-platform invocation helpers for the bundled Bash installer.
*
* `handleInstallCommand` shells out to `workflow/install-goat-flow.sh` via
* `spawnSync("bash", ...)`. On native Windows two things go wrong with the
* naive call:
*
* 1. `getTemplatePath()` and `resolve(".")` return backslash paths. When
* Bash receives them as argv, the backslashes act as shell escapes and
* collapse the path (e.g. `C:\Users\...\install.sh` -> `CUsers...`).
* 2. `bash` on a stock Windows host resolves to `System32\bash.exe` (WSL)
* or the `WindowsApps\bash.exe` proxy first, which does not accept
* Windows-shaped paths and is slow to boot from PowerShell.
*
* This module owns the platform-gated argument shape and the Bash selection
* policy. POSIX behavior is intentionally byte-for-byte unchanged.
*/
/** Successful invocation spec. */
export interface InstallerInvocation {
ok: true;
bashCommand: string;
args: string[];
}
/** Spawn-ready command, argv, and environment for the selected installer Bash. */
export interface InstallerSpawnSpec {
command: string;
args: string[];
env: NodeJS.ProcessEnv;
}
/** Failure with a CLI-ready error message. */
export interface InstallerInvocationError {
ok: false;
error: string;
}
/** Inputs needed to build the installer call. */
export interface InstallerInvocationParams {
scriptPath: string;
projectPath: string;
agent: string;
installerFlags: readonly string[];
platform: NodeJS.Platform;
/**
* Bash candidates to consider on Windows. Tests inject this list; production
* code reads it from `where bash` via `discoverWindowsBashCandidates`.
*/
windowsBashCandidates?: readonly string[];
}
/**
* Build the (bash, argv) pair that `spawnSync` should use.
*
* Linux/macOS/WSL (`platform` other than `"win32"`): returns the raw inputs
* with `bash` as the command. The shape matches the historical call so POSIX
* users see no behavioural change.
*
* Native Windows (`platform === "win32"`): forward-slash-normalises the script
* and project paths so Git Bash / MSYS2 receive a valid path, and picks a
* non-WSL `bash.exe` from the supplied candidates.
*
* @param params Installer script, target project, agent, flags, and platform-specific Bash candidates.
* @returns Spawn-ready Bash command and argv, or a CLI-ready error when Windows has no usable Bash.
*/
export declare function buildInstallerInvocation(params: InstallerInvocationParams): InstallerInvocation | InstallerInvocationError;
/**
* Build the exact spawn command for a successful installer invocation.
*
* @param invocation Selected Bash command and installer argv.
* @param baseEnv Environment to inherit; tests may pass a fixed object.
* @returns Command, argv, and PATH-adjusted environment for `spawnSync`.
*/
export declare function buildInstallerSpawnSpec(invocation: InstallerInvocation, baseEnv?: NodeJS.ProcessEnv): InstallerSpawnSpec;
/**
* Convert a Windows path to a form Bash will not shell-escape.
*
* Drive-letter: `C:\Users\me` -> `C:/Users/me`
* UNC share: `\\srv\share\x` -> `//srv/share/x`
*
* POSIX paths contain no backslashes so the operation is a no-op for them,
* which matters because tests assert that POSIX inputs are byte-identical.
*
* @param shellPath Path argument that will be passed to Bash.
* @returns The same path with Windows backslashes converted to forward slashes.
*/
export declare function toBashPath(shellPath: string): string;
/**
* Pick the first Windows `bash.exe` that is not one of the known WSL shims.
*
* We reject by path rather than allowlist Git Bash because users may install
* MSYS2, Cygwin, Scoop, or Chocolatey distributions whose paths are not
* predictable. The two known-bad locations both belong to WSL:
*
* - `C:\Windows\System32\bash.exe` (Windows Subsystem for Linux launcher)
* - `%LOCALAPPDATA%\Microsoft\WindowsApps\bash.exe` (Store-managed WSL proxy)
*
* @param candidates Raw `where bash` output lines or test-injected candidate paths.
* @returns First non-WSL Bash path, or null when every candidate is unusable.
*/
export declare function pickWindowsBashPath(candidates: readonly string[]): string | null;
/**
* True if the candidate path matches a known WSL launcher location.
*
* @param candidate Bash executable path from discovery.
* @returns Whether the candidate is a WSL launcher that rejects Windows-shaped installer paths.
*/
export declare function isWslBashPath(candidate: string): boolean;
/**
* Render the actionable error when no usable Bash is found on Windows.
*
* @param candidates Rejected Bash paths from discovery, if any.
* @returns Multi-line CLI error that explains the Git Bash and WSL fallback options.
*/
export declare function buildWindowsBashMissingMessage(candidates: readonly string[]): string;
//# sourceMappingURL=install-invocation.d.ts.map