Skip to main content

Crate pi

Crate pi 

Source
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 Buffer shim — 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 crypto shim — 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 http and https shim — 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.