vex/
main.rs

1//! VEX CLI - Command-line interface for verified AI agent tooling
2//!
3//! # Usage
4//!
5//! ```bash
6//! # Verify an audit chain
7//! vex verify --audit session.json
8//!
9//! # List available tools
10//! vex tools list
11//!
12//! # Run a tool directly
13//! vex tools run calculator '{"expression": "2+2"}'
14//!
15//! # Show version and configuration
16//! vex info
17//! ```
18
19use anyhow::Result;
20use clap::{Parser, Subcommand};
21use colored::Colorize;
22
23mod commands;
24
25use commands::{info, tools, verify};
26
27/// VEX - Verified Evolutionary Xenogenesis
28///
29/// Command-line interface for provable AI agent tooling.
30/// Every action is cryptographically verified.
31#[derive(Parser)]
32#[command(
33    name = "vex",
34    version,
35    about = "VEX CLI - Verified AI Agent Tooling",
36    long_about = "VEX provides cryptographically-verified AI agent tools.\n\n\
37                  Every tool execution is hashed into a Merkle chain,\n\
38                  enabling tamper-proof audit trails and verification."
39)]
40struct Cli {
41    /// Increase verbosity (-v, -vv, -vvv)
42    #[arg(short, long, action = clap::ArgAction::Count, global = true)]
43    verbose: u8,
44
45    #[command(subcommand)]
46    command: Commands,
47}
48
49#[derive(Subcommand)]
50enum Commands {
51    /// Verify audit chain integrity
52    #[command(name = "verify")]
53    Verify(verify::VerifyArgs),
54
55    /// Tool management and execution
56    #[command(name = "tools")]
57    Tools(tools::ToolsArgs),
58
59    /// Show system information
60    #[command(name = "info")]
61    Info(info::InfoArgs),
62}
63
64#[tokio::main]
65async fn main() -> Result<()> {
66    let cli = Cli::parse();
67
68    // Setup tracing based on verbosity
69    setup_logging(cli.verbose);
70
71    // Execute command
72    match cli.command {
73        Commands::Verify(args) => verify::run(args).await,
74        Commands::Tools(args) => tools::run(args).await,
75        Commands::Info(args) => info::run(args),
76    }
77}
78
79/// Setup logging based on verbosity level
80fn setup_logging(verbosity: u8) {
81    use tracing_subscriber::EnvFilter;
82
83    let filter = match verbosity {
84        0 => "warn",
85        1 => "info",
86        2 => "debug",
87        _ => "trace",
88    };
89
90    tracing_subscriber::fmt()
91        .with_env_filter(
92            EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(filter)),
93        )
94        .init();
95}
96
97/// Print a success message with a checkmark
98#[allow(dead_code)]
99pub fn print_success(msg: &str) {
100    println!("{} {}", "✓".green().bold(), msg);
101}
102
103/// Print an error message with an X
104#[allow(dead_code)]
105pub fn print_error(msg: &str) {
106    eprintln!("{} {}", "✗".red().bold(), msg);
107}
108
109/// Print a warning message
110#[allow(dead_code)]
111pub fn print_warning(msg: &str) {
112    println!("{} {}", "⚠".yellow().bold(), msg);
113}
114
115/// Print an info message
116#[allow(dead_code)]
117pub fn print_info(msg: &str) {
118    println!("{} {}", "ℹ".blue().bold(), msg);
119}