1use serde::{Deserialize, Serialize};
2use std::path::{Path, PathBuf};
3
4#[derive(Debug, Serialize, Deserialize)]
5pub struct TracevaultConfig {
6 pub agent: String,
7 pub server_url: Option<String>,
8 pub api_key: Option<String>,
9}
10
11impl Default for TracevaultConfig {
12 fn default() -> Self {
13 Self {
14 agent: "claude-code".to_string(),
15 server_url: None,
16 api_key: None,
17 }
18 }
19}
20
21impl TracevaultConfig {
22 pub fn config_dir(project_root: &Path) -> PathBuf {
23 project_root.join(".tracevault")
24 }
25
26 pub fn config_path(project_root: &Path) -> PathBuf {
27 Self::config_dir(project_root).join("config.toml")
28 }
29
30 pub fn to_toml(&self) -> String {
31 let mut out = format!(
32 "# TraceVault configuration\nagent = \"{}\"\n",
33 self.agent
34 );
35 if let Some(url) = &self.server_url {
36 out.push_str(&format!("server_url = \"{url}\"\n"));
37 }
38 out
39 }
40}