falsegreen 0.1.32

FalseGreen client — independent verification for coding agents
//! CLI argument definitions.

use clap::{Parser, Subcommand};
use std::path::PathBuf;

/// FalseGreen client — independent verification for coding agents.
#[derive(Parser, Debug)]
#[command(name = "falsegreen", version, about, long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Run the MCP server over STDIO (launched by Codex).
    Mcp,
    /// Log in to FalseGreen and store credentials.
    Login {
        /// Enrollment credential (if omitted, you will be prompted).
        #[arg(long)]
        token: Option<String>,
    },
    /// Log out and remove stored credentials.
    Logout,
    /// Show current authentication and configuration status.
    Status,
    /// Inspect and advance a controller-owned Terraform/IaC verification.
    Terraform {
        #[command(subcommand)]
        command: TerraformCommands,
    },
    /// Install FalseGreen into an agent's MCP configuration.
    Install {
        /// Which agent to install into.
        #[arg(value_enum)]
        agent: AgentTarget,
    },
}

#[derive(Subcommand, Debug)]
pub enum TerraformCommands {
    /// Show plan, authorization, and deployed-outcome state without mutation.
    Inspect {
        #[arg(long)]
        task_id: String,
        #[arg(long)]
        run_id: String,
        #[arg(long)]
        command_index: Option<u64>,
    },
    /// Emit the exact bounded payload required for enforced human signing.
    AuthorizationPayload {
        #[arg(long)]
        task_id: String,
        #[arg(long)]
        run_id: String,
        #[arg(long)]
        command_index: Option<u64>,
        #[arg(long)]
        valid_for_seconds: Option<u64>,
    },
    /// Explicitly authorize one use of the exact accepted plan.
    Authorize {
        #[arg(long)]
        task_id: String,
        #[arg(long)]
        run_id: String,
        #[arg(long)]
        actor: String,
        #[arg(long)]
        confirm: bool,
        #[arg(long)]
        command_index: Option<u64>,
        #[arg(long)]
        valid_for_seconds: Option<u64>,
        #[arg(long)]
        approval_file: Option<PathBuf>,
    },
    /// Consume a backend authorization and apply only its exact saved plan.
    Apply {
        #[arg(long)]
        task_id: String,
        #[arg(long)]
        run_id: String,
        #[arg(long)]
        authorization_id: String,
        #[arg(long)]
        command_index: Option<u64>,
    },
    /// Independently refresh and observe the already applied outcome.
    VerifyDeployed {
        #[arg(long)]
        task_id: String,
        #[arg(long)]
        run_id: String,
        #[arg(long)]
        command_index: Option<u64>,
    },
}

#[derive(clap::ValueEnum, Clone, Debug)]
pub enum AgentTarget {
    /// Codex CLI (~/.codex/config.toml, STDIO launch).
    Codex,
    /// GitHub Copilot in VS Code (.vscode/mcp.json, local STDIO).
    #[value(name = "github-copilot")]
    GithubCopilot,
    /// Claude Code (.mcp.json, local STDIO).
    #[value(name = "claude-code")]
    ClaudeCode,
    /// OpenCode (opencode.json, local STDIO).
    #[value(name = "opencode")]
    OpenCode,
    /// Cursor (.cursor/mcp.json, local STDIO).
    Cursor,
}