nuif-figcraft-variables-0 FigCraft variables host profile
Status: experimental executable profile in crates/nuif-figcraft, checked by
cargo xtask gate-figcraft. Directions: import (snapshot to NUIF) and export
(NUIF to a command plan). Tested host: figcraft-cli 0.18.1. It maps FigCraft
variables onto RFC 0015 token collections and needs no FigCraft source change.
Host surfaces
- Snapshot: the result object of the
variable.listcommand, as returned byfigcraft-cli runor the MCP server.adapters/figcraft/fixtures/variables-list.jsonis a synthetic snapshot captured fromfigcraft-cli 0.18.1. - Plan: a JSON step list for
figcraft-cli runor MCPbatch, applied by the host as one all-or-nothing undo step. Steps usevariable.createCollection,variable.renameCollection,variable.deleteCollection,variable.addMode,variable.renameMode,variable.moveMode,variable.removeMode,variable.create,variable.set,variable.updateandvariable.delete, withas/$reffor objects created in the same plan.
Mapping
| FigCraft | NUIF |
|---|---|
| collection, ordered modes (index 0 default) | TokenCollection, ordered TokenModes |
color variable | color token |
number variable whose scopes are non-empty and all dimensional (CORNER_RADIUS, WIDTH_HEIGHT, GAP, stroke, effect and text-size scopes) | dimension token |
other number variable | number token |
string, boolean variable | string, boolean token |
alias value | alias (PropertyValue::Token) |
| value equal to the default-mode value | omitted mode value |
FigCraft stores colour components and numbers as f32. A stored component
that is the f32 of byte / 255 maps to exactly byte / 255; any other
stored value maps to the shortest decimal that round-trips its f32. Plans
send the real; a value whose f32 does not map back to the same real is
refused as unrepresentable. Created dimension variables receive the scopes
CORNER_RADIUS, WIDTH_HEIGHT and GAP; created variables receive
codeSyntax.WEB = var(--name).
Identity
VariablesCorrespondence maps host collection, mode and variable ids to NUIF
ids and is persisted by the caller. Host objects without a correspondence get
SHA-256-derived ids; import_snapshot_with returns the correspondence it
used. link_correspondence links an existing file without one: collections
and modes by name, variables in a linked collection by
codeSyntax.WEB = var(--name), else by name, unique matches only, with a
report of unmatched and ambiguous names. A plan assigns placeholder ids to
created objects; bind_results replaces them with the ids returned by the
applied steps and the post-apply snapshot. VariablesCorrespondence::remap
applies ids assigned by another adapter, such as the new-token remapping of
nuif_css_tokens::synchronize_sources.
Options
HostOptions (all false by default):
names_from_code_syntax: token names come fromcodeSyntax.WEBwhen present; plans maintaincodeSyntax.WEBinstead of renaming host variables.retain_unmanaged: host collections and variables absent from the document stay untouched instead of being refused.allow_deletions: host collections, modes and variables absent from the document are deleted.resolved_values: an existing host variable is set only where its resolved value differs, and then to the resolved literal; the host’s own alias structure is kept elsewhere. Verification compares resolved values.skip_unlinked: tokens without a linked host variable are not created.
Planning
Existing collections are renamed, and their modes renamed, added (values copy
the default mode as FigCraft does) and reordered as needed; existing variables
are renamed (or receive codeSyntax.WEB) and updated per mode; missing
collections and variables are created. Every plan is applied to a simulated
copy of the snapshot and re-imported; it is returned only when the re-import
equals the document (or, with resolved_values or skip_unlinked, when every
planned token resolves to the same literal in every mode). Deletions that
would leave dangling aliases are refused by the simulation.
Unsupported and refused
Not imported, with an unsupported fidelity entry, and left untouched in the
host: colorAlpha and colorMix calculations, unknown value or variable
types, values that do not match the variable type, and aliases to such
variables. Descriptions are reported unsupported and retained in the host.
Plans refuse documents with entities, mode selections or flat tokens, type
changes, unrepresentable values, and host objects absent from the document
unless retain_unmanaged or allow_deletions is set. Collections and
variables copied from a library (ids <library>:VariableID:…) are read-only in
the consuming file: a plan that would change one is refused and names it;
plan against the library’s own file, publish it, and accept the update in the
consuming files (library.publish, library.acceptUpdates).
Command line
nuif figcraft import --snapshot list.json --output host.nuif.json \
[--correspondence c.json] [--options o.json] [--correspondence-out c2.json] [--report r.json]
nuif figcraft link --document tokens.nuif.json --snapshot list.json \
--correspondence-out c.json [--report r.json]
nuif figcraft plan --document tokens.nuif.json --snapshot list.json \
--script script.json --plan plan.json [--correspondence c.json] [--options o.json]
figcraft-cli run script.json --in design.figcraft --out design.figcraft > run.jsonl
nuif figcraft bind --plan plan.json --results run.jsonl --after list-after.json \
--correspondence-out c.json
nuif figcraft remap --correspondence c.json --remapped remapped.json \
--correspondence-out c2.json
A snapshot file may be the variable.list result object or a
figcraft-cli run output line whose result is one.
Limits
16 MiB snapshot, 256 collections, 64 modes per collection, 4,096 variables; duplicate host ids and variables naming missing collections are refused.
Evidence
crates/nuif-figcraft/src/tests.rs: exactf32canonicalization; import of the captured CLI snapshot with independent expected values; CSS to plan to simulated host to NUIF with canonical-hash equality; an empty plan for an unchanged document; a host edit synchronizing to one CSS span edit; linking bycodeSyntaxand name; retained, refused and deleted unmanaged data; collection rename and mode rename, addition and reordering; resolved-value and link-only plans; refused library-copy writes; refusals and hostile snapshots.figcraft-variables-trialapplies plans with the realfigcraft-cli runin four scenarios: create with hash equality and an empty no-op plan; a host edit synchronized to one CSS edit; a host-created variable inserted into the CSS with id remapping; and linking an existing designer file (other names, a missing mode, unmanaged collections) with an empty follow-up plan.gate-figcraftruns it whenNUIF_FIGCRAFT_CLIis set. Local runs withfigcraft-cli 0.18.1on macOS passed on 2026-11-20. CI runs it onmacos-15with the release pinned and SHA-256-verified bytools/figcraft/install-figcraft-cli.shagainsttools/figcraft/figcraft-cli.lock.json; no hosted run has been retained yet.