mecha10-cli 0.6.3

Mecha10 CLI tool
Documentation
//! `mecha10 model` command arguments.
//!
//! Unifies what used to be two separate CLI verbs (`LAB-1808` follow-up):
//! the plural `mecha10 models` (catalog-facing, `packages/mecha10-models::ModelService`,
//! the curated, unversioned, HuggingFace-backed public catalog) and the singular
//! `mecha10 model` (registry-facing, `packages/mecha10-api/src/models/registry`,
//! a private per-project model registry - a different system that just happens to
//! share the same on-disk `models/` directory and the same `model_name` config
//! field, disambiguated by `ObjectDetectorConfig::source`).
//!
//! Product decision: collapse both into one `mecha10 model <subcommand>` surface.
//! `models` (plural) no longer exists as a subcommand at all.

use clap::Subcommand;

/// AI model management operations - spans both the public catalog and the
/// private per-project model registry.
#[derive(Subcommand, Debug)]
pub enum ModelCommand {
    /// List all models in the catalog
    List {
        /// Show detailed information
        #[arg(short, long)]
        verbose: bool,

        /// Show only recommended models
        #[arg(short, long)]
        recommended: bool,
    },

    /// Download a model from the catalog
    Pull {
        /// Model name from catalog (e.g., "yolov8n")
        name: Option<String>,

        /// Download every catalog model referenced by the current project's node configs
        /// (scans `configs/nodes/*/config.json` for `model.name`/`model.source`, `LAB-2043`).
        /// Requires running inside a mecha10 project. To download the entire curated catalog
        /// regardless of what the project references, use `--full-catalog` instead.
        #[arg(long, conflicts_with = "full_catalog")]
        all: bool,

        /// Download every model in the curated catalog (`model_catalog.toml`), regardless of
        /// whether the current project's node configs reference it. This is the pre-`LAB-2043`
        /// behavior of `--all`; kept as its own explicit flag since downloading the whole catalog
        /// is rarely what a single project actually needs.
        #[arg(long, conflicts_with = "all")]
        full_catalog: bool,

        /// Custom HuggingFace repository (e.g., "Xenova/yolov8n")
        #[arg(long, requires = "file")]
        repo: Option<String>,

        /// File name within the repo (e.g., "onnx/model.onnx")
        #[arg(long, requires = "repo")]
        file: Option<String>,

        /// Custom model name for saving (required with --repo)
        #[arg(long, requires = "repo")]
        custom_name: Option<String>,
    },

    /// List installed models
    Installed {
        /// Show detailed information including paths
        #[arg(short, long)]
        verbose: bool,
    },

    /// Remove an installed model
    Remove {
        /// Model name to remove
        name: String,

        /// Skip confirmation prompt
        #[arg(short = 'y', long)]
        yes: bool,
    },

    /// Show information about a model
    Info {
        /// Model name
        name: String,

        /// Registry version to show (`LAB-1808`). Only meaningful for a
        /// Registry-origin model - the public catalog is versionless/always
        /// "latest", so this is ignored for a Catalog model. Omit to show the
        /// newest installed version.
        #[arg(long)]
        version: Option<i32>,
    },

    /// Resolve a registry model version, download its artifact into the
    /// project's local `models/` directory, and switch a node's config to use it.
    Set {
        /// Node name whose config should be updated (e.g. "object-detector")
        node: String,

        /// Registry model name to resolve
        #[arg(long)]
        model: String,

        /// Version number to resolve. Omit to resolve the latest version.
        #[arg(long)]
        version: Option<i32>,
    },
}