harnessd 0.1.0

The harness daemon: API server (axum WS + REST), agent runtime host, and CLI (init/pair/doctor).
//! Filesystem locations for config and data.

use directories::ProjectDirs;
use std::path::PathBuf;

/// `ProjectDirs` for the harness. Falls back to the current dir if the platform has
/// no notion of a config dir (unlikely on macOS/Linux).
pub fn project_dirs() -> ProjectDirs {
    ProjectDirs::from("net", "harness", "harnessd")
        .expect("a home directory is required to locate the harness config")
}

/// Default config file path: `<config_dir>/harnessd.toml`.
pub fn default_config_path() -> PathBuf {
    project_dirs().config_dir().join("harnessd.toml")
}

/// Resolve a possibly-relative db path against the config directory.
pub fn resolve_db_path(db_path: &std::path::Path, config_path: &std::path::Path) -> PathBuf {
    if db_path.is_absolute() {
        db_path.to_path_buf()
    } else {
        config_path
            .parent()
            .unwrap_or_else(|| std::path::Path::new("."))
            .join(db_path)
    }
}