mesh_llm_cli/models.rs
1use clap::{Subcommand, ValueEnum};
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
4pub enum ModelSearchSort {
5 Trending,
6 Downloads,
7 Likes,
8 Created,
9 Updated,
10 #[value(name = "parameters-desc", alias = "most-parameters")]
11 ParametersDesc,
12 #[value(name = "parameters-asc", alias = "least-parameters")]
13 ParametersAsc,
14}
15
16#[derive(Subcommand, Debug)]
17// CLI enums mirror clap's argument shape; boxing these fields would make the parser harder to maintain.
18#[allow(clippy::large_enum_variant)]
19pub enum ModelsCommand {
20 /// Package a GGUF model for distributed inference by splitting it into layer files on Hugging Face Jobs.
21 Package {
22 /// Source Hugging Face model ref (e.g. unsloth/Qwen3-235B-A22B-GGUF:UD-Q4_K_XL).
23 source_repo: Option<String>,
24 /// Quantization variant (deprecated; prefer source refs like repo:Q4_K_M).
25 #[arg(long)]
26 quant: Option<String>,
27 /// Target repo for the layer package (auto-derived if omitted).
28 #[arg(long)]
29 target: Option<String>,
30 /// Override model ID in the manifest.
31 #[arg(long)]
32 model_id: Option<String>,
33 /// HF Job hardware flavor. Use auto for the default CPU splitter baseline.
34 #[arg(long, default_value = "auto")]
35 flavor: String,
36 /// Requested job timeout; raised automatically by model-size minimums.
37 #[arg(long, default_value = "1h")]
38 timeout: String,
39 /// Branch or tag of mesh-llm to build in the job.
40 #[arg(long, default_value = "main")]
41 mesh_llm_ref: String,
42 /// Publish a public package marked experimental and open an unmerged HF catalog PR.
43 #[arg(long)]
44 experimental: bool,
45 /// Explicitly keep this as a dry run. This is the default unless --confirm is set.
46 #[arg(long)]
47 dry_run: bool,
48 /// Actually submit the HF Job. Without this, the command only prints plan, spec, and max cost.
49 #[arg(long)]
50 confirm: bool,
51 /// Stream job logs after submission until completion.
52 #[arg(long)]
53 follow: bool,
54 /// Check status of a previously submitted job.
55 #[arg(long)]
56 status: Option<String>,
57 /// Fetch logs for a previously submitted job.
58 #[arg(long)]
59 logs: Option<String>,
60 /// Cancel a running job.
61 #[arg(long)]
62 cancel: Option<String>,
63 /// List recent package jobs.
64 #[arg(long)]
65 list: bool,
66 /// Upload the latest job script to the meshllm bucket (requires org access).
67 #[arg(long)]
68 update_script: bool,
69 /// Emit JSON output.
70 #[arg(long)]
71 json: bool,
72 },
73 /// List recommended models from the remote meshllm/catalog.
74 Recommended {
75 /// Emit JSON output.
76 #[arg(long)]
77 json: bool,
78 },
79 /// List installed local models from the HF cache.
80 Installed {
81 /// Emit JSON output.
82 #[arg(long)]
83 json: bool,
84 },
85 /// Preview or remove mesh-managed models from the Hugging Face cache.
86 Cleanup {
87 /// Only include models that mesh-llm has not used for the given age (for example 30d or 12h).
88 #[arg(long)]
89 unused_since: Option<String>,
90 /// Remove the selected files instead of printing a dry run preview.
91 #[arg(long)]
92 yes: bool,
93 /// Emit JSON output.
94 #[arg(long)]
95 json: bool,
96 },
97 /// Remove stale derived skippy stage artifacts from the mesh cache.
98 Prune {
99 /// Remove files instead of printing a dry run note.
100 #[arg(long)]
101 yes: bool,
102 /// Emit JSON output.
103 #[arg(long)]
104 json: bool,
105 },
106 /// Certify a Skippy layer package can be resolved, verified, and smoke-tested.
107 Certify {
108 /// Exact layer package ref, local package dir, or catalog model ref with a package mapping.
109 model: String,
110 /// Write the JSON certification report to this path.
111 #[arg(long)]
112 report_out: Option<std::path::PathBuf>,
113 /// Emit JSON output.
114 #[arg(long)]
115 json: bool,
116 /// Stop after package resolution, integrity checks, and local stage materialization.
117 #[arg(long)]
118 package_only: bool,
119 /// Existing mesh-llm OpenAI-compatible API base for runtime smoke gates.
120 #[arg(long)]
121 api_base: Option<String>,
122 /// Prompt for runtime smoke gates.
123 #[arg(long, default_value = "Say ok.")]
124 prompt: String,
125 /// Maximum tokens for runtime smoke gates.
126 #[arg(long, default_value_t = 2)]
127 max_tokens: u32,
128 },
129 // Delete variant defined with explicit clap args later in file (existing block).
130 /// List remote catalog models.
131 #[command(hide = true)]
132 List {
133 /// Emit JSON output.
134 #[arg(long)]
135 json: bool,
136 },
137 /// Search for catalog models and downloadable GGUF/MLX artifacts on Hugging Face.
138 Search {
139 /// Search terms.
140 #[arg(required = true)]
141 query: Vec<String>,
142 /// Filter search results to GGUF artifacts (default).
143 #[arg(long, conflicts_with = "mlx")]
144 gguf: bool,
145 /// Filter search results to MLX artifacts.
146 #[arg(long, conflicts_with = "gguf")]
147 mlx: bool,
148 /// Search only the remote meshllm/catalog.
149 #[arg(long)]
150 catalog: bool,
151 /// Maximum number of results to show.
152 #[arg(long, default_value = "20")]
153 limit: usize,
154 /// Sort search results.
155 #[arg(long, value_enum, default_value = "trending")]
156 sort: ModelSearchSort,
157 /// Emit JSON output.
158 #[arg(long)]
159 json: bool,
160 },
161 /// Show details for one exact model reference.
162 Show {
163 /// Exact remote catalog id or Hugging Face ref.
164 model: String,
165 /// Emit JSON output.
166 #[arg(long)]
167 json: bool,
168 },
169 /// Download one exact model reference.
170 Download {
171 /// Exact remote catalog id or Hugging Face ref.
172 model: String,
173 /// Also download the recommended draft model for speculative decoding.
174 #[arg(long)]
175 draft: bool,
176 /// Download the exact Hugging Face file directly, bypassing catalog layer-package resolution.
177 #[arg(long)]
178 direct: bool,
179 /// Emit JSON output.
180 #[arg(long)]
181 json: bool,
182 },
183 /// Check or refresh cached Hugging Face repos.
184 #[command(visible_alias = "update")]
185 Updates {
186 /// Repo id like Qwen/Qwen3-8B-GGUF.
187 repo: Option<String>,
188 /// Operate on every cached Hugging Face repo.
189 #[arg(long)]
190 all: bool,
191 /// Check for newer upstream revisions without refreshing local cache.
192 #[arg(long)]
193 check: bool,
194 /// Emit JSON output.
195 #[arg(long)]
196 json: bool,
197 },
198 /// Delete a specific model from local storage.
199 Delete {
200 /// Installed model stem or Hugging Face ref (e.g. `Qwen3.5-9B-BF16`, `org/repo`, or `org/repo:BF16`).
201 #[arg(required = true)]
202 model: String,
203 /// Skip dry-run preview and delete immediately.
204 #[arg(long)]
205 yes: bool,
206 /// Emit JSON output.
207 #[arg(long)]
208 json: bool,
209 },
210}