@tpitre/story-ui 1.7.1 โ†’ 2.0.1

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.
Files changed (35) hide show
  1. package/.env.sample +3 -1
  2. package/README.md +160 -606
  3. package/dist/cli/index.js +23 -24
  4. package/dist/cli/setup.js +295 -36
  5. package/dist/mcp-server/index.js +67 -0
  6. package/dist/mcp-server/routes/generateStory.js +323 -56
  7. package/dist/story-generator/componentBlacklist.js +181 -0
  8. package/dist/story-generator/componentDiscovery.js +9 -2
  9. package/dist/story-generator/configLoader.js +109 -39
  10. package/dist/story-generator/considerationsLoader.js +204 -0
  11. package/dist/story-generator/documentation-sources.js +36 -0
  12. package/dist/story-generator/documentationLoader.js +214 -0
  13. package/dist/story-generator/dynamicPackageDiscovery.js +527 -0
  14. package/dist/story-generator/enhancedComponentDiscovery.js +369 -118
  15. package/dist/story-generator/generateStory.js +7 -3
  16. package/dist/story-generator/postProcessStory.js +71 -0
  17. package/dist/story-generator/promptGenerator.js +286 -37
  18. package/dist/story-generator/storyHistory.js +118 -0
  19. package/dist/story-generator/storyTracker.js +33 -18
  20. package/dist/story-generator/storyValidator.js +39 -0
  21. package/dist/story-generator/universalDesignSystemAdapter.js +209 -0
  22. package/dist/story-generator/validateStory.js +82 -7
  23. package/dist/story-ui.config.js +12 -5
  24. package/package.json +11 -6
  25. package/templates/StoryUI/StoryUIPanel.stories.tsx +29 -13
  26. package/templates/StoryUI/StoryUIPanel.tsx +489 -359
  27. package/templates/react-import-rule.json +36 -0
  28. package/templates/story-generation-rules.json +29 -0
  29. package/templates/story-ui-considerations.json +156 -0
  30. package/templates/story-ui-considerations.md +109 -0
  31. package/templates/story-ui-docs-README.md +55 -0
  32. package/dist/scripts/test-validation.js +0 -81
  33. package/dist/test-storybooks/chakra-test/src/components/index.js +0 -3
  34. package/dist/test-storybooks/custom-design-test/src/components/index.js +0 -3
  35. package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,701 +1,255 @@
1
- # Story UI - AI-Powered Storybook Story Generator
1
+ # Story UI ๐ŸŽจ
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@tpitre/story-ui.svg)](https://www.npmjs.com/package/@tpitre/story-ui)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ *AI-powered Storybook story generator for any React component library*
5
4
 
6
- Story UI is a flexible, AI-powered tool that generates Storybook stories for any React component library. It uses Claude AI to understand natural language prompts and create accurate, multi-column layouts using your existing components.
5
+ [![npm version](https://badge.fury.io/js/%40tpitre%2Fstory-ui.svg)](https://badge.fury.io/js/%40tpitre%2Fstory-ui)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- ## Features
8
+ Story UI revolutionizes component documentation by automatically generating Storybook stories through AI-powered conversations. Simply chat with the AI about your components and watch as comprehensive stories are created in real-time.
9
9
 
10
- - ๐Ÿค– **AI-Powered Generation**: Uses Claude AI to generate stories from natural language prompts
11
- - ๐Ÿ”ง **Component Library Agnostic**: Works with any React component library
12
- - ๐Ÿ“ฑ **Smart Layout Generation**: Automatically creates proper multi-column layouts
13
- - ๐Ÿ” **Component Discovery**: Automatically discovers and analyzes your components
14
- - โš™๏ธ **Flexible Configuration**: Highly customizable for different design systems
15
- - ๐Ÿš€ **MCP Server**: Integrates with Claude Desktop and other MCP clients
16
- - ๐Ÿ—‚๏ธ **Git Integration**: Automatically manages .gitignore for ephemeral stories
17
- - ๐Ÿงน **Cleanup Utilities**: Built-in cleanup for old generated stories
18
- - ๐ŸŽจ **Built-in UI**: Includes a Storybook panel for easy interaction
10
+ ## โœจ Features
19
11
 
20
- ## Roadmap
12
+ ### ๐ŸŽฏ Core Features
13
+ - **AI-Powered Story Generation**: Chat with AI to create comprehensive Storybook stories
14
+ - **Intelligent Iteration Support**: Modify existing stories without losing your work
15
+ - **Multi-Component Library Support**: Works with any React component library
16
+ - **Real-time Story Updates**: See your stories appear in Storybook instantly
17
+ - **Intelligent Component Discovery**: Automatically finds and analyzes your components
18
+ - **TypeScript Support**: Full TypeScript integration with type-aware story generation
21
19
 
22
- Check out our [development roadmap](./ROADMAP.md) to see what's coming next and how you can contribute to the future of Story UI. We're planning exciting features like multi-framework support, story sharing, and advanced collaboration tools.
20
+ ### ๐Ÿ“š Documentation System (New!)
21
+ - **Auto-Generated Structure**: `npx story-ui init` creates a `story-ui-docs/` directory template
22
+ - **Directory-Based Documentation**: Organize design system docs in a structured directory
23
+ - **Multiple Format Support**: Markdown, JSON, HTML, and text files
24
+ - **Legacy Support**: Still supports single `story-ui-considerations.md` file
25
+ - **Auto-Discovery**: Automatically finds and loads documentation to enhance AI story generation
23
26
 
24
- ## Quick Start
27
+ ### ๐ŸŽจ Advanced Features
28
+ - **Memory-Persistent Stories**: Stories are remembered across sessions
29
+ - **Git Integration**: Automatic gitignore management for generated files
30
+ - **Production Mode**: Clean deployment without generated stories
31
+ - **Auto Port Detection**: Automatically finds available ports
32
+ - **Hot Reload Integration**: Stories update automatically as you chat
25
33
 
26
- ### 1. Installation
34
+ ## ๐Ÿš€ Quick Start
27
35
 
28
36
  ```bash
29
- npm install @tpitre/story-ui --save-dev
30
- # or
31
- yarn add -D @tpitre/story-ui
32
- ```
37
+ # Install Story UI
38
+ npm install -D @tpitre/story-ui
33
39
 
34
- ### 2. Run Setup
35
-
36
- ```bash
40
+ # Initialize Story UI in your project
37
41
  npx story-ui init
38
- ```
39
-
40
- This interactive setup will:
41
- - โœ… Detect your design system (Material-UI, Chakra UI, Ant Design, etc.)
42
- - โœ… Create configuration file (`story-ui.config.js`)
43
- - โœ… Install the Story UI panel component in your stories
44
- - โœ… Create `.env` file for API configuration
45
- - โœ… Add convenience scripts to your `package.json`
46
- - โœ… Update `.gitignore` with appropriate patterns
47
-
48
- ### 3. Add Your Claude API Key
49
-
50
- If you didn't add it during setup, edit the `.env` file:
51
-
52
- ```bash
53
- # Get your API key from: https://console.anthropic.com/
54
- CLAUDE_API_KEY=your-claude-api-key-here
55
- ```
56
-
57
- **Important:** Keep your API key secure and never commit `.env` files to version control!
58
-
59
- ### 4. Start Using Story UI
60
-
61
- Run both Storybook and Story UI together:
62
-
63
- ```bash
64
- npm run storybook-with-ui
65
- ```
66
-
67
- Or run them separately:
68
42
 
69
- ```bash
70
- # Terminal 1
71
- npm run storybook
72
-
73
- # Terminal 2
43
+ # Start generating stories (Story UI will pick 4001 or the next free port)
74
44
  npm run story-ui
75
- ```
76
-
77
- ### 5. Generate Your First Story
78
-
79
- 1. Open Storybook in your browser
80
- 2. Navigate to **"Story UI > Story Generator"** in the sidebar
81
- 3. Enter a natural language prompt like:
82
- - "Create a login form with email and password fields"
83
- - "Build a three-column dashboard with cards"
84
- - "Design a hero section with navigation"
85
- 4. Click "Generate" and watch your UI come to life!
86
45
 
87
- ## How It Works
88
-
89
- 1. **Component Discovery**: Story UI automatically discovers all components in your project
90
- 2. **AI Understanding**: Your prompt is processed by Claude AI with knowledge of your components
91
- 3. **Code Generation**: Clean, production-ready story code is generated
92
- 4. **Live Preview**: See your generated UI instantly in Storybook
93
- 5. **Iteration**: Refine your designs with follow-up prompts in the same session
94
-
95
- ## What Gets Installed
96
-
97
- After running `npx story-ui init`, your project structure will include:
98
-
99
- ```
100
- your-project/
101
- โ”œโ”€โ”€ .env # Created from template
102
- โ”œโ”€โ”€ story-ui.config.js # Generated configuration
103
- โ”œโ”€โ”€ src/stories/
104
- โ”‚ โ”œโ”€โ”€ StoryUI/ # UI component
105
- โ”‚ โ”‚ โ”œโ”€โ”€ StoryUIPanel.tsx
106
- โ”‚ โ”‚ โ”œโ”€โ”€ StoryUIPanel.stories.tsx
107
- โ”‚ โ”‚ โ””โ”€โ”€ index.tsx
108
- โ”‚ โ””โ”€โ”€ generated/ # Where AI stories go
109
- โ””โ”€โ”€ package.json # Updated with scripts
46
+ # Need a custom port? Just pass the flag:
47
+ npm run story-ui -- --port 4005
110
48
  ```
111
49
 
112
- ## Installation Flow
113
-
114
- ```mermaid
115
- graph TD
116
- A[Developer runs:<br/>'npm install story-ui'] --> B[Story UI package installed]
117
- B --> C[Developer runs:<br/>'npx story-ui init']
118
- C --> D{Interactive Setup}
119
- D --> E[Detects design system<br/>MUI, Chakra, Ant Design, etc.]
120
- D --> F[Creates story-ui.config.js]
121
- D --> G[Copies StoryUI component<br/>to project stories directory]
122
- D --> H[Creates .env file<br/>from template]
123
- D --> I[Updates .gitignore]
124
- D --> J[Adds npm scripts<br/>to package.json]
125
-
126
- E --> K[Configuration complete]
127
- F --> K
128
- G --> K
129
- H --> K
130
- I --> K
131
- J --> K
132
-
133
- K --> L[Developer adds<br/>Claude API key to .env]
134
- L --> M[Developer runs:<br/>'npm run storybook-with-ui']
135
- M --> N[Storybook opens with<br/>Story UI panel available]
136
- N --> O[Non-developer can<br/>generate UI with prompts]
137
-
138
- style A fill:#e1f5e1
139
- style N fill:#e1f5e1
140
- style O fill:#ffd4e5
141
- ```
50
+ Story UI will automatically:
51
+ - โœ… Discover your components
52
+ - โœ… Set up the chat interface
53
+ - โœ… Create a `story-ui-docs/` directory structure for your design system documentation
54
+ - โœ… Generate stories as you type
55
+ - โœ… Load your design system documentation to enhance AI generation
142
56
 
143
- ## Configuration Options
57
+ ## ๐Ÿ“š How It Works
144
58
 
145
- ### Complete Configuration Interface
59
+ Story UI uses advanced AI to understand your component library and generate appropriate stories:
146
60
 
147
- ```typescript
148
- interface StoryUIConfig {
149
- // File paths
150
- generatedStoriesPath: string; // Where to save generated stories
151
- componentsPath?: string; // Path to your components
152
- componentsMetadataPath?: string; // Path to custom-elements.json (optional)
61
+ 1. **Component Discovery**: Story UI scans your codebase for available components
62
+ 2. **Documentation Loading**: Reads your design system documentation (if available)
63
+ 3. **AI Generation**: Claude generates stories using discovered components
64
+ 4. **Iteration Support**: Previous code is preserved when modifying stories
65
+ 5. **Hot Reload**: Stories appear instantly in your Storybook
153
66
 
154
- // Story configuration
155
- storyPrefix: string; // Prefix for story titles
156
- defaultAuthor: string; // Default author name
157
- importPath: string; // Import path for components
158
-
159
- // Component system configuration
160
- componentPrefix: string; // Component naming prefix
161
- components: ComponentConfig[]; // Component definitions
162
- layoutRules: LayoutRules; // Layout generation rules
163
-
164
- // Template configuration
165
- sampleStory?: string; // Custom story template
166
- systemPrompt?: string; // Custom AI system prompt
167
- }
168
- ```
169
-
170
- ### Layout Rules Configuration
171
-
172
- ```typescript
173
- interface LayoutRules {
174
- multiColumnWrapper?: string; // Main layout component
175
- columnComponent?: string; // Column/section component
176
- containerComponent?: string; // Container wrapper component
177
- layoutExamples?: {
178
- twoColumn?: string; // Two-column layout example
179
- threeColumn?: string; // Three-column layout example
180
- grid?: string; // Grid layout example
181
- };
182
- prohibitedElements?: string[]; // HTML elements to avoid
183
- }
184
- ```
67
+ ## ๐ŸŽฏ Configuration
185
68
 
186
- ## Configuration Methods
187
-
188
- ### 1. Configuration File
189
-
190
- Create `story-ui.config.js`:
69
+ ### Basic Configuration (`story-ui.config.js`)
191
70
 
192
71
  ```javascript
193
72
  export default {
194
- generatedStoriesPath: './src/stories/generated',
73
+ // Component library import path
74
+ importPath: 'your-component-library',
75
+
76
+ // Path to your local components (for custom libraries)
195
77
  componentsPath: './src/components',
196
- importPath: 'my-design-system',
197
- componentPrefix: 'DS',
78
+
79
+ // Generated stories location
80
+ generatedStoriesPath: './src/stories/generated/',
81
+
82
+ // Story configuration
83
+ storyPrefix: 'Generated/',
84
+ defaultAuthor: 'Story UI AI',
85
+
86
+ // Layout rules for multi-column layouts
198
87
  layoutRules: {
199
- multiColumnWrapper: 'DSLayout',
200
- columnComponent: 'DSColumn'
88
+ multiColumnWrapper: 'div',
89
+ columnComponent: 'div',
90
+ containerComponent: 'div'
201
91
  }
202
92
  };
203
93
  ```
204
94
 
205
- ### 2. Package.json Configuration
206
-
207
- Add to your `package.json`:
208
-
209
- ```json
210
- {
211
- "storyUI": {
212
- "generatedStoriesPath": "./src/stories/generated",
213
- "componentsPath": "./src/components",
214
- "importPath": "my-design-system",
215
- "componentPrefix": "DS"
216
- }
217
- }
218
- ```
219
-
220
- ### 3. Auto-Detection
221
-
222
- Story UI can automatically detect your project structure:
223
-
224
- ```bash
225
- npx story-ui init --auto-detect
226
- ```
227
-
228
- ## Component Discovery
229
-
230
- Story UI features an **Enhanced Component Discovery System** that automatically finds and categorizes your design system components:
231
-
232
- ### How It Works
233
-
234
- ```mermaid
235
- graph TD
236
- A["Story UI Installation"] --> B["Component Discovery System"]
237
- B --> C{"Identify Sources"}
238
-
239
- C --> D["NPM Packages<br/>@mui/material<br/>antd<br/>@chakra-ui/react<br/>custom packages"]
240
- C --> E["Local Files<br/>*.tsx, *.jsx<br/>*.ts, *.js"]
241
- C --> F["TypeScript Definitions<br/>*.d.ts files"]
242
- C --> G["Custom Elements<br/>custom-elements.json"]
243
-
244
- D --> H["Auto-detect<br/>Pre-configured components<br/>for popular libraries"]
245
- E --> I["Parse source files<br/>Extract components & props"]
246
- F --> J["Analyze type definitions<br/>Extract interfaces"]
247
- G --> K["Read metadata<br/>Parse component specs"]
248
-
249
- H --> L["Component Registry"]
250
- I --> L
251
- J --> L
252
- K --> L
253
-
254
- L --> M["Categorized Components<br/>โ€ข Layout<br/>โ€ข Content<br/>โ€ข Form<br/>โ€ข Navigation<br/>โ€ข Feedback"]
255
-
256
- M --> N["API Endpoints"]
257
- N --> O["GET /mcp/components<br/>Returns discovered components"]
258
- N --> P["POST /mcp/generate-story<br/>AI generates with full context"]
259
-
260
- P --> Q["TypeScript Validation<br/>โ€ข Syntax checking<br/>โ€ข Auto-fix common errors<br/>โ€ข Fallback generation"]
261
- Q --> R["Story Created Successfully<br/>โœ… No syntax errors<br/>โœ… No duplicates<br/>โœ… Ready for Storybook"]
262
- ```
263
-
264
- ### Discovery Methods
95
+ ## ๐ŸŒŸ Officially Supported Design Systems
265
96
 
266
- 1. **Pre-configured Libraries**: Built-in component lists for popular design systems (Ant Design, MUI, Chakra UI)
267
- 2. **Directory Structure**: Scans component directories for `.tsx` files
268
- 3. **Story Files**: Extracts component information from existing `.stories.tsx` files
269
- 4. **Custom Elements**: Reads `custom-elements.json` for web components
270
- 5. **Package Exports**: Analyzes package.json exports and index files
271
- 6. **TypeScript Definitions**: Parses `.d.ts` files for component interfaces
97
+ Story UI provides guided installation and automatic configuration for the following design systems:
272
98
 
273
- ### Features
99
+ | Design System | Package | Auto Install | Pre-configured |
100
+ |--------------|---------|--------------|----------------|
101
+ | Ant Design | `antd` | โœ… Yes | โœ… Yes |
102
+ | Mantine | `@mantine/core` | โœ… Yes | โœ… Yes |
103
+ | Chakra UI | `@chakra-ui/react` | โœ… Yes | โœ… Yes |
104
+ | Custom | Any React library | โŒ Manual | โœ… Configurable |
274
105
 
275
- - โœ… **Zero Configuration**: Works out of the box with popular design systems
276
- - โœ… **Intelligent Categorization**: Automatically groups components by type
277
- - โœ… **Props Discovery**: Extracts component properties and types
278
- - โœ… **Validation System**: Catches and fixes common TypeScript errors
279
- - โœ… **Duplicate Prevention**: Tracks generated stories to avoid duplicates
280
- - โœ… **Performance Optimized**: Caches discovered components with 1-minute TTL
106
+ When you run `npx story-ui init`, you can choose to automatically install and configure these design systems with optimized layout rules and component mappings.
281
107
 
282
- ## Design System Examples
108
+ ## ๐Ÿ“ฑ Examples
283
109
 
284
- ### Material-UI
110
+ ### Simple Component Story
285
111
 
286
- ```javascript
287
- export default {
288
- importPath: '@mui/material',
289
- componentPrefix: '',
290
- layoutRules: {
291
- multiColumnWrapper: 'Grid',
292
- columnComponent: 'Grid',
293
- layoutExamples: {
294
- twoColumn: `<Grid container spacing={2}>
295
- <Grid item xs={6}>
296
- <Card>Left content</Card>
297
- </Grid>
298
- <Grid item xs={6}>
299
- <Card>Right content</Card>
300
- </Grid>
301
- </Grid>`
302
- }
303
- }
304
- };
305
112
  ```
113
+ You: "Create a button story with different variants"
306
114
 
307
- ### Chakra UI
308
-
309
- ```javascript
310
- export default {
311
- importPath: '@chakra-ui/react',
312
- componentPrefix: '',
313
- layoutRules: {
314
- multiColumnWrapper: 'SimpleGrid',
315
- columnComponent: 'Box',
316
- layoutExamples: {
317
- twoColumn: `<SimpleGrid columns={2} spacing={4}>
318
- <Box>
319
- <Card>Left content</Card>
320
- </Box>
321
- <Box>
322
- <Card>Right content</Card>
323
- </Box>
324
- </SimpleGrid>`
325
- }
326
- }
327
- };
115
+ AI: "I'll create a comprehensive Button story with all available variants..."
328
116
  ```
329
117
 
330
- ### Ant Design
331
-
332
- ```javascript
333
- export default {
334
- importPath: 'antd',
335
- componentPrefix: '',
336
- layoutRules: {
337
- multiColumnWrapper: 'Row',
338
- columnComponent: 'Col',
339
- layoutExamples: {
340
- twoColumn: `<Row gutter={16}>
341
- <Col span={12}>
342
- <Card>Left content</Card>
343
- </Col>
344
- <Col span={12}>
345
- <Card>Right content</Card>
346
- </Col>
347
- </Row>`
348
- }
349
- }
118
+ Result:
119
+ ```tsx
120
+ export const AllVariants = {
121
+ render: () => (
122
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
123
+ <Button variant="primary">Primary</Button>
124
+ <Button variant="secondary">Secondary</Button>
125
+ <Button variant="tertiary">Tertiary</Button>
126
+ <Button variant="plain">Plain</Button>
127
+ </div>
128
+ )
350
129
  };
351
130
  ```
352
131
 
353
- ## API Reference
354
-
355
- ### HTTP Endpoints
356
-
357
- #### POST `/mcp/generate-story`
358
-
359
- Generate a new story from a natural language prompt.
360
-
361
- **Request Body:**
362
- ```json
363
- {
364
- "prompt": "Create a three-column layout with different card types",
365
- "fileName": "optional-custom-filename.stories.tsx"
366
- }
367
- ```
368
-
369
- **Response:**
370
- ```json
371
- {
372
- "success": true,
373
- "fileName": "generated-filename.stories.tsx",
374
- "outPath": "/path/to/generated/story",
375
- "title": "Generated Story Title",
376
- "story": "// Generated story content..."
377
- }
378
- ```
132
+ ### Complex Layout Story
379
133
 
380
- #### GET `/mcp/components`
381
-
382
- Get all discovered components from your design system.
383
-
384
- **Response:**
385
- ```json
386
- [
387
- {
388
- "name": "Button",
389
- "description": "Button component",
390
- "category": "form",
391
- "props": ["type", "size", "loading", "icon", "onClick"],
392
- "slots": []
393
- },
394
- // ... more components
395
- ]
396
134
  ```
135
+ You: "Create a product card with image, title, price, and add to cart button"
397
136
 
398
- #### GET `/mcp/stories`
399
-
400
- Get all generated stories (production mode only).
401
-
402
- **Response:**
403
- ```json
404
- [
405
- {
406
- "id": "story-abc123",
407
- "title": "Login Form",
408
- "createdAt": "2024-01-15T10:30:00Z",
409
- "components": ["Form", "Input", "Button"]
410
- },
411
- // ... more stories
412
- ]
137
+ AI: "I'll create a product card using your design system components..."
413
138
  ```
414
139
 
415
- #### GET `/mcp/stories/:id/content`
140
+ ### Iterating on Existing Stories
416
141
 
417
- Get the content of a specific story (production mode only).
418
-
419
- **Response:**
420
- ```json
421
- {
422
- "id": "story-abc123",
423
- "title": "Login Form",
424
- "content": "// Full story TypeScript code...",
425
- "createdAt": "2024-01-15T10:30:00Z"
426
- }
427
142
  ```
143
+ You: "Make the buttons full width"
428
144
 
429
- #### GET `/mcp/stats`
430
-
431
- Get server and memory statistics (production mode only).
432
-
433
- **Response:**
434
- ```json
435
- {
436
- "environment": "production",
437
- "uptime": 3600,
438
- "storyCount": 12,
439
- "totalSizeMB": 0.5,
440
- "memoryLimit": 50,
441
- "oldestStory": "2024-01-15T08:00:00Z"
442
- }
145
+ AI: "I'll modify the existing story to make the buttons full width..."
443
146
  ```
444
147
 
445
- ### MCP Integration
446
-
447
- Story UI includes an MCP (Model Context Protocol) server for integration with Claude Desktop:
448
-
449
- 1. Add to your Claude Desktop configuration:
450
- ```json
451
- {
452
- "mcpServers": {
453
- "story-ui": {
454
- "command": "node",
455
- "args": ["/path/to/story-ui/dist/mcp-server/index.js"]
456
- }
457
- }
458
- }
459
- ```
460
-
461
- 2. Use in Claude Desktop:
462
- ```
463
- Generate a two-column layout with cards using Story UI
464
- ```
465
-
466
- ## CLI Commands
467
-
468
- ### Initialize Configuration
469
-
470
- ```bash
471
- npx story-ui init
472
- npx story-ui init --auto-detect
473
- npx story-ui init --template=material-ui
474
- ```
148
+ The AI will preserve your existing code and only modify what you requested!
475
149
 
476
- ### Start Server
150
+ ## ๐Ÿ“– Documentation Support
477
151
 
478
- ```bash
479
- npx story-ui start
480
- npx story-ui start --port=4001
481
- npx story-ui start --config=./custom-config.js
482
- ```
152
+ ### Directory-Based Documentation (Recommended)
483
153
 
484
- ### Generate Sample Config
154
+ Create a `story-ui-docs/` directory in your project root:
485
155
 
486
- ```bash
487
- npx story-ui config --generate
488
- npx story-ui config --generate --type=json
489
156
  ```
490
-
491
- ## Environment Variables
492
-
493
- ```bash
494
- CLAUDE_API_KEY=your_claude_api_key_here
495
- CLAUDE_MODEL=claude-sonnet-4-20250514 # Optional, defaults to latest Sonnet
157
+ story-ui-docs/
158
+ โ”œโ”€โ”€ README.md # Overview and getting started
159
+ โ”œโ”€โ”€ guidelines/
160
+ โ”‚ โ”œโ”€โ”€ accessibility.md # Accessibility guidelines
161
+ โ”‚ โ”œโ”€โ”€ responsive-design.md # Responsive design rules
162
+ โ”‚ โ””โ”€โ”€ brand-guidelines.md # Brand usage
163
+ โ”œโ”€โ”€ tokens/
164
+ โ”‚ โ”œโ”€โ”€ colors.json # Color tokens
165
+ โ”‚ โ”œโ”€โ”€ spacing.md # Spacing system
166
+ โ”‚ โ””โ”€โ”€ typography.json # Typography tokens
167
+ โ”œโ”€โ”€ components/
168
+ โ”‚ โ”œโ”€โ”€ button.md # Button documentation
169
+ โ”‚ โ””โ”€โ”€ forms.md # Form component docs
170
+ โ””โ”€โ”€ patterns/
171
+ โ”œโ”€โ”€ layouts.md # Layout patterns
172
+ โ””โ”€โ”€ data-tables.md # Table patterns
496
173
  ```
497
174
 
498
- ## Production-Ready Deployment
499
-
500
- Story UI is designed for **seamless deployment** across development and production environments, with automatic environment detection and appropriate story generation strategies.
175
+ Story UI will automatically discover and use this documentation to generate better stories.
501
176
 
502
- ### ๐ŸŒ **Environment Detection**
177
+ ### Legacy Single-File Documentation
503
178
 
504
- Story UI automatically detects your environment:
179
+ You can still use a single `story-ui-considerations.md` file in your project root for simpler setups.
505
180
 
506
- **Development Environment:**
507
- - โœ… **File-system storage** - Stories written to configured directory
508
- - โœ… **Automatic .gitignore** - Generated directory added to git ignore
509
- - โœ… **Directory structure** - Creates necessary folders and README
510
-
511
- **Production Environment (Vercel, Netlify, etc.):**
512
- - โœ… **In-memory storage** - Stories stored in server memory
513
- - โœ… **Read-only compatibility** - Works without file system write permissions
514
- - โœ… **Memory management** - Automatic cleanup to prevent memory leaks
515
- - โœ… **API endpoints** - RESTful API for story management
516
-
517
- ### ๐Ÿ”ง **Automatic Setup**
518
-
519
- ```bash
520
- # Development setup
521
- npx story-ui init --auto-detect
522
-
523
- # Production deployment
524
- # No additional setup needed - automatically detected!
525
- ```
526
-
527
- ### ๐Ÿ—‚๏ธ **Git Integration**
528
-
529
- **Development:**
530
- ```bash
531
- # Automatically adds to .gitignore:
532
- ./libs/your-components/src/components/generated/
533
- ./libs/your-components/src/components/generated/**
534
- ```
181
+ ## ๐Ÿ”ง Advanced Features
535
182
 
536
- **Production:**
537
- - Stories stored in memory only
538
- - No file system writes required
539
- - Perfect for read-only deployments
183
+ ### Story Version History
540
184
 
541
- ### ๐ŸŽฏ **Use Cases**
185
+ Every generated story is tracked with version history:
186
+ - Each iteration is saved with a timestamp
187
+ - Previous versions are linked for easy tracking
188
+ - History is stored in `.story-ui-history/` (git-ignored)
542
189
 
543
- **Perfect for:**
544
- - ๐ŸŽจ **Layout Testing** - Test component arrangements without committing
545
- - ๐Ÿ‘ฅ **Stakeholder Review** - Share layouts with product owners and designers
546
- - ๐Ÿ”„ **Rapid Iteration** - Generate, test, and regenerate layouts quickly
547
- - ๐Ÿ“ฑ **Design Validation** - Validate designs before implementation
548
- - ๐ŸŒ **Public Demos** - Deploy to Vercel/Netlify for team collaboration
190
+ ### Component Validation
549
191
 
550
- **Example Production Workflow:**
551
- 1. Deploy Storybook + Story UI to Vercel/Netlify
552
- 2. Product owners generate layouts using natural language
553
- 3. Stories stored in server memory (ephemeral)
554
- 4. Share generated stories with team for feedback
555
- 5. Iterate and refine layouts
556
- 6. Implement approved layouts in actual codebase
192
+ All generated stories are validated to ensure:
193
+ - โœ… Only existing components are imported
194
+ - โœ… Props match component interfaces
195
+ - โœ… Import paths are correct
196
+ - โœ… TypeScript types are valid
557
197
 
198
+ ### Production Mode
558
199
 
200
+ In production environments, Story UI operates in memory-only mode:
201
+ - No files are written to disk
202
+ - Stories are served from memory
203
+ - Clean deployment without generated files
559
204
 
560
- ### ๐Ÿ“Š **Production Monitoring**
205
+ ## ๐Ÿš€ CLI Commands
561
206
 
562
207
  ```bash
563
- # Check server status and memory usage
564
- curl http://your-server.vercel.app/mcp/stats
565
-
566
- # Get all generated stories
567
- curl http://your-server.vercel.app/mcp/stories
568
-
569
- # Get specific story content
570
- curl http://your-server.vercel.app/mcp/stories/story-abc123/content
571
- ```
572
-
573
- ### ๐Ÿงน **Memory Management**
574
-
575
- Production environments automatically:
576
- - ๐Ÿ”„ **Cleanup old stories** - Removes stories older than 24 hours
577
- - ๐Ÿ“Š **Memory limits** - Keeps maximum 50 stories in memory
578
- - ๐Ÿ“ˆ **Usage tracking** - Monitors memory usage and story access patterns
208
+ # Initialize Story UI in a new project
209
+ npx story-ui init
579
210
 
580
- ```javascript
581
- import { ProductionGitignoreManager, getInMemoryStoryService } from 'story-ui';
211
+ # Start the Story UI server
212
+ npx story-ui start
582
213
 
583
- // Manual cleanup if needed
584
- const manager = new ProductionGitignoreManager(config);
585
- manager.cleanupOldStories();
214
+ # Start on a specific port
215
+ npx story-ui start --port 4005
586
216
 
587
- // Memory statistics
588
- const storyService = getInMemoryStoryService(config);
589
- const stats = storyService.getMemoryStats();
590
- console.log(`${stats.storyCount} stories using ${stats.totalSizeMB}MB`);
217
+ # Use a specific config file
218
+ npx story-ui start --config custom-config.js
591
219
  ```
592
220
 
593
- ## Contributing
221
+ ## ๐Ÿค Contributing
594
222
 
595
- Story UI is designed to be community-driven and extensible. Contributions are welcome!
223
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
596
224
 
597
225
  ### Development Setup
598
226
 
599
227
  ```bash
600
- git clone https://github.com/southleft/story-ui
228
+ # Clone and install
229
+ git clone https://github.com/southleft/story-ui.git
601
230
  cd story-ui
602
231
  npm install
603
- npm run build
604
- npm run start
605
- ```
606
-
607
- ### Adding Design System Templates
608
-
609
- 1. Create a new configuration template in `templates/`
610
- 2. Add examples and documentation
611
- 3. Submit a pull request
612
-
613
- ## License
614
-
615
- MIT License - see LICENSE file for details.
616
-
617
- ## Publishing to npm
618
-
619
- Story UI uses [Semantic Release](https://semantic-release.gitbook.io/semantic-release/) for automated versioning and publishing.
620
-
621
- ### Automated Releases
622
-
623
- When you push to the `main` branch, GitHub Actions automatically:
624
- 1. Analyzes commit messages to determine version bump
625
- 2. Updates version in package.json
626
- 3. Generates/updates CHANGELOG.md
627
- 4. Creates a GitHub release
628
- 5. Publishes to npm
629
232
 
630
- ### Commit Convention
631
-
632
- Follow the [Conventional Commits](https://www.conventionalcommits.org/) format:
633
-
634
- ```bash
635
- # Features (minor version bump)
636
- git commit -m "feat: add dark mode support"
637
-
638
- # Bug fixes (patch version bump)
639
- git commit -m "fix: resolve TypeScript error in CLI"
640
-
641
- # Breaking changes (major version bump)
642
- git commit -m "feat!: redesign configuration API"
643
- ```
644
-
645
- See [COMMIT_CONVENTION.md](./COMMIT_CONVENTION.md) for detailed guidelines.
646
-
647
- ### Manual Release (if needed)
648
-
649
- ```bash
650
- # Dry run to see what would be released
651
- npm run release:dry-run
233
+ # Build and link for development
234
+ npm run build
235
+ npm link
652
236
 
653
- # Manual release (not recommended - use automated releases)
654
- npm run release
237
+ # Test in a project
238
+ cd your-project
239
+ npm link @tpitre/story-ui
655
240
  ```
656
241
 
657
- ### Setup Requirements
658
-
659
- For automated releases to work, you need to add an NPM_TOKEN secret to your GitHub repository:
660
- 1. Generate an npm token: `npm token create`
661
- 2. Add it to GitHub: Settings โ†’ Secrets โ†’ Actions โ†’ New repository secret
662
- 3. Name: `NPM_TOKEN`, Value: your npm token
663
-
664
- ## Troubleshooting
665
-
666
- ### "The requested module does not provide an export named 'Meta'"
667
-
668
- This error occurs when Story UI is installed in a Vite-based Storybook project. The issue happens because the template uses `@storybook/react` imports, but Vite projects require `@storybook/react-vite`.
242
+ ## ๐Ÿ“„ License
669
243
 
670
- **Solution:**
671
- 1. Update your `src/stories/StoryUI/StoryUIPanel.stories.tsx` file
672
- 2. Change the import from:
673
- ```typescript
674
- import { StoryFn, Meta } from '@storybook/react';
675
- ```
676
- To:
677
- ```typescript
678
- import type { StoryFn, Meta } from '@storybook/react-vite';
679
- ```
244
+ MIT ยฉ [Story UI Contributors](LICENSE)
680
245
 
681
- **Note:** This issue has been fixed in Story UI v1.2.0+. The init command now automatically detects your Storybook framework and uses the correct import.
246
+ ## ๐Ÿ”— Links
682
247
 
683
- ### Configuration validation errors
248
+ - [GitHub Repository](https://github.com/southleft/story-ui)
249
+ - [NPM Package](https://www.npmjs.com/package/@tpitre/story-ui)
250
+ - [Issues & Support](https://github.com/southleft/story-ui/issues)
684
251
 
685
- If you see "Components path does not exist" error when using a design system from npm (like Ant Design):
686
-
687
- **Solution:**
688
- Add `componentsPath: null` to your `story-ui.config.js`:
689
- ```javascript
690
- module.exports = {
691
- importPath: "antd",
692
- componentPrefix: "",
693
- componentsPath: null,
694
- // ... rest of config
695
- };
696
- ```
252
+ ---
697
253
 
698
- ## Support
254
+ *Story UI - Making component documentation delightful, one conversation at a time.* โœจ
699
255
 
700
- - ๐Ÿ“– [Documentation](https://github.com/southleft/story-ui#readme)
701
- - ๐Ÿ› [Issues](https://github.com/southleft/story-ui/issues)