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 search "memory" --tool codex --category workflow
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 (--json for machine output)
oghma validate-config Validate configuration and exit non-zero on errors
oghma stats Show memory counts by category/source
oghma start Start background daemon
oghma stop Stop daemon
oghma search "query" Search memories (--mode keyword/vector/hybrid, --category, --status)
oghma export Export memories to files (--format, --group-by, --category, --status, --source-tool)
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.5.0.tar.gz (49.5 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.5.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oghma-0.5.0.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for oghma-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e3909773068d10f33a6abc7d843f5dda760cf5c4c13e8954db1f159f6d2770f6
MD5 a6b1753b219967c8c7a9a9dbe2599fdf
BLAKE2b-256 3b5e61573601fe95d4be9aa7951a8fad853aa8b5e0ebdcfe6c448597ff324edb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oghma-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for oghma-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 901b680844d796a265b0f8ba063c54c7a09f8436ff28a0501f61d5cf7108d129
MD5 73654781c7ee999478a061a98e23c6af
BLAKE2b-256 6096579101898afa09b4c7965f941d31d29732fa3a1ab1fbce9a142d53a10d08

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