(state: GraphState)
| 12 | * It uses an LLM-based agent to create the basic project structure and files. |
| 13 | */ |
| 14 | export const initialProject = async (state: GraphState) => { |
| 15 | logger.printInfoLog('Initializing project...'); |
| 16 | |
| 17 | const envConfig = getModelConfig(); |
| 18 | const modelConfig = { |
| 19 | ...envConfig, |
| 20 | contextWindowTokens: AGENT_CONTEXT_WINDOW_TOKENS, |
| 21 | maxOutputTokens: MAX_OUTPUT_TOKENS, |
| 22 | }; |
| 23 | |
| 24 | const appPath = state.workspace.app; |
| 25 | const appName = state.urlInfo.name || ''; |
| 26 | if (!appPath) { |
| 27 | throw new Error('Workspace application path is not defined.'); |
| 28 | } |
| 29 | |
| 30 | const initialAgent = createInitialAgent(modelConfig); |
| 31 | const result: unknown = await initialAgent.run(initialAgentInstruction({ appPath, appName })); |
| 32 | |
| 33 | // Validate if essential files were created |
| 34 | const essentialFiles = ['package.json', 'src', 'vite.config.ts', 'tsconfig.json', 'index.html', 'src/main.tsx', 'src/App.tsx']; |
| 35 | for (const file of essentialFiles) { |
| 36 | const fullPath = path.join(appPath, file); |
| 37 | if (!fs.existsSync(fullPath)) { |
| 38 | throw new Error(`Critical file/directory missing: "${file}". The project scaffolding may have failed.`); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | logger.printSuccessLog(result as string); |
| 43 | |
| 44 | return {}; |
| 45 | }; |
no test coverage detected