/** * Which execution world a file-search spawn belongs to, and the `wsl.exe` * argv it becomes there. * * `dsh-tool-fs-search` spawns the packaged ripgrep binary through * `ctx.subprocess` with the session workspace as the working directory. Left * alone, that spawn runs the Windows binary over the distro's 9p share — the * one model-facing I/O path that still crossed the share, and in the slow * direction: measured at ~17 ms per file of metadata round trips where the * distro's own ext4 answers in microseconds. The interception point is the * subprocess provider's `spawn`, and the decision lives here — pure, * peer-free, and unit-testable, mirroring `terminal-route.js`. * * The rewrite is deliberately narrow. A spawn is intercepted only when the * working directory NAMES the distro outright — a `\\wsl.localhost\` * UNC — because that is the form a distro session's search carries and the * only one that resolves without an async distro query: `spawn` hands back * its handle synchronously, so the override must stay synchronous. A Windows * drive directory keeps the host binary, which is native there and touches * no share; anything else passes through untouched, exactly as before. * * The rewritten argv forwards every rg argument verbatim, so the tool reads * the output format and exit codes of the distro's own rg. One addition is * made: when the tool named no search path — its pattern rides `--regexp=`, * and a bare `--` separator is exactly how it spells an explicit path — the * rewrite appends `-- .`. Reason: `wsl.exe --exec` hands the distro-side rg a * relay FIFO for stdin, and rg's readable-stdin heuristic then searches stdin * (instantly empty) instead of walking the working directory; the packaged * binary under the old path saw a non-readable NUL stdin and walked it. An * explicit path makes the search deterministic on either transport. * * The distro-side binary must therefore exist — `scripts/bootstrap.sh` reports * it — and a distro without one surfaces rg's own "command not found" instead * of a silent fall-back to the share. * * This is a TypeScript source built to `lib/search-route.js`; edit THIS file * and run `pnpm run build` — the artifact under `lib/` is generated, and * `pnpm test` fails when it drifts. * * @module dsh-plugin-wsl-env/search-route */ /** * Whether a spawn's program is the ripgrep binary. * * A bare `argv[0]` is judged by its own name, so the packaged binary's * absolute path and any other spelling of `rg` match alike. * * @param program - the spawn's `argv[0]`. * @returns true when the spawn is a ripgrep launch. */ export declare function isSearchProgram(program: unknown): boolean; /** * The distro-side rewrite of one search spawn, when it belongs in the distro. * * Two argv forms come back for one decision. `rgArgv` is the distro command * itself (`rg` and its arguments) — what the resident agent execs. `wslArgv` * is the same command wrapped for a one-shot `wsl.exe --exec` launch — the * fallback transport for when the agent is out. The working directory becomes * the `--cd` the distro starts in; `wsl.exe` itself must start in a Windows * directory, so the caller supplies its own host cwd when applying `wslArgv`. * * @param object - the spawn's inputs. * @returns the rewrite, or undefined when the spawn is not a distro search and * must run exactly as the shipped implementation would run it. */ export declare function searchSpawnRewrite({ argv, cwd, wslPath }: { argv: readonly string[]; cwd: string; wslPath: string; }): { distro: string; linuxCwd: string; rgArgv: string[]; wslArgv: string[]; } | undefined;