Skip to main content

Module app

Module app 

Source
Expand description

CLI entry orchestrator. Mirrors the v1-relevant slice of the TS packages/coding-agent/src/main.ts — the main(args) function that:

  1. Parses argv (crate::args::parse_args).
  2. Handles --help/--version + parse errors + startup warnings.
  3. Reads piped stdin (non-TTY ⇒ treat as the initial prompt text — TS readPipedStdin).
  4. Expands @file attachments into an initial-message text block (TS processFileArguments + [build_initial_message] — the port of TS buildInitialMessage).
  5. Resolves the provider + model + thinking level (crate::provider::resolve).
  6. Builds the harness (crate::session::build).
  7. Resolves the effective run mode (crate::args::resolve_mode) and dispatches to crate::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 prompts, 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.exitCode set from runPrintMode.
EXIT_USAGE
The exit code for a usage/parse error. (TS main.ts uses process.exit(1) for most error paths; v1 distinguishes usage errors with the conventional 2 so scripts can tell “bad invocation” from “run failed”.)

Functions§

run
The v1 CLI entry point. Mirrors TS export async function main(args).