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"];
}

Crate Overviewยถ

Crate Summaryยถ

Crate

Description

Key Types

perspt-cli API

CLI entry point with 10 subcommands

Commands, Cli

perspt-core API

LLM provider, config, memory

GenAIProvider, Config

perspt-agent API

SRBN engine for autonomous coding

SRBNOrchestrator, TaskPlan, Energy

perspt-tui API

Terminal UI components

AgentApp, Dashboard, DiffViewer

perspt-policy API

Security policy engine

PolicyEngine, Sanitizer

perspt-sandbox API

Process isolation

SandboxedCommand

perspt-store API

DuckDB session persistence

SessionStore, LlmRequestRecord

Architecture Quick Referenceยถ

๐Ÿ–ฅ๏ธ perspt-cli

10 Subcommands: chat, agent, init, config, ledger, status, abort, resume, logs, simple-chat

perspt-cli API
๐Ÿ”Œ perspt-core

Thread-safe LLM: GenAIProvider with Arc<RwLock>

perspt-core API
๐Ÿค– perspt-agent

SRBN Engine: Orchestrator, LSP, Tools, Ledger

perspt-agent API
๐ŸŽจ perspt-tui

Ratatui UI: Dashboard, DiffViewer, ReviewModal

perspt-tui API
๐Ÿ›ก๏ธ perspt-policy

Security: Starlark rules, command sanitization

perspt-policy API
๐Ÿ“ฆ perspt-sandbox

Isolation: Resource limits, process control

perspt-sandbox API
๐Ÿ’พ perspt-store

Persistence: DuckDB sessions, LLM logging

perspt-store API

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ยถ