ralph/cli/task/args/build.rs
1//! CLI arguments for task build commands.
2//!
3//! Responsibilities:
4//! - Define Args structs for TaskBuildArgs and TaskBuildRefactorArgs.
5//!
6//! Not handled here:
7//! - Command execution (see build and refactor handlers).
8//!
9//! Invariants/assumptions:
10//! - All types must be Clone where needed for clap flattening.
11
12use clap::Args;
13
14use crate::agent;
15use crate::cli::task::args::types::BatchMode;
16
17#[derive(Args)]
18pub struct TaskBuildArgs {
19 /// Freeform request text; if omitted, reads from stdin.
20 #[arg(value_name = "REQUEST")]
21 pub request: Vec<String>,
22
23 /// Optional hint tags (passed to the task builder prompt).
24 #[arg(long, default_value = "")]
25 pub tags: String,
26
27 /// Optional hint scope (passed to the task builder prompt).
28 #[arg(long, default_value = "")]
29 pub scope: String,
30
31 /// Runner to use. CLI flag overrides config defaults (project > global > built-in).
32 #[arg(long)]
33 pub runner: Option<String>,
34
35 /// Model to use. CLI flag overrides config defaults (project > global > built-in).
36 #[arg(long)]
37 pub model: Option<String>,
38
39 /// Codex reasoning effort. CLI flag overrides config defaults (project > global > built-in).
40 /// Ignored for opencode and gemini.
41 #[arg(short = 'e', long)]
42 pub effort: Option<String>,
43
44 /// RepoPrompt mode (tools, plan, off). Alias: -rp.
45 #[arg(long = "repo-prompt", value_enum, value_name = "MODE")]
46 pub repo_prompt: Option<agent::RepoPromptMode>,
47
48 #[command(flatten)]
49 pub runner_cli: agent::RunnerCliArgs,
50
51 /// Template to use for pre-filling task fields (bug, feature, refactor, test, docs,
52 /// add-tests, refactor-performance, fix-error-handling, add-docs, security-audit).
53 #[arg(short = 't', long, value_name = "TEMPLATE")]
54 pub template: Option<String>,
55
56 /// Target file/path for template variable substitution ({{target}}, {{module}}, {{file}}).
57 /// Used with --template to auto-fill template variables.
58 #[arg(long, value_name = "PATH")]
59 pub target: Option<String>,
60
61 /// Estimated time to complete (e.g., "30m", "2h", "1h30m").
62 /// Stored as minutes in the task's estimated_minutes field.
63 #[arg(long, value_name = "DURATION")]
64 pub estimate: Option<String>,
65
66 /// Fail on unknown template variables (default: warn only).
67 /// When enabled, template loading fails if the template contains unknown {{variables}}.
68 /// When disabled (default), unknown variables are left as-is with a warning.
69 #[arg(long)]
70 pub strict_templates: bool,
71}
72
73#[derive(Args)]
74#[command(after_long_help = "Examples:
75 ralph task build refactor
76 ralph task build refactor --threshold 700
77 ralph task build refactor --path crates/ralph/src/cli
78 ralph task build refactor --dry-run --threshold 500
79 ralph task build refactor --batch never
80 ralph task build refactor --tags urgent,technical-debt")]
81pub struct TaskBuildRefactorArgs {
82 /// LOC threshold for flagging files as "large" (default: 1000).
83 /// Files exceeding ~1000 LOC are presumed mis-scoped per AGENTS.md.
84 #[arg(long, default_value = "1000")]
85 pub threshold: usize,
86
87 /// Directory to scan for Rust files (default: current directory / repo root).
88 #[arg(long)]
89 pub path: Option<std::path::PathBuf>,
90
91 /// Preview tasks without inserting into queue.
92 #[arg(long)]
93 pub dry_run: bool,
94
95 /// Batching behavior for related files.
96 /// - auto: Group files in same directory with similar names (default).
97 /// - never: Create individual task per file.
98 /// - aggressive: Group all files in same module.
99 #[arg(long, value_enum, default_value = "auto")]
100 pub batch: BatchMode,
101
102 /// Additional tags to add to generated tasks (comma-separated).
103 #[arg(long)]
104 pub tags: Option<String>,
105
106 /// Runner to use. CLI flag overrides config defaults (project > global > built-in).
107 #[arg(long)]
108 pub runner: Option<String>,
109
110 /// Model to use. CLI flag overrides config defaults (project > global > built-in).
111 #[arg(long)]
112 pub model: Option<String>,
113
114 /// Codex reasoning effort. CLI flag overrides config defaults (project > global > built-in).
115 /// Ignored for opencode and gemini.
116 #[arg(short = 'e', long)]
117 pub effort: Option<String>,
118
119 /// RepoPrompt mode (tools, plan, off). Alias: -rp.
120 #[arg(long = "repo-prompt", value_enum, value_name = "MODE")]
121 pub repo_prompt: Option<agent::RepoPromptMode>,
122
123 #[command(flatten)]
124 pub runner_cli: agent::RunnerCliArgs,
125
126 /// Fail on unknown template variables (default: warn only).
127 /// When enabled, template loading fails if the template contains unknown {{variables}}.
128 /// When disabled (default), unknown variables are left as-is with a warning.
129 #[arg(long)]
130 pub strict_templates: bool,
131}