devibe
Version:
Intelligent repository cleanup with auto mode, AI learning, markdown consolidation, auto-consolidate workflow, context-aware classification, and cost optimization
111 lines • 2.79 kB
TypeScript
/**
* AI Learning Database
*
* Stores user corrections and learned patterns to improve
* AI classification accuracy over time.
*/
export interface FileCorrection {
filePath: string;
fileName: string;
aiSuggestion: {
category: string;
repository?: string;
targetPath: string;
};
userCorrection: {
category: string;
repository?: string;
targetPath: string;
};
timestamp: string;
fileContent?: string;
imports?: string[];
}
export interface LearnedPattern {
id: string;
pattern: string;
rule: string;
confidence: number;
examples: string[];
createdAt: string;
usageCount: number;
}
export interface ProjectStructure {
type: 'monorepo' | 'single-repo';
framework?: string;
repositories: {
name: string;
path: string;
technology?: string;
isRoot: boolean;
}[];
testStrategy?: 'colocated' | 'centralized' | 'per-package';
analyzedAt: string;
}
export interface LearningData {
corrections: FileCorrection[];
patterns: LearnedPattern[];
projectStructure?: ProjectStructure;
version: string;
}
export declare class AILearningDatabase {
private dbPath;
private data;
constructor();
/**
* Load learning data from disk
*/
load(): Promise<LearningData>;
/**
* Save learning data to disk
*/
save(): Promise<void>;
/**
* Add a user correction
*/
addCorrection(correction: FileCorrection): Promise<void>;
/**
* Learn patterns from a correction
*/
private learnFromCorrection;
/**
* Extract package name from import statement
*/
private extractPackageName;
/**
* Extract significant keywords from content
*/
private extractKeywords;
/**
* Get learned patterns for a file
*/
getPatternsForFile(fileName: string, content?: string, imports?: string[]): Promise<LearnedPattern[]>;
/**
* Store project structure analysis
*/
storeProjectStructure(structure: ProjectStructure): Promise<void>;
/**
* Get stored project structure
*/
getProjectStructure(): Promise<ProjectStructure | undefined>;
/**
* Get all corrections
*/
getCorrections(): Promise<FileCorrection[]>;
/**
* Get statistics
*/
getStats(): Promise<{
totalCorrections: number;
totalPatterns: number;
hasProjectStructure: boolean;
mostCommonCategory: string | null;
avgConfidence: number;
}>;
/**
* Clear all learning data (for testing or reset)
*/
clear(): Promise<void>;
}
export declare function getLearningDatabase(): AILearningDatabase;
//# sourceMappingURL=ai-learning-database.d.ts.map