Skip to content

next-theme-figma 0.7.0 / next-theme-dev 1.14.0: tokens.json manifest so Figma variables become theme settings - #58

Merged
next-devin merged 3 commits into
mainfrom
tokens-manifest
Sep 8, 2026
Merged

next-theme-figma 0.7.0 / next-theme-dev 1.14.0: tokens.json manifest so Figma variables become theme settings#58
next-devin merged 3 commits into
mainfrom
tokens-manifest

Conversation

@next-devin

Copy link
Copy Markdown
Contributor

Closes #56

What this adds

next-theme-figma 0.7.0

  • New handoff manifest tokens.json (schema next-theme-figma/tokens/v1, source: "figma-variables"), named in figma-handoff.json.manifests.tokens. Required by strict validation in implementation-handoff mode, a warning elsewhere, legacy v0 packages exempt: the same shape as geometry.json and copy.json. new-package writes the skeleton and pointer.
  • Each entry carries token_id, figma_name, type (color | dimension | font-size | radius | font-family), value, optional modes, both extraction sources in observed[] (variable_defs, design_context), and a target of kind theme-setting | css-custom-property | one-off | unmapped. theme-setting needs a setting_id; css-custom-property needs a css_var; an optional setting_value carries the option a select-typed setting receives.
  • validate-package refuses a wrong source or schema, duplicate ids, unparseable values (hex and functional colours by grammar, dimensions with units), malformed targets, and, for Spark packages, a value that is not an option of a Spark select setting. The PASS line appends tokens: N total, n theme-setting, n css-custom-property, n one-off, n unmapped; names: n canonical, n alias, n unknown.
  • Negative control: the same figma_name carrying two different values, whether across entries or between the two Figma sources, is a hard error in strict and non-strict mode: designer-input-needed: <name> carries two values (...). The validator never picks, averages, or drops a value.
  • Canonical Figma variable namespace with aliases in references/figma-contract.md and the new references/tokens-manifest.md, which also pins the Spark setting ids, types, options, and custom properties each token lands on (from Style settings for radius, spacing, border, page background and type scale (#56) spark#57). handoff-manifest.md lists the eleventh file; the designer checklist asks for variables, not detached hex.

next-theme-dev 1.14.0

  • Entry contract: tokens.json is reading-order row 9. New "Design Tokens From tokens.json" section routes by target.kind: theme-settingsettings_schema.json field + settings_data.json seed + a :root line using exactly {% if settings.x %}--var: {{ settings.x }};{% endif %} (never settings.* as a filter argument); css-custom-property → literal :root line; one-off → section CSS; unmapped → handback. Handback lines Tokens mapped to settings:, Tokens as custom properties:, Unmapped tokens:.
  • Step 3 takes its inputs from the manifest in implementation-handoff mode; the "Change Colors or Fonts" recipe no longer passes settings.* through a filter.

Proof

Fixture package, strict, and the negative controls (director-run against the final tree):

$ validate-package <complete fixture>   (strict)
[next-theme-figma] PASS (strict) with 0 warning(s); tokens: 7 total, 5 theme-setting, 1 css-custom-property, 0 one-off, 1 unmapped; names: 6 canonical, 0 alias, 1 unknown
exit 0

$ validate-package <same figma_name, two values>   (strict)
Error: tokens.json: designer-input-needed: color/text/primary carries two values (#0F172A from color.text.primary, #FFFFFF from color.text.alt); the designer must pick one, the manifest never averages or drops a value
exit 1

$ validate-package <same figma_name, two values> --non-strict
Error: tokens.json: designer-input-needed: color/text/primary carries two values (#0F172A from color.text.primary, #FFFFFF from color.text.alt); the designer must pick one, the manifest never averages or drops a value
exit 1

$ validate-package <variable_defs vs design_context disagree>   (strict)
Error: tokens.json: designer-input-needed: color/text/primary carries two values (#0F172A from variable_defs, #FFFFFF from design_context); the designer must pick one, the manifest never averages or drops a value
exit 1

$ validate-package <rgb(bogus)>   (strict)
Error: tokens.json: color.text.primary: value "rgb(bogus)" does not parse as color
exit 1

A tokens.json whose entire content is null now fails with tokens.json: manifest must be an object (a round-2 challenge finding). Dry Step 3 pass over the fixture, applying the dev-side contract mechanically: five tokens seed existing Spark settings (body_text_color, border_color, body_bg_color, section_padding=roomy, radius_control=8px), one lands as --primary-color (dashboard Branding wins), one is listed under Unmapped tokens:.

Verification

Built with the Fable → Codex build loop: each slice built by Codex, gate-reviewed by an independent Codex seat, and the validator slice challenged with a refusal-coverage packet (one real accept-that-should-refuse found and fixed: malformed functional colours; coverage gaps closed and re-reviewed). Full CI parity run locally: public-safety scan, catalog and version checks, syntax checks, and all unit suites green.

Follow-up

readJson returns null for a file whose JSON is literally null, and the geometry and copy validators then return silently the way the tokens validator did before round 2. Pre-existing, shared helper, not widened here; worth its own small issue.

Spark setting ids

Pinned at run time from the merged NextCommerceCo/spark#57 (configs/settings_schema.json and layouts/base.html on main), not assumed. Note the custom-property names differ from the original issue text: --control-radius, --card-radius, --heading-scale (a factor), --container-max.

🤖 Generated with Claude Code

…so Figma variables become theme settings

Implements #56.

next-theme-figma 0.7.0
- tokens.json (schema next-theme-figma/tokens/v1, source figma-variables) is the
  eleventh handoff file, named in figma-handoff.json.manifests.tokens. Required
  by strict validation in implementation-handoff mode, a warning elsewhere,
  legacy v0 exempt. new-package writes the skeleton and pointer.
- validate-package checks source and schema, unique ids, typed value parsing
  (hex and functional colours by grammar, dimensions with units), target shape
  (theme-setting needs setting_id, css-custom-property needs css_var), and for
  Spark packages that a value landing on a Spark select setting is one of its
  options (setting_value carries the option). PASS line appends the tokens
  counts by target kind and the canonical/alias/unknown name counts.
- Negative control: the same figma_name carrying two values, across entries or
  between the two Figma extraction sources, is a hard error in strict and
  non-strict mode reported as designer-input-needed with both values. The
  validator never picks, averages, or drops a value.
- references/tokens-manifest.md documents the schema, the canonical Figma
  variable namespace with aliases, the pinned Spark Style setting ids
  (NextCommerceCo/spark#57), value rules, and the two-source extraction.
  figma-contract.md carries the namespace; handoff-manifest.md and the designer
  checklist are updated. Fixtures gain a tokens manifest.

next-theme-dev 1.14.0
- Entry contract: tokens.json is reading-order row 9. "Design Tokens From
  tokens.json" routes by target.kind: theme-setting -> schema field + seed +
  :root line using {% if settings.x %}--var: {{ settings.x }};{% endif %}
  (never settings.* as a filter argument); existing Spark ids get the seed only;
  css-custom-property -> literal :root line; one-off -> section CSS; unmapped ->
  handback. Handback lines: Tokens mapped to settings / Tokens as custom
  properties / Unmapped tokens.
- Step 3 takes its inputs from the manifest in implementation-handoff mode; the
  Change Colors or Fonts recipe no longer passes settings.* through a filter.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread next-theme-figma/scripts/theme-figma.js
Comment thread next-theme-figma/scripts/theme-figma.js
Comment thread next-theme-dev/SKILL.md
@kilo-code-bot

kilo-code-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files in incremental diff)
  • next-theme-figma/scripts/theme-figma.js - 0 issues (previous normalizeFunctionalColor rgba/hsla-alpha-1 suggestion at line 1649 now fully resolved: index === 3 always emits a numeric string, and a trailing alpha of 1 (bare or 100%) is popped from the canonical form, so rgb(255,255,255)rgba(255,255,255,1), rgb(255 255 255 / 100%), and the hsl/hsla pair all normalise equal; genuinely different alphas such as 0.5 still conflict)
  • next-theme-figma/tests/test_tokens_manifest.py - 0 issues (new same triples cover the opaque-3-vs-4 and 1.0-alpha cases in both directions; the new different pair covers the conflict regression)
  • next-theme-figma/references/tokens-manifest.md - 0 issues (doc addition matches the new behaviour exactly)
Previous Review Summaries (2 snapshots, latest commit 9f43b98)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 9f43b98)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
next-theme-figma/scripts/theme-figma.js 1649 normalizeFunctionalColor still produces different canonical strings for rgb(...) vs rgba(...,1) (and hsl(...) vs hsla(...,1)), so a 3-component and an equivalent opaque-4-component spelling still flag as a false designer-input-needed conflict.

Previously reported, resolved in this push

  • theme-figma.js:1622normalizeTokenValue now canonicalises functional colours (comma/space, rgba→rgb, %-alpha) so CSS-equivalent spellings compare equal. ✅
  • theme-figma.js:1501target.setting_value is now a hard error on any non-theme-setting kind (setting_value is only meaningful for theme-setting targets), tested for unmapped, one-off, and css-custom-property. ✅
  • next-theme-dev/SKILL.md:269 — The :root DTL literal and the existing-Spark-id exception now sit in the same bullet so the rule reads in one place. ✅
Files Reviewed (4 files in incremental diff)
  • next-theme-figma/scripts/theme-figma.js - 1 new issue (suggestion), 2 prior issues resolved
  • next-theme-figma/tests/test_tokens_manifest.py - 0 issues (new test_functional_equivalent and the misrouted-setting_value subTests cover the fixes)
  • next-theme-figma/references/tokens-manifest.md - 0 issues
  • next-theme-dev/SKILL.md - 0 issues (prior suggestion resolved)

Fix these issues in Kilo Cloud

Previous review (commit cf82e7d)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

CRITICAL

File Line Issue
next-theme-figma/scripts/theme-figma.js 1619 normalizeTokenValue is whitespace- and comma-blind for functional colours, so CSS-equivalent values (rgb(1, 2, 3) vs rgb(1,2,3), hsl(120deg 50% 25%) vs hsl(120,50,50)) compare unequal and produce false designer-input-needed errors, contradicting the negative-control contract.

WARNING

File Line Issue
next-theme-figma/scripts/theme-figma.js 1501 target.setting_value is only type-checked. The validator accepts it on every target.kind (unmapped, one-off, css-custom-property) and silently no-ops, hiding misrouted tokens instead of flagging them.

SUGGESTION

File Line Issue
next-theme-dev/SKILL.md 269 The DTL literal pinned here matches the tokens.json contract verbatim, but the rule "do not add a :root line for an existing Spark setting id" lives in the next paragraph and is easy to miss. Consider merging into the same bullet.
Files Reviewed (19 files)
  • next-theme-figma/scripts/theme-figma.js - 2 issues
  • next-theme-dev/SKILL.md - 1 issue
  • next-theme-figma/SKILL.md - 0 issues
  • next-theme-figma/README.md - 0 issues
  • next-theme-dev/README.md - 0 issues
  • next-theme-figma/references/designer-checklist.md - 0 issues
  • next-theme-figma/references/figma-contract.md - 0 issues
  • next-theme-figma/references/handoff-manifest.md - 0 issues
  • next-theme-figma/references/tokens-manifest.md - 0 issues
  • next-theme-figma/tests/test_tokens_manifest.py - 0 issues (test coverage is broad; conflict detector whitespace gap is unaddressed)
  • next-theme-figma/tests/test_asset_contract.py - 0 issues
  • next-theme-figma/tests/test_geometry_manifest.py - 0 issues
  • next-theme-figma/tests/test_reference_files.py - 0 issues
  • next-theme-figma/tests/test_section_roster_validation.py - 0 issues
  • next-theme-figma/tests/fixtures/complete-package.json - 0 issues
  • next-theme-figma/tests/fixtures/contradiction-package.json - 0 issues
  • next-theme-figma/tests/fixtures/custom-vone-package.json - 0 issues
  • next-theme-figma/tests/fixtures/intro-vone-package.json - 0 issues
  • next-theme-figma/tests/fixtures/placeholder-package.json - 0 issues
  • next-theme-figma/tests/fixtures/spark-vone-package.json - 0 issues
  • next-theme-dev/tests/test_handoff_ingestion.py - 0 issues
  • next-theme-dev/tests/test_tokens_consumption.py - 0 issues
  • skills.json - 0 issues

Fix these issues in Kilo Cloud


Reviewed by minimax-m3 · Input: 21.9K · Output: 1.9K · Cached: 92.8K

… setting_value only on theme-setting, :root rule read in one place

Review follow-ups on the draft PR:
- normalizeTokenValue canonicalises functional colours (rgba->rgb, comma or
  space separation, percentage alpha) so CSS-equivalent spellings from the two
  Figma sources never raise a false designer-input-needed conflict; a genuinely
  different component still does.
- target.setting_value is now an error on any target kind other than
  theme-setting, so a misrouted token is visible instead of silently ignored.
- next-theme-dev: the existing-Spark-id exception sits in the same bullet as
  the :root DTL literal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread next-theme-figma/scripts/theme-figma.js
rgb(255,255,255) and rgba(255,255,255,1) are the same opaque colour and must
not raise a designer-input-needed conflict; a real alpha difference still does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

next-theme-figma / next-theme-dev: tokens.json manifest so Figma variables become theme settings

1 participant