lobe-cli 0.1.4

Lobe — local-first HTTP performance profiling CLI for developers. Spins up a capture proxy, records DNS/TCP/TLS/TTFB/download phases per request, and flags anomalies against grounded network baselines.
use std::path::PathBuf;

use clap::{Parser, Subcommand};

#[derive(Debug, Parser)]
#[command(name = "lobe", version, about = "Lobe — local HTTP performance observer")]
pub struct Cli {
    #[arg(long, global = true)]
    pub db: Option<PathBuf>,
    #[command(subcommand)]
    pub command: Command,
}

#[derive(Debug, Subcommand)]
pub enum Command {
    Probe {
        url: String,
        /// Hold N requests in flight to measure latency under contention.
        /// Pass a list for a sweep, e.g. `--concurrency 1,5,10,25,50`.
        /// Without this flag, probe fires a single request as before.
        #[arg(long, value_delimiter = ',', value_name = "N[,N...]")]
        concurrency: Vec<usize>,
        /// Total requests per concurrency level (raised to the level itself
        /// if smaller, so the target concurrency is actually reached).
        #[arg(long, default_value_t = 200, value_name = "N")]
        requests: usize,
        /// HTTP method for the burst. Only GET/HEAD are allowed unless
        /// --allow-unsafe is set. Requires --concurrency.
        #[arg(long, default_value = "GET")]
        method: String,
        /// Allow flooding a mutating endpoint (POST/PUT/PATCH/DELETE).
        /// A burst of concurrent calls executes real mutations N times.
        #[arg(long)]
        allow_unsafe: bool,
    },
    History {
        target: Option<String>,
        #[arg(short, long, default_value_t = 10)]
        limit: usize,
    },
    Compare {
        url: String,
        #[arg(long, default_value_t = 40.0)]
        threshold: f64,
    },
    Watch {
        url: String,
        #[arg(short, long, default_value_t = 5)]
        interval: u64,
        #[arg(long, default_value_t = 40.0)]
        threshold: f64,
        #[arg(long)]
        count: Option<usize>,
        #[arg(long)]
        tui: bool,
    },
    Capture {
        upstream: String,
        #[arg(long, default_value = "127.0.0.1:7878")]
        listen: String,
        /// Auto-upload the session to your Lobe cloud on export.
        /// Requires `lobe login` first.
        #[arg(long)]
        upload: bool,
        /// GitHub PR number this capture belongs to. When set, the PR bot
        /// picks up the session and grades it against the baseline.
        #[arg(long, value_name = "N")]
        pr: Option<u32>,
        /// Full repo identifier ("owner/repo"). Auto-detected from
        /// `GITHUB_REPOSITORY` when running in GitHub Actions.
        #[arg(long, value_name = "OWNER/REPO", env = "GITHUB_REPOSITORY")]
        repo: Option<String>,
        /// Branch under test. Auto-detected from `GITHUB_HEAD_REF` (PR) or
        /// `GITHUB_REF_NAME` (push).
        #[arg(long, value_name = "NAME", env = "GITHUB_HEAD_REF")]
        branch: Option<String>,
        /// Full git SHA of the commit under test. Auto-detected from
        /// `GITHUB_SHA`.
        #[arg(long, value_name = "SHA", env = "GITHUB_SHA")]
        commit: Option<String>,
        /// GitHub Actions run ID for linking back from PR comments.
        #[arg(long, value_name = "ID", env = "GITHUB_RUN_ID")]
        ci_run_id: Option<String>,
    },
    /// Authorize this machine to sync sessions to your Lobe cloud.
    Login {
        /// Provide the token non-interactively (e.g. from CI).
        #[arg(long)]
        token: Option<String>,
        /// Override the web URL used in the auth prompt.
        /// Defaults to https://getlobe.dev.
        #[arg(long)]
        web_url: Option<String>,
        /// Override the Convex API URL used for token verification and
        /// uploads. Defaults to the shipped production URL.
        #[arg(long)]
        api_url: Option<String>,
    },
    Explain {
        /// Path to a session JSON file produced by `lobe capture` (press `e`).
        session: PathBuf,
        /// Model to use. Defaults to Haiku 4.5 for cost. Use `--model sonnet` for a deeper pass.
        #[arg(long, default_value = "haiku")]
        model: String,
        /// Write the markdown report to a file instead of stdout.
        #[arg(short, long)]
        output: Option<PathBuf>,
    },
    /// Install the lobe-diagnose skill into your AI editor of choice.
    InstallSkill {
        /// Target editor: `claude-code` or `cursor`.
        target: String,
        /// Install to your home dir (~/.claude or ~/.cursor) instead of the current project.
        #[arg(long)]
        global: bool,
        /// Overwrite an existing skill file if present.
        #[arg(long)]
        force: bool,
    },
}