cellstate_pipeline/
lib.rs

1// Copyright 2024-2026 CELLSTATE Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4//! CELLSTATE Pipeline - Configuration Compiler (TOML + Markdown -> CompiledConfig)
5//!
6//! This crate is a **configuration compiler**, not a runtime or interpreter. It reads a TOML manifest
7//! (`cstate.toml`) and Markdown prompt files containing YAML fence blocks, then compiles
8//! them into a single `CompiledConfig` struct that the runtime consumes.
9//!
10//! # Module Layout
11//!
12//! - **[`pack`]** -- Canonical entry point. Call [`compose_pack()`] to compile a pack.
13//!   Orchestrates manifest parsing, Markdown extraction, IR construction, AST building,
14//!   and final compilation.
15//! - **[`ast`]** -- Shared AST type definitions (`CellstateAst`, `Definition`, etc.).
16//!   These types are the common language between `pack`, `config`, and `compiler`.
17//! - **[`config`]** -- YAML fence-block parsers (`parse_adapter_block`, etc.) and the
18//!   canonical Markdown printer (`ast_to_markdown`) for round-trip testing.
19//! - **[`compiler`]** -- Transforms a `CellstateAst` into a validated `CompiledConfig`.
20//! - **`pretty_print`** -- Convenience crate-level alias of `ast_to_markdown`.
21//!
22//! # Compilation Pipeline
23//!
24//! ```text
25//! cstate.toml + *.md files
26//!         |
27//!         v
28//!   pack::compose_pack()
29//!         |
30//!   +-----+------+
31//!   |            |
32//!   v            v
33//! TOML       Markdown
34//! Manifest   Fence Blocks
35//!   |            |
36//!   +-----+------+
37//!         |
38//!         v
39//!     PackIr (intermediate representation)
40//!         |
41//!         v
42//!     CellstateAst (ast types)
43//!         |
44//!         v
45//!     PipelineCompiler::compile()
46//!         |
47//!         v
48//!     CompiledConfig (runtime-ready)
49//! ```
50
51pub mod ast;
52pub mod compiler;
53pub mod config;
54pub mod pack;
55
56// Re-export key types for convenience
57pub use ast::*;
58pub use compiler::*;
59pub use config::ast_to_markdown as pretty_print;
60pub use config::{
61    ast_to_markdown, parse_adapter_block, parse_agent_block, parse_cache_block,
62    parse_injection_block, parse_intent_block, parse_memory_block, parse_policy_block,
63    parse_provider_block, parse_trajectory_block, ConfigError,
64};
65pub use pack::{compose_pack, PackError, PackInput, PackMarkdownFile, PackOutput};