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
30mod agent_package;
31pub mod agent_session;
32pub mod app;
33pub mod approval_gate;
34pub mod args;
35pub mod auth;
36pub mod auth_guidance;
37pub mod brand;
38mod cdn;
39pub mod changelog;
40pub mod config;
41mod credentials;
42pub mod dev_extension;
43pub mod docs_tool;
44pub mod events;
45pub mod experimental;
46pub mod export;
47pub mod extension_api;
48pub mod extensions_actions;
49pub mod extras;
50pub mod fs_watch;
51pub mod host;
52pub mod install;
53pub mod interactive_tui;
54pub mod key_trace;
55#[cfg(unix)]
56mod local_host;
57pub mod message_agent;
58#[cfg(unix)]
59mod mini;
60pub mod model_registry;
61pub mod modes;
62mod native_durable;
63pub mod packages;
64pub mod prebuilt_extensions;
65mod prebuilt_release;
66pub mod provider;
67pub mod provider_probe;
68pub mod remote;
69mod resource_commands;
70pub mod resource_dirs;
71pub mod resource_management;
72pub mod resource_selection;
73pub mod resume_picker;
74pub(crate) mod rpc;
75mod saved_session_read;
76pub mod session;
77pub mod session_cwd;
78pub mod session_driver;
79pub mod session_gc;
80mod session_preview;
81pub mod settings;
82mod side_questions;
83pub mod source_info;
84mod startup_diagnostics;
85pub mod themes;
86pub mod timings;
87mod transcript_navigation;
88pub mod transcript_view;
89pub mod trust;
90pub mod tui_shell;
91pub mod updates;
92
93/// One session's agent home (auth/models/settings/trust, resources, sessions).
94/// `AgentHome::process()` is the historical CLI home; embedding hosts pass an
95/// explicit path to run isolated sessions in one process.
96pub use config::AgentHome;
97
98/// Crate version, surfaced by `rpi --version`. Mirrors the TS `VERSION` export
99/// (sourced from `package.json`; here from `env!("CARGO_PKG_VERSION")`).
100///
101/// Aliases [`rpi_plugin_sdk::HOST_VERSION`] so the version the CLI prints and
102/// the version handed to plugins (and, through it, the version extensions stamp
103/// on their own telemetry) can never disagree.
104pub const VERSION: &str = rpi_plugin_sdk::HOST_VERSION;
105
106/// The application name used in help + version output. Mirrors TS `APP_NAME`
107/// (the TS bin is `"pi"`; the Rust crate publishes under the `rpi-` namespace,
108/// so the binary + displayed name is `"rpi"` to match).
109///
110/// Aliases [`rpi_plugin_sdk::HOST_NAME`] — the plugin contract owns the
111/// identity, so an extension can label its output (a trace name, a tag) without
112/// hardcoding a brand that a rename would silently invalidate.
113pub const APP_NAME: &str = rpi_plugin_sdk::HOST_NAME;