|
| 1 | +use clap::{Parser, Subcommand, ValueEnum}; |
| 2 | +use std::path::PathBuf; |
| 3 | + |
| 4 | +/// MiMi - Multimodal Instruction Master Interface |
| 5 | +#[derive(Parser, Debug)] |
| 6 | +#[command(name = "mimi")] |
| 7 | +#[command(version = "0.1.0")] |
| 8 | +#[command(about = "Multimodal Instruction Master Interface for autonomous task execution")] |
| 9 | +#[command(author = "MiMi Team")] |
| 10 | +pub struct Cli { |
| 11 | + #[command(flatten)] |
| 12 | + pub global: GlobalOpts, |
| 13 | + |
| 14 | + #[command(subcommand)] |
| 15 | + pub command: Option<Commands>, |
| 16 | +} |
| 17 | + |
| 18 | +/// Global options available to all commands |
| 19 | +#[derive(Parser, Debug)] |
| 20 | +pub struct GlobalOpts { |
| 21 | + /// Increase verbosity level (-v for debug, -vv for trace) |
| 22 | + #[arg(short, long, action = clap::ArgAction::Count, global = true)] |
| 23 | + pub verbose: u8, |
| 24 | + |
| 25 | + /// Suppress non-essential output |
| 26 | + #[arg(short, long, global = true)] |
| 27 | + pub quiet: bool, |
| 28 | + |
| 29 | + /// Configuration file path |
| 30 | + #[arg(short, long, global = true, value_name = "FILE")] |
| 31 | + pub config: Option<PathBuf>, |
| 32 | + |
| 33 | + /// Log level: trace, debug, info, warn, error |
| 34 | + #[arg(long, global = true, value_name = "LEVEL")] |
| 35 | + pub log_level: Option<String>, |
| 36 | + |
| 37 | + /// Output format: text, json, yaml |
| 38 | + #[arg(long, global = true, value_name = "FORMAT", default_value = "text")] |
| 39 | + pub output: OutputFormat, |
| 40 | + |
| 41 | + /// Disable colored output |
| 42 | + #[arg(long, global = true)] |
| 43 | + pub no_color: bool, |
| 44 | +} |
| 45 | + |
| 46 | +/// Output formats |
| 47 | +#[derive(ValueEnum, Clone, Debug, Copy)] |
| 48 | +pub enum OutputFormat { |
| 49 | + /// Human-readable text output |
| 50 | + #[value(name = "text")] |
| 51 | + Text, |
| 52 | + /// JSON structured output |
| 53 | + #[value(name = "json")] |
| 54 | + Json, |
| 55 | + /// YAML formatted output |
| 56 | + #[value(name = "yaml")] |
| 57 | + Yaml, |
| 58 | +} |
| 59 | + |
| 60 | +impl std::fmt::Display for OutputFormat { |
| 61 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 62 | + match self { |
| 63 | + OutputFormat::Text => write!(f, "text"), |
| 64 | + OutputFormat::Json => write!(f, "json"), |
| 65 | + OutputFormat::Yaml => write!(f, "yaml"), |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +/// Task priority levels |
| 71 | +#[derive(ValueEnum, Clone, Debug, Copy)] |
| 72 | +pub enum Priority { |
| 73 | + #[value(name = "low")] |
| 74 | + Low, |
| 75 | + #[value(name = "normal")] |
| 76 | + Normal, |
| 77 | + #[value(name = "high")] |
| 78 | + High, |
| 79 | +} |
| 80 | + |
| 81 | +impl std::fmt::Display for Priority { |
| 82 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 83 | + match self { |
| 84 | + Priority::Low => write!(f, "low"), |
| 85 | + Priority::Normal => write!(f, "normal"), |
| 86 | + Priority::High => write!(f, "high"), |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +#[derive(Subcommand, Debug)] |
| 92 | +pub enum Commands { |
| 93 | + /// Execute a task or skill |
| 94 | + Exec { |
| 95 | + /// Task description or command |
| 96 | + #[arg(value_name = "TASK")] |
| 97 | + task: String, |
| 98 | + |
| 99 | + /// Task priority |
| 100 | + #[arg(short, long, default_value = "normal")] |
| 101 | + priority: Priority, |
| 102 | + |
| 103 | + /// Task timeout in seconds |
| 104 | + #[arg(short, long, default_value = "300")] |
| 105 | + timeout: u32, |
| 106 | + |
| 107 | + /// Run asynchronously (return task ID) |
| 108 | + #[arg(long)] |
| 109 | + r#async: bool, |
| 110 | + |
| 111 | + /// Follow async task completion |
| 112 | + #[arg(long)] |
| 113 | + follow: bool, |
| 114 | + |
| 115 | + /// Save result to file |
| 116 | + #[arg(long)] |
| 117 | + save_result: Option<PathBuf>, |
| 118 | + |
| 119 | + /// Output format override |
| 120 | + #[arg(long)] |
| 121 | + format: Option<OutputFormat>, |
| 122 | + |
| 123 | + /// Preview task without executing |
| 124 | + #[arg(long)] |
| 125 | + dry_run: bool, |
| 126 | + }, |
| 127 | + |
| 128 | + /// Query MiMi memory and status |
| 129 | + Query { |
| 130 | + /// Query text |
| 131 | + #[arg(value_name = "QUERY")] |
| 132 | + query: String, |
| 133 | + |
| 134 | + /// Filter results (jq syntax) |
| 135 | + #[arg(short, long)] |
| 136 | + filter: Option<String>, |
| 137 | + |
| 138 | + /// Sort results by field |
| 139 | + #[arg(short, long)] |
| 140 | + sort: Option<String>, |
| 141 | + |
| 142 | + /// Limit number of results |
| 143 | + #[arg(long, default_value = "20")] |
| 144 | + limit: u32, |
| 145 | + |
| 146 | + /// Pagination offset |
| 147 | + #[arg(long, default_value = "0")] |
| 148 | + offset: u32, |
| 149 | + |
| 150 | + /// Include contextual information |
| 151 | + #[arg(long)] |
| 152 | + include_context: bool, |
| 153 | + |
| 154 | + /// Memory type: short, long, working, all |
| 155 | + #[arg(long, default_value = "all")] |
| 156 | + memory_type: String, |
| 157 | + |
| 158 | + /// Results from date (ISO 8601) |
| 159 | + #[arg(long)] |
| 160 | + from: Option<String>, |
| 161 | + |
| 162 | + /// Results until date (ISO 8601) |
| 163 | + #[arg(long)] |
| 164 | + to: Option<String>, |
| 165 | + }, |
| 166 | + |
| 167 | + /// Manage configuration |
| 168 | + Config { |
| 169 | + #[command(subcommand)] |
| 170 | + subcommand: ConfigSubcommand, |
| 171 | + }, |
| 172 | + |
| 173 | + /// Debugging and diagnostics |
| 174 | + Debug { |
| 175 | + #[command(subcommand)] |
| 176 | + subcommand: DebugSubcommand, |
| 177 | + }, |
| 178 | + |
| 179 | + /// Start interactive REPL mode |
| 180 | + Repl { |
| 181 | + /// History file location |
| 182 | + #[arg(long)] |
| 183 | + history_file: Option<PathBuf>, |
| 184 | + |
| 185 | + /// Maximum history entries |
| 186 | + #[arg(long, default_value = "1000")] |
| 187 | + max_history: usize, |
| 188 | + |
| 189 | + /// Disable history persistence |
| 190 | + #[arg(long)] |
| 191 | + no_history: bool, |
| 192 | + |
| 193 | + /// Startup script to run |
| 194 | + #[arg(long)] |
| 195 | + startup_script: Option<PathBuf>, |
| 196 | + |
| 197 | + /// Enable command completion |
| 198 | + #[arg(long)] |
| 199 | + completion: bool, |
| 200 | + }, |
| 201 | + |
| 202 | + /// Show version information |
| 203 | + Version { |
| 204 | + /// Output in JSON format |
| 205 | + #[arg(long)] |
| 206 | + json: bool, |
| 207 | + |
| 208 | + /// Show short version only |
| 209 | + #[arg(long)] |
| 210 | + short: bool, |
| 211 | + |
| 212 | + /// Show full build details |
| 213 | + #[arg(long)] |
| 214 | + full: bool, |
| 215 | + }, |
| 216 | +} |
| 217 | + |
| 218 | +#[derive(Subcommand, Debug)] |
| 219 | +pub enum ConfigSubcommand { |
| 220 | + /// Set a configuration value |
| 221 | + Set { |
| 222 | + /// Config key (e.g., adapter.default) |
| 223 | + key: String, |
| 224 | + /// Config value |
| 225 | + value: String, |
| 226 | + }, |
| 227 | + |
| 228 | + /// Get a configuration value |
| 229 | + Get { |
| 230 | + /// Config key |
| 231 | + key: String, |
| 232 | + }, |
| 233 | + |
| 234 | + /// List all configuration values |
| 235 | + List, |
| 236 | + |
| 237 | + /// Reset to defaults |
| 238 | + Reset, |
| 239 | + |
| 240 | + /// Validate configuration file |
| 241 | + Validate, |
| 242 | + |
| 243 | + /// Initialize with preset profile |
| 244 | + Init { |
| 245 | + /// Profile: development, production |
| 246 | + profile: String, |
| 247 | + }, |
| 248 | +} |
| 249 | + |
| 250 | +#[derive(Subcommand, Debug)] |
| 251 | +pub enum DebugSubcommand { |
| 252 | + /// Show system status and health |
| 253 | + Status, |
| 254 | + |
| 255 | + /// Test message bus latency |
| 256 | + BusLatency { |
| 257 | + /// Number of messages to send |
| 258 | + #[arg(value_name = "NUM")] |
| 259 | + num_messages: u32, |
| 260 | + }, |
| 261 | + |
| 262 | + /// Show memory graph statistics |
| 263 | + MemoryStats, |
| 264 | + |
| 265 | + /// Test AI adapter connectivity |
| 266 | + AdapterTest { |
| 267 | + /// Adapter name: gemini, ollama |
| 268 | + adapter: String, |
| 269 | + }, |
| 270 | + |
| 271 | + /// Trace execution flow of task |
| 272 | + TraceFlow { |
| 273 | + /// Task ID |
| 274 | + task_id: String, |
| 275 | + }, |
| 276 | + |
| 277 | + /// CPU/memory profiling |
| 278 | + Profile { |
| 279 | + /// Duration in seconds |
| 280 | + duration: u32, |
| 281 | + }, |
| 282 | + |
| 283 | + /// Test intent parsing |
| 284 | + ValidateIntent { |
| 285 | + /// Text to parse |
| 286 | + text: String, |
| 287 | + }, |
| 288 | +} |
0 commit comments