Skip to main content

Unified AI memory layer for coding assistants

Project description

Oghma

Unified AI memory layer for coding assistants. Watches transcripts from Claude Code, Codex, OpenClaw, and OpenCode. Extracts memories via LLM. Searches with FTS5, vector similarity, and hybrid (RRF) retrieval.

Features

  • Multi-tool support — Parses transcripts from Claude Code, Codex, OpenClaw, and OpenCode
  • LLM extraction — Uses GPT-4o-mini, Gemini Flash, or any OpenRouter model to extract structured memories
  • Hybrid search — Keyword (FTS5), vector (sqlite-vec), and hybrid (RRF fusion) with recency boost
  • Inline embedding — Memories are embedded immediately on extraction, no separate migration step
  • Cross-source dedup — Same insight from different tools is stored once
  • Smart filtering — Skips trivial sessions (cron heartbeats, tool-only runs) to save API costs
  • MCP server — Native integration with Claude Code and other MCP-compatible tools
  • Write API — Add memories directly via MCP or CLI, not just from transcripts

Install

pip install oghma

For local embeddings (optional):

pip install oghma[local]

Quick Start

export OPENAI_API_KEY=sk-...          # for embeddings
export OPENROUTER_API_KEY=sk-or-...   # for extraction (if using OpenRouter models)

oghma init
oghma start
oghma search "python typing"
oghma export -o ./memories

Configuration

Config at ~/.oghma/config.yaml. Key settings:

Setting Default Description
daemon.poll_interval 300 Seconds between checks for new transcripts
extraction.model gpt-4o-mini LLM for memory extraction
embedding.model text-embedding-3-small Embedding model for vector search
embedding.provider openai Embedding provider (openai or local)

Model Selection

Oghma supports both OpenAI and OpenRouter models for extraction:

Model Provider Quality Cost Notes
gpt-4o-mini OpenAI Good ~$0.30/M Default, factual
google/gemini-3-flash-preview OpenRouter Excellent ~$1.50/M Best quality/cost
google/gemini-2.0-flash-001 OpenRouter Good ~$0.25/M Budget option
deepseek/deepseek-chat-v3-0324 OpenRouter Good ~$0.14/M Cheapest

Set via config:

extraction:
  model: google/gemini-3-flash-preview

Or environment variable: OGHMA_EXTRACTION_MODEL=google/gemini-3-flash-preview

Commands

Command Description
oghma init Create default config
oghma status Show daemon and database status
oghma start Start background daemon
oghma stop Stop daemon
oghma search "query" Search memories (--mode keyword/vector/hybrid)
oghma export Export memories to files
oghma migrate-embeddings Backfill embeddings for existing memories

Search Modes

Mode How it works Best for
keyword (default) FTS5 full-text search, ordered by recency Exact term matching
vector Cosine similarity via sqlite-vec embeddings Semantic/conceptual search
hybrid RRF fusion of keyword + vector with recency boost Best overall relevance
oghma search "async patterns" --mode hybrid --limit 20

MCP Server

Native integration with Claude Code, Codex, and other MCP-compatible tools.

Add to ~/.claude.json:

{
  "mcpServers": {
    "oghma": {
      "command": "uvx",
      "args": ["--from", "oghma", "oghma-mcp"]
    }
  }
}

MCP Tools

Tool Description
oghma_search Search memories (keyword, vector, or hybrid mode)
oghma_get Get a memory by ID
oghma_stats Database statistics (counts by category and source)
oghma_add Write a memory directly with auto-embedding
oghma_categories List categories with counts

Environment Variables

Variable Required Description
OPENAI_API_KEY Yes (embeddings) OpenAI API key for text-embedding-3-small
OPENROUTER_API_KEY If using OpenRouter API key for Gemini, DeepSeek, etc.
OGHMA_DB_PATH No Override database path
OGHMA_POLL_INTERVAL No Override poll interval
OGHMA_LOG_LEVEL No Set log level (DEBUG/INFO/WARNING/ERROR)
OGHMA_EXTRACTION_MODEL No Override extraction model

Adding Custom Parsers

Implement BaseParser with can_parse() and parse() methods, then register in src/oghma/parsers/__init__.py.

License

MIT

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

oghma-0.4.0.tar.gz (38.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oghma-0.4.0-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file oghma-0.4.0.tar.gz.

File metadata

  • Download URL: oghma-0.4.0.tar.gz
  • Upload date:
  • Size: 38.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.2

File hashes

Hashes for oghma-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dc2a94203d056fc9672897923071a5f6e5d6cda4969f04e22d51e3a0d7dcbc0b
MD5 5b1a5f03a32ef168ab30f5f4ebc6130b
BLAKE2b-256 5306102a35410ea71de2686f0256b41b735e764fce4634a1fef1e0fa4bdcc1da

See more details on using hashes here.

File details

Details for the file oghma-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: oghma-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.2

File hashes

Hashes for oghma-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa9caa82db3cad8841a61a63da922131742120c915e7f2c909c5a10b80204f62
MD5 9910f700288409ecddd927906e53b4c4
BLAKE2b-256 6a7bffece8e607335feba70ad3c1d2de8afc1057ee1d227680c73edaff86628a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page