Skip to main content

LLMWiki

CI PyPI Python License: MIT

Context Window = RAM, Local Wiki = Disk

A zero-dependency framework that turns your local Markdown vault (Obsidian, selfwiki, etc.) into long-term memory for any AI agent.

PyPI note: the distribution is published as llmwiki-harness (pip install llmwiki-harness). The bare llmwiki name on PyPI belongs to an unrelated third-party project — do not pip install llmwiki. The Python import package and CLI are still called llmwiki.

What This Is

Every serious agent user hits the same wall: the agent forgets everything between sessions. LLMWiki solves this by treating:

  • Your context window as volatile RAM (fast, limited, per-session)
  • Your local Markdown wiki as persistent Disk (slow, unlimited, cross-session)

It provides a universal harness that any agent framework can plug into — no Docker, no cloud, no vector DB required.

┌─────────────────────────────────────────────┐
│  Agent (OpenClaw / LangChain / AutoGen ...) │
│  ┌───────────────────────────────────────┐  │
│  │  L1: Context Window (RAM)             │  │
│  │  ├── Current conversation             │  │
│  │  └── ← Injected wiki knowledge        │  │
│  └───────────────────────────────────────┘  │
│              ↑ ↓ LLMWiki Harness            │
│  ┌───────────────────────────────────────┐  │
│  │  L3: Local Markdown Wiki (Disk)       │  │
│  │  ├── entities/  concepts/  projects/  │  │
│  │  ├── chronicle/daily/  (conversation) │  │
│  │  └── raw/  (session dumps)            │  │
│  └───────────────────────────────────────┘  │
└─────────────────────────────────────────────┘

Features

Feature Status
Multi-engine search — ripgrep, SQLite FTS, pure Python fallback
CJK-aware full-text search — SQLite FTS5 trigram tokenizer + bigram query splitting; Chinese/Japanese/Korean vaults just work
Multi-strategy retrieval — keyword, graph (wikilink traversal), temporal
Knowledge graph edge table — index-time wikilink graph with backlinks, 2-hop weighted traversal, dead-link/orphan detection
RRF fusion — combine multiple retrieval strategies
Token budget management — never overflow the context window
In-memory cache — avoid repeated disk reads
OpenClaw adapter — drop-in memory hook
MCP server — works with Claude Desktop / Claude Code / Cursor / any MCP host
3-layer vault architecture (Karpathy-native)
Zero dependencies for core (optional enhancements via extras)

Install

# Core (zero dependencies)
pip install llmwiki-harness

# With semantic search support
pip install llmwiki-harness[semantic]

# With MCP server support (Claude Desktop / Cursor / any MCP host)
pip install llmwiki-harness[mcp]

# Dev
pip install llmwiki-harness[dev]

Quick Start

1. Initialize a vault

llmwiki init ~/Documents/selfwiki

This creates the directory structure:

~/Documents/selfwiki/
├── raw/              # Layer 1: session dumps
├── chronicle/daily/  # Layer 2: daily conversation logs
├── entities/         # Layer 3: atomic knowledge
├── concepts/
├── comparisons/
├── projects/
├── queries/
└── SCHEMA.md

2. Use in your agent

from llmwiki import ContextMemoryHarness

harness = ContextMemoryHarness("~/Documents/selfwiki")
harness.build_index()

# Before each turn — retrieve relevant knowledge
context = harness.retrieve_and_assemble(
    query=user_message,
    token_budget=2000,
)

# Inject into your prompt
messages = [
    {"role": "system", "content": f"{system_prompt}\n\n{context}"},
    {"role": "user", "content": user_message},
]

# After each turn — capture to chronicle
harness.capture_turn(user_message, assistant_response)

# Periodically — curate chronicle into compiled notes
harness.curate()

3. OpenClaw adapter

from llmwiki.adapters import OpenClawMemoryHook

hook = OpenClawMemoryHook("~/Documents/selfwiki")

# On each turn:
wiki_context = hook.on_turn_start(user_message)
# → inject into system prompt

hook.on_turn_end(user_message, assistant_response)
# → auto-captures to chronicle

MCP Server

The fastest way to use LLMWiki: run it as an MCP server and plug it into Claude Desktop, Claude Code, Cursor, Codex, or any MCP-compatible host. The agent gets five memory tools:

Tool Purpose
memory_search(query, top_k) Raw ranked search over the wiki
memory_recall(query, token_budget) Assembled context block, ready to inject into a prompt
memory_capture(user_message, assistant_message) Store a conversation turn in the chronicle
memory_curate() Distill the chronicle into compiled atomic notes
memory_stats() Vault / index / cache statistics

Claude Desktop / Cursor (claude_desktop_config.json)

{
  "mcpServers": {
    "llmwiki": {
      "command": "uvx",
      "args": ["--from", "llmwiki-harness[mcp]", "llmwiki-mcp"],
      "env": {
        "LLMWIKI_VAULT_PATH": "~/Documents/selfwiki"
      }
    }
  }
}

Claude Code

claude mcp add llmwiki -- uvx --from "llmwiki-harness[mcp]" llmwiki-mcp
# then set the vault:  export LLMWIKI_VAULT_PATH=~/Documents/selfwiki

Already installed via pip?

pip install llmwiki-harness[mcp]
llmwiki mcp                          # stdio server, vault from config/env
llmwiki -v ~/Documents/selfwiki mcp  # explicit vault path

The server speaks stdio (the MCP default for local servers). Compatible with both mcp 1.x and 2.x Python SDKs.

CLI

llmwiki init <path>              # Initialize vault
llmwiki index [--force]          # Build search index
llmwiki search "prompt injection" # Search wiki
llmwiki curate [--llm]           # Run curation pipeline
llmwiki stats                    # Vault statistics
llmwiki health                   # Check for dead links, orphans
llmwiki graph "Zettelkasten"     # Show a note's links, backlinks, 2-hop neighbors
llmwiki config                   # Show configuration
llmwiki mcp                      # Start MCP server (stdio) for any MCP host

Configuration

Create llmwiki.yaml in your vault root or ~/.config/llmwiki/config.yaml:

vault:
  path: ~/Documents/selfwiki

index:
  engine: ripgrep  # ripgrep | sqlite | hybrid
  incremental: true

retrieve:
  default_top_k: 5
  strategies: [keyword, graph, temporal]
  fusion_method: rrf

context:
  token_budget: 4000
  format: markdown
  priority: relevance  # relevance | recency | diversity | structured

cache:
  enabled: true
  maxsize: 100
  ttl: 300

curate:
  enabled: true
  archive_after_days: 30

Architecture

Core Components

Module Purpose
Indexer Manages search indices (ripgrep, SQLite, etc.)
LinkGraph Persistent wikilink edge table (SQLite): neighbors, backlinks, dead links, orphans
Retriever Multi-strategy recall (keyword, graph, temporal)
Assembler Token-budget-aware context assembly
Cache In-memory LRU cache
MCP Server Exposes memory tools to any MCP host over stdio

Data Flow

User Message → Retriever → [Keyword | Graph | Temporal] → RRF Fusion
                                                        ↓
                              Assembler ←── Token Budget Check
                                                        ↓
                                              System Prompt Injection

Turn End → Capture → chronicle/daily/YYYY-MM-DD.md
                              ↓ (scheduled curation)
                     compiled/entities/ | concepts/ | projects/

Vault Schema (Karpathy 3-Layer)

┌─────────────────────────────────────────┐
│ Layer 3: Compiled Wiki (Query)          │
│ entities/ concepts/ comparisons/        │
│ projects/ queries/                      │
│ ↑ LLM curation (nightly)                │
├─────────────────────────────────────────┤
│ Layer 2: Chronicle (Daily Notes)        │
│ chronicle/daily/YYYY-MM-DD.md           │
│ ↑ auto-capture from agent turns         │
├─────────────────────────────────────────┤
│ Layer 1: Raw (Session Exports)          │
│ raw/session-{id}.md                     │
│ ↑ on_session_end / on_pre_compress      │
└─────────────────────────────────────────┘

Ecosystem

  • TypeScript port for DeepSeek Harness: dsh-llmwiki — same vault format, native dsh plugin, on npm.

What's New in 0.3.0

  • MCP serverllmwiki mcp / llmwiki-mcp exposes five memory tools (memory_search, memory_recall, memory_capture, memory_curate, memory_stats) to Claude Desktop, Claude Code, Cursor, Codex, and any MCP host. Compatible with both mcp 1.x (FastMCP) and 2.x (MCPServer).
  • Persistent knowledge graph — wikilinks are extracted at index time into a SQLite edge table (.llmwiki/graph.db). The graph retrieval strategy now does weighted 2-hop traversal (forward links 1.0, backlinks 0.8, hop-2 0.5) instead of re-parsing files on every query.
  • llmwiki graph / improved llmwiki health — inspect any note's links, backlinks, and 2-hop neighborhood; health checks report dead links and orphan notes from the edge table.
  • CJK search fixed — SQLite engine now prefers the FTS5 trigram tokenizer (with graceful fallback), and temporal/keyword matching splits CJK queries into bigrams. Chinese vaults are first-class.
  • FTS5 query sanitization — natural-language queries no longer crash MATCH on quotes, hyphens, or AND/OR/NOT.
  • Tooling — repo-wide black + ruff clean, CI now actually runs on main (it was misconfigured to master).

From hermes-llmwiki

This project evolved from hermes-llmwiki. Key changes in 0.2.0:

  • Framework-agnostic: No longer Hermes-only — works with any agent
  • Multi-engine search: ripgrep + SQLite FTS + Python fallback
  • Multi-strategy retrieval: keyword + graph + temporal + RRF fusion
  • Token budget management: Dynamic context assembly
  • In-memory cache: L1 RAM layer for frequent queries
  • OpenClaw adapter: First-class adapter for OpenClaw agents

Development

git clone https://github.com/chancelu/llmwiki-harness
cd llmwiki-harness
pip install -e ".[dev,mcp]"

pytest tests/          # 65 tests
black llmwiki/ tests/  # formatting (line-length 100)
ruff check llmwiki/ tests/

CI runs the test matrix (Linux / Windows / macOS × Python 3.10–3.13) plus black and ruff on every push to main.

Releases are published to PyPI via trusted publishing: pushing a v* tag triggers the publish workflow.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmwiki_harness-0.3.0.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

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

llmwiki_harness-0.3.0-py3-none-any.whl (50.8 kB view details)

Uploaded Python 3

File details

Details for the file llmwiki_harness-0.3.0.tar.gz.

File metadata

  • Download URL: llmwiki_harness-0.3.0.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llmwiki_harness-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6cdfd9d8d0fb3eeb83308f05abb32360be8302beadb53d17d04b56a0b24692e7
MD5 ba23806b8f42830c8b657a65ac061519
BLAKE2b-256 d3d9f4f5447d26fbb9b79cfe8e1cb78471209d741b6c43dd0b84aad9c5303fec

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmwiki_harness-0.3.0.tar.gz:

Publisher: publish.yml on chancelu/llmwiki-harness

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmwiki_harness-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: llmwiki_harness-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llmwiki_harness-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b599fd97b0a994259b76681952b28e9c27ceba9bb9adaeb129bcc587a70384e7
MD5 bc5d3fc8b181a24238f87d69bc7dcf8f
BLAKE2b-256 29e8eecf2b2d809aed03b12fc2f2091b17f792985bd0a9cc2345427dbd9d82b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmwiki_harness-0.3.0-py3-none-any.whl:

Publisher: publish.yml on chancelu/llmwiki-harness

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

This release

0.3.0 This release

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page