ownmem README

项目的 README,来自 github.com/grpcer/ownmem。合并为一个 markdown 文件:README.md。

OwnMem

Git-native memory for AI coding agents

Open-source project memory for Claude Code, Codex, Cursor, Gemini CLI, and other AI coding agents — local, deterministic, reviewable, and never written behind your back.

npm version npm downloads GitHub stars release gates node >= 20.6 license Apache-2.0

English · 简体中文 · 繁體中文 · 日本語 · 한국어 · Español · Français · Deutsch · Português (BR)

✨ Why OwnMem

Most AI agent memory systems optimize for remembering more. OwnMem starts with a different question: who owns project knowledge, who may change it, and how can a bad memory be stopped before it changes a coding agent's actions?

Advantage What it means in practice
The repository owns memory Readable Markdown in .ownmem/ travels through clone, review, and rollback with the code, and every agent in the repository reads the same source.
Deterministic local recall Default recall makes no model or network call; the same query, config, and snapshot produce the same ranking.
Evidence before authority Content cannot declare itself trusted. Independent receipts and live evidence checks decide delivery.
It tells you when it does not know Delivery is graded: the memory quoted, up to three pointers, or an abstention that names the gate that refused.
Net-zero growth A hard entry count that only ratchets down, so adding to a full corpus means retiring something in the same change.
OwnMem public benchmark: Recall@1 of 100% on 128 queries in 40 languages, against 3.9% for grep -F on the same corpus; recall latency of 0.46 ms at P50 and 1.05 ms at P95 over 4,200 samples, under a 5 ms release gate; MRR 1.000, all 40 unrelated queries abstained, no model or network calls, two runtime dependencies.

Measured on the locked CC0 corpus in this repository. Reproduce it in a clone with npm run benchmark.

🆚 How it compares

OwnMem does not replace CLAUDE.md or AGENTS.md. Those files say how to work here, and they are read in full every turn. OwnMem answers a different question — which of the things this project learned the hard way are worth putting in front of the model for this task — and it is allowed to answer “none of them”.

Instruction files Built-in agent memory OwnMem
Who writes it you, by hand the agent, from your conversations you, reviewed like code
Where it lives one file in the repository the vendor's account Markdown in your repository
What reaches the model all of it, every turn whatever its own recall picked one of three tiers, under a token budget
When an entry is wrong you edit the file you may never see the entry evidence drift downgrades it and names what moved
Cost per turn the whole file in tokens a retrieval call no model call, no network call

🚀 Quick start

Requires Node.js 20.6 or newer. Run this inside the repository that should own the memory:

npm install --save-dev ownmem
npx ownmem init --hook --hosts claude,codex

Reopen the agent afterwards. Name the hosts you use in --hosts (claude, codex, cursor, gemini, grok); the list is recorded, and passing it again later is how a host is added or removed. init creates .ownmem/ and the host adapters, edits instruction files such as CLAUDE.md only inside managed blocks, and prints any one-time step a host still needs. Add --check to the same command to preview it, and --locale auto to write the generated instructions in your system language.

Host How recall happens Setup
Claude Code A hook before every Edit and Write, and on request claude
Codex A hook before every patch it applies, and on request codex; the hooks need three one-time trust steps, which init prints
Grok CLI Reads Claude Code's hook configuration through its compatibility layer grok, alongside claude if you use both; trust the folder once with /hooks-trust
Cursor An always-applied rule, or the MCP server cursor; the MCP server takes one manual step, see Plugins
Gemini CLI Instructions, or the MCP server gemini; the MCP server takes one manual step, see Plugins

⚠️ Upgrading from 0.6.0? Update the package with npm install --save-dev ownmem@latest, then run npx ownmem init --update before anything else. 0.6.0 installed hooks whose subcommands no longer exist, so an installation that keeps them runs a failing command on every Bash call. The update removes them and never touches hooks you wrote yourself. Updating covers the rest, including the core.hooksPath cleanup.

💬 Daily use

Keep working in plain language. Your agent drafts a memory when you ask for one, and you review it like code:

“Remember this: staging deployment timeouts come from the pool cap, not too few workers. Check both together next time.”

“Before changing this, check whether the project memory has seen the same failure.”

Recall answers in one of three tiers: the memory quoted, up to three pointers to go and read, or an abstention. A real run:

$ npx ownmem recall -- "staging deploy timed out again, should I add more workers?"
== staging deploy timed out again, should I add more workers? ==
  staging_timeout_pool_cap  [score=0.875 lanes=exact,bm25f,ngram fields=body,codePath,description,hooks,name,triggers]
      matched deploy,more,out,staging,staging deploy timed out,timed
      trust advisory authority · lifecycle advisory (not fully verified)
        Treat it as a lead to re-check against the code, not as an established fact.
      excerpt(body) **Why**: `DB_POOL_MAX` is 10 on staging. Adding workers only queues more requests behind the same ten connections, so the deploy health check times out sooner, not later.
      file .ownmem/staging_timeout_pool_cap.md

Trust is stated, not implied. Nothing backs this entry yet — no review has confirmed it, and it cites no authority document or code anchor — so it arrives as a lead to re-check rather than as an established fact.

The commands you will reach for yourself:

npx ownmem new staging_timeout_pool_cap   # scaffold one memory that already passes every gate
npx ownmem report --since 7d              # used? fast enough? right? what to do next
npx ownmem dashboard --open               # open the local console
npx ownmem mcp                            # serve recall and read to any MCP host over stdio
The OwnMem local console: the known false-delivery residual as the headline figure, the lookup funnel beside it, corpus and evidence health below, and navigation for performance, quality, governance, and semantic retrieval.

ownmem mcp exists for hosts without hooks. It exposes exactly two tools, recall and read, and neither can change a memory; the gate commands (audit, trust, compile) and every memory write stay off that surface. Plugins shows how to register it so it runs the project's own copy.

🧩 How it works

OwnMem architecture: repository-owned Markdown and independent trust receipts compile into immutable snapshots; deterministic local recall passes four delivery gates and arrives in one of three tiers — the memory quoted, up to three pointers, or an abstention that names its reason — while local feedback ledgers, an evaluation harness and a net-zero quota bound what the corpus becomes.

Mechanisms, threat model, and research mapping: Technical design.

🔒 Privacy and boundaries

🧭 When to use it

Good fit Choose another system when
A team wants project knowledge reviewed and migrated with code. You need a cross-repository personal profile or global user memory.
Several coding agents rotate through one repository. You need to capture every conversation automatically with no evidence or risk boundary.
Local, reproducible recall with no retrieval API bill matters. You need large-scale cloud vector search or a real-time global knowledge graph.
Bad memory must be attributable, rejectable, and reversible. Maximum recall volume matters more than governance.

📚 Documentation

Document Purpose
Architecture Package boundaries, snapshots, trust, and delivery
Technical design Mechanisms, threat model, and research mapping
Plugins Per-host setup, plugins, and trust steps
Updating Safe repository updates and version migrations
Privacy Local data and optional channel boundaries
Changelog Version history
Contributing Reporting issues and sending changes
Security Reporting a vulnerability
License Apache-2.0
Research lineage

OwnMem does not claim these foundations as inventions. Its contribution is their composition into an executable protocol for repository memory:

These citations describe the research lineage; they do not imply that the papers implement OwnMem or that OwnMem reproduces their experiments.

OwnMem is open source. Reproducible issues and pull requests are welcome.

ownmem (grpcer/ownmem)

正在搜索数据库…

这是什么?OwnMem 是一个开源、Git 原生的 AI 编程代理记忆系统,面向 Claude Code、Codex、Cursor 和 Gemini CLI 等。它把项目知识以可审查的 Markdown 存在你仓库的 .ownmem/ 文件夹里,让多个代理共享同一份本地、确定性的记忆。
这是 CLI 工具,还是我导入的库?它是一个用 npx 安装的 Node.js CLI,通过钩子文件(.claude/settings.json、/.codex/hooks.json)接入你的编程代理,并在你的仓库里添加一个 .ownmem/ 文件夹;它不是拿来当库导入的东西。
怎么让它跑起来?在你想让 OwnMem 管理的仓库里运行 “npx ownmem init”,然后重新打开你的编程代理,让它加载新的钩子。你可以用 “--hosts claude”、“--hosts codex”、“--hosts cursor” 或 “--hosts gemini” 只针对某个代理,并先用 “npx ownmem init --check” 预览改动。
除了 Node.js 我还需要什么?只要 Node.js 20.6 或更新版本;OwnMem 自身的依赖只有 “ajv” 和 “yaml”,默认不需要任何 API 密钥或外部服务。
每个受支持的代理开箱表现都一样吗?不一样——Codex 需要在 config.toml 里启用钩子,而且项目必须先被明确信任,它才看得到钩子文件;Grok CLI 需要通过 “/hooks-trust” 对其文件夹信任一次,否则它会静默跳过所有钩子。Cursor 和 Gemini CLI 只有指令适配器,所以它们能读取记忆,但永远不能写入。
它实际支持哪些编程代理?目前支持 Claude Code、Codex、Cursor、Gemini CLI 和 Grok CLI,其中 Claude Code 和 Grok CLI 获得完整的基于钩子的采集,而 Cursor 和 Gemini CLI 只能从记忆里读取。
记忆召回需要联网或调用 LLM 吗?不需要——默认的排序管线(精确匹配、BM25F、n-gram、模糊匹配和图匹配)完全跑在本地仓库文件和快照上;可选的 embeddings 通道只有在本地 A/B 证据证明它有帮助后才会启用。
我的项目记忆和使用数据实际去了哪里?运行时遥测事件写入一个被 Git 忽略的本地目录,三十天后过期,从不离开本机;提交的只有一个匿名、按天汇总的摘要,不含查询文本、文件路径或机器名。
如果 OwnMem 不确定某条记忆可信,会怎样?它不会瞎猜,而是在自己的证据和操作风险门控之下,把这条目以建议形式交付、隔离起来,或完全弃用,让未经证实的内容永远不会悄悄影响代理的行为。
糟糕的自动记忆编辑能撤销吗?能——每次自动编辑都带有经过验证的逆操作,所以失败或有害的改动可以恢复到之前的确切字节,而不会抹掉编辑历史。
和其他代理记忆工具相比,OwnMem 有什么不同?大多数记忆系统追求记住更多;OwnMem 反而让每个条目都过一遍证据、风险和生命周期检查的关卡,这样坏记忆在改变代理行为之前就能被拒绝、隔离或回滚。
OwnMem 能用 embeddings 或向量搜索吗?Embeddings 是可选的第六条检索通道,但在本地 A/B 对比证明它们确实能在这个仓库自己的数据上改善结果之前,它们的权重一直是零。
作者
grpcer
大小
2.6 MB
星标
427
时长
3个月
提交 · 90 天