rpi_cli/lib.rs
1//! `pi-cli` — a terminal coding-agent CLI built on the rpi library crates.
2//!
3//! It provides the argument surface, provider/model resolution, harness
4//! construction, output modes, and the interactive TUI that a harness-backed
5//! CLI needs.
6//!
7//! # Surface
8//!
9//! - **Argument parsing** ([`args`]) — `--provider`/`--model`/`--api-key`,
10//! `--thinking`, `--print`/`-p`, `--mode {text,json}`, `-c`/`--continue`,
11//! `-r`/`--resume`, `--session`/`--session-dir`/`--no-session`, `--tools`/
12//! `-t`, `--exclude-tools`/`-xt`, `--no-tools`, `--no-builtin-tools`,
13//! `--system-prompt`, `--append-system-prompt`, `--name`/`-n`, `--verbose`,
14//! `--help`/`-h`, `--version`/`-v`, positional `messages`, and `@file`
15//! attachments.
16//! - **Provider/model resolution** ([`provider`]) — API key from `--api-key`
17//! or the provider's environment variable; model pattern
18//! `provider/id[:thinking]` resolved against the provider's catalog.
19//! - **Harness construction + run loop** ([`session`]) — `OsExecutionEnv` +
20//! built-in `read`/`write`/`edit`/`bash` tools, durable JSONL session storage,
21//! `AgentHarness`, and the `prompt_text → outcome` run.
22//! - **Output modes** ([`modes`]) — `print` (text, single-shot) and `json`
23//! (newline-delimited harness events), plus a simple interactive REPL.
24//! - **`app`** ([`app`]) — argument dispatch, model resolution, harness build,
25//! mode dispatch, exit codes.
26//!
27//! Resources load from `.rpi/` and `~/.rpi/agent/`; extensions are Rust
28//! `cdylib` plugins installed and developed with `rpi install` / `rpi dev`.
29
30pub mod agent_session;
31pub mod app;
32pub mod args;
33pub mod auth;
34pub mod auth_guidance;
35pub mod brand;
36pub mod changelog;
37mod child_agents;
38pub mod config;
39mod credentials;
40pub mod dev_extension;
41pub mod docs_tool;
42pub mod events;
43pub mod experimental;
44pub mod export;
45pub mod extension_api;
46pub mod extensions_actions;
47pub mod extras;
48pub mod fs_watch;
49pub mod install;
50pub mod interactive_tui;
51pub mod key_trace;
52pub mod model_registry;
53pub mod modes;
54mod native_store;
55pub mod packages;
56pub mod prebuilt_extensions;
57mod prebuilt_release;
58pub mod provider;
59pub mod remote;
60pub mod resource_dirs;
61pub mod resource_management;
62pub mod resource_selection;
63pub mod resume_picker;
64pub(crate) mod rpc;
65mod saved_session_read;
66pub mod session;
67pub mod session_cwd;
68pub mod session_driver;
69pub mod settings;
70mod side_questions;
71pub mod source_info;
72mod startup_diagnostics;
73pub mod themes;
74pub mod timings;
75mod transcript_navigation;
76pub mod transcript_view;
77pub mod trust;
78pub mod tui_shell;
79pub mod updates;
80
81/// Crate version, surfaced by `rpi --version`. Mirrors the TS `VERSION` export
82/// (sourced from `package.json`; here from `env!("CARGO_PKG_VERSION")`).
83///
84/// Aliases [`rpi_plugin_sdk::HOST_VERSION`] so the version the CLI prints and
85/// the version handed to plugins (and, through it, the version extensions stamp
86/// on their own telemetry) can never disagree.
87pub const VERSION: &str = rpi_plugin_sdk::HOST_VERSION;
88
89/// The application name used in help + version output. Mirrors TS `APP_NAME`
90/// (the TS bin is `"pi"`; the Rust crate publishes under the `rpi-` namespace,
91/// so the binary + displayed name is `"rpi"` to match).
92///
93/// Aliases [`rpi_plugin_sdk::HOST_NAME`] — the plugin contract owns the
94/// identity, so an extension can label its output (a trace name, a tag) without
95/// hardcoding a brand that a rename would silently invalidate.
96pub const APP_NAME: &str = rpi_plugin_sdk::HOST_NAME;