@tpitre/story-ui 2.2.0 → 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.
- package/.env.sample +82 -11
- package/README.md +89 -0
- package/dist/cli/deploy.d.ts +17 -0
- package/dist/cli/deploy.d.ts.map +1 -0
- package/dist/cli/deploy.js +696 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +26 -2
- package/dist/cli/setup.d.ts +11 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +437 -110
- package/dist/mcp-server/index.d.ts +2 -0
- package/dist/mcp-server/index.d.ts.map +1 -0
- package/dist/mcp-server/index.js +120 -2
- package/dist/mcp-server/mcp-stdio-server.d.ts +3 -0
- package/dist/mcp-server/mcp-stdio-server.d.ts.map +1 -0
- package/dist/mcp-server/mcp-stdio-server.js +8 -1
- package/dist/mcp-server/routes/claude.d.ts +3 -0
- package/dist/mcp-server/routes/claude.d.ts.map +1 -0
- package/dist/mcp-server/routes/claude.js +60 -23
- package/dist/mcp-server/routes/components.d.ts +4 -0
- package/dist/mcp-server/routes/components.d.ts.map +1 -0
- package/dist/mcp-server/routes/frameworks.d.ts +38 -0
- package/dist/mcp-server/routes/frameworks.d.ts.map +1 -0
- package/dist/mcp-server/routes/frameworks.js +183 -0
- package/dist/mcp-server/routes/generateStory.d.ts +3 -0
- package/dist/mcp-server/routes/generateStory.d.ts.map +1 -0
- package/dist/mcp-server/routes/generateStory.js +160 -76
- package/dist/mcp-server/routes/generateStoryStream.d.ts +12 -0
- package/dist/mcp-server/routes/generateStoryStream.d.ts.map +1 -0
- package/dist/mcp-server/routes/generateStoryStream.js +947 -0
- package/dist/mcp-server/routes/hybridStories.d.ts +18 -0
- package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/mcpRemote.d.ts +14 -0
- package/dist/mcp-server/routes/mcpRemote.d.ts.map +1 -0
- package/dist/mcp-server/routes/mcpRemote.js +489 -0
- package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
- package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/providers.d.ts +89 -0
- package/dist/mcp-server/routes/providers.d.ts.map +1 -0
- package/dist/mcp-server/routes/providers.js +369 -0
- package/dist/mcp-server/routes/storySync.d.ts +26 -0
- package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
- package/dist/mcp-server/routes/streamTypes.d.ts +110 -0
- package/dist/mcp-server/routes/streamTypes.d.ts.map +1 -0
- package/dist/mcp-server/routes/streamTypes.js +18 -0
- package/dist/mcp-server/sessionManager.d.ts +50 -0
- package/dist/mcp-server/sessionManager.d.ts.map +1 -0
- package/dist/story-generator/componentBlacklist.d.ts +21 -0
- package/dist/story-generator/componentBlacklist.d.ts.map +1 -0
- package/dist/story-generator/componentDiscovery.d.ts +28 -0
- package/dist/story-generator/componentDiscovery.d.ts.map +1 -0
- package/dist/story-generator/componentRegistryGenerator.d.ts +49 -0
- package/dist/story-generator/componentRegistryGenerator.d.ts.map +1 -0
- package/dist/story-generator/componentRegistryGenerator.js +205 -0
- package/dist/story-generator/configLoader.d.ts +33 -0
- package/dist/story-generator/configLoader.d.ts.map +1 -0
- package/dist/story-generator/considerationsLoader.d.ts +32 -0
- package/dist/story-generator/considerationsLoader.d.ts.map +1 -0
- package/dist/story-generator/documentation-sources.d.ts +28 -0
- package/dist/story-generator/documentation-sources.d.ts.map +1 -0
- package/dist/story-generator/documentationLoader.d.ts +64 -0
- package/dist/story-generator/documentationLoader.d.ts.map +1 -0
- package/dist/story-generator/dynamicPackageDiscovery.d.ts +97 -0
- package/dist/story-generator/dynamicPackageDiscovery.d.ts.map +1 -0
- package/dist/story-generator/enhancedComponentDiscovery.d.ts +125 -0
- package/dist/story-generator/enhancedComponentDiscovery.d.ts.map +1 -0
- package/dist/story-generator/enhancedComponentDiscovery.js +111 -11
- package/dist/story-generator/framework-adapters/angular-adapter.d.ts +40 -0
- package/dist/story-generator/framework-adapters/angular-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/angular-adapter.js +427 -0
- package/dist/story-generator/framework-adapters/base-adapter.d.ts +75 -0
- package/dist/story-generator/framework-adapters/base-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/base-adapter.js +147 -0
- package/dist/story-generator/framework-adapters/framework-detector.d.ts +55 -0
- package/dist/story-generator/framework-adapters/framework-detector.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/framework-detector.js +323 -0
- package/dist/story-generator/framework-adapters/index.d.ts +97 -0
- package/dist/story-generator/framework-adapters/index.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/index.js +198 -0
- package/dist/story-generator/framework-adapters/react-adapter.d.ts +40 -0
- package/dist/story-generator/framework-adapters/react-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/react-adapter.js +316 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.d.ts +40 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.js +372 -0
- package/dist/story-generator/framework-adapters/types.d.ts +182 -0
- package/dist/story-generator/framework-adapters/types.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/types.js +8 -0
- package/dist/story-generator/framework-adapters/vue-adapter.d.ts +36 -0
- package/dist/story-generator/framework-adapters/vue-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/vue-adapter.js +336 -0
- package/dist/story-generator/framework-adapters/web-components-adapter.d.ts +54 -0
- package/dist/story-generator/framework-adapters/web-components-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/web-components-adapter.js +387 -0
- package/dist/story-generator/generateStory.d.ts +7 -0
- package/dist/story-generator/generateStory.d.ts.map +1 -0
- package/dist/story-generator/gitignoreManager.d.ts +50 -0
- package/dist/story-generator/gitignoreManager.d.ts.map +1 -0
- package/dist/story-generator/imageProcessor.d.ts +80 -0
- package/dist/story-generator/imageProcessor.d.ts.map +1 -0
- package/dist/story-generator/imageProcessor.js +391 -0
- package/dist/story-generator/inMemoryStoryService.d.ts +89 -0
- package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/base-provider.d.ts +36 -0
- package/dist/story-generator/llm-providers/base-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/base-provider.js +135 -0
- package/dist/story-generator/llm-providers/claude-provider.d.ts +23 -0
- package/dist/story-generator/llm-providers/claude-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/claude-provider.js +414 -0
- package/dist/story-generator/llm-providers/gemini-provider.d.ts +24 -0
- package/dist/story-generator/llm-providers/gemini-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/gemini-provider.js +406 -0
- package/dist/story-generator/llm-providers/index.d.ts +63 -0
- package/dist/story-generator/llm-providers/index.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/index.js +169 -0
- package/dist/story-generator/llm-providers/openai-provider.d.ts +24 -0
- package/dist/story-generator/llm-providers/openai-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/openai-provider.js +458 -0
- package/dist/story-generator/llm-providers/settings-manager.d.ts +75 -0
- package/dist/story-generator/llm-providers/settings-manager.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/settings-manager.js +173 -0
- package/dist/story-generator/llm-providers/story-llm-service.d.ts +79 -0
- package/dist/story-generator/llm-providers/story-llm-service.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/story-llm-service.js +240 -0
- package/dist/story-generator/llm-providers/types.d.ts +153 -0
- package/dist/story-generator/llm-providers/types.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/types.js +8 -0
- package/dist/story-generator/logger.d.ts +14 -0
- package/dist/story-generator/logger.d.ts.map +1 -0
- package/dist/story-generator/logger.js +96 -29
- package/dist/story-generator/postProcessStory.d.ts +6 -0
- package/dist/story-generator/postProcessStory.d.ts.map +1 -0
- package/dist/story-generator/productionGitignoreManager.d.ts +91 -0
- package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
- package/dist/story-generator/promptGenerator.d.ts +48 -0
- package/dist/story-generator/promptGenerator.d.ts.map +1 -0
- package/dist/story-generator/promptGenerator.js +186 -1
- package/dist/story-generator/storyHistory.d.ts +44 -0
- package/dist/story-generator/storyHistory.d.ts.map +1 -0
- package/dist/story-generator/storySync.d.ts +68 -0
- package/dist/story-generator/storySync.d.ts.map +1 -0
- package/dist/story-generator/storyTracker.d.ts +48 -0
- package/dist/story-generator/storyTracker.d.ts.map +1 -0
- package/dist/story-generator/storyValidator.d.ts +6 -0
- package/dist/story-generator/storyValidator.d.ts.map +1 -0
- package/dist/story-generator/universalDesignSystemAdapter.d.ts +68 -0
- package/dist/story-generator/universalDesignSystemAdapter.d.ts.map +1 -0
- package/dist/story-generator/universalDesignSystemAdapter.js +138 -1
- package/dist/story-generator/urlRedirectService.d.ts +21 -0
- package/dist/story-generator/urlRedirectService.d.ts.map +1 -0
- package/dist/story-generator/validateStory.d.ts +19 -0
- package/dist/story-generator/validateStory.d.ts.map +1 -0
- package/dist/story-generator/validateStory.js +6 -2
- package/dist/story-generator/visionPrompts.d.ts +88 -0
- package/dist/story-generator/visionPrompts.d.ts.map +1 -0
- package/dist/story-generator/visionPrompts.js +462 -0
- package/dist/story-ui.config.d.ts +78 -0
- package/dist/story-ui.config.d.ts.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.d.ts +4 -0
- package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.js +1874 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts +18 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.js +37 -0
- package/dist/templates/StoryUI/index.d.ts +3 -0
- package/dist/templates/StoryUI/index.d.ts.map +1 -0
- package/dist/templates/StoryUI/index.js +2 -0
- package/package.json +17 -3
- package/templates/StoryUI/StoryUIPanel.tsx +1960 -384
- package/templates/StoryUI/index.tsx +1 -1
- package/templates/StoryUI/manager.tsx +264 -0
- package/templates/production-app/.env.example +11 -0
- package/templates/production-app/index.html +66 -0
- package/templates/production-app/package.json +30 -0
- package/templates/production-app/public/favicon.svg +5 -0
- package/templates/production-app/src/App.tsx +1157 -0
- package/templates/production-app/src/LivePreviewRenderer.tsx +420 -0
- package/templates/production-app/src/componentRegistry.ts +315 -0
- package/templates/production-app/src/considerations.ts +16 -0
- package/templates/production-app/src/index.css +284 -0
- package/templates/production-app/src/main.tsx +25 -0
- package/templates/production-app/tsconfig.json +32 -0
- package/templates/production-app/tsconfig.node.json +11 -0
- package/templates/production-app/vite.config.ts +83 -0
- package/templates/react-import-rule.json +2 -2
- package/dist/index.js +0 -12
- package/dist/story-ui.config.loader.js +0 -205
|
@@ -1,52 +1,119 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Enhanced logging utility with configurable levels and MCP-safe output
|
|
2
|
+
const LOG_LEVELS = {
|
|
3
|
+
debug: 0,
|
|
4
|
+
info: 1,
|
|
5
|
+
warn: 2,
|
|
6
|
+
error: 3,
|
|
7
|
+
none: 4,
|
|
8
|
+
};
|
|
9
|
+
// Get log level from environment or default to 'info'
|
|
10
|
+
const getConfiguredLevel = () => {
|
|
11
|
+
const envLevel = process.env.STORY_UI_LOG_LEVEL?.toLowerCase();
|
|
12
|
+
return LOG_LEVELS[envLevel] !== undefined ? envLevel : 'info';
|
|
13
|
+
};
|
|
2
14
|
const isMcpMode = () => {
|
|
3
15
|
return process.argv.includes('mcp') || process.env.STORY_UI_MCP_MODE === 'true';
|
|
4
16
|
};
|
|
5
17
|
// Remove emojis from strings to prevent JSON parsing errors in MCP
|
|
6
18
|
const stripEmojis = (str) => {
|
|
7
|
-
// Remove common emojis and unicode symbols
|
|
8
19
|
return str.replace(/[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|[\u{1F000}-\u{1F02F}]|[\u{1F0A0}-\u{1F0FF}]|[\u{1F100}-\u{1F64F}]|[\u{1F680}-\u{1F6FF}]|[\u{1F900}-\u{1F9FF}]|[\u{2190}-\u{21FF}]|[\u{2300}-\u{23FF}]|[\u{25A0}-\u{25FF}]|[\u{2B00}-\u{2BFF}]|[\u{3000}-\u{303F}]|✅|❌|⚠️|🔍|📦|📋|🔄|📊|⭐|🚀|💡|🎯|🔧|📌|🏃|🎨|💪|🌟|🎉|🎊|👍|👎|📝|📄|🗑️|🗂️|📁|🖥️|💻|📱|🌐|🔒|🔓|🔑|🔨|⚡|🔥|💧|🌈|☀️|🌙|⭐|✨|💫|☁️|🌧️|⛈️|❄️|☃️|⛄|🌬️|💨|🌪️|🌫️|🌊|🎯/gu, '');
|
|
9
20
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
const formatTimestamp = () => {
|
|
22
|
+
const now = new Date();
|
|
23
|
+
return now.toISOString().replace('T', ' ').slice(0, 19);
|
|
24
|
+
};
|
|
25
|
+
const formatMessage = (level, args) => {
|
|
26
|
+
const timestamp = formatTimestamp();
|
|
27
|
+
const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
|
|
28
|
+
const processedArgs = args.map(arg => {
|
|
14
29
|
if (typeof arg === 'string') {
|
|
15
|
-
return stripEmojis(arg);
|
|
30
|
+
return isMcpMode() ? stripEmojis(arg) : arg;
|
|
16
31
|
}
|
|
17
|
-
|
|
32
|
+
if (typeof arg === 'object') {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.stringify(arg, null, 2);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return String(arg);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return String(arg);
|
|
18
41
|
});
|
|
42
|
+
return [prefix, ...processedArgs];
|
|
43
|
+
};
|
|
44
|
+
const shouldLog = (level) => {
|
|
45
|
+
const configuredLevel = getConfiguredLevel();
|
|
46
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[configuredLevel];
|
|
19
47
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
48
|
+
class Logger {
|
|
49
|
+
static getInstance() {
|
|
50
|
+
if (!Logger.instance) {
|
|
51
|
+
Logger.instance = new Logger();
|
|
52
|
+
}
|
|
53
|
+
return Logger.instance;
|
|
54
|
+
}
|
|
55
|
+
debug(...args) {
|
|
56
|
+
if (!shouldLog('debug'))
|
|
57
|
+
return;
|
|
58
|
+
const formattedArgs = formatMessage('debug', args);
|
|
59
|
+
if (isMcpMode()) {
|
|
60
|
+
console.error(...formattedArgs);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.debug(...formattedArgs);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
log(...args) {
|
|
67
|
+
// Alias for info for backwards compatibility
|
|
68
|
+
this.info(...args);
|
|
69
|
+
}
|
|
70
|
+
info(...args) {
|
|
71
|
+
if (!shouldLog('info'))
|
|
72
|
+
return;
|
|
73
|
+
const formattedArgs = formatMessage('info', args);
|
|
23
74
|
if (isMcpMode()) {
|
|
24
|
-
console.error(...
|
|
75
|
+
console.error(...formattedArgs);
|
|
25
76
|
}
|
|
26
77
|
else {
|
|
27
|
-
console.log(...
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
warn: (...args) => {
|
|
35
|
-
const processedArgs = processArgs(args);
|
|
78
|
+
console.log(...formattedArgs);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
warn(...args) {
|
|
82
|
+
if (!shouldLog('warn'))
|
|
83
|
+
return;
|
|
84
|
+
const formattedArgs = formatMessage('warn', args);
|
|
36
85
|
if (isMcpMode()) {
|
|
37
|
-
console.error(...
|
|
86
|
+
console.error(...formattedArgs);
|
|
38
87
|
}
|
|
39
88
|
else {
|
|
40
|
-
console.warn(...
|
|
89
|
+
console.warn(...formattedArgs);
|
|
41
90
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
91
|
+
}
|
|
92
|
+
error(...args) {
|
|
93
|
+
if (!shouldLog('error'))
|
|
94
|
+
return;
|
|
95
|
+
const formattedArgs = formatMessage('error', args);
|
|
96
|
+
console.error(...formattedArgs);
|
|
97
|
+
}
|
|
98
|
+
// Utility method for structured logging
|
|
99
|
+
structured(level, message, data) {
|
|
100
|
+
if (!shouldLog(level))
|
|
101
|
+
return;
|
|
102
|
+
const logEntry = {
|
|
103
|
+
timestamp: formatTimestamp(),
|
|
104
|
+
level,
|
|
105
|
+
message,
|
|
106
|
+
...(data && { data }),
|
|
107
|
+
};
|
|
45
108
|
if (isMcpMode()) {
|
|
46
|
-
console.error(
|
|
109
|
+
console.error(JSON.stringify(logEntry));
|
|
47
110
|
}
|
|
48
111
|
else {
|
|
49
|
-
console.
|
|
112
|
+
console.log(JSON.stringify(logEntry, null, 2));
|
|
50
113
|
}
|
|
51
114
|
}
|
|
52
|
-
}
|
|
115
|
+
}
|
|
116
|
+
// Export singleton instance
|
|
117
|
+
export const logger = Logger.getInstance();
|
|
118
|
+
// Export for backwards compatibility with code that imports the object directly
|
|
119
|
+
export default logger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postProcessStory.d.ts","sourceRoot":"","sources":["../../story-generator/postProcessStory.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAkB1E"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { StoryUIConfig } from '../story-ui.config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Production-ready gitignore manager that handles both development and server environments
|
|
4
|
+
*/
|
|
5
|
+
export declare class ProductionGitignoreManager {
|
|
6
|
+
private config;
|
|
7
|
+
private projectRoot;
|
|
8
|
+
private isProduction;
|
|
9
|
+
constructor(config: StoryUIConfig, projectRoot?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Detects if we're running in a production/read-only environment
|
|
12
|
+
*/
|
|
13
|
+
private detectProductionEnvironment;
|
|
14
|
+
/**
|
|
15
|
+
* Tests if we can write to the project root
|
|
16
|
+
*/
|
|
17
|
+
private canWriteToProjectRoot;
|
|
18
|
+
/**
|
|
19
|
+
* Main setup method that adapts to environment
|
|
20
|
+
*/
|
|
21
|
+
setupGitignoreIntegration(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Production environment: Use in-memory story generation
|
|
24
|
+
*/
|
|
25
|
+
private handleProductionEnvironment;
|
|
26
|
+
/**
|
|
27
|
+
* Development environment: Full gitignore management
|
|
28
|
+
*/
|
|
29
|
+
private handleDevelopmentEnvironment;
|
|
30
|
+
/**
|
|
31
|
+
* Validates that production environment is properly configured
|
|
32
|
+
*/
|
|
33
|
+
private validateProductionSetup;
|
|
34
|
+
/**
|
|
35
|
+
* Sets up temporary directory for production story generation
|
|
36
|
+
*/
|
|
37
|
+
private setupTemporaryDirectory;
|
|
38
|
+
/**
|
|
39
|
+
* Gets a writable temporary directory for production
|
|
40
|
+
*/
|
|
41
|
+
getProductionTempDirectory(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Creates the generated directory if it doesn't exist (development only)
|
|
44
|
+
*/
|
|
45
|
+
private ensureGeneratedDirectoryExists;
|
|
46
|
+
/**
|
|
47
|
+
* Ensures the generated stories directory is added to .gitignore (development only)
|
|
48
|
+
*/
|
|
49
|
+
private ensureGeneratedDirectoryIgnored;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the relative path from project root to generated stories directory
|
|
52
|
+
*/
|
|
53
|
+
private getRelativeGeneratedPath;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new .gitignore file with Story UI section
|
|
56
|
+
*/
|
|
57
|
+
private createGitignore;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the generated path is already ignored
|
|
60
|
+
*/
|
|
61
|
+
private isPathIgnored;
|
|
62
|
+
/**
|
|
63
|
+
* Adds ignore rule to existing .gitignore
|
|
64
|
+
*/
|
|
65
|
+
private addIgnoreRule;
|
|
66
|
+
/**
|
|
67
|
+
* Generates the gitignore section for Story UI
|
|
68
|
+
*/
|
|
69
|
+
private generateGitignoreSection;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a README in the generated directory explaining its purpose (development only)
|
|
72
|
+
*/
|
|
73
|
+
private createGeneratedDirectoryReadme;
|
|
74
|
+
/**
|
|
75
|
+
* Cleans up old generated stories (safe for both environments)
|
|
76
|
+
*/
|
|
77
|
+
cleanupOldStories(maxAge?: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the appropriate directory for story generation based on environment
|
|
80
|
+
*/
|
|
81
|
+
getStoryGenerationPath(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if we're in production mode
|
|
84
|
+
*/
|
|
85
|
+
isProductionMode(): boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Convenience function to set up gitignore for Story UI (production-ready)
|
|
89
|
+
*/
|
|
90
|
+
export declare function setupProductionGitignore(config: StoryUIConfig, projectRoot?: string): ProductionGitignoreManager;
|
|
91
|
+
//# sourceMappingURL=productionGitignoreManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productionGitignoreManager.d.ts","sourceRoot":"","sources":["../../story-generator/productionGitignoreManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,EAAE,aAAa,EAAE,WAAW,GAAE,MAAsB;IAMtE;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAgBnC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;OAEG;IACH,yBAAyB,IAAI,IAAI;IAQjC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAUnC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAQpC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAmB/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAY/B;;OAEG;IACH,0BAA0B,IAAI,MAAM;IAuBpC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAStC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IA0BvC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAmBhC;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAOhC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAyCtC;;OAEG;IACH,iBAAiB,CAAC,MAAM,GAAE,MAAgC,GAAG,IAAI;IAoCjE;;OAEG;IACH,sBAAsB,IAAI,MAAM;IAYhC;;OAEG;IACH,gBAAgB,IAAI,OAAO;CAG5B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,0BAA0B,CAIhH"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { StoryUIConfig } from '../story-ui.config.js';
|
|
2
|
+
import { DiscoveredComponent } from './componentDiscovery.js';
|
|
3
|
+
import { FrameworkPrompt, StoryGenerationOptions, FrameworkType, FrameworkAdapter } from './framework-adapters/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extended prompt interface that includes framework information
|
|
6
|
+
* Uses string[] for layoutInstructions instead of string
|
|
7
|
+
*/
|
|
8
|
+
export interface FrameworkAwarePrompt extends Omit<FrameworkPrompt, 'layoutInstructions'> {
|
|
9
|
+
layoutInstructions: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface GeneratedPrompt {
|
|
12
|
+
systemPrompt: string;
|
|
13
|
+
componentReference: string;
|
|
14
|
+
layoutInstructions: string[];
|
|
15
|
+
examples: string[];
|
|
16
|
+
sampleStory: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates a comprehensive AI prompt based on the configuration and discovered components
|
|
20
|
+
*/
|
|
21
|
+
export declare function generatePrompt(config: StoryUIConfig, components: DiscoveredComponent[]): GeneratedPrompt;
|
|
22
|
+
/**
|
|
23
|
+
* Builds the complete Claude prompt
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildClaudePrompt(userPrompt: string, config: StoryUIConfig, components: DiscoveredComponent[]): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Generates a framework-aware prompt using the adapter system
|
|
28
|
+
* This is the new multi-framework entry point
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateFrameworkAwarePrompt(config: StoryUIConfig, components: DiscoveredComponent[], options?: StoryGenerationOptions): Promise<FrameworkAwarePrompt>;
|
|
31
|
+
/**
|
|
32
|
+
* Builds a complete LLM prompt with framework awareness
|
|
33
|
+
* This is the new multi-framework entry point for building complete prompts
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildFrameworkAwarePrompt(userPrompt: string, config: StoryUIConfig, components: DiscoveredComponent[], options?: StoryGenerationOptions): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Detect the framework for a given project
|
|
38
|
+
*/
|
|
39
|
+
export declare function detectProjectFramework(projectRoot?: string): Promise<FrameworkType>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the adapter for a specific framework
|
|
42
|
+
*/
|
|
43
|
+
export declare function getFrameworkAdapter(framework: FrameworkType): FrameworkAdapter;
|
|
44
|
+
/**
|
|
45
|
+
* Get all available framework adapters
|
|
46
|
+
*/
|
|
47
|
+
export declare function getAvailableFrameworks(): FrameworkType[];
|
|
48
|
+
//# sourceMappingURL=promptGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptGenerator.d.ts","sourceRoot":"","sources":["../../story-generator/promptGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAI9D,OAAO,EAEL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,eAAe,EAAE,oBAAoB,CAAC;IACvF,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,eAAe,CAcxG;AAoaD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,GAChC,OAAO,CAAC,MAAM,CAAC,CA8HjB;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAqB/B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,MAAM,CAAC,CA6GjB;AAwDD;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAIzF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,aAAa,GAAG,gBAAgB,CAG9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,aAAa,EAAE,CAGxD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { loadConsiderations, considerationsToPrompt } from './considerationsLoader.js';
|
|
2
2
|
import { DocumentationLoader } from './documentationLoader.js';
|
|
3
|
+
import { getAdapterRegistry, } from './framework-adapters/index.js';
|
|
3
4
|
/**
|
|
4
5
|
* Generates a comprehensive AI prompt based on the configuration and discovered components
|
|
5
6
|
*/
|
|
@@ -27,7 +28,28 @@ function generateSystemPrompt(config) {
|
|
|
27
28
|
const componentSystemName = config.componentPrefix ?
|
|
28
29
|
`${config.componentPrefix.replace(/^[A-Z]+/, '')} design system` :
|
|
29
30
|
'component library';
|
|
30
|
-
|
|
31
|
+
// Get the library name for prominent constraint
|
|
32
|
+
const libraryName = config.designSystemGuidelines?.name || config.importPath || 'configured library';
|
|
33
|
+
const importPath = config.importPath || 'your-library';
|
|
34
|
+
return `
|
|
35
|
+
╔════════════════════════════════════════════════════════════════════╗
|
|
36
|
+
║ 🚨 MANDATORY LIBRARY CONSTRAINT 🚨 ║
|
|
37
|
+
╠════════════════════════════════════════════════════════════════════╣
|
|
38
|
+
║ REQUIRED LIBRARY: ${libraryName.padEnd(46)}║
|
|
39
|
+
║ IMPORT PATH: ${importPath.padEnd(46)}║
|
|
40
|
+
╠════════════════════════════════════════════════════════════════════╣
|
|
41
|
+
║ ALL component imports MUST use: ║
|
|
42
|
+
║ import { ComponentName } from '${importPath}';${' '.repeat(Math.max(0, 32 - importPath.length))}║
|
|
43
|
+
╠════════════════════════════════════════════════════════════════════╣
|
|
44
|
+
║ 🚫 FORBIDDEN LIBRARIES - DO NOT USE: ║
|
|
45
|
+
║ - tamagui, @tamagui/core (NEVER USE) ║
|
|
46
|
+
║ - @chakra-ui/react (unless configured) ║
|
|
47
|
+
║ - @mui/material (unless configured) ║
|
|
48
|
+
║ - antd (unless configured) ║
|
|
49
|
+
║ - Any library NOT matching: ${importPath.padEnd(36)}║
|
|
50
|
+
╚════════════════════════════════════════════════════════════════════╝
|
|
51
|
+
|
|
52
|
+
🚨 CRITICAL: EVERY STORY MUST START WITH "import React from 'react';" AS THE FIRST LINE 🚨
|
|
31
53
|
|
|
32
54
|
🔴 CRITICAL RULE: NEVER use children in args for ANY component or layout. Always use render functions. 🔴
|
|
33
55
|
|
|
@@ -448,3 +470,166 @@ export async function buildClaudePrompt(userPrompt, config, components) {
|
|
|
448
470
|
promptParts.push(`Output a complete Storybook story file in TypeScript. Import components as shown in the sample template below. Use the following sample as a template. Respond ONLY with a single code block containing the full file, and nothing else.`, '', '<rules>', '🚨 FINAL CRITICAL REMINDERS 🚨', "🔴 FIRST LINE MUST BE: import React from 'react';", '🔴 WITHOUT THIS IMPORT, THE STORY WILL BREAK!', '', 'OTHER CRITICAL RULES:', '- Story title MUST always start with "Generated/" (e.g., title: "Generated/Recipe Card")', '- Do NOT use prefixes like "Content/", "Components/", or any other section name', '- ONLY import components that are listed in the "Available components" section', '- ALWAYS use the exact import path shown in parentheses after each component', '- NEVER use main package imports when specific subpath imports are shown', '- Do NOT import story exports - these are NOT real components', '- Check every import against the Available components list before using it', '- FORBIDDEN: Any component not explicitly listed in the Available components section', '- FORBIDDEN: Theme setup components (providers should be configured at the app level, not in individual stories)', '- All images MUST have a src attribute with placeholder URLs (use https://picsum.photos/)', '- Never create <img> tags without src attributes', '- MUST use ES modules syntax: "export default meta;" NOT "module.exports = meta;"', '- The file MUST have a default export for the meta object', '- Keep the story concise and focused - avoid overly complex layouts that might exceed token limits', '- Ensure all JSX tags are properly closed', '- Story must be complete and syntactically valid', '- CRITICAL: Never put ANY content in args.children - always use render function', '- Use render functions for ALL layouts and component compositions', '- For layouts: DO NOT set component in meta', '- Only set component in meta when showcasing a SINGLE component', '- Use appropriate styling for the component library (design tokens, className, or inline styles as needed)', '</rules>', '', 'Sample story format:', generated.sampleStory, '', 'User request:', userPrompt);
|
|
449
471
|
return promptParts.join('\n');
|
|
450
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* Generates a framework-aware prompt using the adapter system
|
|
475
|
+
* This is the new multi-framework entry point
|
|
476
|
+
*/
|
|
477
|
+
export async function generateFrameworkAwarePrompt(config, components, options) {
|
|
478
|
+
const registry = getAdapterRegistry();
|
|
479
|
+
// Get the appropriate adapter (auto-detect or use specified framework)
|
|
480
|
+
let adapter;
|
|
481
|
+
if (options?.framework) {
|
|
482
|
+
adapter = registry.getAdapter(options.framework);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
adapter = await registry.autoDetect(process.cwd());
|
|
486
|
+
}
|
|
487
|
+
// Generate framework-specific prompt components
|
|
488
|
+
const frameworkPrompt = await registry.generatePrompt(config, components, options);
|
|
489
|
+
// Generate layout instructions (framework-agnostic)
|
|
490
|
+
const layoutInstructions = generateLayoutInstructions(config);
|
|
491
|
+
return {
|
|
492
|
+
...frameworkPrompt,
|
|
493
|
+
layoutInstructions,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Builds a complete LLM prompt with framework awareness
|
|
498
|
+
* This is the new multi-framework entry point for building complete prompts
|
|
499
|
+
*/
|
|
500
|
+
export async function buildFrameworkAwarePrompt(userPrompt, config, components, options) {
|
|
501
|
+
const generated = await generateFrameworkAwarePrompt(config, components, options);
|
|
502
|
+
const promptParts = [
|
|
503
|
+
generated.systemPrompt,
|
|
504
|
+
'',
|
|
505
|
+
];
|
|
506
|
+
// Load documentation - try new directory-based approach first
|
|
507
|
+
const projectRoot = config.considerationsPath ?
|
|
508
|
+
config.considerationsPath.replace(/\/story-ui-considerations\.(md|json)$/, '') :
|
|
509
|
+
process.cwd();
|
|
510
|
+
const docLoader = new DocumentationLoader(projectRoot);
|
|
511
|
+
let documentationAdded = false;
|
|
512
|
+
if (docLoader.hasDocumentation()) {
|
|
513
|
+
const docs = await docLoader.loadDocumentation();
|
|
514
|
+
if (docs.sources.length > 0) {
|
|
515
|
+
const docPrompt = docLoader.formatForPrompt(docs);
|
|
516
|
+
if (docPrompt) {
|
|
517
|
+
promptParts.push(docPrompt);
|
|
518
|
+
promptParts.push('');
|
|
519
|
+
documentationAdded = true;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
// Fall back to legacy considerations file if no directory-based docs
|
|
524
|
+
if (!documentationAdded) {
|
|
525
|
+
const considerations = loadConsiderations(config.considerationsPath);
|
|
526
|
+
if (considerations) {
|
|
527
|
+
const considerationsPrompt = considerationsToPrompt(considerations);
|
|
528
|
+
if (considerationsPrompt) {
|
|
529
|
+
promptParts.push(considerationsPrompt);
|
|
530
|
+
promptParts.push('');
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
promptParts.push(...generated.layoutInstructions, '', 'Available components:', generated.componentReference, '', generated.examples);
|
|
535
|
+
// Add additional imports information if configured
|
|
536
|
+
if (config.additionalImports && config.additionalImports.length > 0) {
|
|
537
|
+
promptParts.push('');
|
|
538
|
+
promptParts.push('ADDITIONAL IMPORT EXAMPLES - COPY THESE EXACTLY:');
|
|
539
|
+
config.additionalImports.forEach(additionalImport => {
|
|
540
|
+
const componentExamples = additionalImport.components.map(componentName => {
|
|
541
|
+
let componentConfig = config.components?.find(c => c.name === componentName);
|
|
542
|
+
if (!componentConfig) {
|
|
543
|
+
componentConfig = config.layoutComponents?.find(c => c.name === componentName);
|
|
544
|
+
}
|
|
545
|
+
if (componentConfig && componentConfig.importType === 'default') {
|
|
546
|
+
return `import ${componentName} from '${additionalImport.path}';`;
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
return `import { ${componentName} } from '${additionalImport.path}';`;
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
componentExamples.forEach(example => {
|
|
553
|
+
promptParts.push(`- ${example}`);
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
// Add framework-specific rules
|
|
558
|
+
const frameworkType = generated.framework.componentFramework;
|
|
559
|
+
const frameworkRules = getFrameworkSpecificRules(frameworkType);
|
|
560
|
+
if (frameworkRules.length > 0) {
|
|
561
|
+
promptParts.push('');
|
|
562
|
+
promptParts.push(`${frameworkType.toUpperCase()} SPECIFIC RULES:`);
|
|
563
|
+
promptParts.push(...frameworkRules);
|
|
564
|
+
}
|
|
565
|
+
promptParts.push('', `Output a complete Storybook story file in TypeScript. Import components as shown in the sample template below. Use the following sample as a template. Respond ONLY with a single code block containing the full file, and nothing else.`, '', '<rules>', 'CRITICAL REMINDERS:', '- Story title MUST always start with "Generated/" (e.g., title: "Generated/Recipe Card")', '- ONLY import components that are listed in the "Available components" section', '- ALWAYS use the exact import path shown in parentheses after each component', '- NEVER use main package imports when specific subpath imports are shown', '- Do NOT import story exports - these are NOT real components', '- All images MUST have a src attribute with placeholder URLs (use https://picsum.photos/)', '- MUST use ES modules syntax: "export default meta;" NOT "module.exports = meta;"', '- The file MUST have a default export for the meta object', '- Keep the story concise and focused - avoid overly complex layouts', '- Ensure all tags are properly closed and syntax is valid', '- Story must be complete and syntactically valid', '</rules>', '', 'Sample story format:', generated.sampleStory, '', 'User request:', userPrompt);
|
|
566
|
+
return promptParts.join('\n');
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Get framework-specific rules to include in the prompt
|
|
570
|
+
*/
|
|
571
|
+
function getFrameworkSpecificRules(framework) {
|
|
572
|
+
const rules = [];
|
|
573
|
+
switch (framework) {
|
|
574
|
+
case 'react':
|
|
575
|
+
rules.push("- FIRST LINE MUST BE: import React from 'react';");
|
|
576
|
+
rules.push('- Use JSX syntax for templates');
|
|
577
|
+
rules.push('- NEVER pass children through args - use render functions');
|
|
578
|
+
rules.push('- For layouts with multiple components, DO NOT set component in meta');
|
|
579
|
+
break;
|
|
580
|
+
case 'vue':
|
|
581
|
+
rules.push("- Import from '@storybook/vue3'");
|
|
582
|
+
rules.push('- Use Vue 3 Composition API style');
|
|
583
|
+
rules.push('- Use render functions with template for complex content');
|
|
584
|
+
rules.push('- Event bindings use @event or v-on:event syntax');
|
|
585
|
+
rules.push('- Slots use v-slot directive or # shorthand');
|
|
586
|
+
break;
|
|
587
|
+
case 'angular':
|
|
588
|
+
rules.push("- Import from '@storybook/angular'");
|
|
589
|
+
rules.push('- Use moduleMetadata or applicationConfig decorators');
|
|
590
|
+
rules.push('- Property binding: [property]="value"');
|
|
591
|
+
rules.push('- Event binding: (event)="handler($event)"');
|
|
592
|
+
rules.push('- Use Angular template syntax in render functions');
|
|
593
|
+
break;
|
|
594
|
+
case 'svelte':
|
|
595
|
+
rules.push("- Import from '@storybook/svelte'");
|
|
596
|
+
rules.push('- Import .svelte files directly as default exports');
|
|
597
|
+
rules.push('- Events use on: directive (e.g., on:click)');
|
|
598
|
+
rules.push('- Use bind: for two-way binding');
|
|
599
|
+
break;
|
|
600
|
+
case 'web-components':
|
|
601
|
+
rules.push("- Import { html } from 'lit'");
|
|
602
|
+
rules.push("- Import from '@storybook/web-components'");
|
|
603
|
+
rules.push('- Use html`` template literal, NOT JSX');
|
|
604
|
+
rules.push('- Use kebab-case for tag names (e.g., <my-button>)');
|
|
605
|
+
rules.push('- Property binding: .property=${value}');
|
|
606
|
+
rules.push('- Event binding: @event=${handler}');
|
|
607
|
+
rules.push('- Boolean attributes: ?disabled=${true}');
|
|
608
|
+
break;
|
|
609
|
+
default:
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
return rules;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Detect the framework for a given project
|
|
616
|
+
*/
|
|
617
|
+
export async function detectProjectFramework(projectRoot) {
|
|
618
|
+
const registry = getAdapterRegistry();
|
|
619
|
+
const adapter = await registry.autoDetect(projectRoot || process.cwd());
|
|
620
|
+
return adapter.type;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Get the adapter for a specific framework
|
|
624
|
+
*/
|
|
625
|
+
export function getFrameworkAdapter(framework) {
|
|
626
|
+
const registry = getAdapterRegistry();
|
|
627
|
+
return registry.getAdapter(framework);
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Get all available framework adapters
|
|
631
|
+
*/
|
|
632
|
+
export function getAvailableFrameworks() {
|
|
633
|
+
const registry = getAdapterRegistry();
|
|
634
|
+
return registry.getAvailableFrameworks();
|
|
635
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface StoryVersion {
|
|
2
|
+
id: string;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
prompt: string;
|
|
5
|
+
code: string;
|
|
6
|
+
fileName: string;
|
|
7
|
+
parentId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface StoryHistory {
|
|
10
|
+
storyId: string;
|
|
11
|
+
title: string;
|
|
12
|
+
versions: StoryVersion[];
|
|
13
|
+
currentVersionId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class StoryHistoryManager {
|
|
16
|
+
private historyDir;
|
|
17
|
+
private histories;
|
|
18
|
+
constructor(projectRoot: string);
|
|
19
|
+
private ensureHistoryDir;
|
|
20
|
+
private loadHistories;
|
|
21
|
+
private saveHistory;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new story history or add a version to existing history
|
|
24
|
+
*/
|
|
25
|
+
addVersion(fileName: string, prompt: string, code: string, parentVersionId?: string): StoryVersion;
|
|
26
|
+
/**
|
|
27
|
+
* Get the current version of a story by filename
|
|
28
|
+
*/
|
|
29
|
+
getCurrentVersion(fileName: string): StoryVersion | null;
|
|
30
|
+
/**
|
|
31
|
+
* Get all versions for a story
|
|
32
|
+
*/
|
|
33
|
+
getHistory(fileName: string): StoryHistory | null;
|
|
34
|
+
/**
|
|
35
|
+
* Find a story by partial filename match
|
|
36
|
+
*/
|
|
37
|
+
findStoryByPartialName(partialName: string): StoryHistory | null;
|
|
38
|
+
private titleFromFileName;
|
|
39
|
+
/**
|
|
40
|
+
* Clean up old versions, keeping only the last N versions
|
|
41
|
+
*/
|
|
42
|
+
pruneHistory(maxVersionsPerStory?: number): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=storyHistory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyHistory.d.ts","sourceRoot":"","sources":["../../story-generator/storyHistory.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAwC;gBAE7C,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,UAAU,CACR,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,eAAe,CAAC,EAAE,MAAM,GACvB,YAAY;IAiCf;;OAEG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IASxD;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAKjD;;OAEG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAUhE,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,YAAY,CAAC,mBAAmB,GAAE,MAAW;CAU9C"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { StoryUIConfig } from '../story-ui.config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Story synchronization service that keeps chat interface, file system, and memory in sync
|
|
4
|
+
*/
|
|
5
|
+
export declare class StorySyncService {
|
|
6
|
+
private config;
|
|
7
|
+
private isProduction;
|
|
8
|
+
constructor(config: StoryUIConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Gets all available stories from both file system and memory
|
|
11
|
+
*/
|
|
12
|
+
getAllStories(): Promise<SyncedStory[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Gets stories from the file system
|
|
15
|
+
*/
|
|
16
|
+
private getFileSystemStories;
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a story from both file system and memory
|
|
19
|
+
*/
|
|
20
|
+
deleteStory(storyId: string): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Gets a specific story by ID
|
|
23
|
+
*/
|
|
24
|
+
getStory(storyId: string): Promise<SyncedStory | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Clears all stories
|
|
27
|
+
*/
|
|
28
|
+
clearAllStories(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Syncs localStorage chat history with actual stories
|
|
31
|
+
*/
|
|
32
|
+
syncChatHistory(): Promise<ChatSyncResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Validates that a chat session corresponds to an actual story
|
|
35
|
+
*/
|
|
36
|
+
validateChatSession(chatId: string): Promise<boolean>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Synced story interface that combines file system and memory stories
|
|
40
|
+
*/
|
|
41
|
+
export interface SyncedStory {
|
|
42
|
+
id: string;
|
|
43
|
+
title: string;
|
|
44
|
+
fileName: string;
|
|
45
|
+
description: string;
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
lastAccessed: Date;
|
|
48
|
+
source: 'filesystem' | 'memory';
|
|
49
|
+
content: string;
|
|
50
|
+
prompt?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Chat synchronization result
|
|
54
|
+
*/
|
|
55
|
+
export interface ChatSyncResult {
|
|
56
|
+
actualStories: {
|
|
57
|
+
id: string;
|
|
58
|
+
title: string;
|
|
59
|
+
fileName: string;
|
|
60
|
+
lastUpdated: number;
|
|
61
|
+
}[];
|
|
62
|
+
shouldClearOrphanedChats: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets or creates the global story sync service
|
|
66
|
+
*/
|
|
67
|
+
export declare function getStorySyncService(config: StoryUIConfig): StorySyncService;
|
|
68
|
+
//# sourceMappingURL=storySync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storySync.d.ts","sourceRoot":"","sources":["../../story-generator/storySync.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,EAAE,aAAa;IAMjC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IA4C7C;;OAEG;YACW,oBAAoB;IA0DlC;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA8BpD;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAK5D;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBtC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,cAAc,CAAC;IAehD;;OAEG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAI5D;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE;QACb,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;IACJ,wBAAwB,EAAE,OAAO,CAAC;CACnC;AAOD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAK3E"}
|