Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 10 additions & 40 deletions backend/src/build-system/__tests__/fullstack-gen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import { PRDHandler } from '../handlers/product-manager/product-requirements-doc
import { UXSMDHandler } from '../handlers/ux/sitemap-document';
import { UXSMSHandler } from '../handlers/ux/sitemap-structure';
import { DBRequirementHandler } from '../handlers/database/requirements-document';
import { FileStructureHandler } from '../handlers/file-manager/file-structure';
import { UXSMSPageByPageHandler } from '../handlers/ux/sitemap-structure/sms-page';
import { DBSchemaHandler } from '../handlers/database/schemas/schemas';
import { FileFAHandler } from '../handlers/file-manager/file-arch';
import { BackendRequirementHandler } from '../handlers/backend/requirements-document';
import { BackendCodeHandler } from '../handlers/backend/code-generate';
import { BackendFileReviewHandler } from '../handlers/backend/file-review/file-review';
import { UXDMDHandler } from '../handlers/ux/datamap';
import { BuilderContext } from '../context';
import { FrontendCodeHandler } from '../handlers/frontend-code-generate';
import { FileStructureAndArchitectureHandler } from '../handlers/file-manager/file-struct';
import { BackendRequirementHandler } from '../handlers/backend/requirements-document';

(isIntegrationTest ? describe : describe.skip)('Build Sequence Test', () => {
it('should execute build sequence successfully', async () => {
Expand All @@ -23,8 +18,10 @@ import { FrontendCodeHandler } from '../handlers/frontend-code-generate';
version: '1.0.0',
name: 'Wrtie a Cool personal website',
description:
'A personal blog website. I am a cybersecurity engineer so i want it to show i am a really cool hacker',
'A personal blog website. I am a cybersecurity engineer so i want it to show i am a really cool hacker, with cool terminal functionality',
databaseType: 'SQLite',
model: 'gpt-4o-mini',
projectSize: 'medium', // limit for fun
nodes: [
{
handler: ProjectInitHandler,
Expand All @@ -47,47 +44,20 @@ import { FrontendCodeHandler } from '../handlers/frontend-code-generate';
handler: UXDMDHandler,
name: 'UX DataMap Document Node',
},
{
handler: FileStructureAndArchitectureHandler,
name: 'File Structure and Architecture',
},
{
handler: DBRequirementHandler,
name: 'Database Requirements Node',
// requires: ['op:UX:DATAMAP:DOC'],
},
{
handler: FileStructureHandler,
name: 'File Structure Generation',
// requires: ['op:UX:SMD', 'op:UX:DATAMAP:DOC'],
options: {
projectPart: 'frontend',
},
},
{
handler: UXSMSPageByPageHandler,
name: 'Level 2 UX Sitemap Structure Node details',
// requires: ['op:UX:SMS'],
},
{
handler: DBSchemaHandler,
name: 'Database Schemas Node',
// requires: ['op:DATABASE_REQ'],
},
{
handler: FileFAHandler,
name: 'File Arch',
// requires: ['op:FILE:STRUCT', 'op:UX:DATAMAP:DOC'],
},
{
handler: BackendRequirementHandler,
name: 'Backend Requirements Node',
// requires: ['op:DATABASE_REQ', 'op:UX:DATAMAP:DOC', 'op:UX:SMD'],
},
{
handler: BackendCodeHandler,
name: 'Backend Code Generator Node',
},
{
handler: BackendFileReviewHandler,
name: 'Backend File Review Node',
},
{
handler: FrontendCodeHandler,
name: 'Frontend Code Generator Node',
Expand All @@ -97,5 +67,5 @@ import { FrontendCodeHandler } from '../handlers/frontend-code-generate';
};
const context = new BuilderContext(sequence, 'fullstack-code-gen');
await context.execute();
}, 300000);
}, 2000000);
});
19 changes: 10 additions & 9 deletions backend/src/build-system/__tests__/mock/MockBuilderContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { UXSMSHandler } from 'src/build-system/handlers/ux/sitemap-structure';
import { UXDMDHandler } from 'src/build-system/handlers/ux/datamap';
import { BackendRequirementHandler } from 'src/build-system/handlers/backend/requirements-document';
import { FileFAHandler } from 'src/build-system/handlers/file-manager/file-arch';
import { BuilderContext, GlobalDataKeys } from 'src/build-system/context';
import { v4 as uuidv4 } from 'uuid'; // UUID generator for unique identifiers
import {
Expand Down Expand Up @@ -37,18 +36,20 @@
const backendRequirements = this.readMockFile(
path.join(__dirname, 'test_files', 'Backend_Requirements_Node.md'),
);
const fileStructure = this.readMockFile(
path.join(__dirname, 'test_files', 'File_Structure_Generation.md'),
);
const fileArchitecture = this.readMockFile(
path.join(__dirname, 'test_files', 'File_Arch.md'),
);

//To do integrate FileStructureAndArchitectureHandler
const fileStructureAndArchitectureHandler = this.readMockFile(

Check warning on line 41 in backend/src/build-system/__tests__/mock/MockBuilderContext.ts

View workflow job for this annotation

GitHub Actions / autofix

'fileStructureAndArchitectureHandler' is assigned a value but never used. Allowed unused vars must match /^_/u
path.join(__dirname, 'test_files', 'File_Structure_Architecture_Node.md'),
);
Comment on lines +40 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Implement the integration TODO for FileStructureAndArchitectureHandler.

The code defines a variable to hold the content of the new combined file structure and architecture file, but the TODO comment indicates this integration is incomplete. This is an important part of the restructuring mentioned in the PR objectives.


🏁 Script executed:

#!/bin/bash
# Check if FileStructureAndArchitectureHandler is imported and exists in the codebase
echo "Searching for FileStructureAndArchitectureHandler class..."
rg "FileStructureAndArchitectureHandler" --type ts

Length of output: 1258


Action Required: Complete the Integration of FileStructureAndArchitectureHandler

The file still contains a TODO comment and only a temporary variable assignment for reading the file content. Although the handler exists in the codebase (as seen in multiple locations), its integration into backend/src/build-system/__tests__/mock/MockBuilderContext.ts remains incomplete. Please implement the following:

  • Replace the temporary file read with an actual integration of FileStructureAndArchitectureHandler as outlined in the PR objectives.
  • Verify that the integrated handler correctly processes the combined file structure and architecture file.
  • Update or remove the TODO comment once the integration is finalized.
🧰 Tools
🪛 GitHub Check: autofix

[warning] 41-41:
'fileStructureAndArchitectureHandler' is assigned a value but never used. Allowed unused vars must match /^_/u

this.mockNodeData.set(UXSMSHandler, uxSitemapStructure);
this.mockNodeData.set(UXDMDHandler, uxDataMapDocument);
this.mockNodeData.set(BackendRequirementHandler, backendRequirements);
this.mockNodeData.set(FileFAHandler, fileArchitecture);
this.buildVirtualDirectory(fileStructure);
// this.mockNodeData.set(
// fileStructureAndArchitectureHandler,
// FileStructureAndArchitectureHandler,
// );
Comment on lines +47 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix parameter order in commented-out mockNodeData.set() call.

The parameter order appears to be reversed compared to the pattern used in other mockNodeData.set() calls. It should be handler class first, then data.

-    // this.mockNodeData.set(
-    //   fileStructureAndArchitectureHandler,
-    //   FileStructureAndArchitectureHandler,
-    // );
+    // this.mockNodeData.set(
+    //   FileStructureAndArchitectureHandler,
+    //   fileStructureAndArchitectureHandler,
+    // );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// this.mockNodeData.set(
// fileStructureAndArchitectureHandler,
// FileStructureAndArchitectureHandler,
// );
// this.mockNodeData.set(
// FileStructureAndArchitectureHandler,
// fileStructureAndArchitectureHandler,
// );


// this.buildVirtualDirectory(fileStructure);

copyProjectTemplate(
path.join(__dirname, '..', '..', '..', '..', 'template', 'react-ts'),
Expand Down Expand Up @@ -103,7 +104,7 @@
const absolutePath = resolve(filePath); // Resolve the file path
return readFileSync(absolutePath, 'utf-8'); // Read the file content
} catch (err) {
console.error(`Error reading file at ${filePath}:`, err);

Check warning on line 107 in backend/src/build-system/__tests__/mock/MockBuilderContext.ts

View workflow job for this annotation

GitHub Actions / autofix

Unexpected console statement
return ''; // Return an empty string if file read fails
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ describe('FrontendCodeHandler', () => {
name: 'Spotify-like Music Web',
description: 'Users can play music',
databaseType: 'SQLite',
model: 'o3-mini-high',
nodes: [
{
handler: FrontendCodeHandler,
name: 'Frontend Code Handler',
// requires: ['op:FILE:STRUCT', 'op:UX:DATAMAP:DOC'],
},
],
packages: [],
};

beforeEach(() => {
handler = new FrontendCodeHandler();
context = new MockBuilderContext(sequence, 'test');
context = new MockBuilderContext(sequence, 'frontend-only');
});

//rember to comment requirement in FrontendCodeHandler
Expand All @@ -32,5 +34,5 @@ describe('FrontendCodeHandler', () => {
const result = await handler.run(context);

expect(result.success).toBe(true);
});
}, 6000000);
});
27 changes: 24 additions & 3 deletions backend/src/build-system/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class BuilderContext {

private logFolder: string | null = null;

public defaultModel: string;
/**
* Constructor to initialize the BuilderContext.
* Sets up the handler manager, retry handler, model provider, logger, and virtual directory.
Expand All @@ -99,21 +100,41 @@ export class BuilderContext {
this.monitor = BuildMonitor.getInstance();
this.logger = new Logger(`builder-context-${id ?? sequence.id}`);
this.virtualDirectory = new VirtualDirectory();
this.defaultModel = this.sequence.model;

// Initialize global context with default project values
this.globalContext.set('projectName', sequence.name);
this.globalContext.set('description', sequence.description || '');
this.globalContext.set('platform', 'web'); // Default platform is 'web'
this.globalContext.set('databaseType', sequence.databaseType || 'SQLite');

if (sequence.projectSize) {
this.globalContext.set('projectSize', sequence.projectSize);
} else {
switch (sequence.model) {
case 'gpt-4o-mini':
this.globalContext.set('projectSize', 'small');
break;
case 'gpt-4o':
case 'o3-mini-high':
this.globalContext.set('projectSize', 'medium');
break;
default:
this.globalContext.set('projectSize', 'small');
break;
}
}
const now = new Date();
const projectUUIDPath =
new Date().toISOString().slice(0, 18).replaceAll(/:/g, '-') +
`${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}` +
`-${String(now.getHours()).padStart(2, '0')}-${String(now.getMinutes()).padStart(2, '0')}-${String(now.getSeconds()).padStart(2, '0')}-${String(now.getMilliseconds()).padStart(3, '0')}` +
'-' +
uuidv4();
this.globalContext.set('projectUUID', projectUUIDPath);

if (process.env.DEBUG) {
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const timestamp =
`${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}` +
`-${String(now.getHours()).padStart(2, '0')}-${String(now.getMinutes()).padStart(2, '0')}-${String(now.getSeconds()).padStart(2, '0')}-${String(now.getMilliseconds()).padStart(3, '0')}`;
this.logFolder = path.join(
process.cwd(),
'logs',
Expand Down
182 changes: 0 additions & 182 deletions backend/src/build-system/handlers/file-manager/file-arch/index.ts

This file was deleted.

Loading
Loading