use std::path::Path;
pub fn detect(project: &str) -> Option<&'static str> {
if project.is_empty() {
return None;
}
let p = Path::new(project);
if p.join(".omc").is_dir() {
return Some("oh-my-claudecode");
}
if p.join(".omo").is_dir() {
return Some("oh-my-openagent");
}
None
}
#[cfg(test)]
mod tests {
use super::detect;
#[test]
fn empty_or_plain_project_is_unlabeled() {
assert_eq!(detect(""), None);
assert_eq!(detect("/tmp/sessionwiki-no-such-dir-xyz"), None);
}
#[test]
fn detects_omc_from_the_orchestration_dir() {
let base = std::env::temp_dir().join(format!("sw-omc-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&base);
std::fs::create_dir_all(base.join(".omc")).unwrap();
assert_eq!(detect(&base.to_string_lossy()), Some("oh-my-claudecode"));
let _ = std::fs::remove_dir_all(&base);
}
#[test]
fn discussing_a_harness_in_the_path_is_not_a_run() {
let base = std::env::temp_dir().join(format!("sw-oh-my-codex-talk-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&base);
std::fs::create_dir_all(&base).unwrap();
assert_eq!(detect(&base.to_string_lossy()), None);
let _ = std::fs::remove_dir_all(&base);
}
}