/**
 * Persistent Learning System
 *
 * Manages learning from:
 * - Repair attempts (what fixes work for which errors)
 * - Code conventions (patterns detected in projects)
 * - Tool effectiveness (which tools work best for which tasks)
 *
 * All data is persisted to SQLite for continuous improvement.
 */
import { EventEmitter } from 'events';
import type { RepairLearning, Convention } from '../database/schema.js';
export interface RepairAttempt {
    errorMessage: string;
    errorType: 'compile' | 'runtime' | 'test' | 'lint' | 'type';
    strategy: string;
    success: boolean;
    attempts: number;
    language?: string;
    framework?: string;
    fixCode?: string;
    contextHash?: string;
}
export interface ConventionDetection {
    projectId: string;
    category: 'naming' | 'structure' | 'style' | 'testing' | 'docs';
    pattern: string;
    description?: string;
    examples?: string[];
}
export interface ToolUsage {
    toolName: string;
    projectId?: string;
    success: boolean;
    timeMs: number;
    cacheHit: boolean;
}
export interface LearningStats {
    repair: {
        totalPatterns: number;
        avgSuccessRate: number;
        topStrategies: {
            strategy: string;
            successRate: number;
            count: number;
        }[];
    };
    conventions: {
        totalConventions: number;
        byCategory: Record<string, number>;
        avgConfidence: number;
    };
    tools: {
        totalTools: number;
        topTools: {
            name: string;
            usage: number;
            successRate: number;
        }[];
        avgCacheHitRate: number;
    };
}
export interface LearningInsight {
    type: 'repair' | 'convention' | 'tool';
    message: string;
    confidence: number;
    data?: Record<string, unknown>;
}
export declare class PersistentLearning extends EventEmitter {
    private analyticsRepo;
    constructor();
    /**
     * Record a repair attempt
     */
    recordRepairAttempt(attempt: RepairAttempt): void;
    /**
     * Get best repair strategies for an error
     */
    getBestRepairStrategies(errorMessage: string, options?: {
        errorType?: RepairAttempt['errorType'];
        language?: string;
        framework?: string;
        limit?: number;
    }): RepairLearning[];
    /**
     * Get repair statistics
     */
    getRepairStats(): LearningStats['repair'];
    /**
     * Record a detected convention
     */
    recordConvention(detection: ConventionDetection): void;
    /**
     * Get conventions for a project
     */
    getProjectConventions(projectId: string, options?: {
        category?: string;
        minConfidence?: number;
    }): Convention[];
    /**
     * Get convention statistics
     */
    getConventionStats(projectId?: string): LearningStats['conventions'];
    /**
     * Record tool usage
     */
    recordToolUsage(usage: ToolUsage): void;
    /**
     * Get tool statistics
     */
    getToolStats(projectId?: string): LearningStats['tools'];
    /**
     * Get best tool for a task type
     */
    getBestToolForTask(taskType: string, projectId?: string): {
        tool: string;
        confidence: number;
    } | null;
    /**
     * Generate learning insights
     */
    generateInsights(projectId?: string): LearningInsight[];
    /**
     * Get comprehensive learning stats
     */
    getStats(projectId?: string): LearningStats;
    /**
     * Format stats for display
     */
    formatStats(projectId?: string): string;
    /**
     * Normalize error pattern for matching
     */
    private normalizeErrorPattern;
}
export declare function getPersistentLearning(): PersistentLearning;
export declare function resetPersistentLearning(): void;
