API Referenceยถ
Complete API documentation for Persptโs 7-crate workspace architecture.
![digraph crates {
rankdir=LR;
node [shape=box, style="rounded,filled", fontname="Helvetica", fontsize=10];
cli [label="perspt-cli", fillcolor="#4ECDC4", href="perspt-cli.html"];
core [label="perspt-core", fillcolor="#45B7D1", href="perspt-core.html"];
tui [label="perspt-tui", fillcolor="#96CEB4", href="perspt-tui.html"];
agent [label="perspt-agent", fillcolor="#FFEAA7", href="perspt-agent.html"];
policy [label="perspt-policy", fillcolor="#DDA0DD", href="perspt-policy.html"];
sandbox [label="perspt-sandbox", fillcolor="#F8B739", href="perspt-sandbox.html"];
store [label="perspt-store", fillcolor="#87CEEB", href="perspt-store.html"];
}](../_images/graphviz-60fc6b291d20b1fc26dadb93e6fc8ff089c01a5b.png)
Crate Overviewยถ
Crate APIs
Crate Summaryยถ
Crate |
Description |
Key Types |
|---|---|---|
CLI entry point with 10 subcommands |
|
|
LLM provider, config, memory |
|
|
SRBN engine for autonomous coding |
|
|
Terminal UI components |
|
|
Security policy engine |
|
|
Process isolation |
|
|
DuckDB session persistence |
|
Architecture Quick Referenceยถ
10 Subcommands: chat, agent, init, config, ledger, status, abort, resume, logs, simple-chat
Thread-safe LLM: GenAIProvider with Arc<RwLock>
SRBN Engine: Orchestrator, LSP, Tools, Ledger
Ratatui UI: Dashboard, DiffViewer, ReviewModal
Security: Starlark rules, command sanitization
Isolation: Resource limits, process control
Persistence: DuckDB sessions, LLM logging
Common Patternsยถ
Error Handlingยถ
All crates use anyhow::Result for error propagation:
use anyhow::{Context, Result};
fn example() -> Result<()> {
do_something()
.context("Failed to do something")?;
Ok(())
}
Async Operationsยถ
Built on Tokio async runtime:
use tokio::sync::mpsc;
async fn stream_response(sender: mpsc::Sender<String>) -> Result<()> {
// Stream tokens as they arrive
}
Thread-Safe Sharingยถ
Use Arc for sharing across tasks:
use std::sync::Arc;
let provider = Arc::new(GenAIProvider::new()?);
let provider_clone = Arc::clone(&provider);
tokio::spawn(async move {
provider_clone.generate_response(...).await
});
See Alsoยถ
Architecture - Workspace architecture overview
Contributing - How to contribute
Testing - Testing guide