tsx_forge/lib.rs
1//! **forge** — 4-tier code generation engine for the tsx Framework Protocol.
2//!
3//! ## Overview
4//!
5//! `forge` is built on [Tera](https://keats.github.io/tera/) and extends it with:
6//!
7//! - **4-tier template hierarchy** — `Atom → Molecule → Layout → Feature`
8//! (classified automatically from template paths)
9//! - **Import hoisting** — templates call `{{ "import x from 'x'" | collect_import }}`
10//! and `{{ render_imports() }}` at the top of the file to emit a deduplicated import block.
11//! - **Token-budget metadata** — knowledge `.md` files carry `token_estimate` in frontmatter
12//! so agents can request exactly as much context as they need.
13//! - **Framework package loading** — load templates from disk, embedded bytes, or npm packages.
14//!
15//! ## Quick Start
16//!
17//! ```rust
18//! use forge::{Engine, ForgeContext};
19//!
20//! let mut engine = Engine::new();
21//! engine.add_raw("hello.jinja", "Hello {{ name | pascal_case }}!").unwrap();
22//!
23//! let ctx = ForgeContext::new().insert("name", "world");
24//! let out = engine.render("hello.jinja", &ctx).unwrap();
25//! assert_eq!(out, "Hello World!");
26//! ```
27
28pub mod collector;
29pub mod context;
30pub mod engine;
31pub mod error;
32pub mod filters;
33pub mod metadata;
34pub mod provide;
35pub mod slots;
36pub mod tier;
37
38pub use context::ForgeContext;
39pub use engine::Engine;
40pub use error::ForgeError;
41pub use metadata::{parse as parse_frontmatter, FrontMatter};
42pub use tier::Tier;