systemprompt-models 0.27.0

Foundation data models for systemprompt.io AI governance infrastructure. Shared DTOs, config, and domain types consumed by every layer of the MCP governance pipeline.
Documentation
//! Well-known directory layout helpers.
//!
//! [`AppPaths`] resolves the system, web, build, and storage path trees
//! from a profile's [`crate::profile::PathsConfig`]. Submodules expose
//! each tree plus shared directory/file-name constants.
//! Resolution returns [`PathError`].
//!
//! Copyright (c) systemprompt.io — Business Source License 1.1.
//! See <https://systemprompt.io> for licensing details.

pub(crate) mod build;
pub mod constants;
mod error;
mod storage;
mod system;
mod web;

pub use build::BuildPaths;
pub use constants::{cloud_container, dir_names, file_names};
pub use error::PathError;
pub use storage::StoragePaths;
pub use system::SystemPaths;
pub use web::WebPaths;

use std::path::Path;

use crate::profile::PathsConfig;
use systemprompt_extension::AssetPaths;

/// How profile paths are resolved against the local filesystem. Derive the
/// right mode for a profile with [`crate::profile::Profile::path_resolution`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PathResolution {
    Canonicalize,
    /// Take absolute paths verbatim without touching the filesystem.
    Lexical,
}

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

impl AppPaths {
    pub fn from_profile(
        paths: &PathsConfig,
        resolution: PathResolution,
    ) -> Result<Self, PathError> {
        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()
    }
}