UNPKG

erosolar-cli

Version:

Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning

155 lines 4.92 kB
/** * Self-Evolution System for erosolar-cli * * When erosolar-cli is run in its own source repository, this module enables * fully automatic self-improvement using AlphaZero-style techniques. * * The system: * 1. Analyzes its own source code for improvement opportunities * 2. Generates fixes using dual-response + self-critique * 3. Validates with build + tests * 4. Commits successful changes * 5. Relaunches to run the improved version * 6. Continues until no more improvements found * * Safety: * - Git checkpoint before any changes * - Every change validated with build + tests * - Automatic rollback on any failure * - Max iterations to prevent infinite loops * - Human-readable commit messages * * Principal Investigator: Bo Shang */ export interface SelfEvolutionConfig { maxIterations: number; minConfidence: number; runTests: boolean; autoRelaunch: boolean; verboseLogging: boolean; targetAreas: ('bugs' | 'performance' | 'types' | 'tests' | 'docs')[]; priorityPaths: string[]; anyRepo: boolean; } export interface SourceIssue { type: 'bug' | 'type-error' | 'performance' | 'code-smell' | 'missing-test' | 'todo'; severity: 'critical' | 'high' | 'medium' | 'low'; file: string; line?: number; description: string; suggestedFix?: string; confidence: number; priority: number; } export interface EvolutionResult { success: boolean; iteration: number; issuesFound: number; issuesFixed: number; filesChanged: string[]; commitHash?: string; nextAction: 'continue' | 'relaunch' | 'done' | 'rollback'; error?: string; } export interface EvolutionState { isRunning: boolean; startTime: string | null; iteration: number; totalFixed: number; totalFailed: number; checkpointTag: string | null; lastCommit: string | null; relaunchCount: number; } /** * Check if we're running in the erosolar-cli source repository */ export declare function isErosolarRepo(workingDir: string): boolean; /** * Get the erosolar-cli version */ export declare function getVersion(workingDir: string): string; /** * Check if the directory is a valid git repository with source code */ export declare function isValidSourceRepo(workingDir: string): boolean; /** * Get the repository name from package.json or directory name */ export declare function getRepoName(workingDir: string): string; /** * Analyze source code for improvement opportunities */ export declare function analyzeSource(workingDir: string): SourceIssue[]; /** * Relaunch erosolar-cli with the new code */ export declare function relaunchWithNewCode(workingDir: string): void; export interface EvolutionCallbacks { onStart?: () => void; onIteration?: (iteration: number, issues: SourceIssue[]) => void; onFix?: (issue: SourceIssue, success: boolean) => void; onRelaunch?: () => void; onComplete?: (result: EvolutionResult) => void; onError?: (error: string) => void; } /** * Run the full self-evolution loop */ export declare function runSelfEvolution(workingDir: string, config?: Partial<SelfEvolutionConfig>, callbacks?: EvolutionCallbacks): Promise<EvolutionResult>; /** * Stop the evolution process */ export declare function stopEvolution(): void; /** * Get current evolution state */ export declare function getEvolutionState(): EvolutionState; /** * Emergency rollback to last checkpoint */ export declare function emergencyEvolutionRollback(workingDir: string): { success: boolean; message: string; }; /** * Get formatted status for display */ export declare function getEvolutionStatus(workingDir: string): string; export interface LearnedPattern { category: 'tool-implementation' | 'error-handling' | 'type-pattern' | 'api-design' | 'performance'; description: string; example: string; sourceFile: string; confidence: number; usageCount: number; } /** * Learn optimal patterns from erosolar-cli's own source code */ export declare function learnSourcePatterns(workingDir: string): LearnedPattern[]; /** * Get all learned patterns */ export declare function getLearnedPatterns(): LearnedPattern[]; export interface FixSuggestion { issue: SourceIssue; suggestedCode: string; explanation: string; confidence: number; requiresManualReview: boolean; } /** * Generate a fix for a source issue using learned patterns * Note: This uses pattern matching; full LLM integration requires runtime context */ export declare function generateFix(issue: SourceIssue, workingDir: string): FixSuggestion | null; /** * Apply a fix to the source file */ export declare function applyFix(fix: FixSuggestion, workingDir: string): boolean; /** * Get a summary of what can be learned from the source code */ export declare function getSourceLearningSummary(workingDir: string): string; //# sourceMappingURL=selfEvolution.d.ts.map