CLI-first memory engine for LLM applications.
Project description
Contexara
A CLI-first memory engine for LLM applications. Drop it into any AI system and it remembers what matters — across sessions, without a vector database, without infra.
Install
pip install contexara
Run the setup wizard on first install:
contexara setup
This walks you through AWS credentials and Bedrock model ID, saves them to ~/.contexara/.env, and tests the connection.
How it works
Contexara uses a three-tier memory architecture:
| Tier | What | Storage |
|---|---|---|
| 1 — Raw turns | Every message in the current session | active_state.db → raw_turns |
| 2 — Episodes | LLM-crystallized session summaries | active_state.db → episodes |
| 3 — Semantic facts | Atomic extracted memories | active_state.db → memories |
Session lifecycle: Sessions are detected automatically. After 60 minutes of inactivity, the session closes and a background worker crystallizes it into a structured episode (title, actions, outcomes, open items) using the LLM. This never blocks the user.
Context injection: On every ask, all three tiers are injected into the prompt — recent turns for short-term continuity, episode anchor for session handoff, semantic memories for persistent facts.
Temporal queries: Natural language time expressions ("what did I work on today?", "yesterday", "last week") trigger a SQL pre-filter over episodes followed by embedding-based re-ranking.
Cold archive: Raw turns older than 30 days are swept to cold_archive.db automatically every 7 days. The cold archive uses SQLite FTS5 for full-text search across years of history.
Embeddings: Amazon Titan Text Embeddings V2 (1024-dim, serverless via Bedrock) — no local model, no GPU.
Retrieval: Reciprocal Rank Fusion — semantic similarity and keyword overlap ranked independently then fused. Temporal weighting boosts recent task/constraint memories.
Compression: When the store exceeds budget, old memories are compressed by the LLM and originals move to an archive table — permanently recoverable. Every compressed memory carries a compression_level penalty in retrieval.
CLI
contexara ask "what was I working on?" # memory-aware Q&A
contexara store "prefers Python" # store a memory
contexara ingest notes.txt # bulk ingest .txt / .md / .jsonl
contexara list # all memories
contexara list --since 2026-04-01 # filter by date
contexara search "tech stack" # semantic search
contexara show <id> # full detail for one memory
contexara stats # counts, sources, age
contexara consolidate # LLM-compress all memories
contexara prune # archive expired (TTL) memories
contexara prune --dry-run # preview without changes
contexara delete <id> # delete one memory
contexara chat # interactive chat mode
Chat mode
contexara chat
Contexara Chat type 'exit' to quit
You: what did I work on yesterday?
──────────────────────────────────────────────
Yesterday you built the cold archive sweep module — moved raw turns
older than 30 days to cold_archive.db with FTS5 full-text indexing.
──────────────────────────────────────────────
Use in code
from contexara import ask, store, retrieve, ingest_turn
store("User prefers concise answers")
ingest_turn(user_text, assistant_text, session_id=session_id) # auto-extracts + deduplicates
answer = ask("what do I prefer?")
memories = retrieve("python preferences", top_k=5)
Stack
| Layer | Technology |
|---|---|
| Storage | SQLite — raw turns, episodes, memories, cold archive (FTS5) |
| Embeddings | Amazon Titan Text Embeddings V2 (1024-dim, via Bedrock) |
| LLM | AWS Bedrock (configurable model) — extraction, crystallization, Q&A |
| Retrieval | RRF hybrid search + temporal weighting + episode re-ranking |
| CLI | Python + rich |
What's in v0.3.0
- Three-tier memory — raw turns (Tier 1), crystallized episodes (Tier 2), semantic facts (Tier 3)
- JIT session detection — O(1) SQL check, 60-min idle timeout, automatic session lifecycle
- Background crystallization — detached subprocess worker, never blocks user flow
- Temporal retrieval — natural language time queries map to SQL episode pre-filter + cosine re-rank
- Cold archive sweep — FTS5 full-text search across years of history, auto-runs every 7 days
- Setup wizard — guided AWS credential setup with connection test on first install
- Proper system prompt — Bedrock API
systemfield used correctly for instruction/context separation
What's in v0.2.x
- Bedrock embeddings — replaced local BERT (2GB) with Titan V2, no model loading
- File ingest — bulk seed memory from
.txt,.md,.jsonlfiles - TTL expiry —
contexara pruneenforces expires_at, auto-sweeps on write - Date filters —
--since/--beforeonlistandsearch - Rich terminal UI — colored tables, spinner, progress bar, markdown responses
- Fast-path ingest — low-signal turns skip the LLM entirely
- Temporal weighting — recent tasks rank higher, profiles stay stable
Built by Prajwal Narayan
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contexara-0.3.0.tar.gz.
File metadata
- Download URL: contexara-0.3.0.tar.gz
- Upload date:
- Size: 42.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4756f5532af7a0b29e2109009e87071fad10ff799fc2ca13584a60b14230fd6c
|
|
| MD5 |
60e3618c4d91b41f6b0ecfcc1ced6d25
|
|
| BLAKE2b-256 |
e01b9aedbf62a69ed278c2028f7258a991f6c98cbb73c773478c2e43a13b7672
|
File details
Details for the file contexara-0.3.0-py3-none-any.whl.
File metadata
- Download URL: contexara-0.3.0-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50958671bbce6e72265e685bf21d27a03a7fd875978e6e0c671e2f52814fe547
|
|
| MD5 |
b5fd806b03af7d594d29b29548902ced
|
|
| BLAKE2b-256 |
9830bab7f814f6cff247fd8aa7d693353a003cda138794892b1b219d45f15088
|