Expand description
Pi - High-performance AI coding agent CLI
This library provides the core functionality for the Pi CLI tool, a Rust port of pi-mono (TypeScript) with emphasis on:
- Performance: Sub-100ms startup, smooth TUI at 60fps
- Reliability: No panics in normal operation
- Efficiency: Single binary, minimal dependencies
§Public API policy
The pi crate is primarily the implementation crate for the pi CLI binary.
External consumers should treat non-sdk modules/types as unstable
and subject to change. Use sdk as the stable library-facing surface.
Currently intended stable exports:
Re-exports§
pub use error::Error;pub use error::Result as PiResult;pub use extension_dispatcher::ExtensionDispatcher;
Modules§
- agent
- Agent runtime - the core orchestration loop.
- agent_
cx - Capability-scoped async context for Pi.
- app
- Helpers for
src/main.rs. - auth
- Authentication storage and API key resolution.
- autocomplete
- Autocomplete provider for interactive editor input.
- buffer_
shim - Node.js
Buffershim — pure-JS implementation for the QuickJS extension runtime. - cli
- CLI argument parsing using Clap.
- compaction
- Context compaction for long sessions.
- compaction_
worker - Background compaction worker with basic quota controls.
- config
- Configuration loading and management.
- conformance
- Conformance utilities for fixture- and diff-based validation.
- conformance_
shapes - Shape-aware conformance harness for extension types.
- connectors
- Connectors for extension hostcalls.
- crypto_
shim - Node.js
cryptoshim — Rust hostcalls for the QuickJS extension runtime. - doctor
- Comprehensive environment health checker for
pi doctor. - error
- Error types for the Pi application.
- error_
hints - Error hints: mapping from error variants to user-facing remediation suggestions.
- extension_
conformance_ matrix - Conformance test matrix for Pi extensions.
- extension_
dispatcher - Hostcall dispatcher for JS extensions.
- extension_
events - Typed extension event definitions + dispatch helper.
- extension_
inclusion - Final inclusion list generation for Pi extension candidates.
- extension_
index - Extension discovery index (offline-first).
- extension_
license - License detection and policy screening for Pi extension candidates.
- extension_
popularity - Popularity signal snapshotting for extension candidates.
- extension_
preflight - extension_
replay - Deterministic replay trace bundle core for extension runtime forensics.
- extension_
scoring - extension_
tools - Extension tools integration.
- extension_
validation - Deterministic classifier and deduplication engine for Pi extension candidates.
- extensions
- Extension protocol, policy, and runtime scaffolding.
- extensions_
js - QuickJS runtime bridge for JS-compatible extensions.
- flake_
classifier - hostcall_
amac - AMAC-style interleaved hostcall batch executor with stall-aware toggling.
- hostcall_
io_ uring_ lane - Deterministic io_uring lane policy for hostcall dispatch.
- hostcall_
queue - Hostcall queue primitives with explicit reclamation telemetry.
- hostcall_
rewrite - Constrained hostcall rewrite planner for hot-path marshalling.
- hostcall_
s3_ fifo - Deterministic S3-FIFO-inspired admission policy for hostcall queues.
- hostcall_
superinstructions - Superinstruction compiler for hot typed-hostcall opcode traces.
- hostcall_
trace_ jit - Tier-2 trace-JIT compiler for stabilized superinstruction plans.
- http
- http_
shim - Node.js
httpandhttpsshim — pure-JS implementation for the QuickJS extension runtime. - interactive
- Interactive TUI mode using charmed_rust (bubbletea/lipgloss/bubbles/glamour).
- keybindings
- Keybindings and action catalog for interactive mode.
- migrations
- Startup migrations for legacy Pi layouts and config formats.
- model
- Message types, content blocks, and streaming events.
- model_
selector - Model selector overlay state.
- models
- Model registry: built-in + models.json overrides.
- package_
manager - Package management: install/remove/update/list.
- perf_
build - Shared performance-build metadata helpers for benchmark tooling.
- permissions
- Persistent storage for extension capability decisions.
- pi_wasm
- PiWasm: WebAssembly polyfill for QuickJS runtime.
- provider
- LLM provider abstraction layer.
- provider_
metadata - Canonical provider metadata shared across runtime surfaces.
- providers
- Provider implementations.
- resources
- Resource loading for skills, prompt templates, themes, and extensions.
- rpc
- RPC mode: headless JSON protocol over stdin/stdout.
- scheduler
- Deterministic event loop scheduler for PiJS runtime.
- sdk
- Stable SDK-facing API surface for embedding Pi as a library.
- session
- Session management and persistence.
- session_
index - SQLite session index (derived from JSONL sessions).
- session_
metrics - Session hot-path observability.
- session_
picker - Session picker TUI for selecting from available sessions.
- session_
sqlite - session_
store_ v2 - Session Store V2 segmented append log + sidecar index primitives.
- sse
- Server-Sent Events (SSE) parser for asupersync HTTP client.
- terminal_
images - Terminal image helpers.
- theme
- JSON theme file format and loader.
- tools
- Built-in tool implementations.
- tui
- Terminal UI components using rich_rust.
- vcr
- VCR-style recording for HTTP streaming tests.
- version_
check - Background version check — queries GitHub releases for newer versions.