iai-personal-memory-engine

CodeAbraMIT活跃维护

给 AI 编程助手装一个本地长期记忆库,精确记住你说过的每句话和工作习惯,兼容 Cursor、Claude Code、Codex 等工具。

A cyber brain for your AI. It never forgets a detail, remembers exactly what you said, and learns how you work over time. Free, local, works with Cursor, Claude Code, Codex, OpenClaw, Hermes and more. MIT.

v3.3.0发布于 2026-10-22 19:02 UTC923star +2 / 7 天111fork同步于 2026-11-10 11:52 UTC

怎么上手

由 README 提炼,执行前请确认
python3.12 -m pip install -U iai-pme
iai-mcp crypto init
iai-mcp daemon install
硬件要求按 README 说明

README 未说明显存或 GPU 要求;引擎、存储与嵌入均在本地运行,支持 macOS 与 Linux,Windows 为 beta。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

本地 MCP 记忆服务器,逐字记录每次对话,并在每轮自动注入相关上下文

给 AI 编程助手装一个本地长期记忆库,精确记住你说过的每句话和工作习惯,兼容 Cursor、Claude Code、Codex 等工具。

核心能力

  • 逐字捕获每轮会话,写入加密本地存储
  • 空闲时聚类归纳语义记忆并强化或衰减边
  • 本地无 LLM 召回,融合语义、图、时间与词法证据
  • 提供 15 个 MCP 工具覆盖召回、纠正与画像
  • 用 AES-256-GCM 加密静态记录,数据不出本机

容易踩的坑

首次使用需从 Hugging Face 下载嵌入模型,可用 IAI_MCP_EMBED_OFFLINE=1 关闭;默认开启夜间 REM 步骤会调用 claude -p,可用 IAI_MCP_REM_DISABLED=1 关闭;MCP 服务器会在后台启动引擎且会话结束后继续运行,需用 iai-mcp daemon stop 停止;更换嵌入器需显式迁移,存储拒绝混用不兼容的嵌入代。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v3.3.0
  1. v3.3.0最新正式版2026-10-22 · 2026-10-22 19:02 UTC

    Added

    • The Claude Code plugin now ships an icon.
    • ROADMAP.md: what's planned next and where help is wanted.
    • iai-tools: a separate, brain-free code index, session-event store, and command executor, shipped as its own iai-tools console script, an iai-mcp tools subcommand, and an iai-tools MCP server. It indexes code by whole file, symbol, cross-reference, Python AST, exact literal, and vector lanes; runs commands through a resident executor daemon with bounded output; and offers bounded git-log/git-blame/git-diff queries. On Windows the executor binds a TCP-loopback transport behind a mandatory per-user auth token. It is off by default: iai-mcp capture-hooks install --with-tools registers its MCP server and five hooks, one of which blocks Grep, Glob, and shell grep/rg/find/fd/cat/head/tail/gh reads in favor of the iai-tools search and executor. The flag needs the MCP server and executor built from a source checkout (see docs/DEPLOYMENT.md); install refuses it and changes nothing until both are present.
    • New operator command iai-mcp prune-snapshots removes the pre-write snapshot directories that migration commands leave behind after --apply.
    • New operator command iai-mcp template-pollution-sweep tombstones internal prompt/template records by explicit id. Dry run by default; --apply snapshots the store first.
    • The nightly sleep cycle runs the one-time salience/entity backfill automatically on stores that predate capture-time salience, and iai-mcp doctor reports its status.
    • The per-turn memory pack admits one salience- or directive-tagged record per turn by existence rather than raw cosine, and serves it ahead of conversational matches.
    • A synthetic recall-quality benchmark (bench/recall_quality_fixture.py, bench/recall_quality_verdict.py) measures recall misses by cause against a dev/holdout split, with an A/A null-arm check (#85).

    Changed

    • The plugin's MCP launcher moved from bin/ to scripts/. It is the same readable shell script; reinstall or update the plugin to pick up the new path.
    • The plugin README, the repository README, the reference and llms.txt now say which files under ~/.iai-mcp/ are plain text (the per-turn capture spool until the engine's next pass, and the hook injection caches). They also list every network path with its off switch (REM claude -p is on by default, IAI_MCP_REM_DISABLED=1; the embedding model download, IAI_MCP_EMBED_OFFLINE=1), state when and why the engine reads the Claude Code login record, and explain that the background engine outlives the session, with how to stop it and delete the store. The plugin install line pins the engine version.
    • The plugin README now lists every place the engine touches the network and the local files the hooks read.
    • Read-only engine connections bound their page cache to 8 MiB by default (IAI_MCP_RO_CONN_CACHE_SIZE_KIB), and the read pool is clamped to a 256 MiB aggregate ceiling across IAI_MCP_RO_CONN_CACHE_SIZE_KIB and IAI_MCP_RO_POOL_SIZE. A long-running daemon no longer grows without bound on a large store (#173).
    • The working-tier goal re-anchors when a session's topic shifts and stays shifted, instead of staying fixed at the first message.
    • Ambient capture folds a near-duplicate paraphrase of an existing record into that record instead of inserting a new row, and rejects structural machine noise (harness templates, host-injected markup) at capture time.
    • iai capture --directive requires text that begins with the standing directive: marker.

    Fixed

    • The plugin manifest, marketplace entry, README, and reference docs now say fifteen MCP tools and list claim_check; they previously said fourteen.
    • The Claude Code plugin ships the recall renderer its per-turn hook imports, so the plugin's per-turn memory block is no longer empty.
    • Windows: the daemon no longer crashes at boot on
  2. v3.2.32026-09-14 · 2026-09-14 01:12 UTC
    查看更新说明

    Housekeeping: contributor tooling, hooks, and inline docs no longer reference an external code-search tool; runtime behaviour is unchanged. See CHANGELOG.

  3. v3.2.22026-09-14 · 2026-09-14 00:45 UTC
    查看更新说明

    Context-injection milestone + iai-mcp-server launcher. See CHANGELOG for the full user-facing list.

  4. v3.2.12026-09-09 · 2026-09-09 17:02 UTC
    查看更新说明

    Fixed

    • The transcript sweeper no longer errors when two sweeps run concurrently on the same session. _write_sweep_state now writes to a unique per-process temp file, so running transcript-sweep run back to back no longer races on a shared temp path and raises a spurious FileNotFoundError (surfaced as files_failed). No data was lost — content is staged before the state write — but the errors were alarming on a first run. (#165)
  5. v3.2.02026-09-08 · 2026-09-08 20:11 UTC
    查看更新说明

    Added

    • iai import [path] is a new one-command cold-start: it walks your existing Claude Code session transcripts and imports every turn through the same spine live capture uses, so a fresh install is not cold for its first sessions. Re-running is idempotent; sub-agent transcripts are excluded unless --include-subagents is passed.
    • iai import also imports Codex CLI rollout transcripts (--source codex), infers the source from a supplied path when --source is omitted, and scans both ~/.claude/projects and ~/.codex when neither is given. It resumes on re-run via a per-source state file, and --dry-run reports discovered file/turn counts and writes nothing.
    • iai directive list and iai directive remove <id> are new commands: list shows each live standing directive with a short stable id; remove retires one by id (flips the flag, stays searchable, never deleted). A genuine chat turn remove directive: <id> typed by the user retires a directive the same way. /iai-directive now covers list and remove.
    • Session-start now emits an availability marker: HEALTHY on a rendered pack, and a visible UNAVAILABLE marker (instead of nothing) when the daemon is unreachable or the render layer errors. A reachable-but-empty store still renders nothing — empty is not unavailable.
    • The per-turn <iai-mcp-recall> block now carries a DEGRADED (<reason>) marker when recall used a fallback or degraded read path, so a degraded answer is visibly distinct from a healthy one. Healthy recalls are unchanged.
    • Every rendered session-start pack now leads with a source_watermark comment recording how current the store was when composed; the shell hook appends [iai-mcp memory: STALE] when the served pack and the live store diverge by a full clock-hour.
    • iai-mcp doctor gained two checks: (kk) stop-hook failure marker (WARN/FAIL when recent capture failures are on record), and a watermark-fence check that FAILs when a derived watermark is impossibly ahead of its source and WARNs when consolidation has fallen far behind.
    • New iai_mcp.availability module accounts for measurable sessions so self-measurement excludes unavailable sessions from the pass/fail denominator.

    Changed

    • Rewrote the top of the README (tagline and overview) in plainer language and refreshed the project banner.
    • The Stop capture hook now writes a durable failure marker when it cannot find the CLI or the capture call fails or times out, instead of only logging to a dated file. It still exits 0. Existing installs need iai-mcp capture-hooks install to redeploy the updated hook.
    • On daemon boot, per-session working-tier cache files and the continuity live-state block are cleared, so a restart no longer re-serves a stale pre-restart focal task.
    • The nightly consolidation watermark now pins to the original cycle's start and survives an interrupted or resumed run, instead of certifying data that skipped steps never saw.

    Fixed

    • The transcript sweeper now discovers Cowork/local-agent sessions on both known Claude Desktop layouts, not only the legacy agent/ one. On a host where only the newer direct layout is populated, every sweep previously reported zero files; on upgrade the fix triggers a one-time backfill of every previously-missed transcript. (#165)
    • iai-mcp doctor's "(dd) exact-index coercions" check reads through the daemon's own socket first instead of colliding with the daemon's exclusive lock. Restart the daemon so it serves the new query kind.
    • iai-mcp migrate-to-lilli (the --src/--dst copy path without --swap) refuses an already-native source with a clear message instead of crashing.
    • iai-mcp migrate-to-lilli --swap no longer fails verification on a store older than the tombstone TTL. The migration is now a faithful verbatim copy — aged-tombstone cleanup defers to the nightly consolidation cycle instead of running on the mi

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    English | 中文


    What it is

    A local server that speaks the MCP protocol and gives Claude, and any other MCP-compatible agent, a long-term memory. It captures every turn of every session verbatim, organizes those captures over time into a personal map of who you are, and serves a small slice of relevant memory back at the start of each new conversation and turn. You never have to say "remember this" or "what did we say last time?".

    I built this for myself. It worked. The benchmarks were mostly for my own curiosity.

    Under the hood it's not a wrapper around someone else's vector store and graph library — the parts that matter are my own code: the storage engine, the community-detection algorithm, the hyperdimensional memory substrate, and a native engine that makes it fast.

    And unlike cloud memory services, there's no API key, no account, and no telemetry: the engine, the store, and the embeddings all run locally. The only things that leave your machine are the normal model calls your CLI already makes, a nightly consolidation step that asks your model for a single insight through the same subscription your CLI already uses (on by default; IAI_MCP_REM_DISABLED=1 turns it off), a daily version check, and the one-time download of the embedding model.


    Quick start

    Claude Code

    python3.12 -m pip install -U iai-pme
    

    Then run inside Claude Code:

    /plugin marketplace add CodeAbra/iai-personal-memory-engine
    /plugin install iai-memory@iai-pme
    

    Restart the session, then verify:

    iai --version
    iai-mcp daemon status
    iai-mcp doctor
    

    Python 3.11 is also supported.

    macOS or Linux: all-in-one source install

    curl -fsSL https://raw.githubusercontent.com/CodeAbra/iai-personal-memory-engine/main/scripts/bootstrap.sh | bash
    

    This builds the Rust engine and TypeScript wrapper, installs the background service and hooks, registers Claude Code, and runs the health check. It requires Git, Python 3.11/3.12, Node.js 18+, and Rust. To inspect the steps without changing anything:

    curl -fsSL https://raw.githubusercontent.com/CodeAbra/iai-personal-memory-engine/main/scripts/bootstrap.sh | bash -s -- --dry-run
    

    Other hosts

    python3.12 -m pip install -U iai-pme
    iai-mcp crypto init
    iai-mcp daemon install
    iai-mcp capture-hooks install --target codex
    

    Replace codex with cursor, antigravity, hermes, openclaw, or all. MCP tools work with any MCP-over-stdio client; automatic capture and context injection depend on the hooks exposed by the host. See the technical reference.

    New stores use the native engine format by default; an existing store keeps its current format on upgrade. To move an existing legacy SQLite store onto the native engine, run iai-mcp migrate-to-lilli — iai-mcp doctor prints the exact command, and the technical reference documents the full flow.


    What happens after installation

    EventAction
    PromptNew turns are appended to a session buffer as file IO; no embedding or engine RPC is needed on the capture path
    Session endRemaining transcript content is rolled over for ingestion; hook failures do not block the host
    Session startA bounded memory prefix is exposed as host context; an empty store or unavailable engine yields empty output
    Later turnsSupported hosts receive a small foresight or delta pack with age and revision markers
    Idle timeCaptures are embedded, deduplicated, encrypted, inserted, clustered, consolidated, reinforced, and decayed

    The background process is called the daemon in the CLI. The MCP wrapper and iai can still read the local store directly when it is asleep or temporarily unavailable.


    How it works

    Memory model

    TierContains
    EpisodicTimestamped, write-once fragments of what was said
    SemanticSummaries induced from related episodes during idle consolidation
    ProceduralTen bounded behavioural parameters learned over time

    Distinct hyperdimensional representations keep literal detail, semantic structure, and behavioural tendencies from collapsing into one vector surface.

    The local, LLM-free recall path combines semantic similarity, graph evidence, recency, temporal validity, and lexical evidence. memory_recall returns both hits and anti_hits; memory_contradict closes the old record's validity interval, creates a new record, and links the two.

    While idle, the engine groups related episodes, induces semantic memory, reinforces useful paths, and decays weak unreviewed edges. One REM step, on by default, may invoke claude -p through the user's existing Claude subscription, capped at no more than 1% of the daily quota; IAI_MCP_REM_DISABLED=1 turns it off. No Anthropic API key is required.

    First-party components

    ComponentRole
    HippoEncrypted records, vector index, and graph in one local store
    MOSAICLeiden-family community detection with stable community identity
    Lilli HDHyperdimensional substrate and structural recall
    Native engineRust embedder and graph kernels

    Dashboard and CLI

    iai brain
    

    The local dashboard searches the store, exposes graph neighbourhoods and contradictions, pins or fades memories, ingests files, controls the background engine, and reports token-use estimates from your own store.

    iai recall · temporal-recall · search · ask · capture · teach · upload
    iai watch · brain · status · last
    

    iai upload accepts documents, Office files, e-books, source code, configuration files, and directories. Full formats and administrative commands are listed in docs/REFERENCE.md.


    Benchmarks

    Every harness ships in bench/; methodology and reproduce commands are in BENCHMARKS.md.

    BenchmarkResult
    Rescue@10 after contradiction1.000
    Historical-verbatim hit@101.000
    LongMemEval-S R@5, product embedder0.962
    LongMemEval-S R@10, product embedder0.978

    Historical-verbatim retrieval uses a flat-cosine baseline of about 0.71. With the matched all-MiniLM-L6-v2 embedder, iai-memory and mempalace v3.3.6 both score R@5 0.966 and R@10 0.978; no win is claimed.

    On the author's store, an automatically injected memory pack averaged about 350 tokens versus about 2,850 tokens for the agent-search round trip it replaced: approximately 88% cheaper on that measured workload. This does not apply to explicit memory_recall, whose default response budget is 1,500 tokens.


    MCP tools

    memory_recall              memory_temporal_recall
    memory_recall_structural   memory_search
    memory_capture             memory_contradict
    memory_reinforce           memory_consolidate
    profile_get_set            topology
    schema_list                events_query
    episodes_recent            curiosity_pending
    claim_check
    

    Fifteen tools cover cue, temporal, structural, and lexical recall; checking a claim against memory; capture and correction; reinforcement and consolidation; behavioural-profile control; and store introspection.


    Compatibility

    HostAmbient behaviour
    Claude CodeSession-start recall, per-turn updates, turn capture, and session capture
    Codex CLIFull integration through Codex hooks
    CursorSession-start recall and capture; no per-turn text injection
    AntigravityRecall per invocation and lossless transcript capture
    Hermes 0.5.0+Recall before model calls and capture from its message store
    OpenClawMCP tools on request; no ambient shell hooks
    Gemini CLI and other MCP hostsMCP tools; no bundled host-specific hooks unless listed above
    Claude DesktopMCP tools; plain Chat does not expose Claude Code-style ambient hooks

    Privacy and limitations

    • Records are encrypted at rest with AES-256-GCM. The store and key live under ~/.iai-mcp/; back them up together. Two kinds of files there are plain text: the per-turn capture spool until the engine's next pass encrypts it, and the caches the hooks inject memory from. The plugin README lists them.
    • macOS and Linux use a Unix socket. Windows uses an ephemeral loopback port with a per-user token.
    • There is no iai-memory account, telemetry pipeline, hosted dashboard, or cross-machine sync.
    • iai-memory goes online in three places, each with an off switch: the nightly REM claude -p step (on by default, IAI_MCP_REM_DISABLED=1), a daily PyPI version check (IAI_MCP_VERSION_CHECK=0), and the first-use download of the embedding model from Hugging Face (IAI_MCP_EMBED_OFFLINE=1).
    • The engine checks that your Claude Code login is a subscription by reading Claude Code's login record (~/.claude/.credentials.json, or the macOS Keychain item) when the MCP server starts and before the REM step. Nothing from the record is sent anywhere.
    • The MCP server starts the engine in the background, and it keeps running after the session ends. Stop it with iai-mcp daemon stop.
    • The store refuses to mix incompatible embedding generations; changing the embedder requires an explicit migration.
    • Recall is usually mediocre during roughly the first ten sessions, and quality and latency depend on corpus size, language, embedder, and stored history.
    • The default store is English-first. Raw non-English records require an explicit raw:<lang> tag and a multilingual or custom embedder.
    • Windows support is beta. Ambient behaviour varies with host hook support.
    • The project is solo-maintained and has no enterprise SLA.

    Health and updates:

    iai-mcp doctor          # 38 checks
    iai-mcp daemon status
    iai-mcp self-update
    

    About the name

    IAI — Independent Autistic Intelligence describes the memory design.

    • Independent: the engine, store, embeddings, and dashboard run locally.
    • Autistic: literal preservation, precise cues, sustained focus, and rare events retained as rare rather than smoothed into a typical summary. This is an operational design description, not a diagnosis or casual metaphor.
    • Intelligence: used in the systems sense — a process that observes, adapts, reorganizes itself, and remains viable over time.

    “Personal memory engine” describes the scope: one person's memory, on one machine, used by the assistant they already have.


    Documentation

    Issues and pull requests are welcome. Changes to retrieval, capture, contradiction handling, or consolidation should include relevant benchmark reruns.

    Authors

    By Areg Aramovich Noya and Lilli Noya, in collaboration with the team at lcgc.dev.

    License

    MIT