RepoMemory v2 offers a revolutionary memory system for AI agents, inspired by Git. It enables persistent, tracked changes through an immutable commit chain, ensuring integrity and transparency. With features like content-addressable storage and cross-agent profiles, this library and CLI tool enhances the way agents manage and recall knowledge.
RepoMemory v2
RepoMemory v2 is an innovative, Git-inspired agentic memory system designed to provide persistent and versioned memory for AI agents without any runtime dependencies. It operates through a straightforward library and command-line interface (CLI), offering an intuitive way to manage various types of entities seamlessly.
Key Features
- Content-addressable Storage: Automatically deduplicates entries while ensuring hash-verified integrity.
- Immutable History: Each save creates a commit, establishing a full audit trail for every entity, including deleted items.
- Entity Types: Supports five distinct entity types: Memories, Skills, Knowledge, Sessions, and Profiles.
- Shared Scopes: Utilizing
SHARED_AGENT_ID(_shared), enables cross-agent collaboration on skills and knowledge. - Unified Profiles: Facilitates querying user profiles across multiple agents.
- Conversation Management: Organizes sessions by
conversationId, enhancing context retention through grouped conversations. - Structured Sessions: Provides options to save either raw transcripts or structured messages complete with roles, content, and timestamps.
- Recall Engine: A single
recall()function call retrieves relevant context from all collections, streamlining the information retrieval process. - Incremental TF-IDF Search: Search cache is stored on disk and updated incrementally during writes, providing efficient retrieval and analysis.
- Query Expansion: Supports automatic mapping of synonyms and abbreviations (e.g., "ts config" translates to "TypeScript configuration").
- Customizable Scoring: Fine-tunes search result scoring with adjustable weights for TF-IDF, tag overlap, decay rates, and access boost caps.
- Deduplication Capabilities: Detects similar content during memories, skills, and knowledge save/update operations with configurable thresholds.
- Batch Operations: Supports efficient bulk writes via
saveMany(),deleteMany(), andincrementMany()commands to enhance performance. - Event System: Features a typed event bus for monitoring entity lifecycle events, ensuring robust error handling without core operation disruptions.
- TTL Cleanup: Automatically removes outdated entities while supporting audit log rotation for accountability.
- File Locking Mechanism: Employs a filesystem-based mutex for safe concurrent access during operations.
- AI Integration: Offers optional mining and knowledge consolidation through integrations with AI providers like OpenAI, Anthropic, or Ollama.
- Zero Runtime Dependencies: Relies solely on Node.js built-in modules (
node:fs,node:path,node:crypto, andfetch). - Flexible Middleware Pipeline: Allows the registration of hooks for validating, transforming, or vetoing operations before data modifications occur.
- Export/Import Functionality: Provides portable JSON serialization of all entities for backup, migration, or cloning purposes.
- Multi-protocol Support: Exposes all operations via both Model Context Protocol (MCP) for LLM tool integrations and a lightweight HTTP API for language-agnostic integrations.
Quick Start Examples
As a Library:
import { RepoMemory } from 'repomemory';
const mem = new RepoMemory({ dir: '.repomemory' });
// Saving a memory
const [saved] = mem.memories.save('agent-1', 'user-1', {
content: 'User prefers TypeScript strict mode',
tags: ['preferences', 'typescript'],
category: 'fact',
});
// Searching for memories
const results = mem.memories.search('agent-1', 'user-1', 'typescript', 5);
// Viewing history of an entry
const history = mem.memories.history(saved.id);
// Updating a memory
mem.memories.update(saved.id, { content: 'User requires TypeScript strict mode' });
// Deleting a memory
mem.memories.delete(saved.id);
As a CLI:
repomemory init
repomemory save memory --agent my-agent --user user-1 --content "Prefers dark mode" --tags ui,preferences
repomemory search "dark mode" --agent my-agent --user user-1
repomemory history <entityId>
repomemory stats
repomemory verify
RepoMemory v2 is designed to enhance AI agents' memory capabilities, providing robust management of knowledge and interaction through an accessible interface, enabling greater functionality and efficiency without necessitating extensive dependencies.
No comments yet.
Sign in to be the first to comment.