The Perspt Book 0.6.7
On this page

Example: Rust CLI Tool

Build a Rust command-line tool using Perspt’s agent mode.

Task Description

We will ask the agent to create a CLI tool that converts CSV files to JSON.

Running the Agent

Initialize a Cargo project first so the rust plugin and offline verifier sensors have a manifest to inspect:

export GEMINI_API_KEY="your-key"
cargo init /tmp/csv2json

perspt agent --yes --allow-dependency-mutation -w /tmp/csv2json \
  --actuator-model gemini::gemini-3.1-pro \
  --explorer-model gemini::gemini-3.5-flash \
  "Create a Rust CLI tool called csv2json that:
   1. Reads a CSV file from a path argument
   2. Converts each row to a JSON object
   3. Outputs JSON array to stdout or a file (--output flag)
   4. Handles errors gracefully with anyhow
   5. Uses clap for argument parsing
   6. Includes unit tests and integration tests"

Example output layout

/tmp/csv2json/
+-- Cargo.toml
+-- src/
|   +-- main.rs        # Entry point, clap args
|   +-- lib.rs          # Core conversion logic
|   +-- converter.rs    # CSV -> JSON conversion
+-- tests/
    +-- integration.rs  # Integration tests

Verification

The agent uses the rust plugin’s verifier profile inside the sandboxed verifier:

  • Syntax & Build (V_syn): cargo check --message-format=json and cargo build --message-format=json
  • Tests (V_log): cargo test
  • Lint (advisory): cargo clippy -- -D warnings (steers repairs without blocking a hard pass)
  • Sensor readiness (V_boot): tracks whether required toolchain sensors were available and runnable
cd /tmp/csv2json
cargo test
cargo run -- --help

Key Observations

  • The rust plugin runs cargo check, cargo build, and cargo test as required hard-gate stages against the candidate overlay
  • --allow-dependency-mutation permits governed cargo add calls when the task needs crates such as clap or anyhow
  • cargo test runs both unit and integration tests (V_log)
  • The dispatcher prevents nodes with conflicting write footprints from running concurrently

See Also