use std::path::{Path, PathBuf};
pub fn pitboss_dir(workspace: impl AsRef<Path>) -> PathBuf {
workspace.as_ref().join(".pitboss")
}
pub fn play_dir(workspace: impl AsRef<Path>) -> PathBuf {
pitboss_dir(workspace).join("play")
}
pub fn grind_dir(workspace: impl AsRef<Path>) -> PathBuf {
pitboss_dir(workspace).join("grind")
}
pub fn grind_prompts_dir(workspace: impl AsRef<Path>) -> PathBuf {
grind_dir(workspace).join("prompts")
}
pub fn home_grind_prompts_dir(home: impl AsRef<Path>) -> PathBuf {
home.as_ref().join(".pitboss").join("grind").join("prompts")
}
pub fn grind_rotations_dir(workspace: impl AsRef<Path>) -> PathBuf {
grind_dir(workspace).join("rotations")
}
pub fn grind_runs_dir(workspace: impl AsRef<Path>) -> PathBuf {
grind_dir(workspace).join("runs")
}
pub fn grind_run_dir(workspace: impl AsRef<Path>, run_id: &str) -> PathBuf {
grind_runs_dir(workspace).join(run_id)
}
pub fn config_path(workspace: impl AsRef<Path>) -> PathBuf {
pitboss_dir(workspace).join("config.toml")
}
pub fn plan_path(workspace: impl AsRef<Path>) -> PathBuf {
play_dir(workspace).join("plan.md")
}
pub fn deferred_path(workspace: impl AsRef<Path>) -> PathBuf {
play_dir(workspace).join("deferred.md")
}
pub fn state_path(workspace: impl AsRef<Path>) -> PathBuf {
play_dir(workspace).join("state.json")
}
pub fn play_logs_dir(workspace: impl AsRef<Path>) -> PathBuf {
play_dir(workspace).join("logs")
}
pub fn play_snapshots_dir(workspace: impl AsRef<Path>) -> PathBuf {
play_dir(workspace).join("snapshots")
}
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
#[test]
fn layout_is_nested_under_pitboss_dir() {
let ws = PathBuf::from("/tmp/ws");
assert_eq!(pitboss_dir(&ws), ws.join(".pitboss"));
assert_eq!(play_dir(&ws), ws.join(".pitboss/play"));
assert_eq!(grind_dir(&ws), ws.join(".pitboss/grind"));
assert_eq!(grind_prompts_dir(&ws), ws.join(".pitboss/grind/prompts"));
assert_eq!(
grind_rotations_dir(&ws),
ws.join(".pitboss/grind/rotations")
);
assert_eq!(grind_runs_dir(&ws), ws.join(".pitboss/grind/runs"));
assert_eq!(
grind_run_dir(&ws, "20260501T000000Z"),
ws.join(".pitboss/grind/runs/20260501T000000Z")
);
let home = PathBuf::from("/home/u");
assert_eq!(
home_grind_prompts_dir(&home),
home.join(".pitboss/grind/prompts")
);
assert_eq!(config_path(&ws), ws.join(".pitboss/config.toml"));
assert_eq!(plan_path(&ws), ws.join(".pitboss/play/plan.md"));
assert_eq!(deferred_path(&ws), ws.join(".pitboss/play/deferred.md"));
assert_eq!(state_path(&ws), ws.join(".pitboss/play/state.json"));
assert_eq!(play_logs_dir(&ws), ws.join(".pitboss/play/logs"));
assert_eq!(play_snapshots_dir(&ws), ws.join(".pitboss/play/snapshots"));
}
}