Skip to main content

agent_policy/
lib.rs

1//! # agent-policy
2//!
3//! Schema-first generator for coding-agent repo policies and compatibility files.
4//!
5//! ## Usage
6//!
7//! ```no_run
8//! use camino::Utf8Path;
9//!
10//! let policy = agent_policy::load(Utf8Path::new("agent-policy.yaml"))
11//!     .expect("failed to load policy");
12//!
13//! println!("Project: {}", policy.project.name);
14//! ```
15//!
16//! ## Command-line interface
17//!
18//! See the [README](https://github.com/CameronBrooks11/agent-policy) for CLI documentation.
19
20#![deny(clippy::unwrap_used)]
21#![deny(clippy::expect_used)]
22#![warn(clippy::pedantic)]
23#![allow(clippy::module_name_repetitions)]
24
25pub mod cli;
26pub mod commands;
27pub mod error;
28pub mod load;
29pub mod model;
30pub mod render;
31pub(crate) mod util;
32
33pub use error::{Error, Result};
34pub use model::normalized::Policy;
35
36/// Load, validate, and normalize an `agent-policy.yaml` from a file path.
37///
38/// This is the main entry point for the entire load pipeline.
39///
40/// # Errors
41///
42/// Returns an [`Error`] if the file cannot be read, the YAML is invalid, the
43/// document fails schema validation, or normalization encounters invalid values.
44pub fn load(path: &camino::Utf8Path) -> Result<Policy> {
45    let raw = load::load_file(path)?;
46    model::normalize(raw)
47}