|
| 1 | +# PR 8.3 — Sample Color Palette Generation |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Generate schema-compliant sample palette documents from colors actually used by each sample. |
| 5 | + |
| 6 | +## Scope |
| 7 | +- Do not assume `samples/**/config.json` exists. |
| 8 | +- Do not assume `samples/**/*.palette.json` exists. |
| 9 | +- Scan each sample's existing JSON payloads and related sample assets for color values. |
| 10 | +- Generate palette documents only from colors found in the sample. |
| 11 | +- Add `$schema` references to generated palette documents. |
| 12 | +- Keep `workspace.manifest` as source of truth. |
| 13 | +- Keep shared schemas in `tools/schemas/`. |
| 14 | + |
| 15 | +## Required Output Shape |
| 16 | +Generated palette files must conform to: |
| 17 | + |
| 18 | +`tools/schemas/palette.schema.json` |
| 19 | + |
| 20 | +Expected shared palette document shape: |
| 21 | + |
| 22 | +```json |
| 23 | +{ |
| 24 | + "$schema": "../../../tools/schemas/palette.schema.json", |
| 25 | + "schema": "palette", |
| 26 | + "version": "1.0.0", |
| 27 | + "name": "Sample 0101 Palette", |
| 28 | + "source": "generated-from-sample-colors", |
| 29 | + "entries": [ |
| 30 | + { |
| 31 | + "name": "color-001", |
| 32 | + "value": "#000000" |
| 33 | + } |
| 34 | + ] |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +## Generation Rules |
| 39 | +- Extract only explicit color values used by the sample. |
| 40 | +- Supported color formats: |
| 41 | + - `#RGB` |
| 42 | + - `#RRGGBB` |
| 43 | + - `#RRGGBBAA` |
| 44 | + - `rgb(...)` |
| 45 | + - `rgba(...)` |
| 46 | + - named CSS colors only if already present in sample files |
| 47 | +- Normalize hex colors to uppercase `#RRGGBB` unless alpha is required. |
| 48 | +- Deduplicate colors per sample. |
| 49 | +- Preserve deterministic ordering. |
| 50 | +- Use stable generated names: |
| 51 | + - `color-001` |
| 52 | + - `color-002` |
| 53 | + - `color-003` |
| 54 | +- Do not invent colors. |
| 55 | +- Do not generate empty palettes unless the sample already has no color data and a manifest entry requires one. |
| 56 | + |
| 57 | +## Non-Goals |
| 58 | +- No runtime validation utilities. |
| 59 | +- No implementation behavior changes. |
| 60 | +- No start_of_day changes. |
| 61 | +- No repo-wide architectural rewrite. |
| 62 | +- No sample gameplay changes. |
| 63 | + |
| 64 | +## Acceptance |
| 65 | +- Palette files exist only where sample color data exists or where the manifest requires them. |
| 66 | +- Generated palettes validate against `tools/schemas/palette.schema.json`. |
| 67 | +- All generated palette files include `$schema`. |
| 68 | +- No references to nonexistent `samples/**/config.json` or `samples/**/*.palette.json` remain in PR docs. |
0 commit comments