Expand description
CLI entry orchestrator. Mirrors the v1-relevant slice of the TS
packages/coding-agent/src/main.ts — the main(args) function that:
- Parses argv (
crate::args::parse_args). - Handles
--help/--version+ parse errors + startup warnings. - Reads piped stdin (non-TTY ⇒ treat as the initial prompt text — TS
readPipedStdin). - Expands
@fileattachments into an initial-message text block (TSprocessFileArguments+ [build_initial_message] — the port of TSbuildInitialMessage). - Resolves the provider + model + thinking level (
crate::provider::resolve). - Builds the harness (
crate::session::build). - Resolves the effective run mode (
crate::args::resolve_mode) and dispatches tocrate::modes(print/json/interactive), mapping the outcome to an exit code.
§v1 scope cuts vs TS main.ts (in docs/m6-cli-open-questions.md)
The TS main is enormous: HTTP proxy config, project-trust handling,
first-time setup, migrations, and full npm package management remain
outside this port. rpi does support local static package management via
rpi package and Rust cdylib extension installation. The regular agent path
remains a straight parse → resolve → build → run pipeline. The @file
expansion ports only the text-file branch (images are detected
but not attached to the prompt — the harness prompt_text accepts images,
but v1 does not yet wire an image processor; binary/non-UTF-8 files error).
Constants§
- EXIT_
RUNTIME - The exit code for a runtime failure (model-resolution, harness-build, or
run failure). Mirrors TS
process.exitCodeset fromrunPrintMode. - EXIT_
USAGE - The exit code for a usage/parse error. (TS
main.tsusesprocess.exit(1)for most error paths; v1 distinguishes usage errors with the conventional2so scripts can tell “bad invocation” from “run failed”.)
Functions§
- run
- The v1 CLI entry point. Mirrors TS
export async function main(args).