Skip to main content

zenith_cli/library/
mod.rs

1//! Zenith library subsystem: pack format, registry, and resolver.
2//!
3//! A library "pack" is a `.zen` file whose IDENTITY is declared by a single
4//! `library` SELF-entry in its own `libraries` block, for example:
5//!
6//! ```kdl
7//! libraries { library id="@zenith/flowchart" version="1.0.0" }
8//! ```
9//!
10//! That entry's `id` is the package id and `version` is the pack version. A
11//! pack's ITEMS are its `components`, filter/mask `tokens`, and `actions`:
12//! item `decision` in pack `@zenith/flowchart` is addressed
13//! `@zenith/flowchart#decision`.
14//!
15//! PRESET packs are embedded in the binary via [`include_str!`] (see
16//! [`EMBEDDED_PACKS`]); PROJECT packs live in
17//! `<project_dir>/libraries/*.zen` and are scanned at runtime. Resolution order
18//! is project packs first, then embedded presets (a project pack shadows an
19//! embedded pack of the same id).
20//!
21//! This module contains pure pack-loading/registry logic only; the CLI command
22//! that consumes it lives in [`crate::commands::library`]. The submodules group
23//! by concern: `registry` (pack model + parse + resolve), `add` (shared
24//! materialization machinery), and one module per `materialize*` flavor
25//! (`component`, `token`, `action`).
26
27mod action;
28mod add;
29mod component;
30mod registry;
31mod token;
32
33#[cfg(test)]
34mod tests;
35
36// ── Public API (crate-internal callers in `commands::library` / `lib.rs`) ─────
37
38pub use registry::{
39    EMBEDDED_PACKS, ItemKind, LibraryPack, PackError, PackItem, PackSource, load_embedded_packs,
40    load_project_packs, parse_pack, resolve_packs,
41};
42
43pub use add::{AddError, AddOutcome, collect_all_ids, load_pack_document, parse_spec};
44
45pub use action::{ActionAddOutcome, materialize_action};
46pub use component::materialize;
47pub use token::{TokenAddOutcome, materialize_token};