Skip to main content

ralph/cli/machine/
args.rs

1//! Clap argument definitions for `ralph machine`.
2//!
3//! Responsibilities:
4//! - Define the versioned machine-facing subcommands consumed by the macOS app.
5//! - Keep machine Clap wiring separate from execution logic.
6//! - Re-export request-shaping flags shared by the machine handlers.
7//!
8//! Not handled here:
9//! - JSON document emission.
10//! - Queue/task/run business logic.
11//! - Machine contract schema types.
12//!
13//! Invariants/assumptions:
14//! - Machine commands stay non-human-facing and versioned.
15//! - Subcommand shapes remain stable unless machine contract versions change.
16
17use clap::Args;
18use clap::Subcommand;
19
20use crate::agent;
21
22#[derive(Args)]
23pub struct MachineArgs {
24    #[command(subcommand)]
25    pub command: MachineCommand,
26}
27
28#[derive(Subcommand)]
29pub enum MachineCommand {
30    System(MachineSystemArgs),
31    Queue(MachineQueueArgs),
32    Config(MachineConfigArgs),
33    Task(MachineTaskArgs),
34    Run(Box<MachineRunArgs>),
35    Doctor(MachineDoctorArgs),
36    CliSpec,
37    Schema,
38}
39
40#[derive(Args)]
41pub struct MachineSystemArgs {
42    #[command(subcommand)]
43    pub command: MachineSystemCommand,
44}
45
46#[derive(Subcommand)]
47pub enum MachineSystemCommand {
48    Info,
49}
50
51#[derive(Args)]
52pub struct MachineQueueArgs {
53    #[command(subcommand)]
54    pub command: MachineQueueCommand,
55}
56
57#[derive(Subcommand)]
58pub enum MachineQueueCommand {
59    Read,
60    Graph,
61    Dashboard(MachineDashboardArgs),
62    Validate,
63    Repair(MachineQueueRepairArgs),
64    Undo(MachineQueueUndoArgs),
65}
66
67#[derive(Args)]
68pub struct MachineDashboardArgs {
69    #[arg(long, default_value_t = 30)]
70    pub days: u32,
71}
72
73#[derive(Args)]
74pub struct MachineQueueRepairArgs {
75    #[arg(long)]
76    pub dry_run: bool,
77}
78
79#[derive(Args)]
80pub struct MachineQueueUndoArgs {
81    #[arg(long, short)]
82    pub id: Option<String>,
83    #[arg(long)]
84    pub list: bool,
85    #[arg(long)]
86    pub dry_run: bool,
87}
88
89#[derive(Args)]
90pub struct MachineConfigArgs {
91    #[command(subcommand)]
92    pub command: MachineConfigCommand,
93}
94
95#[derive(Subcommand)]
96pub enum MachineConfigCommand {
97    Resolve,
98}
99
100#[derive(Args)]
101pub struct MachineTaskArgs {
102    #[command(subcommand)]
103    pub command: MachineTaskCommand,
104}
105
106#[derive(Subcommand)]
107pub enum MachineTaskCommand {
108    Create(MachineTaskCreateArgs),
109    Mutate(MachineTaskMutateArgs),
110    Decompose(Box<MachineTaskDecomposeArgs>),
111}
112
113#[derive(Args)]
114pub struct MachineTaskCreateArgs {
115    #[arg(long, value_name = "PATH")]
116    pub input: Option<String>,
117}
118
119#[derive(Args)]
120pub struct MachineTaskMutateArgs {
121    #[arg(long, value_name = "PATH")]
122    pub input: Option<String>,
123    #[arg(long)]
124    pub dry_run: bool,
125}
126
127#[derive(Args)]
128pub struct MachineTaskDecomposeArgs {
129    pub source: Vec<String>,
130    #[arg(long)]
131    pub attach_to: Option<String>,
132    #[arg(long, default_value_t = 3)]
133    pub max_depth: u8,
134    #[arg(long, default_value_t = 5)]
135    pub max_children: u8,
136    #[arg(long, default_value_t = 50)]
137    pub max_nodes: u8,
138    #[arg(long, default_value = "draft")]
139    pub status: String,
140    #[arg(long, default_value = "fail")]
141    pub child_policy: String,
142    #[arg(long)]
143    pub with_dependencies: bool,
144    #[arg(long)]
145    pub write: bool,
146    #[command(flatten)]
147    pub agent: agent::AgentArgs,
148}
149
150#[derive(Args)]
151pub struct MachineRunArgs {
152    #[command(subcommand)]
153    pub command: MachineRunCommand,
154}
155
156#[derive(Subcommand)]
157pub enum MachineRunCommand {
158    One(MachineRunOneArgs),
159    Loop(MachineRunLoopArgs),
160    ParallelStatus,
161}
162
163#[derive(Args)]
164pub struct MachineRunOneArgs {
165    #[arg(long)]
166    pub id: Option<String>,
167    #[arg(long)]
168    pub force: bool,
169    #[arg(long)]
170    pub resume: bool,
171    #[command(flatten)]
172    pub agent: agent::RunAgentArgs,
173}
174
175#[derive(Args)]
176pub struct MachineRunLoopArgs {
177    #[arg(long, default_value_t = 0)]
178    pub max_tasks: u32,
179    #[arg(long)]
180    pub force: bool,
181    #[arg(long)]
182    pub resume: bool,
183    #[command(flatten)]
184    pub agent: agent::RunAgentArgs,
185}
186
187#[derive(Args)]
188pub struct MachineDoctorArgs {
189    #[command(subcommand)]
190    pub command: MachineDoctorCommand,
191}
192
193#[derive(Subcommand)]
194pub enum MachineDoctorCommand {
195    Report,
196}