Repository navigation
Description
Problem
npm run xds -- docs theme --dense outputs 12.5 KB / 308 lines covering HCT color models, derived variable registries, cascade layers, color scale expansion, motion curves, and type scale math. AI coding agents that read this doc to learn defineTheme() routinely abandon XDS components and fall back to raw CSS.
Evidence from Monotelier benchmarks
The Monotelier benchmark builds an ASCII art canvas editor across 6 frontend stacks. XDS (source) compliance scores are highly variable, and the variance tracks whether the agent reads the theme docs:
| Run | Agent read theme docs? | Compliance | Anti-patterns | Outcome |
|---|---|---|---|---|
| run-009 | No (guessed) | 94% | 0 | Used defineTheme({ name }) minimally, stayed on track |
| run-011 | Yes (--dense) | 45% | 74 | Overwhelmed by HCT details, abandoned XDS components |
| run-012 | Yes (--dense) | 20% | 70 | Same — total design system abandonment |
The theme doc is the single strongest predictor of framework compliance in XDS benchmarks. Every run where the agent reads it scores below 50%. Every run where the agent skips it scores above 70%.
Root cause
The dense theme doc includes information the agent doesn't need to use defineTheme():
- HCT color model theory (agents just need
[light, dark]tuples) - Derived variable registries (internal implementation)
- Cascade layer architecture (internal implementation)
- Color scale expansion math (agents don't build color scales)
- Motion curve definitions (not needed for basic theming)
This burns the agent's context budget. By the time it reaches actual component code, the relevant guidance has either decayed from context or the agent has been spooked into hand-rolling everything.
Comparison with other frameworks
MUI and Ant Design score 90-95% consistently because their theming APIs (createTheme({ palette: {...} }), ConfigProvider theme={{ algorithm: darkAlgorithm }}) are in the LLM's training data. The agent doesn't need to read docs — it already knows the API shape.
XDS's defineTheme() is proprietary — the agent MUST read docs. When those docs dump architecture internals alongside the API, it backfires.
Proposed fix
Add a docs theme --api or docs theme --brief flag that returns only the API surface:
defineTheme({ name, tokens, base? })signature- Token naming convention (
--color-*, --spacing-*, --radius-*, etc.) [light, dark]tuple format- 1-2 complete examples
- ~2-3 KB / ~60 lines
Leave --dense as-is for humans building production themes. Add the new flag for AI agent consumption, and document it in working-with-ai.doc.mjs as the recommended path over --dense for theming.
Prior art
The Monotelier project ships a 2.8 KB / 79 line THEMING.md reference that consistently produces 96% compliance when agents read it instead of docs theme --dense. This could serve as a template for what the --api output should look like.
Activity
josephfarina commentedon Jul 20, 2026
Picking this up — status + plan.
#3891 (reference-doc
--dense/--zhscramble) and #3892 (component-doc prop-drop, merged) fix real overlay-correctness bugs, but neither touches the size concern this issue is about, so keeping this open for that.On size: I compared the ~16KB
docs theme --denseagainst a ~3KB lean version on both a basic and a hard theming task (custom theme extending a base + component overrides + a custom variant + light/dark). The lean doc was capability-equivalent — real API,extends, overrides, custom variants, and light/dark tuples all at 100%, with nothing dropped. A lean--denseis safe.Two honesty notes:
--dense→ ~20%, guessing → ~94%." In my runs, no-docs was the worst (agents inventcreateTheme/ThemeProviderand hardcode values); any docs (even scrambled) produced correct real-API usage. So the win from a lean doc is ~80% token savings, not a compliance rescue.Plan:
--denseemit lean, curated output for reference docs + add a--detail minimallevel; keep leanness a renderer concern, not encoded per-doc.josephfarina commentedon Jul 20, 2026
Design refinement for the overlay/size work (from digging into #3891):
#3891 fixes overlay drift at the section level (anchor by
section:name), but content blocks within a section are still matched by array position (content: [null, null, {prose}]) — the same bug class one level down. Reorder or insert a base block and the prose override lands on the wrong one.Durable design we'll build on top:
ids in the canonical docs; overlays key overrides byid, not array position (the block-level analog of 3891's section anchoring). Removes thenullarrays.--densevariant on each block —{ id, type, text, dense }— so the compressed form lives next to its source and can't drift. This deletes the parallel*.doc.dense.mjsfiles entirely and makes leanness a render-time concern.--zhstays a separate locale overlay, but keyed byidand prose-only (per @cixzhang's lockdown: entries are{ id, text }, structurally unable to carry type/default/structure).ids unique per section, every overlayidresolves to a real base block.Net: no positional arrays, no parallel plain-text to drift, structurally impossible to drop or misalign a block. This unifies 3891 (sections) + @cixzhang's prose-only lockdown + render-time leanness into one model.
feat(cli): migrate theme/tokens/layout overlays to id-anchored blocks…
feat(cli): id-anchored, prose-only reference doc overlays (#2182)
feat(cli): make block id required + backfill ids across all reference…
feat(cli): let an integration contribute doc topics, and replace or e…
feat(cli): let an integration contribute doc topics, and replace or e…
josephfarina commentedon Nov 16, 2026
Thanks for the benchmarks behind this. #7141 split the theme doc into use-a-theme and author-a-theme, so
astryx docs themenow prints about 2 to 4 KB, with or without--dense, down from 12 to 16 KB. Closing as fixed.