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