af-contracts 0.2.0

Generated Agent Factory Agent and Docs protobuf contracts.
Documentation
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?).join("proto");
    let manifest: serde_json::Value =
        serde_json::from_slice(&std::fs::read(root.join("contracts.json"))?)?;
    let files = manifest["contracts"]
        .as_array()
        .ok_or("contracts.json must contain contracts")?
        .iter()
        .map(|contract| {
            contract["path"]
                .as_str()
                .map(|path| root.join(path))
                .ok_or("contract path must be a string")
        })
        .collect::<Result<Vec<_>, _>>()?;
    for file in &files {
        println!("cargo:rerun-if-changed={}", file.display());
    }
    tonic_build::configure()
        .build_server(true)
        .build_client(true)
        .compile_protos(&files, &[root])?;
    Ok(())
}