mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-27 08:00:17 +00:00
feat: add IRONCLAW_BASE_DIR env var with LazyLock caching (#397)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user