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
@@ -14,6 +14,7 @@ use async_trait::async_trait;
use chrono::Utc;
use uuid::Uuid;
use crate::bootstrap::ironclaw_base_dir;
use crate::channels::IncomingMessage;
use crate::channels::web::types::SseEvent;
use crate::context::{ContextManager, JobContext, JobState};
@@ -554,10 +555,7 @@ fn validate_env_var_name(name: &str) -> Result<(), ToolError> {
}
fn projects_base() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("projects")
ironclaw_base_dir().join("projects")
}
/// Resolve the project directory, creating it if it doesn't exist.
+2 -3
View File
@@ -8,6 +8,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use tokio::sync::RwLock;
use crate::bootstrap::ironclaw_base_dir;
use crate::channels::{ChannelManager, OutgoingResponse};
use crate::context::JobContext;
use crate::tools::tool::{
@@ -27,9 +28,7 @@ pub struct MessageTool {
impl MessageTool {
pub fn new(channel_manager: Arc<ChannelManager>) -> Self {
let base_dir = dirs::home_dir()
.unwrap_or_else(|| std::path::PathBuf::from("."))
.join(".ironclaw");
let base_dir = ironclaw_base_dir();
Self {
channel_manager,
+2 -4
View File
@@ -9,6 +9,7 @@ use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use tokio::fs;
use crate::bootstrap::ironclaw_base_dir;
use crate::tools::tool::ToolError;
/// Configuration for connecting to a remote MCP server.
@@ -251,10 +252,7 @@ impl From<ConfigError> for ToolError {
/// Get the default MCP servers configuration path.
pub fn default_config_path() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ironclaw")
.join("mcp-servers.json")
ironclaw_base_dir().join("mcp-servers.json")
}
/// Load MCP server configurations from the default location.