pub struct Config {
pub defaults: Defaults,
pub models: AgentModels,
pub auto: AutoConfig,
pub ollama: OllamaConfig,
pub listen: ListenConfig,
}Expand description
Root configuration structure.
Fields§
§defaults: DefaultsDefault settings
models: AgentModelsPer-agent model defaults
auto: AutoConfigAuto-selection settings
ollama: OllamaConfigOllama-specific settings
listen: ListenConfigListen command settings
Implementations§
Source§impl Config
impl Config
Sourcepub const VALID_PROVIDERS: &'static [&'static str]
pub const VALID_PROVIDERS: &'static [&'static str]
Valid provider names (including “auto”).
Sourcepub const VALID_KEYS: &'static [&'static str]
pub const VALID_KEYS: &'static [&'static str]
All valid config keys for listing/discovery.
Sourcepub fn load(root: Option<&str>) -> Result<Self>
pub fn load(root: Option<&str>) -> Result<Self>
Load configuration from ~/.zag/projects/<id>/zag.toml.
The project ID is derived from the git repo root or explicit --root.
Returns default config if file doesn’t exist.
Sourcepub fn save(&self, root: Option<&str>) -> Result<()>
pub fn save(&self, root: Option<&str>) -> Result<()>
Save configuration to ~/.zag/projects/<id>/zag.toml.
Creates the directory if it doesn’t exist.
Sourcepub fn init(root: Option<&str>) -> Result<bool>
pub fn init(root: Option<&str>) -> Result<bool>
Initialize config file with defaults if it doesn’t exist.
Returns true if a new config was created, false if it already existed.
Sourcepub fn global_base_dir() -> PathBuf
pub fn global_base_dir() -> PathBuf
Get the global base directory (~/.zag).
Sourcepub fn sanitize_path(path: &str) -> String
pub fn sanitize_path(path: &str) -> String
Sanitize an absolute path into a directory name.
Strips leading / and replaces / with -.
Sourcepub fn config_path(root: Option<&str>) -> PathBuf
pub fn config_path(root: Option<&str>) -> PathBuf
Get the path to the config file.
Sourcepub fn agent_dir(root: Option<&str>) -> PathBuf
pub fn agent_dir(root: Option<&str>) -> PathBuf
Get the project directory path (for sessions, etc.).
Sourcepub fn global_logs_dir() -> PathBuf
pub fn global_logs_dir() -> PathBuf
Get the global logs directory path.
Sourcepub fn get_model(&self, agent: &str) -> Option<&str>
pub fn get_model(&self, agent: &str) -> Option<&str>
Get the default model for a specific agent, if configured. Checks agent-specific model first, then falls back to defaults.model.
Sourcepub fn default_model(&self) -> Option<&str>
pub fn default_model(&self) -> Option<&str>
Get the global default model (without agent-specific override).
Sourcepub fn ollama_model(&self) -> &str
pub fn ollama_model(&self) -> &str
Get the ollama model name (default: “qwen3.5”).
Sourcepub fn ollama_size(&self) -> &str
pub fn ollama_size(&self) -> &str
Get the ollama default size (default: “9b”).
Sourcepub fn ollama_size_for<'a>(&'a self, size: &'a str) -> &'a str
pub fn ollama_size_for<'a>(&'a self, size: &'a str) -> &'a str
Get the ollama size for a model size alias, with config override.
Sourcepub fn auto_approve(&self) -> bool
pub fn auto_approve(&self) -> bool
Check if auto-approve is enabled by default.
Sourcepub fn system_prompt(&self) -> Option<&str>
pub fn system_prompt(&self) -> Option<&str>
Get the default system prompt, if configured.
Sourcepub fn auto_provider(&self) -> Option<&str>
pub fn auto_provider(&self) -> Option<&str>
Get the auto-selection provider, if configured.
Sourcepub fn auto_model(&self) -> Option<&str>
pub fn auto_model(&self) -> Option<&str>
Get the auto-selection model, if configured.
Sourcepub fn listen_format(&self) -> Option<&str>
pub fn listen_format(&self) -> Option<&str>
Get the listen output format, if configured.
Sourcepub fn listen_timestamp_format(&self) -> &str
pub fn listen_timestamp_format(&self) -> &str
Get the listen timestamp format (strftime-style, default: “%H:%M:%S”).
Sourcepub fn get_value(&self, key: &str) -> Option<String>
pub fn get_value(&self, key: &str) -> Option<String>
Get a config value by dot-notation key. Get a config value by dot-notation key.
Sourcepub fn set_value(&mut self, key: &str, value: &str) -> Result<()>
pub fn set_value(&mut self, key: &str, value: &str) -> Result<()>
Set a config value by dot-notation key. Validates inputs.
Sourcepub fn unset_value(&mut self, key: &str) -> Result<()>
pub fn unset_value(&mut self, key: &str) -> Result<()>
Unset a config value by dot-notation key (revert to default).