use std::path::{Path, PathBuf};
pub fn default_copilot_dir() -> anyhow::Result<PathBuf> {
dirs::home_dir()
.map(|home| home.join(".copilot"))
.ok_or_else(|| anyhow::anyhow!("Could not determine home directory; provide --copilot-dir"))
}
pub fn session_store_path(copilot_dir: &Path) -> PathBuf {
copilot_dir.join("session-store.db")
}
pub fn session_state_dir(copilot_dir: &Path) -> PathBuf {
copilot_dir.join("session-state")
}
pub fn stats_cache_db_path(copilot_dir: &Path) -> PathBuf {
copilot_dir.join("remo-stats-cache.db")
}
#[cfg(test)]
mod tests {
use super::*;
use std::path::Path;
#[test]
fn test_child_paths_are_derived_from_copilot_dir() {
let base = Path::new("/tmp/custom-copilot");
assert_eq!(session_store_path(base), base.join("session-store.db"));
assert_eq!(session_state_dir(base), base.join("session-state"));
assert_eq!(stats_cache_db_path(base), base.join("remo-stats-cache.db"));
}
}