1use std::path::PathBuf;
8
9pub fn entity_root() -> Result<PathBuf, String> {
15 if let Ok(p) = std::env::var("RECALL_ECHO_HOME") {
16 return Ok(PathBuf::from(p));
17 }
18 std::env::current_dir().map_err(|e| format!("Could not determine working directory: {e}"))
19}
20
21pub fn memory_dir() -> Result<PathBuf, String> {
23 Ok(entity_root()?.join("memory"))
24}
25
26pub fn memory_file() -> Result<PathBuf, String> {
27 Ok(memory_dir()?.join("MEMORY.md"))
28}
29
30pub fn ephemeral_file() -> Result<PathBuf, String> {
31 Ok(memory_dir()?.join("EPHEMERAL.md"))
32}
33
34pub fn archive_index() -> Result<PathBuf, String> {
35 Ok(memory_dir()?.join("ARCHIVE.md"))
36}
37
38pub fn conversations_dir() -> Result<PathBuf, String> {
39 Ok(memory_dir()?.join("conversations"))
40}
41
42pub fn config_file() -> Result<PathBuf, String> {
43 Ok(memory_dir()?.join(".recall-echo.toml"))
44}
45
46pub fn claude_dir() -> Result<PathBuf, String> {
52 let home = dirs::home_dir().ok_or("Could not determine home directory")?;
53 Ok(home.join(".claude"))
54}
55
56pub fn detect_claude_code() -> Option<PathBuf> {
59 let home = dirs::home_dir()?;
60 let claude = home.join(".claude");
61 if claude.exists() {
62 Some(claude)
63 } else {
64 None
65 }
66}