@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.
- package/.env.sample +3 -1
- package/README.md +160 -606
- package/dist/cli/index.js +23 -24
- package/dist/cli/setup.js +295 -36
- package/dist/mcp-server/index.js +67 -0
- package/dist/mcp-server/routes/generateStory.js +323 -56
- package/dist/story-generator/componentBlacklist.js +181 -0
- package/dist/story-generator/componentDiscovery.js +9 -2
- package/dist/story-generator/configLoader.js +109 -39
- package/dist/story-generator/considerationsLoader.js +204 -0
- package/dist/story-generator/documentation-sources.js +36 -0
- package/dist/story-generator/documentationLoader.js +214 -0
- package/dist/story-generator/dynamicPackageDiscovery.js +527 -0
- package/dist/story-generator/enhancedComponentDiscovery.js +369 -118
- package/dist/story-generator/generateStory.js +7 -3
- package/dist/story-generator/postProcessStory.js +71 -0
- package/dist/story-generator/promptGenerator.js +286 -37
- package/dist/story-generator/storyHistory.js +118 -0
- package/dist/story-generator/storyTracker.js +33 -18
- package/dist/story-generator/storyValidator.js +39 -0
- package/dist/story-generator/universalDesignSystemAdapter.js +209 -0
- package/dist/story-generator/validateStory.js +82 -7
- package/dist/story-ui.config.js +12 -5
- package/package.json +11 -6
- package/templates/StoryUI/StoryUIPanel.stories.tsx +29 -13
- package/templates/StoryUI/StoryUIPanel.tsx +489 -359
- package/templates/react-import-rule.json +36 -0
- package/templates/story-generation-rules.json +29 -0
- package/templates/story-ui-considerations.json +156 -0
- package/templates/story-ui-considerations.md +109 -0
- package/templates/story-ui-docs-README.md +55 -0
- package/dist/scripts/test-validation.js +0 -81
- package/dist/test-storybooks/chakra-test/src/components/index.js +0 -3
- package/dist/test-storybooks/custom-design-test/src/components/index.js +0 -3
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,701 +1,255 @@
|
|
|
1
|
-
# Story UI
|
|
1
|
+
# Story UI ๐จ
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
3
|
+
*AI-powered Storybook story generator for any React component library*
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
[](https://badge.fury.io/js/%40tpitre%2Fstory-ui)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
+
## ๐ Quick Start
|
|
27
35
|
|
|
28
36
|
```bash
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
yarn add -D @tpitre/story-ui
|
|
32
|
-
```
|
|
37
|
+
# Install Story UI
|
|
38
|
+
npm install -D @tpitre/story-ui
|
|
33
39
|
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
##
|
|
57
|
+
## ๐ How It Works
|
|
144
58
|
|
|
145
|
-
|
|
59
|
+
Story UI uses advanced AI to understand your component library and generate appropriate stories:
|
|
146
60
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
197
|
-
|
|
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: '
|
|
200
|
-
columnComponent: '
|
|
88
|
+
multiColumnWrapper: 'div',
|
|
89
|
+
columnComponent: 'div',
|
|
90
|
+
containerComponent: 'div'
|
|
201
91
|
}
|
|
202
92
|
};
|
|
203
93
|
```
|
|
204
94
|
|
|
205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
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
|
-
##
|
|
108
|
+
## ๐ฑ Examples
|
|
283
109
|
|
|
284
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
150
|
+
## ๐ Documentation Support
|
|
477
151
|
|
|
478
|
-
|
|
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
|
-
|
|
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
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
177
|
+
### Legacy Single-File Documentation
|
|
503
178
|
|
|
504
|
-
|
|
179
|
+
You can still use a single `story-ui-considerations.md` file in your project root for simpler setups.
|
|
505
180
|
|
|
506
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
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
|
-
|
|
205
|
+
## ๐ CLI Commands
|
|
561
206
|
|
|
562
207
|
```bash
|
|
563
|
-
#
|
|
564
|
-
|
|
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
|
-
|
|
581
|
-
|
|
211
|
+
# Start the Story UI server
|
|
212
|
+
npx story-ui start
|
|
582
213
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
manager.cleanupOldStories();
|
|
214
|
+
# Start on a specific port
|
|
215
|
+
npx story-ui start --port 4005
|
|
586
216
|
|
|
587
|
-
|
|
588
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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
|
-
#
|
|
654
|
-
|
|
237
|
+
# Test in a project
|
|
238
|
+
cd your-project
|
|
239
|
+
npm link @tpitre/story-ui
|
|
655
240
|
```
|
|
656
241
|
|
|
657
|
-
|
|
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
|
-
|
|
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
|
-
|
|
246
|
+
## ๐ Links
|
|
682
247
|
|
|
683
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|