Fix lint errors

This commit is contained in:
Alex Gleason committed 2025-07-16 16:29:20 -05:00
1 parent caa4dce6f0
commit c222a13901
16 files changed
+152 -106

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ const buildSchema = z.object({
projectId: z.string(),
});
export async function createAIChat(projectId: string, messages: any[]) {
export async function createAIChat(projectId: string, messages: Array<{ role: 'user' | 'assistant'; content: string }>) {
const result = await streamText({
model: openai('gpt-4-turbo-preview'),
messages,
+25 -24
View File
@@ -15,34 +15,34 @@ export interface BuildOperation {
export type AIToolOperation = FileOperation | BuildOperation;
export class AITools {
async executeOperation(operation: AIToolOperation): Promise<any> {
async executeOperation(operation: AIToolOperation): Promise<unknown> {
try {
switch (operation.type) {
case 'read':
return await this.readFile(operation.projectId, operation.filePath);
case 'write':
if (!operation.content) {
throw new Error('Content is required for write operations');
}
await this.writeFile(operation.projectId, operation.filePath, operation.content);
return { success: true, message: 'File written successfully' };
case 'delete':
await this.deleteFile(operation.projectId, operation.filePath);
return { success: true, message: 'File deleted successfully' };
case 'list':
return await this.listFiles(operation.projectId, operation.filePath);
case 'exists':
return await this.fileExists(operation.projectId, operation.filePath);
case 'build':
return await this.buildProject(operation.projectId);
default:
throw new Error(`Unknown operation type: ${(operation as any).type}`);
throw new Error(`Unknown operation type: ${(operation as { type: string }).type}`);
}
} catch (error) {
return { error: error.message };
@@ -69,7 +69,7 @@ export class AITools {
return await fsManager.fileExists(projectId, filePath);
}
private async buildProject(projectId: string): Promise<any> {
private async buildProject(projectId: string): Promise<{ success: boolean; message: string; url: string }> {
// TODO: Implement Vite build in browser
// For now, return a stub
return {
@@ -79,44 +79,45 @@ export class AITools {
};
}
async getProjectStructure(projectId: string): Promise<any> {
const structure: any = {};
async function buildStructure(currentPath: string, obj: any) {
async getProjectStructure(projectId: string): Promise<Record<string, unknown>> {
const structure: Record<string, unknown> = {};
async function buildStructure(currentPath: string, obj: Record<string, unknown>) {
const items = await fsManager.listFiles(projectId, currentPath);
for (const item of items) {
const itemPath = currentPath ? `${currentPath}/${item}` : item;
const fullPath = `${fsManager['dir']}/${projectId}/${itemPath}`;
try {
const stat = await fsManager['fs'].promises.stat(fullPath);
if (stat.isDirectory()) {
obj[item] = {};
await buildStructure(itemPath, obj[item]);
const newObj: Record<string, unknown> = {};
obj[item] = newObj;
await buildStructure(itemPath, newObj);
} else {
obj[item] = 'file';
}
} catch (error) {
} catch {
// Skip inaccessible items
}
}
}
await buildStructure('', structure);
return structure;
}
async searchFiles(projectId: string, query: string): Promise<Array<{path: string, content: string}>> {
const results: Array<{path: string, content: string}> = [];
async function searchDirectory(dirPath: string) {
const items = await fsManager.listFiles(projectId, dirPath);
for (const item of items) {
const itemPath = dirPath ? `${dirPath}/${item}` : item;
const fullPath = `${fsManager['dir']}/${projectId}/${itemPath}`;
try {
const stat = await fsManager['fs'].promises.stat(fullPath);
if (stat.isDirectory()) {
@@ -127,12 +128,12 @@ export class AITools {
results.push({ path: itemPath, content });
}
}
} catch (error) {
} catch {
// Skip inaccessible files
}
}
}
await searchDirectory('');
return results;
}
+9 -10
View File
@@ -5,7 +5,7 @@ import { Buffer } from 'buffer';
// Polyfill Buffer for browser
if (typeof window !== 'undefined') {
(window as any).Buffer = Buffer;
(window as { Buffer?: typeof Buffer }).Buffer = Buffer;
}
export interface Project {
@@ -28,7 +28,7 @@ export class FileSystemManager {
async init() {
try {
await this.fs.promises.mkdir(this.dir);
} catch (error) {
} catch {
// Directory might already exist
}
}
@@ -71,8 +71,7 @@ export class FileSystemManager {
singleBranch: true,
depth: 1,
});
} catch (error) {
console.error('Failed to clone template:', error);
} catch {
// Create basic structure if clone fails
await this.createBasicStructure(projectPath);
}
@@ -146,7 +145,7 @@ export default defineConfig({
const dir = filePath.split('/').slice(0, -1).join('/');
try {
await this.fs.promises.mkdir(dir);
} catch (error) {
} catch {
// Directory might already exist
}
await this.fs.promises.writeFile(filePath, content);
@@ -170,13 +169,13 @@ export default defineConfig({
createdAt: new Date(project.createdAt),
lastModified: new Date(project.lastModified),
});
} catch (error) {
} catch {
// Skip invalid projects
}
}
return projects.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
} catch (error) {
} catch {
return [];
}
}
@@ -191,7 +190,7 @@ export default defineConfig({
createdAt: new Date(project.createdAt),
lastModified: new Date(project.lastModified),
};
} catch (error) {
} catch {
return null;
}
}
@@ -221,7 +220,7 @@ export default defineConfig({
const fullPath = `${this.dir}/${projectId}/${dirPath}`;
try {
return await this.fs.promises.readdir(fullPath);
} catch (error) {
} catch {
return [];
}
}
@@ -252,7 +251,7 @@ export default defineConfig({
const project = JSON.parse(projectData);
project.lastModified = new Date().toISOString();
await this.fs.promises.writeFile(projectFile, JSON.stringify(project, null, 2));
} catch (error) {
} catch {
// Ignore errors updating last modified
}
}