@tpitre/story-ui 2.5.0 ā 2.6.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/README.md +366 -224
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +76 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,170 +1,264 @@
|
|
|
1
|
-
# Story UI
|
|
1
|
+
# Story UI
|
|
2
2
|
|
|
3
|
-
*AI-powered Storybook story generator for any
|
|
3
|
+
*AI-powered Storybook story generator for any JavaScript framework*
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/%40tpitre%2Fstory-ui)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
Story UI revolutionizes component documentation by automatically generating Storybook stories through AI-powered conversations.
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- **Multi-Provider LLM Support**: Choose between Claude, OpenAI, or Gemini
|
|
22
|
-
- **Production Deployment**: Deploy as a standalone web app with Railway or Cloudflare
|
|
23
|
-
- **Post-Generation Validation**: Automatic syntax validation with error detection
|
|
24
|
-
- **Children Props Preservation**: Intelligent handling of `children: 'text'` in args
|
|
25
|
-
- **Image/Vision Support**: Attach screenshots for visual component requests
|
|
26
|
-
- **In-Memory Storage**: Production mode without file system writes
|
|
27
|
-
- **REST API**: Full CRUD operations for story management
|
|
28
|
-
- **Design System Agnosticism**: Core code is framework-independent
|
|
29
|
-
|
|
30
|
-
### š Documentation System (New!)
|
|
31
|
-
- **Auto-Generated Structure**: `npx story-ui init` creates a `story-ui-docs/` directory template
|
|
32
|
-
- **Directory-Based Documentation**: Organize design system docs in a structured directory
|
|
33
|
-
- **Multiple Format Support**: Markdown, JSON, HTML, and text files
|
|
34
|
-
- **Legacy Support**: Still supports single `story-ui-considerations.md` file
|
|
35
|
-
- **Auto-Discovery**: Automatically finds and loads documentation to enhance AI story generation
|
|
36
|
-
|
|
37
|
-
### šØ Advanced Features
|
|
38
|
-
- **Memory-Persistent Stories**: Stories are remembered across sessions
|
|
39
|
-
- **Git Integration**: Automatic gitignore management for generated files
|
|
40
|
-
- **Production Mode**: Clean deployment without generated stories
|
|
41
|
-
- **Auto Port Detection**: Automatically finds available ports
|
|
42
|
-
- **Hot Reload Integration**: Stories update automatically as you chat
|
|
43
|
-
- **MCP Server Integration**: Use Story UI directly from Claude Desktop or other MCP clients
|
|
44
|
-
|
|
45
|
-
## š Quick Start
|
|
8
|
+
Story UI revolutionizes component documentation by automatically generating Storybook stories through AI-powered conversations. Works with **any framework** (React, Vue, Angular, Svelte, Web Components) and **any LLM provider** (Claude, OpenAI, Gemini).
|
|
9
|
+
|
|
10
|
+
## Why Story UI?
|
|
11
|
+
|
|
12
|
+
- **Framework Agnostic**: Works with React, Vue, Angular, Svelte, and Web Components
|
|
13
|
+
- **Multi-Provider AI**: Choose between Claude (Anthropic), GPT-4 (OpenAI), or Gemini (Google)
|
|
14
|
+
- **Design System Aware**: Learns your component library and generates appropriate code
|
|
15
|
+
- **Production Ready**: Deploy as a standalone web app with full MCP integration
|
|
16
|
+
- **Zero Lock-in**: Use any component library - Mantine, Vuetify, Angular Material, Shoelace, or your own
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
46
21
|
|
|
47
22
|
```bash
|
|
48
23
|
# Install Story UI
|
|
49
24
|
npm install -D @tpitre/story-ui
|
|
50
25
|
|
|
51
|
-
# Initialize
|
|
26
|
+
# Initialize in your project
|
|
52
27
|
npx story-ui init
|
|
53
28
|
|
|
54
|
-
# Start generating stories
|
|
29
|
+
# Start generating stories
|
|
55
30
|
npm run story-ui
|
|
56
|
-
|
|
57
|
-
# Need a custom port? Just pass the flag:
|
|
58
|
-
npm run story-ui -- --port 4005
|
|
59
31
|
```
|
|
60
32
|
|
|
61
|
-
Story UI will
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
33
|
+
Story UI will guide you through:
|
|
34
|
+
1. Selecting your JavaScript framework
|
|
35
|
+
2. Choosing a design system (or using your own)
|
|
36
|
+
3. Configuring your preferred AI provider
|
|
37
|
+
4. Setting up component discovery
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Features
|
|
67
42
|
|
|
68
|
-
|
|
43
|
+
### Core Capabilities
|
|
44
|
+
- **AI-Powered Story Generation**: Describe what you want in natural language
|
|
45
|
+
- **Intelligent Iteration**: Modify existing stories without losing your work
|
|
46
|
+
- **Real-time Preview**: See generated stories instantly in Storybook
|
|
47
|
+
- **TypeScript Support**: Full type-aware story generation
|
|
48
|
+
- **Vision Support**: Attach screenshots for visual component requests
|
|
69
49
|
|
|
70
|
-
|
|
50
|
+
### Multi-Framework Support
|
|
71
51
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
| Framework | Design Systems | Status |
|
|
53
|
+
|-----------|---------------|--------|
|
|
54
|
+
| React | Mantine, Chakra UI, MUI, Ant Design, ShadCN, Custom | Fully Supported |
|
|
55
|
+
| Vue | Vuetify, Element Plus, PrimeVue, Quasar, Custom | Fully Supported |
|
|
56
|
+
| Angular | Angular Material, PrimeNG, NG-ZORRO, Custom | Fully Supported |
|
|
57
|
+
| Svelte | Skeleton, Custom | Fully Supported |
|
|
58
|
+
| Web Components | Shoelace, Lit, Custom | Fully Supported |
|
|
77
59
|
|
|
78
|
-
|
|
60
|
+
### Multi-Provider LLM Support
|
|
61
|
+
|
|
62
|
+
| Provider | Models | Best For |
|
|
63
|
+
|----------|--------|----------|
|
|
64
|
+
| **Claude** (Anthropic) | claude-sonnet-4, claude-3.5-sonnet, claude-3-haiku | Complex reasoning, code quality |
|
|
65
|
+
| **GPT-4** (OpenAI) | gpt-4o, gpt-4-turbo, gpt-3.5-turbo | Versatility, speed |
|
|
66
|
+
| **Gemini** (Google) | gemini-2.0-flash, gemini-1.5-pro | Fast generation, cost efficiency |
|
|
67
|
+
|
|
68
|
+
### Production Deployment
|
|
69
|
+
- **Cloudflare Workers**: Edge-deployed API proxy
|
|
70
|
+
- **Cloudflare Pages**: Static frontend hosting
|
|
71
|
+
- **Railway**: Full Node.js backend (alternative)
|
|
72
|
+
- **MCP Integration**: Connect AI clients directly to production
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Installation Options
|
|
77
|
+
|
|
78
|
+
### Option 1: Interactive Setup (Recommended)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx story-ui init
|
|
82
|
+
```
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
The interactive installer will ask:
|
|
85
|
+
|
|
86
|
+
1. **Framework Selection**
|
|
87
|
+
```
|
|
88
|
+
? Which JavaScript framework are you using?
|
|
89
|
+
> React
|
|
90
|
+
Vue
|
|
91
|
+
Angular
|
|
92
|
+
Svelte
|
|
93
|
+
Web Components
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
2. **Design System Selection** (varies by framework)
|
|
97
|
+
```
|
|
98
|
+
# For React:
|
|
99
|
+
? Choose a design system:
|
|
100
|
+
> ShadCN/UI
|
|
101
|
+
Mantine
|
|
102
|
+
Chakra UI
|
|
103
|
+
Ant Design
|
|
104
|
+
Custom
|
|
105
|
+
|
|
106
|
+
# For Vue:
|
|
107
|
+
? Choose a design system:
|
|
108
|
+
> Vuetify
|
|
109
|
+
Element Plus
|
|
110
|
+
PrimeVue
|
|
111
|
+
Quasar
|
|
112
|
+
Custom
|
|
113
|
+
|
|
114
|
+
# For Angular:
|
|
115
|
+
? Choose a design system:
|
|
116
|
+
> Angular Material
|
|
117
|
+
PrimeNG
|
|
118
|
+
NG-ZORRO
|
|
119
|
+
Custom
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
3. **AI Provider Selection**
|
|
123
|
+
```
|
|
124
|
+
? Which AI provider do you prefer?
|
|
125
|
+
> Claude (Anthropic) - Recommended
|
|
126
|
+
OpenAI (GPT-4)
|
|
127
|
+
Google Gemini
|
|
128
|
+
|
|
129
|
+
? Enter your API key:
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Option 2: Manual Configuration
|
|
133
|
+
|
|
134
|
+
Create `story-ui.config.js` in your project root:
|
|
81
135
|
|
|
82
136
|
```javascript
|
|
83
137
|
export default {
|
|
138
|
+
// Framework: 'react' | 'vue' | 'angular' | 'svelte' | 'web-components'
|
|
139
|
+
framework: 'react',
|
|
140
|
+
|
|
84
141
|
// Component library import path
|
|
85
|
-
importPath: '
|
|
142
|
+
importPath: '@mantine/core',
|
|
86
143
|
|
|
87
|
-
// Path to
|
|
144
|
+
// Path to custom components
|
|
88
145
|
componentsPath: './src/components',
|
|
89
146
|
|
|
90
147
|
// Generated stories location
|
|
91
148
|
generatedStoriesPath: './src/stories/generated/',
|
|
92
149
|
|
|
150
|
+
// LLM provider configuration
|
|
151
|
+
llmProvider: 'claude', // 'claude' | 'openai' | 'gemini'
|
|
152
|
+
|
|
93
153
|
// Story configuration
|
|
94
154
|
storyPrefix: 'Generated/',
|
|
95
|
-
defaultAuthor: 'Story UI AI'
|
|
96
|
-
|
|
97
|
-
// Layout rules for multi-column layouts
|
|
98
|
-
layoutRules: {
|
|
99
|
-
multiColumnWrapper: 'div',
|
|
100
|
-
columnComponent: 'div',
|
|
101
|
-
containerComponent: 'div'
|
|
102
|
-
}
|
|
155
|
+
defaultAuthor: 'Story UI AI'
|
|
103
156
|
};
|
|
104
157
|
```
|
|
105
158
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Story UI provides guided installation and automatic configuration for the following design systems:
|
|
109
|
-
|
|
110
|
-
| Design System | Package | Auto Install | Pre-configured |
|
|
111
|
-
|--------------|---------|--------------|----------------|
|
|
112
|
-
| Ant Design | `antd` | ā
Yes | ā
Yes |
|
|
113
|
-
| Mantine | `@mantine/core` | ā
Yes | ā
Yes |
|
|
114
|
-
| Chakra UI | `@chakra-ui/react` | ā
Yes | ā
Yes |
|
|
115
|
-
| Custom | Any React library | ā Manual | ā
Configurable |
|
|
116
|
-
|
|
117
|
-
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.
|
|
159
|
+
---
|
|
118
160
|
|
|
119
|
-
##
|
|
161
|
+
## Usage
|
|
120
162
|
|
|
121
|
-
###
|
|
163
|
+
### Basic Story Generation
|
|
122
164
|
|
|
165
|
+
Start the Story UI server:
|
|
166
|
+
```bash
|
|
167
|
+
npm run story-ui
|
|
123
168
|
```
|
|
124
|
-
You: "Create a button story with different variants"
|
|
125
169
|
|
|
126
|
-
|
|
170
|
+
Then describe what you want:
|
|
171
|
+
```
|
|
172
|
+
You: "Create a product card with image, title, price, and add to cart button"
|
|
127
173
|
```
|
|
128
174
|
|
|
129
|
-
|
|
175
|
+
Story UI generates:
|
|
130
176
|
```tsx
|
|
131
|
-
export const
|
|
177
|
+
export const ProductCard = {
|
|
132
178
|
render: () => (
|
|
133
|
-
<
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
|
|
179
|
+
<Card shadow="sm" padding="lg" radius="md" withBorder>
|
|
180
|
+
<Card.Section>
|
|
181
|
+
<Image src="https://example.com/product.jpg" height={160} alt="Product" />
|
|
182
|
+
</Card.Section>
|
|
183
|
+
<Group justify="space-between" mt="md" mb="xs">
|
|
184
|
+
<Text fw={500}>Product Name</Text>
|
|
185
|
+
<Badge color="pink">On Sale</Badge>
|
|
186
|
+
</Group>
|
|
187
|
+
<Text size="sm" c="dimmed">$29.99</Text>
|
|
188
|
+
<Button color="blue" fullWidth mt="md" radius="md">
|
|
189
|
+
Add to Cart
|
|
190
|
+
</Button>
|
|
191
|
+
</Card>
|
|
139
192
|
)
|
|
140
193
|
};
|
|
141
194
|
```
|
|
142
195
|
|
|
143
|
-
###
|
|
196
|
+
### Iterating on Stories
|
|
144
197
|
|
|
198
|
+
Continue the conversation to refine:
|
|
145
199
|
```
|
|
146
|
-
You: "
|
|
200
|
+
You: "Make the button green and add a quantity selector"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Story UI modifies only what you requested, preserving the rest.
|
|
147
204
|
|
|
148
|
-
|
|
205
|
+
### Using with Different Frameworks
|
|
206
|
+
|
|
207
|
+
**Vue Example:**
|
|
208
|
+
```
|
|
209
|
+
You: "Create a user profile card with avatar, name, and edit button"
|
|
149
210
|
```
|
|
150
211
|
|
|
151
|
-
|
|
212
|
+
Generates Vue template:
|
|
213
|
+
```vue
|
|
214
|
+
<template>
|
|
215
|
+
<v-card class="mx-auto" max-width="400">
|
|
216
|
+
<v-card-item>
|
|
217
|
+
<v-avatar size="80">
|
|
218
|
+
<v-img src="https://example.com/avatar.jpg" alt="User" />
|
|
219
|
+
</v-avatar>
|
|
220
|
+
<v-card-title>John Doe</v-card-title>
|
|
221
|
+
<v-card-subtitle>Software Engineer</v-card-subtitle>
|
|
222
|
+
</v-card-item>
|
|
223
|
+
<v-card-actions>
|
|
224
|
+
<v-btn color="primary" variant="outlined">Edit Profile</v-btn>
|
|
225
|
+
</v-card-actions>
|
|
226
|
+
</v-card>
|
|
227
|
+
</template>
|
|
228
|
+
```
|
|
152
229
|
|
|
230
|
+
**Angular Example:**
|
|
231
|
+
```
|
|
232
|
+
You: "Create a data table with sorting and pagination"
|
|
153
233
|
```
|
|
154
|
-
You: "Make the buttons full width"
|
|
155
234
|
|
|
156
|
-
|
|
235
|
+
Generates Angular component:
|
|
236
|
+
```typescript
|
|
237
|
+
@Component({
|
|
238
|
+
selector: 'app-data-table',
|
|
239
|
+
template: `
|
|
240
|
+
<mat-table [dataSource]="dataSource" matSort>
|
|
241
|
+
<ng-container matColumnDef="name">
|
|
242
|
+
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
|
243
|
+
<mat-cell *matCellDef="let element">{{element.name}}</mat-cell>
|
|
244
|
+
</ng-container>
|
|
245
|
+
<!-- Additional columns -->
|
|
246
|
+
</mat-table>
|
|
247
|
+
<mat-paginator [pageSizeOptions]="[5, 10, 25]" showFirstLastButtons />
|
|
248
|
+
`
|
|
249
|
+
})
|
|
250
|
+
export class DataTableComponent { }
|
|
157
251
|
```
|
|
158
252
|
|
|
159
|
-
|
|
253
|
+
---
|
|
160
254
|
|
|
161
|
-
##
|
|
255
|
+
## MCP Server Integration
|
|
162
256
|
|
|
163
|
-
Story UI
|
|
257
|
+
Story UI includes a Model Context Protocol (MCP) server, allowing direct integration with AI clients like Claude Desktop.
|
|
164
258
|
|
|
165
|
-
###
|
|
259
|
+
### Local MCP Setup
|
|
166
260
|
|
|
167
|
-
|
|
261
|
+
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
168
262
|
|
|
169
263
|
```json
|
|
170
264
|
{
|
|
@@ -173,190 +267,233 @@ Story UI can be used as a Model Context Protocol (MCP) server, allowing you to g
|
|
|
173
267
|
"command": "npx",
|
|
174
268
|
"args": ["@tpitre/story-ui", "mcp"],
|
|
175
269
|
"env": {
|
|
176
|
-
"
|
|
270
|
+
"ANTHROPIC_API_KEY": "your-api-key"
|
|
177
271
|
}
|
|
178
272
|
}
|
|
179
273
|
}
|
|
180
274
|
}
|
|
181
275
|
```
|
|
182
276
|
|
|
183
|
-
|
|
277
|
+
Then start the Story UI HTTP server:
|
|
184
278
|
```bash
|
|
185
|
-
story-ui start
|
|
279
|
+
npx story-ui start
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Production MCP Setup
|
|
283
|
+
|
|
284
|
+
Connect Claude Desktop to your deployed Story UI instance:
|
|
285
|
+
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"mcpServers": {
|
|
289
|
+
"story-ui-production": {
|
|
290
|
+
"command": "npx",
|
|
291
|
+
"args": ["mcp-remote", "https://your-worker.workers.dev/mcp"],
|
|
292
|
+
"env": {}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
186
296
|
```
|
|
187
297
|
|
|
188
|
-
|
|
298
|
+
This allows you to generate stories in your production environment directly from Claude Desktop, with all your design system configurations loaded.
|
|
189
299
|
|
|
190
|
-
|
|
191
|
-
|
|
300
|
+
### Available MCP Commands
|
|
301
|
+
|
|
302
|
+
Once connected, you can use these commands in Claude Desktop:
|
|
303
|
+
- "Use Story UI to create a hero section with a CTA button"
|
|
192
304
|
- "List all available components in Story UI"
|
|
305
|
+
- "Generate a dashboard layout with sidebar navigation"
|
|
193
306
|
- "Show me the stories I've generated"
|
|
194
307
|
|
|
195
|
-
|
|
308
|
+
---
|
|
196
309
|
|
|
197
|
-
##
|
|
310
|
+
## Production Deployment
|
|
198
311
|
|
|
199
|
-
|
|
312
|
+
Story UI v3 can be deployed as a standalone web application accessible from anywhere.
|
|
200
313
|
|
|
201
|
-
|
|
314
|
+
### Architecture
|
|
202
315
|
|
|
203
316
|
```
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
ā
|
|
208
|
-
ā
|
|
209
|
-
ā
|
|
210
|
-
|
|
211
|
-
ā
|
|
212
|
-
ā
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
317
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
318
|
+
ā Cloudflare Pages ā
|
|
319
|
+
ā (Your Frontend App) ā
|
|
320
|
+
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
321
|
+
ā ā - Chat Interface āā
|
|
322
|
+
ā ā - Live Component Preview āā
|
|
323
|
+
ā ā - Syntax Highlighted Code View āā
|
|
324
|
+
ā ā - Provider/Model Selection āā
|
|
325
|
+
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
326
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
327
|
+
ā
|
|
328
|
+
ā¼
|
|
329
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
330
|
+
ā Cloudflare Workers Edge ā
|
|
331
|
+
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
332
|
+
ā ā - /story-ui/providers ā Available providers/models āā
|
|
333
|
+
ā ā - /story-ui/claude ā Claude API proxy āā
|
|
334
|
+
ā ā - /story-ui/openai ā OpenAI API proxy āā
|
|
335
|
+
ā ā - /story-ui/gemini ā Gemini API proxy āā
|
|
336
|
+
ā ā - /mcp ā MCP JSON-RPC endpoint āā
|
|
337
|
+
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
338
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
220
339
|
```
|
|
221
340
|
|
|
222
|
-
|
|
341
|
+
### Deploy to Cloudflare
|
|
223
342
|
|
|
224
|
-
|
|
343
|
+
**1. Deploy the Edge Worker (Backend)**
|
|
225
344
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
345
|
+
```bash
|
|
346
|
+
cd cloudflare-edge
|
|
347
|
+
wrangler deploy
|
|
229
348
|
|
|
230
|
-
|
|
349
|
+
# Set your API keys as secrets
|
|
350
|
+
wrangler secret put ANTHROPIC_API_KEY
|
|
351
|
+
wrangler secret put OPENAI_API_KEY # optional
|
|
352
|
+
wrangler secret put GEMINI_API_KEY # optional
|
|
353
|
+
```
|
|
231
354
|
|
|
232
|
-
|
|
233
|
-
- Each iteration is saved with a timestamp
|
|
234
|
-
- Previous versions are linked for easy tracking
|
|
235
|
-
- History is stored in `.story-ui-history/` (git-ignored)
|
|
355
|
+
**2. Deploy the Frontend**
|
|
236
356
|
|
|
237
|
-
|
|
357
|
+
```bash
|
|
358
|
+
cd templates/production-app
|
|
359
|
+
npm install
|
|
360
|
+
npm run build
|
|
361
|
+
wrangler pages deploy dist --project-name=your-app-name
|
|
362
|
+
```
|
|
238
363
|
|
|
239
|
-
|
|
240
|
-
- ā
Only existing components are imported
|
|
241
|
-
- ā
Props match component interfaces
|
|
242
|
-
- ā
Import paths are correct
|
|
243
|
-
- ā
TypeScript types are valid
|
|
364
|
+
**3. Configure Environment**
|
|
244
365
|
|
|
245
|
-
|
|
366
|
+
Update the frontend to point to your worker URL in the configuration.
|
|
246
367
|
|
|
247
|
-
|
|
248
|
-
- No files are written to disk
|
|
249
|
-
- Stories are served from memory
|
|
250
|
-
- Clean deployment without generated files
|
|
368
|
+
### Alternative: Railway Backend
|
|
251
369
|
|
|
252
|
-
|
|
370
|
+
For a full Node.js environment:
|
|
253
371
|
|
|
254
372
|
```bash
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
# Start the Story UI server
|
|
259
|
-
npx story-ui start
|
|
260
|
-
|
|
261
|
-
# Start on a specific port
|
|
262
|
-
npx story-ui start --port 4005
|
|
373
|
+
cd mcp-server
|
|
374
|
+
railway up
|
|
263
375
|
|
|
264
|
-
#
|
|
265
|
-
|
|
376
|
+
# Set environment variables in Railway dashboard:
|
|
377
|
+
# - ANTHROPIC_API_KEY
|
|
378
|
+
# - OPENAI_API_KEY (optional)
|
|
379
|
+
# - GEMINI_API_KEY (optional)
|
|
266
380
|
```
|
|
267
381
|
|
|
268
|
-
|
|
382
|
+
---
|
|
269
383
|
|
|
270
|
-
|
|
384
|
+
## Design System Documentation
|
|
271
385
|
|
|
272
|
-
|
|
386
|
+
Story UI can learn your design system conventions to generate better stories.
|
|
273
387
|
|
|
274
|
-
|
|
388
|
+
### Directory-Based Documentation (Recommended)
|
|
275
389
|
|
|
276
|
-
|
|
277
|
-
# Railway CLI (for backend deployment)
|
|
278
|
-
npm install -g @railway/cli
|
|
279
|
-
railway login
|
|
390
|
+
Create a `story-ui-docs/` directory:
|
|
280
391
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
392
|
+
```
|
|
393
|
+
story-ui-docs/
|
|
394
|
+
āāā README.md # Overview
|
|
395
|
+
āāā guidelines/
|
|
396
|
+
ā āāā accessibility.md # A11y guidelines
|
|
397
|
+
ā āāā responsive-design.md # Responsive rules
|
|
398
|
+
ā āāā brand-guidelines.md # Brand usage
|
|
399
|
+
āāā tokens/
|
|
400
|
+
ā āāā colors.json # Color tokens
|
|
401
|
+
ā āāā spacing.md # Spacing system
|
|
402
|
+
ā āāā typography.json # Typography
|
|
403
|
+
āāā components/
|
|
404
|
+
ā āāā button.md # Button documentation
|
|
405
|
+
ā āāā forms.md # Form patterns
|
|
406
|
+
āāā patterns/
|
|
407
|
+
āāā layouts.md # Layout patterns
|
|
408
|
+
āāā data-tables.md # Table patterns
|
|
284
409
|
```
|
|
285
410
|
|
|
286
|
-
###
|
|
411
|
+
### Single-File Documentation
|
|
287
412
|
|
|
288
|
-
|
|
413
|
+
For simpler setups, use `story-ui-considerations.md`:
|
|
289
414
|
|
|
290
|
-
```
|
|
291
|
-
#
|
|
292
|
-
cd mcp-server
|
|
293
|
-
railway up
|
|
415
|
+
```markdown
|
|
416
|
+
# Design System Considerations
|
|
294
417
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
418
|
+
## Color Usage
|
|
419
|
+
- Primary actions: blue.6
|
|
420
|
+
- Destructive actions: red.6
|
|
421
|
+
- Success states: green.6
|
|
422
|
+
|
|
423
|
+
## Component Preferences
|
|
424
|
+
- Use Button with variant="filled" for primary actions
|
|
425
|
+
- Use Card with shadow="sm" for content containers
|
|
299
426
|
```
|
|
300
427
|
|
|
301
|
-
|
|
428
|
+
---
|
|
302
429
|
|
|
303
|
-
|
|
430
|
+
## CLI Reference
|
|
304
431
|
|
|
305
432
|
```bash
|
|
306
|
-
#
|
|
307
|
-
|
|
308
|
-
wrangler deploy
|
|
433
|
+
# Initialize Story UI
|
|
434
|
+
npx story-ui init
|
|
309
435
|
|
|
310
|
-
#
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
436
|
+
# Start the development server
|
|
437
|
+
npx story-ui start
|
|
438
|
+
npx story-ui start --port 4005
|
|
439
|
+
|
|
440
|
+
# Deploy to production
|
|
441
|
+
npx story-ui deploy
|
|
442
|
+
|
|
443
|
+
# Run MCP server
|
|
444
|
+
npx story-ui mcp
|
|
314
445
|
```
|
|
315
446
|
|
|
316
|
-
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## API Reference
|
|
317
450
|
|
|
318
|
-
|
|
451
|
+
### REST Endpoints
|
|
319
452
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
453
|
+
| Method | Endpoint | Description |
|
|
454
|
+
|--------|----------|-------------|
|
|
455
|
+
| `GET` | `/story-ui/providers` | List available LLM providers and models |
|
|
456
|
+
| `POST` | `/story-ui/claude` | Generate with Claude |
|
|
457
|
+
| `POST` | `/story-ui/openai` | Generate with OpenAI |
|
|
458
|
+
| `POST` | `/story-ui/gemini` | Generate with Gemini |
|
|
459
|
+
| `GET` | `/story-ui/considerations` | Get design system context |
|
|
460
|
+
|
|
461
|
+
### Request Format
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
{
|
|
465
|
+
prompt: string; // User's request
|
|
466
|
+
model?: string; // Specific model to use
|
|
467
|
+
previousCode?: string; // For iterations
|
|
468
|
+
history?: Message[]; // Conversation history
|
|
469
|
+
imageData?: string; // Base64 image for vision
|
|
470
|
+
}
|
|
324
471
|
```
|
|
325
472
|
|
|
326
|
-
|
|
473
|
+
---
|
|
327
474
|
|
|
328
|
-
|
|
329
|
-
|----------|----------|-------------|
|
|
330
|
-
| `ANTHROPIC_API_KEY` | Yes | Claude API key from Anthropic |
|
|
331
|
-
| `OPENAI_API_KEY` | No | OpenAI API key for GPT models |
|
|
332
|
-
| `GEMINI_API_KEY` | No | Google Gemini API key |
|
|
333
|
-
| `DEFAULT_MODEL` | No | Default LLM model to use |
|
|
475
|
+
## Upgrading from v2
|
|
334
476
|
|
|
335
|
-
|
|
477
|
+
Story UI v3 is backwards compatible with v2 configurations. However, to take advantage of new features:
|
|
336
478
|
|
|
337
|
-
|
|
479
|
+
1. **Multi-Provider Support**: Add `llmProvider` to your config
|
|
480
|
+
2. **Framework Detection**: Add `framework` to your config for non-React projects
|
|
481
|
+
3. **Production Deployment**: Use `npx story-ui deploy` for one-command deployment
|
|
338
482
|
|
|
339
|
-
|
|
340
|
-
|--------|----------|-------------|
|
|
341
|
-
| `GET` | `/story-ui/providers` | List available LLM providers |
|
|
342
|
-
| `POST` | `/story-ui/generate` | Generate a new story |
|
|
343
|
-
| `GET` | `/story-ui/stories` | List all stories |
|
|
344
|
-
| `GET` | `/story-ui/stories/:id` | Get a specific story |
|
|
345
|
-
| `DELETE` | `/story-ui/stories/:id` | Delete a story |
|
|
483
|
+
No breaking changes - existing stories and configurations will continue to work.
|
|
346
484
|
|
|
347
|
-
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## Contributing
|
|
348
488
|
|
|
349
|
-
We welcome contributions!
|
|
489
|
+
We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md).
|
|
350
490
|
|
|
351
491
|
### Development Setup
|
|
352
492
|
|
|
353
493
|
```bash
|
|
354
|
-
# Clone and install
|
|
355
494
|
git clone https://github.com/southleft/story-ui.git
|
|
356
495
|
cd story-ui
|
|
357
496
|
npm install
|
|
358
|
-
|
|
359
|
-
# Build and link for development
|
|
360
497
|
npm run build
|
|
361
498
|
npm link
|
|
362
499
|
|
|
@@ -365,17 +502,22 @@ cd your-project
|
|
|
365
502
|
npm link @tpitre/story-ui
|
|
366
503
|
```
|
|
367
504
|
|
|
368
|
-
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## License
|
|
369
508
|
|
|
370
509
|
MIT Ā© [Story UI Contributors](LICENSE)
|
|
371
510
|
|
|
372
|
-
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Links
|
|
373
514
|
|
|
374
515
|
- [GitHub Repository](https://github.com/southleft/story-ui)
|
|
375
516
|
- [NPM Package](https://www.npmjs.com/package/@tpitre/story-ui)
|
|
376
517
|
- [Issues & Support](https://github.com/southleft/story-ui/issues)
|
|
518
|
+
- [MCP Integration Guide](docs/MCP_INTEGRATION.md)
|
|
519
|
+
- [Deployment Guide](DEPLOYMENT.md)
|
|
377
520
|
|
|
378
521
|
---
|
|
379
522
|
|
|
380
|
-
*Story UI - Making component documentation delightful, one conversation at a time.*
|
|
381
|
-
|
|
523
|
+
*Story UI - Making component documentation delightful, one conversation at a time.*
|
package/dist/cli/setup.d.ts
CHANGED
package/dist/cli/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../cli/setup.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,iCAAiC,SA8ChD;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../cli/setup.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,iCAAiC,SA8ChD;AAiYD,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC7C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,YAAY,CAAC,OAAO,GAAE,YAAiB,iBAqxB5D"}
|
package/dist/cli/setup.js
CHANGED
|
@@ -189,6 +189,30 @@ export default preview;
|
|
|
189
189
|
fs.writeFileSync(previewTsxPath, previewContent);
|
|
190
190
|
console.log(chalk.green(`ā
Created .storybook/preview.tsx with ${designSystem} provider setup`));
|
|
191
191
|
}
|
|
192
|
+
// LLM Provider configurations
|
|
193
|
+
const LLM_PROVIDERS = {
|
|
194
|
+
claude: {
|
|
195
|
+
name: 'Claude (Anthropic)',
|
|
196
|
+
envKey: 'ANTHROPIC_API_KEY',
|
|
197
|
+
models: ['claude-sonnet-4-20250514', 'claude-3-5-sonnet-20241022', 'claude-3-haiku-20240307'],
|
|
198
|
+
docsUrl: 'https://console.anthropic.com/',
|
|
199
|
+
description: 'Recommended - Best for complex reasoning and code quality'
|
|
200
|
+
},
|
|
201
|
+
openai: {
|
|
202
|
+
name: 'OpenAI (GPT-4)',
|
|
203
|
+
envKey: 'OPENAI_API_KEY',
|
|
204
|
+
models: ['gpt-4o', 'gpt-4-turbo', 'gpt-3.5-turbo'],
|
|
205
|
+
docsUrl: 'https://platform.openai.com/api-keys',
|
|
206
|
+
description: 'Versatile and fast'
|
|
207
|
+
},
|
|
208
|
+
gemini: {
|
|
209
|
+
name: 'Google Gemini',
|
|
210
|
+
envKey: 'GEMINI_API_KEY',
|
|
211
|
+
models: ['gemini-2.0-flash', 'gemini-1.5-pro', 'gemini-1.5-flash'],
|
|
212
|
+
docsUrl: 'https://aistudio.google.com/app/apikey',
|
|
213
|
+
description: 'Cost-effective with good performance'
|
|
214
|
+
}
|
|
215
|
+
};
|
|
192
216
|
// Design system installation configurations (organized by framework)
|
|
193
217
|
const DESIGN_SYSTEM_CONFIGS = {
|
|
194
218
|
// React design systems
|
|
@@ -544,14 +568,17 @@ export async function setupCommand(options = {}) {
|
|
|
544
568
|
console.log(chalk.yellow(`Valid options: ${validSystems.join(', ')}`));
|
|
545
569
|
process.exit(1);
|
|
546
570
|
}
|
|
571
|
+
const llmProvider = options.llmProvider || 'claude';
|
|
547
572
|
answers = {
|
|
548
573
|
designSystem,
|
|
549
574
|
installDesignSystem: !options.skipInstall && Object.keys(DESIGN_SYSTEM_CONFIGS).includes(designSystem),
|
|
550
575
|
generatedStoriesPath: './src/stories/generated/',
|
|
576
|
+
llmProvider,
|
|
551
577
|
mcpPort,
|
|
552
578
|
hasApiKey: false,
|
|
553
579
|
};
|
|
554
580
|
console.log(chalk.blue(`š¦ Design system: ${designSystem}`));
|
|
581
|
+
console.log(chalk.blue(`š¤ AI Provider: ${LLM_PROVIDERS[llmProvider]?.name || llmProvider}`));
|
|
555
582
|
console.log(chalk.blue(`š Generated stories: ${answers.generatedStoriesPath}`));
|
|
556
583
|
console.log(chalk.blue(`š MCP port: ${mcpPort}`));
|
|
557
584
|
if (options.skipInstall) {
|
|
@@ -623,16 +650,33 @@ export async function setupCommand(options = {}) {
|
|
|
623
650
|
return available ? true : `Port ${value} is already in use`;
|
|
624
651
|
}
|
|
625
652
|
},
|
|
653
|
+
{
|
|
654
|
+
type: 'list',
|
|
655
|
+
name: 'llmProvider',
|
|
656
|
+
message: 'Which AI provider would you like to use?',
|
|
657
|
+
choices: [
|
|
658
|
+
{ name: `${chalk.green('Claude (Anthropic)')} - ${chalk.gray('Recommended for complex reasoning and code quality')}`, value: 'claude' },
|
|
659
|
+
{ name: `${chalk.blue('OpenAI (GPT-4)')} - ${chalk.gray('Versatile and fast')}`, value: 'openai' },
|
|
660
|
+
{ name: `${chalk.yellow('Google Gemini')} - ${chalk.gray('Cost-effective with good performance')}`, value: 'gemini' }
|
|
661
|
+
],
|
|
662
|
+
default: 'claude'
|
|
663
|
+
},
|
|
626
664
|
{
|
|
627
665
|
type: 'confirm',
|
|
628
666
|
name: 'hasApiKey',
|
|
629
|
-
message:
|
|
667
|
+
message: (promptAnswers) => {
|
|
668
|
+
const provider = LLM_PROVIDERS[promptAnswers.llmProvider];
|
|
669
|
+
return `Do you have a ${provider?.name || 'provider'} API key? (You can add it later)`;
|
|
670
|
+
},
|
|
630
671
|
default: false
|
|
631
672
|
},
|
|
632
673
|
{
|
|
633
674
|
type: 'password',
|
|
634
675
|
name: 'apiKey',
|
|
635
|
-
message:
|
|
676
|
+
message: (promptAnswers) => {
|
|
677
|
+
const provider = LLM_PROVIDERS[promptAnswers.llmProvider];
|
|
678
|
+
return `Enter your ${provider?.name || 'provider'} API key:`;
|
|
679
|
+
},
|
|
636
680
|
when: (promptAnswers) => promptAnswers.hasApiKey,
|
|
637
681
|
validate: (input) => input.trim() ? true : 'API key is required'
|
|
638
682
|
}
|
|
@@ -906,6 +950,7 @@ Material UI (MUI) is a React component library implementing Material Design.
|
|
|
906
950
|
config.defaultAuthor = 'Story UI AI';
|
|
907
951
|
config.componentFramework = componentFramework; // react, angular, vue, svelte, or web-components
|
|
908
952
|
config.storybookFramework = storybookFramework; // e.g., @storybook/react-vite, @storybook/angular
|
|
953
|
+
config.llmProvider = answers.llmProvider || 'claude'; // claude, openai, or gemini
|
|
909
954
|
// Create configuration file
|
|
910
955
|
const configContent = `module.exports = ${JSON.stringify(config, null, 2)};`;
|
|
911
956
|
const configPath = path.join(process.cwd(), 'story-ui.config.js');
|
|
@@ -972,23 +1017,32 @@ Material UI (MUI) is a React component library implementing Material Design.
|
|
|
972
1017
|
console.log(chalk.green('ā
Created story-ui-docs/ directory structure'));
|
|
973
1018
|
console.log(chalk.gray(' Add your design system documentation to enhance AI story generation'));
|
|
974
1019
|
}
|
|
975
|
-
// Create .env file
|
|
976
|
-
const envSamplePath = path.resolve(__dirname, '../../.env.sample');
|
|
1020
|
+
// Create .env file with provider-specific configuration
|
|
977
1021
|
const envPath = path.join(process.cwd(), '.env');
|
|
1022
|
+
const selectedProvider = answers.llmProvider || 'claude';
|
|
1023
|
+
const providerConfig = LLM_PROVIDERS[selectedProvider];
|
|
978
1024
|
if (!fs.existsSync(envPath)) {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1025
|
+
// Generate .env content based on selected provider
|
|
1026
|
+
let envContent = `# Story UI Configuration
|
|
1027
|
+
# Generated by: npx story-ui init
|
|
1028
|
+
|
|
1029
|
+
# LLM Provider: ${providerConfig?.name || selectedProvider}
|
|
1030
|
+
LLM_PROVIDER=${selectedProvider}
|
|
1031
|
+
|
|
1032
|
+
# API Key for ${providerConfig?.name || selectedProvider}
|
|
1033
|
+
# Get your key from: ${providerConfig?.docsUrl || 'your provider dashboard'}
|
|
1034
|
+
${providerConfig?.envKey || 'API_KEY'}=${answers.apiKey || 'your-api-key-here'}
|
|
1035
|
+
|
|
1036
|
+
# Story UI MCP Server Port
|
|
1037
|
+
VITE_STORY_UI_PORT=${answers.mcpPort || '4001'}
|
|
1038
|
+
|
|
1039
|
+
# Optional: Add additional provider keys if you want to switch providers later
|
|
1040
|
+
# ANTHROPIC_API_KEY=your-anthropic-key
|
|
1041
|
+
# OPENAI_API_KEY=your-openai-key
|
|
1042
|
+
# GEMINI_API_KEY=your-gemini-key
|
|
1043
|
+
`;
|
|
1044
|
+
fs.writeFileSync(envPath, envContent);
|
|
1045
|
+
console.log(chalk.green(`ā
Created .env file for ${providerConfig?.name || selectedProvider}${answers.apiKey ? ' with your API key' : ''}`));
|
|
992
1046
|
}
|
|
993
1047
|
else {
|
|
994
1048
|
console.log(chalk.yellow('ā ļø .env file already exists, skipping'));
|
|
@@ -1077,11 +1131,13 @@ Material UI (MUI) is a React component library implementing Material Design.
|
|
|
1077
1131
|
console.log(`š¦ Import path: ${chalk.cyan(config.importPath)}`);
|
|
1078
1132
|
}
|
|
1079
1133
|
if (!answers.apiKey) {
|
|
1080
|
-
|
|
1081
|
-
console.log('
|
|
1134
|
+
const provider = LLM_PROVIDERS[answers.llmProvider] || LLM_PROVIDERS.claude;
|
|
1135
|
+
console.log(chalk.yellow(`\nā ļø Don't forget to add your ${provider.name} API key to .env file!`));
|
|
1136
|
+
console.log(` Get your key from: ${provider.docsUrl}`);
|
|
1082
1137
|
}
|
|
1138
|
+
const providerName = LLM_PROVIDERS[answers.llmProvider]?.name || 'your LLM provider';
|
|
1083
1139
|
console.log('\nš Next steps:');
|
|
1084
|
-
console.log('1. ' + (answers.apiKey ? 'Start' :
|
|
1140
|
+
console.log('1. ' + (answers.apiKey ? 'Start' : `Add your ${providerName} API key to .env, then start`) + ' Story UI: npm run story-ui');
|
|
1085
1141
|
console.log('2. Start Storybook: npm run storybook');
|
|
1086
1142
|
console.log('3. Navigate to "Story UI > Story Generator" in your Storybook sidebar');
|
|
1087
1143
|
console.log('4. Start generating UI with natural language prompts!');
|