systemprompt-config 0.56.0

Profile-based configuration for systemprompt.io AI governance infrastructure. Bootstraps profiles, secrets, and credentials with zero environment-variable fallback.
Documentation
//! Filesystem projection of a profile's `paths` block.
//!
//! [`AppPaths`] resolves the profile's system, web, build and storage roots
//! against the local filesystem — canonicalising, probing sibling build
//! directories, creating storage directories — so every consumer works from
//! absolute, verified paths. The pure vocabulary (`PathResolution`, the
//! directory and file name constants) stays in `systemprompt_models::paths`.
//!
//! Copyright (c) systemprompt.io — Business Source License 1.1.
//! See <https://systemprompt.io> for licensing details.

mod build;
mod error;
mod storage;
mod system;
mod web;

pub use build::BuildPaths;
pub use error::PathError;
pub use storage::StoragePaths;
pub use system::SystemPaths;
pub use web::WebPaths;

use std::path::Path;

use systemprompt_extension::AssetPaths;
use systemprompt_models::paths::PathResolution;
use systemprompt_models::profile::PathsConfig;

#[derive(Debug, Clone)]
pub struct AppPaths {
    system: SystemPaths,
    web: WebPaths,
    build: BuildPaths,
    storage: StoragePaths,
}

impl AppPaths {
    pub fn from_profile(
        paths: &PathsConfig,
        resolution: PathResolution,
        services_root_override: Option<&Path>,
    ) -> Result<Self, PathError> {
        let overridden = services_root_override.map(|root| paths.with_services_root(root));
        let paths = overridden.as_ref().unwrap_or(paths);
        Ok(Self {
            system: SystemPaths::from_profile(paths, resolution)?,
            web: WebPaths::from_profile(paths),
            build: BuildPaths::from_profile(paths),
            storage: StoragePaths::from_profile(paths)?,
        })
    }

    pub const fn system(&self) -> &SystemPaths {
        &self.system
    }

    pub const fn web(&self) -> &WebPaths {
        &self.web
    }

    pub const fn build(&self) -> &BuildPaths {
        &self.build
    }

    pub const fn storage(&self) -> &StoragePaths {
        &self.storage
    }
}

impl AssetPaths for AppPaths {
    fn storage_files(&self) -> &Path {
        self.storage.files()
    }

    fn web_dist(&self) -> &Path {
        self.web.dist()
    }
}