use std::path::PathBuf;
pub const ACTIVE: &str = "DEJAVU_ACTIVE";
pub const BIN: &str = "DEJAVU_BIN";
pub const REPO_ROOT: &str = "DEJAVU_REPO_ROOT";
pub const CACHE_DIR: &str = "DEJAVU_CACHE_DIR";
pub const SESSION_ID: &str = "DEJAVU_SESSION_ID";
pub const SHIM_DIR: &str = "DEJAVU_SHIM_DIR";
pub const MODE: &str = "DEJAVU";
pub const DISABLED: &str = "DEJAVU_DISABLED";
pub const ORIG_ZDOTDIR: &str = "DEJAVU_ORIG_ZDOTDIR";
pub fn is_disabled() -> bool {
let legacy_flag = std::env::var_os(DISABLED).is_some_and(|v| v == "1");
let mode_off = std::env::var_os(MODE).is_some_and(|v| {
matches!(
v.to_string_lossy().to_ascii_lowercase().as_str(),
"off" | "0" | "false" | "disabled"
)
});
legacy_flag || mode_off
}
pub fn is_active() -> bool {
std::env::var_os(ACTIVE).is_some_and(|v| v == "1")
}
#[derive(Debug, Clone)]
pub struct AgentEnv {
pub bin: PathBuf,
pub repo_root: PathBuf,
pub cache_dir: PathBuf,
pub session_id: String,
pub shim_dir: PathBuf,
}
impl AgentEnv {
pub fn from_current() -> Option<AgentEnv> {
Some(AgentEnv {
bin: std::env::var_os(BIN)?.into(),
repo_root: std::env::var_os(REPO_ROOT)?.into(),
cache_dir: std::env::var_os(CACHE_DIR)?.into(),
session_id: std::env::var_os(SESSION_ID)?.to_string_lossy().into_owned(),
shim_dir: std::env::var_os(SHIM_DIR)?.into(),
})
}
}