@tpitre/story-ui 1.0.0
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 +17 -0
- package/LICENSE +21 -0
- package/README.md +531 -0
- package/dist/cli/index.js +250 -0
- package/dist/cli/setup.js +289 -0
- package/dist/index.js +12 -0
- package/dist/mcp-server/index.js +64 -0
- package/dist/mcp-server/routes/claude.js +30 -0
- package/dist/mcp-server/routes/components.js +26 -0
- package/dist/mcp-server/routes/generateStory.js +289 -0
- package/dist/mcp-server/routes/memoryStories.js +141 -0
- package/dist/mcp-server/routes/storySync.js +147 -0
- package/dist/story-generator/componentDiscovery.js +222 -0
- package/dist/story-generator/configLoader.js +482 -0
- package/dist/story-generator/generateStory.js +19 -0
- package/dist/story-generator/gitignoreManager.js +182 -0
- package/dist/story-generator/inMemoryStoryService.js +128 -0
- package/dist/story-generator/productionGitignoreManager.js +333 -0
- package/dist/story-generator/promptGenerator.js +201 -0
- package/dist/story-generator/storySync.js +201 -0
- package/dist/story-ui.config.js +114 -0
- package/dist/story-ui.config.loader.js +205 -0
- package/package.json +80 -0
- package/templates/README.md +32 -0
- package/templates/StoryUI/StoryUIPanel.stories.tsx +28 -0
- package/templates/StoryUI/StoryUIPanel.tsx +870 -0
- package/templates/StoryUI/index.tsx +2 -0
package/.env.sample
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Story UI Configuration
|
|
2
|
+
# Copy this file to .env and add your Claude API key
|
|
3
|
+
|
|
4
|
+
# Claude API Configuration
|
|
5
|
+
# Get your API key from: https://console.anthropic.com/
|
|
6
|
+
CLAUDE_API_KEY=your-claude-api-key-here
|
|
7
|
+
|
|
8
|
+
# Optional: Specify Claude model (defaults to claude-3-opus-20240229)
|
|
9
|
+
# Available models: claude-3-opus-20240229, claude-3-sonnet-20240229, claude-3-haiku-20240307
|
|
10
|
+
CLAUDE_MODEL=claude-3-opus-20240229
|
|
11
|
+
|
|
12
|
+
# Story UI Server Configuration
|
|
13
|
+
# Port for the MCP server (defaults to 4001)
|
|
14
|
+
PORT=4001
|
|
15
|
+
|
|
16
|
+
# Optional: Story UI configuration file path
|
|
17
|
+
# STORY_UI_CONFIG_PATH=./story-ui.config.js
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Story UI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
# Story UI - AI-Powered Storybook Story Generator
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ๐ค **AI-Powered Generation**: Uses Claude AI to generate stories from natural language prompts
|
|
8
|
+
- ๐ง **Component Library Agnostic**: Works with any React component library
|
|
9
|
+
- ๐ฑ **Smart Layout Generation**: Automatically creates proper multi-column layouts
|
|
10
|
+
- ๐ **Component Discovery**: Automatically discovers and analyzes your components
|
|
11
|
+
- โ๏ธ **Flexible Configuration**: Highly customizable for different design systems
|
|
12
|
+
- ๐ **MCP Server**: Integrates with Claude Desktop and other MCP clients
|
|
13
|
+
- ๐๏ธ **Git Integration**: Automatically manages .gitignore for ephemeral stories
|
|
14
|
+
- ๐งน **Cleanup Utilities**: Built-in cleanup for old generated stories
|
|
15
|
+
- ๐จ **Built-in UI**: Includes a Storybook panel for easy interaction
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @tpitre/story-ui --save-dev
|
|
23
|
+
# or
|
|
24
|
+
yarn add -D @tpitre/story-ui
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. Run Setup
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx story-ui init
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This interactive setup will:
|
|
34
|
+
- โ
Detect your design system (Material-UI, Chakra UI, Ant Design, etc.)
|
|
35
|
+
- โ
Create configuration file (`story-ui.config.js`)
|
|
36
|
+
- โ
Install the Story UI panel component in your stories
|
|
37
|
+
- โ
Create `.env` file for API configuration
|
|
38
|
+
- โ
Add convenience scripts to your `package.json`
|
|
39
|
+
- โ
Update `.gitignore` with appropriate patterns
|
|
40
|
+
|
|
41
|
+
### 3. Add Your Claude API Key
|
|
42
|
+
|
|
43
|
+
If you didn't add it during setup, edit the `.env` file:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Get your API key from: https://console.anthropic.com/
|
|
47
|
+
CLAUDE_API_KEY=your-claude-api-key-here
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Important:** Keep your API key secure and never commit `.env` files to version control!
|
|
51
|
+
|
|
52
|
+
### 4. Start Using Story UI
|
|
53
|
+
|
|
54
|
+
Run both Storybook and Story UI together:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run storybook-with-ui
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or run them separately:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Terminal 1
|
|
64
|
+
npm run storybook
|
|
65
|
+
|
|
66
|
+
# Terminal 2
|
|
67
|
+
npm run story-ui
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 5. Generate Your First Story
|
|
71
|
+
|
|
72
|
+
1. Open Storybook in your browser
|
|
73
|
+
2. Navigate to **"Story UI > Story Generator"** in the sidebar
|
|
74
|
+
3. Enter a natural language prompt like:
|
|
75
|
+
- "Create a login form with email and password fields"
|
|
76
|
+
- "Build a three-column dashboard with cards"
|
|
77
|
+
- "Design a hero section with navigation"
|
|
78
|
+
4. Click "Generate" and watch your UI come to life!
|
|
79
|
+
|
|
80
|
+
## How It Works
|
|
81
|
+
|
|
82
|
+
1. **Component Discovery**: Story UI automatically discovers all components in your project
|
|
83
|
+
2. **AI Understanding**: Your prompt is processed by Claude AI with knowledge of your components
|
|
84
|
+
3. **Code Generation**: Clean, production-ready story code is generated
|
|
85
|
+
4. **Live Preview**: See your generated UI instantly in Storybook
|
|
86
|
+
5. **Iteration**: Refine your designs with follow-up prompts in the same session
|
|
87
|
+
|
|
88
|
+
## What Gets Installed
|
|
89
|
+
|
|
90
|
+
After running `npx story-ui init`, your project structure will include:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
your-project/
|
|
94
|
+
โโโ .env # Created from template
|
|
95
|
+
โโโ story-ui.config.js # Generated configuration
|
|
96
|
+
โโโ src/stories/
|
|
97
|
+
โ โโโ StoryUI/ # UI component
|
|
98
|
+
โ โ โโโ StoryUIPanel.tsx
|
|
99
|
+
โ โ โโโ StoryUIPanel.stories.tsx
|
|
100
|
+
โ โ โโโ index.tsx
|
|
101
|
+
โ โโโ generated/ # Where AI stories go
|
|
102
|
+
โโโ package.json # Updated with scripts
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Installation Flow
|
|
106
|
+
|
|
107
|
+
```mermaid
|
|
108
|
+
graph TD
|
|
109
|
+
A[Developer runs:<br/>'npm install story-ui'] --> B[Story UI package installed]
|
|
110
|
+
B --> C[Developer runs:<br/>'npx story-ui init']
|
|
111
|
+
C --> D{Interactive Setup}
|
|
112
|
+
D --> E[Detects design system<br/>MUI, Chakra, Ant Design, etc.]
|
|
113
|
+
D --> F[Creates story-ui.config.js]
|
|
114
|
+
D --> G[Copies StoryUI component<br/>to project stories directory]
|
|
115
|
+
D --> H[Creates .env file<br/>from template]
|
|
116
|
+
D --> I[Updates .gitignore]
|
|
117
|
+
D --> J[Adds npm scripts<br/>to package.json]
|
|
118
|
+
|
|
119
|
+
E --> K[Configuration complete]
|
|
120
|
+
F --> K
|
|
121
|
+
G --> K
|
|
122
|
+
H --> K
|
|
123
|
+
I --> K
|
|
124
|
+
J --> K
|
|
125
|
+
|
|
126
|
+
K --> L[Developer adds<br/>Claude API key to .env]
|
|
127
|
+
L --> M[Developer runs:<br/>'npm run storybook-with-ui']
|
|
128
|
+
M --> N[Storybook opens with<br/>Story UI panel available]
|
|
129
|
+
N --> O[Non-developer can<br/>generate UI with prompts]
|
|
130
|
+
|
|
131
|
+
style A fill:#e1f5e1
|
|
132
|
+
style N fill:#e1f5e1
|
|
133
|
+
style O fill:#ffd4e5
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Configuration Options
|
|
137
|
+
|
|
138
|
+
### Complete Configuration Interface
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
interface StoryUIConfig {
|
|
142
|
+
// File paths
|
|
143
|
+
generatedStoriesPath: string; // Where to save generated stories
|
|
144
|
+
componentsPath?: string; // Path to your components
|
|
145
|
+
componentsMetadataPath?: string; // Path to custom-elements.json (optional)
|
|
146
|
+
|
|
147
|
+
// Story configuration
|
|
148
|
+
storyPrefix: string; // Prefix for story titles
|
|
149
|
+
defaultAuthor: string; // Default author name
|
|
150
|
+
importPath: string; // Import path for components
|
|
151
|
+
|
|
152
|
+
// Component system configuration
|
|
153
|
+
componentPrefix: string; // Component naming prefix
|
|
154
|
+
components: ComponentConfig[]; // Component definitions
|
|
155
|
+
layoutRules: LayoutRules; // Layout generation rules
|
|
156
|
+
|
|
157
|
+
// Template configuration
|
|
158
|
+
sampleStory?: string; // Custom story template
|
|
159
|
+
systemPrompt?: string; // Custom AI system prompt
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Layout Rules Configuration
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
interface LayoutRules {
|
|
167
|
+
multiColumnWrapper?: string; // Main layout component
|
|
168
|
+
columnComponent?: string; // Column/section component
|
|
169
|
+
containerComponent?: string; // Container wrapper component
|
|
170
|
+
layoutExamples?: {
|
|
171
|
+
twoColumn?: string; // Two-column layout example
|
|
172
|
+
threeColumn?: string; // Three-column layout example
|
|
173
|
+
grid?: string; // Grid layout example
|
|
174
|
+
};
|
|
175
|
+
prohibitedElements?: string[]; // HTML elements to avoid
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Configuration Methods
|
|
180
|
+
|
|
181
|
+
### 1. Configuration File
|
|
182
|
+
|
|
183
|
+
Create `story-ui.config.js`:
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
export default {
|
|
187
|
+
generatedStoriesPath: './src/stories/generated',
|
|
188
|
+
componentsPath: './src/components',
|
|
189
|
+
importPath: 'my-design-system',
|
|
190
|
+
componentPrefix: 'DS',
|
|
191
|
+
layoutRules: {
|
|
192
|
+
multiColumnWrapper: 'DSLayout',
|
|
193
|
+
columnComponent: 'DSColumn'
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 2. Package.json Configuration
|
|
199
|
+
|
|
200
|
+
Add to your `package.json`:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"storyUI": {
|
|
205
|
+
"generatedStoriesPath": "./src/stories/generated",
|
|
206
|
+
"componentsPath": "./src/components",
|
|
207
|
+
"importPath": "my-design-system",
|
|
208
|
+
"componentPrefix": "DS"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### 3. Auto-Detection
|
|
214
|
+
|
|
215
|
+
Story UI can automatically detect your project structure:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
npx story-ui init --auto-detect
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Component Discovery
|
|
222
|
+
|
|
223
|
+
Story UI automatically discovers components using multiple methods:
|
|
224
|
+
|
|
225
|
+
1. **Directory Structure**: Scans component directories for `.tsx` files
|
|
226
|
+
2. **Story Files**: Extracts component information from existing `.stories.tsx` files
|
|
227
|
+
3. **Custom Elements**: Reads `custom-elements.json` for web components
|
|
228
|
+
4. **Package Exports**: Analyzes package.json exports and index files
|
|
229
|
+
|
|
230
|
+
## Design System Examples
|
|
231
|
+
|
|
232
|
+
### Material-UI
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
export default {
|
|
236
|
+
importPath: '@mui/material',
|
|
237
|
+
componentPrefix: '',
|
|
238
|
+
layoutRules: {
|
|
239
|
+
multiColumnWrapper: 'Grid',
|
|
240
|
+
columnComponent: 'Grid',
|
|
241
|
+
layoutExamples: {
|
|
242
|
+
twoColumn: `<Grid container spacing={2}>
|
|
243
|
+
<Grid item xs={6}>
|
|
244
|
+
<Card>Left content</Card>
|
|
245
|
+
</Grid>
|
|
246
|
+
<Grid item xs={6}>
|
|
247
|
+
<Card>Right content</Card>
|
|
248
|
+
</Grid>
|
|
249
|
+
</Grid>`
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Chakra UI
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
export default {
|
|
259
|
+
importPath: '@chakra-ui/react',
|
|
260
|
+
componentPrefix: '',
|
|
261
|
+
layoutRules: {
|
|
262
|
+
multiColumnWrapper: 'SimpleGrid',
|
|
263
|
+
columnComponent: 'Box',
|
|
264
|
+
layoutExamples: {
|
|
265
|
+
twoColumn: `<SimpleGrid columns={2} spacing={4}>
|
|
266
|
+
<Box>
|
|
267
|
+
<Card>Left content</Card>
|
|
268
|
+
</Box>
|
|
269
|
+
<Box>
|
|
270
|
+
<Card>Right content</Card>
|
|
271
|
+
</Box>
|
|
272
|
+
</SimpleGrid>`
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Ant Design
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
export default {
|
|
282
|
+
importPath: 'antd',
|
|
283
|
+
componentPrefix: '',
|
|
284
|
+
layoutRules: {
|
|
285
|
+
multiColumnWrapper: 'Row',
|
|
286
|
+
columnComponent: 'Col',
|
|
287
|
+
layoutExamples: {
|
|
288
|
+
twoColumn: `<Row gutter={16}>
|
|
289
|
+
<Col span={12}>
|
|
290
|
+
<Card>Left content</Card>
|
|
291
|
+
</Col>
|
|
292
|
+
<Col span={12}>
|
|
293
|
+
<Card>Right content</Card>
|
|
294
|
+
</Col>
|
|
295
|
+
</Row>`
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## API Reference
|
|
302
|
+
|
|
303
|
+
### HTTP Endpoints
|
|
304
|
+
|
|
305
|
+
#### POST `/mcp/generate-story`
|
|
306
|
+
|
|
307
|
+
Generate a new story from a natural language prompt.
|
|
308
|
+
|
|
309
|
+
**Request Body:**
|
|
310
|
+
```json
|
|
311
|
+
{
|
|
312
|
+
"prompt": "Create a three-column layout with different card types",
|
|
313
|
+
"fileName": "optional-custom-filename.stories.tsx"
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Response:**
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"success": true,
|
|
321
|
+
"fileName": "generated-filename.stories.tsx",
|
|
322
|
+
"outPath": "/path/to/generated/story",
|
|
323
|
+
"title": "Generated Story Title",
|
|
324
|
+
"story": "// Generated story content..."
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### MCP Integration
|
|
329
|
+
|
|
330
|
+
Story UI includes an MCP (Model Context Protocol) server for integration with Claude Desktop:
|
|
331
|
+
|
|
332
|
+
1. Add to your Claude Desktop configuration:
|
|
333
|
+
```json
|
|
334
|
+
{
|
|
335
|
+
"mcpServers": {
|
|
336
|
+
"story-ui": {
|
|
337
|
+
"command": "node",
|
|
338
|
+
"args": ["/path/to/story-ui/dist/mcp-server/index.js"]
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
2. Use in Claude Desktop:
|
|
345
|
+
```
|
|
346
|
+
Generate a two-column layout with cards using Story UI
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## CLI Commands
|
|
350
|
+
|
|
351
|
+
### Initialize Configuration
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
npx story-ui init
|
|
355
|
+
npx story-ui init --auto-detect
|
|
356
|
+
npx story-ui init --template=material-ui
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Start Server
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
npx story-ui start
|
|
363
|
+
npx story-ui start --port=4001
|
|
364
|
+
npx story-ui start --config=./custom-config.js
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Generate Sample Config
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
npx story-ui config --generate
|
|
371
|
+
npx story-ui config --generate --type=json
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Environment Variables
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
CLAUDE_API_KEY=your_claude_api_key_here
|
|
378
|
+
CLAUDE_MODEL=claude-3-opus-20240229 # Optional, defaults to opus
|
|
379
|
+
PORT=4001 # Optional, defaults to 4001
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Production-Ready Deployment
|
|
383
|
+
|
|
384
|
+
Story UI is designed for **seamless deployment** across development and production environments, with automatic environment detection and appropriate story generation strategies.
|
|
385
|
+
|
|
386
|
+
### ๐ **Environment Detection**
|
|
387
|
+
|
|
388
|
+
Story UI automatically detects your environment:
|
|
389
|
+
|
|
390
|
+
**Development Environment:**
|
|
391
|
+
- โ
**File-system storage** - Stories written to configured directory
|
|
392
|
+
- โ
**Automatic .gitignore** - Generated directory added to git ignore
|
|
393
|
+
- โ
**Directory structure** - Creates necessary folders and README
|
|
394
|
+
|
|
395
|
+
**Production Environment (Vercel, Netlify, etc.):**
|
|
396
|
+
- โ
**In-memory storage** - Stories stored in server memory
|
|
397
|
+
- โ
**Read-only compatibility** - Works without file system write permissions
|
|
398
|
+
- โ
**Memory management** - Automatic cleanup to prevent memory leaks
|
|
399
|
+
- โ
**API endpoints** - RESTful API for story management
|
|
400
|
+
|
|
401
|
+
### ๐ง **Automatic Setup**
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
# Development setup
|
|
405
|
+
npx story-ui init --auto-detect
|
|
406
|
+
npx story-ui setup-gitignore
|
|
407
|
+
|
|
408
|
+
# Production deployment
|
|
409
|
+
# No additional setup needed - automatically detected!
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### ๐๏ธ **Git Integration**
|
|
413
|
+
|
|
414
|
+
**Development:**
|
|
415
|
+
```bash
|
|
416
|
+
# Automatically adds to .gitignore:
|
|
417
|
+
./libs/your-components/src/components/generated/
|
|
418
|
+
./libs/your-components/src/components/generated/**
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
**Production:**
|
|
422
|
+
- Stories stored in memory only
|
|
423
|
+
- No file system writes required
|
|
424
|
+
- Perfect for read-only deployments
|
|
425
|
+
|
|
426
|
+
### ๐ฏ **Use Cases**
|
|
427
|
+
|
|
428
|
+
**Perfect for:**
|
|
429
|
+
- ๐จ **Layout Testing** - Test component arrangements without committing
|
|
430
|
+
- ๐ฅ **Stakeholder Review** - Share layouts with product owners and designers
|
|
431
|
+
- ๐ **Rapid Iteration** - Generate, test, and regenerate layouts quickly
|
|
432
|
+
- ๐ฑ **Design Validation** - Validate designs before implementation
|
|
433
|
+
- ๐ **Public Demos** - Deploy to Vercel/Netlify for team collaboration
|
|
434
|
+
|
|
435
|
+
**Example Production Workflow:**
|
|
436
|
+
1. Deploy Storybook + Story UI to Vercel/Netlify
|
|
437
|
+
2. Product owners generate layouts using natural language
|
|
438
|
+
3. Stories stored in server memory (ephemeral)
|
|
439
|
+
4. Share generated stories with team for feedback
|
|
440
|
+
5. Iterate and refine layouts
|
|
441
|
+
6. Implement approved layouts in actual codebase
|
|
442
|
+
|
|
443
|
+
### ๐ **Production Monitoring**
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
# Check server status and memory usage
|
|
447
|
+
curl http://your-server.vercel.app/mcp/stats
|
|
448
|
+
|
|
449
|
+
# Get all generated stories
|
|
450
|
+
curl http://your-server.vercel.app/mcp/stories
|
|
451
|
+
|
|
452
|
+
# Get specific story content
|
|
453
|
+
curl http://your-server.vercel.app/mcp/stories/story-abc123/content
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### ๐งน **Memory Management**
|
|
457
|
+
|
|
458
|
+
Production environments automatically:
|
|
459
|
+
- ๐ **Cleanup old stories** - Removes stories older than 24 hours
|
|
460
|
+
- ๐ **Memory limits** - Keeps maximum 50 stories in memory
|
|
461
|
+
- ๐ **Usage tracking** - Monitors memory usage and story access patterns
|
|
462
|
+
|
|
463
|
+
```javascript
|
|
464
|
+
import { ProductionGitignoreManager, getInMemoryStoryService } from 'story-ui';
|
|
465
|
+
|
|
466
|
+
// Manual cleanup if needed
|
|
467
|
+
const manager = new ProductionGitignoreManager(config);
|
|
468
|
+
manager.cleanupOldStories();
|
|
469
|
+
|
|
470
|
+
// Memory statistics
|
|
471
|
+
const storyService = getInMemoryStoryService(config);
|
|
472
|
+
const stats = storyService.getMemoryStats();
|
|
473
|
+
console.log(`${stats.storyCount} stories using ${stats.totalSizeMB}MB`);
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## Contributing
|
|
477
|
+
|
|
478
|
+
Story UI is designed to be community-driven and extensible. Contributions are welcome!
|
|
479
|
+
|
|
480
|
+
### Development Setup
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
git clone https://github.com/your-org/story-ui
|
|
484
|
+
cd story-ui
|
|
485
|
+
yarn install
|
|
486
|
+
yarn build
|
|
487
|
+
yarn start
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Adding Design System Templates
|
|
491
|
+
|
|
492
|
+
1. Create a new configuration template in `templates/`
|
|
493
|
+
2. Add examples and documentation
|
|
494
|
+
3. Submit a pull request
|
|
495
|
+
|
|
496
|
+
## License
|
|
497
|
+
|
|
498
|
+
MIT License - see LICENSE file for details.
|
|
499
|
+
|
|
500
|
+
## Publishing to npm
|
|
501
|
+
|
|
502
|
+
To publish Story UI to npm:
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
# Make sure you're logged in to npm
|
|
506
|
+
npm login
|
|
507
|
+
|
|
508
|
+
# Build the project
|
|
509
|
+
npm run build
|
|
510
|
+
|
|
511
|
+
# Publish to npm
|
|
512
|
+
npm publish
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
For pre-release versions:
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
# Beta release
|
|
519
|
+
npm version 1.0.1-beta.0
|
|
520
|
+
npm publish --tag beta
|
|
521
|
+
|
|
522
|
+
# Alpha release
|
|
523
|
+
npm version 1.0.1-alpha.0
|
|
524
|
+
npm publish --tag alpha
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
## Support
|
|
528
|
+
|
|
529
|
+
- ๐ [Documentation](https://github.com/southleft/story-ui#readme)
|
|
530
|
+
- ๐ [Issues](https://github.com/southleft/story-ui/issues)
|
|
531
|
+
- ๐ฌ [Discussions](https://github.com/southleft/story-ui/discussions)
|