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

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 clap

  • commands/ β€” Subcommand implementations

Subcommands:

Command

Function

chat

Launch interactive TUI

agent

Run SRBN orchestrator

init

Initialize project config

config

Manage configuration

ledger

Query Merkle ledger

status

Show agent status

abort

Cancel current session

resume

Resume interrupted session

logs

View LLM request/response logs

simple-chat

Simple CLI chat (no TUI)

perspt-coreΒΆ

Purpose: Core abstractions for LLM interaction

Location: crates/perspt-core/

Key Components:

  • config.rs β€” Simple Config struct

  • llm_provider.rs β€” Thread-safe GenAIProvider

  • memory.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

orchestrator.rs

34KB

SRBN control loop, model tiers

lsp.rs

28KB

LSP client for Python (ty)

tools.rs

12KB

Agent tools (read, write, search, shell)

types.rs

24KB

TaskPlan, Node, Energy types

ledger.rs

6KB

Merkle change tracking

test_runner.rs

15KB

pytest integration

context_retriever.rs

10KB

Code context extraction

perspt-tuiΒΆ

Purpose: Terminal UI components

Location: crates/perspt-tui/

Key Components:

  • agent_app.rs β€” Main agent TUI

  • dashboard.rs β€” Status metrics

  • diff_viewer.rs β€” File diff display

  • review_modal.rs β€” Change approval

  • task_tree.rs β€” Task hierarchy

perspt-policyΒΆ

Purpose: Security policy enforcement

Location: crates/perspt-policy/

Key Components:

  • engine.rs β€” Starlark policy evaluator

  • sanitize.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 operations

  • schema.rs β€” Database schema initialization

Key Types:

Type

Description

SessionRecord

Session metadata (id, task, status, timestamps)

LlmRequestRecord

LLM request/response with latency and tokens

EnergyRecord

Energy history for stability tracking

NodeStateRecord

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ΒΆ

  1. Create directory: crates/perspt-newcrate/

  2. Add Cargo.toml with package metadata

  3. Register in root Cargo.toml:

    [workspace]
    members = [
        "crates/perspt-core",
        "crates/perspt-newcrate",  # Add here
        # ...
    ]
    
  4. Add dependencies to consuming crates

See AlsoΒΆ