Token codegen
tokens/cabin.tokens.json is the single source of truth. Codegen emits Android,
Compose, and CSS with the same semantic names, then CI fails on drift.
Outputs
| Output | Path |
|---|---|
| Kotlin constants | cabin-tokens/.../CabinTokens.generated.kt |
| Android resources | cabin-tokens/.../res/values/ + values-night/ |
| Theme.Cabin attrs | cabin-tokens/.../res/values/cabin_attrs.xml |
| Compose mappings | cabin-compose/.../CabinComposeTokens.generated.kt |
| CSS variables | apps/www/src/styles/cabin.tokens.css |
| CSS mirror | tokens/generated/cabin.tokens.css |
Catalog consumes the Kotlin/Android outputs through cabin-tokens (no separate
catalog codegen).
Commands
# Regenerate all outputs
python3 tools/generate_cabin_tokens.py
# or
./gradlew :cabin-tokens:generateCabinTokens
# CI / local drift gate (exit 1 if committed outputs are stale)
python3 tools/generate_cabin_tokens.py --check
./gradlew :cabin-tokens:checkCabinTokenDrift
How to add a token
- Edit
tokens/cabin.tokens.json— keep namingcabin.{category}.{tier}.{name}. - Prefer semantic or component tiers; do not invent call-site hex/
sp/dp. - For safety-adjacent color roles (
warning,error) set:"extensions": { "cabin.lock": "safety-adjacent" }. - Night scheme
warning/error/chargingmust keep that lock (codegen fails closed otherwise — OEMs cannot soft-wash). - Run
python3 tools/generate_cabin_tokens.py. - Commit the JSON and regenerated Android / Compose / CSS outputs together.
- Confirm
python3 tools/generate_cabin_tokens.py --checkpasses.
Naming parity
| Layer | Example |
|---|---|
| JSON | cabin.color.semantic.primary |
| Kotlin | CabinTokens.Color.Semantic.primary |
| Android res | cabin_color_semantic_primary |
| Compose | CabinComposeTokens.Semantic.primary |
| CSS | --cabin-color-semantic-primary (+ web alias --primary) |
Craft lock
Generated outputs should read as calm cabin luxury: forest primary on night
instrument surfaces, glanceable type roles, inevitable HMI chrome — not loud
marketing gradients or vibecode glow. Safety feedback stays high-chroma at night;
brand never remaps warning / error / charging.
Safety locks
Codegen requires extensions["cabin.lock"] = "safety-adjacent" on:
cabin.color.semantic.warning/.errorcabin.color.scheme.night.warning/.error/.charging
Night locked values must stay high-chroma. Do not remap them for brand wash.
www / catalog
apps/wwwimports generated CSS; presentation-only vars may usecolor-mixfrom generated roles — no hand hex for cabin roles.- Catalog demos bind
CabinTokens/ Theme Kit; they stay out of the publish graph.