1pub mod auth;
4pub mod config;
5pub mod run;
6
7use clap::{Parser, Subcommand};
8use std::path::PathBuf;
9
10#[derive(Parser, Debug)]
15#[command(name = "codetether")]
16#[command(version, about, long_about = None)]
17pub struct Cli {
18 #[arg(global = true)]
20 pub project: Option<PathBuf>,
21
22 #[arg(long, global = true)]
24 pub print_logs: bool,
25
26 #[arg(long, global = true, value_parser = ["DEBUG", "INFO", "WARN", "ERROR"])]
28 pub log_level: Option<String>,
29
30 #[arg(short, long, env = "CODETETHER_SERVER")]
33 pub server: Option<String>,
34
35 #[arg(short, long, env = "CODETETHER_TOKEN")]
37 pub token: Option<String>,
38
39 #[arg(short, long, env = "CODETETHER_WORKER_NAME")]
41 pub name: Option<String>,
42
43 #[command(subcommand)]
44 pub command: Option<Command>,
45}
46
47#[derive(Subcommand, Debug)]
48pub enum Command {
49 Tui(TuiArgs),
51
52 Serve(ServeArgs),
54
55 Run(RunArgs),
57
58 Auth(AuthArgs),
60
61 Config(ConfigArgs),
63
64 Worker(A2aArgs),
66
67 Swarm(SwarmArgs),
69
70 Rlm(RlmArgs),
72
73 Ralph(RalphArgs),
75
76 Mcp(McpArgs),
78
79 Stats(StatsArgs),
81
82 Cleanup(CleanupArgs),
84
85 Models(ModelsArgs),
87
88 Benchmark(BenchmarkArgs),
90
91 Moltbook(MoltbookArgs),
93}
94
95#[derive(Parser, Debug)]
96pub struct AuthArgs {
97 #[command(subcommand)]
98 pub command: AuthCommand,
99}
100
101#[derive(Subcommand, Debug)]
102pub enum AuthCommand {
103 Copilot(CopilotAuthArgs),
105
106 Login(LoginAuthArgs),
108}
109
110#[derive(Parser, Debug)]
111pub struct LoginAuthArgs {
112 #[arg(short, long, env = "CODETETHER_SERVER")]
114 pub server: String,
115
116 #[arg(short, long)]
118 pub email: Option<String>,
119}
120
121#[derive(Parser, Debug)]
122pub struct CopilotAuthArgs {
123 #[arg(long)]
125 pub enterprise_url: Option<String>,
126
127 #[arg(long, env = "CODETETHER_COPILOT_OAUTH_CLIENT_ID")]
129 pub client_id: Option<String>,
130}
131
132#[derive(Parser, Debug)]
133pub struct TuiArgs {
134 pub project: Option<PathBuf>,
136}
137
138#[derive(Parser, Debug)]
139pub struct ServeArgs {
140 #[arg(short, long, default_value = "4096")]
142 pub port: u16,
143
144 #[arg(long, default_value = "127.0.0.1")]
146 pub hostname: String,
147
148 #[arg(long)]
150 pub mdns: bool,
151}
152
153#[derive(Parser, Debug)]
154pub struct RunArgs {
155 pub message: String,
157
158 #[arg(short, long)]
160 pub continue_session: bool,
161
162 #[arg(short, long)]
164 pub session: Option<String>,
165
166 #[arg(short, long)]
168 pub model: Option<String>,
169
170 #[arg(long)]
172 pub agent: Option<String>,
173
174 #[arg(long, default_value = "default", value_parser = ["default", "json"])]
176 pub format: String,
177
178 #[arg(short, long)]
180 pub file: Vec<PathBuf>,
181}
182
183#[derive(Parser, Debug, Clone)]
184pub struct A2aArgs {
185 #[arg(short, long, env = "CODETETHER_SERVER")]
187 pub server: String,
188
189 #[arg(short, long, env = "CODETETHER_TOKEN")]
191 pub token: Option<String>,
192
193 #[arg(short, long, env = "CODETETHER_WORKER_NAME")]
195 pub name: Option<String>,
196
197 #[arg(short, long)]
199 pub codebases: Option<String>,
200
201 #[arg(long, default_value = "safe", value_parser = ["all", "safe", "none"])]
203 pub auto_approve: String,
204
205 #[arg(short, long)]
207 pub email: Option<String>,
208
209 #[arg(long)]
211 pub push_url: Option<String>,
212}
213
214#[derive(Parser, Debug)]
215pub struct ConfigArgs {
216 #[arg(long)]
218 pub show: bool,
219
220 #[arg(long)]
222 pub init: bool,
223
224 #[arg(long)]
226 pub set: Option<String>,
227}
228
229#[derive(Parser, Debug)]
230pub struct SwarmArgs {
231 pub task: String,
233
234 #[arg(short, long)]
236 pub model: Option<String>,
237
238 #[arg(short = 's', long, default_value = "auto")]
240 pub strategy: String,
241
242 #[arg(long, default_value = "100")]
244 pub max_subagents: usize,
245
246 #[arg(long, default_value = "100")]
248 pub max_steps: usize,
249
250 #[arg(long, default_value = "300")]
252 pub timeout: u64,
253
254 #[arg(long)]
256 pub json: bool,
257}
258
259#[derive(Parser, Debug)]
260pub struct RlmArgs {
261 pub query: String,
263
264 #[arg(short, long)]
266 pub file: Vec<PathBuf>,
267
268 #[arg(long)]
270 pub content: Option<String>,
271
272 #[arg(long, default_value = "auto")]
274 pub content_type: String,
275
276 #[arg(long, default_value = "4000")]
278 pub max_tokens: usize,
279
280 #[arg(long)]
282 pub json: bool,
283
284 #[arg(short, long)]
286 pub verbose: bool,
287}
288
289#[derive(Parser, Debug)]
290pub struct RalphArgs {
291 #[arg(value_parser = ["run", "status", "create-prd"])]
293 pub action: String,
294
295 #[arg(short, long, default_value = "prd.json")]
297 pub prd: PathBuf,
298
299 #[arg(short, long)]
301 pub feature: Option<String>,
302
303 #[arg(long = "project-name")]
305 pub project_name: Option<String>,
306
307 #[arg(long, default_value = "10")]
309 pub max_iterations: usize,
310
311 #[arg(short, long)]
313 pub model: Option<String>,
314
315 #[arg(long)]
317 pub json: bool,
318}
319
320#[derive(Parser, Debug)]
321pub struct McpArgs {
322 #[arg(value_parser = ["serve", "connect", "list-tools", "call"])]
324 pub action: String,
325
326 #[arg(short, long)]
328 pub command: Option<String>,
329
330 #[arg(long)]
332 pub server_name: Option<String>,
333
334 #[arg(long)]
336 pub tool: Option<String>,
337
338 #[arg(long)]
340 pub arguments: Option<String>,
341
342 #[arg(long)]
344 pub json: bool,
345}
346
347#[derive(Parser, Debug)]
348pub struct StatsArgs {
349 #[arg(short, long)]
351 pub tools: bool,
352
353 #[arg(short, long)]
355 pub files: bool,
356
357 #[arg(long)]
359 pub tokens: bool,
360
361 #[arg(long)]
363 pub tool: Option<String>,
364
365 #[arg(long)]
367 pub file: Option<String>,
368
369 #[arg(short, long, default_value = "20")]
371 pub limit: usize,
372
373 #[arg(long)]
375 pub json: bool,
376
377 #[arg(long)]
379 pub all: bool,
380}
381
382#[derive(Parser, Debug)]
383pub struct CleanupArgs {
384 #[arg(short, long)]
386 pub dry_run: bool,
387
388 #[arg(long)]
390 pub worktrees_only: bool,
391
392 #[arg(long)]
394 pub json: bool,
395}
396
397#[derive(Parser, Debug)]
398pub struct ModelsArgs {
399 #[arg(short, long)]
401 pub provider: Option<String>,
402
403 #[arg(long)]
405 pub json: bool,
406}
407
408#[derive(Parser, Debug)]
409pub struct MoltbookArgs {
410 #[command(subcommand)]
411 pub command: MoltbookCommand,
412}
413
414#[derive(Subcommand, Debug)]
415pub enum MoltbookCommand {
416 Register(MoltbookRegisterArgs),
418
419 Status,
421
422 Profile,
424
425 UpdateProfile(MoltbookUpdateProfileArgs),
427
428 Post(MoltbookPostArgs),
430
431 Intro,
433
434 Heartbeat,
436
437 Comment(MoltbookCommentArgs),
439
440 Search(MoltbookSearchArgs),
442}
443
444#[derive(Parser, Debug)]
445pub struct MoltbookRegisterArgs {
446 pub name: String,
448
449 #[arg(short, long)]
451 pub description: Option<String>,
452}
453
454#[derive(Parser, Debug)]
455pub struct MoltbookUpdateProfileArgs {
456 #[arg(short, long)]
458 pub description: Option<String>,
459}
460
461#[derive(Parser, Debug)]
462pub struct MoltbookPostArgs {
463 pub title: String,
465
466 #[arg(short, long)]
468 pub content: String,
469
470 #[arg(short, long, default_value = "general")]
472 pub submolt: String,
473}
474
475#[derive(Parser, Debug)]
476pub struct MoltbookCommentArgs {
477 pub post_id: String,
479
480 pub content: String,
482}
483
484#[derive(Parser, Debug)]
485pub struct MoltbookSearchArgs {
486 pub query: String,
488
489 #[arg(short, long, default_value = "10")]
491 pub limit: usize,
492}
493
494#[derive(Parser, Debug)]
495pub struct BenchmarkArgs {
496 #[arg(long, default_value = "benchmarks")]
498 pub prd_dir: String,
499
500 #[arg(short, long, value_delimiter = ',')]
502 pub models: Vec<String>,
503
504 #[arg(long)]
506 pub tier: Option<u8>,
507
508 #[arg(long)]
510 pub parallel: bool,
511
512 #[arg(long, default_value = "10")]
514 pub max_iterations: usize,
515
516 #[arg(long, default_value = "300")]
518 pub story_timeout: u64,
519
520 #[arg(short, long, default_value = "benchmark_results.json")]
522 pub output: String,
523
524 #[arg(long, default_value = "50.0")]
526 pub cost_ceiling: f64,
527
528 #[arg(long)]
530 pub submit_url: Option<String>,
531
532 #[arg(long, env = "BENCHMARK_API_KEY")]
534 pub submit_key: Option<String>,
535
536 #[arg(long)]
538 pub json: bool,
539}