ralph_workflow/cli/presets.rs
1//! Preset configurations for common agent combinations.
2//!
3//! Presets allow users to quickly configure Ralph for common use cases
4//! without specifying individual agent options.
5
6use crate::config::{Config, ReviewDepth};
7use crate::logger::Colors;
8use clap::ValueEnum;
9
10/// Preset configurations for common agent combinations.
11#[derive(Clone, Debug, ValueEnum)]
12pub enum Preset {
13 /// Use `agent_chain` defaults (no explicit agent override)
14 Default,
15 /// Use opencode for both developer and reviewer
16 Opencode,
17}
18
19/// Apply CLI arguments to the configuration.
20///
21/// This function uses the reducer architecture to process CLI arguments:
22/// 1. Parse Args into a sequence of CliEvents
23/// 2. Run events through the reducer to build CliState
24/// 3. Apply CliState to Config
25///
26/// This approach ensures:
27/// - All CLI arguments are handled (fixes missing -L, -S, -T flags)
28/// - Event processing is testable and maintainable
29/// - Consistent with the existing pipeline reducer pattern
30pub fn apply_args_to_config(args: &super::Args, config: &mut Config, colors: Colors) {
31 use crate::cli::reducer::{apply_cli_state_to_config, args_to_events, reduce, CliState};
32
33 // Validate review depth before processing (for user warning)
34 if let Some(ref depth) = args.review_depth {
35 if ReviewDepth::from_str(depth).is_none() {
36 eprintln!(
37 "{}{}Warning:{} Unknown review depth '{}'. Using default (standard).",
38 colors.bold(),
39 colors.yellow(),
40 colors.reset(),
41 depth
42 );
43 eprintln!("Valid options: standard, comprehensive, security, incremental");
44 }
45 }
46
47 // Parse args into events
48 let events = args_to_events(args);
49
50 // Run events through reducer to build state
51 let mut state = CliState::initial();
52 for event in events {
53 state = reduce(state, event);
54 }
55
56 // Apply final state to config
57 apply_cli_state_to_config(&state, config);
58}