项目 / akitaonrails/ai-memory
给 AI 编程命令行工具加长期记忆的方案,方便换不同家的 AI。
本站整理,非 GitHub 官方 description。
官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。
以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。
ai-memory通过hooks采集观察,会话结束生成wiki页,下次会话可检索全文、实体、链接和向量,并显式跨代理交接。
ai-memory 让 Claude Code、Codex、Cursor 等二十多个编码代理共享同一记忆,并在切换工具时通过带 owner 且只被认领一次的 handoff 交接进度。
来自 GitHub 仓库 README / 主页介绍正文,正文较长,已截断:保留前 20000 字符(原始 48,217 字节),完整内容见 GitHub 仓库。
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/logo-dark.png">
<img alt="ai-memory" src="docs/logo-light.png" width="480">
</picture>
</p>
> Long-term memory for AI coding agents. Quit Claude Code mid-task,
> start OpenAI Codex in the same directory, continue without
> re-explaining the architecture, the failed approaches, or the open
> questions.
**Website: [aimemory.sh](https://aimemory.sh)**
[](https://aimemory.sh)
[](https://github.com/akitaonrails/ai-memory/releases/latest)
[](rust-toolchain.toml)
[](LICENSE)
## Why ai-memory
Your coding agent probably has a memory feature already. Claude Code takes its
own notes, Cursor remembers some things, and every platform is adding more. They
all have the same limits: the notes live on one machine, belong to one agent,
and drop out of view when you switch tools or hand the work to a teammate.
ai-memory removes those limits.
- **It follows you across agents.** More than twenty harnesses (Claude Code,
Codex, Cursor, Gemini CLI, OpenCode, Grok, Devin, Kimi, Kiro, and others)
feed one shared memory. Quit Claude Code mid-task, open Codex in the same
directory, and the next agent picks up a handoff that says where you left
off, what failed, and what is still open. Handoffs are a typed protocol:
each one has an owner and is claimed exactly once.
- **It can carry the session, not just a summary.** Start agents with
`ai-memory run`: quit Claude Code, run `ai-memory run codex`, and Codex gets
the shared workstream plus a private, temporary local projection of Claude's
visible native history for exact details the bounded startup packet omitted.
The remote server receives only the harness and session identity, never the
local transcript path or body. Direct harness launches behave exactly as
before.
- **It follows you across projects.** A small profile of how you usually
work (your package manager, test layout, architecture habits) reaches
every new repository at session start, so you stop re-explaining yourself.
It sits below each repository's rules file as a default. It is on by
default for a single user, and on a shared server it is opt-in and private
per person. See [`docs/cross-project-profile.md`](docs/cross-project-profile.md).
- **It follows you across machines.** Memory lives in a server you run, on
the same laptop, a homelab box, or anywhere else, so the project you left
on the desktop is the project you resume on the laptop, with the same
knowledge and the same open questions.
- **It works for a team.** Point everyone at one server, and what one
person's sessions learn, everyone's agents can retrieve. Knowledge is
shared per project; personal handoffs stay personal. Multi-user auth,
per-person attribution, and an audit log are built in and are not a paid tier.
- **Your memory is plain markdown.** The source of truth is a git-backed
wiki of ordinary `.md` files: `grep` it, open it in Obsidian, edit it by
hand, `rsync` it. The database is a derived index that can always be
rebuilt from the files. There is no vector store to maintain and no
content locked in a binary blob.
- **It captures the work itself, silently.** Lifecycle hooks record what
happened (prompts, tool calls, session boundaries), sanitize it at a typed
privacy boundary before anything is stored, and the server consolidates it
into readable pages. You do not have to ask it to remember anything. The
default path uses **zero LLM calls**: capture, search, and handoffs all
work with no API key.
- **It ages memory without an LLM.** Memory decays on a schedule you can
tune per tier, and memory you use decays *slower*: opening a page,
searching it, or reaching it through a link counts as use. When episodic
notes go cold they can be compacted down to their durable facts (file
paths, error codes, decisions) instead of dropped. Near-duplicates
collapse into one, and likely contradictions get flagged, all with **zero
API calls**. Nothing is hard-deleted: the original stays in git and the
version chain (`restore-page` brings it back). Access-weighted retention is
always on because it can only keep memory *longer*. The parts that rewrite
or drop content (compaction, dedup, per-tier curves) stay off by default
until you turn them on.
- **It can also "dream", if you let it.** With an LLM configured, an opt-in
background pass rewrites whole clusters of cold notes into single coherent
pages while you are idle, and cancels as soon as you come back to work. It
never deletes a source (the pre-merge versions stay reachable), it is off
by default, and it has to pass a recall eval before it could become
default behavior. Unless you ask for more, the zero-LLM path above is what
runs.
- **It is honest about itself.** It ships as one self-contained binary.
Purge commands say exactly what "deleted" means. The write ceiling
(~700/s) is measured, not guessed. An audit log records every mutation.
## How it works
```
capture ──▶ consolidate ──▶ recall ──▶ handoff
hooks session-end search next agent,
observe summaries as + brief any harness
silently wiki pages injection
```
Agents emit sanitized observations through lifecycle hooks as you work.
At session end, observations become coherent markdown pages in the
project's wiki (optionally LLM-written; useful even without). The next
session, in any agent on any machine, gets a bounded brief and can search
everything: full-text, entities, links, and (optionally) vectors, fused
into one ranking. Cross-agent handoffs pass the baton explicitly.
The full design, including the invariants that keep multi-user and
multi-session use safe, is in [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md).
An optional [server-rendered management console](docs/management-ui.md) provides
user administration, session inspection and deletion, and personal MCP API keys.
Build with `--features management-ui` and start `serve --transport http
--enable-management-ui`; both compile-time and runtime opt-ins are required.
## Support matrix
Every row below is a first-party integration (MCP registration, lifecycle
hooks, or both) checked by CI. The full matrix with per-agent notes and
caveats is in [`docs/support-matrix.md`](docs/support-matrix.md).
| Area | Status |
| --- | --- |
| Linux | Supported |
| NixOS module | Supported |
| macOS | Supported |
| Windows via WSL2 | Supported |
| Native Windows | Experimental |
| Claude Code | Supported |
| Codex | Supported |
| Command Code | Supported |
| Devin CLI | Supported |
| OpenCode (V1/V2 auto-detected; legacy force-V2 aliases retained) | Supported |
| Cursor | Supported |
| Gemini CLI | Supported |
| Oh My Pi / OMP | Supported |
| Pi | Supported |
| Crush | Managed-only |
| Managed workstreams | Opt-in |
| Claude Desktop | MCP-only |
| OpenClaw | Supported |
| Antigravity CLI | Supported |
| Grok Build CLI | Supported |
| Swival CLI | MCP-only |
| Zero | Supported |
| ZCode | Supported |
| Kimi Code | Supported |
| Kiro CLI | Supported |
| Pool | Hooks-only |
| GitHub Copilot CLI | Supported |
| Factory Droid | Supported |
| Meta Muse Code | Supported |
| CodeBuddy Code | Hooks-only |
| WorkBuddy | Supported |
| IBM Bob | Supported |
| Qwen Code | Supported |
| Qoder | Supported |
| VS Code Copilot | MCP-only |
| Zed | MCP-only |
| DeepSeek Harness (DSH) | Hooks + MCP |
| Cline CLI | Hooks + MCP |
| FreeBuff | MCP-only |
| Prime Agent | MCP-only |
| Hermes Agent | Supported |
| GrizzyBot | Supported |
| LLM/auth providers | Supported |
| Embedding providers | Supported |
## Coming from another tool?
Most agent-memory tools optimize for one thing: extracting atomic facts per
turn, a temporal knowledge graph, an agent-editable memory OS, or a hosted
context API. ai-memory is built around a **git-backed markdown wiki as the
source of truth**, with a derived index for retrieval. It captures
automatically from lifecycle hooks, is shared across agents, machines, and
people, and works with **zero LLM calls by default**. This table shows what
carries over from each tool and what you gain:
| Coming from… | What's similar | What you gain |
|---|---|---|
| **Mem0 / fact extractors** (LangMem) | Automatic per-turn capture | Memory compiles into readable **pages** you own and edit, not opaque fact rows; retrieval fuses FTS + entity + graph (+ local vectors) with no cloud API key |
| **Zep / Graphiti** (temporal KG) | Temporal reasoning, typed relations | Bi-temporal-lite (`as_of`, version-filtered search) and typed edges without standing up a graph database, in one binary |
| **mcp-memory-service** (fact rows, SQLite) | SQLite + local embeddings, hook capture, typed edges, honest numbers, per-tier decay curves, extractive compression, DBSCAN cold-cluster dedup, access reinforcement, and contradiction flagging | Human-editable markdown **pages** instead of fact-rows, cross-agent claim-once handoffs, and the same aging machinery done **zero-LLM by default, reversibly** (supersede-not-delete + `restore-page`), and **off by default** |
| **basic-memory** (file-first markdown) | Markdown-on-disk as the source of truth | Automatic lifecycle capture and a derived FTS/entity/graph index on top, cross-agent handoffs, and multi-user sharing built in |
| **Claude Code built-in memory** | "Remember my project" convenience, zero setup | Synced across machines and agents, searchable, team-capable, and captures tool lifecycle, unlike a machine-local `MEMORY.md` index per repository |
| **Hindsight / OpenViking** (LLM or VLM in the loop) | Living pages / document memory with a background consolidation loop, belief-strength confidence, and an opt-in LLM "dream" rewrite of cold clusters | A self-contained binary that runs zero-LLM by default and keeps memory in markdown files that are the source of truth, not a mirror; claim-once handoffs; the dream/belief features are **opt-in, off by default, and never delete a source** (vs a mandatory LLM loop) |
| **Supermemory / LiquidLM** (hosted memory API) | A managed second brain with automatic ingestion | Git-versioned markdown you own, no required API spend, offline operation, and per-project team sharing; ai-memory remembers *this repo*, not a general vault |
Across all of these, ai-memory gives you files you own (git-backed markdown),
a zero-LLM default, one self-contained binary, sharing across agents, machines,
and teams, automatic lifecycle capture, and typed, claim-once handoffs.
Opt-in features (LLM consolidation, vector search, the "dream" consolidation
pass, belief-strength in ranking) stay opt-in, and the zero-LLM aging path
(per-tier decay, extractive compaction, dedup, contradiction flagging,
access-weighted retention) works with no API key at all.
**Built on the shoulders of:** the
[Karpathy LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f)
(compile-not-retrieve),
[agentmemory](https://github.com/rohitg00/agentmemory) (hook capture for coding
agents), [basic-memory](https://github.com/basicmachines-co/basic-memory)
(markdown-on-disk truth),
[cognee](https://github.com/topoteretes/cognee) (pipeline composition and
triplet embeddings),
[Hermes Agent](https://github.com/NousResearch/hermes-agent) (the
self-improvement loop), and [A-MEM](https://arxiv.org/abs/2502.12110)
(Zettelkasten-style atomic notes).
The full comparison, covering where each approach wins, where ai-memory
differs, and the published benchmark, is in [How ai-memory compares](docs/comparison.md).
## Quick start
### Linux and macOS (two commands, no root)
```bash
curl -fsSL https://github.com/akitaonrails/ai-memory/releases/latest/download/install.sh | sh
ai-memory setup
```
`install.sh` downloads the release for your OS and CPU, checks it against the
release's published SHA-256 checksum (it refuses to install without a match),
and links `~/.local/bin/ai-memory`. `ai-memory setup` then creates the data
directory with a bearer token in an owner-only file, starts a per-user service
(systemd `--user` or a launchd LaunchAgent), and wires MCP, hooks and Agent
Skills for every agent it finds, or the ones you name with `--agent`. It shows
the plan, with where it found each agent, and asks first: answer `y`, or type
the numbers of the agents to wire. `--plan` prints the plan and changes
nothing, `--web` shows the plan as a page in your browser and applies the agents
you tick there, `--yes` skips the question, and running it again changes nothing.
Afterwards, restart your agents and ask one of them "What do you remember
about this project?" to see it answer through ai-memory. Details, the environment
variables and how to verify the script before running it are in
[`docs/install.md`](docs/install.md#one-step-native-install-installsh--ai-memory-setup).
An AI agent installing ai-memory for you can follow
[`INSTALL_FOR_AGENTS.md`](INSTALL_FOR_AGENTS.md).
Claude Code and Codex users can wire their agent as a marketplace plugin
instead (the binary is still installed as above):
```bash
claude plugin marketplace add akitaonrails/ai-memory && claude plugin install ai-memory@ai-memory
codex plugin marketplace add akitaonrails/ai-memory && codex plugin add ai-memory@ai-memory
```
Codex then asks you to trust the hooks in `/hooks`. See
[Marketplace plugins](docs/install.md#marketplace-plugins).
### Windows (two commands, no admin)
In PowerShell:
```powershell
irm https://github.com/akitaonrails/ai-memory/releases/latest/download/install.ps1 | iex
ai-memory setup
```
`install.ps1` checks the release zip against its published SHA-256 checksum,
unpacks it under `%LOCALAPPDATA%\Programs\ai-memory` and adds that directory
to your user `PATH`. `ai-memory setup` then does what it does on Linux and
macOS, with a logon entry in place of the service: the server starts when you
sign in, with no console window, and restarts if it fails. Details and the
other Windows setups (WSL2, Docker Desktop, a real Windows service) are in
[`docs/windows.md`](docs/windows.md).
With [Scoop](https://scoop.sh):
```powershell
scoop bucket add akitaonrails https://github.com/akitaonrails/scoop-bucket
scoop install ai-memory
ai-memory setup
```
Update it with `scoop update ai-memory`.
### Arch Linux (AUR)
For native Arch installs, use the AUR packages. They install
`/usr/bin/ai-memory`, packaged hook sources, and both system-level and
user-level systemd units.
```bash
yay -S ai-memory-bin # prebuilt Linux x86_64/aarch64 binary
yay -S ai-memory # builds from source
ai-memory setup # data dir, user service, agents, self-check
```
### Homebrew (macOS and Linux)
The tap installs the prebuilt binary and its hook sources on macOS and on
Linux, including atomic distributions such as Bazzite or Fedora Silverblue
where Homebrew is the usual way to add tools:
```bash
brew install akitaonrails/tap/ai-memory
ai-memory setup # data dir, user service, agents, self-check
```
Use either `ai-memory setup` or `brew services start ai-memory`, not both.
Details are in [`docs/install.md`](docs/install.md#homebrew-macos-and-linux).
### Fedora (RPM)
Download the `x86_64` or `aarch64` RPM from the
[latest release](https://github.com/akitaonrails/ai-memory/releases/latest),
then install it:
```bash
sudo dnf install ./ai-memory-*.rpm
```
On a single-user workstation, `ai-memory setup` then does the rest, as on the
two-command path above: data dir and token, a user service, the agents it
finds, and a self-check.
```bash
ai-memory setup
```
System service installs use `/var/lib/ai-memory` and `/etc/ai-memory/` via the
packaged unit. Full user-service, system-service, auth, and provider setup is in
[`docs/install.md#arch-linux-native-packages-aur`](docs/install.md#arch-linux-native-packages-aur).
### macOS (menu bar app)
A self-contained `.app` that bundles the native `ai-memory` binary and
`hooks/` tree, starts the existing LaunchAgent, and opens `/web`,
`ai-memory status`, and `config.toml` from the menu bar. Wiki, SQLite,
config, and models stay in `~/Library/Application Support/ai-memory`, so
replacing the app is an update and does not rewrite that tree.
Needs a Rust toolchain and Xcode / Swift 6 (same as a source build):
```bash
git clone https://github.com/akitaonrails/ai-memory
cd ai-memory
./companions/ai-memory-macos/build.sh
open "companions/ai-memory-macos/dist/AI Memory.app"
```
Drag **AI Memory.app** to `/Applications`, then **Install & Start Server**
from the menu extra (no Dock icon). The app reads the bearer token `init`
wrote into its data dir, so the status item turns green on its own. Then wire
your agents with the bundled binary; `--no-service` leaves the app's
LaunchAgent in charge:
```bash
BIN="/Applications/AI Memory.app/Contents/Resources/runtime/ai-memory"
"$BIN" setup --no-service
```
Prebuilt tarball and launchd-without-the-app paths:
[`docs/macos.md`](docs/macos.md). Companion details:
[`companions/ai-memory-macos`](companions/ai-memory-macos).
### Docker
You need: Docker or Podman + an agent CLI from the [Support Matrix](#support-matrix),
or anything else that speaks MCP.
The published Docker image includes `linux/amd64` and `linux/arm64` variants,
so Apple Silicon Macs and ARM64 Linux hosts can pull `akitaonrails/ai-memory`
without `--platform linux/amd64` emulation.
The Docker quick-start below has **no authentication**: the container never
runs `init`, so it starts without a token. The server binds to loopback only,
so nothing outside the machine can reach it, but local processes and browser
pages can. Native installs that run `ai-memory init` get a bearer token by
default; see [Security](#security) below for that and for adding a token here.
```bash
# 1. Install the ai-memory CLI wrapper (a small shell script that
# runs the binary inside a container with your $HOME mounted). This is
# the only thing that needs to live on the host filesystem.
mkdir -p ~/.local/bin
wrapper_tmp="$(mktemp -d)"
trap 'rm -rf "$wrapper_tmp"' EXIT
wrapper_base=https://github.com/akitaonrails/ai-memory/releases/latest/download/ai-memory-wrapper
curl -fsSL "$wrapper_base" -o "$wrapper_tmp/ai-memory-wrapper"
curl -fsSL "$wrapper_base.sha256" -o "$wrapper_tmp/ai-memory-wrapper.sha256"
expected="$(awk 'NR == 1 { print $1 }' "$wrapper_tmp/ai-memory-wrapper.sha256")"
if command -v sha256sum >/dev/null 2>&1; then
actual="$(sha256sum "$wrapper_tmp/ai-memory-wrapper" | awk '{ print $1 }')"
else
actual="$(shasum -a 256 "$wrapper_tmp/ai-memory-wrapper" | awk '{ print $1 }')"
fi
[ -n "$expected" ] && [ "$actual" = "$expected" ] || { echo "wrapper checksum mismatch" >&2; exit 1; }
install -m 0755 "$wrapper_tmp/ai-memory-wrapper" ~/.local/bin/ai-memory
rm -rf "$wrapper_tmp"
trap - EXIT
# Most distros put ~/.local/bin on PATH automatically. If `which
# ai-memory` comes up empty, add this to ~/.bashrc / ~/.zshrc:
# export PATH="$HOME/.local/bin:$PATH"
# 2. Start the server. `--restart unless-stopped` makes it come back
# on docker daemon restart and on machine boot (provided your
# docker service is enabled at boot — `sudo systemctl enable
# docker` on most distros). Loopback-only bind (`127.0.0.1:49374`)
# so nothing outside this machine can reach it. Omit the LLM /
# EMBEDDING lines for zero-LLM mode — FTS5 search still works
# without any keys.
docker run -d --name ai-memory \
--restart unless-stopped \
-p 127.0.0.1:49374:49374 \
-v ai-memory-data:/data \
-e AI_MEMORY_LLM_PROVIDER=anthropic \
-e ANTHROPIC_API_KEY=sk-ant-... \
-e AI_MEMORY_EMBEDDING_PROVIDER=openai \
-e OPENAI_API_KEY=sk-... \
docker.io/akitaonrails/ai-memory:latest
# 3. Wire your agent