Workspace CratesΒΆ
Perspt is organized as a 7-crate Cargo workspace for modularity and maintainability.
Crate OverviewΒΆ
![digraph workspace {
rankdir=TB;
node [shape=box, style="rounded,filled", fontname="Helvetica", fontsize=10];
edge [color="#666666"];
cli [label="perspt-cli\nβββββββββ\nCLI Entry Point\n10 Subcommands", fillcolor="#4ECDC4"];
core [label="perspt-core\nβββββββββ\nGenAIProvider\nConfig, Memory", fillcolor="#45B7D1"];
tui [label="perspt-tui\nβββββββββ\nAgentApp\nDashboard", fillcolor="#96CEB4"];
agent [label="perspt-agent\nβββββββββ\nOrchestrator\nLSP, Tools", fillcolor="#FFEAA7"];
policy [label="perspt-policy\nβββββββββ\nPolicyEngine\nSanitizer", fillcolor="#DDA0DD"];
sandbox [label="perspt-sandbox\nβββββββββ\nSandboxedCommand", fillcolor="#F8B739"];
store [label="perspt-store\nβββββββββ\nSession Persistence\nLLM Logging", fillcolor="#FFD700"];
cli -> core;
cli -> tui;
cli -> agent;
cli -> store;
agent -> core;
agent -> policy;
agent -> sandbox;
agent -> store;
}](../_images/graphviz-a9caf6e3b5d2316149945dee9b0a8b59828e025b.png)
Crate Dependency GraphΒΆ
Crate DetailsΒΆ
perspt-cliΒΆ
Purpose: Command-line interface entry point
Location: crates/perspt-cli/
Key Components:
main.rsβ CLI argument parsing with clapcommands/β Subcommand implementations
Subcommands:
Command |
Function |
|---|---|
|
Launch interactive TUI |
|
Run SRBN orchestrator |
|
Initialize project config |
|
Manage configuration |
|
Query Merkle ledger |
|
Show agent status |
|
Cancel current session |
|
Resume interrupted session |
|
View LLM request/response logs |
|
Simple CLI chat (no TUI) |
perspt-coreΒΆ
Purpose: Core abstractions for LLM interaction
Location: crates/perspt-core/
Key Components:
config.rsβ Simple Config structllm_provider.rsβ Thread-safe GenAIProvidermemory.rsβ Conversation memory
Thread Safety: GenAIProvider uses Arc<RwLock<SharedState>> for concurrent access.
perspt-agentΒΆ
Purpose: SRBN autonomous coding engine
Location: crates/perspt-agent/
Key Components:
Module |
Size |
Description |
|---|---|---|
|
34KB |
SRBN control loop, model tiers |
|
28KB |
LSP client for Python ( |
|
12KB |
Agent tools (read, write, search, shell) |
|
24KB |
TaskPlan, Node, Energy types |
|
6KB |
Merkle change tracking |
|
15KB |
pytest integration |
|
10KB |
Code context extraction |
perspt-tuiΒΆ
Purpose: Terminal UI components
Location: crates/perspt-tui/
Key Components:
agent_app.rsβ Main agent TUIdashboard.rsβ Status metricsdiff_viewer.rsβ File diff displayreview_modal.rsβ Change approvaltask_tree.rsβ Task hierarchy
perspt-policyΒΆ
Purpose: Security policy enforcement
Location: crates/perspt-policy/
Key Components:
engine.rsβ Starlark policy evaluatorsanitize.rsβ Command sanitization
perspt-sandboxΒΆ
Purpose: Process isolation
Location: crates/perspt-sandbox/
Key Component: command.rs β Sandboxed command execution with resource limits
perspt-storeΒΆ
Purpose: DuckDB-based session persistence and LLM logging
Location: crates/perspt-store/
Key Components:
store.rsβ SessionStore with CRUD operationsschema.rsβ Database schema initialization
Key Types:
Type |
Description |
|---|---|
|
Session metadata (id, task, status, timestamps) |
|
LLM request/response with latency and tokens |
|
Energy history for stability tracking |
|
SRBN node state snapshots |
Building Individual CratesΒΆ
# Build specific crate
cargo build -p perspt-cli
cargo build -p perspt-agent
# Run tests for crate
cargo test -p perspt-core
# Generate docs for crate
cargo doc -p perspt-agent --open
Adding a New CrateΒΆ
Create directory:
crates/perspt-newcrate/Add
Cargo.tomlwith package metadataRegister in root
Cargo.toml:[workspace] members = [ "crates/perspt-core", "crates/perspt-newcrate", # Add here # ... ]
Add dependencies to consuming crates
See AlsoΒΆ
Architecture - Architecture overview
Extending Perspt - Extension guide
API Reference - Per-crate API reference