@tpitre/story-ui 3.3.0 → 3.4.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.
Files changed (281) hide show
  1. package/dist/cli/index.js +0 -0
  2. package/dist/cli/index.js.map +1 -0
  3. package/dist/cli/setup.js.map +1 -0
  4. package/dist/cloudflare-edge/src/mcp-session.js +462 -0
  5. package/dist/cloudflare-edge/src/types.js +4 -0
  6. package/dist/cloudflare-edge/src/worker.js +106 -0
  7. package/dist/cloudflare-pages/vite.config.js +14 -0
  8. package/dist/index.d.ts +13 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +12 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/mcp-server/index.js.map +1 -0
  13. package/dist/mcp-server/mcp-stdio-server.js.map +1 -0
  14. package/dist/mcp-server/routes/claude.js.map +1 -0
  15. package/dist/mcp-server/routes/components.js.map +1 -0
  16. package/dist/mcp-server/routes/generateStory.js.map +1 -0
  17. package/dist/mcp-server/routes/hybridStories.d.ts +18 -0
  18. package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -0
  19. package/dist/mcp-server/routes/hybridStories.js +216 -0
  20. package/dist/mcp-server/routes/hybridStories.js.map +1 -0
  21. package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
  22. package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
  23. package/dist/mcp-server/routes/memoryStories.js +158 -0
  24. package/dist/mcp-server/routes/memoryStories.js.map +1 -0
  25. package/dist/mcp-server/routes/storySync.d.ts +26 -0
  26. package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
  27. package/dist/mcp-server/routes/storySync.js +147 -0
  28. package/dist/mcp-server/routes/storySync.js.map +1 -0
  29. package/dist/mcp-server/routes/updateStory.js +246 -0
  30. package/dist/mcp-server/sessionManager.d.ts +50 -0
  31. package/dist/mcp-server/sessionManager.d.ts.map +1 -0
  32. package/dist/mcp-server/sessionManager.js +125 -0
  33. package/dist/mcp-server/sessionManager.js.map +1 -0
  34. package/dist/playground/components/AIAssistant/AIAssistant.d.ts +6 -0
  35. package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +1 -0
  36. package/dist/playground/components/AIAssistant/AIAssistant.js +109 -0
  37. package/dist/playground/components/AIAssistant/AIAssistant.js.map +1 -0
  38. package/dist/playground/components/AIAssistant/AIAssistant.module.css +166 -0
  39. package/dist/playground/components/Canvas/Canvas.d.ts +9 -0
  40. package/dist/playground/components/Canvas/Canvas.d.ts.map +1 -0
  41. package/dist/playground/components/Canvas/Canvas.js +58 -0
  42. package/dist/playground/components/Canvas/Canvas.js.map +1 -0
  43. package/dist/playground/components/Canvas/Canvas.module.css +189 -0
  44. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +9 -0
  45. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +1 -0
  46. package/dist/playground/components/Canvas/CanvasWithDnd.js +158 -0
  47. package/dist/playground/components/Canvas/CanvasWithDnd.js.map +1 -0
  48. package/dist/playground/components/Canvas/ComponentRenderer.d.ts +15 -0
  49. package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +1 -0
  50. package/dist/playground/components/Canvas/ComponentRenderer.js +177 -0
  51. package/dist/playground/components/Canvas/ComponentRenderer.js.map +1 -0
  52. package/dist/playground/components/Canvas/DraggableComponent.d.ts +15 -0
  53. package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +1 -0
  54. package/dist/playground/components/Canvas/DraggableComponent.js +49 -0
  55. package/dist/playground/components/Canvas/DraggableComponent.js.map +1 -0
  56. package/dist/playground/components/Canvas/index.d.ts +9 -0
  57. package/dist/playground/components/Canvas/index.d.ts.map +1 -0
  58. package/dist/playground/components/Canvas/index.js +5 -0
  59. package/dist/playground/components/Canvas/index.js.map +1 -0
  60. package/dist/playground/components/CodeView/CodeView.d.ts +12 -0
  61. package/dist/playground/components/CodeView/CodeView.d.ts.map +1 -0
  62. package/dist/playground/components/CodeView/CodeView.js +77 -0
  63. package/dist/playground/components/CodeView/CodeView.js.map +1 -0
  64. package/dist/playground/components/CodeView/CodeView.module.css +178 -0
  65. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +17 -0
  66. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +1 -0
  67. package/dist/playground/components/ComponentPalette/ComponentPalette.js +138 -0
  68. package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +1 -0
  69. package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +217 -0
  70. package/dist/playground/components/ComponentPalette/index.d.ts +3 -0
  71. package/dist/playground/components/ComponentPalette/index.d.ts.map +1 -0
  72. package/dist/playground/components/ComponentPalette/index.js +2 -0
  73. package/dist/playground/components/ComponentPalette/index.js.map +1 -0
  74. package/dist/playground/components/DropZone/DropZone.d.ts +17 -0
  75. package/dist/playground/components/DropZone/DropZone.d.ts.map +1 -0
  76. package/dist/playground/components/DropZone/DropZone.js +73 -0
  77. package/dist/playground/components/DropZone/DropZone.js.map +1 -0
  78. package/dist/playground/components/DropZone/DropZone.module.css +86 -0
  79. package/dist/playground/components/ExportDialog/ExportDialog.d.ts +10 -0
  80. package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +1 -0
  81. package/dist/playground/components/ExportDialog/ExportDialog.js +57 -0
  82. package/dist/playground/components/ExportDialog/ExportDialog.js.map +1 -0
  83. package/dist/playground/components/ExportDialog/ExportDialog.module.css +328 -0
  84. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +134 -0
  85. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +1 -0
  86. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +254 -0
  87. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +1 -0
  88. package/dist/playground/components/LayoutHelpers/index.d.ts +3 -0
  89. package/dist/playground/components/LayoutHelpers/index.d.ts.map +1 -0
  90. package/dist/playground/components/LayoutHelpers/index.js +2 -0
  91. package/dist/playground/components/LayoutHelpers/index.js.map +1 -0
  92. package/dist/playground/components/Playground/Playground.d.ts +10 -0
  93. package/dist/playground/components/Playground/Playground.d.ts.map +1 -0
  94. package/dist/playground/components/Playground/Playground.js +128 -0
  95. package/dist/playground/components/Playground/Playground.js.map +1 -0
  96. package/dist/playground/components/Playground/Playground.module.css +308 -0
  97. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +10 -0
  98. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +1 -0
  99. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +150 -0
  100. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +1 -0
  101. package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +155 -0
  102. package/dist/playground/components/PropertiesPanel/index.d.ts +3 -0
  103. package/dist/playground/components/PropertiesPanel/index.d.ts.map +1 -0
  104. package/dist/playground/components/PropertiesPanel/index.js +2 -0
  105. package/dist/playground/components/PropertiesPanel/index.js.map +1 -0
  106. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +12 -0
  107. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +1 -0
  108. package/dist/playground/components/PropertyEditors/BooleanEditor.js +14 -0
  109. package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +1 -0
  110. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +12 -0
  111. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +1 -0
  112. package/dist/playground/components/PropertyEditors/ColorEditor.js +62 -0
  113. package/dist/playground/components/PropertyEditors/ColorEditor.js.map +1 -0
  114. package/dist/playground/components/PropertyEditors/IconEditor.d.ts +12 -0
  115. package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +1 -0
  116. package/dist/playground/components/PropertyEditors/IconEditor.js +123 -0
  117. package/dist/playground/components/PropertyEditors/IconEditor.js.map +1 -0
  118. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +15 -0
  119. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +1 -0
  120. package/dist/playground/components/PropertyEditors/NumberEditor.js +46 -0
  121. package/dist/playground/components/PropertyEditors/NumberEditor.js.map +1 -0
  122. package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +432 -0
  123. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +19 -0
  124. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +1 -0
  125. package/dist/playground/components/PropertyEditors/SelectEditor.js +17 -0
  126. package/dist/playground/components/PropertyEditors/SelectEditor.js.map +1 -0
  127. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +19 -0
  128. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +1 -0
  129. package/dist/playground/components/PropertyEditors/SpacingEditor.js +162 -0
  130. package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +1 -0
  131. package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +214 -0
  132. package/dist/playground/components/PropertyEditors/TextEditor.d.ts +14 -0
  133. package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +1 -0
  134. package/dist/playground/components/PropertyEditors/TextEditor.js +38 -0
  135. package/dist/playground/components/PropertyEditors/TextEditor.js.map +1 -0
  136. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +23 -0
  137. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +1 -0
  138. package/dist/playground/components/PropertyEditors/TokenEditor.js +50 -0
  139. package/dist/playground/components/PropertyEditors/TokenEditor.js.map +1 -0
  140. package/dist/playground/components/PropertyEditors/index.d.ts +20 -0
  141. package/dist/playground/components/PropertyEditors/index.d.ts.map +1 -0
  142. package/dist/playground/components/PropertyEditors/index.js +12 -0
  143. package/dist/playground/components/PropertyEditors/index.js.map +1 -0
  144. package/dist/playground/components/TreeView/TreeView.d.ts +10 -0
  145. package/dist/playground/components/TreeView/TreeView.d.ts.map +1 -0
  146. package/dist/playground/components/TreeView/TreeView.js +146 -0
  147. package/dist/playground/components/TreeView/TreeView.js.map +1 -0
  148. package/dist/playground/components/TreeView/TreeView.module.css +214 -0
  149. package/dist/playground/components/TreeView/index.d.ts +3 -0
  150. package/dist/playground/components/TreeView/index.d.ts.map +1 -0
  151. package/dist/playground/components/TreeView/index.js +2 -0
  152. package/dist/playground/components/TreeView/index.js.map +1 -0
  153. package/dist/playground/config/propertyDefinitions.d.ts +73 -0
  154. package/dist/playground/config/propertyDefinitions.d.ts.map +1 -0
  155. package/dist/playground/config/propertyDefinitions.js +809 -0
  156. package/dist/playground/config/propertyDefinitions.js.map +1 -0
  157. package/dist/playground/hooks/useKeyboardShortcuts.d.ts +38 -0
  158. package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +1 -0
  159. package/dist/playground/hooks/useKeyboardShortcuts.js +191 -0
  160. package/dist/playground/hooks/useKeyboardShortcuts.js.map +1 -0
  161. package/dist/playground/index.d.ts +21 -0
  162. package/dist/playground/index.d.ts.map +1 -0
  163. package/dist/playground/index.js +23 -0
  164. package/dist/playground/index.js.map +1 -0
  165. package/dist/playground/services/CodeGenerator.d.ts +73 -0
  166. package/dist/playground/services/CodeGenerator.d.ts.map +1 -0
  167. package/dist/playground/services/CodeGenerator.js +359 -0
  168. package/dist/playground/services/CodeGenerator.js.map +1 -0
  169. package/dist/playground/services/DragDropManager.d.ts +95 -0
  170. package/dist/playground/services/DragDropManager.d.ts.map +1 -0
  171. package/dist/playground/services/DragDropManager.js +408 -0
  172. package/dist/playground/services/DragDropManager.js.map +1 -0
  173. package/dist/playground/services/StoryParser.d.ts +73 -0
  174. package/dist/playground/services/StoryParser.d.ts.map +1 -0
  175. package/dist/playground/services/StoryParser.js +419 -0
  176. package/dist/playground/services/StoryParser.js.map +1 -0
  177. package/dist/playground/store/playgroundStore.d.ts +86 -0
  178. package/dist/playground/store/playgroundStore.d.ts.map +1 -0
  179. package/dist/playground/store/playgroundStore.js +337 -0
  180. package/dist/playground/store/playgroundStore.js.map +1 -0
  181. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +13 -0
  182. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +1 -0
  183. package/dist/playground/stories/PlaygroundDragDrop.stories.js +227 -0
  184. package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +1 -0
  185. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +13 -0
  186. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +1 -0
  187. package/dist/playground/stories/PlaygroundPhase4.stories.js +334 -0
  188. package/dist/playground/stories/PlaygroundPhase4.stories.js.map +1 -0
  189. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +14 -0
  190. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +1 -0
  191. package/dist/playground/stories/PlaygroundPhase5.stories.js +512 -0
  192. package/dist/playground/stories/PlaygroundPhase5.stories.js.map +1 -0
  193. package/dist/playground/stories/PlaygroundProperties.stories.d.ts +13 -0
  194. package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +1 -0
  195. package/dist/playground/stories/PlaygroundProperties.stories.js +342 -0
  196. package/dist/playground/stories/PlaygroundProperties.stories.js.map +1 -0
  197. package/dist/playground/types/index.d.ts +251 -0
  198. package/dist/playground/types/index.d.ts.map +1 -0
  199. package/dist/playground/types/index.js +5 -0
  200. package/dist/playground/types/index.js.map +1 -0
  201. package/dist/scripts/verify-framework-adapters.js +105 -0
  202. package/dist/story-generator/componentBlacklist.js.map +1 -0
  203. package/dist/story-generator/componentDiscovery.js.map +1 -0
  204. package/dist/story-generator/configLoader.js.map +1 -0
  205. package/dist/story-generator/considerationsLoader.js.map +1 -0
  206. package/dist/story-generator/documentation-sources.js.map +1 -0
  207. package/dist/story-generator/documentationLoader.js.map +1 -0
  208. package/dist/story-generator/dynamicPackageDiscovery.js.map +1 -0
  209. package/dist/story-generator/enhancedComponentDiscovery.js.map +1 -0
  210. package/dist/story-generator/generateStory.js.map +1 -0
  211. package/dist/story-generator/gitignoreManager.js.map +1 -0
  212. package/dist/story-generator/inMemoryStoryService.d.ts +89 -0
  213. package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
  214. package/dist/story-generator/inMemoryStoryService.js +128 -0
  215. package/dist/story-generator/inMemoryStoryService.js.map +1 -0
  216. package/dist/story-generator/logger.js.map +1 -0
  217. package/dist/story-generator/postProcessStory.js.map +1 -0
  218. package/dist/story-generator/postgresStoryService.d.ts +56 -0
  219. package/dist/story-generator/postgresStoryService.d.ts.map +1 -0
  220. package/dist/story-generator/postgresStoryService.js +240 -0
  221. package/dist/story-generator/productionGitignoreManager.d.ts +91 -0
  222. package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
  223. package/dist/story-generator/productionGitignoreManager.js +340 -0
  224. package/dist/story-generator/productionGitignoreManager.js.map +1 -0
  225. package/dist/story-generator/promptGenerator.js.map +1 -0
  226. package/dist/story-generator/providerPresets.d.ts +54 -0
  227. package/dist/story-generator/providerPresets.d.ts.map +1 -0
  228. package/dist/story-generator/providerPresets.js +214 -0
  229. package/dist/story-generator/storyHistory.js.map +1 -0
  230. package/dist/story-generator/storyServiceFactory.d.ts +22 -0
  231. package/dist/story-generator/storyServiceFactory.d.ts.map +1 -0
  232. package/dist/story-generator/storyServiceFactory.js +97 -0
  233. package/dist/story-generator/storyServiceInterface.d.ts +85 -0
  234. package/dist/story-generator/storyServiceInterface.d.ts.map +1 -0
  235. package/dist/story-generator/storyServiceInterface.js +5 -0
  236. package/dist/story-generator/storySync.d.ts +68 -0
  237. package/dist/story-generator/storySync.d.ts.map +1 -0
  238. package/dist/story-generator/storySync.js +201 -0
  239. package/dist/story-generator/storySync.js.map +1 -0
  240. package/dist/story-generator/storyTracker.js.map +1 -0
  241. package/dist/story-generator/storyValidator.js.map +1 -0
  242. package/dist/story-generator/test_validation.d.ts +2 -0
  243. package/dist/story-generator/test_validation.d.ts.map +1 -0
  244. package/dist/story-generator/test_validation.js +51 -0
  245. package/dist/story-generator/universalDesignSystemAdapter.js.map +1 -0
  246. package/dist/story-generator/urlRedirectService.js.map +1 -0
  247. package/dist/story-generator/validateStory.js.map +1 -0
  248. package/dist/story-ui.config.js.map +1 -0
  249. package/dist/story-ui.config.loader.d.ts +36 -0
  250. package/dist/story-ui.config.loader.d.ts.map +1 -0
  251. package/dist/story-ui.config.loader.js +205 -0
  252. package/dist/story-ui.config.loader.js.map +1 -0
  253. package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +807 -0
  254. package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +37 -0
  255. package/dist/temp/package/templates/StoryUI/index.js +2 -0
  256. package/dist/templates/StoryUI/StoryUIPanel.js.map +1 -0
  257. package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +1 -0
  258. package/dist/templates/StoryUI/index.js.map +1 -0
  259. package/dist/templates/StoryUI/manager.d.ts +14 -0
  260. package/dist/templates/StoryUI/manager.d.ts.map +1 -0
  261. package/dist/templates/production-app/src/App.d.ts +10 -0
  262. package/dist/templates/production-app/src/App.d.ts.map +1 -0
  263. package/dist/templates/production-app/src/App.js +653 -0
  264. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +24 -0
  265. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +1 -0
  266. package/dist/templates/production-app/src/LivePreviewRenderer.js +199 -0
  267. package/dist/templates/production-app/src/componentRegistry.d.ts +20 -0
  268. package/dist/templates/production-app/src/componentRegistry.d.ts.map +1 -0
  269. package/dist/templates/production-app/src/componentRegistry.js +316 -0
  270. package/dist/templates/production-app/src/main.d.ts +9 -0
  271. package/dist/templates/production-app/src/main.d.ts.map +1 -0
  272. package/dist/templates/production-app/src/main.js +18 -0
  273. package/dist/templates/production-app/vite.config.d.ts +3 -0
  274. package/dist/templates/production-app/vite.config.d.ts.map +1 -0
  275. package/dist/templates/production-app/vite.config.js +71 -0
  276. package/dist/test-storybooks/angular-material-storybook/src/main.js +66 -0
  277. package/dist/test-storybooks/chakra-storybook/vite.config.js +6 -0
  278. package/dist/test-storybooks/mantine-storybook/vite.config.js +93 -0
  279. package/dist/test-storybooks/web-components-shoelace/vite.config.js +9 -0
  280. package/dist/tsconfig.tsbuildinfo +1 -0
  281. package/package.json +1 -1
@@ -0,0 +1,26 @@
1
+ import { Request, Response } from 'express';
2
+ /**
3
+ * Get all synchronized stories (from both file system and memory)
4
+ */
5
+ export declare function getSyncedStories(req: Request, res: Response): Promise<void>;
6
+ /**
7
+ * Delete a story from both file system and memory
8
+ */
9
+ export declare function deleteSyncedStory(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
10
+ /**
11
+ * Clear all stories from both file system and memory
12
+ */
13
+ export declare function clearAllSyncedStories(req: Request, res: Response): Promise<void>;
14
+ /**
15
+ * Sync chat history with actual stories
16
+ */
17
+ export declare function syncChatHistory(req: Request, res: Response): Promise<void>;
18
+ /**
19
+ * Validate that a chat session corresponds to an actual story
20
+ */
21
+ export declare function validateChatSession(req: Request, res: Response): Promise<void>;
22
+ /**
23
+ * Get a specific synced story by ID
24
+ */
25
+ export declare function getSyncedStoryById(req: Request, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
26
+ //# sourceMappingURL=storySync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storySync.d.ts","sourceRoot":"","sources":["../../../mcp-server/routes/storySync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAyBjE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DAwBlE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAgBtE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAgBhE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,iBAkBpE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,2DAwBnE"}
@@ -0,0 +1,147 @@
1
+ import { getStorySyncService } from '../../story-generator/storySync.js';
2
+ import { loadUserConfig } from '../../story-generator/configLoader.js';
3
+ /**
4
+ * Get all synchronized stories (from both file system and memory)
5
+ */
6
+ export async function getSyncedStories(req, res) {
7
+ try {
8
+ const config = loadUserConfig();
9
+ const syncService = getStorySyncService(config);
10
+ const stories = await syncService.getAllStories();
11
+ res.json({
12
+ success: true,
13
+ stories: stories.map(story => ({
14
+ id: story.id,
15
+ title: story.title,
16
+ fileName: story.fileName,
17
+ description: story.description,
18
+ createdAt: story.createdAt,
19
+ lastAccessed: story.lastAccessed,
20
+ source: story.source
21
+ })),
22
+ count: stories.length
23
+ });
24
+ }
25
+ catch (error) {
26
+ res.status(500).json({
27
+ success: false,
28
+ error: 'Failed to retrieve synchronized stories'
29
+ });
30
+ }
31
+ }
32
+ /**
33
+ * Delete a story from both file system and memory
34
+ */
35
+ export async function deleteSyncedStory(req, res) {
36
+ try {
37
+ const { id } = req.params;
38
+ const config = loadUserConfig();
39
+ const syncService = getStorySyncService(config);
40
+ const deleted = await syncService.deleteStory(id);
41
+ if (!deleted) {
42
+ return res.status(404).json({
43
+ success: false,
44
+ error: 'Story not found'
45
+ });
46
+ }
47
+ res.json({
48
+ success: true,
49
+ message: 'Story deleted successfully from all sources'
50
+ });
51
+ }
52
+ catch (error) {
53
+ res.status(500).json({
54
+ success: false,
55
+ error: 'Failed to delete story'
56
+ });
57
+ }
58
+ }
59
+ /**
60
+ * Clear all stories from both file system and memory
61
+ */
62
+ export async function clearAllSyncedStories(req, res) {
63
+ try {
64
+ const config = loadUserConfig();
65
+ const syncService = getStorySyncService(config);
66
+ await syncService.clearAllStories();
67
+ res.json({
68
+ success: true,
69
+ message: 'All stories cleared successfully'
70
+ });
71
+ }
72
+ catch (error) {
73
+ res.status(500).json({
74
+ success: false,
75
+ error: 'Failed to clear stories'
76
+ });
77
+ }
78
+ }
79
+ /**
80
+ * Sync chat history with actual stories
81
+ */
82
+ export async function syncChatHistory(req, res) {
83
+ try {
84
+ const config = loadUserConfig();
85
+ const syncService = getStorySyncService(config);
86
+ const syncResult = await syncService.syncChatHistory();
87
+ res.json({
88
+ success: true,
89
+ ...syncResult
90
+ });
91
+ }
92
+ catch (error) {
93
+ res.status(500).json({
94
+ success: false,
95
+ error: 'Failed to sync chat history'
96
+ });
97
+ }
98
+ }
99
+ /**
100
+ * Validate that a chat session corresponds to an actual story
101
+ */
102
+ export async function validateChatSession(req, res) {
103
+ try {
104
+ const { id } = req.params;
105
+ const config = loadUserConfig();
106
+ const syncService = getStorySyncService(config);
107
+ const isValid = await syncService.validateChatSession(id);
108
+ res.json({
109
+ success: true,
110
+ isValid,
111
+ message: isValid ? 'Chat session is valid' : 'Chat session has no corresponding story'
112
+ });
113
+ }
114
+ catch (error) {
115
+ res.status(500).json({
116
+ success: false,
117
+ error: 'Failed to validate chat session'
118
+ });
119
+ }
120
+ }
121
+ /**
122
+ * Get a specific synced story by ID
123
+ */
124
+ export async function getSyncedStoryById(req, res) {
125
+ try {
126
+ const { id } = req.params;
127
+ const config = loadUserConfig();
128
+ const syncService = getStorySyncService(config);
129
+ const story = await syncService.getStory(id);
130
+ if (!story) {
131
+ return res.status(404).json({
132
+ success: false,
133
+ error: 'Story not found'
134
+ });
135
+ }
136
+ res.json({
137
+ success: true,
138
+ story
139
+ });
140
+ }
141
+ catch (error) {
142
+ res.status(500).json({
143
+ success: false,
144
+ error: 'Failed to retrieve story'
145
+ });
146
+ }
147
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storySync.js","sourceRoot":"","sources":["../../../mcp-server/routes/storySync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CA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,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE7C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,iBAAiB;aACzB,CAAC,CAAC;QACL,CAAC;QAED,GAAG,CAAC,IAAI,CAAC;YACP,OAAO,EAAE,IAAI;YACb,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,0BAA0B;SAClC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,246 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { loadUserConfig } from '../../story-generator/configLoader.js';
4
+ import { logger } from '../../story-generator/logger.js';
5
+ /**
6
+ * Update an existing story file with new content from Visual Builder
7
+ * This uses the same file system access that Story UI already uses for generation
8
+ */
9
+ export async function updateStoryFromVisualBuilder(req, res) {
10
+ const { filePath, components, storyName, fileName, createBackup = false } = req.body;
11
+ if (!fileName && !filePath) {
12
+ return res.status(400).json({
13
+ error: 'Missing required parameters',
14
+ details: 'Either fileName or filePath must be provided'
15
+ });
16
+ }
17
+ try {
18
+ // Load the Story UI configuration to get the stories path
19
+ const config = loadUserConfig();
20
+ // Determine the target file path - save edited stories to edited/ subdirectory
21
+ let targetPath;
22
+ let cleanFileName;
23
+ if (filePath) {
24
+ // If full path is provided, extract the filename
25
+ cleanFileName = path.basename(filePath);
26
+ }
27
+ else {
28
+ // Use fileName to construct path and ensure proper extension
29
+ cleanFileName = fileName;
30
+ }
31
+ // Smart extension handling to prevent double .stories extensions
32
+ // First, remove any existing .stories.tsx or .stories.stories.tsx patterns
33
+ cleanFileName = cleanFileName
34
+ .replace(/\.stories\.stories\.tsx$/, '') // Remove double extension if present
35
+ .replace(/\.stories\.tsx$/, '') // Remove single extension if present
36
+ .replace(/\.stories$/, ''); // Remove partial extension if present
37
+ // Now add the correct extension
38
+ cleanFileName = cleanFileName + '.stories.tsx';
39
+ // Determine if this should be saved as an edited story
40
+ const isEditedStory = cleanFileName.startsWith('edited-') ||
41
+ cleanFileName.startsWith('generated-') ||
42
+ req.body.isEdited === true;
43
+ if (isEditedStory) {
44
+ // Save edited stories to the edited/ subdirectory
45
+ const editedPath = path.join(config.generatedStoriesPath, '..', 'edited');
46
+ // Ensure the edited directory exists
47
+ if (!fs.existsSync(editedPath)) {
48
+ fs.mkdirSync(editedPath, { recursive: true });
49
+ }
50
+ // Smart file name handling to prevent duplicate prefixes
51
+ let finalFileName = cleanFileName;
52
+ // If it's a generated story being edited for the first time, convert the prefix
53
+ if (cleanFileName.startsWith('generated-')) {
54
+ finalFileName = cleanFileName.replace(/^generated-/, 'edited-');
55
+ }
56
+ // If it doesn't start with 'edited-', add the prefix (for new stories)
57
+ else if (!cleanFileName.startsWith('edited-')) {
58
+ finalFileName = `edited-${cleanFileName}`;
59
+ }
60
+ // If it already starts with 'edited-', keep it as is (re-editing existing edited story)
61
+ // Check if a file already exists in the edited directory with the original name
62
+ // This handles re-editing scenarios where we want to update the existing file
63
+ const originalNamePath = path.join(editedPath, cleanFileName);
64
+ if (fs.existsSync(originalNamePath) && !cleanFileName.startsWith('edited-')) {
65
+ // Use the original filename to update the existing edited file
66
+ finalFileName = cleanFileName;
67
+ }
68
+ targetPath = path.join(editedPath, finalFileName);
69
+ }
70
+ else {
71
+ // Save generated stories to the main generated directory
72
+ targetPath = path.join(config.generatedStoriesPath, cleanFileName);
73
+ }
74
+ // Optional backup creation (only if explicitly requested)
75
+ if (createBackup && fs.existsSync(targetPath)) {
76
+ const backupPath = targetPath.replace('.stories.tsx', '.backup.stories.tsx');
77
+ fs.copyFileSync(targetPath, backupPath);
78
+ logger.log(`📦 Created backup: ${backupPath}`);
79
+ }
80
+ logger.log(`📝 Updating story file: ${targetPath}`);
81
+ logger.log(`🔍 File name resolution: ${fileName} → ${cleanFileName} → ${path.basename(targetPath)}`);
82
+ // Generate the new story content from components
83
+ const { generateStoryFileContent } = await import('../../visual-builder/utils/storyFileUpdater.js');
84
+ const newContent = generateStoryFileContent(components, storyName || 'Updated Story', path.basename(targetPath));
85
+ // Check if file exists (for updates) or create new (for saves)
86
+ const fileExists = fs.existsSync(targetPath);
87
+ // Write the file - always overwrite
88
+ fs.writeFileSync(targetPath, newContent, 'utf-8');
89
+ logger.log(`✅ Successfully ${fileExists ? 'updated' : 'created'} story file`);
90
+ // Return success response
91
+ res.json({
92
+ success: true,
93
+ filePath: targetPath,
94
+ fileName: path.basename(targetPath),
95
+ action: fileExists ? 'updated' : 'created',
96
+ hasBackup: createBackup && fileExists,
97
+ message: `Story ${fileExists ? 'updated' : 'created'} successfully`
98
+ });
99
+ }
100
+ catch (error) {
101
+ logger.log(`❌ Error updating story file: ${error.message}`);
102
+ res.status(500).json({
103
+ error: 'Failed to update story file',
104
+ details: error.message
105
+ });
106
+ }
107
+ }
108
+ /**
109
+ * Get story content for editing in Visual Builder
110
+ * This allows Visual Builder to load existing stories
111
+ */
112
+ export async function getStoryForVisualBuilder(req, res) {
113
+ const { fileName, isEdited } = req.query;
114
+ if (!fileName) {
115
+ return res.status(400).json({
116
+ error: 'Missing fileName parameter'
117
+ });
118
+ }
119
+ try {
120
+ const config = loadUserConfig();
121
+ // Clean the filename - remove any double extensions first
122
+ let cleanFileName = String(fileName)
123
+ .replace(/\.stories\.stories\.tsx$/, '.stories.tsx') // Fix double extension
124
+ .replace(/\.stories\.tsx$/, '.stories.tsx'); // Keep single extension
125
+ // If no extension, add it
126
+ if (!cleanFileName.endsWith('.stories.tsx')) {
127
+ if (cleanFileName.endsWith('.stories')) {
128
+ cleanFileName = cleanFileName + '.tsx';
129
+ }
130
+ else {
131
+ cleanFileName = cleanFileName + '.stories.tsx';
132
+ }
133
+ }
134
+ const isEditedStory = isEdited === 'true' || String(fileName).startsWith('edited-');
135
+ let fullPath;
136
+ // Priority-based lookup: edited stories get priority in edited/ directory
137
+ if (isEditedStory) {
138
+ // For edited stories, check edited/ directory first
139
+ const editedDir = path.join(config.generatedStoriesPath, '..', 'edited');
140
+ // Try multiple filename patterns to handle existing double-extension files
141
+ const filenamesToTry = [
142
+ cleanFileName, // Correct format: filename.stories.tsx
143
+ cleanFileName.replace('.stories.tsx', '.stories.stories.tsx'), // Double extension format
144
+ ];
145
+ // Check edited directory with all possible filenames
146
+ for (const tryFileName of filenamesToTry) {
147
+ const editedPath = path.join(editedDir, tryFileName);
148
+ if (fs.existsSync(editedPath)) {
149
+ fullPath = editedPath;
150
+ console.log(`✅ Found edited story at: ${editedPath}`);
151
+ break;
152
+ }
153
+ }
154
+ // If not found in edited, try generated directory
155
+ if (!fullPath) {
156
+ const generatedPath = path.join(config.generatedStoriesPath, cleanFileName);
157
+ if (fs.existsSync(generatedPath)) {
158
+ fullPath = generatedPath;
159
+ console.log(`⚠️ Edited story not found, falling back to generated: ${generatedPath}`);
160
+ }
161
+ }
162
+ // If still not found, try pattern matching
163
+ if (!fullPath) {
164
+ const baseFileName = cleanFileName.replace('.stories.tsx', '');
165
+ // Check edited directory first with pattern matching
166
+ if (fs.existsSync(editedDir)) {
167
+ const editedFiles = fs.readdirSync(editedDir);
168
+ const matchingEditedFile = editedFiles.find(file => file.startsWith(baseFileName) && (file.endsWith('.stories.tsx') || file.endsWith('.stories.stories.tsx')));
169
+ if (matchingEditedFile) {
170
+ fullPath = path.join(editedDir, matchingEditedFile);
171
+ console.log(`✅ Found edited story by pattern: ${fullPath}`);
172
+ }
173
+ }
174
+ // If still not found, check generated directory
175
+ if (!fullPath) {
176
+ const generatedDir = config.generatedStoriesPath;
177
+ if (fs.existsSync(generatedDir)) {
178
+ const generatedFiles = fs.readdirSync(generatedDir);
179
+ const matchingGeneratedFile = generatedFiles.find(file => file.startsWith(baseFileName) && file.endsWith('.stories.tsx'));
180
+ if (matchingGeneratedFile) {
181
+ fullPath = path.join(generatedDir, matchingGeneratedFile);
182
+ }
183
+ }
184
+ }
185
+ if (!fullPath) {
186
+ return res.status(404).json({
187
+ error: 'Story file not found',
188
+ fileName: cleanFileName,
189
+ searched: ['edited/', 'generated/'],
190
+ baseFileName
191
+ });
192
+ }
193
+ }
194
+ }
195
+ else {
196
+ // For generated stories, check generated/ directory first
197
+ fullPath = path.join(config.generatedStoriesPath, cleanFileName);
198
+ if (!fs.existsSync(fullPath)) {
199
+ const editedPath = path.join(config.generatedStoriesPath, '..', 'edited', cleanFileName);
200
+ if (fs.existsSync(editedPath)) {
201
+ fullPath = editedPath;
202
+ }
203
+ else {
204
+ // Also try to find files with a hash suffix (e.g., basic-card-781ccd01.stories.tsx)
205
+ const baseFileName = cleanFileName.replace('.stories.tsx', '');
206
+ const generatedDir = config.generatedStoriesPath;
207
+ // Check if there's a file that starts with the base name
208
+ if (fs.existsSync(generatedDir)) {
209
+ const files = fs.readdirSync(generatedDir);
210
+ const matchingFile = files.find(file => file.startsWith(baseFileName) && file.endsWith('.stories.tsx'));
211
+ if (matchingFile) {
212
+ fullPath = path.join(generatedDir, matchingFile);
213
+ }
214
+ else {
215
+ return res.status(404).json({
216
+ error: 'Story file not found',
217
+ fileName: cleanFileName,
218
+ searched: ['generated/', 'edited/'],
219
+ baseFileName
220
+ });
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ if (!fullPath) {
227
+ return res.status(404).json({
228
+ error: 'Story file not found',
229
+ fileName: cleanFileName
230
+ });
231
+ }
232
+ const content = fs.readFileSync(fullPath, 'utf-8');
233
+ res.json({
234
+ success: true,
235
+ fileName: path.basename(fullPath),
236
+ content,
237
+ filePath: fullPath
238
+ });
239
+ }
240
+ catch (error) {
241
+ res.status(500).json({
242
+ error: 'Failed to read story file',
243
+ details: error.message
244
+ });
245
+ }
246
+ }
@@ -0,0 +1,50 @@
1
+ interface SessionStory {
2
+ id: string;
3
+ fileName: string;
4
+ title: string;
5
+ prompt: string;
6
+ timestamp: Date;
7
+ keywords: string[];
8
+ }
9
+ export declare class SessionManager {
10
+ private static instance;
11
+ private sessions;
12
+ private currentStoryId;
13
+ private constructor();
14
+ static getInstance(): SessionManager;
15
+ /**
16
+ * Track a newly generated story in the current session
17
+ */
18
+ trackStory(sessionId: string, story: {
19
+ id: string;
20
+ fileName: string;
21
+ title: string;
22
+ prompt: string;
23
+ }): void;
24
+ /**
25
+ * Get the current story being discussed
26
+ */
27
+ getCurrentStory(sessionId: string): SessionStory | null;
28
+ /**
29
+ * Find a story by context (keywords in the user's message)
30
+ */
31
+ findStoryByContext(sessionId: string, userMessage: string): SessionStory | null;
32
+ /**
33
+ * Get all stories in the current session
34
+ */
35
+ getSessionStories(sessionId: string): SessionStory[];
36
+ /**
37
+ * Set the current story being discussed
38
+ */
39
+ setCurrentStory(sessionId: string, storyId: string): void;
40
+ /**
41
+ * Clear session data (for cleanup)
42
+ */
43
+ clearSession(sessionId: string): void;
44
+ /**
45
+ * Extract meaningful keywords from text
46
+ */
47
+ private extractKeywords;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=sessionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionManager.d.ts","sourceRoot":"","sources":["../../mcp-server/sessionManager.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAA0C;IAC1D,OAAO,CAAC,cAAc,CAAuB;IAE7C,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,cAAc;IAOpC;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE;QACnC,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB;IAmBD;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IASvD;;OAEG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAiC/E;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE;IAIpD;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAQlD;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAO9B;;OAEG;IACH,OAAO,CAAC,eAAe;CAkCxB"}
@@ -0,0 +1,125 @@
1
+ export class SessionManager {
2
+ constructor() {
3
+ this.sessions = new Map();
4
+ this.currentStoryId = null;
5
+ }
6
+ static getInstance() {
7
+ if (!SessionManager.instance) {
8
+ SessionManager.instance = new SessionManager();
9
+ }
10
+ return SessionManager.instance;
11
+ }
12
+ /**
13
+ * Track a newly generated story in the current session
14
+ */
15
+ trackStory(sessionId, story) {
16
+ const sessionStories = this.sessions.get(sessionId) || [];
17
+ // Extract keywords from prompt and title for smart matching
18
+ const keywords = this.extractKeywords(story.prompt + ' ' + story.title);
19
+ const sessionStory = {
20
+ ...story,
21
+ timestamp: new Date(),
22
+ keywords
23
+ };
24
+ sessionStories.push(sessionStory);
25
+ this.sessions.set(sessionId, sessionStories);
26
+ this.currentStoryId = story.id;
27
+ console.error(`[SessionManager] Tracked story: ${story.title} (${story.id}) for session ${sessionId}`);
28
+ }
29
+ /**
30
+ * Get the current story being discussed
31
+ */
32
+ getCurrentStory(sessionId) {
33
+ const stories = this.sessions.get(sessionId) || [];
34
+ if (this.currentStoryId) {
35
+ return stories.find(s => s.id === this.currentStoryId) || null;
36
+ }
37
+ // Return the most recent story if no current story is set
38
+ return stories[stories.length - 1] || null;
39
+ }
40
+ /**
41
+ * Find a story by context (keywords in the user's message)
42
+ */
43
+ findStoryByContext(sessionId, userMessage) {
44
+ const stories = this.sessions.get(sessionId) || [];
45
+ if (stories.length === 0)
46
+ return null;
47
+ const messageKeywords = this.extractKeywords(userMessage.toLowerCase());
48
+ // Score each story based on keyword matches
49
+ const scoredStories = stories.map(story => {
50
+ const score = story.keywords.filter(keyword => messageKeywords.some(msgKeyword => msgKeyword.includes(keyword) || keyword.includes(msgKeyword))).length;
51
+ return { story, score };
52
+ });
53
+ // Sort by score and recency
54
+ scoredStories.sort((a, b) => {
55
+ if (a.score !== b.score)
56
+ return b.score - a.score;
57
+ return b.story.timestamp.getTime() - a.story.timestamp.getTime();
58
+ });
59
+ // Return the best match if it has any keyword matches
60
+ if (scoredStories[0].score > 0) {
61
+ this.currentStoryId = scoredStories[0].story.id;
62
+ console.error(`[SessionManager] Found story by context: ${scoredStories[0].story.title} (score: ${scoredStories[0].score})`);
63
+ return scoredStories[0].story;
64
+ }
65
+ return null;
66
+ }
67
+ /**
68
+ * Get all stories in the current session
69
+ */
70
+ getSessionStories(sessionId) {
71
+ return this.sessions.get(sessionId) || [];
72
+ }
73
+ /**
74
+ * Set the current story being discussed
75
+ */
76
+ setCurrentStory(sessionId, storyId) {
77
+ const stories = this.sessions.get(sessionId) || [];
78
+ if (stories.some(s => s.id === storyId)) {
79
+ this.currentStoryId = storyId;
80
+ console.error(`[SessionManager] Set current story to: ${storyId}`);
81
+ }
82
+ }
83
+ /**
84
+ * Clear session data (for cleanup)
85
+ */
86
+ clearSession(sessionId) {
87
+ this.sessions.delete(sessionId);
88
+ if (this.currentStoryId) {
89
+ this.currentStoryId = null;
90
+ }
91
+ }
92
+ /**
93
+ * Extract meaningful keywords from text
94
+ */
95
+ extractKeywords(text) {
96
+ // Remove common words and extract meaningful terms
97
+ const commonWords = new Set([
98
+ 'a', 'an', 'the', 'and', 'or', 'but', 'in', 'on', 'at', 'to', 'for',
99
+ 'of', 'with', 'by', 'from', 'up', 'about', 'into', 'through', 'during',
100
+ 'before', 'after', 'above', 'below', 'between', 'under', 'again', 'further',
101
+ 'then', 'once', 'create', 'make', 'generate', 'build', 'add', 'update',
102
+ 'component', 'story', 'please', 'should', 'would', 'could'
103
+ ]);
104
+ const words = text.toLowerCase()
105
+ .replace(/[^a-z0-9\s]/g, ' ')
106
+ .split(/\s+/)
107
+ .filter(word => word.length > 2 && !commonWords.has(word));
108
+ // Also extract compound terms (like "toast notification")
109
+ const phrases = [];
110
+ const importantPhrases = [
111
+ 'toast notification', 'banner notification', 'success message',
112
+ 'error message', 'warning message', 'info message',
113
+ 'dark mode', 'light mode', 'switch', 'toggle', 'button',
114
+ 'card', 'alert', 'modal', 'dialog', 'form', 'input',
115
+ 'table', 'list', 'grid', 'layout', 'navigation', 'menu'
116
+ ];
117
+ const lowerText = text.toLowerCase();
118
+ for (const phrase of importantPhrases) {
119
+ if (lowerText.includes(phrase)) {
120
+ phrases.push(phrase);
121
+ }
122
+ }
123
+ return [...new Set([...words, ...phrases])];
124
+ }
125
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionManager.js","sourceRoot":"","sources":["../../mcp-server/sessionManager.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,cAAc;IAKzB;QAHQ,aAAQ,GAAgC,IAAI,GAAG,EAAE,CAAC;QAClD,mBAAc,GAAkB,IAAI,CAAC;IAEtB,CAAC;IAExB,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC7B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,SAAiB,EAAE,KAK7B;QACC,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,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,QAAQ;YACtE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;SAC3D,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE;aAC7B,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC;aAC5B,KAAK,CAAC,KAAK,CAAC;aACZ,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAE7D,0DAA0D;QAC1D,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,gBAAgB,GAAG;YACvB,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB;YAC9D,eAAe,EAAE,iBAAiB,EAAE,cAAc;YAClD,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;YACvD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO;YACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM;SACxD,CAAC;QAEF,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * AIAssistant - Connects to existing Story UI generation and enables visual editing
3
+ */
4
+ import React from 'react';
5
+ export declare const AIAssistant: React.FC;
6
+ //# sourceMappingURL=AIAssistant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIAssistant.d.ts","sourceRoot":"","sources":["../../../../playground/components/AIAssistant/AIAssistant.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAwC,MAAM,OAAO,CAAC;AAqB7D,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAsM/B,CAAC"}