Skip to main content

apr_cli/
tool_commands.rs

1
2#[derive(Subcommand, Debug)]
3pub enum ToolCommands {
4    /// Qwen2.5-Coder showcase demo
5    Showcase {
6        /// Run all steps with auto-verification
7        #[arg(long)]
8        auto_verify: bool,
9        /// Run specific step
10        #[arg(long)]
11        step: Option<String>,
12        /// Model tier: tiny (0.5B), small (1.5B), medium (7B), large (32B)
13        #[arg(long, default_value = "small")]
14        tier: String,
15        /// Model directory
16        #[arg(long, default_value = "./models")]
17        model_dir: PathBuf,
18        /// Baselines to compare: llama-cpp,ollama
19        #[arg(long, default_value = "llama-cpp,ollama")]
20        baseline: String,
21        /// Enable ZRAM compression
22        #[arg(long)]
23        zram: bool,
24        /// Number of benchmark runs (spec: minimum 30)
25        #[arg(long, default_value = "30")]
26        runs: usize,
27        /// Force GPU acceleration
28        #[arg(long)]
29        gpu: bool,
30        /// Output results as JSON
31        #[arg(long)]
32        json: bool,
33        /// Verbose output
34        #[arg(short, long)]
35        verbose: bool,
36        /// Quiet mode (errors only)
37        #[arg(short, long)]
38        quiet: bool,
39    },
40    /// Rosetta Stone - Universal model format converter (PMAT-ROSETTA-001)
41    Rosetta {
42        #[command(subcommand)]
43        action: RosettaCommands,
44    },
45    /// Publish model to HuggingFace Hub (APR-PUB-001)
46    Publish {
47        /// Directory containing model files to publish
48        #[arg(value_name = "DIRECTORY")]
49        directory: PathBuf,
50        /// HuggingFace repository ID (e.g., paiml/whisper-apr-tiny)
51        #[arg(value_name = "REPO_ID")]
52        repo_id: String,
53        /// Model display name
54        #[arg(long)]
55        model_name: Option<String>,
56        /// License (SPDX identifier, default: mit)
57        #[arg(long, default_value = "mit")]
58        license: String,
59        /// Pipeline tag (e.g., automatic-speech-recognition, text-generation)
60        #[arg(long, default_value = "text-generation")]
61        pipeline_tag: String,
62        /// Library name (e.g., whisper-apr, aprender)
63        #[arg(long)]
64        library_name: Option<String>,
65        /// Additional tags (comma-separated)
66        #[arg(long, value_delimiter = ',')]
67        tags: Option<Vec<String>>,
68        /// Commit message
69        #[arg(long)]
70        message: Option<String>,
71        /// Dry run (preview without uploading)
72        #[arg(long)]
73        dry_run: bool,
74        /// Plan mode (alias for --dry-run)
75        #[arg(long)]
76        plan: bool,
77    },
78    /// Model Oracle: identify family, size, constraints, and contract compliance
79    ///
80    /// Three modes:
81    ///   apr oracle <FILE>         - Analyze local model file
82    ///   apr oracle hf://org/repo  - Query HuggingFace API
83    ///   apr oracle --family qwen2 - Describe contract from YAML
84    Oracle {
85        /// Model file path or hf:// URI
86        #[arg(value_name = "SOURCE")]
87        source: Option<String>,
88        /// Show contract for a model family (e.g., qwen2, llama, whisper, bert)
89        #[arg(long)]
90        family: Option<String>,
91        /// Filter to a specific size variant (e.g., 0.5b, 7b)
92        #[arg(long)]
93        size: Option<String>,
94        /// Run full contract compliance check
95        #[arg(long)]
96        compliance: bool,
97        /// List all tensor shapes
98        #[arg(long)]
99        tensors: bool,
100        /// Show statistical analysis (GQA, memory, FFN, FLOPS)
101        #[arg(long)]
102        stats: bool,
103        /// Show architecture explanations with literature references
104        #[arg(long)]
105        explain: bool,
106        /// Show kernel compatibility report (quantization, TPS estimates)
107        #[arg(long)]
108        kernels: bool,
109        /// Cross-validate contract against HuggingFace config.json
110        #[arg(long)]
111        validate: bool,
112        /// Enable all analysis sections (stats + explain + kernels + validate)
113        #[arg(long)]
114        full: bool,
115    },
116
117    /// Encrypt model weights at rest using BLAKE3-derived keystream + MAC.
118    ///
119    /// Produces an encrypted `.enc` file with integrity verification.
120    /// Key derivation uses BLAKE3 derive_key from a passphrase or key file.
121    Encrypt {
122        /// Path to model file (safetensors, GGUF, etc.)
123        #[arg(value_name = "FILE")]
124        file: PathBuf,
125
126        /// Output path for encrypted file
127        #[arg(short, long, value_name = "FILE")]
128        output: PathBuf,
129
130        /// Encryption key file (32 bytes). If omitted, reads passphrase from stdin.
131        #[arg(long, value_name = "FILE")]
132        key_file: Option<PathBuf>,
133    },
134
135    /// Decrypt model weights encrypted with `apr encrypt`.
136    Decrypt {
137        /// Path to encrypted `.enc` file
138        #[arg(value_name = "FILE")]
139        file: PathBuf,
140
141        /// Output path for decrypted model
142        #[arg(short, long, value_name = "FILE")]
143        output: PathBuf,
144
145        /// Decryption key file (32 bytes). If omitted, reads passphrase from stdin.
146        #[arg(long, value_name = "FILE")]
147        key_file: Option<PathBuf>,
148    },
149}