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