Skip to content
Conduit

mcp server

k0maru-agent-memory

A Standalone, Single-Static-Binary, Zero-Daemon Long-Term Memory Hub for AI Coding Agents.

K0maru/k0maru-agent-memorycommunitylistedunreviewed

Set up

Runs on your computer. Pick your agent and operating system.

This project does not publish an install method we can turn into a config. Follow the README instead.

README

synced Oct 21, 2026

English | 简体中文

K0maru-Agent-Memory

A Standalone, Single-Static-Binary, Zero-Daemon Long-Term Memory Hub for AI Coding Agents.
Topology-agnostic memory hub mounting any Markdown vault or LLM-Wiki (flat Karpathy wikis, engineering ADRs, PARA, Johnny.Decimal) with instant sub-millisecond context retrieval, symbolic log offloading, and living ADR architectural guardrails.

Language: Rust 2021 License: MIT Version: 0.11.0 Tests: 67 passed Binary Size: 3.66MB Cold Start: 3.4ms Zero-Daemon

💡 Dual Binary Support: Available as both k0maru and k0maru-memory standalone binaries for seamless compatibility with multi-agent orchestration systems.


🌟 Core Advantages & Architectural Superiority (Why K0maru?)

Modern AI coding agents (Claude Code, Cursor, Windsurf, Gemini, etc.) frequently suffer from two critical pain points: Cross-Session Amnesia (loss of architectural decisions across sessions) and Terminal Log Bloat (compiler and test outputs flooding the context window).

Existing agent memory frameworks frequently deploy heavy multi-container Docker clusters (PostgreSQL, pgvector, Redis) or resident background daemons, incurring continuous RAM footprints (800MB–2GB), port conflicts, and complex deployment friction.

K0maru is engineered specifically for local developer workstations, delivering industrial-grade performance with minimal mechanical complexity:

  1. ⚡ Zero-Daemon & Sub-Millisecond Cold Start:
    • Pure Rust, statically compiled into a single 3.66 MB standalone binary.
    • Cold-starts in just 3.38 ms with a lean ~11 MB RAM footprint; occupies 0 persistent network ports.
    • Runs on demand via standard Unix pipes and stdio streams, releasing all memory immediately upon process exit.
  2. 📝 Bring Your Own Markdown (Topology-Agnostic LLM-Wiki):
    • Your existing local Markdown notes serve as the Single Source of Truth. Fully topology-agnostic: adapts seamlessly to any LLM-Wiki shape — flat Karpathy-style LLM-Wikis, engineering docs/adr/ or decisions/ wikis, PARA (projects/, cards/, logs/), and Johnny.Decimal (10_Projects/, 20_Cards/).
    • Zero proprietary binary lock-in, zero migration friction, and zero changes to your existing folder structure.
  3. 🪓 Disposable Transient Cache:
    • Maintains only a single-file SQLite database (cache.sqlite) integrating FTS5 BM25 full-text indices and sqlite-vec virtual tables with pluggable embedding dimensions.
    • Strictly disposable: delete it anytime (rm cache.sqlite) and the scanner self-heals and rebuilds the index from scratch in 74 ms.
  4. 📉 Symbolic Context Offloading & Governance (99.4% TRR & Live A100 Validation):
    • Filters verbose logs via standard Unix pipes (| k0maru offload), transforming long traces into Mermaid state diagrams and stored slices.
    • Includes 4-tier Context GC (k0maru gc) keeping agent sessions within the cognitive Smart-Zone (15%–60%).
  5. 🛡️ Living ADR Guard & Architectural Invariant Sentinel (<10ms Audit):
    • Transforms passive Architecture Decision Records (ADRs) and vault notes into active, executable guardrails.
    • Audits staged Git diffs and incoming code against architectural rules (forbidden anti-patterns, required boundaries, regex invariants) via k0maru guard check --diff or the guard_check FastMCP tool.
    • Installs pre-commit hooks (k0maru guard install) to block non-compliant code from entering repositories with 0 runtime dependencies.

Architectural Comparison Matrix

Evaluation DimensionVanilla Context (Copy-Paste)Containerized Microservices (Letta / TencentDB)Resident Background Daemons (agentmemory)K0maru-Agent-Memory (This Project)
Storage MediumEphemeral chat historyExternal DBs (PostgreSQL, pgvector, Redis)Proprietary DB in hidden directoriesLocal Markdown Vaults (Plain Text)
Deployment ModelManual copyMulti-container Docker Compose clustersBackground daemon process (iii-engine, etc.)Single static binary, on-demand (Zero-Daemon)
Network Port FootprintNone1–4 open ports1–4 open ports0 ports (Unix pipes & stdio streams)
Cold Start LatencyInstant2,500 ms – 3,500 ms (container boot)1,000 ms – 2,000 ms3.38 ms (native Rust binary)
Resident Memory (RAM)0 MB~850 MB – 2,000 MB~150 MB – 300 MB~11.7 MB (released instantly on command exit)
Terminal Log GovernanceManual or LLM truncationNetwork API transfer requiredInternal bespoke truncationStandard Unix pipe filter (| k0maru offload)
Living ADR SentinelManual code reviewExternal SonarQube / heavy CINoneLiving ADR Guard (<10ms git diff audit against vault rules)
Index Self-HealingNoneSnapshot & backup dependentLocal database integrity dependentcache.sqlite disposable anytime, rebuilt in 74ms

Empirical Open-Source Model Benchmark (NVIDIA A100-80GB GPU)

Evaluated on an NVIDIA A100-SXM4-80GB GPU in Google Colab Pro, measuring real local inference across leading open-source models on 5 representative industrial defects (Rust concurrency, Python asyncio leaks, TypeScript auth crashes, Go deadlocks, C memory safety):

Evaluated Open ModelArchitectureBaseline (Raw Traces)K0maru ManagedBreakthrough & Performance Impact
Qwen2.5-Coder-32B32B Dense Code ModelPass@1: 60.0%Latency: 17.23sPass@1: 100.0% (+40%)Latency: 2.92s (5.90x faster)100% Full Pass Rate; Mermaid diagrams eliminated trace noise, solving async deadlocks and null checks
DeepSeek-R1-32B32B Full Reasoning DistillLatency: 27.14sTokens: 817Latency: 14.07s (1.93x faster)Tokens: 652 (-20.2%)Reasoning Latency Cut in Half (-48.2%); streamlined reflection chain, Rust turnaround dropped from 39.2s to 11.5s (3.4x)
DeepSeek-Coder-V216B MoE (2.4B active)Pass@1: 60.0%Latency: 12.46sPass@1: 80.0% (+20%)Latency: 1.05s (11.86x faster)Sub-Second Extreme Throughput; cured Python async leak with 1.05s turnaround
Qwen3.8-27B27B Dense (Dual-Stage Reasoning)Tokens: 923Rust Latency: 21.2sTokens: 709 (-23.2%)Rust Latency: 11.1s (2x faster)Flawless 100% Pass Baseline; 23.2% Prompt Token reduction, halved Rust turnaround

Autonomous Agent Ecosystem Adaptation (Hermes Agent & OpenClaw on Real LLM-Wiki)

Simulated an enterprise-grade payment gateway LLM-Wiki on Colab A100 (containing P0 service architecture, L3 idempotency rules, and incident postmortems), driving Qwen3.8-27B through an autonomous Hermes / OpenClaw function calling loop. All 4 core invariants achieved 100% compliance:

Invariant Verification ItemExpected Standard & BehaviorEmpirical OutcomeStatus
1. Pre-flight Memory InspectionQuery loadout and rules before generating any codeAutonomously issued get_project_loadout + 2x targeted recall_memory callsPASS ✓
2. Architectural Invariant ComplianceGenerated code must enforce distributed mutex & state guardProduced Go handler with Redis lock SET NX EX 30 & STATUS_PENDING checkPASS ✓
3. Self-Healing Session FlushPersist ADR decision to wiki via flush_session with WikiLinksAutomatically created 20_Cards/adr-pay-012-...md with frontmatterPASS ✓
4. Instant Recall Without Re-indexingNote must be recallable immediately without manual re-indexRecalled in 0.88 ms with top score of 12.05 (Rank #1 hit)PASS ✓

📖 Comprehensive Case Breakdown & Autonomous Agent Traces:
For the complete per-case logs, multi-turn Hermes/OpenClaw traces, and 500B+ model notes, see Part 4 & Part 5 of the Comparison Report.


🚀 Quick Start & Installation

For step-by-step instructions, see QUICKSTART.md.

1. Install K0maru Binary

Option A: One-Line Install Script (macOS & Linux - Recommended)

No Rust toolchain required. Automatically detects OS and chip architecture, verifies SHA-256 checksums, and installs the standalone binary:

curl -fsSL https://raw.githubusercontent.com/K0maru/k0maru-agent-memory/main/install.sh | bash

Option B: Homebrew (macOS & Linux)

brew install K0maru/tap/k0maru

Option C: Build from Source (Cargo)

cargo install --git https://github.com/K0maru/k0maru-agent-memory

(Builds both k0maru and k0maru-memory binary aliases).


2. Connect Your Coding Agents (k0maru install)

With a single command, inject K0maru's FastMCP service into all detected coding agent configuration files (Claude Code, Cursor, Gemini CLI, Windsurf, Cline / Roo Code, Hermes, OpenClaw, and Oh My Pi / omp):

# Auto-detect and configure all installed agents pointing to your Markdown vault
k0maru install --vault ~/Documents/MyVault

# Or configure a specific client (e.g. Oh My Pi / omp)
k0maru install --target omp --vault ~/Documents/MyVault

# Or preview configuration diffs safely without writing to disk
k0maru install --vault ~/Documents/MyVault --dry-run

For manual setup, add this snippet to your IDE's MCP config:

{
  "mcpServers": {
    "k0maru-memory": {
      "command": "k0maru",
      "args": ["mcp", "--vault", "/path/to/your/markdown-vault"]
    }
  }
}

2.1 Tern Native Plugin & omp/Claude Plugin Marketplace

K0maru integrates natively with modern terminal multiplexers and agent plugin marketplaces:

  • Tern Multiplexer Plugin: Native Luau plugin featuring an interactive cockpit dashboard, CLI lens, and Carly palette integration:
    tern plugin install github.com/K0maru/k0maru-agent-memory/tern-plugin
    
  • Oh My Pi (omp) Plugin Marketplace:
    /marketplace add K0maru/k0maru-agent-memory
    /marketplace install k0maru-memory@k0maru-agent-memory
    
  • Claude Code Plugin Marketplace:
    /plugin add K0maru/k0maru-agent-memory
    

3. Verify Health & Environment (k0maru doctor)

Run the automated doctor check to inspect your binary, vault conventions, SQLite indices, and agent bindings:

k0maru doctor

Outputs a clear, color-coded health report (✓ Binary In Path, ✓ FTS5 Index Ready, ✓ Vectors Indexed, ✓ Claude Code Configured, ✓ Cursor Configured) with actionable remediation steps for any warnings.


🛠️ Common Use Cases & Workflows (How-Tos)

Use Case 1: Kickstarting New Sessions —— Rapid Context Loadout (k0maru loadout & get_project_loadout)

Avoid dumping dozens of unrelated files into fresh agent chats. loadout extracts project mission, core architectural invariants (L3), and recent engineering logs (L2), strictly contained within < 300 Tokens:

  • 4-Tier Scoped Project Resolver:
    • Tier 1: Normalized exact match, alias, tag, and backlink-derived project aliases.
    • Tier 2: Scoped FTS5 SQL push-down via search_scoped_fts (never global Top 5 truncation).
    • Tier 3: Vector semantic fallback (if vector embeddings exist).
    • Tier 4: Ambient workspace / CWD directory matching.
  • Git Diff Change-Awareness (--diff): Dynamically analyzes working tree modifications to activate module-relevant ADRs and invariants.
# Generate project loadout and copy directly to the system clipboard (macOS / Linux / Windows)
k0maru loadout my-project --vault ~/wiki --copy

# Diff-aware loadout: dynamically inspect git changes and activate relevant ADRs
k0maru loadout my-project --vault ~/wiki --diff --copy

FastMCP Autonomous Tool Equivalent: get_project_loadout

{
  "project_name": "k0maru-agent-memory",
  "diff": true,
  "branch": "main"
}

Use Case 2: Build & Test Failures —— Symbolic Context Offloading (| k0maru offload)

When running test suites or compilers that generate thousands of lines, pipe the command output through k0maru:

# Intercept verbose dumps; outputs a clean Mermaid diagram with a node_id
cargo test 2>&1 | k0maru offload

# Retrieve targeted failure stack trace slice on demand
k0maru inspect node_54697ed3
  • 99.44% Token Reduction: Truncates massive compiler dumps, storing full raw logs safely under .scratch/refs/ or <vault>/.k0maru/refs/.
  • Mermaid State Diagrams: Transforms raw stack traces into structural transitions (e.g., Iteration1 --> Failure: E0382 borrow after move), guiding LLMs directly to the root cause without attention drift.
  • FastMCP Autonomous Tools:
    • offload_context: Agents can offload terminal logs produced during tool execution.
    • inspect_log_node: Retrieve specific stack slices by node_id.
    • gc_session_context: Compresses long 50+ turn trajectory sessions using a 4-tier compaction protocol (preserving hot windows and achieving TRR >= 85%).

Use Case 3: Querying the Vault —— Natural Language Intent-Driven Recall (recall_memory & k0maru search)

Once connected via MCP, frontier models automatically understand intent and invoke the right tools without memorizing explicit keywords:

# Hybrid search (BM25 + ONNX vectors + RRF k=60 + WikiLinks graph boost)
k0maru search "concurrency deadlock mitigation" --vault ~/wiki --mode hybrid --limit 5

# Pluggable embeddings: select specific model or dimension
k0maru search "vector similarity" --vault ~/wiki --embed-model bge-small-zh-v1.5
  • Compact K-DSL Wire Default (!μ:<tier>|<path>|...) for MCP recall_memory: To prevent Master Agent context explosion, the recall_memory MCP tool defaults to returning ultra-dense single-line K-DSL wire entries (!μ:<tier>|<path>|score:<score>|links:<in>/<out> § <snippet>, capped at ≤140 chars per snippet). Pass "full": true in tool arguments only when full multi-line markdown excerpts are explicitly needed.
  • Pluggable Vector Backends: Built-in support for all-minilm-l6-v2 (384d, default), bge-small-zh-v1.5 (512d), bge-base-en-v1.5 (768d), paraphrase-multilingual-minilm-l12-v2 (384d), and mock embedders for offline testing.
  • Dynamic Dimension Migration: Seamlessly reconfigures sqlite-vec virtual tables upon model switching without manual database rebuilds.

Use Case 4: Preserving Decisions & Troubleshooting Skills —— Memory Crystallization (k0maru flush & distill)

Crystallize engineering takeaways, architectural decisions (ADRs), or debugging playbooks back into your vault:

# Crystallize an ADR into vault matching local conventions
k0maru flush \
  --title "Mitigating Tokio Runtime Blocking in Worker Pools" \
  --category decision \
  --summary "Offloaded synchronous disk IO to spawn_blocking threadpool" \
  --content "Detailed stack analysis and remediation..." \
  --tags "tokio,rust,performance" \
  --related "Architecture Standards,Async Concurrency" \
  --vault ~/wiki

# Distill troubleshooting trace into a reusable skill note
k0maru distill \
  --trace-file /tmp/error.log \
  --title "Resolving SQLite Vec Apple Silicon Linking" \
  --vault ~/wiki
  • Convention Sniffing: Automatically adapts to your vault's naming style (e.g., YYYY-MM-DD-slug.md), directory structures, and AGENTS.md rules.
  • Collision Defense: Detects duplicate titles and increments versions safely (-v2.md) without overwriting existing notes.
  • Hermes Skill Export: Supports --target hermes to output dynamic skills compatible with Nous Research Hermes Agent.
  • FastMCP Autonomous Tools: flush_session and distill_session_skill.

Use Case 5: Pre-Commit Sentinel —— Living ADR Guard (k0maru guard & guard_check)

ADRs and technical guidelines should not be dead text in forgotten folders. K0maru's Living ADR Guard turns your documentation into an automated architectural sentinel:

# Audit Git working tree / staged diff against active Living ADR invariants (<10ms)
k0maru guard check --diff

# Install pre-commit hook into repository to block non-compliant commits automatically
k0maru guard install

How Invariants are Declared

In your vault's ADR notes (20_Cards/ or 10_Projects/), add an invariants block to the frontmatter:

---
title: ADR-042 Distributed Lock Standard
category: decision
tags: [architecture, redis, idempotency]
invariants:
  - id: "enforce-distributed-mutex"
    condition: "must_contain"
    pattern: "redis_lock\\.acquire|SET\\s+NX\\s+EX"
    paths: ["src/payment/**/*.rs", "services/order/**/*.go"]
    severity: "deny"
    fix_hint: "Critical financial paths must acquire a distributed Redis lock before mutating state."
  - id: "ban-raw-sql-in-handlers"
    condition: "forbidden"
    pattern: "SELECT .* FROM raw_|execute_unprepared"
    paths: ["src/api/**/*.rs"]
    severity: "deny"
    fix_hint: "Use query builders or prepared statements in storage layer."
---

You can also place rules in repository root .k0maru/rules, guard.toml, or AGENTS.md.

  • <10ms Lightning Fast: Runs in native Rust, evaluating hundreds of diff hunks instantly.
  • Exit Codes: Returns 0 on clean pass, 1 on blocking deny violation, 2 on execution error.
  • FastMCP Autonomous Tool: guard_check allows AI agents to audit diffs before presenting changes to the human developer.

Use Case 6: Vault Introspection —— Embedded Developer Console (k0maru ui)

Launch a local visual dashboard on demand:

k0maru ui --vault ~/wiki --open

  • 🌐 Bilingual Switching: Instant one-click toggle between English and Chinese in the header.
  • 🔍 Search Explainability Console: Inspect BM25 ranks, vector cosine distances, and Emerald +0.05 Graph Boost badges.
  • 🪵 Log & State Machine Inspector: Native SVG Mermaid renderer with syntax-highlighted error logs and one-click copying.
  • 📊 Token Economics Scoreboard: Real-time telemetry tracking vector coverage, database size, and cumulative tokens saved.
  • Zero Daemon: Pressing Ctrl+C immediately frees all memory and network ports. See docs/UI_TUTORIAL.md.

Use Case 7: Vault Changes —— Sub-Millisecond Incremental Synchronization (k0maru sync)

# Incremental rescan of markdown files and FTS5 indices (takes just 11ms when clean)
k0maru sync --vault ~/wiki

# Batch incremental generation of ONNX vector embeddings (skips unchanged notes)
k0maru sync --vault ~/wiki --vector

# Sync with custom embedding model
k0maru sync --vault ~/wiki --vector --embed-model bge-small-zh-v1.5

🤖 Autonomous Agent Ecosystem & FastMCP Protocol

When connected via FastMCP, K0maru operates in two distinct server modes:

  • Default Full Mode (8 Tools): For general open-source and IDE agents (Claude Code, Cursor, Windsurf, Hermes, OpenClaw), providing the complete suite of memory, context offloading, and GC tools.
  • Orthogonal Sidecar Mode (--sidecar, 5 Tools): Tailored for omp (Oh My Pi). Because omp natively manages terminal streams and session compaction, sidecar mode exposes the 5 orthogonal domain tools (get_project_loadout, recall_memory, flush_session, distill_session_skill, guard_check) while omitting offload_context, inspect_log_node, and gc_session_context to prevent pipeline redundancy.
FastMCP ToolModeTarget Intent & Natural Prompt TriggersCore Value & Mechanics
get_project_loadoutFull / Sidecar"Start new task", "What are our architectural invariants?"Scoped 4-tier retrieval returning mission, rules, and recent logs strictly < 300 Tokens. Supports --diff dynamic activation.
recall_memoryFull / Sidecar"How do we configure X?", "Search notes for Y"Hybrid BM25 + ONNX vector + RRF $k=60$ + 1-hop WikiLinks graph boost. Instant sub-millisecond retrieval.
offload_contextFull OnlyLarge tool execution outputs, test logs (>30 lines)Externalizes verbose terminal text into Mermaid state diagrams and stored disk slices. Prevents attention drift.
inspect_log_nodeFull Only"Inspect failure stack for node_xxxx"Retrieves exact raw stack trace slice on demand by node ID.
flush_sessionFull / Sidecar"Document this decision", "Save milestone to vault"Atomically writes structured ADRs or logs into vault matching local naming conventions and frontmatter schemas.
distill_session_skillFull / Sidecar"Distill this bug fix into a reusable skill"Extracts troubleshooting patterns into structured skill notes (Markdown or Hermes format).
gc_session_contextFull OnlyLong multi-turn agent dialogues approaching context limitCompresses session trajectory with 4-tier pruning protocol, achieving TRR >= 85% while preserving hot window.
guard_checkFull / SidecarBefore Git commits, post-implementation code reviewAudits diff against Living ADR rules (<10ms). Halts non-compliant code from entering repositories.

💡 Pro-Tip: Autonomous Vault Inspection System Prompt
Add this single instruction to your AGENTS.md or global system prompt:
> Before designing architecture, debugging complex failures, or implementing core logic, inspect the local vault using k0maru-memory to align with historical ADRs and codebase conventions. Run guard_check before completing tasks.
Agents will proactively consult your security and architectural standards before writing code.


📊 Empirical Google Colab A100 Benchmark Matrix

Evaluated live on a dedicated NVIDIA A100-SXM4-80GB GPU across 5 frontier and coding models on 5 representative industrial defect scenarios (Rust E0382, Python InvalidStateError, TypeScript auth null reference, Go deadlock, C double free) and 4 architectural invariants:

1. Multi-Model Benchmark Matrix

Evaluated ModelArchitecturePass@1 (Baseline)Pass@1 (K0maru)Avg Latency (Base -> K0maru)SpeedupPrompt Tokens (Base -> K0maru)Token Reduction (%)
Qwen3.8-27B (Flagship Kanban)27B Dual-Stage Reasoning20.0% (1/5)40.0% (2/5)16.70s ➔ 6.14s2.72x5,745 ➔ 1,07681.3%
DeepSeek-Coder-V2-16B16B MoE (2.4B active)80.0% (4/5)100.0% (5/5)9.43s ➔ 1.36s6.93x6,298 ➔ 1,14281.9%
Qwen2.5-Coder-32B (Code Baseline)32B Dense Q4_K_M60.0% (3/5)100.0% (5/5)24.68s ➔ 7.13s3.46x5,472 ➔ 1,11979.6%
DeepSeek-R1-32B32B Reasoning Distill20.0% (1/5)40.0% (2/5)12.01s ➔ 9.19s1.31x5,412 ➔ 98981.7%
Google Gemma 4 31B31B Multimodal Foundation0.0% (0/5)0.0% (0/5)16.69s ➔ 6.94s2.40x6,356 ➔ 1,13482.2%

See docs/COMPARISON_REPORT.md for full breakdown, including 4/4 invariant compliance.

2. Multi-Agent Concurrency & Heterogeneous Harness Benchmark (A100)

Benchmark Stress DimensionConcurrency / LoadMeasured Metric / ThroughputStatusEngineering Assurance
Simultaneous Read Bursts12 Concurrent Agents, 120 queries18.9 QPS, Avg: 614.29ms (P50: 781.9ms)100% PASSZero SQLite busy contention (SQLITE_BUSY = 0)
Simultaneous Write & Flush Race8 Concurrent Writers12.2 writes/sec, Avg: 584.93ms100% PASS8/8 files created, zero collision loss (-v2.md to -v8.md)
Instant Self-Healing RecallRead-your-writes validation290.99 msPASS ✓Immediate sub-second recall without re-indexing
Context Garbage Collection (GC)50-turn trajectory compaction94.67% TRR (20,946 ➔ 1,110 tokens)PASS ✓Preserves context within cognitive Smart-Zone (15%–60%)
Dynamic Loadout Git-DiffChange-aware ADR activation245 tokensPASS ✓Strictly bounded under <300 token budget
Heterogeneous Agent LoopsHermes, OpenClaw, PiTurnaround: 1.04s – 8.49s100% PASSVerified autonomous tool calling & ADR crystallization

🏗️ Architecture & Mechanics

Four-Layer Decoupled Architecture

  1. Interface Layer: CLI Tools (doctor, install, loadout, search, flush, distill, gc, guard, pipe filters) + Embedded Dashboard (Axum + rust-embed) + FastMCP Stdio Service.
  2. Orchestration & Governance Layer: Living ADR Guard Engine + State Machine Log Parser (Mermaid abstraction and slice storage) + Packager (<300 token Smart-Zone control) + Adaptive Convention Sniffer.
  3. Hybrid Search & Graph Layer: SQLite FTS5 BM25 + sqlite-vec ONNX Embeddings (pluggable 384d/512d/768d) + Reciprocal Rank Fusion ($k=60$) + 1-Hop WikiLinks Graph Boost (+0.05).
  4. Storage & Persistence Layer: Local Plaintext Markdown Vault (Single Source of Truth) + Disposable cache.sqlite (Transient full-text, vector, and adjacency index).

Memory Lifecycle Loop

  • Wake & Loadout ➔ Run & Offload ➔ Pre-Commit Guard ➔ Session Flush (ADR) ➔ Consolidation (Evergreen Cards)

📖 CLI Cheat Sheet

Both k0maru and k0maru-memory binary names are supported identically.

CommandCommon FlagsDescription
k0maru install--vault <path>Injects k0maru-memory into agent client config files
--target <client>Target client (all, claude, cursor, gemini, windsurf, cline, hermes, openclaw, omp)
--dry-runPreviews configuration changes without touching disk
k0maru doctor--vault <path>Full diagnostic check of binary, vault, cache, and client bindings
--jsonOutputs machine-readable JSON diagnostic report
k0maru ui--vault <path>Launches embedded visual developer console (127.0.0.1:3721)
--port <port>Binds custom local port
--openAutomatically opens default browser upon startup
k0maru loadout <query>--vault <path>Target markdown vault directory
--diffDynamically activates module-relevant ADRs by inspecting git diff
--copyCopies assembled <300 token loadout directly to clipboard
--jsonOutputs structured JSON loadout data
-l, --listLists all active projects within vault
k0maru search <query>--vault <path>Target markdown vault directory
--mode <mode>Search mode (hybrid [default], bm25, vector)
--embed-model <name>Pluggable embedding model (all-minilm-l6-v2, bge-small-zh-v1.5, etc.)
--limit <N>Maximum search results to return (default: 5)
--jsonOutputs structured JSON search results
k0maru sync--vault <path>Incrementally scans and updates SQLite indices
--vectorComputes and stores ONNX vector embeddings incrementally
--embed-model <name>Selects embedding model for vector generation
--forceForces full re-index ignoring cache timestamps
k0maru offload--threshold <N>Line count threshold for triggering symbolic offload (default: 50)
--task-id <id>Binds a task ID for traceable offloaded logs
k0maru inspect <id><node_id>Retrieves persisted stack trace slice for a specific node ID
k0maru flush--vault <path>Crystallizes decisions into vault matching local conventions
--title <title>Note title
--category <cat>Note category (decision, log, concept, etc.)
--summary <text>Executive summary
--tags <t1,t2>Comma-separated tags
--related <r1,r2>Comma-separated related note titles (linked as [[WikiLinks]])
--dry-runPreviews destination path and generated note without writing
k0maru distill--trace-file <path>Distills raw execution trace into reusable skill note
--target <ecosystem>Export target: default (Obsidian) or hermes (Hermes Agent)
k0maru gc--input <path>Compacts multi-turn session trajectory with 4-tier GC protocol
--threshold <N>Line threshold for folding tool outputs (default: 20)
k0maru guard check--diffAudits git staged/unstaged diff against Living ADR rules (<10ms)
--strictTreats all warnings as blocking errors
--jsonOutputs structured JSON guard report
k0maru guard install--path <repo_dir>Installs .git/hooks/pre-commit hook to block non-compliant commits
k0maru mcp--vault <path>Starts stdio FastMCP service exposing all 8 memory tools
--sidecarOrthogonal 5-tool mode for omp (omits log offload and GC tools)
k0maru pack export--name <name> --tag <tag> -o <file.pack.json>Exports portable Memory Pack (.pack.json) of notes & ADRs
k0maru pack import<file.pack.json> [--dry-run]Imports Memory Pack into LLM-Wiki adapting to local topology
k0maru pack inspect<file.pack.json>Inspects pack contents, metadata, and predicted destination paths

📊 Empirical Benchmarks: Cognitive Memory & Living ADR Guard

Empirically measured across a Google Colab Linux VM (Intel Xeon @ 2.20GHz, 12.67 GB RAM) protected by Zero-Burn Guard (runtime.unassign()), alongside local Apple M5 Pro Mac and Linux Workstation (company-pc):

Benchmark DimensionBaseline (Full Markdown RAG / Manual CI)Google Colab Linux VMApple M5 Pro MacArchitectural Advantage & Impact
Recall Payload Size (Single Memory)611 bytes (112 Tokens)164 bytes (22 Tokens)164 bytes (22 Tokens)73.16% Token Reduction via compact !μ: K-DSL wire
Vault Index Sync (k0maru sync)500ms ~ 2,000ms34.48 ms9.50 msHigh-performance incremental SQLite + ONNX sync
Full Hybrid Search (BM25 + Vec)1,500ms+ (Remote API RAG)495.04 ms180.20 ms100% local ONNX embedding + RRF reciprocal rerank
Living ADR Guard (guard check --diff)Minutes (Human Review / CI)17.40 ms4.20 msPre-commit AST invariant verification (<20ms)
Living ADR Rule EnforcementAd-hoc / Drift-proneStrict Blocking (deny)Strict Blocking (deny)Prevents architectural erosion before code review

🔒 Privacy & Cleanroom Principles

  • 100% Local & Zero Telemetry: K0maru never collects, stores, or uploads your notes, code snippets, or queries. All indexing, vector inference, and guard evaluations run entirely on your physical machine.
  • Open-Domain Evaluation Compliance: Benchmark data and rules are derived exclusively from public, compliant, and reproducible sources (SWE-bench agent trajectories, GitHub Actions public CI logs, BEIR/CoIR benchmarks). Zero private user data was involved. See docs/TUNING_AND_DATA.md.

🛠️ Customization & Tuning

  • Vault Convention Tuning: Declare custom directory mappings in .k0maru/rules.md or AGENTS.md (e.g., decisions: docs/adr, logs: 01_AI_Logs).
  • Living ADR Invariants: Add YAML frontmatter invariants to any ADR card in 20_Cards/ to immediately activate guardrails across your repositories.
  • Low-Resource Workstations: On memory-constrained devices (<1GB RAM), run with --mode bm25 for sub-millisecond keyword retrieval with zero ONNX memory overhead.
  • Offload Sensitivity: Adjust --threshold <N> to match your model's context window. See Developer Tuning Guide.

🙏 Acknowledgments & Technical Ancestry

K0maru-Agent-Memory builds on foundational ideas from the open-source community:

  1. Andrej Karpathy (LLM-Wiki): Knowledge compounding via flat Markdown files, bidirectional links, and "filesystem as single source of truth".
  2. Tencent Cloud (TencentDB-Agent-Memory): "Mermaid Symbolic Log Offloading" and "L0–L3 Semantic Hierarchy". Clean-room reimplemented in 100% Rust as a standalone CLI filter and disposable cache.
  3. Colby McHenry (CodeGraph): Local Rust pre-indexing and graph topology models.
  4. Nous Research (Hermes Agent): Autonomous crystallization of skills from execution trajectories.
  5. Anthropic (Model Context Protocol): Standardized stdio JSON-RPC 2.0 communication.
  6. Open-Source Rust Ecosystem: pulldown-cmark, rusqlite, sqlite-vec, fastembed-rs, axum, and clap.

⚖️ License

Distributed under the MIT License.

↑↓ navigate openesc close