Expand description
Spawn-spec — safely launch AI tools without shell escape hazards.
Prompts with quotes/$/backticks/newlines break when re-quoted through
AppleScript/wezterm/tmux send-text layers. Instead, materialize writes
argv+cwd to a temp file and returns exec gw _spawn-ai <path> as the
launcher command. execute reads the spec, unlinks it, chdir’s, and
execvp’s the real tool — the pane shell only ever parses ASCII.
Structs§
Constants§
Functions§
- execute
- Execute a spawn spec. Never returns to the caller:
- materialize
- Write
specto a 0600 tempfile in the system temp dir and return(shell_line, spec_path).shell_lineis safe to hand to any launcher. - materialize_
in_ dir - Test seam — write into an explicit directory.
- read_
spec - Parse a spec file, rejecting unsupported versions and empty argv.
All errors are prefixed with
spawn-ai:so the entrypoint can print them verbatim without duplicating the prefix. - sweep_
stale - Best-effort removal of stale
gw-spawn-*.jsontemp files from the system temp directory. Intended to run once atgwstartup. All errors are swallowed — this is a safety net, not a correctness mechanism.