Expand description
Auto Memory system for MatrixCode.
This module implements automatic memory accumulation inspired by Claude Code. It captures user preferences, project decisions, key findings, and solutions across sessions, providing persistent context that survives conversation compression.
Structs§
- AiMemory
Config - Configuration for AI-enhanced memory processing.
- AiMemory
Extractor - AI-based memory extractor using a fast/cheap model.
- AiMemory
Processor - AI-enhanced memory processor. Provides advanced memory operations using AI.
- Auto
Memory - Manager for automatic memory accumulation.
- Memory
Config - Configuration for the memory system.
- Memory
Conflict Result - Result of AI conflict detection.
- Memory
Entry - A single memory entry.
- Memory
File Lock - File lock for preventing concurrent access to memory storage. Uses a simple lock file approach (.lock) with atomic operations.
- Memory
Merge Result - Result of AI memory merge.
- Memory
Quality Result - Result of AI quality assessment.
- Memory
Statistics - Statistics about memory collection.
- Memory
Storage - Storage for memory files (global and project-level) with file locking.
- Memory
Summary Result - Result of AI memory summarization.
- Rewind
Result - Result of a rewind/summarize operation.
- Semantic
Utils - Cosine similarity calculation utility. Used for vector-based semantic search when embedding API is available.
- TfIdf
Search - Semantic search without AI (using TF-IDF like approach).
Enums§
- AiDetection
Mode - AI memory detection mode. Controls whether AI is used for memory category detection.
- AiKeyword
Mode - AI keyword extraction mode.
- Memory
Category - Categories for memory entries.
Constants§
- CONFLICT_
OVERLAY_ THRESHOLD - Topic overlap threshold for conflict detection.
- CONFLICT_
OVERLAY_ THRESHOLD_ WITH_ SIGNAL - Lower topic overlap threshold when change signal is present.
- CONTEXT_
IMPORTANCE_ WEIGHT - Weight for importance in contextual summary (1.0 - CONTEXT_RELEVANCE_WEIGHT).
- CONTEXT_
RELEVANCE_ WEIGHT - Weight for relevance in contextual summary (relevance vs importance trade-off).
- DEFAULT_
FAST_ MODEL - Default fast model for AI memory extraction.
- DEFAULT_
IMPORTANCE_ DECISION - Default importance scores by category. Lower values allow for gradual importance growth through references.
- DEFAULT_
IMPORTANCE_ FINDING - DEFAULT_
IMPORTANCE_ PREF - DEFAULT_
IMPORTANCE_ SOLUTION - DEFAULT_
IMPORTANCE_ STRUCTURE - DEFAULT_
IMPORTANCE_ TECH - DEFAULT_
MEMORY_ EXTRACTOR_ MODEL - Default model for cost-effective memory extraction.
- IMPORTANCE_
STAR_ THRESHOLD - Importance threshold for displaying star marker (⭐).
- MAX_
DETECTED_ ENTRIES - Maximum entries to return from detection (to avoid overwhelming).
- MAX_
DISPLAY_ LENGTH - Maximum length for display (shorter for terminal readability).
- MAX_
IMPORTANCE_ CEILING - Maximum importance score ceiling (entries cannot exceed this).
- MAX_
MEMORY_ CONTENT_ LENGTH - Maximum length for memory content before truncation.
- MIN_
KEYWORDS_ FOR_ AI_ FALLBACK - Minimum keywords threshold for triggering AI fallback. If rule-based extraction produces fewer keywords than this, AI is used.
- MIN_
MEMORY_ CONTENT_ LENGTH - Minimum content length for memory detection (to avoid capturing too generic content). Increased to 20 to filter out short fragments.
- MIN_
SIMILARITY_ LENGTH - Minimum content length for similarity check (to avoid short words matching everything).
- SIMILARITY_
THRESHOLD - Similarity threshold for considering entries as duplicates (0.0-1.0). Higher value (0.85) reduces duplicate detection false negatives.
Traits§
- Memory
Extractor - Trait for memory extraction implementations.
Functions§
- calculate_
similarity - Calculate word-based similarity between two strings (Jaccard coefficient). Returns a value between 0.0 (no similarity) and 1.0 (identical words). This is the public version for external use.
- detect_
memories_ fallback - Detect potential memory entries from conversation content. This is the fallback method using rule-based detection (no AI). For AI-based extraction, use AiMemoryExtractor.
- detect_
memories_ from_ text - Detect memories from text using the rule-based fallback method. This is kept for backward compatibility and for cases where AI is unavailable.
- detect_
memories_ smart - Smart memory detection that chooses the best method based on environment. Uses AI when MEMORY_AI_DETECTION=always and extractor is provided. Otherwise falls back to rule-based detection.
- detect_
memories_ with_ ai - Detect memories asynchronously using AI extractor. Falls back to rule-based detection if AI fails or is unavailable.
- extract_
context_ keywords - Extract meaningful keywords from conversation context. Filters out common stop words and short tokens. Public for external use (e.g., TUI keyword display).
- extract_
keywords_ hybrid - Extract keywords from context with hybrid approach.
- extract_
keywords_ with_ ai - Extract keywords from context using AI (for context-aware memory retrieval).
- summarize_
up_ to - Summarize messages up to a specific index, keeping recent ones. Returns the new message list with summary + kept messages.