@tpitre/story-ui 2.2.0 → 2.3.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 (188) hide show
  1. package/.env.sample +82 -11
  2. package/README.md +89 -0
  3. package/dist/cli/deploy.d.ts +17 -0
  4. package/dist/cli/deploy.d.ts.map +1 -0
  5. package/dist/cli/deploy.js +696 -0
  6. package/dist/cli/index.d.ts +3 -0
  7. package/dist/cli/index.d.ts.map +1 -0
  8. package/dist/cli/index.js +26 -2
  9. package/dist/cli/setup.d.ts +11 -0
  10. package/dist/cli/setup.d.ts.map +1 -0
  11. package/dist/cli/setup.js +437 -110
  12. package/dist/mcp-server/index.d.ts +2 -0
  13. package/dist/mcp-server/index.d.ts.map +1 -0
  14. package/dist/mcp-server/index.js +120 -2
  15. package/dist/mcp-server/mcp-stdio-server.d.ts +3 -0
  16. package/dist/mcp-server/mcp-stdio-server.d.ts.map +1 -0
  17. package/dist/mcp-server/mcp-stdio-server.js +8 -1
  18. package/dist/mcp-server/routes/claude.d.ts +3 -0
  19. package/dist/mcp-server/routes/claude.d.ts.map +1 -0
  20. package/dist/mcp-server/routes/claude.js +60 -23
  21. package/dist/mcp-server/routes/components.d.ts +4 -0
  22. package/dist/mcp-server/routes/components.d.ts.map +1 -0
  23. package/dist/mcp-server/routes/frameworks.d.ts +38 -0
  24. package/dist/mcp-server/routes/frameworks.d.ts.map +1 -0
  25. package/dist/mcp-server/routes/frameworks.js +183 -0
  26. package/dist/mcp-server/routes/generateStory.d.ts +3 -0
  27. package/dist/mcp-server/routes/generateStory.d.ts.map +1 -0
  28. package/dist/mcp-server/routes/generateStory.js +160 -76
  29. package/dist/mcp-server/routes/generateStoryStream.d.ts +12 -0
  30. package/dist/mcp-server/routes/generateStoryStream.d.ts.map +1 -0
  31. package/dist/mcp-server/routes/generateStoryStream.js +947 -0
  32. package/dist/mcp-server/routes/hybridStories.d.ts +18 -0
  33. package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -0
  34. package/dist/mcp-server/routes/mcpRemote.d.ts +14 -0
  35. package/dist/mcp-server/routes/mcpRemote.d.ts.map +1 -0
  36. package/dist/mcp-server/routes/mcpRemote.js +489 -0
  37. package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
  38. package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
  39. package/dist/mcp-server/routes/providers.d.ts +89 -0
  40. package/dist/mcp-server/routes/providers.d.ts.map +1 -0
  41. package/dist/mcp-server/routes/providers.js +369 -0
  42. package/dist/mcp-server/routes/storySync.d.ts +26 -0
  43. package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
  44. package/dist/mcp-server/routes/streamTypes.d.ts +110 -0
  45. package/dist/mcp-server/routes/streamTypes.d.ts.map +1 -0
  46. package/dist/mcp-server/routes/streamTypes.js +18 -0
  47. package/dist/mcp-server/sessionManager.d.ts +50 -0
  48. package/dist/mcp-server/sessionManager.d.ts.map +1 -0
  49. package/dist/story-generator/componentBlacklist.d.ts +21 -0
  50. package/dist/story-generator/componentBlacklist.d.ts.map +1 -0
  51. package/dist/story-generator/componentDiscovery.d.ts +28 -0
  52. package/dist/story-generator/componentDiscovery.d.ts.map +1 -0
  53. package/dist/story-generator/componentRegistryGenerator.d.ts +49 -0
  54. package/dist/story-generator/componentRegistryGenerator.d.ts.map +1 -0
  55. package/dist/story-generator/componentRegistryGenerator.js +205 -0
  56. package/dist/story-generator/configLoader.d.ts +33 -0
  57. package/dist/story-generator/configLoader.d.ts.map +1 -0
  58. package/dist/story-generator/considerationsLoader.d.ts +32 -0
  59. package/dist/story-generator/considerationsLoader.d.ts.map +1 -0
  60. package/dist/story-generator/documentation-sources.d.ts +28 -0
  61. package/dist/story-generator/documentation-sources.d.ts.map +1 -0
  62. package/dist/story-generator/documentationLoader.d.ts +64 -0
  63. package/dist/story-generator/documentationLoader.d.ts.map +1 -0
  64. package/dist/story-generator/dynamicPackageDiscovery.d.ts +97 -0
  65. package/dist/story-generator/dynamicPackageDiscovery.d.ts.map +1 -0
  66. package/dist/story-generator/enhancedComponentDiscovery.d.ts +125 -0
  67. package/dist/story-generator/enhancedComponentDiscovery.d.ts.map +1 -0
  68. package/dist/story-generator/enhancedComponentDiscovery.js +111 -11
  69. package/dist/story-generator/framework-adapters/angular-adapter.d.ts +40 -0
  70. package/dist/story-generator/framework-adapters/angular-adapter.d.ts.map +1 -0
  71. package/dist/story-generator/framework-adapters/angular-adapter.js +427 -0
  72. package/dist/story-generator/framework-adapters/base-adapter.d.ts +75 -0
  73. package/dist/story-generator/framework-adapters/base-adapter.d.ts.map +1 -0
  74. package/dist/story-generator/framework-adapters/base-adapter.js +147 -0
  75. package/dist/story-generator/framework-adapters/framework-detector.d.ts +55 -0
  76. package/dist/story-generator/framework-adapters/framework-detector.d.ts.map +1 -0
  77. package/dist/story-generator/framework-adapters/framework-detector.js +323 -0
  78. package/dist/story-generator/framework-adapters/index.d.ts +97 -0
  79. package/dist/story-generator/framework-adapters/index.d.ts.map +1 -0
  80. package/dist/story-generator/framework-adapters/index.js +198 -0
  81. package/dist/story-generator/framework-adapters/react-adapter.d.ts +40 -0
  82. package/dist/story-generator/framework-adapters/react-adapter.d.ts.map +1 -0
  83. package/dist/story-generator/framework-adapters/react-adapter.js +316 -0
  84. package/dist/story-generator/framework-adapters/svelte-adapter.d.ts +40 -0
  85. package/dist/story-generator/framework-adapters/svelte-adapter.d.ts.map +1 -0
  86. package/dist/story-generator/framework-adapters/svelte-adapter.js +372 -0
  87. package/dist/story-generator/framework-adapters/types.d.ts +182 -0
  88. package/dist/story-generator/framework-adapters/types.d.ts.map +1 -0
  89. package/dist/story-generator/framework-adapters/types.js +8 -0
  90. package/dist/story-generator/framework-adapters/vue-adapter.d.ts +36 -0
  91. package/dist/story-generator/framework-adapters/vue-adapter.d.ts.map +1 -0
  92. package/dist/story-generator/framework-adapters/vue-adapter.js +336 -0
  93. package/dist/story-generator/framework-adapters/web-components-adapter.d.ts +54 -0
  94. package/dist/story-generator/framework-adapters/web-components-adapter.d.ts.map +1 -0
  95. package/dist/story-generator/framework-adapters/web-components-adapter.js +387 -0
  96. package/dist/story-generator/generateStory.d.ts +7 -0
  97. package/dist/story-generator/generateStory.d.ts.map +1 -0
  98. package/dist/story-generator/gitignoreManager.d.ts +50 -0
  99. package/dist/story-generator/gitignoreManager.d.ts.map +1 -0
  100. package/dist/story-generator/imageProcessor.d.ts +80 -0
  101. package/dist/story-generator/imageProcessor.d.ts.map +1 -0
  102. package/dist/story-generator/imageProcessor.js +391 -0
  103. package/dist/story-generator/inMemoryStoryService.d.ts +89 -0
  104. package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
  105. package/dist/story-generator/llm-providers/base-provider.d.ts +36 -0
  106. package/dist/story-generator/llm-providers/base-provider.d.ts.map +1 -0
  107. package/dist/story-generator/llm-providers/base-provider.js +135 -0
  108. package/dist/story-generator/llm-providers/claude-provider.d.ts +23 -0
  109. package/dist/story-generator/llm-providers/claude-provider.d.ts.map +1 -0
  110. package/dist/story-generator/llm-providers/claude-provider.js +414 -0
  111. package/dist/story-generator/llm-providers/gemini-provider.d.ts +24 -0
  112. package/dist/story-generator/llm-providers/gemini-provider.d.ts.map +1 -0
  113. package/dist/story-generator/llm-providers/gemini-provider.js +406 -0
  114. package/dist/story-generator/llm-providers/index.d.ts +63 -0
  115. package/dist/story-generator/llm-providers/index.d.ts.map +1 -0
  116. package/dist/story-generator/llm-providers/index.js +169 -0
  117. package/dist/story-generator/llm-providers/openai-provider.d.ts +24 -0
  118. package/dist/story-generator/llm-providers/openai-provider.d.ts.map +1 -0
  119. package/dist/story-generator/llm-providers/openai-provider.js +458 -0
  120. package/dist/story-generator/llm-providers/settings-manager.d.ts +75 -0
  121. package/dist/story-generator/llm-providers/settings-manager.d.ts.map +1 -0
  122. package/dist/story-generator/llm-providers/settings-manager.js +173 -0
  123. package/dist/story-generator/llm-providers/story-llm-service.d.ts +79 -0
  124. package/dist/story-generator/llm-providers/story-llm-service.d.ts.map +1 -0
  125. package/dist/story-generator/llm-providers/story-llm-service.js +240 -0
  126. package/dist/story-generator/llm-providers/types.d.ts +153 -0
  127. package/dist/story-generator/llm-providers/types.d.ts.map +1 -0
  128. package/dist/story-generator/llm-providers/types.js +8 -0
  129. package/dist/story-generator/logger.d.ts +14 -0
  130. package/dist/story-generator/logger.d.ts.map +1 -0
  131. package/dist/story-generator/logger.js +96 -29
  132. package/dist/story-generator/postProcessStory.d.ts +6 -0
  133. package/dist/story-generator/postProcessStory.d.ts.map +1 -0
  134. package/dist/story-generator/productionGitignoreManager.d.ts +91 -0
  135. package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
  136. package/dist/story-generator/promptGenerator.d.ts +48 -0
  137. package/dist/story-generator/promptGenerator.d.ts.map +1 -0
  138. package/dist/story-generator/promptGenerator.js +186 -1
  139. package/dist/story-generator/storyHistory.d.ts +44 -0
  140. package/dist/story-generator/storyHistory.d.ts.map +1 -0
  141. package/dist/story-generator/storySync.d.ts +68 -0
  142. package/dist/story-generator/storySync.d.ts.map +1 -0
  143. package/dist/story-generator/storyTracker.d.ts +48 -0
  144. package/dist/story-generator/storyTracker.d.ts.map +1 -0
  145. package/dist/story-generator/storyValidator.d.ts +6 -0
  146. package/dist/story-generator/storyValidator.d.ts.map +1 -0
  147. package/dist/story-generator/universalDesignSystemAdapter.d.ts +68 -0
  148. package/dist/story-generator/universalDesignSystemAdapter.d.ts.map +1 -0
  149. package/dist/story-generator/universalDesignSystemAdapter.js +138 -1
  150. package/dist/story-generator/urlRedirectService.d.ts +21 -0
  151. package/dist/story-generator/urlRedirectService.d.ts.map +1 -0
  152. package/dist/story-generator/validateStory.d.ts +19 -0
  153. package/dist/story-generator/validateStory.d.ts.map +1 -0
  154. package/dist/story-generator/validateStory.js +6 -2
  155. package/dist/story-generator/visionPrompts.d.ts +88 -0
  156. package/dist/story-generator/visionPrompts.d.ts.map +1 -0
  157. package/dist/story-generator/visionPrompts.js +462 -0
  158. package/dist/story-ui.config.d.ts +78 -0
  159. package/dist/story-ui.config.d.ts.map +1 -0
  160. package/dist/templates/StoryUI/StoryUIPanel.d.ts +4 -0
  161. package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -0
  162. package/dist/templates/StoryUI/StoryUIPanel.js +1874 -0
  163. package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts +18 -0
  164. package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts.map +1 -0
  165. package/dist/templates/StoryUI/StoryUIPanel.stories.js +37 -0
  166. package/dist/templates/StoryUI/index.d.ts +3 -0
  167. package/dist/templates/StoryUI/index.d.ts.map +1 -0
  168. package/dist/templates/StoryUI/index.js +2 -0
  169. package/package.json +17 -3
  170. package/templates/StoryUI/StoryUIPanel.tsx +1960 -384
  171. package/templates/StoryUI/index.tsx +1 -1
  172. package/templates/StoryUI/manager.tsx +264 -0
  173. package/templates/production-app/.env.example +11 -0
  174. package/templates/production-app/index.html +66 -0
  175. package/templates/production-app/package.json +30 -0
  176. package/templates/production-app/public/favicon.svg +5 -0
  177. package/templates/production-app/src/App.tsx +1560 -0
  178. package/templates/production-app/src/LivePreviewRenderer.tsx +420 -0
  179. package/templates/production-app/src/componentRegistry.ts +315 -0
  180. package/templates/production-app/src/considerations.ts +16 -0
  181. package/templates/production-app/src/index.css +284 -0
  182. package/templates/production-app/src/main.tsx +25 -0
  183. package/templates/production-app/tsconfig.json +32 -0
  184. package/templates/production-app/tsconfig.node.json +11 -0
  185. package/templates/production-app/vite.config.ts +83 -0
  186. package/templates/react-import-rule.json +2 -2
  187. package/dist/index.js +0 -12
  188. package/dist/story-ui.config.loader.js +0 -205
package/dist/cli/setup.js CHANGED
@@ -144,6 +144,18 @@ function setupStorybookPreview(designSystem) {
144
144
  <MantineProvider>
145
145
  <Story />
146
146
  </MantineProvider>
147
+ )`
148
+ },
149
+ shadcn: {
150
+ imports: [
151
+ "import type { Preview } from '@storybook/react-vite'",
152
+ "import '../src/index.css'", // or globals.css for Tailwind styles
153
+ "import React from 'react'"
154
+ ],
155
+ decorator: `(Story) => (
156
+ <div className="min-h-screen bg-background text-foreground">
157
+ <Story />
158
+ </div>
147
159
  )`
148
160
  }
149
161
  };
@@ -177,25 +189,121 @@ export default preview;
177
189
  fs.writeFileSync(previewTsxPath, previewContent);
178
190
  console.log(chalk.green(`✅ Created .storybook/preview.tsx with ${designSystem} provider setup`));
179
191
  }
180
- // Design system installation configurations
192
+ // Design system installation configurations (organized by framework)
181
193
  const DESIGN_SYSTEM_CONFIGS = {
194
+ // React design systems
182
195
  antd: {
183
196
  packages: ['antd'],
184
197
  name: 'Ant Design',
185
198
  importPath: 'antd',
186
- additionalSetup: 'import "antd/dist/reset.css";'
199
+ additionalSetup: 'import "antd/dist/reset.css";',
200
+ framework: 'react'
187
201
  },
188
202
  mantine: {
189
203
  packages: ['@mantine/core', '@mantine/hooks', '@mantine/notifications'],
190
204
  name: 'Mantine',
191
205
  importPath: '@mantine/core',
192
- additionalSetup: 'import "@mantine/core/styles.css";'
206
+ additionalSetup: 'import "@mantine/core/styles.css";',
207
+ framework: 'react'
193
208
  },
194
209
  chakra: {
195
210
  packages: ['@chakra-ui/react', '@emotion/react', '@emotion/styled', 'framer-motion'],
196
211
  name: 'Chakra UI',
197
212
  importPath: '@chakra-ui/react',
198
- additionalSetup: 'import { ChakraProvider } from "@chakra-ui/react";'
213
+ additionalSetup: 'import { ChakraProvider } from "@chakra-ui/react";',
214
+ framework: 'react'
215
+ },
216
+ mui: {
217
+ packages: ['@mui/material', '@emotion/react', '@emotion/styled'],
218
+ name: 'Material UI',
219
+ importPath: '@mui/material',
220
+ additionalSetup: 'import { ThemeProvider } from "@mui/material/styles";',
221
+ framework: 'react'
222
+ },
223
+ shadcn: {
224
+ packages: ['class-variance-authority', 'clsx', 'tailwind-merge', '@radix-ui/react-slot', 'lucide-react'],
225
+ name: 'shadcn/ui',
226
+ importPath: '@/components/ui',
227
+ additionalSetup: '// shadcn/ui components are locally installed. Run: npx shadcn@latest init',
228
+ framework: 'react'
229
+ },
230
+ // Angular design systems
231
+ 'angular-material': {
232
+ packages: ['@angular/material', '@angular/cdk'],
233
+ name: 'Angular Material',
234
+ importPath: '@angular/material',
235
+ additionalSetup: 'import { MatModule } from "@angular/material";',
236
+ framework: 'angular'
237
+ },
238
+ primeng: {
239
+ packages: ['primeng', 'primeicons'],
240
+ name: 'PrimeNG',
241
+ importPath: 'primeng',
242
+ additionalSetup: 'import "primeng/resources/themes/lara-light-blue/theme.css";',
243
+ framework: 'angular'
244
+ },
245
+ 'ng-zorro': {
246
+ packages: ['ng-zorro-antd'],
247
+ name: 'NG-ZORRO',
248
+ importPath: 'ng-zorro-antd',
249
+ additionalSetup: 'import "ng-zorro-antd/ng-zorro-antd.min.css";',
250
+ framework: 'angular'
251
+ },
252
+ // Vue design systems
253
+ primevue: {
254
+ packages: ['primevue', 'primeicons'],
255
+ name: 'PrimeVue',
256
+ importPath: 'primevue',
257
+ additionalSetup: 'import "primevue/resources/themes/lara-light-blue/theme.css";',
258
+ framework: 'vue'
259
+ },
260
+ vuetify: {
261
+ packages: ['vuetify'],
262
+ name: 'Vuetify',
263
+ importPath: 'vuetify',
264
+ additionalSetup: 'import "vuetify/styles";',
265
+ framework: 'vue'
266
+ },
267
+ 'element-plus': {
268
+ packages: ['element-plus'],
269
+ name: 'Element Plus',
270
+ importPath: 'element-plus',
271
+ additionalSetup: 'import "element-plus/dist/index.css";',
272
+ framework: 'vue'
273
+ },
274
+ // Svelte design systems
275
+ 'skeleton-ui': {
276
+ packages: ['@skeletonlabs/skeleton'],
277
+ name: 'Skeleton UI',
278
+ importPath: '@skeletonlabs/skeleton',
279
+ framework: 'svelte'
280
+ },
281
+ smui: {
282
+ packages: ['svelte-material-ui'],
283
+ name: 'Svelte Material UI',
284
+ importPath: 'svelte-material-ui',
285
+ framework: 'svelte'
286
+ },
287
+ // Web Components design systems
288
+ shoelace: {
289
+ packages: ['@shoelace-style/shoelace'],
290
+ name: 'Shoelace',
291
+ importPath: '@shoelace-style/shoelace',
292
+ additionalSetup: 'import "@shoelace-style/shoelace/dist/themes/light.css";',
293
+ framework: 'web-components'
294
+ },
295
+ lit: {
296
+ packages: ['lit'],
297
+ name: 'Lit',
298
+ importPath: 'lit',
299
+ framework: 'web-components'
300
+ },
301
+ vaadin: {
302
+ packages: ['@vaadin/vaadin-core'],
303
+ name: 'Vaadin',
304
+ importPath: '@vaadin',
305
+ additionalSetup: 'import "@vaadin/vaadin-lumo-styles/all-imports.js";',
306
+ framework: 'web-components'
199
307
  }
200
308
  };
201
309
  async function installDesignSystem(systemKey) {
@@ -283,41 +391,85 @@ async function installDesignSystem(systemKey) {
283
391
  return false;
284
392
  }
285
393
  }
286
- export async function setupCommand() {
394
+ export async function setupCommand(options = {}) {
287
395
  console.log(chalk.blue.bold('\n🎨 Story UI Setup\n'));
288
- console.log('This will help you configure Story UI for your design system.\n');
396
+ // Non-interactive mode indicator
397
+ if (options.yes || options.designSystem) {
398
+ console.log(chalk.gray('Running in non-interactive mode...\n'));
399
+ }
400
+ else {
401
+ console.log('This will help you configure Story UI for your design system.\n');
402
+ }
289
403
  // Check if we're in a valid project
290
404
  const packageJsonPath = path.join(process.cwd(), 'package.json');
291
405
  if (!fs.existsSync(packageJsonPath)) {
292
406
  console.error(chalk.red('❌ No package.json found. Please run this command in your project root.'));
293
407
  process.exit(1);
294
408
  }
295
- // Check if Storybook is installed
409
+ // Check if Storybook is installed (any framework)
296
410
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
297
- const hasStorybook = packageJson.devDependencies?.['@storybook/react'] ||
298
- packageJson.dependencies?.['@storybook/react'] ||
411
+ const devDeps = packageJson.devDependencies || {};
412
+ const deps = packageJson.dependencies || {};
413
+ // Check for any Storybook framework
414
+ const storybookPackages = [
415
+ '@storybook/react', '@storybook/react-vite', '@storybook/react-webpack5', '@storybook/nextjs',
416
+ '@storybook/angular', '@storybook/vue3', '@storybook/svelte', '@storybook/web-components'
417
+ ];
418
+ const hasStorybook = storybookPackages.some(pkg => devDeps[pkg] || deps[pkg]) ||
299
419
  fs.existsSync(path.join(process.cwd(), '.storybook'));
300
420
  if (!hasStorybook) {
301
421
  console.warn(chalk.yellow('⚠️ Storybook not detected. Story UI works best with Storybook installed.'));
302
422
  console.log('Install Storybook first: npx storybook@latest init\n');
303
423
  }
304
- // Detect Storybook framework (Vite vs Webpack)
424
+ // Detect Storybook framework and component framework type
305
425
  let storybookFramework = '@storybook/react'; // default
306
- const devDeps = packageJson.devDependencies || {};
307
- const deps = packageJson.dependencies || {};
308
- // Check for Vite-based Storybook
426
+ let componentFramework = 'react';
427
+ // Check for React Storybook variants
309
428
  if (devDeps['@storybook/react-vite'] || deps['@storybook/react-vite']) {
310
429
  storybookFramework = '@storybook/react-vite';
311
- console.log(chalk.green('✅ Detected Vite-based Storybook'));
430
+ componentFramework = 'react';
431
+ console.log(chalk.green('✅ Detected Vite-based React Storybook'));
312
432
  }
313
433
  else if (devDeps['@storybook/react-webpack5'] || deps['@storybook/react-webpack5']) {
314
434
  storybookFramework = '@storybook/react-webpack5';
315
- console.log(chalk.green('✅ Detected Webpack 5-based Storybook'));
435
+ componentFramework = 'react';
436
+ console.log(chalk.green('✅ Detected Webpack 5-based React Storybook'));
316
437
  }
317
438
  else if (devDeps['@storybook/nextjs'] || deps['@storybook/nextjs']) {
318
439
  storybookFramework = '@storybook/nextjs';
440
+ componentFramework = 'react';
319
441
  console.log(chalk.green('✅ Detected Next.js Storybook'));
320
442
  }
443
+ // Check for Angular Storybook
444
+ else if (devDeps['@storybook/angular'] || deps['@storybook/angular']) {
445
+ storybookFramework = '@storybook/angular';
446
+ componentFramework = 'angular';
447
+ console.log(chalk.green('✅ Detected Angular Storybook'));
448
+ }
449
+ // Check for Vue Storybook
450
+ else if (devDeps['@storybook/vue3'] || deps['@storybook/vue3']) {
451
+ storybookFramework = '@storybook/vue3';
452
+ componentFramework = 'vue';
453
+ console.log(chalk.green('✅ Detected Vue 3 Storybook'));
454
+ }
455
+ // Check for Svelte Storybook
456
+ else if (devDeps['@storybook/svelte'] || deps['@storybook/svelte']) {
457
+ storybookFramework = '@storybook/svelte';
458
+ componentFramework = 'svelte';
459
+ console.log(chalk.green('✅ Detected Svelte Storybook'));
460
+ }
461
+ // Check for Web Components Storybook
462
+ else if (devDeps['@storybook/web-components'] || deps['@storybook/web-components']) {
463
+ storybookFramework = '@storybook/web-components';
464
+ componentFramework = 'web-components';
465
+ console.log(chalk.green('✅ Detected Web Components Storybook'));
466
+ }
467
+ // Check for generic @storybook/react (old setup)
468
+ else if (devDeps['@storybook/react'] || deps['@storybook/react']) {
469
+ storybookFramework = '@storybook/react';
470
+ componentFramework = 'react';
471
+ console.log(chalk.green('✅ Detected React Storybook'));
472
+ }
321
473
  // Auto-detect design system
322
474
  const autoDetected = autoDetectDesignSystem();
323
475
  if (autoDetected) {
@@ -330,93 +482,164 @@ export async function setupCommand() {
330
482
  console.log(` 📁 Components path: ${autoDetected.componentsPath}`);
331
483
  }
332
484
  }
333
- const answers = await inquirer.prompt([
334
- {
335
- type: 'list',
336
- name: 'designSystem',
337
- message: 'Which design system are you using?',
338
- choices: [
339
- { name: '🤖 Auto-detect from package.json', value: 'auto' },
340
- { name: '🐜 Ant Design (antd) - Automatic Install & Configure', value: 'antd' },
341
- { name: '🎯 Mantine (@mantine/core) - Automatic Install & Configure', value: 'mantine' },
342
- { name: ' Chakra UI (@chakra-ui/react) - Automatic Install & Configure', value: 'chakra' },
343
- { name: '🔧 Custom/Other', value: 'custom' }
344
- ],
345
- default: autoDetected ? 'auto' : 'custom'
346
- },
347
- {
348
- type: 'confirm',
349
- name: 'installDesignSystem',
350
- message: (answers) => {
351
- const systemName = answers.designSystem === 'antd' ? 'Ant Design' :
352
- answers.designSystem === 'mantine' ? 'Mantine' :
353
- answers.designSystem === 'chakra' ? 'Chakra UI' : 'the design system';
354
- const config = DESIGN_SYSTEM_CONFIGS[answers.designSystem];
355
- return `🚨 IMPORTANT: Would you like to install ${systemName} packages now?\n Required packages: ${config.packages.join(', ')}\n (Without these packages, Story UI and Storybook will not work properly)`;
485
+ // Build design system choices based on detected framework
486
+ const getDesignSystemChoices = () => {
487
+ const baseChoice = { name: '🤖 Auto-detect from package.json', value: 'auto' };
488
+ const customChoice = { name: '🔧 Custom/Other', value: 'custom' };
489
+ switch (componentFramework) {
490
+ case 'angular':
491
+ return [
492
+ baseChoice,
493
+ { name: '🅰️ Angular Material (@angular/material)', value: 'angular-material' },
494
+ { name: '🎨 PrimeNG (primeng)', value: 'primeng' },
495
+ { name: '🌈 NG-ZORRO (ng-zorro-antd)', value: 'ng-zorro' },
496
+ customChoice
497
+ ];
498
+ case 'vue':
499
+ return [
500
+ baseChoice,
501
+ { name: '🍃 PrimeVue (primevue)', value: 'primevue' },
502
+ { name: '🎯 Vuetify (vuetify)', value: 'vuetify' },
503
+ { name: '🔮 Element Plus (element-plus)', value: 'element-plus' },
504
+ customChoice
505
+ ];
506
+ case 'svelte':
507
+ return [
508
+ baseChoice,
509
+ { name: '🟠 Skeleton UI (skeleton)', value: 'skeleton-ui' },
510
+ { name: '🌸 Svelte Material UI (svelte-material-ui)', value: 'smui' },
511
+ customChoice
512
+ ];
513
+ case 'web-components':
514
+ return [
515
+ baseChoice,
516
+ { name: '👟 Shoelace (@shoelace-style/shoelace)', value: 'shoelace' },
517
+ { name: '🔥 Lit (@lit/element)', value: 'lit' },
518
+ { name: '🌟 Vaadin (@vaadin)', value: 'vaadin' },
519
+ customChoice
520
+ ];
521
+ case 'react':
522
+ default:
523
+ return [
524
+ baseChoice,
525
+ { name: '🐜 Ant Design (antd) - Automatic Install & Configure', value: 'antd' },
526
+ { name: '🎯 Mantine (@mantine/core) - Automatic Install & Configure', value: 'mantine' },
527
+ { name: '⚡ Chakra UI (@chakra-ui/react) - Automatic Install & Configure', value: 'chakra' },
528
+ { name: '🎨 Material UI (@mui/material)', value: 'mui' },
529
+ { name: '✨ shadcn/ui (Tailwind + Radix) - Automatic Install & Configure', value: 'shadcn' },
530
+ customChoice
531
+ ];
532
+ }
533
+ };
534
+ // Non-interactive mode: build answers from CLI options
535
+ let answers;
536
+ if (options.yes || options.designSystem) {
537
+ // Non-interactive mode
538
+ const designSystem = options.designSystem || (autoDetected ? 'auto' : 'custom');
539
+ const mcpPort = String(await findAvailablePort(4001));
540
+ // Validate design system choice
541
+ const validSystems = ['auto', 'custom', ...Object.keys(DESIGN_SYSTEM_CONFIGS)];
542
+ if (!validSystems.includes(designSystem)) {
543
+ console.error(chalk.red(`❌ Invalid design system: ${designSystem}`));
544
+ console.log(chalk.yellow(`Valid options: ${validSystems.join(', ')}`));
545
+ process.exit(1);
546
+ }
547
+ answers = {
548
+ designSystem,
549
+ installDesignSystem: !options.skipInstall && Object.keys(DESIGN_SYSTEM_CONFIGS).includes(designSystem),
550
+ generatedStoriesPath: './src/stories/generated/',
551
+ mcpPort,
552
+ hasApiKey: false,
553
+ };
554
+ console.log(chalk.blue(`📦 Design system: ${designSystem}`));
555
+ console.log(chalk.blue(`📁 Generated stories: ${answers.generatedStoriesPath}`));
556
+ console.log(chalk.blue(`🔌 MCP port: ${mcpPort}`));
557
+ if (options.skipInstall) {
558
+ console.log(chalk.yellow('⏭️ Skipping package installation'));
559
+ }
560
+ }
561
+ else {
562
+ // Interactive mode - use inquirer prompts
563
+ answers = await inquirer.prompt([
564
+ {
565
+ type: 'list',
566
+ name: 'designSystem',
567
+ message: `Which design system are you using? (${componentFramework} detected)`,
568
+ choices: getDesignSystemChoices(),
569
+ default: autoDetected ? 'auto' : 'custom'
356
570
  },
357
- when: (answers) => ['antd', 'mantine', 'chakra'].includes(answers.designSystem),
358
- default: true
359
- },
360
- {
361
- type: 'input',
362
- name: 'importPath',
363
- message: 'What is the import path for your components?',
364
- when: (answers) => answers.designSystem === 'custom',
365
- validate: (input) => input.trim() ? true : 'Import path is required'
366
- },
367
- {
368
- type: 'input',
369
- name: 'componentPrefix',
370
- message: 'Do your components have a prefix? (e.g., "AL" for ALButton)',
371
- when: (answers) => answers.designSystem === 'custom',
372
- default: ''
373
- },
374
- {
375
- type: 'input',
376
- name: 'generatedStoriesPath',
377
- message: 'Where should generated stories be saved?',
378
- default: './src/stories/generated/',
379
- validate: (input) => input.trim() ? true : 'Path is required'
380
- },
381
- {
382
- type: 'input',
383
- name: 'componentsPath',
384
- message: 'Where are your component files located?',
385
- default: './src/components',
386
- when: (answers) => answers.designSystem === 'custom'
387
- },
388
- {
389
- type: 'input',
390
- name: 'mcpPort',
391
- message: 'Port for the Story UI MCP server',
392
- default: async () => {
393
- const port = await findAvailablePort(4001);
394
- return String(port);
571
+ {
572
+ type: 'confirm',
573
+ name: 'installDesignSystem',
574
+ message: (promptAnswers) => {
575
+ const config = DESIGN_SYSTEM_CONFIGS[promptAnswers.designSystem];
576
+ const systemName = config?.name || 'the design system';
577
+ return `🚨 IMPORTANT: Would you like to install ${systemName} packages now?\n Required packages: ${config?.packages.join(', ') || 'unknown'}\n (Without these packages, Story UI and Storybook will not work properly)`;
578
+ },
579
+ when: (promptAnswers) => Object.keys(DESIGN_SYSTEM_CONFIGS).includes(promptAnswers.designSystem),
580
+ default: true
581
+ },
582
+ {
583
+ type: 'input',
584
+ name: 'importPath',
585
+ message: 'What is the import path for your components?',
586
+ when: (promptAnswers) => promptAnswers.designSystem === 'custom',
587
+ validate: (input) => input.trim() ? true : 'Import path is required'
588
+ },
589
+ {
590
+ type: 'input',
591
+ name: 'componentPrefix',
592
+ message: 'Do your components have a prefix? (e.g., "AL" for ALButton)',
593
+ when: (promptAnswers) => promptAnswers.designSystem === 'custom',
594
+ default: ''
595
+ },
596
+ {
597
+ type: 'input',
598
+ name: 'generatedStoriesPath',
599
+ message: 'Where should generated stories be saved?',
600
+ default: './src/stories/generated/',
601
+ validate: (input) => input.trim() ? true : 'Path is required'
395
602
  },
396
- validate: async (input) => {
397
- const value = parseInt(input, 10);
398
- if (isNaN(value) || value <= 0)
399
- return 'Enter a valid port number';
400
- const available = await isPortAvailable(value);
401
- return available ? true : `Port ${value} is already in use`;
603
+ {
604
+ type: 'input',
605
+ name: 'componentsPath',
606
+ message: 'Where are your component files located?',
607
+ default: './src/components',
608
+ when: (promptAnswers) => promptAnswers.designSystem === 'custom'
609
+ },
610
+ {
611
+ type: 'input',
612
+ name: 'mcpPort',
613
+ message: 'Port for the Story UI MCP server',
614
+ default: async () => {
615
+ const port = await findAvailablePort(4001);
616
+ return String(port);
617
+ },
618
+ validate: async (input) => {
619
+ const value = parseInt(input, 10);
620
+ if (isNaN(value) || value <= 0)
621
+ return 'Enter a valid port number';
622
+ const available = await isPortAvailable(value);
623
+ return available ? true : `Port ${value} is already in use`;
624
+ }
625
+ },
626
+ {
627
+ type: 'confirm',
628
+ name: 'hasApiKey',
629
+ message: 'Do you have a Claude API key? (You can add it later)',
630
+ default: false
631
+ },
632
+ {
633
+ type: 'password',
634
+ name: 'apiKey',
635
+ message: 'Enter your Claude API key:',
636
+ when: (promptAnswers) => promptAnswers.hasApiKey,
637
+ validate: (input) => input.trim() ? true : 'API key is required'
402
638
  }
403
- },
404
- {
405
- type: 'confirm',
406
- name: 'hasApiKey',
407
- message: 'Do you have a Claude API key? (You can add it later)',
408
- default: false
409
- },
410
- {
411
- type: 'password',
412
- name: 'apiKey',
413
- message: 'Enter your Claude API key:',
414
- when: (answers) => answers.hasApiKey,
415
- validate: (input) => input.trim() ? true : 'API key is required'
416
- }
417
- ]);
639
+ ]);
640
+ }
418
641
  // Install design system if requested
419
- if (answers.installDesignSystem && ['antd', 'mantine', 'chakra'].includes(answers.designSystem)) {
642
+ if (answers.installDesignSystem && Object.keys(DESIGN_SYSTEM_CONFIGS).includes(answers.designSystem)) {
420
643
  const installSuccess = await installDesignSystem(answers.designSystem);
421
644
  if (!installSuccess) {
422
645
  console.log(chalk.red('❌ Installation failed! Cannot continue without required dependencies.'));
@@ -434,25 +657,35 @@ export async function setupCommand() {
434
657
  // Set up Storybook preview file after successful installation
435
658
  setupStorybookPreview(answers.designSystem);
436
659
  }
437
- else if (['antd', 'mantine', 'chakra'].includes(answers.designSystem)) {
660
+ else if (Object.keys(DESIGN_SYSTEM_CONFIGS).includes(answers.designSystem)) {
438
661
  // User declined installation - verify dependencies exist
439
662
  const packageJsonPath = path.join(process.cwd(), 'package.json');
440
663
  if (fs.existsSync(packageJsonPath)) {
441
664
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
442
665
  const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
443
- const config = DESIGN_SYSTEM_CONFIGS[answers.designSystem];
444
- const missingDeps = config.packages.filter(pkg => !allDeps[pkg]);
666
+ const dsConfig = DESIGN_SYSTEM_CONFIGS[answers.designSystem];
667
+ const missingDeps = dsConfig.packages.filter(pkg => !allDeps[pkg]);
445
668
  if (missingDeps.length > 0) {
446
- console.log(chalk.red('❌ Required dependencies missing:'), missingDeps.join(', '));
447
- console.log(chalk.yellow('Please install them manually:'));
448
- console.log(chalk.cyan(`npm install ${missingDeps.join(' ')}`));
449
- // Clean up any existing preview.tsx that might cause issues
450
- const previewTsxPath = path.join(process.cwd(), '.storybook', 'preview.tsx');
451
- if (fs.existsSync(previewTsxPath)) {
452
- fs.unlinkSync(previewTsxPath);
453
- console.log(chalk.yellow('⚠️ Removed preview.tsx to prevent import errors'));
669
+ // If --skip-install was explicitly passed, just warn but continue with config generation
670
+ if (options.skipInstall) {
671
+ console.log(chalk.yellow('⚠️ Dependencies not installed (--skip-install used):'), missingDeps.join(', '));
672
+ console.log(chalk.yellow(' Install them later with:'));
673
+ console.log(chalk.cyan(` npm install ${missingDeps.join(' ')}`));
674
+ // Don't set up Storybook preview since deps are missing
675
+ }
676
+ else {
677
+ // Interactive mode: user declined installation
678
+ console.log(chalk.red('❌ Required dependencies missing:'), missingDeps.join(', '));
679
+ console.log(chalk.yellow('Please install them manually:'));
680
+ console.log(chalk.cyan(`npm install ${missingDeps.join(' ')}`));
681
+ // Clean up any existing preview.tsx that might cause issues
682
+ const previewTsxPath = path.join(process.cwd(), '.storybook', 'preview.tsx');
683
+ if (fs.existsSync(previewTsxPath)) {
684
+ fs.unlinkSync(previewTsxPath);
685
+ console.log(chalk.yellow('⚠️ Removed preview.tsx to prevent import errors'));
686
+ }
687
+ process.exit(1);
454
688
  }
455
- process.exit(1);
456
689
  }
457
690
  else {
458
691
  // Dependencies exist, set up Storybook preview
@@ -556,6 +789,98 @@ export async function setupCommand() {
556
789
  }
557
790
  };
558
791
  }
792
+ else if (answers.designSystem === 'shadcn') {
793
+ config = {
794
+ importPath: '@/components/ui',
795
+ componentPrefix: '',
796
+ layoutRules: {
797
+ multiColumnWrapper: 'div',
798
+ columnComponent: 'div',
799
+ containerComponent: 'div',
800
+ layoutExamples: {
801
+ twoColumn: `<div className="grid grid-cols-2 gap-4">
802
+ <Card>
803
+ <CardHeader>
804
+ <CardTitle>Left Card</CardTitle>
805
+ </CardHeader>
806
+ <CardContent>
807
+ <p className="text-sm text-muted-foreground">
808
+ Left content goes here
809
+ </p>
810
+ </CardContent>
811
+ </Card>
812
+ <Card>
813
+ <CardHeader>
814
+ <CardTitle>Right Card</CardTitle>
815
+ </CardHeader>
816
+ <CardContent>
817
+ <p className="text-sm text-muted-foreground">
818
+ Right content goes here
819
+ </p>
820
+ </CardContent>
821
+ </Card>
822
+ </div>`
823
+ }
824
+ },
825
+ designSystemGuidelines: {
826
+ name: 'shadcn/ui',
827
+ additionalNotes: `
828
+ shadcn/ui components are locally installed in the project.
829
+ - Import components from "@/components/ui" (e.g., import { Button } from "@/components/ui/button")
830
+ - Use the cn() utility from "@/lib/utils" for conditional classes
831
+ - Components use Tailwind CSS for styling
832
+ - Use CSS variables for theming (--primary, --secondary, --muted, etc.)
833
+ - Prefer composition over configuration
834
+ `.trim()
835
+ }
836
+ };
837
+ }
838
+ else if (answers.designSystem === 'mui') {
839
+ config = {
840
+ importPath: '@mui/material',
841
+ componentPrefix: '',
842
+ layoutRules: {
843
+ multiColumnWrapper: 'Grid',
844
+ columnComponent: 'Grid',
845
+ containerComponent: 'Container',
846
+ layoutExamples: {
847
+ twoColumn: `<Grid container spacing={2}>
848
+ <Grid item xs={6}>
849
+ <Card>
850
+ <CardContent>
851
+ <Typography variant="h6">Left Card</Typography>
852
+ <Typography variant="body2" color="text.secondary">
853
+ Left content goes here
854
+ </Typography>
855
+ </CardContent>
856
+ </Card>
857
+ </Grid>
858
+ <Grid item xs={6}>
859
+ <Card>
860
+ <CardContent>
861
+ <Typography variant="h6">Right Card</Typography>
862
+ <Typography variant="body2" color="text.secondary">
863
+ Right content goes here
864
+ </Typography>
865
+ </CardContent>
866
+ </Card>
867
+ </Grid>
868
+ </Grid>`
869
+ }
870
+ },
871
+ designSystemGuidelines: {
872
+ name: 'Material UI',
873
+ additionalNotes: `
874
+ Material UI (MUI) is a React component library implementing Material Design.
875
+ - Import components from "@mui/material" (e.g., import { Button } from "@mui/material")
876
+ - Use the sx prop for inline styling with theme awareness
877
+ - Use Grid for layouts, Card for containers
878
+ - Leverage ThemeProvider for consistent theming
879
+ - Typography component for text with proper variants
880
+ `.trim()
881
+ }
882
+ };
883
+ }
559
884
  else {
560
885
  // Custom configuration
561
886
  config = {
@@ -579,6 +904,8 @@ export async function setupCommand() {
579
904
  config.generatedStoriesPath = path.resolve(answers.generatedStoriesPath || './src/stories/generated/');
580
905
  config.storyPrefix = 'Generated/';
581
906
  config.defaultAuthor = 'Story UI AI';
907
+ config.componentFramework = componentFramework; // react, angular, vue, svelte, or web-components
908
+ config.storybookFramework = storybookFramework; // e.g., @storybook/react-vite, @storybook/angular
582
909
  // Create configuration file
583
910
  const configContent = `module.exports = ${JSON.stringify(config, null, 2)};`;
584
911
  const configPath = path.join(process.cwd(), 'story-ui.config.js');
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../mcp-server/index.ts"],"names":[],"mappings":""}