use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "sparrow", about = "one cli ยท grows with you", version)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
#[arg(long)]
pub tui: bool,
#[arg(long)]
pub web: bool,
#[arg(long)]
pub json: bool,
#[arg(long)]
pub autonomy: Option<String>,
#[arg(long)]
pub model: Option<String>,
#[arg(long)]
pub local: bool,
#[arg(long)]
pub budget: Option<f64>,
#[arg(long)]
pub sandbox: Option<String>,
#[arg(long)]
pub profile: Option<String>,
#[arg(long)]
pub no_checkpoint: bool,
#[arg(long)]
pub agent: Option<String>,
}
#[derive(Subcommand)]
pub enum Commands {
Run {
task: String,
#[arg(long)]
json: bool,
},
Plan {
task: String,
#[arg(long)]
json: bool,
},
Chat,
Tui,
Launch {
#[arg(long, default_value = "9339")]
port: u16,
#[arg(long)]
tui: bool,
},
Console {
#[arg(long, default_value = "9339")]
port: u16,
},
Daemon,
Agent {
#[command(subcommand)]
action: AgentAction,
},
Swarm {
task: String,
},
Schedule {
task: String,
#[arg(long)]
cron: String,
#[arg(long)]
autonomy: Option<String>,
#[arg(long)]
report: Vec<String>,
},
Model {
#[arg(long)]
set: Option<String>,
#[arg(long)]
list: bool,
},
Route {
#[command(subcommand)]
action: RouteAction,
},
Auth {
#[command(subcommand)]
action: AuthAction,
},
Skills {
#[command(subcommand)]
action: SkillsAction,
},
Plugins {
#[command(subcommand)]
action: PluginsAction,
},
Tools {
#[command(subcommand)]
action: ToolsAction,
},
Security {
#[command(subcommand)]
action: SecurityAction,
},
Github {
#[command(subcommand)]
action: GithubAction,
},
Compact {
#[arg(long)]
task: Option<String>,
#[arg(long)]
out: Option<PathBuf>,
#[arg(long)]
json: bool,
},
Mcp {
#[command(subcommand)]
action: McpAction,
},
Checkpoint {
#[command(subcommand)]
action: CheckpointAction,
},
Rewind {
id: String,
},
Replay {
run_id: String,
#[arg(long)]
scrub: bool,
},
Gateway {
#[command(subcommand)]
action: GatewayAction,
},
Sessions {
#[command(subcommand)]
action: SessionAction,
},
Learn,
Init,
Status,
Memory {
#[command(subcommand)]
action: MemoryAction,
},
Permissions {
#[command(subcommand)]
action: PermissionAction,
},
Profile {
#[command(subcommand)]
action: ProfileAction,
},
Import {
#[command(subcommand)]
source: ImportSource,
},
Config {
#[arg(short)]
edit: bool,
},
Update,
Doctor,
Setup,
Demo,
Share,
Hook {
#[command(subcommand)]
action: HookAction,
},
Voice {
#[command(subcommand)]
action: VoiceAction,
},
}
#[derive(Subcommand)]
pub enum AgentAction {
Create { name: String },
List,
Edit { name: String },
Rm { name: String },
Run { name: String, task: String },
Mention { name: String, message: String },
}
#[derive(Subcommand)]
pub enum AuthAction {
Add {
provider: String,
},
List,
Rm {
provider: String,
},
Login {
provider: String,
#[arg(long)]
client_id: Option<String>,
},
}
#[derive(Subcommand)]
pub enum SkillsAction {
List,
View {
name: String,
},
Create {
name: String,
},
Install {
source: String,
},
Update {
name: String,
},
Prune,
Rm {
name: String,
},
}
#[derive(Subcommand)]
pub enum PluginsAction {
List,
Install {
source: String,
#[arg(long)]
allow: bool,
},
Rm {
name: String,
},
}
#[derive(Subcommand)]
pub enum GithubAction {
Review {
pr: u64,
#[arg(long)]
dry_run: bool,
#[arg(long)]
model: Option<String>,
#[arg(long)]
allowed_tools: Option<String>,
},
Status,
Logs { run_id: String },
}
#[derive(Subcommand)]
pub enum SecurityAction {
Audit {
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub enum ToolsAction {
List {
#[arg(long)]
surface: Option<String>,
},
Enable {
tool: String,
},
Disable {
tool: String,
},
}
#[derive(Subcommand)]
pub enum McpAction {
Add {
server: String,
#[arg(long)]
command: Option<String>,
#[arg(long, value_delimiter = ' ', allow_hyphen_values = true)]
args: Vec<String>,
#[arg(long)]
transport: Option<String>,
},
List,
Rm {
server: String,
},
}
#[derive(Subcommand)]
pub enum CheckpointAction {
List,
Diff {
id: String,
},
Prune {
#[arg(long, default_value = "30")]
older_than_days: u64,
},
}
#[derive(Subcommand)]
pub enum GatewayAction {
Start,
Status,
Health,
Abort { run: String },
Stop,
}
#[derive(Subcommand)]
pub enum SessionAction {
List,
Export {
id: String,
path: Option<PathBuf>,
},
Cleanup {
#[arg(long, default_value_t = 30)]
older_than_days: u64,
},
}
#[derive(Subcommand)]
pub enum ProfileAction {
Create { name: String },
List,
Use { name: String },
}
#[derive(Subcommand)]
pub enum ImportSource {
Openclaw { path: Option<PathBuf> },
}
#[derive(Subcommand)]
pub enum MemoryAction {
List,
Forget {
id: String,
},
Add {
key: String,
value: String,
},
Replace {
id: String,
key: String,
value: String,
},
Recall {
query: String,
#[arg(long, default_value_t = 10)]
limit: usize,
},
Consolidate,
Docs,
Search {
query: String,
#[arg(long, default_value_t = 10)]
limit: usize,
},
Scroll {
session: String,
#[arg(long, default_value_t = 0)]
around: usize,
#[arg(long, default_value_t = 3)]
before: usize,
#[arg(long, default_value_t = 3)]
after: usize,
},
Graph {
#[command(subcommand)]
action: GraphAction,
},
}
#[derive(Subcommand)]
pub enum GraphAction {
UpsertNode {
id: String,
label: String,
#[arg(long, default_value = "entity")]
kind: String,
#[arg(long, default_value = "{}")]
properties: String,
},
UpsertEdge {
from_id: String,
relation: String,
to_id: String,
#[arg(long)]
id: Option<String>,
#[arg(long, default_value_t = 1.0)]
weight: f64,
#[arg(long, default_value = "{}")]
properties: String,
},
Get {
id: String,
},
Neighbors {
id: String,
#[arg(long, default_value = "both")]
direction: String,
#[arg(long, default_value_t = 20)]
limit: usize,
},
Search {
query: String,
#[arg(long, default_value_t = 20)]
limit: usize,
},
Export,
DeleteNode {
id: String,
},
DeleteEdge {
id: String,
},
SyncNeo4j,
}
#[derive(Subcommand)]
pub enum PermissionAction {
List,
Set { mode: String },
AllowTool { tool: String },
AskTool { tool: String },
DenyTool { tool: String },
AllowPath { path: PathBuf },
DenyPath { path: PathBuf },
}
#[derive(Subcommand)]
pub enum RouteAction {
Set {
provider: String,
},
Clear,
Show,
}
#[derive(Subcommand)]
pub enum HookAction {
Install,
Scan {
#[arg(long)]
all: bool,
},
}
#[derive(Subcommand)]
pub enum VoiceAction {
Speak { text: String },
Transcribe { file: String },
Providers,
}