1use std::path::PathBuf;
5
6pub const DEFAULT_SQLITE_PATH: &str = ".zeph/data/zeph.db";
10pub const DEFAULT_SKILLS_DIR: &str = ".zeph/skills";
12pub const DEFAULT_DEBUG_DIR: &str = ".zeph/debug";
14pub const DEFAULT_LOG_FILE: &str = ".zeph/logs/zeph.log";
16
17#[cfg(any(target_os = "macos", target_os = "windows"))]
18const PLATFORM_APP_DIR_NAME: &str = "Zeph";
19#[cfg(not(any(target_os = "macos", target_os = "windows")))]
20const PLATFORM_APP_DIR_NAME: &str = "zeph";
21
22pub(crate) fn default_runtime_data_root() -> PathBuf {
29 dirs::data_local_dir()
30 .or_else(dirs::data_dir)
31 .or_else(|| dirs::home_dir().map(|home| home.join(".local").join("share")))
32 .unwrap_or_else(|| PathBuf::from("."))
33 .join(PLATFORM_APP_DIR_NAME)
34}
35
36#[must_use]
45pub fn default_sqlite_path() -> String {
46 default_runtime_data_root()
47 .join("data")
48 .join("zeph.db")
49 .to_string_lossy()
50 .into_owned()
51}
52
53#[must_use]
57pub fn default_vault_dir() -> PathBuf {
58 if let Ok(xdg) = std::env::var("XDG_CONFIG_HOME") {
59 return PathBuf::from(xdg).join("zeph");
60 }
61 if let Ok(appdata) = std::env::var("APPDATA") {
62 return PathBuf::from(appdata).join("zeph");
63 }
64 let home = std::env::var("HOME").unwrap_or_else(|_| ".".to_owned());
65 PathBuf::from(home).join(".config").join("zeph")
66}
67
68#[must_use]
77pub fn default_skills_dir() -> String {
78 default_vault_dir()
79 .join("skills")
80 .to_string_lossy()
81 .into_owned()
82}
83
84#[must_use]
86pub fn default_debug_dir() -> PathBuf {
87 default_runtime_data_root().join("debug")
88}
89
90#[must_use]
99pub fn default_log_file_path() -> String {
100 default_runtime_data_root()
101 .join("logs")
102 .join("zeph.log")
103 .to_string_lossy()
104 .into_owned()
105}
106
107#[must_use]
109pub fn default_skill_paths() -> Vec<String> {
110 vec![default_skills_dir()]
111}
112
113pub(crate) fn default_log_file() -> String {
114 default_log_file_path()
115}
116
117#[must_use]
119pub fn default_sqlite_path_field() -> String {
120 default_sqlite_path()
121}
122
123pub(crate) fn default_debug_output_dir() -> PathBuf {
124 default_debug_dir()
125}
126
127#[must_use]
129pub fn is_legacy_default_sqlite_path(path: &str) -> bool {
130 path == DEFAULT_SQLITE_PATH
131}
132
133#[must_use]
135pub fn is_legacy_default_skills_path(path: &str) -> bool {
136 path == DEFAULT_SKILLS_DIR
137}
138
139#[must_use]
141pub fn is_legacy_default_debug_dir(path: &std::path::Path) -> bool {
142 path == std::path::Path::new(DEFAULT_DEBUG_DIR)
143}
144
145#[must_use]
147pub fn is_legacy_default_log_file(path: &str) -> bool {
148 path == DEFAULT_LOG_FILE
149}
150
151pub(crate) fn default_true() -> bool {
152 true
153}