MCPcopy Create free account
hub / github.com/MigoXLab/coderio / generateFrame

Function generateFrame

src/nodes/code/utils.ts:110–143  ·  view source on GitHub ↗
(node: Protocol, state: GraphState, assetFilesList: string, progressInfo: string)

Source from the content-addressed store, hash-verified

108 * Frames compose multiple child components based on layout
109 */
110export async function generateFrame(node: Protocol, state: GraphState, assetFilesList: string, progressInfo: string): Promise<void> {
111 const frameName = node.data.name;
112 logger.printInfoLog(`${progressInfo} 🖼️ Generating Frame: ${frameName}`);
113
114 // Build children imports information
115 const childrenImports = (node.children || []).map(child => ({
116 name: child.data.name || '',
117 path: child.data.path,
118 }));
119
120 // Detect rendering modes
121 const renderingModes = detectRenderingModes(node);
122
123 // Generate prompt
124 const prompt = generateFramePrompt({
125 frameDetails: JSON.stringify(node.data),
126 childrenImports: JSON.stringify(childrenImports),
127 styling: JSON.stringify(DEFAULT_STYLING),
128 assetFiles: assetFilesList,
129 renderingModes,
130 });
131
132 // Call AI model
133 const code = await callModel({
134 question: prompt,
135 imageUrls: state.figmaInfo.thumbnail,
136 });
137
138 // Save generated files
139 const componentPath = node.data.path || '';
140 const filePath = workspaceManager.resolveAppSrc(state.workspace, workspaceManager.resolveComponentPath(componentPath));
141 saveGeneratedCode(code, filePath);
142 logger.printSuccessLog(`Successfully generated frame: ${frameName}`);
143}
144
145/**
146 * Generate a component (leaf or reusable)

Callers 1

processSingleNodeFunction · 0.85

Calls 6

generateFramePromptFunction · 0.90
callModelFunction · 0.90
detectRenderingModesFunction · 0.85
saveGeneratedCodeFunction · 0.85
resolveAppSrcMethod · 0.80
resolveComponentPathMethod · 0.80

Tested by

no test coverage detected