Expand description
pi-cli — a terminal coding-agent CLI built on the rpi library crates.
It provides the argument surface, provider/model resolution, harness construction, output modes, and the interactive TUI that a harness-backed CLI needs.
§Surface
- Argument parsing (
args) —--provider/--model/--api-key,--thinking,--print/-p,--mode {text,json},-c/--continue,-r/--resume,--session/--session-dir/--no-session,--tools/-t,--exclude-tools/-xt,--no-tools,--no-builtin-tools,--system-prompt,--append-system-prompt,--name/-n,--verbose,--help/-h,--version/-v, positionalmessages, and@fileattachments. - Provider/model resolution (
provider) — API key from--api-keyor the provider’s environment variable; model patternprovider/id[:thinking]resolved against the provider’s catalog. - Harness construction + run loop (
session) —OsExecutionEnv+ built-inread/write/edit/bashtools, durable JSONL session storage,AgentHarness, and theprompt_text → outcomerun. - Output modes (
modes) —print(text, single-shot) andjson(newline-delimited harness events), plus a simple interactive REPL. app(app) — argument dispatch, model resolution, harness build, mode dispatch, exit codes.
Resources load from .rpi/ and ~/.rpi/agent/; extensions are Rust
cdylib plugins installed and developed with rpi install / rpi dev.
Modules§
- agent_
session AgentSession— the coding-agent product layer over the harness.- app
- CLI entry orchestrator. The
main(args)function that: - args
- CLI argument parsing + help text. Mirrors the TS The CLI arg surface, scoped to the flags the v1 Rust CLI honors.
- auth
rpi authsubcommand — persistent credential management. Mirrors the Rust-relevant slice of the TSpackages/coding-agent/src/cli/auth-command.ts- auth_
guidance - Auth guidance strings.
- brand
- The startup brand lockup: the three-bar mark, the
rpiwordmark, and the Rust crab standing in for the language name. - changelog
- Changelog fetching and parsing.
- config
- Layout
- dev_
extension - Development workflow for Rust-native rpi extensions.
- docs_
tool - Built-in
docstool for looking up rpi usage documentation. - events
rpi events …— inspect the extension event journal (P3).- experimental
- Experimental feature gate.
- export
- Session export functionality.
- extension_
api - Stable capability contracts shared by native and Node extension backends.
- extensions_
actions - B5a — the
RuntimeActionHostimpl over the harness, lived inrpi-cli(NOTrpi-harness) sorpi-extensionsstays a leaf in the crate DAG. The trait is defined inrpi-extensions(JSON + primitives only); this is the host side that bridges the 16 [RuntimeActionId] actions to the harness. - extras
- First-launch setup banner — thin host wrapper over the rpi-tui components.
- fs_
watch - Lightweight file watching for live reload.
- install
rpi install— install a Rustcdylibextension from crates.io.- interactive_
tui - Interactive mode for pi-cli.
- key_
trace - Env-gated key-event tracing for diagnosing terminal input problems (remote/mobile clients, “Enter inserted a newline”, paste-vs-typed Enter…).
- llama_
command - LLaMA.cpp integration command.
- model_
registry - Model registry runtime - dynamic model registration and refresh.
- modes
- Output modes. Mirrors the v1-relevant slice of the TS
packages/coding-agent/src/modes/{print-mode,json-event,rpc-mode}.ts— the three run shapes a harness-backed CLI needs: - packages
- Project-local Rust extension packages.
- provider
- Provider + model resolution. Mirrors the provider/model selection and request-auth portions of upstream’s model runtime.
- remote
- Remote client support for
rpi --connect. - resource_
dirs - Resource-directory resolution + project-wins dedupe for skills and
prompt templates. Mirrors the precedence contract from pi’s
DefaultResourceLoader/package-manager(resource-loader.ts:676-681,package-manager.ts:178-181): resources are ranked project=0/1 < user=2/3 < package=4, andaddSkills/dedupePromptsare first-registration-wins on name → loading project before global means project wins on collision (skills.ts:399-428), with a collision diagnostic naming the winner (kept) and loser (dropped) paths. - resume_
picker - Startup session picker used by
-r/--resume. - session
- Harness construction + session-storage wiring. Mirrors the Rust-side
equivalent of the TS
packages/coding-agent/src/core/sdk.ts(createAgentSession) — build the env, tools, durable session storage, andAgentHarnessOptions, thenAgentHarness::create. - session_
cwd - Stored-session working-directory recovery.
- session_
driver - Transport-agnostic session driver — the “only the transport differs” boundary.
- settings
~/.rpi/agent/settings.json— saved user defaults. Mirrors the slice of pi’sSettingsinterface (packages/coding-agent/src/core/settings-manager.ts) that rpi honors:defaultProvider/defaultModel/defaultThinkingLevel(consumed byprovider::resolveas pi’sfindInitialModelstep 3 — the saved default, when authed, wins over the built-in fallback),theme, packages, and configurable resource directories.- source_
info - Resource provenance metadata.
- timings
- Central timing instrumentation for startup profiling.
- transcript_
view - Transport-agnostic transcript rendering.
- trust
- Trust management for project resources.
- tui_
shell - Driver-generic TUI shell.
- updates
- Lightweight update discovery and update commands.
Constants§
- APP_
NAME - The application name used in help + version output. Mirrors TS
APP_NAME(the TS bin is"pi"; the Rust crate publishes under therpi-namespace, so the binary + displayed name is"rpi"to match). - VERSION
- Crate version, surfaced by
rpi --version. Mirrors the TSVERSIONexport (sourced frompackage.json; here fromenv!("CARGO_PKG_VERSION")).