Expand description
Cookbook engine for SIM: runnable, crate-local tutorial recipes.
A recipe is a tiny lesson – a runnable setup (in Lisp or any registered codec) plus a purpose document – that ships inside the crate it teaches. When a lib loads, it registers its recipes as Card records; the cookbook is then a projection over those cards, grouped into books and chapters and rendered by every surface (CLI, WebUI, browse, agent).
This crate owns the kernel-free cookbook engine: manifest parsing and lint,
compile-time embedding, recipe stores, projection/search/next behavior, and
deterministic user overlays. Runtime operations live in sim-lib-cookbook;
the CLI, WebUI, browse/help, and agent surfaces all use that shared runtime
projection instead of parallel cookbook logic.
Structs§
- Book
Manifest - Parsed
book.toml. - Book
View - One book (all recipes from one crate) in a
CookbookView. - Chapter
Manifest - Parsed
chapter.toml(every field optional). - Chapter
View - One chapter within a
BookView. - Check
Result - The result of checking one
Expectationafter a run. - Cookbook
View - The full computed cookbook: every loaded recipe grouped into books.
- Diagnostic
- One problem found while linting recipe files on disk.
- Expectation
- One declared expectation, turning a recipe into a generated test.
- Overlay
Directives - Parsed
overlay.tomldirectives. - Recipe
Card - The in-memory record for one recipe. Registered as a Card of kind
"recipe"; the cookbook view is a projection over these. - Recipe
Manifest - Parsed
recipe.toml. - Recipe
Run - The outcome of running a recipe’s setup through its codec.
- Recipe
Store - A registry of loaded recipe cards, keyed by their globally unique id.
Enums§
- Recipe
Source - Where a recipe came from.
- Toml
Value - A scalar or string-array value from a manifest line.
Constants§
- DEFAULT_
ORDER - Default sort key when
orderis omitted.
Functions§
- apply_
directives - Apply directives to a store: hide removes, reorder sets
order, retitle setstitle. Directives naming an unknown recipe are ignored (the overlay may reference recipes from libs not currently loaded). - generate_
embed_ code - Walk
recipes_rootand return the Rust source for ancrate::EmbeddedDirliteral: a sorted&[(rel-path, include_bytes!(abs-path))]. A missing or empty directory yields an empty slice. - lint_
dir - Lint one recipe directory on disk: parse
recipe.toml, confirm the declared setup and purpose files exist, and that required fields are present. Returns every problem found, so an author sees all errors at once. - load_
overlay - Load the overlay at
rootintostore: upsert any overlay recipes (so they override crate recipes by id and merge into matching books), then apply theoverlay.tomldirectives. A missing directory is a no-op. - next
- The recipe immediately after
idin global order, for “continue” buttons.Noneifidis unknown or is the last recipe. - ordered_
cards - All cards in deterministic global order: by book order then id, chapter order then name, recipe order then id. Two recipes never compare equal because ids are unique, so the order is total and stable.
- parse_
book - Parse and validate
book.tomltext. - parse_
chapter - Parse
chapter.tomltext (all fields optional). - parse_
overlay - Parse
overlay.tomltext into directives. - parse_
recipe - Parse and validate
recipe.tomltext. - recipes_
from_ embedded - Parse an embedded
recipes/tree into recipe cards (unsorted; the cookbook view applies ordering). Returns an error string on the first malformed manifest, missing file, or non-UTF-8 purpose document. - search
- Rank recipes matching
query(case-insensitive). A title match scores highest, then a tag match, then a purpose match; scores add. Recipes that match nothing are dropped. Ties keep deterministic global order. - view
- Group the store’s cards into the nested
CookbookView. - write_
embed - Generate the embed slice and write it to
$OUT_DIR/cookbook_recipes.rs.recipes_subdiris relative to$CARGO_MANIFEST_DIR. Intended for use from a crate’sbuild.rs.
Type Aliases§
- Embedded
Dir - A crate’s embedded
recipes/tree:(path-relative-to-recipes, bytes). Paths use/separators. Produced at build time (seecrate::generate_embed_code).