Skip to main content

flow_core/
agent.rs

1use crate::theme::Theme;
2use std::path::PathBuf;
3
4/// Configuration for the agent monitoring system.
5#[derive(Debug, Clone)]
6pub struct AgentConfig {
7    /// Port for the web server (default: 3456).
8    pub port: u16,
9
10    /// Root directory for Claude/agent data (e.g., ~/.claude).
11    pub claude_dir: PathBuf,
12
13    /// Data directory for application state.
14    pub data_dir: PathBuf,
15
16    /// UI theme.
17    pub theme: Theme,
18
19    /// Maximum number of concurrent agent operations.
20    pub max_concurrency: usize,
21
22    /// Testing ratio for validation (0.0-1.0).
23    pub testing_ratio: f64,
24
25    /// Batch size for bulk operations.
26    pub batch_size: usize,
27
28    /// Enable yolo mode (skip confirmations).
29    pub yolo_mode: bool,
30
31    /// Optional custom public directory for static assets.
32    pub public_dir: Option<PathBuf>,
33
34    /// Open browser on server start.
35    pub open_browser: bool,
36}
37
38impl Default for AgentConfig {
39    fn default() -> Self {
40        let home = dirs::home_dir().expect("Failed to get home directory");
41        let claude_dir = home.join(".claude");
42        let data_dir = claude_dir.join("data");
43
44        Self {
45            port: 3456,
46            claude_dir,
47            data_dir,
48            theme: Theme::default(),
49            max_concurrency: 4,
50            testing_ratio: 0.3,
51            batch_size: 10,
52            yolo_mode: false,
53            public_dir: None,
54            open_browser: true,
55        }
56    }
57}
58
59impl AgentConfig {
60    /// Create a new `AgentConfig` with default values.
61    #[must_use]
62    pub fn new() -> Self {
63        Self::default()
64    }
65
66    /// Get the tasks directory path (~/.claude/tasks).
67    #[must_use]
68    pub fn tasks_dir(&self) -> PathBuf {
69        self.claude_dir.join("tasks")
70    }
71
72    /// Get the projects directory path (~/.claude/projects).
73    #[must_use]
74    pub fn projects_dir(&self) -> PathBuf {
75        self.claude_dir.join("projects")
76    }
77
78    /// Get the teams directory path (~/.claude/teams).
79    #[must_use]
80    pub fn teams_dir(&self) -> PathBuf {
81        self.claude_dir.join("teams")
82    }
83
84    /// Get the features database path for a specific project.
85    #[must_use]
86    pub fn features_db_path(&self, project: &str) -> PathBuf {
87        self.data_dir.join(format!("{project}.db"))
88    }
89
90    /// Set a custom port.
91    #[must_use]
92    pub const fn with_port(mut self, port: u16) -> Self {
93        self.port = port;
94        self
95    }
96
97    /// Set a custom claude directory.
98    #[must_use]
99    pub fn with_claude_dir(mut self, dir: PathBuf) -> Self {
100        self.claude_dir = dir;
101        self
102    }
103
104    /// Set a custom theme.
105    #[must_use]
106    pub const fn with_theme(mut self, theme: Theme) -> Self {
107        self.theme = theme;
108        self
109    }
110
111    /// Set yolo mode.
112    #[must_use]
113    pub const fn with_yolo_mode(mut self, enabled: bool) -> Self {
114        self.yolo_mode = enabled;
115        self
116    }
117
118    /// Set custom public directory.
119    #[must_use]
120    pub fn with_public_dir(mut self, dir: PathBuf) -> Self {
121        self.public_dir = Some(dir);
122        self
123    }
124
125    /// Set whether to open browser on start.
126    #[must_use]
127    pub const fn with_open_browser(mut self, open: bool) -> Self {
128        self.open_browser = open;
129        self
130    }
131}