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

Function initialProject

src/nodes/initial/index.ts:14–45  ·  view source on GitHub ↗
(state: GraphState)

Source from the content-addressed store, hash-verified

12 * It uses an LLM-based agent to create the basic project structure and files.
13 */
14export 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};

Callers 1

registerP2CCommandFunction · 0.90

Calls 3

getModelConfigFunction · 0.90
createInitialAgentFunction · 0.90
initialAgentInstructionFunction · 0.90

Tested by

no test coverage detected