tsx-forge 0.1.0

4-tier code generation engine for the tsx Framework Protocol
Documentation

forge — 4-tier code generation engine for the tsx Framework Protocol.

Overview

forge is built on Tera and extends it with:

  • 4-tier template hierarchyAtom → Molecule → Layout → Feature (classified automatically from template paths)
  • Import hoisting — templates call {{ "import x from 'x'" | collect_import }} and {{ render_imports() }} at the top of the file to emit a deduplicated import block.
  • Token-budget metadata — knowledge .md files carry token_estimate in frontmatter so agents can request exactly as much context as they need.
  • Framework package loading — load templates from disk, embedded bytes, or npm packages.

Quick Start

use forge::{Engine, ForgeContext};

let mut engine = Engine::new();
engine.add_raw("hello.jinja", "Hello {{ name | pascal_case }}!").unwrap();

let ctx = ForgeContext::new().insert("name", "world");
let out = engine.render("hello.jinja", &ctx).unwrap();
assert_eq!(out, "Hello World!");