Port the color intelligence route from rafters-studio/rafters to platform. Platform-shaped work only -- schema and intelligence shape stay in rafters' lane (boundary set in reflection 019dd027). The naming prompt at apps/web/src/api/lib/color/name-prompt.ts is staged and ready for use.
Reflections: 019dad65 (redesign decisions), 019dadb2 (naming layer fix), 019dae8b (palette ownership), 019dd027 (boundary), 019d65d7 (link: precedent).
Scope:
- apps/web/src/api/routes/color.ts -- new route
- GET /api/color/:oklch where oklch matches `L.LLL-C.CCC-H` (e.g. `0.500-0.120-240`)
- Query params via zValidator: `sync` (bool, default false), `adhoc` (bool, default false)
- Branches mirror rafters/apps/api/src/routes/color/color.handlers.ts:
- adhoc=true -> instant `buildColorValue(oklch)` math response
- sync=false -> math + `status: 'generating'`
- sync=true -> calls AI Gateway with `cf-aig-byok-alias: colors` header, uses NAME_SYSTEM_PROMPT + buildNamePrompt() from src/api/lib/color/name-prompt.ts, persists to Vectorize
- Vectorize lookup: exact ID `${l.toFixed(3)}-${c.toFixed(3)}-${Math.round(h)}`, fallback query with 0.6 nearest-neighbor threshold
- Response schema: `ColorResponseSchema` from @rafters/shared (status enum: found | approximate | generating | queued | error)
- Mount in BOTH apps/web/src/api/app.ts AND apps/web/src/pages/api/[...slug].ts (Astro 6 dev quirk -- catch-all inlines its own app, see /auth + /ctrl precedent)
Tests: tests/api/routes/color.test.ts -- unit tests for handler branches with mocked AI/Vectorize bindings via Zocker.
Port the color intelligence route from rafters-studio/rafters to platform. Platform-shaped work only -- schema and intelligence shape stay in rafters' lane (boundary set in reflection 019dd027). The naming prompt at apps/web/src/api/lib/color/name-prompt.ts is staged and ready for use.
Reflections: 019dad65 (redesign decisions), 019dadb2 (naming layer fix), 019dae8b (palette ownership), 019dd027 (boundary), 019d65d7 (link: precedent).
Scope:
Tests: tests/api/routes/color.test.ts -- unit tests for handler branches with mocked AI/Vectorize bindings via Zocker.