This commit is contained in:
Developers Digest
2025-08-08 09:04:33 -04:00
parent 0e883102ed
commit 1629e12079
73 changed files with 24502 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
// Conversation tracking types for maintaining context across interactions
export interface ConversationMessage {
id: string;
role: 'user' | 'assistant';
content: string;
timestamp: number;
metadata?: {
editedFiles?: string[]; // Files edited in this interaction
addedPackages?: string[]; // Packages added in this interaction
editType?: string; // Type of edit performed
sandboxId?: string; // Sandbox ID at time of message
};
}
export interface ConversationEdit {
timestamp: number;
userRequest: string;
editType: string;
targetFiles: string[];
confidence: number;
outcome: 'success' | 'partial' | 'failed';
errorMessage?: string;
}
export interface ConversationContext {
messages: ConversationMessage[];
edits: ConversationEdit[];
currentTopic?: string; // Current focus area (e.g., "header styling", "hero section")
projectEvolution: {
initialState?: string; // Description of initial project state
majorChanges: Array<{
timestamp: number;
description: string;
filesAffected: string[];
}>;
};
userPreferences: {
editStyle?: 'targeted' | 'comprehensive'; // How the user prefers edits
commonRequests?: string[]; // Common patterns in user requests
packagePreferences?: string[]; // Commonly used packages
};
}
export interface ConversationState {
conversationId: string;
startedAt: number;
lastUpdated: number;
context: ConversationContext;
}
+77
View File
@@ -0,0 +1,77 @@
// File manifest types for enhanced edit tracking
export interface FileInfo {
content: string;
type: 'component' | 'page' | 'style' | 'config' | 'utility' | 'layout' | 'hook' | 'context';
exports?: string[]; // Named exports and default export
imports?: ImportInfo[]; // Dependencies
lastModified: number;
componentInfo?: ComponentInfo; // For React components
path: string;
relativePath: string; // Path relative to src/
}
export interface ImportInfo {
source: string; // e.g., './Header', 'react', '@/components/Button'
imports: string[]; // Named imports
defaultImport?: string; // Default import name
isLocal: boolean; // true if starts with './' or '@/'
}
export interface ComponentInfo {
name: string;
props?: string[]; // Prop names if detectable
hooks?: string[]; // Hooks used (useState, useEffect, etc)
hasState: boolean;
childComponents?: string[]; // Components rendered inside
}
export interface RouteInfo {
path: string; // Route path (e.g., '/videos', '/about')
component: string; // Component file path
layout?: string; // Layout component if any
}
export interface ComponentTree {
[componentName: string]: {
file: string;
imports: string[]; // Components it imports
importedBy: string[]; // Components that import it
type: 'page' | 'layout' | 'component';
}
}
export interface FileManifest {
files: Record<string, FileInfo>;
routes: RouteInfo[];
componentTree: ComponentTree;
entryPoint: string; // Usually App.jsx or main.jsx
styleFiles: string[]; // All CSS files
timestamp: number;
}
// Edit classification types
export enum EditType {
UPDATE_COMPONENT = 'UPDATE_COMPONENT', // "update the header", "change button color"
ADD_FEATURE = 'ADD_FEATURE', // "add a videos page", "create new component"
FIX_ISSUE = 'FIX_ISSUE', // "fix the styling", "resolve error"
REFACTOR = 'REFACTOR', // "reorganize", "clean up"
FULL_REBUILD = 'FULL_REBUILD', // "start over", "recreate everything"
UPDATE_STYLE = 'UPDATE_STYLE', // "change colors", "update theme"
ADD_DEPENDENCY = 'ADD_DEPENDENCY' // "install package", "add library"
}
export interface EditIntent {
type: EditType;
targetFiles: string[]; // Predicted files to edit
confidence: number; // 0-1 confidence score
description: string; // Human-readable description
suggestedContext: string[]; // Additional files to include for context
}
// Patterns for intent detection
export interface IntentPattern {
patterns: RegExp[];
type: EditType;
fileResolver: (prompt: string, manifest: FileManifest) => string[];
}
+31
View File
@@ -0,0 +1,31 @@
// Global types for sandbox file management
export interface SandboxFile {
content: string;
lastModified: number;
}
export interface SandboxFileCache {
files: Record<string, SandboxFile>;
lastSync: number;
sandboxId: string;
manifest?: any; // FileManifest type from file-manifest.ts
}
export interface SandboxState {
fileCache: SandboxFileCache | null;
sandbox: any; // E2B sandbox instance
sandboxData: {
sandboxId: string;
url: string;
} | null;
}
// Declare global types
declare global {
var activeSandbox: any;
var sandboxState: SandboxState;
var existingFiles: Set<string>;
}
export {};