Skip to content

Emitter: {component}.tokens.json #140

Description

@nathanacurtis

Summary

Add a {component}.tokens.json emitter to specs-cli that projects a validated component contract into a flat JSON file listing every design token referenced, with type metadata and a per-element usage map.

RFC

This emitter is specified in RFC 001: Component Dictionary — emitter group defaults, priority high, complexity trivial.

Flat list of every token referenced, with type and per-element usage map.

Sketch

rfc/001-component-dictionary/sketches/button.tokens.json

The sketch shows a { component, tokens[] } structure with slash-delimited token paths (including parametric patterns like pattern/size/control/{small|medium|large}/gap) and typography token references.

The RFC notes this emitter should carry richer metadata than the sketch currently shows — specifically $type and per-element usage map, similar in structure to what StylingInventory tracks per row (appliedTo: Map<string, number>). See specs-plugin-2/src/Output/StylingInventory/types.ts for the StylingInventoryRow shape as a reference for what that metadata looks like.

Acceptance criteria

  • Emitter registered under the defaults group
  • Every token path referenced in the contract is included
  • Each token entry includes $type metadata
  • Each token entry includes a per-element usage map (element name -> usage count)
  • Parametric token patterns (e.g. size scale variants) are represented accurately
  • Output is deterministic (same contract -> identical file)
  • Covered by unit tests using a fixture component

Metadata

Metadata

Assignees

No one assigned

    Labels

    clispecs-cli and MCP server

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions