okf-agent-memory README

The project's README from github.com/okf-memory/okf-agent-memory. As one markdown file: README.md.

OKF Agent Memory

A Domain-Neutral, Git-Native Persistent Project Memory for AI Agents based on the Open Knowledge Format (OKF) v0.2.

Specification Tooling Protocol License


🌟 Overview

Conversations with AI agents reset when context windows close. Valuable architectural decisions, domain discoveries, and operational facts are lost unless stored persistently.

OKF Agent Memory provides a standardized, vendor-neutral memory layer that lives directly in your repository (knowledge/) as plain Markdown files with YAML frontmatter. It bridges the gap between unstructured ad-hoc markdown files (CLAUDE.md, AGENTS.md) and complex, black-box vector databases.

flowchart TD
    L1["1. OKF v0.2 Specification<br/>(Normative Markdown & YAML Format)"]
    L2["2. Agent Memory Convention<br/>(Behavioral Rules: Search, Review, Trust)"]
    L3["3. Agent Skill<br/>(LLM Prompts & Operational Workflows)"]
    L4["4. Tooling Layer: Go Library & CLI<br/>(Deterministic Parsing, Validation, Search, MCP)"]
    L5["5. Project Knowledge Corpus<br/>(knowledge/ OKF Bundle)"]

    L1 --> L2
    L2 --> L3
    L3 --> L4
    L4 --> L5

⚡ Key Highlights


📊 Performance Benchmarks

Built in Go with zero external dependencies, okf is engineered for high-frequency agent tool calling loops:

Benchmark Metric Python / Vector DB Runtimes (Mem0, Letta) Deno / Node.js Tooling OKF Agent Memory (Go)
Concept Search Latency 150ms – 800ms (Embedding API + Vector DB) 40ms – 120ms < 300 µs (Microseconds, In-Memory BM25)
Full Corpus Parse & Graph Validation 200ms – 1.5s 80ms – 250ms ~4.0 ms (50+ concepts, bidirectional graph)
Process Cold-Start Overhead 250ms – 600ms (Python VM boot) 80ms – 180ms (V8 / Deno boot) < 4 ms (Compiled Single Binary)
Retrieval Cost per 1,000 Queries ~$0.10 – $0.50 (Embedding tokens) $0.00 $0.00 (Zero API cost, fully local)
Memory Footprint (RSS) ~120 MB – 350 MB ~60 MB – 140 MB < 15 MB

[!TIP] Reproduce Locally with your own LLM: We provide an automated benchmark runner in pure Go to verify Time-To-First-Token (TTFT) speedups and -80% token reduction on your local hardware (LM Studio / Ollama with Gemma, Qwen, Llama). Run make benchmark or explore the Progressive Disclosure Benchmark Suite.


🚀 Quickstart

1. Build the Tooling

Clone the repository and compile the standalone okf executable:

make build

This generates the standalone binary at bin/okf.

2. Basic CLI Commands

# Validate bundle conformance, graph connectivity, and description drift
./bin/okf validate knowledge --strict --drift

# Search concepts via in-memory BM25 scoring
./bin/okf search "architecture layers" knowledge

# Inspect a concept and its relationships (with --json support)
./bin/okf show architecture/layers knowledge --json

# Create a new concept with automated log.md and index.md bookkeeping
./bin/okf create decisions/auth-flow knowledge \
  --type Decision \
  --title "OAuth2 Authorization Flow" \
  --desc "Standardized on PKCE for client authentication."

# Update an existing concept
./bin/okf update decisions/auth-flow knowledge \
  --desc "Updated OAuth2 PKCE token refresh interval."

# Bootstrap full agent memory stack into any target project
./bin/okf bootstrap /path/to/project --name "My Project"

# Initialize only a bare OKF bundle in any directory
./bin/okf init my-project/knowledge

3. Bootstrapping Agent Memory in Any Project

Scaffold the complete OKF Agent Memory architecture into any new or existing repository with a single command:

# Bootstrap full memory stack into target project
./bin/okf bootstrap /path/to/my-project --name "My Service"

This automatically sets up:

4. Running as an MCP Server

okf ships with a native Model Context Protocol (MCP) server over stdio to seamlessly connect with Claude Code, Cursor, Codex, and other agent platforms:

./bin/okf mcp knowledge

Example MCP Configuration (claude_desktop_config.json or Cursor):

{
  "mcpServers": {
    "okf-memory": {
      "command": "/path/to/okf-agent-memory/bin/okf",
      "args": ["mcp", "/path/to/project/knowledge"]
    }
  }
}

📂 Repository Structure

okf-agent-memory/
├── benchmarks/             # Progressive disclosure benchmark suite & hardware test data
│   ├── data/               # Monolith docs vs OKF bundle test fixtures
│   └── results/            # Reproducible benchmark logs across 8+ local & cloud LLMs
├── cmd/
│   ├── okf/                # Standalone CLI and embedded MCP server (`stdio`)
│   └── okf-benchmark/      # Automated benchmark runner for LLM TTFT & token measurements
├── docs/                   # Guides, specifications, architecture & release playbook
│   ├── AGENT_TESTING.md    # Multi-agent testing, prompt scenarios & compatibility matrix
│   ├── ALTERNATIVES.md     # Comparison against Mem0, Letta, and ad-hoc markdown
│   ├── CLI.md              # Complete command-line & MCP tool reference
│   ├── CONVENTION.md       # OKF Agent Memory Convention v0.1
│   ├── GETTING_STARTED.md  # Comprehensive onboarding guide
│   ├── OKF-COMPATIBILITY.md# OKF v0.2 spec compatibility analysis
│   ├── RELEASE_PLAYBOOK.md # Automated release process & version tagging
│   ├── ROADMAP.md          # Project roadmap & milestones
│   └── SECURITY.md         # Data governance, secret prevention & PII rules
├── examples/               # Domain-neutral reference OKF v0.2 bundles
│   ├── books/              # Literature & cognitive science knowledge bundle
│   ├── coaching/           # Executive coaching & client session bundle
│   └── software/           # Microservices architecture & ADR bundle
├── knowledge/              # Project's own OKF v0.2 persistent memory bundle
│   ├── index.md            # Root progressive disclosure index (okf_version: "0.2")
│   ├── log.md              # Dated change log (ISO 8601 YYYY-MM-DD)
│   ├── project/            # Overview & value propositions
│   ├── architecture/       # 5-tier architecture & tooling decisions
│   ├── convention/         # Principles & lifecycle workflows
│   └── roadmap/            # Milestones
├── packaging/              # Distribution packaging
│   └── homebrew/           # Official Homebrew formula & tap instructions
├── pkg/okf/                # Zero-dependency Go core library (parser, validator, BM25, MCP, bootstrap)
├── AGENTS.md               # Operating instructions for AI coding agents
├── CONTRIBUTING.md         # Contribution guidelines & development workflow
├── Makefile                # Build, test, lint, validation & release targets
├── LICENSE                 # MIT License
├── README.md               # Main repository documentation
└── SECURITY.md             # Security policy & reporting guidelines

🧪 Testing & Verification

Run the full test suite and validate the repository's self-documenting knowledge bundle:

make check

📖 Further Documentation


📄 License

MIT License. See LICENSE for details.

okf-agent-memory (okf-memory/okf-agent-memory)

Searching Database…

这是什么?OKF Agent Memory 是面向 AI 编码智能体的 Git 原生持久化记忆层:它遵循 Open Knowledge Format(OKF)v0.2 规范,把架构决策和项目知识以带 YAML frontmatter 的纯 Markdown 文件形式直接存进你的仓库,让上下文得以跨会话保留,而不是在上下文窗口关闭时消失。
这是 CLI 工具还是 MCP 服务器?两者都是:它是一个用于搭建和搜索记忆的独立 'okf' 命令行二进制文件,同一个二进制文件还能通过 stdio 作为原生 MCP 服务器运行,让 Claude Code、Cursor 和 Codex 等智能体直接读写记忆。
怎么在我的项目里让它跑起来?克隆仓库并编译独立的 'okf' 可执行文件(bin/okf),然后在任意仓库中运行它的 bootstrap 命令,即可生成 knowledge/ 文件夹、.agents/skills/okf-memory/、AGENTS.md,以及一个带 validate/search 任务的 Makefile。
使用它需要 API 密钥或数据库吗?不需要 —— 它是纯 Go 实现,没有外部数据库、向量存储或 API 密钥;你只需要在本地安装 Go(和 make)来构建 okf 二进制文件,搜索则完全通过 BM25 在内存中运行。
我可以不加验证就相信它的速度和 token 节省声明吗?README 明确表示你应该自己验证这些声明:它附带一个本地基准测试运行器(make benchmark),可通过 LM Studio 或 Ollama 针对你自己的本地 LLM 测量 Time-To-First-Token 加速和约 80% 的 token 减少。
我的记忆数据实际存放在哪里?一切都保存在你自己的 git 仓库中,是 knowledge/ 下的纯 Markdown 文件 —— 不会有任何内容发送到外部服务器或厂商数据库。
什么是 OKF?OKF(Open Knowledge Format,开放知识格式)是一个厂商中立的规范(目前为 v0.2),用于结构化 AI 智能体的持久化记忆;本项目是它的参考实现,用纯 Go 编写。
knowledge/ 文件夹里最终会有什么?一个符合 OKF v0.2 的记忆包,由 index.md 和 log.md 组成,同时生成 .agents/skills/okf-memory/ 中的内嵌智能体技能定义和一个为项目定制的 AGENTS.md 文件。
这和只用一个 CLAUDE.md 或 AGENTS.md 文件有什么不同?那些是非结构化的临时笔记;OKF Agent Memory 把同样的想法规范化为标准化、可搜索的 OKF v0.2 记忆包,弥合了松散 Markdown 笔记与 Mem0、Letta 这类重量级向量数据库记忆工具之间的差距。
内置搜索有多快?项目声称对知识包的内存中 BM25 搜索低于 300μs,不涉及任何外部搜索索引或数据库。
Creator
okf-memory
Size
0.8 MB
Stars
819
Age
1mo
Commits · 90 Days