Skip to main content

edict/commands/
run.rs

1use std::path::PathBuf;
2
3use clap::Subcommand;
4
5#[derive(Debug, Subcommand)]
6pub enum RunCommand {
7    /// Run an agent with stream output parsing (pi default, claude opt-in)
8    Agent {
9        /// Prompt to send to the agent
10        prompt: String,
11        /// Model to use (tier name: fast/balanced/strong, or provider/model-id e.g. anthropic/claude-sonnet-4-6:medium)
12        #[arg(short, long)]
13        model: Option<String>,
14        /// Timeout in seconds
15        #[arg(short, long, default_value = "600")]
16        timeout: u64,
17        /// Output format (pretty or text)
18        #[arg(long)]
19        format: Option<String>,
20        /// Runtime: 'pi' (default) or 'claude'
21        #[arg(long, default_value = "pi")]
22        runner: String,
23        /// Skip Claude Code permission checks (only for --runner claude)
24        #[arg(long)]
25        skip_permissions: bool,
26    },
27    /// Run the dev-loop (lead agent)
28    DevLoop {
29        /// Project root directory
30        #[arg(long)]
31        project_root: Option<PathBuf>,
32        /// Agent name override
33        #[arg(long)]
34        agent: Option<String>,
35        /// Model to use
36        #[arg(long)]
37        model: Option<String>,
38    },
39    /// Run the worker-loop (agent-loop)
40    WorkerLoop {
41        /// Project root directory
42        #[arg(long)]
43        project_root: Option<PathBuf>,
44        /// Agent name override
45        #[arg(long)]
46        agent: Option<String>,
47        /// Model to use
48        #[arg(long)]
49        model: Option<String>,
50    },
51    /// Run the reviewer-loop
52    ReviewerLoop {
53        /// Project root directory
54        #[arg(long)]
55        project_root: Option<PathBuf>,
56        /// Agent name override
57        #[arg(long)]
58        agent: Option<String>,
59        /// Model to use
60        #[arg(long)]
61        model: Option<String>,
62    },
63    /// Run the responder (message router)
64    Responder {
65        /// Project root directory
66        #[arg(long)]
67        project_root: Option<PathBuf>,
68        /// Agent name override
69        #[arg(long)]
70        agent: Option<String>,
71        /// Model to use
72        #[arg(long)]
73        model: Option<String>,
74    },
75    /// Run triage (bone scoring and recommendations)
76    Triage {
77        /// Project root directory
78        #[arg(long)]
79        project_root: Option<PathBuf>,
80    },
81    /// Run iteration-start (combined status snapshot)
82    IterationStart {
83        /// Project root directory
84        #[arg(long)]
85        project_root: Option<PathBuf>,
86        /// Agent name override
87        #[arg(long)]
88        agent: Option<String>,
89    },
90}
91
92impl RunCommand {
93    pub fn execute(&self) -> anyhow::Result<()> {
94        match self {
95            RunCommand::Agent {
96                prompt,
97                model,
98                timeout,
99                format,
100                runner,
101                skip_permissions,
102            } => crate::commands::run_agent::run_agent(
103                runner,
104                prompt,
105                model.as_deref(),
106                *timeout,
107                format.as_deref(),
108                *skip_permissions,
109            ),
110            RunCommand::DevLoop {
111                project_root,
112                agent,
113                model,
114            } => crate::commands::dev_loop::run(
115                project_root.as_deref(),
116                agent.as_deref(),
117                model.as_deref(),
118            ),
119            RunCommand::WorkerLoop {
120                project_root,
121                agent,
122                model,
123            } => crate::commands::worker_loop::run_worker_loop(
124                project_root.clone(),
125                agent.clone(),
126                model.clone(),
127            ),
128            RunCommand::ReviewerLoop {
129                project_root,
130                agent,
131                model,
132            } => crate::commands::run_reviewer_loop::run_reviewer_loop(
133                project_root.clone(),
134                agent.clone(),
135                model.clone(),
136            ),
137            RunCommand::Responder {
138                project_root,
139                agent,
140                model,
141            } => crate::commands::responder::run_responder(
142                project_root.clone(),
143                agent.clone(),
144                model.clone(),
145            ),
146            RunCommand::Triage { .. } => crate::commands::triage::run_triage(),
147            RunCommand::IterationStart { agent, .. } => {
148                crate::commands::iteration_start::run_iteration_start(agent.as_deref())
149            }
150        }
151    }
152}