Minimal CLI text vault with hierarchical memory management to prevent AI agent rot.
Built by @milonspace
Text Volt is a production-grade command-line tool for storing and searching text using Google Gemini embeddings. It implements a three-tier memory system (working/warm/cold) to prevent memory overload and maintain agent performance over time.
- π Semantic Search - Vector-based similarity search using cosine similarity
- πΎ Smart Caching - Automatic embedding cache prevents redundant API calls
- π« Duplicate Prevention - SHA256 hash-based deduplication ensures unique entries
- π§ Hierarchical Memory - Three-tier memory system (working/warm/cold) prevents agent rot
- π Auto Consolidation - Automatic tier migration based on access patterns
- π Secure Config - Environment-based API key management
- β‘ Minimal CLI - Clean, intuitive interface with short aliases (
a,s,l,d) - π₯ Stdin Support - Pipe text directly into the vault
# Install with UV
uv sync
# Or use UVX to run from anywhere
uvx textvolt --help- Copy the example environment file:
cp .env.example .env- Add your Gemini API key:
# Edit .env and add your API key
GEMINI_API_KEY=your_api_key_here# Add text
textvolt a "Your text here"
# Search semantically
textvolt s "query"
# List entries
textvolt l
# Delete entry
textvolt d 1| Command | Alias | Description |
|---|---|---|
add |
a |
Add text to vault |
search |
s |
Semantic search |
list |
l |
List entries |
delete |
d, rm |
Delete entry |
consolidate |
- | Consolidate memory tiers |
validate |
- | Validate memory integrity |
reset |
- | Reset vault (with confirmation) |
-q, --quiet- Quiet mode (minimal output, useful for scripting)-n, --limit <N>- Limit number of results (default: 5 for search, 10 for list)-t, --tier <tier>- Filter by memory tier (working/warm/cold)-m, --meta <json>- Add JSON metadata to entry
# Add multiple entries
textvolt a "Project idea: Build a CLI tool"
textvolt a "Meeting notes: Discussed API design"
textvolt a "Code snippet: Fast vector search"
# Search for related content
textvolt s "API" # Finds API-related entries
textvolt s "code" -n 3 # Top 3 code-related entries
# List recent entries
textvolt l # Last 10 entries
textvolt l -n 20 # Last 20 entries
textvolt l -t working # Only working memory
# Clean up
textvolt d 5 # Delete entry #5
textvolt consolidate # Optimize memory tiers# From file
cat notes.txt | textvolt add
# From command output
git log --oneline -5 | textvolt add
# Quiet mode for scripting
echo "text" | textvolt add -quvx textvolt add "Your text here"
uvx textvolt s "query"
uvx textvolt lβββββββββββββββββββββββββββββββββββββββββββ
β CLI Interface (Minimal TUI) β
β Commands: a/s/l/d + stdin support β
ββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββββββ
β Memory Manager (Hierarchical) β
β ββββββββββββ ββββββββββββ βββββββββββ β
β β Working β β Warm β β Cold β β
β β (Recent) β β (Active) β β(Archive)β β
β ββββββββββββ ββββββββββββ βββββββββββ β
ββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββββββ
β Vector Store (SQLite + numpy) β
β - Embeddings storage (JSON) β
β - Hash-based deduplication β
β - Semantic search (cosine) β
β - Metadata tracking β
ββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββββββ
β Gemini Embedding Service β
β - Text-based caching β
β - Secure API key management β
β - Error handling & retries β
βββββββββββββββββββββββββββββββββββββββββββ
Text Volt implements several strategies to prevent agent degradation:
- Hierarchical Memory - Three-tier system prevents memory overload
- Automatic Consolidation - Moves entries between tiers based on access patterns
- Access Tracking - Tracks access counts and timestamps for relevance
- Memory Validation - Integrity checks detect corruption
- Stateless Operations - Idempotent operations reduce state-related errors
- Size Limits - Configurable limits for each memory tier
- Duplicate Prevention - Hash-based deduplication prevents redundant entries
- Embedding Cache - Reuses embeddings for duplicate text, saving API calls
All configuration is done through environment variables in .env:
| Variable | Description | Default |
|---|---|---|
GEMINI_API_KEY |
Your Google Gemini API key (required) | - |
TEXTVOLT_VAULT_PATH |
Path to SQLite database | ~/.textvolt/vault.db |
TEXTVOLT_WORKING_SIZE |
Maximum entries in working memory | 100 |
TEXTVOLT_WARM_SIZE |
Maximum entries in warm memory | 1000 |
TEXTVOLT_EMBEDDING_MODEL |
Embedding model name | gemini-embedding-exp-03-07 |
See .env.example for a template.
textvolt/
βββ pyproject.toml # UV project configuration
βββ .env.example # Environment template
βββ textvolt/
β βββ __init__.py
β βββ config.py # Settings & configuration
β βββ embedding.py # Gemini embedding service
β βββ vault.py # Vector storage & search
β βββ memory.py # Memory management
β βββ cli.py # CLI interface
βββ README.md # This file
- SQLite over PostgreSQL - Minimal dependency, portable, sufficient for CLI tool
- JSON storage for embeddings - Simple, no additional vector extensions needed
- Cosine similarity - Standard vector similarity metric, implemented in pure NumPy
- Hierarchical memory - Three-tier system prevents memory overload and agent rot
- Stateless design - Each operation is independent, reducing state-related errors
- Hash-based deduplication - SHA256 hashing for fast duplicate detection
- Text-based caching - Automatic embedding cache reduces API costs
- Minimal CLI - Clean, intuitive interface with short aliases for zero friction
- UV/UVX - Fast, modern Python package management and execution
- API keys stored in
.envfile (never committed to git) - No hardcoded credentials in source code
- Environment-based configuration for all sensitive data
- SHA256 hashing for duplicate detection (no plaintext comparison)
- Caching - Duplicate text uses cached embeddings (no API call)
- Deduplication - Hash-based lookup is O(1) for duplicate detection
- Search - Cosine similarity with NumPy (efficient for <10K entries)
- Memory - Automatic consolidation prevents database bloat
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project follows YAGNI, KISS, and DRY principles for maintainable architecture.