Skip to main content

Module cli

Module cli 

Source
Expand description

The real transport: shells out to the opencode CLI.

Stdout goes to a temp file, never a pipe: the CLI writes the body with one un-awaited process.stdout.write and then calls process.exit, so a pipe loses whatever the reader has not drained (spec Transport). The file is deleted by a drop guard on every exit path.

StructsΒ§

CliTransport
Finished πŸ”’
StdoutFile πŸ”’
Deletes the stdout temp file on every path, including a failed spawn.

EnumsΒ§

How πŸ”’
Mapped
What a failed (non-zero exit) CLI run maps to.

ConstantsΒ§

AUTH_HINT πŸ”’
SIZE_POLL πŸ”’
STDERR_CAP πŸ”’
STDERR_DRAIN πŸ”’
STDOUT_READ_CEILING
Runaway-output ceiling for a child’s stdout file (not a budget: legitimate reads are far below).

FunctionsΒ§

ceiling_error πŸ”’
deadline_error πŸ”’
err πŸ”’
exit_text πŸ”’
first_line πŸ”’
from_tool πŸ”’
io_error πŸ”’
map_cli_failure
The spec’s mapping table, in order. Reached only after a successful spawn.
npm_shim_exe
The executable an npm install of opencode keeps beside its opencode.cmd shim in dir (node_modules\@opencode\cli\bin\opencode.exe, the very file the shim runs), when both exist. The shim itself is never started: cmd.exe would expand %VAR% inside prompt text passed as arguments.
plain_failure πŸ”’
resolve_binary
Explicit path; else the first opencode/opencode.exe on path (on Windows also the executable behind an npm opencode.cmd shim, see npm_shim_exe); else <home>/.opencode/bin/opencode[.exe]; else OPENCODE_NOT_FOUND. Pure: nothing is spawned.
spawn_error πŸ”’
The one mapping of a failed Command::spawn.
unparseable πŸ”’
verb πŸ”’