ui-foundations 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,259 +1,66 @@
1
1
  # UI Foundations
2
2
 
3
- This repository contains the **foundation layer** of our UI platform:
3
+ Token-first UI foundations aligned with Figma variables.
4
4
 
5
- - Design tokens (core primitives, color modes, semantic roles)
6
- - Component token APIs (variants, parts, properties, states)
7
- - Foundational architecture rules for long-term consistency
8
- - Docs/playground generated with Eleventy
5
+ This package provides:
9
6
 
10
- ## What this is
7
+ - foundation and semantic design tokens
8
+ - UI pattern CSS
9
+ - optional React wrappers
10
+ - docs/playground via Eleventy
11
11
 
12
- - A **token-first** foundation that aligns **Figma Variables** with **CSS custom properties**
13
- - A **multi-brand** and **multi-mode** ready architecture
14
- - A place to document foundational rules that must remain stable over time
12
+ ## Install
15
13
 
16
- ## What this is not (yet)
17
-
18
- - A full “product design system” with all patterns, usage guidelines, and governance
19
- - Product-specific application rules (these live downstream in product repositories)
20
-
21
- ## Architecture (4 layers)
22
-
23
- 1. **Core (Primitives)**
24
- Raw physical values: spacing, radii, borders, typography primitives, layout constants.
25
-
26
- 2. **Color Modes (Light/Dark)**
27
- Theme palettes: brand colors, neutrals, overlays. No semantic meaning.
28
-
29
- 3. **Semantics (Roles)**
30
- Meaning-based roles: `Color.Text.*`, `Color.Fill.*`, `Color.Border.*`, `Typography.*`, `Corner.*`.
31
- Supports brand modes (e.g. TUI, ROBINSON, LTUR).
32
-
33
- 4. **Components (APIs)**
34
- Component-level API rules: variants, parts, properties, states.
35
- Components reference semantic roles—**never raw values**.
36
-
37
- ## Naming conventions
38
-
39
- Component tokens use a **variant-first** grouping:
40
-
41
- `Component.variant.part.property.state`
42
-
43
- Example:
44
-
45
- - `Button.solid.container.background.default`
46
- - `Button.outline.container.border-color.hover`
47
-
48
- Rules:
49
-
50
- - **Typography never includes color** (color lives in `Color.Text.*`)
51
- - **Components never introduce new colors** (they reference semantic roles)
52
- - Layout primitives (breakpoints, container sizes, z-index) live in **Core**
53
-
54
- ## Repository structure
55
-
56
- - `figma/exports/` — token source exports from Figma
57
- - `dist/tokens/` — generated token artifacts (CSS/JSON/TS)
58
- - `src/` — package source layers (Core/UI/React)
59
- - `site/` — Eleventy preview/docs site (templates + docs-specific CSS)
60
- - `docs/foundations/` — foundational architecture and token rules (source of truth)
61
- - `docs/agentic/` — assistant behavior rules and AI collaboration playbooks
62
- - `figma/` — Figma exports, mappings, Code Connect notes
63
- - `AGENTS.md` — entrypoint for AI coding agents
64
-
65
- Docs structure (`site/`):
66
- - `_includes/layouts/` — shared Nunjucks layouts
67
- - `tokens/*.md` — token docs pages (Eleventy collection)
68
- - `components/*.md` — component docs pages (Eleventy collection)
69
- - `assets/docs.css` — docs-only styling
70
-
71
- AI collaboration:
72
- - `AGENTS.md` — quick entrypoint and baseline checks for agents
73
- - `docs/agentic/assistant-behavior-rules.md` — assistant-specific guardrails
74
- - `docs/agentic/team-ai-playbook.md` — standard AI-assisted workflows for component incubation and token roundtrips
75
-
76
- ## Flow: Add a new component
77
-
78
- ```text
79
- Figma
80
- ├─ 0) Run boundary + utility check
81
- │ ├─ Is this a standalone component or composition of an existing one?
82
- │ └─ Snowflake check: one-off local case vs shared cross-context utility
83
- ├─ 1) Create/update component tokens
84
- │ └─ figma/exports/Component.tokens.json
85
- ├─ 2) (Optional) Add/update Code Connect mapping
86
- │ └─ figma/connections/web-<component>.figma.ts
87
- └─ 3) Regenerate generated artifacts
88
- └─ npm run build:all
89
- ├─ dist/tokens/*
90
- ├─ dist/ui/*
91
- ├─ dist/react/*
92
- └─ dist/main.css
93
-
94
- Repository implementation
95
- ├─ 4) Add CSS pattern
96
- │ └─ src/ui/patterns/<component>.css
97
- ├─ 5) Export pattern in UI bundle
98
- │ └─ src/ui/index.css
99
- ├─ 6) Add React wrapper (if needed)
100
- │ ├─ src/react/<component>.js
101
- │ └─ src/react/index.js
102
- └─ 7) Add assets (if needed)
103
- └─ src/assets/*
104
-
105
- Documentation + Playground
106
- ├─ 8) Add component docs page
107
- │ └─ site/components/<component>.md
108
- ├─ 9) Add playground page
109
- │ └─ site/components/<component>-playground.md
110
- ├─ 10) Extend macros (if needed)
111
- │ └─ site/_includes/macros/{ui.njk,playground.njk}
112
- └─ 11) Extend playground runtime (only for new behavior)
113
- └─ site/assets/playground/{renderers.js,state.js,code.js,shared.js}
114
-
115
- Validation
116
- ├─ npm run test:unit
117
- ├─ npm run build:all
118
- ├─ npm run docs:site
119
- └─ npm run ci:check
14
+ ```bash
15
+ npm install ui-foundations
120
16
  ```
121
17
 
122
- ## Flow: AI-assisted component incubation
18
+ ## Package Usage
123
19
 
124
- This project is designed for a collaborative build loop between design and implementation, not only for one-way token export.
125
-
126
- ```text
127
- Collaborative loop (real-world workflow)
128
- ├─ 0) Run boundary + utility check
129
- │ ├─ standalone component or composition inside an existing component family
130
- │ └─ Snowflake check: solves one local case or reusable across contexts
131
- ├─ 1) Ask the assistant for a proposed component setup
132
- │ ├─ component structure (HTML/CSS/React)
133
- │ ├─ token naming proposal
134
- │ └─ docs/playground example
135
- ├─ 2) Review and adapt the proposal
136
- │ └─ align names and states with your design language
137
- ├─ 3) Create/import the proposed tokens in Figma
138
- │ └─ refine values and variants in design
139
- ├─ 4) Export from Figma back into this repository
140
- │ └─ figma/exports/*.tokens.json
141
- ├─ 5) Let the assistant integrate and align implementation
142
- │ ├─ src/ui/patterns/<component>.css
143
- │ ├─ src/react/<component>.js
144
- │ ├─ site/components/<component>.md
145
- │ ├─ site/components/<component>-playground.md
146
- │ └─ figma/connections/web-<component>.figma.ts (if needed)
147
- └─ 6) Validate and iterate
148
- ├─ npm run ci:check
149
- └─ repeat loop for naming, states, a11y, and behavior refinements
20
+ ```js
21
+ import "ui-foundations/core.css";
22
+ import "ui-foundations/ui.css";
150
23
  ```
151
24
 
152
- Why this matters:
153
- - It closes the gap between design intent and production implementation.
154
- - It keeps token naming and component APIs consistent across Figma and code.
155
- - It makes component incubation faster while staying auditable in Git.
156
-
157
- ## Script locations
158
-
159
- - `scripts/` — build, token extraction, validation, lint and smoke-check automation for local/CI usage
160
- - `site/assets/playground/` — browser runtime modules for docs playground (shared helpers, state, code formatting, renderers)
161
- - `tests/` — unit tests for extraction helpers and edge-case behavior
162
-
163
- ## CSS variable naming
164
-
165
- CSS custom property names are derived from `com.figma.codeSyntax.WEB`.
166
- If a token is missing `codeSyntax.WEB`, a warning is logged and the build
167
- falls back to an auto-derived token name.
168
-
169
- Scopes are derived from export filenames:
170
-
171
- - `Brand X.tokens.json` -> `:root[data-brand="x"]`
172
- - `Mode Light.tokens.json` -> `:root`
173
- - `Mode Dark.tokens.json` -> `:root[data-mode="dark"]`
174
-
175
- ## Specification compliance
176
-
177
- Generated JSON tokens follow the official Design Tokens Community Group format where applicable:
178
-
179
- - W3C DTCG format: `https://www.designtokens.org/tr/drafts/format/`
180
- - Export normalization maps Figma values to spec-friendly types (for example `dimension`, `fontFamily`, `fontWeight`)
181
- - `fontWeight` values are emitted numerically in generated JSON, even if authored as strings in Figma
182
- - Distributed JSON in `dist/tokens/json/*.json` strips `com.figma.*` metadata for cleaner consumer output
183
- - Optional: include Figma metadata sidecars with `npm run tokens:generate -- --include-figma-metadata` (writes `*.figma.json`)
184
-
185
- ## Quick start (local)
25
+ Optional token imports:
186
26
 
187
- 1. Read the foundation rules in `docs/foundations/`
188
- 2. Inspect source tokens in `figma/exports/` and generated tokens in `dist/tokens/`
189
- 3. Run `npm run docs:dev`
190
-
191
- ## Prompt to UI Component
192
-
193
- Use this copy/paste prompt with AI when you want a new component scaffolded and implemented in this repo:
194
-
195
- ```text
196
- Scaffold and implement a new UI component named <component-name> in this repository.
197
-
198
- Follow these sources strictly:
199
- - docs/agentic/team-ai-playbook.md
200
- - docs/agentic/assistant-behavior-rules.md
201
- - docs/foundations/*
202
-
203
- Execution requirements:
204
- 1) Run the Component Boundary Check first and state the decision (composition vs standalone).
205
- 2) Keep scope small, incremental, and reviewable in Git.
206
- 3) Implement token-first and reuse existing patterns:
207
- - src/ui/patterns/<component>.css
208
- - src/react/<component>.js and src/react/index.js (if needed)
209
- - site/components/<component>.md
210
- - site/components/<component>-playground.md
211
- - figma/connections/web-<component>.figma.ts (only if a publishable top-level Figma component/component-set exists)
212
- 4) Validate before handoff:
213
- - npm run lint
214
- - npm run test:unit
215
- - npm run ci:check
216
-
217
- Mandatory progress tracker for this task type:
218
- - Start with: Tasks completion: 0/4
219
- - Update after each phase: 1/4, 2/4, 3/4, 4/4
220
-
221
- Handoff format:
222
- - boundary decision result
223
- - files changed
224
- - validation results
225
- - open follow-ups (if any)
27
+ ```js
28
+ import "ui-foundations/tokens/primitives.css";
29
+ import "ui-foundations/tokens/brand-a.css";
30
+ import "ui-foundations/tokens/brand-b.css";
31
+ import "ui-foundations/tokens/color-light.css";
32
+ import "ui-foundations/tokens/color-dark.css";
33
+ import "ui-foundations/tokens/semantic.css";
34
+ import "ui-foundations/tokens/components.css";
226
35
  ```
227
36
 
228
- ## Build (local)
37
+ Runtime scope example:
229
38
 
230
- 1. Optional syntax lint for JS files: `npm run lint`
231
- 2. Optional unit tests for extractor helpers: `npm run test:unit`
232
- 3. Generate token outputs (after Figma export updates): `npm run tokens:generate`
233
- 4. Build CSS bundles from already generated tokens: `npm run build:css`
234
- 5. Full refresh in one command (tokens + CSS): `npm run build:all`
235
- 6. Run smoke checks for generated artifacts: `npm run smoke:check`
236
- 7. Build docs: `npm run docs:site`
237
- 8. Run CI-equivalent checks locally: `npm run ci:check`
39
+ ```js
40
+ const root = document.documentElement;
41
+ root.dataset.brand = "a"; // "a" | "b"
42
+ root.dataset.mode = "light"; // "light" | "dark"
43
+ ```
238
44
 
239
- `npm run build:css` fails if `dist/tokens/css/*.tokens.css` does not exist yet.
45
+ ## Documentation
240
46
 
241
- ## Token Pipeline Internals
47
+ - Foundations (source of truth): `docs/foundations/`
48
+ - Workflow + pipeline details: `docs/foundations/foundation-010-implementation-and-pipeline-workflow.md`
49
+ - AI playbook: `docs/agentic/team-ai-playbook.md`
50
+ - Shareable skill: `docs/agentic/skills/design-ops-specialist/SKILL.md`
51
+ - Docs site content: `site/`
52
+ - Vanilla starter guide: `site/examples/vanilla-starter.md`
242
53
 
243
- `scripts/extract-tokens.js` is the orchestration entry point.
54
+ ## Local Development
244
55
 
245
- Main helper modules:
246
- - `scripts/extract-tokens.utils.js` — parsing + normalization helpers (`readJsonLike`, `parseWebSyntax`, length/path utilities)
247
- - `scripts/extract-tokens.lookup.js` — alias lookup + cycle/missing-target handling
248
- - `scripts/extract-tokens.value.js` — token grouping + output value formatting
249
- - `scripts/extract-tokens.scope.js` — scope parsing and selector/output-base normalization
56
+ ```bash
57
+ npm run docs:dev
58
+ ```
250
59
 
251
- Data flow:
252
- 1. Read `figma/exports/*.tokens.json` (JSON/JSONC supported)
253
- 2. Flatten tokens + resolve aliases across the combined lookup
254
- 3. Assign CSS variable names from `com.figma.codeSyntax.WEB`
255
- 4. Emit `dist/tokens/{css,json,ts}` and `dist/tokens/tokens.yaml`
60
+ Validation baseline:
256
61
 
257
- Fallback behavior:
258
- - Missing or invalid `com.figma.codeSyntax.WEB` values fall back to auto-derived CSS variable names and are reported in the extract summary.
259
- - Missing alias targets and alias cycles fall back to literal values and are reported.
62
+ ```bash
63
+ npm run lint
64
+ npm run test:unit
65
+ npm run ci:check
66
+ ```
package/dist/main.css CHANGED
@@ -181,7 +181,7 @@
181
181
  }
182
182
  }
183
183
  /* Auto-generated design tokens from Figma */
184
- /* Generated on 2026-03-04T21:31:32.474Z */
184
+ /* Generated on 2026-03-04T21:56:02.562Z */
185
185
 
186
186
  :root {
187
187
  --color-transparent: rgba(0 0 0 / 0);
@@ -308,7 +308,7 @@
308
308
  --zindex-tooltip: 1070;
309
309
  }
310
310
  /* Auto-generated design tokens from Figma */
311
- /* Generated on 2026-03-04T21:31:32.456Z */
311
+ /* Generated on 2026-03-04T21:56:02.552Z */
312
312
 
313
313
  :root[data-brand="a"] {
314
314
  --brand-color-primary: var(--color-brand-a-purple-600);
@@ -330,7 +330,7 @@
330
330
  --brand-corner-modal: var(--size-radius-400);
331
331
  }
332
332
  /* Auto-generated design tokens from Figma */
333
- /* Generated on 2026-03-04T21:31:32.458Z */
333
+ /* Generated on 2026-03-04T21:56:02.554Z */
334
334
 
335
335
  :root[data-brand="b"] {
336
336
  --brand-color-primary: var(--color-brand-b-blue-500);
@@ -352,7 +352,7 @@
352
352
  --brand-corner-modal: var(--size-radius-200);
353
353
  }
354
354
  /* Auto-generated design tokens from Figma */
355
- /* Generated on 2026-03-04T21:31:32.476Z */
355
+ /* Generated on 2026-03-04T21:56:02.563Z */
356
356
 
357
357
  :root {
358
358
  --typography-code: var(--font-family-mono);
@@ -387,7 +387,7 @@
387
387
  --corner-modal-radius: var(--brand-corner-modal);
388
388
  }
389
389
  /* Auto-generated design tokens from Figma */
390
- /* Generated on 2026-03-04T21:31:32.464Z */
390
+ /* Generated on 2026-03-04T21:56:02.558Z */
391
391
 
392
392
  :root {
393
393
  --button-font-family: var(--brand-font-lead);
@@ -490,7 +490,7 @@
490
490
  --form-field-helper-text-color-invalid: var(--color-text-danger);
491
491
  }
492
492
  /* Auto-generated design tokens from Figma */
493
- /* Generated on 2026-03-04T21:31:32.470Z */
493
+ /* Generated on 2026-03-04T21:56:02.560Z */
494
494
 
495
495
  :root {
496
496
  --color-focus: var(--brand-color-primary);
@@ -522,7 +522,7 @@
522
522
  --color-overlay-selected: var(--color-neutral-alpha-600);
523
523
  }
524
524
  /* Auto-generated design tokens from Figma */
525
- /* Generated on 2026-03-04T21:31:32.468Z */
525
+ /* Generated on 2026-03-04T21:56:02.559Z */
526
526
 
527
527
  :root[data-mode="dark"] {
528
528
  --color-focus: var(--brand-color-primary-dark);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.456Z */
2
+ /* Generated on 2026-03-04T21:56:02.552Z */
3
3
 
4
4
  :root[data-brand="a"] {
5
5
  --brand-color-primary: var(--color-brand-a-purple-600);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.458Z */
2
+ /* Generated on 2026-03-04T21:56:02.554Z */
3
3
 
4
4
  :root[data-brand="b"] {
5
5
  --brand-color-primary: var(--color-brand-b-blue-500);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.468Z */
2
+ /* Generated on 2026-03-04T21:56:02.559Z */
3
3
 
4
4
  :root[data-mode="dark"] {
5
5
  --color-focus: var(--brand-color-primary-dark);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.470Z */
2
+ /* Generated on 2026-03-04T21:56:02.560Z */
3
3
 
4
4
  :root {
5
5
  --color-focus: var(--brand-color-primary);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.464Z */
2
+ /* Generated on 2026-03-04T21:56:02.558Z */
3
3
 
4
4
  :root {
5
5
  --button-font-family: var(--brand-font-lead);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.474Z */
2
+ /* Generated on 2026-03-04T21:56:02.562Z */
3
3
 
4
4
  :root {
5
5
  --color-transparent: rgba(0 0 0 / 0);
@@ -1,5 +1,5 @@
1
1
  /* Auto-generated design tokens from Figma */
2
- /* Generated on 2026-03-04T21:31:32.476Z */
2
+ /* Generated on 2026-03-04T21:56:02.563Z */
3
3
 
4
4
  :root {
5
5
  --typography-code: var(--font-family-mono);
@@ -1,5 +1,5 @@
1
1
  # Auto-generated design tokens from Figma
2
- # Generated on 2026-03-04T21:31:32.490Z
2
+ # Generated on 2026-03-04T21:56:02.574Z
3
3
 
4
4
  summary:
5
5
  total: 338
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.457Z
2
+ // Generated on 2026-03-04T21:56:02.553Z
3
3
 
4
4
  export const tokens = {
5
5
  "colors": {
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.458Z
2
+ // Generated on 2026-03-04T21:56:02.554Z
3
3
 
4
4
  export const tokens = {
5
5
  "colors": {
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.468Z
2
+ // Generated on 2026-03-04T21:56:02.559Z
3
3
 
4
4
  export const tokens = {
5
5
  "colors": {
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.470Z
2
+ // Generated on 2026-03-04T21:56:02.560Z
3
3
 
4
4
  export const tokens = {
5
5
  "colors": {
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.464Z
2
+ // Generated on 2026-03-04T21:56:02.558Z
3
3
 
4
4
  export const tokens = {
5
5
  "components": {
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.474Z
2
+ // Generated on 2026-03-04T21:56:02.562Z
3
3
 
4
4
  export const tokens = {
5
5
  "colors": {
@@ -1,5 +1,5 @@
1
1
  // Auto-generated design tokens from Figma
2
- // Generated on 2026-03-04T21:31:32.476Z
2
+ // Generated on 2026-03-04T21:56:02.563Z
3
3
 
4
4
  export const tokens = {
5
5
  "typography": {
@@ -0,0 +1,16 @@
1
+ # Assistant rules (UI Foundations)
2
+
3
+ 1. Always follow foundation rules in `/docs/foundations` as the source of truth.
4
+ 2. Keep the 4-layer architecture: Core → Color Modes → Semantics → Components.
5
+ 3. Components may only reference Semantics/Core tokens; no raw values in components.
6
+ 4. Typography tokens never include color; text color lives in `Color.Text.*`.
7
+ 5. Responsive thresholds:
8
+ - Viewport breakpoints in `Core.Breakpoint.*`
9
+ - Container query thresholds in `Core.Container.*`
10
+ 6. Use variant-first naming: `Component.variant.part.property.state`.
11
+ 7. Before creating a new component, run a boundary check:
12
+ - Prefer composition inside an existing component family when behavior is mainly layout/wrapping/grouping.
13
+ - Create a standalone component only if it introduces distinct semantics, API surface, or lifecycle.
14
+ - This decision is independent from token work: new tokens alone are not sufficient reason for a standalone component.
15
+ - Apply the Snowflake check: local one-off solutions stay local; shared utility can enter the system.
16
+ - Source of truth: `docs/foundations/foundation-009-component-boundaries-and-utility.md`.
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: design-ops-specialist
3
+ description: "Design Ops Specialist guidance for token-first component proposals in this repo and package consumers. Use when a request asks for token naming (variants/parts/states), CSS pattern structure under src/ui/patterns, optional React wrapper API, and docs/playground integration while keeping scope minimal and non-breaking."
4
+ ---
5
+
6
+ # Design Ops Specialist
7
+
8
+ ## Intent
9
+
10
+ Use this skill for proposal-first work before implementation.
11
+
12
+ ## Workflow
13
+
14
+ 1. Confirm scope and constraints:
15
+ - component name
16
+ - parts/variants/states
17
+ - platform or framework constraints
18
+ 2. Align with source rules:
19
+ - `docs/foundations/`
20
+ - `docs/agentic/assistant-behavior-rules.md`
21
+ - `docs/agentic/team-ai-playbook.md`
22
+ 3. Produce a concise proposal (no code changes unless explicitly requested).
23
+ 4. Keep proposals minimal, incremental, and non-breaking by default.
24
+
25
+ ## Output Format
26
+
27
+ Provide these sections:
28
+
29
+ 1. Token naming proposal
30
+ - prefix, variants, parts, states
31
+ - alignment to foundations naming rules
32
+ 2. CSS pattern structure
33
+ - target files under `src/ui/patterns`
34
+ - expected class names and token hookups
35
+ 3. Optional React wrapper API
36
+ - only when requested or needed
37
+ - props mapped to token variants/states
38
+ 4. Docs + playground integration
39
+ - required docs pages/sections
40
+ - playground additions or updates
41
+
42
+ ## Guardrails
43
+
44
+ - Prefer extending existing patterns over introducing new frameworks.
45
+ - If requirements are underspecified, ask targeted clarifying questions.
46
+ - Preserve compatibility with token-first and Figma-aligned architecture.
@@ -0,0 +1,216 @@
1
+ # AI Playbook
2
+
3
+ This playbook defines how to use AI as an engineering copilot in this repository.
4
+
5
+ ## Goal
6
+
7
+ Use AI to speed up component incubation and implementation while keeping output:
8
+
9
+ - token-first
10
+ - reviewable in Git
11
+ - consistent with existing architecture
12
+
13
+ ## Principles
14
+
15
+ 1. Keep changes small and incremental.
16
+ 2. Prefer existing patterns over introducing new abstractions.
17
+ 3. Keep Figma and code aligned through explicit token roundtrips.
18
+ 4. Always validate with local checks before pushing.
19
+
20
+ ## Component Boundary Check (Mandatory)
21
+
22
+ Run this decision gate before implementing a "new component":
23
+
24
+ 1. Start with composition-first:
25
+ - If the new idea is primarily grouping, layout, or orchestration of existing components, implement it as composition within the existing component family and document it there.
26
+ 2. Promote to standalone only when needed:
27
+ - The candidate introduces distinct semantics (own role/responsibility), a stable API surface, or independent lifecycle/behavior that is not just a wrapper.
28
+ 3. Apply a utility test ("Snowflake check"):
29
+ - One-off/local case -> keep it local or document as composition.
30
+ - Reusable across contexts/products -> valid candidate for system-level component.
31
+ 4. Keep token work independent:
32
+ - New tokens may be needed in both paths.
33
+ - Token creation does not automatically justify a new standalone component.
34
+ 5. Source of truth:
35
+ - `docs/foundations/foundation-009-component-boundaries-and-utility.md`
36
+
37
+ ## Standard Workflow: New Component
38
+
39
+ 1. Run the Component Boundary Check and decide:
40
+ - standalone component, or
41
+ - composition inside existing component docs/API.
42
+ 2. Ask AI for a first proposal:
43
+ - structure: HTML/CSS/React
44
+ - token names and states
45
+ - docs + playground example
46
+ 3. Review and adjust naming before implementation.
47
+ 4. Add/import proposed tokens in Figma.
48
+ 5. Export tokens from Figma to `figma/exports/`.
49
+ 6. Let AI integrate implementation:
50
+ - `src/ui/patterns/<component>.css`
51
+ - `src/react/<component>.js` and `src/react/index.js` (if needed)
52
+ - `site/components/<component>.md`
53
+ - `site/components/<component>-playground.md`
54
+ - `figma/connections/web-<component>.figma.ts` (if needed)
55
+ 7. Run validation:
56
+ - `npm run ci:check`
57
+ 8. Iterate naming/states/a11y until stable.
58
+
59
+ ## Proposal Mode: Design Ops Specialist
60
+
61
+ Use this mode when the request is explicitly a proposal (no implementation yet).
62
+
63
+ 1. Confirm scope and constraints first:
64
+ - component name
65
+ - variants/sizes/states/parts
66
+ - platform constraints
67
+ 2. Review source rules before proposing:
68
+ - `docs/foundations/`
69
+ - `docs/agentic/assistant-behavior-rules.md`
70
+ - this playbook
71
+ 3. Deliver a concise proposal with these sections:
72
+ - token naming proposal (variants/parts/states)
73
+ - CSS pattern structure under `src/ui/patterns`
74
+ - optional React wrapper API (only if requested/needed)
75
+ - docs + playground integration plan
76
+ 4. Keep recommendations minimal and non-breaking by default.
77
+
78
+ ## Standard Workflow: Token Roundtrip
79
+
80
+ 1. Create or update tokens in Figma.
81
+ 2. Export into `figma/exports/*.tokens.json`.
82
+ 3. Run:
83
+ - `npm run build:all`
84
+ - `npm run tokens:validate`
85
+ 4. Check output consistency:
86
+ - `dist/tokens/css/*.tokens.css`
87
+ - `dist/tokens/json/*.json`
88
+ - `dist/tokens/tokens.yaml`
89
+ 5. If warnings appear (missing/invalid WEB syntax, alias issues), fix in Figma first.
90
+
91
+ ## Standard Workflow: Figma Drift Reconciliation
92
+
93
+ Use this when the component was scaffolded in code first and component variables/variants are created or changed in Figma afterwards.
94
+
95
+ 1. Define the contract first:
96
+ - component API (props/states/semantics)
97
+ - token names and expected usage
98
+ 2. Update Figma variables/variants and export tokens:
99
+ - `figma/exports/*.tokens.json`
100
+ 3. Rebuild token artifacts:
101
+ - `npm run build:all`
102
+ - `npm run tokens:validate`
103
+ 4. Reconcile Code Connect mappings:
104
+ - update `figma/connections/web-<component>.figma.ts`
105
+ - align node-id targets and property names with actual Figma top-level component/component set
106
+ - run `figma connect parse`
107
+ - run `figma connect publish --dry-run`
108
+ 5. Reconcile implementation only where needed:
109
+ - adjust CSS/React/docs/playground to match agreed contract
110
+ - avoid broad rewrites; keep changes minimal
111
+ 6. Validate and stabilize:
112
+ - `npm run lint`
113
+ - `npm run test:unit`
114
+ - `npm run ci:check`
115
+ 7. Commit with explicit scope, for example:
116
+ - `chore(figma): reconcile <component> code-connect mapping`
117
+ - `feat(<component>): align states and tokens with figma`
118
+
119
+ ## Standard Workflow: Refactor and Quality
120
+
121
+ 1. Ask AI to identify one small refactor target.
122
+ 2. Implement only one focused change set.
123
+ 3. Add or update tests when behavior is touched.
124
+ 4. Run:
125
+ - `npm run lint`
126
+ - `npm run test:unit`
127
+ - `npm run ci:check`
128
+ 5. Commit with clear scope in message.
129
+
130
+ ## Prompt Templates
131
+
132
+ ### 1) New component incubation
133
+
134
+ ```text
135
+ You are my Design OPS Manager. Propose a token-first setup for a new <component>.
136
+ Include:
137
+ - token naming proposal (variants/parts/states)
138
+ - CSS pattern structure under src/ui/patterns
139
+ - optional React wrapper API
140
+ - docs + playground integration
141
+ Keep changes minimal and aligned with existing repository conventions.
142
+ ```
143
+
144
+ ### 2) Token integration after Figma export
145
+
146
+ ```text
147
+ I updated figma/exports. Please run the token/build pipeline, review warnings,
148
+ and apply minimal fixes so docs and bundles are green.
149
+ ```
150
+
151
+ ### 3) Safe refactor
152
+
153
+ ```text
154
+ Refactor <target file/module> for maintainability in small steps only.
155
+ No behavior changes. Add tests if needed. Keep ci:check green.
156
+ ```
157
+
158
+ ### 4) Prompt to UI component (scaffold + implement)
159
+
160
+ ```text
161
+ Scaffold and implement a new UI component named <component-name> in this repository.
162
+
163
+ Follow these sources strictly:
164
+ - docs/agentic/team-ai-playbook.md
165
+ - docs/agentic/assistant-behavior-rules.md
166
+ - docs/foundations/*
167
+
168
+ Execution requirements:
169
+ 1) Run the Component Boundary Check first and state the decision (composition vs standalone).
170
+ 2) Keep scope small, incremental, and reviewable in Git.
171
+ 3) Implement token-first and reuse existing patterns:
172
+ - src/ui/patterns/<component>.css
173
+ - src/react/<component>.js and src/react/index.js (if needed)
174
+ - site/components/<component>.md
175
+ - site/components/<component>-playground.md
176
+ - figma/connections/web-<component>.figma.ts (only if a publishable top-level Figma component/component-set exists)
177
+ 4) Validate before handoff:
178
+ - npm run lint
179
+ - npm run test:unit
180
+ - npm run ci:check
181
+
182
+ Mandatory progress tracker for this task type:
183
+ - Start with: Tasks completion: 0/4
184
+ - Update after each phase: 1/4, 2/4, 3/4, 4/4
185
+
186
+ Handoff format:
187
+ - boundary decision result
188
+ - files changed
189
+ - validation results
190
+ - open follow-ups (if any)
191
+ ```
192
+
193
+ ## Definition of Done (AI Task)
194
+
195
+ - Scope is clear and minimal.
196
+ - Affected files are easy to review.
197
+ - No broken exports or docs.
198
+ - `npm run ci:check` passes.
199
+ - README/docs updated when behavior or workflow changes.
200
+
201
+ ## Worked example: Button Group
202
+
203
+ This repository now includes a concrete walkthrough based on a `Button Group`:
204
+
205
+ 1. AI proposal:
206
+ - layout model (`orientation`, `attached`, `justify`)
207
+ - token proposal (`--button-group-gap`, `--button-group-border-radius`)
208
+ 2. Implementation in code:
209
+ - integrated button family CSS: `src/ui/patterns/button.css`
210
+ - React wrapper API in `src/react/button.js` (`ButtonGroup`)
211
+ 3. Documentation:
212
+ - integrated in `site/components/button.md` under grouped usage
213
+ 4. Validation:
214
+ - `npm run ci:check`
215
+
216
+ Use this pattern as the reference baseline for future AI-assisted component incubation where wrappers extend an existing component family.
@@ -0,0 +1,82 @@
1
+ # Foundation-010: Implementation and Pipeline Workflow
2
+
3
+ ## Purpose
4
+
5
+ Define the stable implementation workflow for adding or updating UI foundations artifacts, including token generation, component integration, docs updates, and validation.
6
+
7
+ ## Rules
8
+
9
+ 1. Follow this sequence for new components:
10
+ - Run boundary + utility check first (see Foundation-009).
11
+ - Add/update Figma token exports in `figma/exports/`.
12
+ - Regenerate artifacts via `npm run build:all`.
13
+ - Add or update CSS pattern in `src/ui/patterns/`.
14
+ - Export pattern in `src/ui/index.css`.
15
+ - Add React wrapper only when needed.
16
+ - Add docs + playground pages in `site/components/`.
17
+
18
+ 2. Keep changes token-first:
19
+ - Components consume semantic/foundation tokens.
20
+ - Do not introduce component-local hard-coded colors.
21
+
22
+ 3. Treat generated output as build artifacts:
23
+ - `dist/tokens/` and `dist/` are generated outputs.
24
+ - Build scripts in `scripts/` are the source for generation behavior.
25
+
26
+ 4. Keep package runtime mode policy consumer-owned:
27
+ - Token outputs define scopes/selectors.
28
+ - Consumers decide when/how `data-mode` and `data-brand` are applied.
29
+
30
+ ## Build and Validation
31
+
32
+ Use these commands as the baseline:
33
+
34
+ - `npm run lint`
35
+ - `npm run test:unit`
36
+ - `npm run ci:check`
37
+
38
+ Additional useful commands:
39
+
40
+ - `npm run tokens:generate`
41
+ - `npm run build:css`
42
+ - `npm run build:all`
43
+ - `npm run docs:site`
44
+
45
+ ## Token Pipeline Notes
46
+
47
+ `scripts/extract-tokens.js` orchestrates generation.
48
+
49
+ Key helpers:
50
+
51
+ - `scripts/extract-tokens.utils.js`
52
+ - `scripts/extract-tokens.lookup.js`
53
+ - `scripts/extract-tokens.value.js`
54
+ - `scripts/extract-tokens.scope.js`
55
+
56
+ Scope behavior from export filenames:
57
+
58
+ - `Brand X.tokens.json` -> `:root[data-brand="x"]`
59
+ - `Mode Light.tokens.json` -> `:root`
60
+ - `Mode Dark.tokens.json` -> `:root[data-mode="dark"]`
61
+
62
+ Fallback behavior:
63
+
64
+ - Missing or invalid `com.figma.codeSyntax.WEB` falls back to auto-derived CSS variable names and is reported.
65
+ - Missing alias targets and alias cycles fall back to literal values and are reported.
66
+
67
+ ## AI-Assisted Workflow
68
+
69
+ When using assistants for component incubation:
70
+
71
+ 1. Define boundary (composition vs standalone).
72
+ 2. Propose token naming + component structure.
73
+ 3. Align/update Figma tokens.
74
+ 4. Regenerate and integrate in code.
75
+ 5. Update docs/playground.
76
+ 6. Run validation commands before handoff.
77
+
78
+ ## Implications
79
+
80
+ - The repository remains predictable for humans and assistants.
81
+ - Detailed operational guidance stays in foundations docs, not top-level onboarding.
82
+ - The README can remain minimal while implementation rigor stays explicit.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-foundations",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Token-first UI foundations with CSS, tokens, and React exports.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,7 +15,10 @@
15
15
  "files": [
16
16
  "dist/**",
17
17
  "README.md",
18
- "docs/foundations/**"
18
+ "docs/foundations/**",
19
+ "docs/agentic/assistant-behavior-rules.md",
20
+ "docs/agentic/team-ai-playbook.md",
21
+ "docs/agentic/skills/**"
19
22
  ],
20
23
  "exports": {
21
24
  "./core.css": "./dist/core/index.css",