cloudflare/kumo
Publicmirrored fromhttps://github.com/cloudflare/kumoAvailable
AGENTS.md
131lines · modecode
| 1 | # KUMO KNOWLEDGE BASE |
| 2 | |
| 3 | **Generated:** 2026-02-09 | **Commit:** d10c711 | **Branch:** rozenmd/agents-init |
| 4 | |
| 5 | ## OVERVIEW |
| 6 | |
| 7 | Cloudflare's React component library (`@cloudflare/kumo`). pnpm monorepo: component library (Base UI + Tailwind v4), Astro docs site, Figma plugin. ESM-only, Node 24+. |
| 8 | |
| 9 | ## STRUCTURE |
| 10 | |
| 11 | ``` |
| 12 | kumo/ |
| 13 | ├── packages/ |
| 14 | │ ├── kumo/ # Component library → see packages/kumo/AGENTS.md |
| 15 | │ ├── kumo-docs-astro/ # Astro docs site → see packages/kumo-docs-astro/AGENTS.md |
| 16 | │ └── kumo-figma/ # Figma plugin → see packages/kumo-figma/AGENTS.md |
| 17 | ├── ci/ # CI/CD scripts → see ci/AGENTS.md |
| 18 | ├── lint/ # Custom oxlint rules (shared by kumo + docs) |
| 19 | ├── .changeset/ # Changeset files |
| 20 | └── lefthook.yml # Pre-push changeset validation |
| 21 | ``` |
| 22 | |
| 23 | ## WHERE TO LOOK |
| 24 | |
| 25 | | Task | Location | Notes | |
| 26 | | -------------------- | ------------------------------------------------ | -------------------------------------------------------- | |
| 27 | | Component API | `packages/kumo/ai/component-registry.{json,md}` | Source of truth. Query with `jq` or CLI | |
| 28 | | Component source | `packages/kumo/src/components/{name}/{name}.tsx` | Standard pattern | |
| 29 | | Blocks (installable) | `packages/kumo/src/blocks/` | NOT library exports; installed via CLI | |
| 30 | | Semantic tokens | `packages/kumo/src/styles/theme-kumo.css` | AUTO-GENERATED; edit `scripts/theme-generator/config.ts` | |
| 31 | | Custom lint rules | `lint/` and `packages/kumo/lint/` | Two copies; package copy adds `no-deprecated-props` | |
| 32 | | Demo examples | `packages/kumo-docs-astro/src/components/demos/` | Feed into registry codegen | |
| 33 | | CI scripts | `ci/` | Reporter system, versioning, deployment | |
| 34 | | Figma generators | `packages/kumo-figma/src/generators/` | 35+ component generators | |
| 35 | |
| 36 | ## CONVENTIONS |
| 37 | |
| 38 | ### Styling (CRITICAL) |
| 39 | |
| 40 | - **ONLY semantic tokens**: `bg-kumo-base`, `text-kumo-default`, `border-kumo-line`, `ring-kumo-ring` |
| 41 | - **NEVER raw Tailwind colors**: `bg-blue-500`, `text-gray-900` → fails lint |
| 42 | - **NEVER `dark:` variant**: dark mode automatic via `light-dark()` in CSS custom properties |
| 43 | - **Exceptions**: `bg-white`, `bg-black`, `text-white`, `text-black`, `transparent` |
| 44 | - **`cn()` utility**: Always compose classNames via `cn("base", conditional && "extra", className)` |
| 45 | - **Surface hierarchy**: `bg-kumo-base` → `bg-kumo-elevated` → `bg-kumo-recessed` |
| 46 | - **Mode/theme**: `data-mode="light"|"dark"` + `data-theme="fedramp"` on parent element |
| 47 | |
| 48 | ### Components |
| 49 | |
| 50 | - **Scaffold new**: `pnpm --filter @cloudflare/kumo new:component` (never create manually) |
| 51 | - **Registry first**: Always check `component-registry.json` before using/modifying a component |
| 52 | - See `packages/kumo/AGENTS.md` for component conventions (variants, forwardRef, displayName) |
| 53 | |
| 54 | ### Imports |
| 55 | |
| 56 | - **No cross-package relative imports**: Use `@cloudflare/kumo` not `../../kumo/src/...` (lint-enforced) |
| 57 | - **ESM-only**: `"type": "module"` throughout. No CJS. |
| 58 | |
| 59 | ### Changesets |
| 60 | |
| 61 | - **Required**: Any change to `packages/kumo/` needs a changeset (`pnpm changeset`) |
| 62 | - **Pre-push hook**: Lefthook validates before push. Bypass: `git push --no-verify` |
| 63 | - **AI agents NEVER**: `pnpm version`, `pnpm release`, `pnpm publish:beta`, `pnpm release:production` |
| 64 | |
| 65 | ## ANTI-PATTERNS |
| 66 | |
| 67 | | Pattern | Why | Instead | |
| 68 | | ------------------------------ | ------------------------------------------------------------ | ------------------------------------------- | |
| 69 | | `bg-blue-500`, `text-gray-*` | Breaks theming, fails lint | `bg-kumo-brand`, `text-kumo-default` | |
| 70 | | `dark:bg-black` | Redundant; tokens auto-adapt | Remove `dark:` prefix | |
| 71 | | Missing `displayName` | Breaks React DevTools | Set `.displayName` on forwardRef components | |
| 72 | | Manual component file creation | Misses vite/package.json/index updates | Use scaffolding tool | |
| 73 | | Editing auto-generated files | `theme-kumo.css`, `ai/schemas.ts`, `ai/component-registry.*` | Edit source configs, run codegen | |
| 74 | |
| 75 | ## COMMANDS |
| 76 | |
| 77 | ```bash |
| 78 | # Cross-cutting |
| 79 | pnpm dev # Docs dev server (localhost:4321) |
| 80 | pnpm lint # oxlint + custom rules |
| 81 | pnpm typecheck # TypeScript check all packages |
| 82 | pnpm changeset # Create changeset (required for kumo changes) |
| 83 | |
| 84 | # Package-specific (see child AGENTS.md for full lists) |
| 85 | pnpm --filter @cloudflare/kumo build # Build library |
| 86 | pnpm --filter @cloudflare/kumo test # Vitest |
| 87 | pnpm --filter @cloudflare/kumo codegen:registry # Regenerate component-registry |
| 88 | pnpm --filter @cloudflare/kumo-figma build # Build Figma plugin |
| 89 | ``` |
| 90 | |
| 91 | ## BUILD PIPELINE |
| 92 | |
| 93 | ``` |
| 94 | kumo-docs-astro demos → dist/demo-metadata.json |
| 95 | ↓ |
| 96 | kumo codegen:registry → ai/component-registry.{json,md} + ai/schemas.ts |
| 97 | ↓ |
| 98 | kumo-figma build:data → generated/*.json → esbuild → code.js (IIFE, ES2017) |
| 99 | ``` |
| 100 | |
| 101 | Cross-package dependency: registry codegen requires docs demo metadata. Run `codegen:demos` in docs before `codegen:registry` in kumo. |
| 102 | |
| 103 | ## TOOLCHAIN |
| 104 | |
| 105 | | Tool | Version | Notes | |
| 106 | | ---------- | --------- | -------------------------------------- | |
| 107 | | Node | ^24.12.0 | Engine constraint | |
| 108 | | pnpm | >=10.21.0 | Workspace manager | |
| 109 | | TypeScript | 5.9.2 | Via pnpm catalog | |
| 110 | | Vite | 7.1.7 | Library mode (kumo), dev server (docs) | |
| 111 | | Tailwind | 4.1.17 | v4 with `light-dark()` tokens | |
| 112 | | oxlint | 1.42.0 | Primary linter + 5 custom JS rules | |
| 113 | | Vitest | 3.2.4 | happy-dom env, v8 coverage | |
| 114 | | Changesets | latest | Version management | |
| 115 | | Astro | latest | Docs framework | |
| 116 | |
| 117 | ## SECURITY |
| 118 | |
| 119 | - **NEVER commit** Figma tokens, npm tokens, or API keys |
| 120 | - `.env` files are gitignored |
| 121 | - `wrangler.jsonc` contains Cloudflare account IDs (not secret but don't expose) |
| 122 | |
| 123 | ## NOTES |
| 124 | |
| 125 | - `ai/component-registry.json`, `ai/schemas.ts` are auto-generated but committed to git (shipped in npm package) |
| 126 | - `src/primitives/` (37 files) are auto-generated Base UI re-exports |
| 127 | - Blocks in `src/blocks/` are NOT exported from package index; installed via CLI `kumo add` |
| 128 | - `src/catalog/` is a runtime JSON-UI rendering module (separate concern from component library) |
| 129 | - No GitHub Actions workflows checked into repo; CI scripts exist but orchestration is external |
| 130 | - Dual linter: oxlint (fast, custom rules) + ESLint (7 jsx-a11y rules only) |
| 131 | - `PLOP_INJECT_EXPORT` and `PLOP_INJECT_COMPONENT_ENTRY` markers in source for scaffolding |