Skip to main content

LLMWiki

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
Multi-strategy retrieval — keyword, graph (wikilink traversal), temporal
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
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]

# 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

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 config                   # Show configuration

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.)
Retriever Multi-strategy recall (keyword, graph, temporal)
Assembler Token-budget-aware context assembly
Cache In-memory LRU cache

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.

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

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.2.1.tar.gz (35.7 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.2.1-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llmwiki_harness-0.2.1.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.1

File hashes

Hashes for llmwiki_harness-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6e0672047ae55bf66a64f8cd70ba9ae06929992adee606fb1a9eead58a19f9f6
MD5 b201eea6e4b35462ef5ca3dcef4d0002
BLAKE2b-256 a6b18556a4cb3a67abe78697088d9e712f6f216267ac7f7b3e672219804b4443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llmwiki_harness-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edd2ab96495b2ac58e22eaca3cf81603093155ecdc7cab9f53a427474cab0275
MD5 b5fba6d28d007e929ba1b2b29b2e9e5e
BLAKE2b-256 202b2007c02d7da0a3ceae8b2115e3a50ff0f8b9d1289044c5465090d75ad388

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 Sentry Error logging StatusPage Status page