Skip to main content

Module memory

Module memory 

Source
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§

AiMemoryConfig
Configuration for AI-enhanced memory processing.
AiMemoryExtractor
AI-based memory extractor using a fast/cheap model.
AiMemoryProcessor
AI-enhanced memory processor. Provides advanced memory operations using AI.
AutoMemory
Manager for automatic memory accumulation.
MemoryConfig
Configuration for the memory system.
MemoryConflictResult
Result of AI conflict detection.
MemoryEntry
A single memory entry.
MemoryFileLock
File lock for preventing concurrent access to memory storage. Uses a simple lock file approach (.lock) with atomic operations.
MemoryMergeResult
Result of AI memory merge.
MemoryQualityResult
Result of AI quality assessment.
MemoryStatistics
Statistics about memory collection.
MemoryStorage
Storage for memory files (global and project-level) with file locking.
MemorySummaryResult
Result of AI memory summarization.
RewindResult
Result of a rewind/summarize operation.
SemanticUtils
Cosine similarity calculation utility. Used for vector-based semantic search when embedding API is available.
TfIdfSearch
Semantic search without AI (using TF-IDF like approach).

Enums§

AiDetectionMode
AI memory detection mode. Controls whether AI is used for memory category detection.
AiKeywordMode
AI keyword extraction mode.
MemoryCategory
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§

MemoryExtractor
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.