Cortex Memory CLI
cortex-mem-cli is the command-line interface for the Cortex Memory system, providing complete terminal access to memory management functionality.
✨ Features
- 🗣️ Session Management: Create and list sessions
- 💬 Message Operations: Add, search, get, and delete messages
- 🔍 Semantic Search: Vector-based search with scope filtering
- 📊 Layer Management: Generate and manage L0/L1 layer files
- 📈 Statistics: View system status and usage statistics
- 🎨 Friendly Output: Colored terminal output with configurable verbosity
🚀 Quick Start
Installation
# Build from source
# Or run directly
Basic Usage
# Create a new session
# Add a message
# Search for relevant content
# View statistics
📖 Command Reference
Global Options
| Option | Short | Default | Description |
|---|---|---|---|
--config |
-c |
config.toml |
Path to configuration file |
--tenant |
default |
Tenant identifier for memory isolation | |
--verbose |
-v |
false | Enable verbose/debug logging |
Session Commands
Create Session
# Examples
List Sessions
Output displays: thread_id, status, created_at, updated_at
Message Commands
Add Message
# Role options: user, assistant, system (default: user)
| Argument | Short | Default | Description |
|---|---|---|---|
--thread |
-t |
(required) | Thread ID for the message |
--role |
-r |
user |
Message role: user, assistant, or system |
content |
(required) | Message content text |
Search Messages
# Examples
| Argument | Short | Default | Description |
|---|---|---|---|
query |
(required) | Search query text | |
--thread |
-t |
None | Thread ID to search within |
--limit |
-n |
10 |
Maximum number of results |
--min-score |
-s |
0.4 |
Minimum relevance score (0.0-1.0) |
--scope |
session |
Search scope: session, user, or agent |
List Memories
# Examples
| Argument | Short | Default | Description |
|---|---|---|---|
--uri |
-u |
cortex://session |
URI path to list |
--include-abstracts |
false | Show L0 abstracts in results |
Get Memory
# Examples
| Argument | Short | Default | Description |
|---|---|---|---|
uri |
(required) | Memory URI to retrieve | |
--abstract-only |
-a |
false | Show L0 abstract instead of full content |
Delete Memory
# Example
Layer Commands
Ensure All Layers
Generate missing .abstract.md (L0) and .overview.md (L1) files for all memories.
Layer Status
Show L0/L1 file coverage status.
Regenerate Oversized Abstracts
Regenerate .abstract.md files exceeding the size limit.
Statistics
Displays:
- Number of sessions
- Number of user memories
- Number of agent memories
- Total message count
- Data directory path
Tenant Commands
List Tenants
List all available tenant IDs to help you identify the correct --tenant parameter value.
Output displays all tenant IDs found in the data directory. Use the desired tenant ID with --tenant <id> for other commands.
⚙️ Configuration
Configuration File
Create a config.toml file with the following structure:
[]
= "/path/to/cortex-data" # Optional, has smart defaults
[]
= "https://api.openai.com/v1"
= "your-api-key"
= "gpt-4o-mini"
= 0.7
= 4096
[]
= "https://api.openai.com/v1"
= "your-embedding-api-key"
= "text-embedding-3-small"
= 10
= 30
[]
= "http://localhost:6333"
= "cortex-mem"
= 1536
= 30
Environment Variables
Configuration can be overridden via environment variables:
Data Directory Resolution
The data directory is resolved in the following priority order:
cortex.data_dirconfig valueCORTEX_DATA_DIRenvironment variable- System app data directory (e.g.,
%APPDATA%/tars/cortexon Windows) - Fallback:
./.cortexin current directory
📝 Complete Workflow Example
# 1. Create a session
# 2. Add conversation messages
# 3. Search for relevant information
# 4. View extracted memories
# 5. Get a specific memory with abstract
# 6. View system statistics
# 7. Generate missing layer files
🎨 Output Format
CLI uses color coding for better readability:
- 🔵 Blue: Session IDs and file URIs
- 🟢 Green: Successful operations
- 🟡 Yellow: Warning messages
- 🔴 Red: Error messages
- ⚪ White: General information
🔍 Troubleshooting
Common Issues
Data directory permission error
LLM service unavailable
Vector search failure
# Start Qdrant
# Configure connection
Debug Mode
# Enable verbose logging
# View full error stack trace
RUST_BACKTRACE=1
📚 Related Resources
🤝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
📄 License
MIT License - see the LICENSE file for details.
Built with ❤️ using Rust and the Cortex Memory Core