//! Command specs and help formatting. use crate::config::APP_NAME; #[derive(Debug, Clone)] pub struct CommandSpec { pub path: &'static [&'static str], pub usage: &'static str, pub summary: &'static str, pub description: Option<&'static str>, pub options: &'static [&'static str], pub examples: &'static [&'static str], } impl CommandSpec { const fn new( path: &'static [&'static str], usage: &'static str, summary: &'static str, ) -> Self { CommandSpec { path, usage, summary, description: None, options: &[], examples: &[], } } const fn description(mut self, description: &'static str) -> Self { self.description = Some(description); self } const fn options(mut self, options: &'static [&'static str]) -> Self { self.options = options; self } const fn examples(mut self, examples: &'static [&'static str]) -> Self { self.examples = examples; self } } /// All public command specs, in registry order. pub const COMMAND_SPECS: &[CommandSpec] = &[ CommandSpec::new(&["help"], "help [command]", "Show command help"), CommandSpec::new(&["agents"], "agents", "Search and open sessions"), CommandSpec::new( &["list"], "list [--all] [--json]", "List agents", ) .options(&[ "-a, --all Include saved agents", "--json Print JSON", ]), CommandSpec::new( &["sessions"], "sessions [--all] [--json]", "Show agent status, activity, and usage", ) .options(&[ "-a, --all Include saved agents", "--json Print JSON", ]), CommandSpec::new( &["attach"], "attach ", "Attach the interactive UI to an agent", ), CommandSpec::new(&["stop"], "stop [--json]", "Stop an agent"), CommandSpec::new( &["rename"], "rename [--json]", "Rename an agent", ), CommandSpec::new( &["send"], "send [--from ] ", "Send a message to an agent", ) .options(&[ "--from Identify the sending agent", "--steer Deliver as steering when the agent is busy", "--follow-up Queue the message after the current turn", "--json Print JSON", ]), CommandSpec::new( &["schedule"], "schedule ", "Manage prompts that run later or on a recurring schedule", ), CommandSpec::new( &["schedule", "list"], "schedule list [--all] [agent] [--json]", "List scheduled prompts", ), CommandSpec::new( &["schedule", "add"], "schedule add -- ", "Schedule a prompt", ) .description("The schedule may be a cron expression or a supported one-time schedule.") .examples(&["schedule add worker \"0 9 * * 1-5\" -- \"Check open work\""]), CommandSpec::new( &["schedule", "cancel"], "schedule cancel ", "Cancel a scheduled prompt", ), CommandSpec::new( &["status"], "status [--json]", "Show background service status", ), CommandSpec::new( &["doctor"], "doctor [--fix] [--json]", "Inspect and safely clean up background services", ) .options(&[ "--fix Remove stale sockets and stop idle orphaned services", "--json Print JSON", ]), CommandSpec::new( &["incident"], "incident [--since