Skip to main content

Katechon Memory — Sovereign Semantic Memory System

Project description

Katechon Memory (ktkn)

Sovereign semantic memory for AI agents. Local-first. Zero-ceiling. Yours forever.

τὸ κατέχον — "the one who holds fast"

License: AGPL-3.0


What is ktkn?

Katechon Memory is a hybrid RAG engine that gives AI agents persistent, searchable long-term memory. It runs entirely on your machine — no cloud, no API keys, no data leaving your device.

Think of it as a personal library system:

  • The vector index is the Dewey Decimal catalog — it finds what you're looking for
  • The full-text store holds the actual books
  • The Librarian (agent skill) knows how to use both
  • Agents are scholars who get library cards and build their own collections

Quick Start

pip install ktkn-mem
ktkn init

ktkn init detects your platform, finds existing embedding models (Ollama, LM Studio, HuggingFace), and lets you choose a backend:

  • CoreML/ANE — 925+ chunks/sec on Apple Silicon (recommended for Mac)
  • ONNX — cross-platform, works everywhere
  • Ollama — uses your existing Ollama installation

Usage

# Search a database
ktkn search --db archive.ktkn --query "Byzantine theology"

# Ingest files into a new database
ktkn ingest --dir ./documents --db mylib.ktkn

# RAG query (search + synthesize via Ollama)
ktkn rag --db archive.ktkn --query "What are my ideas about governance?"

# Cross-database RAG with Reciprocal Rank Fusion
ktkn rag --db-dir ./libraries/ --query "the restrainer" --sources --report

# Library management
ktkn lib list                     # See mounted libraries
ktkn lib create --name "research" --source ./ktkns/ --output research.ktknlib
ktkn lib mount ./research.ktknlib

# Agent memory (created automatically when agents connect)
ktkn agent list                   # See registered agents
ktkn agent info hermes-v1         # Agent memory stats

# User profiling
ktkn profile show                 # View your profile
ktkn profile update               # Analyze conversations, build profile

For Agent Developers

ktkn is designed to be a memory backend that agents plug into. When an agent (like Hermes) chooses ktkn during setup:

  1. A namespace is created at ~/.ktkn/agents/{agent-id}/
  2. The agent records conversations verbatim into sessions.ktkn
  3. Key insights go into memory.ktkn
  4. Current context lives in working_memory.md
  5. The agent can search its own memory + any mounted libraries

See .agents/skills/ktkn-librarian/SKILL.md for the full agent integration guide.

Architecture

Component What it does
.ktkn file Self-contained SQLite database with text chunks + vector embeddings
.ktknlib bundle Directory of related .ktkn databases with a manifest
ktkn CLI System-wide command-line interface
kTkN-MCP Swift-based ANE embedding server for sandboxed agents
Librarian Skill Teaches any agent how to use the library system
~/.ktkn/
├── config.json           # Global configuration
├── models/               # Embedding models
├── libraries/            # Mounted .ktknlib bundles
├── agents/               # Per-agent memory namespaces
│   ├── _system/          # System agent (librarian, user profiler)
│   └── hermes-v1/        # Agent-managed namespace
└── feeds/                # Feed configurations (RSS, YouTube, Apple Docs)

Install Options

# Python CLI (all platforms)
pip install ktkn-mem              # Core
pip install ktkn-mem[onnx]        # + ONNX runtime
pip install ktkn-mem[full]        # Everything

# System-wide (no venv needed)
pipx install ktkn-mem

# From source
git clone https://github.com/anthropic-cookbook/ktkn
cd ktkn && pip install -e ".[full]"

# MCP Server (macOS, Apple Silicon)
swift build -c release    # from kTkN-MCP-Server/

License

AGPL-3.0 — Use it, modify it, build on it. If you offer it as a hosted service, you must open-source your changes.


ktkn.dev

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

ktkn_mem-1.0.0.tar.gz (84.3 kB view details)

Uploaded Source

Built Distribution

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

ktkn_mem-1.0.0-py3-none-any.whl (71.3 kB view details)

Uploaded Python 3

File details

Details for the file ktkn_mem-1.0.0.tar.gz.

File metadata

  • Download URL: ktkn_mem-1.0.0.tar.gz
  • Upload date:
  • Size: 84.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for ktkn_mem-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cdfc75de7315bc3529f07dd6cb9bd675caf4bbe150d5e888d70e454373334b0e
MD5 df3219666ca0f1a14833c4c47fed4d3d
BLAKE2b-256 f41491ff905e244e17843a93d2a4172fd420719734410dae1fb51eef3b7672e7

See more details on using hashes here.

File details

Details for the file ktkn_mem-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ktkn_mem-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 71.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for ktkn_mem-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3420a678661dfcc6f2fb4b82b58d246c25a3f909e7c322d79b19f92f82ca697f
MD5 f349cf9c0aa9696f1f0154573f08bebe
BLAKE2b-256 0fa9ad386c8559b39543286b8ef6b1bcc535a691b944e29b0c96307daa350e9f

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