//! Arguments for `mcptest interop` (WOR-1431).

use std::path::PathBuf;

use clap::{Args, Subcommand, ValueEnum};

/// Bridge eval suites and datasets between mcptest and the wider ecosystem.
///
/// `import` converts a promptfoo, DeepEval, or mcp-eval artifact into a
/// runnable mcptest suite (warning about anything it could not carry).
/// `export` turns a mcptest suite into a neutral portable dataset stamped with
/// provenance. `dataset` builds a starter suite from a `tools/list` snapshot or
/// a registry export. Native mcptest YAML stays the canonical authoring surface.
#[derive(Debug, Args)]
pub struct InteropArgs {
    /// Which interop action to run.
    #[command(subcommand)]
    pub command: InteropCommand,
}

/// Subcommands under `mcptest interop`.
#[derive(Debug, Subcommand)]
pub enum InteropCommand {
    /// Convert a competitor suite into a mcptest suite.
    Import(InteropImportArgs),
    /// Export a mcptest suite into a portable dataset.
    Export(InteropExportArgs),
    /// Build a starter mcptest suite from an MCP-native surface.
    Dataset(InteropDatasetArgs),
}

/// Source ecosystems `interop import --from` understands.
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum InteropSource {
    /// A promptfoo `tests:` / `redteam:` config.
    Promptfoo,
    /// A DeepEval dataset of goldens / test cases.
    DeepEval,
    /// An mcp-eval task suite.
    McpEval,
}

/// Arguments for `mcptest interop import`.
#[derive(Debug, Args)]
pub struct InteropImportArgs {
    /// Source ecosystem to convert from.
    #[arg(long = "from", value_enum, value_name = "ECOSYSTEM")]
    pub from: InteropSource,

    /// The source artifact (JSON or YAML).
    #[arg(value_name = "FILE")]
    pub file: PathBuf,

    /// Server the imported agents target. Repeatable; declared with a
    /// placeholder command to edit. Defaults to a single `server`.
    #[arg(long = "server", value_name = "NAME")]
    pub servers: Vec<String>,

    /// Model the imported agents run.
    #[arg(long, value_name = "MODEL", default_value = "claude-sonnet-4-5")]
    pub model: String,

    /// Write the generated suite here instead of stdout.
    #[arg(long, value_name = "PATH")]
    pub out: Option<PathBuf>,

    /// Overwrite the output if it already exists (off by default so a re-run
    /// cannot silently clobber a tracked or hand-edited file).
    #[arg(long)]
    pub force: bool,
}

/// Arguments for `mcptest interop export`.
#[derive(Debug, Args)]
pub struct InteropExportArgs {
    /// The mcptest suite YAML to export.
    #[arg(value_name = "SUITE")]
    pub suite: PathBuf,

    /// Write the portable dataset here instead of stdout.
    #[arg(long, value_name = "PATH")]
    pub out: Option<PathBuf>,

    /// Overwrite the output if it already exists (off by default so a re-run
    /// cannot silently clobber a tracked or hand-edited file).
    #[arg(long)]
    pub force: bool,
}

/// Arguments for `mcptest interop dataset`.
#[derive(Debug, Args)]
pub struct InteropDatasetArgs {
    /// A `tools/list` snapshot (JSON) to turn into a starter suite.
    #[arg(long, value_name = "FILE")]
    pub tools_list: Option<PathBuf>,

    /// A registry export (JSON) to turn into a starter suite.
    #[arg(long, value_name = "FILE", conflicts_with = "tools_list")]
    pub registry: Option<PathBuf>,

    /// Server the starter agents target. Defaults to a single `server`.
    #[arg(long = "server", value_name = "NAME")]
    pub servers: Vec<String>,

    /// Model the starter agents run.
    #[arg(long, value_name = "MODEL", default_value = "claude-sonnet-4-5")]
    pub model: String,

    /// Write the generated suite here instead of stdout.
    #[arg(long, value_name = "PATH")]
    pub out: Option<PathBuf>,

    /// Overwrite the output if it already exists (off by default so a re-run
    /// cannot silently clobber a tracked or hand-edited file).
    #[arg(long)]
    pub force: bool,
}
