@cere/cere-design-system 0.0.11 → 0.0.13

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.
@@ -0,0 +1,44 @@
1
+ # Multi-Agent Factory Pattern
2
+
3
+ ## Purpose
4
+ Allow different AI coding agents (Warp, Claude Code, Cursor, Copilot, etc.) to work with this design system using standardized interfaces while leveraging agent-specific capabilities.
5
+
6
+ ## Agent Capabilities Matrix
7
+
8
+ | Agent | Strengths | Best For |
9
+ |-------|-----------|----------|
10
+ | Warp Agent Mode | Shell integration, file operations | Build automation, testing workflows |
11
+ | Claude Code | Long context, complex reasoning | Architecture, refactoring, documentation |
12
+ | GitHub Copilot | Code completion, patterns | Rapid prototyping, boilerplate |
13
+ | Cursor | IDE integration, inline edits | Component implementation, quick fixes |
14
+
15
+ ## Agent Configuration Files
16
+ Spec Kit supports multiple agents through dedicated command files:
17
+ - `.claude/` - Claude-specific commands
18
+ - `.github/copilot-instructions.md` - Copilot context
19
+ - `.cursor/rules` - Cursor IDE rules
20
+ - `.warp/` - Warp agent configuration
21
+
22
+ All agents should reference:
23
+ - `.specify/memory/constitution.md` - Core principles
24
+ - `.specify/memory/toolkits.md` - Available toolkits
25
+ - `.specify/templates/` - Spec templates
26
+
27
+ ## Pluggable Toolkit Loading
28
+ Each spec can declare required toolkits in frontmatter:
29
+ ```yaml
30
+ ---
31
+ toolkits:
32
+ - mui-component-generator
33
+ - storybook-docs
34
+ agent_hints:
35
+ preferred: claude
36
+ complexity: high
37
+ ---
38
+ ```
39
+
40
+ Agents read this metadata and activate appropriate specialized knowledge.
41
+
42
+ ## Implementation
43
+ No code changes required - this is a documentation and organizational pattern.
44
+ Agents interpret these files as context when working on specs.
@@ -1,6 +1,4 @@
1
- # AGENTS.md
2
-
3
- This file provides guidance to WARP (warp.dev) when working with code in this repository.
1
+ # architecture.md
4
2
 
5
3
  ## Project Overview
6
4
 
@@ -0,0 +1,73 @@
1
+ # Component Architecture Patterns
2
+
3
+ ## File Structure Convention
4
+ ```
5
+ src/
6
+ ├── components/
7
+ │ ├── buttons/
8
+ │ │ ├── Button.tsx
9
+ │ │ ├── Button.stories.tsx
10
+ │ │ └── __tests__/
11
+ │ │ └── Button.test.tsx
12
+ │ ├── inputs/
13
+ │ ├── navigation/
14
+ │ ├── layout/
15
+ │ ├── feedback/
16
+ │ ├── charts/
17
+ │ ├── third-party/
18
+ │ └── utilities/
19
+ ├── theme/
20
+ │ └── index.ts (theme definition)
21
+ ├── hooks/
22
+ │ └── useResponsive.ts
23
+ └── index.ts (public API)
24
+ ```
25
+
26
+ ## Component Template Pattern
27
+ ```typescript
28
+ import { styled } from '@mui/material/styles';
29
+ import MuiButton from '@mui/material/Button';
30
+ import type { ButtonProps as MuiButtonProps } from '@mui/material/Button';
31
+
32
+ export interface ButtonProps extends Omit<MuiButtonProps, 'variant'> {
33
+ variant?: 'primary' | 'secondary' | 'tertiary';
34
+ }
35
+
36
+ const StyledButton = styled(MuiButton)<ButtonProps>(({ theme, variant }) => ({
37
+ borderRadius: theme.spacing(1.5),
38
+ ...(variant === 'primary' && {
39
+ // Primary styles
40
+ }),
41
+ }));
42
+
43
+ export const Button: React.FC<ButtonProps> = ({ variant = 'primary', ...props }) => {
44
+ return <StyledButton variant={variant} {...props} />;
45
+ };
46
+ ```
47
+
48
+ ## Export Pattern
49
+ All components must be exported from `src/index.ts`:
50
+ ```typescript
51
+ export { Button } from './components/buttons/Button';
52
+ export type { ButtonProps } from './components/buttons/Button';
53
+ export { theme, colors } from './theme';
54
+ ```
55
+
56
+ ## Testing Pattern
57
+ ```typescript
58
+ import { render, screen } from '@testing-library/react';
59
+ import { ThemeProvider } from '@mui/material/styles';
60
+ import { theme } from '@/theme';
61
+ import { Button } from '../Button';
62
+
63
+ const renderWithTheme = (component: React.ReactElement) => {
64
+ return render(<ThemeProvider theme={theme}>{component}</ThemeProvider>);
65
+ };
66
+
67
+ describe('Button', () => {
68
+ it('renders primary variant', () => {
69
+ renderWithTheme(<Button variant="primary">Test</Button>);
70
+ expect(screen.getByRole('button')).toBeInTheDocument();
71
+ });
72
+ });
73
+ ```
@@ -1,3 +1,5 @@
1
+ # Cere Design System - Component Reference
2
+
1
3
  You are a senior UI developer with expertise in React, TypeScript, Material-UI, and the Cere Design System.
2
4
  When building applications using this design system, follow these guidelines and use the components documented below.
3
5
 
@@ -1348,4 +1350,4 @@ All icons are React components that accept standard SVG props (width, height, co
1348
1350
  </Grid>
1349
1351
  </Grid>
1350
1352
  </Container>
1351
- ```
1353
+ ```
@@ -0,0 +1,295 @@
1
+ # Cere Design System Constitution
2
+
3
+ This constitution defines the immutable principles and standards that govern the development of the Cere Design System (@cere/cere-design-system). All components, features, and changes must comply with these articles.
4
+
5
+ ## Article I: Material UI Foundation
6
+
7
+ **All components MUST extend Material UI components using `styled()` or `sx` prop patterns.**
8
+
9
+ ### Requirements
10
+ - Components must be built on top of Material UI base components
11
+ - Use MUI's `styled()` API from `@mui/material/styles` or the `sx` prop for styling
12
+ - Components must support MUI's theming system and be compatible with `ThemeProvider`
13
+ - Follow MUI's component API conventions (props, variants, sizes, event handlers)
14
+ - Maintain backward compatibility with existing component APIs unless a major version bump is warranted
15
+
16
+ ### Rationale
17
+ Material UI provides a battle-tested foundation with accessibility, theming, and responsive design built-in. Extending MUI ensures consistency and reduces maintenance burden.
18
+
19
+ ## Article II: Component Modularity
20
+
21
+ **Each component must be self-contained, independently exportable, and follow the established file structure.**
22
+
23
+ ### Requirements
24
+ - Each component must reside in its appropriate category folder under `src/components/`:
25
+ - `buttons/`, `inputs/`, `navigation/`, `layout/`, `feedback/`, `charts/`, `third-party/`, `utilities/`
26
+ - Components must export both the component itself and its TypeScript type interfaces
27
+ - All public exports must be registered in `src/index.ts` (both component and type exports)
28
+ - Components must not have tight coupling; prefer composition patterns and prop-based configuration
29
+ - Each component must be independently importable: `import { Button } from '@cere/cere-design-system'`
30
+
31
+ ### File Structure
32
+ ```
33
+ src/components/[category]/
34
+ ├── [ComponentName].tsx # Component implementation
35
+ ├── [ComponentName].stories.tsx # Storybook documentation
36
+ └── __tests__/
37
+ └── [ComponentName].test.tsx # Jest tests
38
+ ```
39
+
40
+ ## Article III: Testing Standards (NON-NEGOTIABLE)
41
+
42
+ **Every component MUST have comprehensive test coverage before being merged.**
43
+
44
+ ### Requirements
45
+ 1. **Jest Unit Tests** (in `__tests__/` subdirectory):
46
+ - Target: 80%+ code coverage
47
+ - Test rendering, user interactions, prop variants, callbacks, disabled/error states
48
+ - Use React Testing Library idioms (prefer `getByRole`, `getByLabelText`, user-event)
49
+ - Tests must wrap components with `ThemeProvider` using the design system theme
50
+
51
+ 2. **Storybook Stories** (with all variants/states documented):
52
+ - Create stories for all visual variants, sizes, and states
53
+ - Include interaction tests using `play` functions from `@storybook/test`
54
+ - Document props with JSDoc comments that appear in Storybook
55
+
56
+ 3. **Accessibility Tests**:
57
+ - Storybook integration with axe-playwright automatically checks accessibility
58
+ - Run via `npm run test:storybook`
59
+ - All interactive components must pass WCAG AA standards
60
+
61
+ ### Test Pattern
62
+ ```typescript
63
+ import { render, screen } from '@testing-library/react';
64
+ import { ThemeProvider } from '@mui/material/styles';
65
+ import { theme } from '@/theme';
66
+
67
+ const renderWithTheme = (component: React.ReactElement) => {
68
+ return render(
69
+ <ThemeProvider theme={theme}>
70
+ {component}
71
+ </ThemeProvider>
72
+ );
73
+ };
74
+ ```
75
+
76
+ ## Article IV: Type Safety
77
+
78
+ **All components must be written in TypeScript with explicit, strict type definitions.**
79
+
80
+ ### Requirements
81
+ - All components must be written in TypeScript (`.tsx` files)
82
+ - Export all prop interfaces with `Props` suffix (e.g., `ButtonProps`, `TextFieldProps`)
83
+ - Use strict TypeScript configuration; avoid `any` types
84
+ - Provide comprehensive JSDoc comments for all public APIs and prop interfaces
85
+ - Type exports must be separate from component exports in `src/index.ts`:
86
+ ```typescript
87
+ export { Button } from './components/buttons/Button';
88
+ export type { ButtonProps } from './components/buttons/Button';
89
+ ```
90
+
91
+ ### Type Definition Pattern
92
+ ```typescript
93
+ import type { ButtonProps as MuiButtonProps } from '@mui/material/Button';
94
+
95
+ export interface ButtonProps extends Omit<MuiButtonProps, 'variant'> {
96
+ variant?: 'primary' | 'secondary' | 'tertiary';
97
+ // Custom props with JSDoc
98
+ }
99
+ ```
100
+
101
+ ## Article V: Build System Integrity
102
+
103
+ **The package build system must produce optimized, tree-shakeable outputs with proper peer dependencies.**
104
+
105
+ ### Requirements
106
+ - Package builds via `tsup` producing:
107
+ - CommonJS format (`dist/index.js`)
108
+ - ESM format (`dist/index.mjs`)
109
+ - TypeScript declarations (`dist/index.d.ts`)
110
+ - All React, MUI, Monaco, and ReactFlow packages must be peer dependencies (not bundled)
111
+ - No new dependencies without evaluating if they should be peer dependencies
112
+ - Entry point is `src/index.ts` - all public APIs must export through this single file
113
+ - Build must complete without errors: `npm run build`
114
+ - Type checking must pass: `npm run type-check`
115
+ - Linting must pass: `npm run lint`
116
+
117
+ ### Peer Dependencies
118
+ ```json
119
+ {
120
+ "peerDependencies": {
121
+ "react": "^18.0.0",
122
+ "react-dom": "^18.0.0",
123
+ "@mui/material": "^5.0.0",
124
+ "@emotion/react": "^11.0.0",
125
+ "@emotion/styled": "^11.0.0"
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## Article VI: Documentation Requirements
131
+
132
+ **Every component must have comprehensive, up-to-date documentation.**
133
+
134
+ ### Requirements
135
+ 1. **Storybook Documentation**:
136
+ - Every component must have a `.stories.tsx` file
137
+ - Stories must demonstrate all variants, sizes, and states
138
+ - Include interactive examples and code snippets
139
+
140
+ 2. **Component Reference**:
141
+ - Keep `.specify/memory/components-reference.md` synchronized with all component changes
142
+ - Document all props, usage examples, and best practices
143
+ - Update after every component addition or API change
144
+
145
+ 3. **Type Documentation**:
146
+ - Add JSDoc comments to all exported interfaces and components
147
+ - Document prop purposes, default values, and constraints
148
+
149
+ 4. **Versioning**:
150
+ - Breaking changes require version updates following semver (MAJOR.MINOR.PATCH)
151
+ - Maintain a changelog documenting all changes
152
+
153
+ ## Article VII: Design Consistency
154
+
155
+ **All components must follow the design tokens defined in the theme.**
156
+
157
+ ### Design Tokens (Defined in `src/theme/index.ts`)
158
+ - **Primary color**: `#1976d2` (blue)
159
+ - **Border radius**:
160
+ - Inputs/buttons: `12px`
161
+ - Cards/chips: `16px`
162
+ - **Typography**: Inter font family
163
+ - **Component variants**: primary, secondary, tertiary (where applicable)
164
+ - **Spacing**: Use theme's spacing system (`theme.spacing(n)` where n is a multiple of 8px)
165
+
166
+ ### Requirements
167
+ - Components must reference theme tokens, not hardcoded values
168
+ - Use `useTheme()` hook or `colors` import for accessing theme values
169
+ - Maintain visual consistency across the design system
170
+ - Responsive design using MUI Grid system or custom responsive hooks
171
+
172
+ ### Theme Usage Pattern
173
+ ```typescript
174
+ import { useTheme } from '@mui/material/styles';
175
+ import { colors } from '@cere/cere-design-system';
176
+
177
+ const theme = useTheme();
178
+ // Use: theme.palette.primary.main
179
+ // Use: colors.primary.main
180
+ // Use: theme.spacing(2) // 16px
181
+ ```
182
+
183
+ ## Article VIII: Accessibility First
184
+
185
+ **All interactive components must be fully accessible to keyboard and assistive technology users.**
186
+
187
+ ### Requirements
188
+ - All interactive components must be keyboard navigable (Tab, Enter, Space, Arrow keys)
189
+ - Provide proper ARIA labels, roles, and live regions
190
+ - Ensure color contrast meets WCAG AA standards (4.5:1 for normal text, 3:1 for large text)
191
+ - Support screen readers and assistive technologies
192
+ - Test with Storybook's axe-playwright integration
193
+ - Focus management for dialogs, drawers, and modals
194
+
195
+ ### Accessibility Checklist
196
+ - [ ] Keyboard navigation works correctly
197
+ - [ ] ARIA attributes are present and accurate
198
+ - [ ] Color contrast passes WCAG AA
199
+ - [ ] Screen reader announces changes appropriately
200
+ - [ ] Focus indicators are visible
201
+ - [ ] No keyboard traps
202
+
203
+ ## Article IX: Third-Party Integration
204
+
205
+ **Third-party component wrappers must provide typed interfaces and maintain clear boundaries.**
206
+
207
+ ### Requirements
208
+ For wrappers around third-party libraries (e.g., FlowEditor wrapping ReactFlow, CodeEditor wrapping Monaco):
209
+
210
+ 1. **Type Safety**:
211
+ - Provide typed interfaces aligned with the underlying library
212
+ - Re-export commonly used types from the third-party library
213
+ - Make wrapper-specific props clearly distinct from pass-through props
214
+
215
+ 2. **Theme Integration**:
216
+ - Include theme integration where applicable
217
+ - Respect design system colors, typography, and spacing
218
+
219
+ 3. **Documentation**:
220
+ - Maintain clear documentation of wrapper-specific vs. pass-through props
221
+ - Document which third-party features are exposed vs. hidden
222
+ - Provide migration guides if wrapper APIs change
223
+
224
+ 4. **Peer Dependencies**:
225
+ - Third-party libraries must be peer dependencies
226
+ - Document minimum required versions
227
+
228
+ ### Example: FlowEditor
229
+ ```typescript
230
+ import type { Node, Edge, ReactFlowInstance } from 'reactflow';
231
+
232
+ export interface FlowEditorProps {
233
+ nodes: Node[]; // From reactflow
234
+ edges: Edge[]; // From reactflow
235
+ height?: string; // Wrapper-specific
236
+ showBackground?: boolean; // Wrapper-specific
237
+ // ... other props
238
+ }
239
+
240
+ // Re-export common types
241
+ export type { Node, Edge, NodeTypes, EdgeTypes, ReactFlowInstance } from 'reactflow';
242
+ ```
243
+
244
+ ## Development Workflow
245
+
246
+ ### Component Development Process
247
+ 1. **Specification**: Create a feature spec using `/speckit.specify`
248
+ 2. **Planning**: Generate implementation plan using `/speckit.plan`
249
+ 3. **Task Breakdown**: Create task checklist using `/speckit.tasks`
250
+ 4. **Implementation**: Follow the tasks, adhering to all articles above
251
+ 5. **Validation**: Run all checks before PR:
252
+ ```bash
253
+ npm run type-check && npm run lint && npm run test && npm run build && npm run test:storybook
254
+ ```
255
+ 6. **Review**: Code review must verify constitutional compliance
256
+ 7. **Documentation**: Update `components-reference.md` before merging
257
+
258
+ ### Quality Gates
259
+ All PRs must pass:
260
+ - ✅ TypeScript compilation
261
+ - ✅ ESLint checks
262
+ - ✅ Jest tests (80%+ coverage)
263
+ - ✅ Build succeeds
264
+ - ✅ Storybook accessibility tests
265
+ - ✅ Component reference updated
266
+ - ✅ Constitutional compliance verified
267
+
268
+ ## Governance
269
+
270
+ ### Constitutional Supremacy
271
+ - This constitution supersedes all other development practices and guidelines
272
+ - When in conflict, the constitution takes precedence
273
+ - All code reviews must verify compliance with these articles
274
+
275
+ ### Amendments
276
+ - Constitutional amendments require:
277
+ 1. Documented rationale for the change
278
+ 2. Team approval/consensus
279
+ 3. Migration plan for existing components if needed
280
+ 4. Version update in this document
281
+
282
+ ### Non-Negotiable Articles
283
+ - **Article III (Testing Standards)**: Cannot be waived or reduced
284
+ - **Article VIII (Accessibility First)**: Cannot be compromised
285
+
286
+ ### Guidance Documents
287
+ For detailed development patterns and examples, consult:
288
+ - `.specify/memory/architecture.md` - Component architecture patterns
289
+ - `.specify/memory/design-tokens.md` - Complete design token reference
290
+ - `.specify/memory/workflow.md` - Step-by-step development workflow
291
+ - `.specify/memory/components-reference.md` - Complete component API documentation
292
+
293
+ ---
294
+
295
+ **Version**: 1.0.0 | **Ratified**: 2026-02-03 | **Last Amended**: 2026-02-03
@@ -0,0 +1,139 @@
1
+ # Cere Design System - Design Tokens
2
+
3
+ ## Color Palette
4
+
5
+ ### Primary Colors
6
+ - Primary Main: `#1976d2` (blue)
7
+ - Primary Light: `#42a5f5`
8
+ - Primary Dark: `#1565c0`
9
+ - Primary Contrast Text: `#ffffff`
10
+
11
+ ### Secondary Colors
12
+ - Secondary Main: `#dc004e`
13
+ - Secondary Light: `#f50057`
14
+ - Secondary Dark: `#9a0036`
15
+ - Secondary Contrast Text: `#ffffff`
16
+
17
+ ### Tertiary Colors
18
+ - Tertiary Main: `#ff9800` (orange/amber)
19
+
20
+ ### Semantic Colors
21
+ - Error: `#f44336`
22
+ - Warning: `#ff9800`
23
+ - Info: `#2196f3`
24
+ - Success: `#4caf50`
25
+
26
+ ### Grey Scale
27
+ - Grey 50: `#fafafa`
28
+ - Grey 100: `#f5f5f5`
29
+ - Grey 200: `#eeeeee`
30
+ - Grey 300: `#e0e0e0`
31
+ - Grey 400: `#bdbdbd`
32
+ - Grey 500: `#9e9e9e`
33
+ - Grey 600: `#757575`
34
+ - Grey 700: `#616161`
35
+ - Grey 800: `#424242`
36
+ - Grey 900: `#212121`
37
+
38
+ ### Background
39
+ - Default: `#fafafa`
40
+ - Paper: `#ffffff`
41
+ - Selected: `rgba(25, 118, 210, 0.08)`
42
+
43
+ ### Text
44
+ - Primary: `rgba(0, 0, 0, 0.87)`
45
+ - Secondary: `rgba(0, 0, 0, 0.6)`
46
+ - Disabled: `rgba(0, 0, 0, 0.38)`
47
+
48
+ ## Typography
49
+
50
+ ### Font Family
51
+ - Primary: `'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif`
52
+
53
+ ### Font Weights
54
+ - Light: 300
55
+ - Regular: 400
56
+ - Medium: 500
57
+ - Semi-Bold: 600
58
+ - Bold: 700
59
+
60
+ ### Type Scale
61
+ - h1: 2.5rem (40px), weight: 700
62
+ - h2: 2rem (32px), weight: 700
63
+ - h3: 1.75rem (28px), weight: 600
64
+ - h4: 1.5rem (24px), weight: 600
65
+ - h5: 1.25rem (20px), weight: 600
66
+ - h6: 1rem (16px), weight: 600
67
+ - subtitle1: 1rem (16px), weight: 500
68
+ - subtitle2: 0.875rem (14px), weight: 500
69
+ - body1: 1rem (16px), weight: 400
70
+ - body2: 0.875rem (14px), weight: 400
71
+ - caption: 0.75rem (12px), weight: 400
72
+ - button: 0.875rem (14px), weight: 500, uppercase
73
+ - overline: 0.625rem (10px), weight: 400, uppercase
74
+
75
+ ## Spacing System
76
+ Based on 8px scale:
77
+ - 0: 0px
78
+ - 1: 8px
79
+ - 2: 16px
80
+ - 3: 24px
81
+ - 4: 32px
82
+ - 5: 40px
83
+ - 6: 48px
84
+ - 7: 56px
85
+ - 8: 64px
86
+ - 9: 72px
87
+ - 10: 80px
88
+
89
+ ## Border Radius
90
+ - Small (inputs, buttons): 12px
91
+ - Medium (cards, chips): 16px
92
+ - Large: 24px
93
+ - Circle: 50%
94
+
95
+ ## Elevation (Shadows)
96
+ Follows Material Design elevation levels:
97
+ - Level 0: none
98
+ - Level 1: `0px 2px 4px rgba(0,0,0,0.1)`
99
+ - Level 2: `0px 4px 8px rgba(0,0,0,0.1)`
100
+ - Level 3: `0px 6px 12px rgba(0,0,0,0.1)`
101
+ - Level 24: Maximum elevation
102
+
103
+ ## Breakpoints
104
+ - xs: 0px (mobile)
105
+ - sm: 600px (tablet)
106
+ - md: 960px (desktop)
107
+ - lg: 1280px (large desktop)
108
+ - xl: 1920px (extra large)
109
+
110
+ ## Custom Breakpoint Hooks
111
+ - `useIsMobile()`: < 768px
112
+ - `useIsTablet()`: 768px - 1024px
113
+ - `useIsDesktop()`: > 1024px
114
+
115
+ ## Transitions
116
+ - Duration: 300ms (standard)
117
+ - Easing: cubic-bezier(0.4, 0, 0.2, 1)
118
+
119
+ ## Z-Index Scale
120
+ - Drawer: 1200
121
+ - AppBar: 1100
122
+ - Modal: 1300
123
+ - Snackbar: 1400
124
+ - Tooltip: 1500
125
+
126
+ ## Implementation
127
+ All tokens are defined in `src/theme/index.ts` using MUI's `createTheme()`.
128
+ Components should reference theme tokens, not hardcoded values.
129
+
130
+ Example:
131
+ ```typescript
132
+ import { useTheme } from '@mui/material';
133
+ import { colors } from '@cere/cere-design-system';
134
+
135
+ const theme = useTheme();
136
+ // Use: theme.palette.primary.main
137
+ // Use: colors.primary.main
138
+ // Use: theme.spacing(2) // 16px
139
+ ```
@@ -0,0 +1,99 @@
1
+ # Using Cere Design System in Your Application's Spec Kit
2
+
3
+ ## Overview
4
+ This guide shows how to reference and use the Cere Design System (@cere/cere-design-system) in your application's Spec-Driven Development workflow.
5
+
6
+ ## Installation
7
+ ```bash
8
+ npm install @cere/cere-design-system
9
+ ```
10
+
11
+ ## Referencing in Your Application's Specs
12
+
13
+ ### Method 1: Direct Reference in Constitution
14
+ In your application's `.specify/memory/constitution.md`, add an article requiring the design system:
15
+
16
+ ```markdown
17
+ # Application Constitution
18
+
19
+ ## Article: UI Component Standards
20
+
21
+ ### Design System Requirement
22
+ All UI components MUST use the Cere Design System (@cere/cere-design-system).
23
+
24
+ ### Component Reference
25
+ Available components and their APIs are documented at:
26
+ `node_modules/@cere/cere-design-system/.specify/memory/components-reference.md`
27
+
28
+ All developers and AI agents MUST consult this reference before implementing UI features.
29
+
30
+ ### Usage Requirements
31
+ 1. Always wrap application with ThemeProvider:
32
+ ```tsx
33
+ import { ThemeProvider, theme } from '@cere/cere-design-system';
34
+
35
+ <ThemeProvider theme={theme}>
36
+ <App />
37
+ </ThemeProvider>
38
+ ```
39
+
40
+ 2. Import components from the package:
41
+ ```tsx
42
+ import { Button, TextField, Card } from '@cere/cere-design-system';
43
+ import type { ButtonProps } from '@cere/cere-design-system';
44
+ ```
45
+ ```
46
+
47
+ ### Method 2: Create Design System Memory Reference
48
+ Create `.specify/memory/design-system.md` in your application:
49
+
50
+ ```markdown
51
+ # Cere Design System Reference
52
+
53
+ This application uses @cere/cere-design-system
54
+
55
+ ## Quick Reference
56
+ See complete component reference:
57
+ `node_modules/@cere/cere-design-system/.specify/memory/components-reference.md`
58
+
59
+ ## Example Usage
60
+ ```tsx
61
+ import { Card, TextField, LoadingButton, Alert } from '@cere/cere-design-system';
62
+
63
+ <Card>
64
+ <CardContent>
65
+ <Stack spacing={2}>
66
+ <TextField label="Email" />
67
+ <LoadingButton variant="primary">Submit</LoadingButton>
68
+ </Stack>
69
+ </CardContent>
70
+ </Card>
71
+ ```
72
+ ```
73
+
74
+ ## AI Agent Instructions
75
+
76
+ When AI agents work on specs that use the Cere Design System:
77
+
78
+ ### 1. Always Reference Component Documentation
79
+ Before suggesting code, agents should reference:
80
+ `node_modules/@cere/cere-design-system/.specify/memory/components-reference.md`
81
+
82
+ ### 2. Follow Design System Patterns
83
+ - Use ThemeProvider wrapper
84
+ - Import components from package root
85
+ - Use design system colors/theme tokens
86
+
87
+ ### 3. Type Safety
88
+ Always import TypeScript types:
89
+ ```tsx
90
+ import type { ButtonProps, TextFieldProps } from '@cere/cere-design-system';
91
+ ```
92
+
93
+ ## Best Practices Summary
94
+
95
+ 1. ✅ **Always reference** `components-reference.md` before using components
96
+ 2. ✅ **Import types** for TypeScript safety
97
+ 3. ✅ **Use ThemeProvider** at application root
98
+ 4. ✅ **Follow design system patterns** for consistency
99
+ 5. ✅ **Include design system requirements** in feature specs
@@ -0,0 +1,57 @@
1
+ # AI Coding Agent Toolkits for Material UI Design Systems
2
+
3
+ ## Supported Toolkits
4
+
5
+ ### 1. Material UI Component Generator (Primary)
6
+ **Specialization:** MUI-based React component development
7
+ **Use Cases:** Creating new components, extending MUI components
8
+ **Configuration:**
9
+ - Base library: @mui/material
10
+ - Styling approach: styled-components + emotion
11
+ - Theme system: MUI theming
12
+
13
+ ### 2. Storybook Documentation Toolkit
14
+ **Specialization:** Component documentation and interaction testing
15
+ **Use Cases:** Creating stories, play functions, a11y tests
16
+ **Configuration:**
17
+ - Framework: Storybook 7+
18
+ - Testing: @storybook/test, axe-playwright
19
+
20
+ ### 3. Jest Testing Toolkit
21
+ **Specialization:** Unit and integration testing
22
+ **Use Cases:** Writing tests, achieving coverage targets
23
+ **Configuration:**
24
+ - Framework: Jest + React Testing Library
25
+ - Coverage target: 80%+
26
+ - Setup: src/setupTests.ts
27
+
28
+ ### 4. TypeScript Type System Toolkit
29
+ **Specialization:** Type definitions and interfaces
30
+ **Use Cases:** Creating types, ensuring type safety
31
+ **Configuration:**
32
+ - Strict mode: enabled
33
+ - Export pattern: ComponentProps interfaces
34
+
35
+ ## Toolkit Selection Strategy
36
+ Based on the feature type, select appropriate toolkit(s):
37
+
38
+ | Feature Type | Primary Toolkit | Secondary Toolkits |
39
+ |--------------|----------------|---------------------|
40
+ | New Component | MUI Component Generator | Storybook, Jest, TypeScript |
41
+ | Component Enhancement | MUI Component Generator | Jest, TypeScript |
42
+ | Documentation | Storybook | - |
43
+ | Testing | Jest | - |
44
+ | Type Updates | TypeScript | - |
45
+ | Integration | All | - |
46
+
47
+ ## Dynamic Loading
48
+ Toolkits can be referenced in specs using:
49
+ ```yaml
50
+ required_toolkits:
51
+ - mui-component-generator
52
+ - storybook-docs
53
+ - jest-testing
54
+ - typescript-types
55
+ ```
56
+
57
+ The AI agent should activate appropriate context and specialized knowledge for each toolkit.
@@ -0,0 +1,87 @@
1
+ # Spec-Driven Development Workflow for Cere Design System
2
+
3
+ ## Workflow Phases
4
+
5
+ ### 1. Constitution (One-time Setup)
6
+ Run once when starting spec-driven development:
7
+ ```bash
8
+ /speckit.constitution
9
+ ```
10
+ Review and customize the constitution to match team principles.
11
+
12
+ ### 2. Specify (Feature Definition)
13
+ For each new component or feature:
14
+ ```bash
15
+ /speckit.specify Create a [ComponentName] component that...
16
+ ```
17
+
18
+ This creates:
19
+ - New git branch: `001-component-name`
20
+ - Spec file: `specs/001-component-name/spec.md`
21
+ - Populates spec from template with feature details
22
+
23
+ **Review the spec:**
24
+ - Verify component category
25
+ - Confirm Material UI base component
26
+ - Review props interface
27
+ - Validate accessibility requirements
28
+
29
+ ### 3. Plan (Technical Design)
30
+ After spec is approved:
31
+ ```bash
32
+ /speckit.plan
33
+ ```
34
+
35
+ This creates:
36
+ - Plan file: `specs/001-component-name/plan.md`
37
+ - Technical implementation details
38
+ - Phase-by-phase breakdown
39
+
40
+ ### 4. Tasks (Implementation Breakdown)
41
+ After plan is approved:
42
+ ```bash
43
+ /speckit.tasks
44
+ ```
45
+
46
+ This creates:
47
+ - Tasks file: `specs/001-component-name/tasks.md`
48
+ - Granular checklist of implementation steps
49
+
50
+ ### 5. Implement (Execution)
51
+ Work through tasks systematically:
52
+
53
+ **Setup Phase:**
54
+ - Create component file
55
+ - Create test file
56
+ - Create story file
57
+
58
+ **Implementation Phase:**
59
+ - Define TypeScript interfaces
60
+ - Implement component logic
61
+ - Add theme integration
62
+
63
+ **Testing Phase:**
64
+ - Write unit tests
65
+ - Create Storybook stories
66
+ - Run accessibility checks
67
+
68
+ **Validation Phase:**
69
+ ```bash
70
+ npm run type-check && npm run lint && npm test && npm run build && npm run test:storybook
71
+ ```
72
+
73
+ ### 6. Review (Quality Assurance)
74
+ - Code review on PR
75
+ - Visual design review in Storybook
76
+ - Accessibility audit results
77
+
78
+ ### 7. Merge & Document
79
+ - Merge feature branch to main
80
+ - Update package version if needed
81
+ - Update changelog
82
+
83
+ ## Best Practices
84
+ 1. Always start with a spec - don't code directly
85
+ 2. One component per spec/branch
86
+ 3. Keep specs focused and atomic
87
+ 4. Update components-reference.md after merging
package/README.md CHANGED
@@ -201,6 +201,141 @@ npm run lint
201
201
  - **Warning**: Orange/Yellow (#F59E0B)
202
202
  - **Tertiary**: Orange/Yellow (#F59E0B)
203
203
 
204
+ ## Spec-Driven Development
205
+
206
+ This project uses [GitHub Spec Kit](https://github.com/github/spec-kit) (`specify-cli`) for spec-driven development - a methodology where every feature starts with a specification document before implementation.
207
+
208
+ ### What is Spec-Driven Development?
209
+
210
+ Spec-Driven Development (SDD) is a structured approach to software development where:
211
+ 1. **Specs define features** - Write clear specifications before coding
212
+ 2. **Plans outline architecture** - Technical designs guide implementation
213
+ 3. **Tasks break down work** - Granular checklists ensure completeness
214
+ 4. **AI agents assist** - Specs provide context for AI-powered development
215
+
216
+ This ensures consistency, clarity, and maintainability across the entire design system.
217
+
218
+ ### Using Specify CLI
219
+
220
+ Install `specify-cli` (recommended via `uv`):
221
+ ```bash
222
+ uv tool install specify-cli
223
+ ```
224
+
225
+ Or with pipx/npm:
226
+ ```bash
227
+ pipx install specify-cli
228
+ # or
229
+ npm install -g specify-cli
230
+ ```
231
+
232
+ ### Development Workflow
233
+
234
+ #### 1. **Create a Specification**
235
+ Use AI agents (Cursor, Warp, Claude, etc.) with the `/speckit.specify` command:
236
+ ```bash
237
+ /speckit.specify Create a [ComponentName] component that [does something]
238
+ ```
239
+
240
+ This creates:
241
+ - New git branch: `001-component-name`
242
+ - Spec file: `specs/001-component-name/spec.md`
243
+ - Populated template with requirements, APIs, and acceptance criteria
244
+
245
+ #### 2. **Generate Implementation Plan**
246
+ After spec approval:
247
+ ```bash
248
+ /speckit.plan
249
+ ```
250
+
251
+ Creates `specs/001-component-name/plan.md` with:
252
+ - Technical architecture decisions
253
+ - Implementation phases
254
+ - Dependencies and considerations
255
+
256
+ #### 3. **Break Down into Tasks**
257
+ After plan approval:
258
+ ```bash
259
+ /speckit.tasks
260
+ ```
261
+
262
+ Creates `specs/001-component-name/tasks.md` with:
263
+ - Granular implementation checklist
264
+ - Testing requirements
265
+ - Documentation updates
266
+
267
+ #### 4. **Implement & Validate**
268
+ Follow the tasks checklist and validate:
269
+ ```bash
270
+ npm run type-check && npm run lint && npm test && npm run build
271
+ ```
272
+
273
+ ### Key Files
274
+
275
+ - `.specify/memory/constitution.md` - Project governing principles
276
+ - `.specify/memory/components-reference.md` - Complete component API reference
277
+ - `.specify/memory/workflow.md` - Step-by-step development workflow
278
+ - `.specify/memory/package-usage-guide.md` - How to use this package in other projects
279
+ - `.specify/templates/` - Spec, plan, and task templates
280
+ - `specs/` - Feature specifications and implementation plans
281
+
282
+ ### Using This Package in Your Application's SpecKit
283
+
284
+ If you're building an application that uses this design system and also uses Spec Kit, you can reference the design system's component documentation in your specs and AI agent context.
285
+
286
+ #### Method 1: Reference in Your Constitution
287
+
288
+ Add to your application's `.specify/memory/constitution.md`:
289
+
290
+ ```markdown
291
+ ## Article: UI Component Standards
292
+
293
+ ### Design System Requirement
294
+ All UI components MUST use the Cere Design System (@cere/cere-design-system).
295
+
296
+ ### Component Reference
297
+ Available components and their APIs are documented at:
298
+ `node_modules/@cere/cere-design-system/.specify/memory/components-reference.md`
299
+
300
+ All developers and AI agents MUST consult this reference before implementing UI features.
301
+ ```
302
+
303
+ #### Method 2: Create a Design System Memory File
304
+
305
+ Create `.specify/memory/design-system.md` in your application:
306
+
307
+ ```markdown
308
+ # Cere Design System Reference
309
+
310
+ This application uses @cere/cere-design-system
311
+
312
+ ## Quick Reference
313
+ See complete component reference:
314
+ `node_modules/@cere/cere-design-system/.specify/memory/components-reference.md`
315
+
316
+ Also see package usage guide:
317
+ `node_modules/@cere/cere-design-system/.specify/memory/package-usage-guide.md`
318
+
319
+ ## Installation & Setup
320
+ ```tsx
321
+ import { ThemeProvider, theme } from '@cere/cere-design-system';
322
+ import { Button, TextField, Card } from '@cere/cere-design-system';
323
+
324
+ <ThemeProvider theme={theme}>
325
+ <App />
326
+ </ThemeProvider>
327
+ ```
328
+ ```
329
+
330
+ #### AI Agent Instructions
331
+
332
+ When AI agents work on your application specs:
333
+ 1. They can reference `components-reference.md` for complete component APIs
334
+ 2. They should follow design system patterns and use existing components
335
+ 3. They get TypeScript types and usage examples from the reference
336
+
337
+ See `.specify/memory/package-usage-guide.md` (included in the npm package) for detailed integration instructions.
338
+
204
339
  ## Documentation
205
340
 
206
341
  - [Full Components Reference](./COMPONENTS.md) - Complete API documentation
@@ -236,6 +371,35 @@ Paste the output into your AI conversation to give the agent complete knowledge
236
371
 
237
372
  See [.agent/README.md](./.agent/README.md) for detailed setup instructions and examples.
238
373
 
374
+ ## AI-Assisted Development
375
+
376
+ This design system includes comprehensive AI agent context to accelerate development with AI coding assistants.
377
+
378
+ ### For AI Agents (Cursor, Claude, GPT-4, etc.)
379
+
380
+ The package includes a complete component reference optimized for AI agents at `.agent/rules/COMPONENTS.md`.
381
+
382
+ **Quick Start:**
383
+ ```bash
384
+ # After installing the package
385
+ cat node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md
386
+ ```
387
+
388
+ Paste the output into your AI conversation to give the agent complete knowledge of:
389
+ - All 70+ available components
390
+ - Props and TypeScript types
391
+ - Usage examples and patterns
392
+ - Theme configuration
393
+ - Best practices
394
+
395
+ **Setup Methods:**
396
+
397
+ 1. **Direct reference** - Copy the file content into your AI conversation
398
+ 2. **Project rules** - Add to `.cursorrules` or `.agent/rules/`
399
+ 3. **Auto-inject** - Use a postinstall script to copy to your project
400
+
401
+ See [.agent/README.md](./.agent/README.md) for detailed setup instructions and examples.
402
+
239
403
  ## Integration with Existing Projects
240
404
 
241
405
  To use this package in `dynamic-indexer-client` or other projects:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cere/cere-design-system",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Cere Network Design System - UI component library built with Material UI and React",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "files": [
16
16
  "dist",
17
- ".agent"
17
+ ".specify/memory"
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "tsup",
package/.agent/README.md DELETED
@@ -1,154 +0,0 @@
1
- # Cere Design System - AI Agent Context
2
-
3
- This folder contains documentation and context optimized for AI agents to effectively work with the Cere Design System.
4
-
5
- ## Files
6
-
7
- ### `rules/COMPONENTS.md`
8
- **Comprehensive component reference** for AI agents building applications with the Cere Design System.
9
-
10
- This file provides:
11
- - Complete listing of all 70+ available components
12
- - Detailed props and usage examples for each component
13
- - TypeScript type information
14
- - Theme and styling guidelines
15
- - Best practices and common patterns
16
- - Installation and setup instructions
17
-
18
- **Use Case:** Feed this document to AI agents (like Claude, GPT-4, etc.) as context when building React applications. The agent will have immediate access to all component APIs, props, and usage patterns without needing to search documentation or source code.
19
-
20
- ### `rules/AGENTS.md`
21
- Development guidelines and architecture documentation for AI agents working on the design system codebase itself.
22
-
23
- ### `rules/guidelines.md`
24
- General coding guidelines and conventions.
25
-
26
- ## Usage Examples
27
-
28
- ### For Building Applications
29
-
30
- When using an AI agent to build a React application with the Cere Design System:
31
-
32
- 1. **Include the context**: Upload or paste `rules/COMPONENTS.md` into your AI conversation
33
- 2. **Reference components**: Ask the agent to build UI using specific components from the design system
34
- 3. **Get accurate code**: The agent will generate TypeScript/React code with correct imports, props, and patterns
35
-
36
- Example prompts:
37
- ```
38
- "Build a login form using TextField, LoadingButton, and Alert components"
39
- "Create a dashboard with Grid, Card, ChartWidget, and MetricsChart"
40
- "Implement a data table with pagination using Table and Pagination components"
41
- ```
42
-
43
- #### Injecting Context into Project Prompts
44
-
45
- You can provide the component reference to AI agents in several ways:
46
-
47
- **Method 1: Direct File Reference (Recommended)**
48
- ```bash
49
- # After installing the package, reference the file directly
50
- cat node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md
51
- ```
52
-
53
- Then paste the output into your AI conversation or include it in your project's AI configuration.
54
-
55
- **Method 2: Project .cursorrules or .agent Files**
56
-
57
- Create a rule file in your project root that references the design system components:
58
-
59
- `.cursorrules` or `.agent/rules/design-system.md`:
60
- ```markdown
61
- # Design System Components
62
-
63
- When building UI components, use the Cere Design System.
64
-
65
- Available components reference:
66
-
67
- {PASTE CONTENTS OF node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md HERE}
68
- ```
69
-
70
- **Method 3: Dynamic Import Script**
71
-
72
- Create a script to automatically inject the context:
73
-
74
- `scripts/inject-design-system-context.sh`:
75
- ```bash
76
- #!/bin/bash
77
- # Inject Cere Design System component reference into project AI context
78
-
79
- COMPONENTS_FILE="node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md"
80
- OUTPUT_FILE=".agent/rules/cere-components.md"
81
-
82
- if [ -f "$COMPONENTS_FILE" ]; then
83
- echo "Copying Cere Design System component reference..."
84
- mkdir -p .agent/rules
85
- cp "$COMPONENTS_FILE" "$OUTPUT_FILE"
86
- echo "✓ Component reference available at $OUTPUT_FILE"
87
- else
88
- echo "Error: Design system not found. Run 'npm install' first."
89
- exit 1
90
- fi
91
- ```
92
-
93
- Make it executable and run after installation:
94
- ```bash
95
- chmod +x scripts/inject-design-system-context.sh
96
- npm install && ./scripts/inject-design-system-context.sh
97
- ```
98
-
99
- **Method 4: Package.json Postinstall Hook**
100
-
101
- Automatically copy the component reference after package installation:
102
-
103
- `package.json`:
104
- ```json
105
- {
106
- "scripts": {
107
- "postinstall": "mkdir -p .agent/rules && cp node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md .agent/rules/cere-components.md || true"
108
- }
109
- }
110
- ```
111
-
112
- **Method 5: AI Tool Configuration**
113
-
114
- For tools like Cursor, Cline, or Windsurf, add to your configuration:
115
-
116
- `.cursor/rules` or `.windsurfrules`:
117
- ```
118
- When building React components, always use components from @cere/cere-design-system.
119
- Refer to the complete component API documentation at:
120
- node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md
121
- ```
122
-
123
- ### For Package Installation
124
-
125
- After installing the package:
126
- ```bash
127
- npm install @cere/cere-design-system
128
- ```
129
-
130
- The `.agent` folder will be available at:
131
- ```
132
- node_modules/@cere/cere-design-system/.agent/
133
- ```
134
-
135
- You can reference it in AI agent contexts or documentation tools.
136
-
137
- ## Benefits
138
-
139
- - **Faster Development**: AI agents have immediate access to all component APIs
140
- - **Consistency**: Ensures AI-generated code follows design system patterns
141
- - **Type Safety**: All TypeScript types and interfaces are documented
142
- - **Best Practices**: Common patterns and usage guidelines included
143
- - **Complete Reference**: No need to browse Storybook or source code during AI-assisted development
144
-
145
- ## Updating
146
-
147
- This documentation is maintained alongside the component source code. When components are added or updated, the `COMPONENTS.md` file should be updated to reflect the changes.
148
-
149
- ## Package Information
150
-
151
- - **Package**: `@cere/cere-design-system`
152
- - **Version**: 0.0.10
153
- - **Repository**: https://github.com/cere-io/cere-design-system
154
- - **License**: MIT
@@ -1,111 +0,0 @@
1
- ### Cere Design System — Development Guidelines (Material UI, Vite, Storybook, Jest)
2
-
3
- These notes capture project-specific details for developing this Material UI–based design system. Components should be implemented first, then covered with comprehensive tests. They complement README/TESTING docs with nuances from this repo's configuration.
4
-
5
- #### Build and Configuration
6
- - Build tool: `tsup`
7
- - Entry: `src/index.ts`
8
- - Formats: CJS + ESM, with type declarations (`dts: true`)
9
- - Externalized peer deps to keep bundle lean: `react`, `react-dom`, `@mui/*`, `@emotion/*`, `reactflow`, `@monaco-editor/react`
10
- - Command: `npm run build`
11
- - Type checking: `npm run type-check` (and `npm run check-types:ci` in CI)
12
- - Linting: `npm run lint` or `npm run lint:fix`
13
- - Vite (for Storybook and local tooling): minimal plugin setup in `vite.config.ts`
14
- - Package entrypoints are defined in `package.json` `exports`, with `main/module/types` pointing to `dist/*`
15
- - Peer dependencies (must be present in consumer app and in local dev):
16
- - `@emotion/react`, `@emotion/styled`, `@mui/material`, `@mui/icons-material`, `@mui/lab`, `react`, `react-dom`, plus `reactflow`, `@monaco-editor/react` for third-party components
17
-
18
- #### Storybook Setup (Vite)
19
- - Start: `npm run storybook`
20
- - Build: `npm run build-storybook`
21
- - Customizations in `.storybook/main.ts`:
22
- - CSS modules `localsConvention: 'camelCase'` to align class name access patterns
23
- - `optimizeDeps.include` for `@monaco-editor/react`, `reactflow`, `monaco-editor`
24
- - `define: { 'process.env': {} }` to satisfy Monaco in Vite/Storybook
25
- - Accessibility: `.storybook/test-runner.ts` integrates `@axe-core/playwright` checks for every story root (`#storybook-root`). Run with `npm run test:storybook`.
26
-
27
- #### Jest and RTL Configuration
28
- - Jest setup in `jest.config.js`:
29
- - Preset: `ts-jest`
30
- - Environment: `jsdom`
31
- - Roots: `<rootDir>/src`
32
- - Test discovery: `**/__tests__/**/*.test.{ts,tsx}` and `**/*.test.{ts,tsx}` under `src/`
33
- - Path alias: `^@/(.*)$ -> <rootDir>/src/$1`
34
- - CSS modules auto-mocked via `identity-obj-proxy`
35
- - Coverage excludes stories, test files, `src/index.ts`, and type decls
36
- - Transform configured to ensure `jsx: 'react-jsx'`
37
- - Test setup file: `src/setupTests.ts`
38
- - Imports `@testing-library/jest-dom`
39
- - Mocks `window.matchMedia` (important for MUI internals and components using media queries)
40
- - Commands:
41
- - All tests: `npm test`
42
- - Watch: `npm run test:watch`
43
- - Coverage: `npm run test:coverage`
44
- - CI mode: `npm run test:ci`
45
-
46
- #### Verified test run (local sanity)
47
- A minimal Jest test was added temporarily at `src/__tests__/sanity.test.ts` and executed with:
48
- ```
49
- npm test -- src/__tests__/sanity.test.ts
50
- ```
51
- It passed (`1 passed`). The file was removed after verification to keep the repo clean. Use this pattern to quickly validate the test harness when needed.
52
-
53
- #### Writing Tests (Pragmatic Workflow)
54
- - Principle: Implement components first, then write comprehensive tests to ensure quality and prevent regressions.
55
- - Where to put tests:
56
- - Preferred: colocate under the component area using `__tests__` with `*.test.tsx` naming. Example: `src/components/layout/__tests__/Avatar.test.tsx`
57
- - Alternatively: place a direct `*.test.tsx` beside the component; Jest will still pick it up.
58
- - Wrap components with theme in tests:
59
- ```
60
- import { ThemeProvider } from '@mui/material';
61
- import { theme } from '@/theme';
62
- import { render } from '@testing-library/react';
63
-
64
- const renderWithTheme = (ui: React.ReactElement) =>
65
- render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>);
66
- ```
67
- - Use React Testing Library idioms:
68
- - Prefer `getByRole`, `getByText`, `getByLabelText` and user-level interactions via `@testing-library/user-event`
69
- - Use `@testing-library/jest-dom` matchers (already configured)
70
- - Snapshot testing: Avoid broad snapshots for MUI; assert semantics and key props/attributes instead
71
- - Accessibility: Validate roles, names, disabled state, focus management
72
- - Example patterns already in repo: see `src/components/**/__tests__/*.test.tsx` (e.g., `Avatar.test.tsx`)
73
-
74
- #### Adding Storybook Interaction Tests
75
- - Add `play` functions to stories using `@storybook/test` utilities (e.g., `within`, `userEvent`)
76
- - Run with: `npm run test:storybook`
77
- - These tests also run automatic axe accessibility checks via the configured test runner
78
-
79
- #### Component Authoring Conventions
80
- - Material UI theming
81
- - Use the shared `theme` from `src/theme` and expose component tokens via theme when practical
82
- - Respect MUI variants/sizes; provide sensible defaults and typed props
83
- - Public exports
84
- - Ensure all new components are exported from `src/index.ts` and surfaced in the package
85
- - CSS and classNames
86
- - MUI’s `sx` and `styled` utilities are preferred; if class-based styling is necessary, remember Storybook’s CSS module config uses camelCase
87
- - Third-party components
88
- - If components integrate `reactflow` or `@monaco-editor/react`, keep their imports dynamic-friendly and avoid relying on Node globals; Storybook’s `process.env` shim is in place
89
-
90
- #### Common Pitfalls and Fixes
91
- - matchMedia not defined in JSDOM
92
- - Already handled in `src/setupTests.ts`. If adding features that rely on different media APIs, extend this mock
93
- - Failing to wrap with ThemeProvider in tests
94
- - Most MUI components require theme context; tests should wrap components with `ThemeProvider`
95
- - Missing peer dependencies in consumer app or local dev
96
- - Install all listed peer deps to avoid runtime errors
97
- - Class name expectations
98
- - RTL queries should target roles and text over MUI-generated class names; class selectors may be brittle across MUI versions
99
-
100
- #### Release Hygiene
101
- - Run `npm run type-check && npm run lint && npm test && npm run build` before publishing
102
- - Storybook should render locally (`npm run storybook`) for visual checks; optionally run `npm run test:storybook` for a11y/interaction coverage
103
-
104
- #### Quick Development Loop
105
- 1) Implement component following existing patterns and conventions
106
- 2) Create Storybook story with all variants and states
107
- 3) Write comprehensive tests under the component's `__tests__` folder
108
- 4) Run `npm test -- componentPathOrPattern` to verify coverage
109
- 5) Add `play` interaction tests to Storybook stories if relevant
110
- 6) Verify accessibility with `npm run test:storybook`
111
-