Expand description
§plumb-codegen
Source-tree token inference for Plumb. Walks a project directory,
discovers design-token sources (CSS custom properties, Tailwind
config files, DTCG token JSON), and bootstraps a best-effort
plumb_core::Config.
Consumers (plumb-cli’s init --from <path> command) call
infer_config to walk the tree and render_toml to serialize
the result. Both are deterministic: identical inputs produce
byte-identical output across runs and platforms.
§Inference sources (V0)
- CSS custom properties. Every
:root { --token: value; }declaration discovered undersrc/,styles/,app/, or the project root is classified by name into the spacing, color, radius, and type-scale buckets. Implementation lives inplumb_config::scrape_css_properties. - Tailwind config files. Presence of
tailwind.config.{js,ts, mjs,cjs,mts,cts}is recorded in the rendered TOML’s header comment so the user knows to wireextendsonce that landed. The crate never spawns Node; full Tailwind theme resolution is handled at lint time byplumb_config::merge_tailwind. - DTCG token JSON files. Files matching
*.tokens.jsonor placed under atokens/directory are merged viaplumb_config::merge_dtcg.
§Determinism contract
- Directory entries are sorted by their canonical UTF-8 path before recursion. The walker visits files in the same order on every filesystem.
- Scales (
spacing.scale,radius.scale,type.scale) are sorted ascending and deduplicated. - Tokens land in
indexmap::IndexMapin discovery order; insertion order is preserved by serde during TOML serialization. - The walker never reads
SystemTime/Instant. The error surface never carries a wall-clock value.
Structs§
- Inferred
Config - Result of walking a source tree. The
Configfield is populated with whatever tokens the inference passes were able to recover; thesummaryfield records, in stable order, what each pass discovered so the CLI can surface a one-line note per source. - Token
Source - One discovered token-source file.
Enums§
- Codegen
Error - Codegen errors.
- Token
Source Kind - Kind of a discovered token source. Used to drive both the renderer’s header comment and the per-source summary order.
Constants§
- MAX_
WALK_ DEPTH - Maximum directory depth the walker descends into the source tree.
Functions§
- infer_
config - Walk
source_dirand infer aplumb_core::Configfrom the design-token sources it finds. - render_
toml - Render
inferredto a TOML string.