Skip to main content

agent_tools_interface/core/
dirs.rs

1use std::path::PathBuf;
2
3/// Resolve the ATI directory path.
4///
5/// Priority: ATI_DIR env var > $HOME/.ati > fallback to .ati
6pub fn ati_dir() -> PathBuf {
7    std::env::var("ATI_DIR")
8        .ok()
9        .map(PathBuf::from)
10        .unwrap_or_else(|| {
11            std::env::var("HOME")
12                .map(|h| PathBuf::from(h).join(".ati"))
13                .unwrap_or_else(|_| PathBuf::from(".ati"))
14        })
15}
16
17/// Map a duration unit string to seconds.
18///
19/// Supports both short and long forms:
20/// `"s"`, `"sec"`, `"second"` → 1
21/// `"m"`, `"min"`, `"minute"` → 60
22/// `"h"`, `"hr"`, `"hour"` → 3600
23/// `"d"`, `"day"` → 86400
24pub fn unit_to_secs(unit: &str) -> Option<u64> {
25    match unit {
26        "s" | "sec" | "second" => Some(1),
27        "m" | "min" | "minute" => Some(60),
28        "h" | "hr" | "hour" => Some(3600),
29        "d" | "day" => Some(86400),
30        _ => None,
31    }
32}