feat: add IRONCLAW_BASE_DIR env var with LazyLock caching (#397)

This commit is contained in:
ibhagwan
2026-02-27 17:43:43 +04:00
committed by GitHub
parent a7c0be7f1b
commit c592a8f2de
26 changed files with 255 additions and 127 deletions
+2 -4
View File
@@ -2,6 +2,7 @@ use std::path::PathBuf;
use secrecy::SecretString;
use crate::bootstrap::ironclaw_base_dir;
use crate::config::helpers::{optional_env, parse_bool_env, parse_optional_env};
use crate::error::ConfigError;
use crate::settings::Settings;
@@ -193,8 +194,5 @@ impl ChannelsConfig {
/// Get the default channels directory (~/.ironclaw/channels/).
fn default_channels_dir() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("channels")
ironclaw_base_dir().join("channels")
}
+2 -4
View File
@@ -2,6 +2,7 @@ use std::path::PathBuf;
use secrecy::{ExposeSecret, SecretString};
use crate::bootstrap::ironclaw_base_dir;
use crate::config::helpers::{optional_env, parse_optional_env};
use crate::error::ConfigError;
@@ -123,8 +124,5 @@ impl DatabaseConfig {
/// Default libSQL database path (~/.ironclaw/ironclaw.db).
pub fn default_libsql_path() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("ironclaw.db")
ironclaw_base_dir().join("ironclaw.db")
}
+2 -3
View File
@@ -1,3 +1,4 @@
use crate::bootstrap::ironclaw_base_dir;
use crate::config::helpers::{parse_bool_env, parse_optional_env};
use crate::error::ConfigError;
@@ -41,9 +42,7 @@ impl HygieneConfig {
enabled: self.enabled,
retention_days: self.retention_days,
cadence_hours: self.cadence_hours,
state_dir: dirs::home_dir()
.unwrap_or_else(|| std::path::PathBuf::from("."))
.join(".ironclaw"),
state_dir: ironclaw_base_dir(),
}
}
}
+2 -4
View File
@@ -2,6 +2,7 @@ use std::path::PathBuf;
use secrecy::SecretString;
use crate::bootstrap::ironclaw_base_dir;
use crate::config::helpers::{optional_env, parse_optional_env};
use crate::error::ConfigError;
use crate::settings::Settings;
@@ -373,10 +374,7 @@ fn parse_extra_headers(val: &str) -> Result<Vec<(String, String)>, ConfigError>
/// Get the default session file path (~/.ironclaw/session.json).
fn default_session_path() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("session.json")
ironclaw_base_dir().join("session.json")
}
#[cfg(test)]
+3 -8
View File
@@ -1,5 +1,6 @@
use std::path::PathBuf;
use crate::bootstrap::ironclaw_base_dir;
use crate::config::helpers::{optional_env, parse_bool_env, parse_optional_env};
use crate::error::ConfigError;
@@ -34,18 +35,12 @@ impl Default for SkillsConfig {
/// Get the default user skills directory (~/.ironclaw/skills/).
fn default_skills_dir() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("skills")
ironclaw_base_dir().join("skills")
}
/// Get the default installed skills directory (~/.ironclaw/installed_skills/).
fn default_installed_skills_dir() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("installed_skills")
ironclaw_base_dir().join("installed_skills")
}
impl SkillsConfig {
+2 -4
View File
@@ -1,6 +1,7 @@
use std::path::PathBuf;
use std::time::Duration;
use crate::bootstrap::ironclaw_base_dir;
use crate::config::helpers::{optional_env, parse_bool_env, parse_optional_env};
use crate::error::ConfigError;
@@ -39,10 +40,7 @@ impl Default for WasmConfig {
/// Get the default tools directory (~/.ironclaw/tools/).
fn default_tools_dir() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("tools")
ironclaw_base_dir().join("tools")
}
impl WasmConfig {