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 (~100 tokens) instead of full content |
--overview |
-o |
false | Show L1 overview (structured summary) instead of full content |
Delete Memory
# Example
Session Close
Close a session and trigger memory extraction, L0/L1 layer generation, and vector indexing.
# Example
This is the key command for finalizing a conversation โ it runs the full processing pipeline:
- Memory Extraction: LLM analyzes the conversation and extracts structured facts, decisions, and entities.
- Layer Generation: L0 (abstract) and L1 (overview) files are generated or updated.
- Vector Indexing: All layers are embedded and indexed in Qdrant for future semantic search.
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-5-mini"
= 0.7
= 65536
[]
= "https://api.openai.com/v1"
= "your-embedding-api-key"
= "text-embedding-3-small"
= 10
= 30
[]
= "http://localhost:6334"
= "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
๐งช Testing
# Run basic tests (no external services needed)
# Run all tests including integration tests (requires Qdrant + LLM + Embedding)
CONFIG_PATH=./config.toml TENANT_ID=testcase_user
Tests are automatically run in single-threaded mode (configured in .cargo/config.toml) to avoid Qdrant collection creation race conditions.
๐ 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