Skip to content

feat(map-tokens): kind-scope the candidate list in the prompt - #201

Merged
Tyler Pina (tylerpina) merged 1 commit into
integ-4683-token-optionsfrom
integ-4801-kind-scope-map-tokens-prompt
Sep 4, 2026
Merged

feat(map-tokens): kind-scope the candidate list in the prompt#201
Tyler Pina (tylerpina) merged 1 commit into
integ-4683-token-optionsfrom
integ-4801-kind-scope-map-tokens-prompt

Conversation

@tylerpina

Copy link
Copy Markdown
Contributor

Summary

  • The map tokens step's prompt gave every design-token prop the entire DTCG token tree as candidates, regardless of the prop's own $token.kind — a color prop saw spacing, typography, and every other tier too. That's noise on every run and a truncation risk on real libraries where each token category is separately populated.
  • The token path index is now split into one section per $token.kind present among the CDF's design-token props, each scoped to tokens of that type only, and flattened to one path · type line per candidate instead of a nested JSON array — legible and countable. A prop with no $token.kind still falls back to the full, unscoped tree, unchanged from before.
  • Candidate ordering within a section is sorted by path for deterministic output on repeated runs over identical input.
  • No change to apply.ts, the map_token_prop contract, or the CDF schema — this only reshapes what the agent sees before it decides.

Test plan

  • Added tests in prompt-builder.test.ts: kind-scoping excludes other kinds, a prop with no $token.kind falls back to the full tree, multiple distinct kinds render separate sections, and a determinism check (identical input produces a byte-identical prompt across repeated calls).
  • Full experience-design-system-generation suite passes (152 tests).
  • Full experience-design-system-cli suite passes against a freshly rebuilt dist (3234 tests) — the CLI's map-tokens integration tests spawn the compiled binary, so this exercises the change end-to-end, not just the unit tests.

@bito-code-review

bito-code-review Bot commented Sep 1, 2026

Copy link
Copy Markdown

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at michael.pearce@contentful.com.

@tylerpina
Tyler Pina (tylerpina) force-pushed the integ-4801-kind-scope-map-tokens-prompt branch from 513e37f to 89d8974 Compare September 2, 2026 21:18
Every design-token prop received the full DTCG token tree as candidates,
regardless of its own $token.kind — noise on every run and a truncation
risk on real libraries where colors, spacing, and typography are all
populated separately.

The token path index is now split into one section per $token.kind
present among the CDF's design-token props, each containing only tokens
of that type, flattened to one path · type line per candidate instead
of a nested JSON array. A prop with no $token.kind still falls back to
the full, unscoped tree — unchanged from before.

No change to apply.ts, the map_token_prop contract, or the CDF schema —
this only reshapes what the agent sees before it decides.
@tylerpina
Tyler Pina (tylerpina) force-pushed the integ-4801-kind-scope-map-tokens-prompt branch from 89d8974 to c467563 Compare September 3, 2026 23:59
@tylerpina
Tyler Pina (tylerpina) marked this pull request as ready for review September 4, 2026 21:08
@tylerpina
Tyler Pina (tylerpina) requested a review from a team as a code owner September 4, 2026 21:08
@tylerpina
Tyler Pina (tylerpina) merged commit 1479d78 into integ-4683-design-token-auto-binding-m1 Sep 4, 2026
8 checks passed
@tylerpina
Tyler Pina (tylerpina) deleted the integ-4801-kind-scope-map-tokens-prompt branch September 4, 2026 21:09
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.

1 participant