export interface MemoryEntry {
  id: string;
  content: string;
  type: 'code' | 'documentation' | 'decision' | 'learning' | 'context';
  tags: string[];
  metadata: Record<string, any>;
  importance: 'low' | 'medium' | 'high' | 'critical';
  timestamp: string;
  embedding?: number[]; // For semantic search
  relationships?: string[]; // IDs of related memories
}

export interface MemoryQuery {
  query: string;
  type?: string;
  tags?: string[];
  limit?: number;
  includeContext?: boolean;
  minScore?: number;
}

export interface MemorySearchResult {
  id: string;
  content: string;
  type: string;
  tags: string[];
  importance: string;
  timestamp: string;
  score: number; // Relevance score
  context?: string; // Surrounding context
}

export interface MemoryStats {
  totalEntries: number;
  storageSize: number; // In bytes
  lastUpdated: string;
  byType: Record<string, number>;
  byImportance: Record<string, number>;
  recentActivity: {
    today: number;
    thisWeek: number;
    mostActiveDay: string;
  };
  topTags: Array<{
    name: string;
    count: number;
  }>;
}

export interface CodeContext {
  filePath: string;
  functionName?: string;
  summary: string;
  dependencies: Array<{
    name: string;
    type: 'import' | 'function' | 'class' | 'variable';
    description: string;
    filePath?: string;
  }>;
  usagePatterns: string[];
  relatedCode: Array<{
    file: string;
    description: string;
    relationship: 'calls' | 'imports' | 'extends' | 'implements' | 'uses';
  }>;
  recommendations: string[];
}

export interface DocumentContext {
  documentPath: string;
  summary: string;
  keyPoints: string[];
  relatedFiles: string[];
  lastUpdated: string;
  topics: string[];
  importance: 'low' | 'medium' | 'high' | 'critical';
}

export interface MemoryExportOptions {
  format: 'json' | 'markdown' | 'csv';
  includeMetadata: boolean;
  outputPath?: string;
}

export interface MemoryExportResult {
  outputPath?: string;
  data?: any;
  entryCount: number;
  size: number;
}

export interface RelatedSuggestion {
  id: string;
  content: string;
  type: string;
  tags: string[];
  relevanceScore: number;
  reason: string;
}

export interface MemoryClearOptions {
  type?: string;
  olderThan?: string;
}

export interface EmbeddingConfig {
  provider: 'local' | 'openai' | 'cohere';
  model?: string;
  apiKey?: string;
  batchSize?: number;
}

export interface SemanticIndex {
  entries: Map<string, number[]>; // id -> embedding
  index?: any; // Vector index for fast search
  lastUpdated: string;
}

export interface MemoryCluster {
  id: string;
  name: string;
  description: string;
  entryIds: string[];
  centroid: number[];
  tags: string[];
}

export interface MemoryGraph {
  nodes: Map<string, MemoryGraphNode>;
  edges: Map<string, MemoryGraphEdge[]>;
}

export interface MemoryGraphNode {
  id: string;
  type: string;
  importance: number;
  connections: number;
  lastAccessed: string;
}

export interface MemoryGraphEdge {
  from: string;
  to: string;
  relationship: 'references' | 'extends' | 'implements' | 'calls' | 'relates_to';
  strength: number;
}

export interface MemoryInsight {
  type: 'pattern' | 'gap' | 'cluster' | 'trend';
  title: string;
  description: string;
  confidence: number;
  evidence: string[];
  recommendations: string[];
}