@tpitre/story-ui 2.1.5 → 2.3.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 (203) hide show
  1. package/.env.sample +82 -11
  2. package/README.md +130 -4
  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 +55 -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 +138 -6
  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 +638 -0
  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 +274 -115
  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/hybridStories.js +214 -0
  35. package/dist/mcp-server/routes/mcpRemote.d.ts +14 -0
  36. package/dist/mcp-server/routes/mcpRemote.d.ts.map +1 -0
  37. package/dist/mcp-server/routes/mcpRemote.js +489 -0
  38. package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
  39. package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
  40. package/dist/mcp-server/routes/memoryStories.js +13 -7
  41. package/dist/mcp-server/routes/providers.d.ts +89 -0
  42. package/dist/mcp-server/routes/providers.d.ts.map +1 -0
  43. package/dist/mcp-server/routes/providers.js +369 -0
  44. package/dist/mcp-server/routes/storySync.d.ts +26 -0
  45. package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
  46. package/dist/mcp-server/routes/streamTypes.d.ts +110 -0
  47. package/dist/mcp-server/routes/streamTypes.d.ts.map +1 -0
  48. package/dist/mcp-server/routes/streamTypes.js +18 -0
  49. package/dist/mcp-server/sessionManager.d.ts +50 -0
  50. package/dist/mcp-server/sessionManager.d.ts.map +1 -0
  51. package/dist/mcp-server/sessionManager.js +125 -0
  52. package/dist/story-generator/componentBlacklist.d.ts +21 -0
  53. package/dist/story-generator/componentBlacklist.d.ts.map +1 -0
  54. package/dist/story-generator/componentBlacklist.js +4 -0
  55. package/dist/story-generator/componentDiscovery.d.ts +28 -0
  56. package/dist/story-generator/componentDiscovery.d.ts.map +1 -0
  57. package/dist/story-generator/componentRegistryGenerator.d.ts +49 -0
  58. package/dist/story-generator/componentRegistryGenerator.d.ts.map +1 -0
  59. package/dist/story-generator/componentRegistryGenerator.js +205 -0
  60. package/dist/story-generator/configLoader.d.ts +33 -0
  61. package/dist/story-generator/configLoader.d.ts.map +1 -0
  62. package/dist/story-generator/configLoader.js +8 -1
  63. package/dist/story-generator/considerationsLoader.d.ts +32 -0
  64. package/dist/story-generator/considerationsLoader.d.ts.map +1 -0
  65. package/dist/story-generator/considerationsLoader.js +2 -1
  66. package/dist/story-generator/documentation-sources.d.ts +28 -0
  67. package/dist/story-generator/documentation-sources.d.ts.map +1 -0
  68. package/dist/story-generator/documentationLoader.d.ts +64 -0
  69. package/dist/story-generator/documentationLoader.d.ts.map +1 -0
  70. package/dist/story-generator/documentationLoader.js +4 -3
  71. package/dist/story-generator/dynamicPackageDiscovery.d.ts +97 -0
  72. package/dist/story-generator/dynamicPackageDiscovery.d.ts.map +1 -0
  73. package/dist/story-generator/dynamicPackageDiscovery.js +31 -22
  74. package/dist/story-generator/enhancedComponentDiscovery.d.ts +125 -0
  75. package/dist/story-generator/enhancedComponentDiscovery.d.ts.map +1 -0
  76. package/dist/story-generator/enhancedComponentDiscovery.js +162 -21
  77. package/dist/story-generator/framework-adapters/angular-adapter.d.ts +40 -0
  78. package/dist/story-generator/framework-adapters/angular-adapter.d.ts.map +1 -0
  79. package/dist/story-generator/framework-adapters/angular-adapter.js +427 -0
  80. package/dist/story-generator/framework-adapters/base-adapter.d.ts +75 -0
  81. package/dist/story-generator/framework-adapters/base-adapter.d.ts.map +1 -0
  82. package/dist/story-generator/framework-adapters/base-adapter.js +147 -0
  83. package/dist/story-generator/framework-adapters/framework-detector.d.ts +55 -0
  84. package/dist/story-generator/framework-adapters/framework-detector.d.ts.map +1 -0
  85. package/dist/story-generator/framework-adapters/framework-detector.js +323 -0
  86. package/dist/story-generator/framework-adapters/index.d.ts +97 -0
  87. package/dist/story-generator/framework-adapters/index.d.ts.map +1 -0
  88. package/dist/story-generator/framework-adapters/index.js +198 -0
  89. package/dist/story-generator/framework-adapters/react-adapter.d.ts +40 -0
  90. package/dist/story-generator/framework-adapters/react-adapter.d.ts.map +1 -0
  91. package/dist/story-generator/framework-adapters/react-adapter.js +316 -0
  92. package/dist/story-generator/framework-adapters/svelte-adapter.d.ts +40 -0
  93. package/dist/story-generator/framework-adapters/svelte-adapter.d.ts.map +1 -0
  94. package/dist/story-generator/framework-adapters/svelte-adapter.js +372 -0
  95. package/dist/story-generator/framework-adapters/types.d.ts +182 -0
  96. package/dist/story-generator/framework-adapters/types.d.ts.map +1 -0
  97. package/dist/story-generator/framework-adapters/types.js +8 -0
  98. package/dist/story-generator/framework-adapters/vue-adapter.d.ts +36 -0
  99. package/dist/story-generator/framework-adapters/vue-adapter.d.ts.map +1 -0
  100. package/dist/story-generator/framework-adapters/vue-adapter.js +336 -0
  101. package/dist/story-generator/framework-adapters/web-components-adapter.d.ts +54 -0
  102. package/dist/story-generator/framework-adapters/web-components-adapter.d.ts.map +1 -0
  103. package/dist/story-generator/framework-adapters/web-components-adapter.js +387 -0
  104. package/dist/story-generator/generateStory.d.ts +7 -0
  105. package/dist/story-generator/generateStory.d.ts.map +1 -0
  106. package/dist/story-generator/gitignoreManager.d.ts +50 -0
  107. package/dist/story-generator/gitignoreManager.d.ts.map +1 -0
  108. package/dist/story-generator/gitignoreManager.js +7 -6
  109. package/dist/story-generator/imageProcessor.d.ts +80 -0
  110. package/dist/story-generator/imageProcessor.d.ts.map +1 -0
  111. package/dist/story-generator/imageProcessor.js +391 -0
  112. package/dist/story-generator/inMemoryStoryService.d.ts +89 -0
  113. package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
  114. package/dist/story-generator/llm-providers/base-provider.d.ts +36 -0
  115. package/dist/story-generator/llm-providers/base-provider.d.ts.map +1 -0
  116. package/dist/story-generator/llm-providers/base-provider.js +135 -0
  117. package/dist/story-generator/llm-providers/claude-provider.d.ts +23 -0
  118. package/dist/story-generator/llm-providers/claude-provider.d.ts.map +1 -0
  119. package/dist/story-generator/llm-providers/claude-provider.js +414 -0
  120. package/dist/story-generator/llm-providers/gemini-provider.d.ts +24 -0
  121. package/dist/story-generator/llm-providers/gemini-provider.d.ts.map +1 -0
  122. package/dist/story-generator/llm-providers/gemini-provider.js +406 -0
  123. package/dist/story-generator/llm-providers/index.d.ts +63 -0
  124. package/dist/story-generator/llm-providers/index.d.ts.map +1 -0
  125. package/dist/story-generator/llm-providers/index.js +169 -0
  126. package/dist/story-generator/llm-providers/openai-provider.d.ts +24 -0
  127. package/dist/story-generator/llm-providers/openai-provider.d.ts.map +1 -0
  128. package/dist/story-generator/llm-providers/openai-provider.js +458 -0
  129. package/dist/story-generator/llm-providers/settings-manager.d.ts +75 -0
  130. package/dist/story-generator/llm-providers/settings-manager.d.ts.map +1 -0
  131. package/dist/story-generator/llm-providers/settings-manager.js +173 -0
  132. package/dist/story-generator/llm-providers/story-llm-service.d.ts +79 -0
  133. package/dist/story-generator/llm-providers/story-llm-service.d.ts.map +1 -0
  134. package/dist/story-generator/llm-providers/story-llm-service.js +240 -0
  135. package/dist/story-generator/llm-providers/types.d.ts +153 -0
  136. package/dist/story-generator/llm-providers/types.d.ts.map +1 -0
  137. package/dist/story-generator/llm-providers/types.js +8 -0
  138. package/dist/story-generator/logger.d.ts +14 -0
  139. package/dist/story-generator/logger.d.ts.map +1 -0
  140. package/dist/story-generator/logger.js +119 -0
  141. package/dist/story-generator/postProcessStory.d.ts +6 -0
  142. package/dist/story-generator/postProcessStory.d.ts.map +1 -0
  143. package/dist/story-generator/postProcessStory.js +8 -7
  144. package/dist/story-generator/productionGitignoreManager.d.ts +91 -0
  145. package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
  146. package/dist/story-generator/productionGitignoreManager.js +11 -10
  147. package/dist/story-generator/promptGenerator.d.ts +48 -0
  148. package/dist/story-generator/promptGenerator.d.ts.map +1 -0
  149. package/dist/story-generator/promptGenerator.js +186 -1
  150. package/dist/story-generator/storyHistory.d.ts +44 -0
  151. package/dist/story-generator/storyHistory.d.ts.map +1 -0
  152. package/dist/story-generator/storySync.d.ts +68 -0
  153. package/dist/story-generator/storySync.d.ts.map +1 -0
  154. package/dist/story-generator/storyTracker.d.ts +48 -0
  155. package/dist/story-generator/storyTracker.d.ts.map +1 -0
  156. package/dist/story-generator/storyTracker.js +2 -1
  157. package/dist/story-generator/storyValidator.d.ts +6 -0
  158. package/dist/story-generator/storyValidator.d.ts.map +1 -0
  159. package/dist/story-generator/universalDesignSystemAdapter.d.ts +68 -0
  160. package/dist/story-generator/universalDesignSystemAdapter.d.ts.map +1 -0
  161. package/dist/story-generator/universalDesignSystemAdapter.js +141 -3
  162. package/dist/story-generator/urlRedirectService.d.ts +21 -0
  163. package/dist/story-generator/urlRedirectService.d.ts.map +1 -0
  164. package/dist/story-generator/urlRedirectService.js +140 -0
  165. package/dist/story-generator/validateStory.d.ts +19 -0
  166. package/dist/story-generator/validateStory.d.ts.map +1 -0
  167. package/dist/story-generator/validateStory.js +6 -2
  168. package/dist/story-generator/visionPrompts.d.ts +88 -0
  169. package/dist/story-generator/visionPrompts.d.ts.map +1 -0
  170. package/dist/story-generator/visionPrompts.js +462 -0
  171. package/dist/story-ui.config.d.ts +78 -0
  172. package/dist/story-ui.config.d.ts.map +1 -0
  173. package/dist/templates/StoryUI/StoryUIPanel.d.ts +4 -0
  174. package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -0
  175. package/dist/templates/StoryUI/StoryUIPanel.js +1874 -0
  176. package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts +18 -0
  177. package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts.map +1 -0
  178. package/dist/templates/StoryUI/StoryUIPanel.stories.js +37 -0
  179. package/dist/templates/StoryUI/index.d.ts +3 -0
  180. package/dist/templates/StoryUI/index.d.ts.map +1 -0
  181. package/dist/templates/StoryUI/index.js +2 -0
  182. package/package.json +35 -4
  183. package/templates/StoryUI/StoryUIPanel.tsx +1973 -388
  184. package/templates/StoryUI/index.tsx +1 -1
  185. package/templates/StoryUI/manager.tsx +264 -0
  186. package/templates/mcp-config-claude.json +11 -0
  187. package/templates/mcp-example.md +76 -0
  188. package/templates/production-app/.env.example +11 -0
  189. package/templates/production-app/index.html +66 -0
  190. package/templates/production-app/package.json +30 -0
  191. package/templates/production-app/public/favicon.svg +5 -0
  192. package/templates/production-app/src/App.tsx +1157 -0
  193. package/templates/production-app/src/LivePreviewRenderer.tsx +420 -0
  194. package/templates/production-app/src/componentRegistry.ts +315 -0
  195. package/templates/production-app/src/considerations.ts +16 -0
  196. package/templates/production-app/src/index.css +284 -0
  197. package/templates/production-app/src/main.tsx +25 -0
  198. package/templates/production-app/tsconfig.json +32 -0
  199. package/templates/production-app/tsconfig.node.json +11 -0
  200. package/templates/production-app/vite.config.ts +83 -0
  201. package/templates/react-import-rule.json +2 -2
  202. package/dist/index.js +0 -12
  203. package/dist/story-ui.config.loader.js +0 -205
@@ -0,0 +1,427 @@
1
+ /**
2
+ * Angular Framework Adapter
3
+ *
4
+ * Generates Storybook stories for Angular components.
5
+ * Supports standalone components and module-based components.
6
+ */
7
+ import { BaseFrameworkAdapter } from './base-adapter.js';
8
+ export class AngularAdapter extends BaseFrameworkAdapter {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.type = 'angular';
12
+ this.name = 'Angular';
13
+ this.supportedStoryFrameworks = [
14
+ 'storybook-angular',
15
+ 'chromatic',
16
+ ];
17
+ this.defaultExtension = '.stories.ts';
18
+ }
19
+ generateSystemPrompt(config, options) {
20
+ if (config.systemPrompt) {
21
+ return config.systemPrompt;
22
+ }
23
+ const componentSystemName = config.componentPrefix
24
+ ? `${config.componentPrefix.replace(/^[A-Z]+/, '')} design system`
25
+ : 'component library';
26
+ return `You are an expert Angular developer creating Storybook stories using CSF 3.0 format.
27
+ Use ONLY the Angular components from the ${componentSystemName} listed below.
28
+
29
+ MANDATORY IMPORTS - First lines of every story file:
30
+ 1. import type { Meta, StoryObj } from '@storybook/angular';
31
+ 2. import { ComponentName } from '${config.importPath || 'your-library'}';
32
+
33
+ ANGULAR STORY FORMAT:
34
+ - Use moduleMetadata for imports and providers
35
+ - Components can be standalone or module-based
36
+ - Use applicationConfig for standalone components
37
+
38
+ STORY STRUCTURE (CSF 3.0):
39
+ - Meta object with component, title, and decorators
40
+ - Use render function for template customization
41
+ - Export named stories as StoryObj
42
+
43
+ CRITICAL RULES:
44
+ - Import modules/components in moduleMetadata or applicationConfig
45
+ - Use Angular template syntax in render functions
46
+ - Event bindings use (event) syntax
47
+
48
+ Example structure (Standalone Components):
49
+ \`\`\`typescript
50
+ import type { Meta, StoryObj } from '@storybook/angular';
51
+ import { applicationConfig, argsToTemplate } from '@storybook/angular';
52
+ import { ButtonComponent } from 'your-library';
53
+
54
+ const meta: Meta<ButtonComponent> = {
55
+ title: 'Components/Button',
56
+ component: ButtonComponent,
57
+ tags: ['autodocs'],
58
+ decorators: [
59
+ applicationConfig({
60
+ providers: [],
61
+ }),
62
+ ],
63
+ argTypes: {
64
+ variant: {
65
+ control: 'select',
66
+ options: ['primary', 'secondary', 'ghost'],
67
+ },
68
+ },
69
+ };
70
+
71
+ export default meta;
72
+ type Story = StoryObj<ButtonComponent>;
73
+
74
+ export const Primary: Story = {
75
+ args: {
76
+ variant: 'primary',
77
+ label: 'Click me',
78
+ },
79
+ };
80
+
81
+ export const WithContent: Story = {
82
+ render: (args) => ({
83
+ props: args,
84
+ template: \`
85
+ <app-button [variant]="variant">
86
+ <span class="icon">★</span>
87
+ Click me
88
+ </app-button>
89
+ \`,
90
+ }),
91
+ };
92
+ \`\`\`
93
+
94
+ Example structure (Module-based Components):
95
+ \`\`\`typescript
96
+ import type { Meta, StoryObj } from '@storybook/angular';
97
+ import { moduleMetadata } from '@storybook/angular';
98
+ import { ButtonModule } from 'your-library';
99
+
100
+ const meta: Meta = {
101
+ title: 'Components/Button',
102
+ decorators: [
103
+ moduleMetadata({
104
+ imports: [ButtonModule],
105
+ }),
106
+ ],
107
+ argTypes: {
108
+ variant: {
109
+ control: 'select',
110
+ options: ['primary', 'secondary', 'ghost'],
111
+ },
112
+ },
113
+ };
114
+
115
+ export default meta;
116
+ type Story = StoryObj;
117
+
118
+ export const Primary: Story = {
119
+ render: (args) => ({
120
+ props: args,
121
+ template: \`<app-button [variant]="variant">Click me</app-button>\`,
122
+ }),
123
+ };
124
+ \`\`\`
125
+
126
+ ANGULAR TEMPLATE SYNTAX:
127
+ - Property binding: [property]="value"
128
+ - Event binding: (event)="handler($event)"
129
+ - Two-way binding: [(ngModel)]="value"
130
+ - Structural directives: *ngIf, *ngFor, *ngSwitch
131
+
132
+ CONTENT PROJECTION (ng-content):
133
+ - Default slot: Content between tags
134
+ - Named slots: Use ngProjectAs or select attribute
135
+
136
+ ${this.getCommonRules()}`;
137
+ }
138
+ generateExamples(config) {
139
+ const lib = config.importPath || 'your-library';
140
+ return `
141
+ ## Example Stories for Angular
142
+
143
+ ### Standalone Component
144
+ \`\`\`typescript
145
+ import type { Meta, StoryObj } from '@storybook/angular';
146
+ import { applicationConfig } from '@storybook/angular';
147
+ import { ButtonComponent } from 'your-library';
148
+
149
+ const meta: Meta<ButtonComponent> = {
150
+ title: 'Components/Button',
151
+ component: ButtonComponent,
152
+ tags: ['autodocs'],
153
+ decorators: [
154
+ applicationConfig({
155
+ providers: [],
156
+ }),
157
+ ],
158
+ argTypes: {
159
+ variant: {
160
+ control: 'select',
161
+ options: ['primary', 'secondary', 'ghost'],
162
+ },
163
+ size: {
164
+ control: 'select',
165
+ options: ['small', 'medium', 'large'],
166
+ },
167
+ },
168
+ };
169
+
170
+ export default meta;
171
+ type Story = StoryObj<ButtonComponent>;
172
+
173
+ export const Default: Story = {
174
+ args: {
175
+ variant: 'primary',
176
+ size: 'medium',
177
+ label: 'Button',
178
+ },
179
+ };
180
+
181
+ export const AllVariants: Story = {
182
+ render: () => ({
183
+ template: \`
184
+ <div style="display: flex; gap: 8px;">
185
+ <app-button variant="primary">Primary</app-button>
186
+ <app-button variant="secondary">Secondary</app-button>
187
+ <app-button variant="ghost">Ghost</app-button>
188
+ </div>
189
+ \`,
190
+ }),
191
+ };
192
+ \`\`\`
193
+
194
+ ### Module-based Component
195
+ \`\`\`typescript
196
+ import type { Meta, StoryObj } from '@storybook/angular';
197
+ import { moduleMetadata } from '@storybook/angular';
198
+ import { CardModule, ButtonModule } from '${lib}';
199
+
200
+ const meta: Meta = {
201
+ title: 'Components/Card',
202
+ decorators: [
203
+ moduleMetadata({
204
+ imports: [CardModule, ButtonModule],
205
+ }),
206
+ ],
207
+ };
208
+
209
+ export default meta;
210
+ type Story = StoryObj;
211
+
212
+ export const ProductCard: Story = {
213
+ render: () => ({
214
+ template: \`
215
+ <app-card style="width: 300px">
216
+ <img appCardImage src="https://picsum.photos/300/200" alt="Product">
217
+ <h3 appCardTitle>Product Name</h3>
218
+ <p appCardContent>$99.00</p>
219
+ <app-button appCardAction variant="primary">Add to Cart</app-button>
220
+ </app-card>
221
+ \`,
222
+ }),
223
+ };
224
+ \`\`\`
225
+
226
+ ### With Event Handling
227
+ \`\`\`typescript
228
+ import type { Meta, StoryObj } from '@storybook/angular';
229
+ import { applicationConfig } from '@storybook/angular';
230
+ import { action } from '@storybook/addon-actions';
231
+ import { ButtonComponent } from 'your-library';
232
+
233
+ const meta: Meta<ButtonComponent> = {
234
+ title: 'Components/Button',
235
+ component: ButtonComponent,
236
+ decorators: [
237
+ applicationConfig({
238
+ providers: [],
239
+ }),
240
+ ],
241
+ };
242
+
243
+ export default meta;
244
+ type Story = StoryObj<ButtonComponent>;
245
+
246
+ export const WithClick: Story = {
247
+ render: () => ({
248
+ props: {
249
+ onClick: action('button-click'),
250
+ },
251
+ template: \`
252
+ <app-button (click)="onClick($event)" variant="primary">
253
+ Click me
254
+ </app-button>
255
+ \`,
256
+ }),
257
+ };
258
+ \`\`\`
259
+
260
+ ### With Forms
261
+ \`\`\`typescript
262
+ import type { Meta, StoryObj } from '@storybook/angular';
263
+ import { moduleMetadata } from '@storybook/angular';
264
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
265
+ import { InputModule } from '${lib}';
266
+
267
+ const meta: Meta = {
268
+ title: 'Components/Input',
269
+ decorators: [
270
+ moduleMetadata({
271
+ imports: [FormsModule, ReactiveFormsModule, InputModule],
272
+ }),
273
+ ],
274
+ };
275
+
276
+ export default meta;
277
+ type Story = StoryObj;
278
+
279
+ export const WithNgModel: Story = {
280
+ render: () => ({
281
+ props: {
282
+ value: '',
283
+ },
284
+ template: \`
285
+ <div>
286
+ <app-input [(ngModel)]="value" placeholder="Type here..."></app-input>
287
+ <p>Value: {{ value }}</p>
288
+ </div>
289
+ \`,
290
+ }),
291
+ };
292
+ \`\`\`
293
+ `;
294
+ }
295
+ generateSampleStory(config, components) {
296
+ const lib = config.importPath || 'your-library';
297
+ const firstComponent = components[0];
298
+ if (!firstComponent) {
299
+ return `
300
+ import type { Meta, StoryObj } from '@storybook/angular';
301
+
302
+ const meta: Meta = {
303
+ title: 'Examples/Sample',
304
+ parameters: { layout: 'centered' },
305
+ };
306
+
307
+ export default meta;
308
+ type Story = StoryObj;
309
+
310
+ export const Default: Story = {
311
+ render: () => ({
312
+ template: '<div>Sample story content</div>',
313
+ }),
314
+ };
315
+ `;
316
+ }
317
+ // Convert PascalCase to kebab-case for selector
318
+ const selector = this.toKebabCase(firstComponent.name);
319
+ return `
320
+ import type { Meta, StoryObj } from '@storybook/angular';
321
+ import { applicationConfig } from '@storybook/angular';
322
+ import { ${firstComponent.name}Component } from '${lib}';
323
+
324
+ const meta: Meta<${firstComponent.name}Component> = {
325
+ title: 'Components/${firstComponent.name}',
326
+ component: ${firstComponent.name}Component,
327
+ tags: ['autodocs'],
328
+ decorators: [
329
+ applicationConfig({
330
+ providers: [],
331
+ }),
332
+ ],
333
+ parameters: { layout: 'centered' },
334
+ };
335
+
336
+ export default meta;
337
+ type Story = StoryObj<${firstComponent.name}Component>;
338
+
339
+ export const Default: Story = {
340
+ args: {},
341
+ };
342
+ `;
343
+ }
344
+ getStoryTemplate(options) {
345
+ return `
346
+ // {{componentName}}.stories.ts
347
+ import type { Meta, StoryObj } from '@storybook/angular';
348
+ import { applicationConfig } from '@storybook/angular';
349
+ import { {{componentName}}Component } from '{{importPath}}';
350
+
351
+ const meta: Meta<{{componentName}}Component> = {
352
+ title: '{{category}}/{{componentName}}',
353
+ component: {{componentName}}Component,
354
+ tags: ['autodocs'],
355
+ decorators: [
356
+ applicationConfig({
357
+ providers: [],
358
+ }),
359
+ ],
360
+ parameters: { layout: 'centered' },
361
+ };
362
+
363
+ export default meta;
364
+ type Story = StoryObj<{{componentName}}Component>;
365
+
366
+ export const Default: Story = {
367
+ args: {},
368
+ };
369
+ `;
370
+ }
371
+ /**
372
+ * Convert PascalCase to kebab-case for selectors
373
+ */
374
+ toKebabCase(str) {
375
+ return str
376
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
377
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
378
+ .toLowerCase();
379
+ }
380
+ /**
381
+ * Post-process Angular stories
382
+ */
383
+ postProcess(storyContent) {
384
+ let processed = super.postProcess(storyContent);
385
+ // Remove React imports if present
386
+ processed = processed.replace(/import React from ['"]react['"];?\n?/g, '');
387
+ // Fix JSX to Angular template syntax
388
+ processed = processed
389
+ // Fix className to class
390
+ .replace(/className=/g, 'class=')
391
+ // Fix onClick to (click)
392
+ .replace(/onClick=/g, '(click)=')
393
+ .replace(/onChange=/g, '(change)=')
394
+ .replace(/onInput=/g, '(input)=');
395
+ return processed;
396
+ }
397
+ /**
398
+ * Validate Angular story
399
+ */
400
+ validate(storyContent) {
401
+ const baseValidation = super.validate(storyContent);
402
+ const errors = [...baseValidation.errors];
403
+ // Angular-specific validations
404
+ if (!storyContent.includes('@storybook/angular')) {
405
+ errors.push("Missing '@storybook/angular' import");
406
+ }
407
+ if (storyContent.includes("import React from 'react'")) {
408
+ errors.push('React import found in Angular story');
409
+ }
410
+ // Check for neither moduleMetadata nor applicationConfig
411
+ if (!storyContent.includes('moduleMetadata') &&
412
+ !storyContent.includes('applicationConfig') &&
413
+ !storyContent.includes('component:')) {
414
+ errors.push('Missing moduleMetadata or applicationConfig decorator');
415
+ }
416
+ return {
417
+ valid: errors.length === 0,
418
+ errors,
419
+ };
420
+ }
421
+ }
422
+ /**
423
+ * Factory function
424
+ */
425
+ export function createAngularAdapter() {
426
+ return new AngularAdapter();
427
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Base Framework Adapter
3
+ *
4
+ * Abstract base class that provides common functionality for all
5
+ * framework-specific adapters. Subclasses implement framework-specific
6
+ * prompt generation and story templates.
7
+ */
8
+ import { FrameworkType, StoryFramework, FrameworkAdapter, StoryGenerationOptions } from './types.js';
9
+ import { StoryUIConfig } from '../../story-ui.config.js';
10
+ import { DiscoveredComponent } from '../componentDiscovery.js';
11
+ /**
12
+ * Abstract Base Framework Adapter
13
+ */
14
+ export declare abstract class BaseFrameworkAdapter implements FrameworkAdapter {
15
+ abstract readonly type: FrameworkType;
16
+ abstract readonly name: string;
17
+ abstract readonly supportedStoryFrameworks: StoryFramework[];
18
+ abstract readonly defaultExtension: string;
19
+ /**
20
+ * Generate the system prompt for this framework
21
+ */
22
+ abstract generateSystemPrompt(config: StoryUIConfig, options?: StoryGenerationOptions): string;
23
+ /**
24
+ * Generate component reference documentation
25
+ */
26
+ generateComponentReference(components: DiscoveredComponent[], config: StoryUIConfig): string;
27
+ /**
28
+ * Format a single component entry
29
+ */
30
+ protected formatComponentEntry(component: DiscoveredComponent, config: StoryUIConfig): string;
31
+ /**
32
+ * Get the import path for a component
33
+ */
34
+ protected getImportPath(component: DiscoveredComponent, config: StoryUIConfig): string;
35
+ /**
36
+ * Group components by their category
37
+ */
38
+ protected groupComponentsByPackage(components: DiscoveredComponent[]): Record<string, DiscoveredComponent[]>;
39
+ /**
40
+ * Generate example stories - framework specific
41
+ */
42
+ abstract generateExamples(config: StoryUIConfig): string;
43
+ /**
44
+ * Generate a sample story template - framework specific
45
+ */
46
+ abstract generateSampleStory(config: StoryUIConfig, components: DiscoveredComponent[]): string;
47
+ /**
48
+ * Generate import statements for components
49
+ */
50
+ generateImports(components: DiscoveredComponent[], config: StoryUIConfig): string;
51
+ /**
52
+ * Post-process generated story content
53
+ */
54
+ postProcess(storyContent: string): string;
55
+ /**
56
+ * Validate generated story syntax
57
+ */
58
+ validate(storyContent: string): {
59
+ valid: boolean;
60
+ errors: string[];
61
+ };
62
+ /**
63
+ * Get the story file template - framework specific
64
+ */
65
+ abstract getStoryTemplate(options?: StoryGenerationOptions): string;
66
+ /**
67
+ * Log adapter activity
68
+ */
69
+ protected log(message: string, data?: Record<string, unknown>): void;
70
+ /**
71
+ * Get common story structure rules
72
+ */
73
+ protected getCommonRules(): string;
74
+ }
75
+ //# sourceMappingURL=base-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-adapter.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/base-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,gBAAgB;IACpE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,wBAAwB,EAAE,cAAc,EAAE,CAAC;IAC7D,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,oBAAoB,CAC3B,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM;IAET;;OAEG;IACH,0BAA0B,CACxB,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,aAAa,GACpB,MAAM;IAmBT;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAC5B,SAAS,EAAE,mBAAmB,EAC9B,MAAM,EAAE,aAAa,GACpB,MAAM;IAkBT;;OAEG;IACH,SAAS,CAAC,aAAa,CACrB,SAAS,EAAE,mBAAmB,EAC9B,MAAM,EAAE,aAAa,GACpB,MAAM;IAUT;;OAEG;IACH,SAAS,CAAC,wBAAwB,CAChC,UAAU,EAAE,mBAAmB,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAcxC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAExD;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,GAChC,MAAM;IAET;;OAEG;IACH,eAAe,CACb,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,aAAa,GACpB,MAAM;IAoBT;;OAEG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAQzC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAkBpE;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAEnE;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpE;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,MAAM;CAoBnC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Base Framework Adapter
3
+ *
4
+ * Abstract base class that provides common functionality for all
5
+ * framework-specific adapters. Subclasses implement framework-specific
6
+ * prompt generation and story templates.
7
+ */
8
+ import { logger } from '../logger.js';
9
+ /**
10
+ * Abstract Base Framework Adapter
11
+ */
12
+ export class BaseFrameworkAdapter {
13
+ /**
14
+ * Generate component reference documentation
15
+ */
16
+ generateComponentReference(components, config) {
17
+ if (components.length === 0) {
18
+ return 'No components discovered.';
19
+ }
20
+ const groupedComponents = this.groupComponentsByPackage(components);
21
+ const sections = [];
22
+ for (const [packageName, pkgComponents] of Object.entries(groupedComponents)) {
23
+ const componentList = pkgComponents
24
+ .map(comp => this.formatComponentEntry(comp, config))
25
+ .join('\n');
26
+ sections.push(`## ${packageName}\n${componentList}`);
27
+ }
28
+ return `# Available Components\n\n${sections.join('\n\n')}`;
29
+ }
30
+ /**
31
+ * Format a single component entry
32
+ */
33
+ formatComponentEntry(component, config) {
34
+ const importPath = this.getImportPath(component, config);
35
+ let entry = `- **${component.name}** (import from '${importPath}')`;
36
+ if (component.props && component.props.length > 0) {
37
+ const propsList = component.props
38
+ .slice(0, 5) // Limit to first 5 props
39
+ .join(', ');
40
+ entry += `\n Props: ${propsList}${component.props.length > 5 ? '...' : ''}`;
41
+ }
42
+ if (component.description) {
43
+ entry += `\n ${component.description}`;
44
+ }
45
+ return entry;
46
+ }
47
+ /**
48
+ * Get the import path for a component
49
+ */
50
+ getImportPath(component, config) {
51
+ // Use component's __componentPath if available
52
+ if (component.__componentPath) {
53
+ return component.__componentPath;
54
+ }
55
+ // Fall back to import path from config
56
+ return config.importPath || 'unknown';
57
+ }
58
+ /**
59
+ * Group components by their category
60
+ */
61
+ groupComponentsByPackage(components) {
62
+ const grouped = {};
63
+ for (const component of components) {
64
+ const category = component.category || 'other';
65
+ if (!grouped[category]) {
66
+ grouped[category] = [];
67
+ }
68
+ grouped[category].push(component);
69
+ }
70
+ return grouped;
71
+ }
72
+ /**
73
+ * Generate import statements for components
74
+ */
75
+ generateImports(components, config) {
76
+ const importsByPath = new Map();
77
+ for (const component of components) {
78
+ const importPath = this.getImportPath(component, config);
79
+ if (!importsByPath.has(importPath)) {
80
+ importsByPath.set(importPath, new Set());
81
+ }
82
+ importsByPath.get(importPath).add(component.name);
83
+ }
84
+ const imports = [];
85
+ for (const [path, names] of importsByPath) {
86
+ const namedImports = Array.from(names).sort().join(', ');
87
+ imports.push(`import { ${namedImports} } from '${path}';`);
88
+ }
89
+ return imports.join('\n');
90
+ }
91
+ /**
92
+ * Post-process generated story content
93
+ */
94
+ postProcess(storyContent) {
95
+ // Default implementation - can be overridden by subclasses
96
+ return storyContent
97
+ .trim()
98
+ .replace(/\r\n/g, '\n')
99
+ .replace(/\n{3,}/g, '\n\n');
100
+ }
101
+ /**
102
+ * Validate generated story syntax
103
+ */
104
+ validate(storyContent) {
105
+ const errors = [];
106
+ if (!storyContent || storyContent.trim().length === 0) {
107
+ errors.push('Story content is empty');
108
+ }
109
+ // Check for common issues
110
+ if (!storyContent.includes('export')) {
111
+ errors.push('Story missing exports');
112
+ }
113
+ return {
114
+ valid: errors.length === 0,
115
+ errors,
116
+ };
117
+ }
118
+ /**
119
+ * Log adapter activity
120
+ */
121
+ log(message, data) {
122
+ logger.debug(`[${this.name}Adapter] ${message}`, data);
123
+ }
124
+ /**
125
+ * Get common story structure rules
126
+ */
127
+ getCommonRules() {
128
+ return `
129
+ GENERAL RULES:
130
+ - Follow the component library's design patterns
131
+ - Use meaningful story names that describe the variant
132
+ - Include multiple stories showing different states/variants
133
+ - Ensure accessibility by using proper ARIA attributes
134
+ - Use realistic placeholder content
135
+
136
+ IMAGE RULES:
137
+ - Use Lorem Picsum for placeholder images: https://picsum.photos/[width]/[height]
138
+ - Always include alt text for images
139
+ - Example: https://picsum.photos/400/300?random=1
140
+
141
+ SPACING RULES:
142
+ - Use the design system's spacing tokens when available
143
+ - Maintain consistent margins and padding
144
+ - Follow the layout grid system if present
145
+ `;
146
+ }
147
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Framework Detection System
3
+ *
4
+ * Automatically detects the component framework and story framework
5
+ * used in a project by analyzing package.json, config files, and
6
+ * file patterns.
7
+ */
8
+ import { FrameworkType, FrameworkDetectionResult } from './types.js';
9
+ /**
10
+ * Framework Detector Class
11
+ */
12
+ export declare class FrameworkDetector {
13
+ private projectRoot;
14
+ private packageJson;
15
+ private dependencies;
16
+ private detectedConfigFiles;
17
+ constructor(projectRoot?: string);
18
+ /**
19
+ * Detect frameworks used in the project
20
+ */
21
+ detect(): Promise<FrameworkDetectionResult>;
22
+ /**
23
+ * Load and parse package.json
24
+ */
25
+ private loadPackageJson;
26
+ /**
27
+ * Scan for framework configuration files
28
+ */
29
+ private scanConfigFiles;
30
+ /**
31
+ * Score each framework pattern based on evidence
32
+ */
33
+ private scoreFrameworks;
34
+ /**
35
+ * Get framework version from dependencies
36
+ */
37
+ private getFrameworkVersion;
38
+ /**
39
+ * Get framework-specific configuration
40
+ */
41
+ private getFrameworkConfig;
42
+ /**
43
+ * Quick check for a specific framework
44
+ */
45
+ hasFramework(framework: FrameworkType): boolean;
46
+ }
47
+ /**
48
+ * Factory function for framework detection
49
+ */
50
+ export declare function detectFramework(projectRoot?: string): Promise<FrameworkDetectionResult>;
51
+ /**
52
+ * Get framework detector instance
53
+ */
54
+ export declare function getFrameworkDetector(projectRoot?: string): FrameworkDetector;
55
+ //# sourceMappingURL=framework-detector.d.ts.map