@equal-experts/kuat-react 0.3.0 → 0.3.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.
@@ -1,451 +0,0 @@
1
- # Kuat Design System Typography
2
-
3
- A guide to using typography in the Kuat Design System. This document helps ensure consistent, accessible typography across all digital products built with shadcn/ui and shadcn-vue.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- The Kuat Design System follows shadcn/ui patterns, which means **typography is handled through Tailwind CSS utility classes** rather than predefined typography components. This approach provides flexibility while maintaining consistency through design tokens.
10
-
11
- **Key Principle:** Use Tailwind utility classes for typography styling. All typography values are defined in `@equal-experts/kuat-core` and accessible via Tailwind classes.
12
-
13
- ---
14
-
15
- ## Font Families
16
-
17
- Font families are defined in `@equal-experts/kuat-core/src/variables.css` and available via Tailwind utilities.
18
-
19
- ### Sans Serif (Default)
20
- - **Font Family:** `Lexend`
21
- - **CSS Variable:** `--font-sans`
22
- - **Tailwind Class:** `font-sans`
23
- - **Fallback Stack:** `Lexend, ui-sans-serif, sans-serif, system-ui`
24
- - **Usage:** Primary font for all UI elements, body text, headings, and interface copy
25
-
26
- ### Serif
27
- - **Font Family:** `Lora`
28
- - **CSS Variable:** `--font-serif`
29
- - **Tailwind Class:** `font-serif`
30
- - **Usage:** Decorative text, special emphasis (use sparingly)
31
-
32
- ### Monospace
33
- - **Font Family:** `JetBrains Mono`
34
- - **CSS Variable:** `--font-mono`
35
- - **Tailwind Class:** `font-mono`
36
- - **Usage:** Code blocks, technical content, data display
37
- - **Why JetBrains Mono:** A professional monospace font designed specifically for developers, with excellent readability and clear character distinction optimized for coding
38
-
39
- ### Usage Examples
40
-
41
- ```tsx
42
- // React
43
- <p className="font-sans">Primary text using Lexend</p>
44
- <code className="font-mono">Code example</code>
45
- ```
46
-
47
- ```vue
48
- <!-- Vue -->
49
- <p class="font-sans">Primary text using Lexend</p>
50
- <code class="font-mono">Code example</code>
51
- ```
52
-
53
- ---
54
-
55
- ## Typography Scale
56
-
57
- The design system uses Tailwind's default typography scale. All sizes are relative and responsive by default.
58
-
59
- ### Text Sizes (Tailwind Utilities)
60
-
61
- | Size | Class | Font Size | Line Height | Usage |
62
- |------|-------|-----------|-------------|-------|
63
- | XS | `text-xs` | 0.75rem (12px) | 1rem (16px) | Labels, captions, metadata |
64
- | SM | `text-sm` | 0.875rem (14px) | 1.25rem (20px) | Secondary text, form inputs |
65
- | Base | `text-base` | 1rem (16px) | 1.5rem (24px) | Body text (default) |
66
- | LG | `text-lg` | 1.125rem (18px) | 1.75rem (28px) | Large body text, subheadings |
67
- | XL | `text-xl` | 1.25rem (20px) | 1.75rem (28px) | Section headings |
68
- | 2XL | `text-2xl` | 1.5rem (24px) | 2rem (32px) | Page headings |
69
- | 3XL | `text-3xl` | 1.875rem (30px) | 2.25rem (36px) | Large headings |
70
- | 4XL | `text-4xl` | 2.25rem (36px) | 2.5rem (40px) | Display text |
71
- | 5XL | `text-5xl` | 3rem (48px) | 1 | Hero headings |
72
- | 6XL | `text-6xl` | 3.75rem (60px) | 1 | Large hero text |
73
- | 7XL | `text-7xl` | 4.5rem (72px) | 1 | Extra large display |
74
- | 8XL | `text-8xl` | 6rem (96px) | 1 | Maximum display |
75
- | 9XL | `text-9xl` | 8rem (128px) | 1 | Ultra large display |
76
-
77
- ### Usage Examples
78
-
79
- ```tsx
80
- // React
81
- <h1 className="text-4xl font-bold">Page Title</h1>
82
- <p className="text-base">Body text content</p>
83
- <span className="text-sm text-muted-foreground">Secondary information</span>
84
- ```
85
-
86
- ```vue
87
- <!-- Vue -->
88
- <h1 class="text-4xl font-bold">Page Title</h1>
89
- <p class="text-base">Body text content</p>
90
- <span class="text-sm text-muted-foreground">Secondary information</span>
91
- ```
92
-
93
- ---
94
-
95
- ## Font Weights
96
-
97
- Font weights use Tailwind's standard weight scale:
98
-
99
- | Weight | Class | Value | Usage |
100
- |--------|-------|-------|-------|
101
- | Thin | `font-thin` | 100 | Rarely used |
102
- | Extra Light | `font-extralight` | 200 | Rarely used |
103
- | Light | `font-light` | 300 | Large display text, subtle emphasis |
104
- | Normal | `font-normal` | 400 | Default body text |
105
- | Medium | `font-medium` | 500 | Form inputs, UI labels, subtle emphasis |
106
- | Semi Bold | `font-semibold` | 600 | Headings, important labels |
107
- | Bold | `font-bold` | 700 | Strong emphasis, primary headings |
108
- | Extra Bold | `font-extrabold` | 800 | Maximum emphasis (use sparingly) |
109
- | Black | `font-black` | 900 | Maximum emphasis (use sparingly) |
110
-
111
- ### Recommended Weight Usage
112
-
113
- - **Body Text:** `font-normal` (400) - Default for paragraphs and content
114
- - **Headings:** `font-semibold` (600) or `font-bold` (700)
115
- - **Form Inputs:** `font-medium` (500) or `font-semibold` (600)
116
- - **UI Labels:** `font-medium` (500)
117
- - **Display Text:** `font-light` (300) for large sizes, `font-bold` (700) for impact
118
-
119
- ---
120
-
121
- ## Text Colors
122
-
123
- Text colors use the design system's semantic color tokens from `@equal-experts/kuat-core`. All colors support light and dark modes automatically.
124
-
125
- ### Primary Text Colors
126
-
127
- | Color | Class | Usage |
128
- |-------|-------|-------|
129
- | Foreground | `text-foreground` | Primary text color (default) |
130
- | Muted | `text-muted-foreground` | Secondary text, hints, metadata |
131
- | Primary | `text-primary` | Brand color text |
132
- | Primary Foreground | `text-primary-foreground` | Text on primary backgrounds |
133
- | Secondary | `text-secondary` | Secondary brand color |
134
- | Secondary Foreground | `text-secondary-foreground` | Text on secondary backgrounds |
135
- | Accent | `text-accent` | Accent color text |
136
- | Accent Foreground | `text-accent-foreground` | Text on accent backgrounds |
137
- | Destructive | `text-destructive` | Error text, warnings |
138
- | Destructive Foreground | `text-destructive-foreground` | Text on destructive backgrounds |
139
-
140
- ### Usage Examples
141
-
142
- ```tsx
143
- // React
144
- <p className="text-foreground">Primary text</p>
145
- <p className="text-muted-foreground">Secondary text</p>
146
- <h2 className="text-primary">Brand heading</h2>
147
- <span className="text-destructive">Error message</span>
148
- ```
149
-
150
- ```vue
151
- <!-- Vue -->
152
- <p class="text-foreground">Primary text</p>
153
- <p class="text-muted-foreground">Secondary text</p>
154
- <h2 class="text-primary">Brand heading</h2>
155
- <span class="text-destructive">Error message</span>
156
- ```
157
-
158
- ### Accessibility
159
-
160
- All text color combinations are designed to meet WCAG AA contrast standards:
161
- - **Normal text:** Minimum 4.5:1 contrast ratio
162
- - **Large text (18px+ or 14px+ bold):** Minimum 3:1 contrast ratio
163
-
164
- Always use semantic color tokens rather than hardcoded colors to ensure accessibility.
165
-
166
- ---
167
-
168
- ## Letter Spacing
169
-
170
- Letter spacing is controlled via CSS variables and Tailwind utilities.
171
-
172
- ### Available Classes
173
-
174
- | Class | Value | Usage |
175
- |------|-------|-------|
176
- | `tracking-tighter` | `calc(var(--tracking-normal) - 0.05em)` | Tighter spacing |
177
- | `tracking-tight` | `calc(var(--tracking-normal) - 0.025em)` | Slightly tighter |
178
- | `tracking-normal` | `var(--tracking-normal)` (0.01em) | Default spacing |
179
- | `tracking-wide` | `calc(var(--tracking-normal) + 0.025em)` | Slightly wider |
180
- | `tracking-wider` | `calc(var(--tracking-normal) + 0.05em)` | Wider spacing |
181
- | `tracking-widest` | `calc(var(--tracking-normal) + 0.1em)` | Maximum spacing |
182
-
183
- **Default:** Body text uses `tracking-normal` automatically via CSS variables.
184
-
185
- ---
186
-
187
- ## Line Height
188
-
189
- Line heights are built into Tailwind's typography scale. Use Tailwind's `leading-*` utilities for custom line heights when needed.
190
-
191
- ### Common Line Height Classes
192
-
193
- | Class | Value | Usage |
194
- |------|-------|-------|
195
- | `leading-none` | 1 | Tight spacing (headings) |
196
- | `leading-tight` | 1.25 | Compact text |
197
- | `leading-snug` | 1.375 | Slightly tight |
198
- | `leading-normal` | 1.5 | Default body text |
199
- | `leading-relaxed` | 1.625 | Comfortable reading |
200
- | `leading-loose` | 2 | Generous spacing |
201
-
202
- ---
203
-
204
- ## Typography in Components
205
-
206
- ### Using Typography with shadcn/ui Components
207
-
208
- shadcn/ui components use Tailwind utility classes for typography. You can customize typography by adding classes:
209
-
210
- ```tsx
211
- // React - Button component
212
- <Button className="text-lg font-semibold">
213
- Click me
214
- </Button>
215
-
216
- // React - Card component
217
- <Card>
218
- <CardHeader>
219
- <CardTitle className="text-2xl font-bold">Card Title</CardTitle>
220
- <CardDescription className="text-sm text-muted-foreground">
221
- Card description
222
- </CardDescription>
223
- </CardHeader>
224
- </Card>
225
- ```
226
-
227
- ```vue
228
- <!-- Vue - Button component -->
229
- <Button class="text-lg font-semibold">
230
- Click me
231
- </Button>
232
-
233
- <!-- Vue - Card component -->
234
- <Card>
235
- <CardHeader>
236
- <CardTitle class="text-2xl font-bold">Card Title</CardTitle>
237
- <CardDescription class="text-sm text-muted-foreground">
238
- Card description
239
- </CardDescription>
240
- </CardHeader>
241
- </Card>
242
- ```
243
-
244
- ### Creating Typography Utilities
245
-
246
- For reusable typography patterns, create utility classes or use the `cn()` helper:
247
-
248
- ```tsx
249
- // React
250
- import { cn } from "@/lib/utils"
251
-
252
- const headingStyles = cn(
253
- "text-2xl font-bold text-foreground",
254
- "tracking-tight"
255
- )
256
-
257
- <h1 className={headingStyles}>Heading</h1>
258
- ```
259
-
260
- ```vue
261
- <!-- Vue -->
262
- <script setup>
263
- import { cn } from "@/lib/utils"
264
-
265
- const headingStyles = cn(
266
- "text-2xl font-bold text-foreground",
267
- "tracking-tight"
268
- )
269
- </script>
270
-
271
- <template>
272
- <h1 :class="headingStyles">Heading</h1>
273
- </template>
274
- ```
275
-
276
- ---
277
-
278
- ## Typography Hierarchy
279
-
280
- Establish clear visual hierarchy using size, weight, and color:
281
-
282
- 1. **Primary Heading (H1):** `text-4xl` or `text-5xl` with `font-bold`
283
- 2. **Secondary Heading (H2):** `text-3xl` or `text-2xl` with `font-semibold` or `font-bold`
284
- 3. **Tertiary Heading (H3):** `text-xl` or `text-2xl` with `font-semibold`
285
- 4. **Body Text:** `text-base` with `font-normal`
286
- 5. **Supporting Text:** `text-sm` with `font-normal` or `font-medium`
287
- 6. **Labels/Captions:** `text-xs` or `text-sm` with `text-muted-foreground`
288
-
289
- ### Example Hierarchy
290
-
291
- ```tsx
292
- // React
293
- <div>
294
- <h1 className="text-5xl font-bold text-foreground mb-4">
295
- Main Page Title
296
- </h1>
297
- <h2 className="text-3xl font-semibold text-foreground mb-3">
298
- Section Heading
299
- </h2>
300
- <p className="text-base font-normal text-foreground mb-2">
301
- Body text content goes here. This is the primary content.
302
- </p>
303
- <p className="text-sm text-muted-foreground">
304
- Supporting information or metadata.
305
- </p>
306
- </div>
307
- ```
308
-
309
- ```vue
310
- <!-- Vue -->
311
- <template>
312
- <div>
313
- <h1 class="text-5xl font-bold text-foreground mb-4">
314
- Main Page Title
315
- </h1>
316
- <h2 class="text-3xl font-semibold text-foreground mb-3">
317
- Section Heading
318
- </h2>
319
- <p class="text-base font-normal text-foreground mb-2">
320
- Body text content goes here. This is the primary content.
321
- </p>
322
- <p class="text-sm text-muted-foreground">
323
- Supporting information or metadata.
324
- </p>
325
- </div>
326
- </template>
327
- ```
328
-
329
- ---
330
-
331
- ## Best Practices
332
-
333
- ### ✅ Do's
334
-
335
- 1. **Use Tailwind utility classes**
336
- - ✅ Use `text-*` classes for font sizes
337
- - ✅ Use `font-*` classes for font weights
338
- - ✅ Use semantic color tokens (`text-foreground`, `text-muted-foreground`, etc.)
339
-
340
- 2. **Maintain consistency**
341
- - ✅ Use the same typography scale across components
342
- - ✅ Follow the hierarchy guidelines
343
- - ✅ Use design tokens from `@equal-experts/kuat-core`
344
-
345
- 3. **Ensure accessibility**
346
- - ✅ Use semantic HTML elements (`<h1>`, `<h2>`, `<p>`, etc.)
347
- - ✅ Apply visual styles with classes, not semantic meaning
348
- - ✅ Verify contrast ratios meet WCAG AA standards
349
- - ✅ Use proper heading hierarchy (h1 → h2 → h3, etc.)
350
-
351
- 4. **Use semantic colors**
352
- - ✅ Prefer `text-foreground` over hardcoded colors
353
- - ✅ Use `text-muted-foreground` for secondary text
354
- - ✅ Leverage color tokens for automatic dark mode support
355
-
356
- 5. **Combine utilities effectively**
357
- - ✅ Use the `cn()` utility for conditional classes
358
- - ✅ Create reusable typography patterns
359
- - ✅ Keep class lists readable and maintainable
360
-
361
- ### ❌ Don'ts
362
-
363
- 1. **Don't hardcode typography values**
364
- - ❌ Don't use inline styles for font sizes or weights
365
- - ❌ Don't create custom CSS for typography (use Tailwind)
366
- - ❌ Don't use pixel values directly in components
367
-
368
- 2. **Don't break semantic structure**
369
- - ❌ Don't use heading levels based on appearance
370
- - ❌ Don't use `<h1>` through `<h6>` for styling non-headings
371
- - ❌ Don't skip heading levels (h1 → h3 is invalid)
372
-
373
- 3. **Don't ignore accessibility**
374
- - ❌ Don't use low-contrast text colors
375
- - ❌ Don't use font sizes smaller than 12px for body text
376
- - ❌ Don't rely solely on color to convey information
377
-
378
- 4. **Don't mix font families unnecessarily**
379
- - ❌ Don't use multiple font families in the same component
380
- - ❌ Don't override font-family without a good reason
381
- - ❌ Stick to `font-sans` for most UI elements
382
-
383
- 5. **Don't create custom typography components**
384
- - ❌ Don't create wrapper components for typography (shadcn/ui pattern)
385
- - ❌ Use Tailwind utilities directly
386
- - ❌ Keep typography styling at the element level
387
-
388
- ---
389
-
390
- ## Responsive Typography
391
-
392
- Tailwind's responsive modifiers work with typography utilities:
393
-
394
- ```tsx
395
- // React
396
- <h1 className="text-2xl md:text-4xl lg:text-5xl font-bold">
397
- Responsive Heading
398
- </h1>
399
- ```
400
-
401
- ```vue
402
- <!-- Vue -->
403
- <h1 class="text-2xl md:text-4xl lg:text-5xl font-bold">
404
- Responsive Heading
405
- </h1>
406
- ```
407
-
408
- ---
409
-
410
- ## Dark Mode
411
-
412
- Typography automatically adapts to dark mode through color tokens:
413
-
414
- ```tsx
415
- // React - Colors automatically switch in dark mode
416
- <p className="text-foreground">This text adapts to dark mode</p>
417
- <p className="text-muted-foreground">Secondary text also adapts</p>
418
- ```
419
-
420
- The `text-foreground` and `text-muted-foreground` classes automatically use the appropriate colors based on the `dark` class on the root element.
421
-
422
- ---
423
-
424
- ## Integration with Design System
425
-
426
- Typography integrates seamlessly with other design system elements:
427
-
428
- - **Colors:** Use semantic color tokens (`text-foreground`, `text-primary`, etc.)
429
- - **Spacing:** Combine with Tailwind spacing utilities (`mb-4`, `mt-2`, etc.)
430
- - **Components:** All shadcn/ui components accept typography classes
431
- - **Tokens:** All values come from `@equal-experts/kuat-core/src/variables.css`
432
-
433
- ---
434
-
435
- ## Additional Resources
436
-
437
- - **Design System Overview:** See [design-system.md](./design-system.md) for complete design system documentation
438
- - **Component Guidelines:** See [../technical/component-guidelines.md](../technical/component-guidelines.md) for component development patterns
439
- - **Usage Guide:** See [../usage-guide.md](../usage-guide.md) for quick reference
440
- - **shadcn/ui Typography:** [shadcn/ui Typography Documentation](https://ui.shadcn.com/docs/components/typography)
441
- - **Tailwind Typography:** [Tailwind CSS Typography Documentation](https://tailwindcss.com/docs/font-size)
442
-
443
- ---
444
-
445
- ## Notes
446
-
447
- - **Consistency is key:** Always use Tailwind utility classes for typography
448
- - **Semantic HTML first:** Use proper HTML elements, then style with classes
449
- - **Design tokens:** All typography values reference tokens from `@equal-experts/kuat-core`
450
- - **Flexibility:** shadcn/ui's utility-first approach allows customization while maintaining consistency
451
- - **Accessibility:** Always verify contrast ratios and use semantic HTML structure
@@ -1,88 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- // Get __dirname equivalent in ES modules
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
-
9
- // Paths
10
- const docsSource = path.join(__dirname, '../../../docs/agent');
11
- const docsTarget = path.join(__dirname, '../docs');
12
-
13
- // Clean target directory
14
- if (fs.existsSync(docsTarget)) {
15
- fs.rmSync(docsTarget, { recursive: true });
16
- }
17
-
18
- // Create target directory
19
- fs.mkdirSync(docsTarget, { recursive: true });
20
-
21
- // Copy design docs
22
- console.log('Copying design documentation...');
23
- fs.cpSync(
24
- path.join(docsSource, 'design'),
25
- path.join(docsTarget, 'design'),
26
- { recursive: true }
27
- );
28
-
29
- // Copy component guidelines
30
- console.log('Copying component guidelines...');
31
- fs.mkdirSync(path.join(docsTarget, 'components'), { recursive: true });
32
- fs.copyFileSync(
33
- path.join(docsSource, 'technical/component-guidelines.md'),
34
- path.join(docsTarget, 'components/guidelines.md')
35
- );
36
-
37
- // Copy content guidelines
38
- console.log('Copying content guidelines...');
39
- fs.cpSync(
40
- path.join(docsSource, 'content'),
41
- path.join(docsTarget, 'content'),
42
- { recursive: true }
43
- );
44
-
45
- // Create README
46
- console.log('Creating docs README...');
47
- const readme = `# Agent Documentation
48
-
49
- This directory contains AI-friendly documentation for the Kuat Design System React library.
50
-
51
- ## Contents
52
-
53
- - **[Design System](./design/)** - Colors, typography, spacing, borders
54
- - [Colours](./design/colours.md) - Brand colors and usage guidelines
55
- - [Typography](./design/typography.md) - Font scales and text styling
56
- - [Spacing](./design/spacing.md) - Spacing system and patterns
57
- - [Borders](./design/borders.md) - Border usage and specifications
58
- - [Design System Overview](./design/design-system.md) - Complete design system guide
59
-
60
- - **[Component Guidelines](./components/guidelines.md)** - Component development patterns and best practices
61
-
62
- - **[Content Guidelines](./content/)** - Content writing guidelines
63
- - [Content Foundations](./content/content-foundations.md) - Universal content principles
64
- - [Marketing & Sales](./content/content-marketing-sales.md) - Marketing content guidelines
65
- - [Product & UX](./content/content-product-ux.md) - Product interface writing
66
-
67
- ## Purpose
68
-
69
- These docs are optimized for LLM consumption and provide context for:
70
- - Understanding the design system
71
- - Using components correctly
72
- - Maintaining brand consistency
73
- - Writing appropriate content
74
-
75
- ## Version
76
-
77
- These docs are synchronized with @equal-experts/kuat-react.
78
-
79
- ## Source
80
-
81
- Documentation is sourced from the [Kuat monorepo](https://github.com/equal-experts/kuat) and copied during the build process.
82
- `;
83
-
84
- fs.writeFileSync(path.join(docsTarget, 'README.md'), readme);
85
-
86
- console.log('✓ Documentation copied successfully!');
87
- console.log(` Target: ${docsTarget}`);
88
-
@@ -1,169 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- // Get __dirname equivalent in ES modules
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
-
9
- /**
10
- * Find the consuming app's root directory by looking for package.json
11
- * in parent directories starting from node_modules/@equal-experts/kuat-react
12
- */
13
- function findAppRoot(startDir) {
14
- let currentDir = startDir;
15
-
16
- // First, go up from node_modules/@equal-experts/kuat-react to node_modules
17
- // Then go up to the app root
18
- while (currentDir !== path.dirname(currentDir)) {
19
- const packageJsonPath = path.join(currentDir, 'package.json');
20
- if (fs.existsSync(packageJsonPath)) {
21
- // Check if this is the app root (not the package itself)
22
- const nodeModulesPath = path.join(currentDir, 'node_modules');
23
- if (!fs.existsSync(nodeModulesPath) || !currentDir.includes('node_modules')) {
24
- // This might be the app root, but let's check if we're in node_modules
25
- // If we're in node_modules, the app root is typically 2 levels up
26
- if (currentDir.includes('node_modules')) {
27
- // Go up from node_modules/@equal-experts/kuat-react to app root
28
- let checkDir = currentDir;
29
- while (checkDir !== path.dirname(checkDir)) {
30
- const checkPackageJson = path.join(checkDir, 'package.json');
31
- const checkNodeModules = path.join(checkDir, 'node_modules');
32
- if (fs.existsSync(checkPackageJson) && fs.existsSync(checkNodeModules)) {
33
- return checkDir;
34
- }
35
- checkDir = path.dirname(checkDir);
36
- }
37
- }
38
- return currentDir;
39
- }
40
- }
41
- currentDir = path.dirname(currentDir);
42
- }
43
-
44
- // Fallback: assume we're in node_modules/@equal-experts/kuat-react
45
- // App root should be 3 levels up (node_modules/@equal-experts/kuat-react -> node_modules/@equal-experts -> node_modules -> app root)
46
- let fallbackDir = startDir;
47
- for (let i = 0; i < 3; i++) {
48
- fallbackDir = path.dirname(fallbackDir);
49
- }
50
- return fallbackDir;
51
- }
52
-
53
- /**
54
- * Setup agent documentation by copying from package to .cursor/rules/kuat-docs/
55
- */
56
- function setupDocs() {
57
- try {
58
- // Get the package directory (where this script is located)
59
- const packageDir = path.dirname(__dirname);
60
- const docsSource = path.join(packageDir, 'docs');
61
-
62
- // Check if docs exist in the package
63
- if (!fs.existsSync(docsSource)) {
64
- console.error('❌ Error: Documentation not found in package.');
65
- console.error(` Expected location: ${docsSource}`);
66
- console.error(' Make sure the package is built and docs are included.');
67
- process.exit(1);
68
- }
69
-
70
- // Find the consuming app's root
71
- const appRoot = findAppRoot(packageDir);
72
- const docsTarget = path.join(appRoot, '.cursor', 'rules', 'kuat-docs');
73
-
74
- // Create .cursor/rules directory if it doesn't exist
75
- const cursorRulesDir = path.dirname(docsTarget);
76
- if (!fs.existsSync(cursorRulesDir)) {
77
- fs.mkdirSync(cursorRulesDir, { recursive: true });
78
- console.log(`✓ Created directory: ${cursorRulesDir}`);
79
- }
80
-
81
- // Clean existing docs if they exist
82
- if (fs.existsSync(docsTarget)) {
83
- fs.rmSync(docsTarget, { recursive: true });
84
- console.log(`✓ Cleaned existing docs: ${docsTarget}`);
85
- }
86
-
87
- // Create target directory
88
- fs.mkdirSync(docsTarget, { recursive: true });
89
-
90
- // Copy all docs recursively
91
- console.log('📚 Copying agent documentation...');
92
- console.log(` From: ${docsSource}`);
93
- console.log(` To: ${docsTarget}`);
94
-
95
- fs.cpSync(docsSource, docsTarget, { recursive: true });
96
-
97
- // Create a README in the destination explaining the source
98
- const readmeContent = `# Kuat Design System - Agent Documentation
99
-
100
- This directory contains AI-friendly documentation for the Kuat Design System.
101
-
102
- ## Source
103
-
104
- These docs were copied from \`@equal-experts/kuat-react\` package.
105
-
106
- **Version:** ${getPackageVersion(packageDir)}
107
- **Last Updated:** ${new Date().toISOString()}
108
-
109
- ## Contents
110
-
111
- - **[Design System](./design/)** - Colors, typography, spacing, borders, layouts
112
- - **[Component Guidelines](./components/)** - Component development patterns
113
- - **[Content Guidelines](./content/)** - Content writing guidelines
114
-
115
- ## Purpose
116
-
117
- These docs are optimized for LLM consumption and provide context for:
118
- - Understanding the design system
119
- - Using components correctly
120
- - Maintaining brand consistency
121
- - Writing appropriate content
122
-
123
- ## Updating
124
-
125
- To update these docs after installing a new version of \`@equal-experts/kuat-react\`, run:
126
-
127
- \`\`\`bash
128
- pnpm exec @equal-experts/kuat-react setup-docs
129
- \`\`\`
130
-
131
- Or if you have the package installed locally:
132
-
133
- \`\`\`bash
134
- cd node_modules/@equal-experts/kuat-react && pnpm setup-docs
135
- \`\`\`
136
- `;
137
-
138
- fs.writeFileSync(path.join(docsTarget, 'README.md'), readmeContent);
139
-
140
- console.log('✓ Documentation copied successfully!');
141
- console.log(`\n📖 Documentation is now available at: ${docsTarget}`);
142
- console.log(' You can reference these files in your Cursor rules or LLM context.\n');
143
-
144
- } catch (error) {
145
- console.error('❌ Error setting up documentation:');
146
- console.error(error.message);
147
- process.exit(1);
148
- }
149
- }
150
-
151
- /**
152
- * Get package version from package.json
153
- */
154
- function getPackageVersion(packageDir) {
155
- try {
156
- const packageJsonPath = path.join(packageDir, 'package.json');
157
- if (fs.existsSync(packageJsonPath)) {
158
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
159
- return packageJson.version || 'unknown';
160
- }
161
- } catch (error) {
162
- // Ignore errors
163
- }
164
- return 'unknown';
165
- }
166
-
167
- // Run the setup
168
- setupDocs();
169
-