Skip to main content

Module app

Module app 

Source
Expand description

CLI entry orchestrator. 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).
  4. Expands @file attachments into an initial-message text block ([build_initial_message]).
  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.

@file expansion covers text files; images are detected but not attached to the prompt — the harness prompt_text accepts images, but this path 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”.)
EXIT_VETOED
The exit code when an extension vetoes startup at a lifecycle event (e.g. a BeforeTuiStart handler returns rpi_plugin_sdk::EVENT_HANDLER_ABORT). Distinct from EXIT_RUNTIME so scripts can tell “an extension refused to start” from “the run itself failed”.

Functions§

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