1use serde::Deserialize;
2use std::path::PathBuf;
3
4#[derive(Debug, Deserialize, Clone)]
5pub struct Settings {
6 pub agents: Vec<AgentConfig>,
7}
8
9#[derive(Debug, Deserialize, Clone)]
10pub struct AgentConfig {
11 pub command: String,
12 #[serde(default)]
13 pub args: Vec<String>,
14}
15
16impl Default for Settings {
17 fn default() -> Self {
18 Self {
19 agents: vec![AgentConfig {
20 command: "claude".to_string(),
21 args: vec![],
22 }],
23 }
24 }
25}
26
27impl Settings {
28 pub fn load() -> Result<Self, Box<dyn std::error::Error>> {
29 let path = Self::settings_path()?;
30 if !path.exists() {
31 return Ok(Settings::default());
32 }
33 let content = std::fs::read_to_string(&path)?;
34 let settings: Settings = serde_json::from_str(&content)?;
35 Ok(settings)
36 }
37
38 fn settings_path() -> Result<PathBuf, Box<dyn std::error::Error>> {
39 let home = dirs::home_dir().ok_or("HOME directory not found")?;
40 Ok(home.join(".seher").join("settings.json"))
41 }
42}