RecallNest

RecallNest · AI 客户端共享记忆层 · MIT 许可RecallNest · shared memory layer for AI clients · MIT-licensed

跨 AI 客户端
共享的长期记忆层
A persistent memory layer shared across AI clients

RecallNest 以 LanceDB 为存储,通过 MCP(stdio)与 HTTP API 向 Claude Code、Codex、Kimi、Antigravity 等客户端提供统一的读写接口。会话结束时写入检查点,新会话启动时恢复上下文;存储位于本机,其他主机通过 ssh 接入同一存储。RecallNest stores memory in LanceDB and exposes one read/write interface over MCP (stdio) and an HTTP API to Claude Code, Codex, Kimi, Antigravity and other clients. Sessions checkpoint on exit and restore context on start; the store stays on your machine, and other machines reach it over ssh.

查看 GitHub 仓库View on GitHub 安装说明Installation

01 · 问题Problem

会话之间没有共享上下文No shared context between sessions

项目配置、调试过程中的决策、实体映射分散在各客户端各自的会话记录里:新会话读不到,其他工具也看不到。Project configuration, debugging decisions and entity mappings live in each client's own session history: a new session cannot read them, and other tools cannot see them.

02 · 架构Architecture

单一存储,多协议接入One store, several ways in

命令行 agent 与支持 MCP 的桌面应用通过 MCP(stdio)接入;仅支持 HTTP 的脚本与定时任务调用 HTTP API;移动端经只读网关访问;远程主机将启动命令替换为 ssh,即可共享同一存储。CLI agents and MCP-capable desktop apps connect over MCP (stdio); scripts and cron jobs that only speak HTTP call the HTTP API; mobile clients go through a read-only gateway; a remote host replaces the launch command with ssh and shares the same store.

  • 44 个 MCP 工具44 MCP tools
  • 21 个 HTTP 端点21 HTTP endpoints
  • LanceDB 本地存储LanceDB, on your machine
  • Jina v5 嵌入 · 1024 维Jina v5 embeddings · 1024-dim

03 · 记忆模型Memory model

六类记忆、三级粒度、版本链Six categories, three granularities, version chains

每条记忆归入六个类别之一:profile、preferences、entities、events、cases、patterns,并存储三级粒度(单句摘要、要点、全文);检索时按相关度与 token 预算选择返回层级。同一结论的修订以 supersede 链记录,旧版本作为历史保留。Each memory belongs to one of six categories — profile, preferences, entities, events, cases, patterns — and is stored at three granularities: one-line summary, key points, full text. Retrieval picks the layer by relevance and token budget. Revisions of the same conclusion form a supersede chain, with earlier versions kept as history.

04 · 检索Retrieval

默认向量检索,可选混合检索Vector search by default, hybrid on demand

默认使用向量检索;可启用 BM25 全文检索、L0/L1/L2 多粒度向量与知识图谱(PPR)。写入时可为每条记忆附加 2–6 条触发语句(triggers),独立嵌入、仅用于召回,不作为证据返回。Vector search by default; BM25 full-text, L0/L1/L2 multi-granularity vectors and a knowledge graph (PPR) can be enabled. At write time a memory can carry 2–6 trigger phrasings, embedded separately and used only for recall, never returned as evidence.

Query   : deploy rollback
Hits    : 5

#  ID       Score Category  Tier        Source  Date        Age  Retrieval Path
1  ee79037a 46.1% cases     peripheral  cc      2026-08-25  2d   vector
   [assistant] Rolled back to the previous image and pinned the digest so the next…
   prov : evidence/transcript-ingest
   imgs : 52 agent-made in this session · read sess=dca70d4a
召回输出示例(摘自 README)Sample recall output (from the README)

05 · 生命周期Lifecycle

Weibull 衰减与豁免规则Weibull decay with explicit exemptions

记忆按 Weibull 曲线随时间衰减,半衰期由重要度调节。patterns 类别不做时间衰减;置顶(pinned)、7 天内被访问过、核心层且重要度 ≥ 0.95 的记忆同样豁免。从会话记录中提取的片段停留在证据层,升级为持久记忆需经过单独的、附带证据要求的晋升步骤。Memories decay along a Weibull curve, with importance shaping the half-life. The patterns category is exempt from time decay, as are pinned memories, memories accessed in the last 7 days, and core memories with importance ≥ 0.95. Fragments extracted from transcripts stay in the evidence layer; promotion to durable memory is a separate, gated step with its own evidence requirement.

06 · 会话连续性Session continuity

检查点与上下文恢复Checkpoints and context restore

会话结束时,checkpoint_session 记录本次的决策与待办;新会话中调用 resume_context 即可恢复。恢复的状态仅作为交接参考,不代表仓库的当前状态。On exit, checkpoint_session records the session's decisions and open loops; in a new session, resume_context restores them. Restored state is a handoff reference, not a statement about the repository's current state.

07 · 版本演进Release history

13 个标签版本,
514 次提交
13 tagged releases, 514 commits

按时间列出 CHANGELOG 记录的主要版本与关键改动,日期取自 git 提交记录。Major versions recorded in the CHANGELOG, oldest first, with their key changes. Dates come from the git history.

  1. v1.0 · 2026-03-03

    初始版本。对 Claude Code 会话记录做向量检索;LanceDB 存储,Jina 生成嵌入,命令行使用。Initial release. Vector search over Claude Code transcripts; LanceDB storage, Jina embeddings, a command-line interface.

  2. v1.1 · 2026-03-06

    混合检索、MCP 与工作台。向量与 BM25 关键词混合检索,权重可配置;MCP server 首批提供 9 个工具;本地 Web 工作台。Hybrid retrieval, MCP and a workbench. Vector plus BM25 keyword retrieval with configurable weights; an MCP server with 9 tools; a local web workbench.

  3. v1.2 · 2026-03-08

    首个可分发版本。目标:新用户从 git clone 到第一条检索结果不超过 15 分钟。新增 lm doctor 预检、lm demo 与 CI;Jina key 无效时在导入开始前报错。First distributable release. Target: from git clone to a first search result in 15 minutes. Adds the lm doctor pre-flight check, lm demo and CI; an invalid Jina key now fails before ingest begins.

  4. v2.1 – v2.2 · 2026-04-11

    引入记忆研究中的机制。依据记忆哲学的 9 个研究维度完成五项改造,包括情绪感知衰减、四级隐私与级联遗忘、建构式检索;随后补齐研究扫描指出的三处引擎缺口:置信度加权、干扰检测与主动遗忘、时间有效期。Mechanisms from memory research. Five changes derived from nine research dimensions in the philosophy of memory, among them emotion-aware decay, four privacy tiers with cascade forgetting, and constructive retrieval; then three engine gaps found by a research scan: confidence weighting, interference detection with active forgetting, and validity windows.

  5. v2.3 · 2026-04-14

    接入外部数据源。Connector-v1 JSON 标准与 Obsidian 库导入;每个数据源导入时写入心跳,超过 7 天告警、超过 30 天报错。External data sources. The Connector-v1 JSON standard and Obsidian vault ingestion; every source writes a heartbeat on ingest, with a warning after 7 days and an error after 30.

  6. v2.5.0 – v2.5.2 · 2026-05-27

    技能记录接入使用反馈。首次实际调用 store_skill → workflow_observe → retrieve_skill 即返回 skill_not_found:查询只接受完整 UUID,返回给 agent 的却是 8 位前缀。统一 ID 后成功计数开始累加;技能类型收窄为说明文档,schema 不再暗示 RecallNest 会执行技能。Skill records receive real outcomes. The first real store_skill → workflow_observe → retrieve_skill run returned skill_not_found: lookup accepted only full UUIDs, while agents were shown 8-character prefixes. With ids reconciled, the success count began to move; skill types were narrowed to runbooks, so the schema no longer implies that RecallNest executes them.

  7. v2.5.3 · 2026-05-29

    诊断工具与失效功能。一轮多 agent 审查发现:诊断工具在生产库上给出虚假的健康结论,三个功能完全失效,检索分数的显示失去区分度。修复后,真实库上检出的矛盾 0 → 174、重复 0 → 1,473。Diagnostics and dead features. A multi-agent review found diagnostics reporting false health on the production store, three features that never worked, and score displays that no longer discriminated. After the fix, the real store showed contradictions 0 → 174 and duplicates 0 → 1,473.

  8. v2.5.4 · 2026-07-17

    发布边界。npm 包改为严格白名单;发布前与 CI 中检查实际打包内容,环境文件、日志、会话、数据库或密钥材料一旦进包即失败;凭证扫描只报告路径与行号。Package boundary. A strict file whitelist for the npm package; the actual tarball is checked before publishing and in CI, failing on env files, logs, sessions, databases or key material; the credential scan reports only path and line.

  9. v2.6.0 · 2026-08-13

    跨进程一致性与分发。默认启用强读一致性,长驻进程无需重启即可读到其他进程的写入;脚本不再悄悄打开第二个数据库;从 Claude Code 插件市场安装即注册 MCP server。Cross-process consistency and distribution. Strong read consistency by default, so long-lived processes see other processes’ writes without a restart; scripts no longer silently open a second database; installing from the Claude Code marketplace registers the MCP server.

  10. v3.0.0 · 2026-08-24

    Node 22;合成结论可进入稳定记忆。诊断发现合成记忆的结论密度低于其输入(人工整理的记录 40.4%,合成洞察 14.4%)。合成改为可弃权的契约,写库前校验;新增 promote_synthesis,证据充分的结论可晋升为稳定记忆。MCP 工具 43 → 44。Node 22; synthesized conclusions reach stable memory. A diagnostic found synthesized memories less conclusive than their input (40.4% for hand-written records, 14.4% for synthesized insights). Synthesis now follows a contract that may abstain and is validated before writing; promote_synthesis lets a well-evidenced conclusion become stable memory. MCP tools 43 → 44.

  11. v3.0.1 · 2026-09-06

    发布卫生。源码中移除本机路径与用户名,测试不再随 npm 包发布:357 个文件 / 965.8 kB → 189 个文件 / 620.0 kB;新增可选的嵌入请求超时。Publication hygiene. Machine-local paths and usernames removed from the tree, and tests no longer ship in the npm package: 357 files / 965.8 kB → 189 files / 620.0 kB; an opt-in timeout for embedding requests.

  12. main · 2026-09-25

    相关度优先于流行度(未发版)。三层叠加的流行度加成改为链尾一次加分,上限 +20%:501 个已知答案的查询中,目标排第一的从 190 个增至 474 个。记忆文件改为与当前文件对账:在生产库快照上回放 625 条真实查询,返回过期片段的查询 133 → 0。Relevance before popularity (unreleased). Three stacked popularity stages became one bonus at the end of the chain, capped at +20%: of 501 queries with a known answer, the target now ranks first in 474, up from 190. Memory files are reconciled against the current files: replaying 625 real queries on a production snapshot, those returning a stale slice went from 133 to 0.

完整记录见 CHANGELOG.md。The full record is in CHANGELOG.md.

08 · 失败记录Failure log

九次故障:
现象、根因与修复
Nine failures: symptom, cause, fix

以下九次故障摘自 CHANGELOG,按时间排列;数字均为维护者本机生产库上的实测。Nine failures from the CHANGELOG, oldest first; every figure was measured on the maintainer’s own production store.

  1. v2.5.3 · 2026-05-29

    三个功能静默失效。distill_session 每次调用都抛出 ReferenceError;ingest --no-llm 仍全程调用 LLM;工具输出压缩在字母 z 处误截断。根因引用了未声明的变量;commander 把 --no-llm 解析为 options.llm=false,代码读的却是 options.noLlm;\z 在 JavaScript 正则中不是锚点。修复三处分别更正。Three features silently dead. distill_session threw a ReferenceError on every call; ingest --no-llm still called the LLM throughout; the tool-output compressor cut at a literal letter z. Causean undeclared variable; commander parses --no-llm as options.llm=false, while the code read options.noLlm; \z is not an anchor in JavaScript regular expressions. Fixeach corrected at the source.

  2. v2.5.3 · 2026-05-29

    诊断工具在空向量上报告健康。memory_lint 与 data_checkup 报告 0 条矛盾、0 条重复。根因store.list() 出于性能返回空向量,相似度恒为 0;测试 mock 返回了向量,与生产行为不一致,问题因此没有被测出。修复检查前补回真实向量,mock 改为复现生产行为;真实库上检出矛盾 0 → 174、重复 0 → 1,473。Diagnostics reported health on empty vectors. memory_lint and data_checkup reported 0 contradictions and 0 duplicates. Causestore.list() returns empty vectors for performance, so every similarity was 0; the test mocks returned vectors, unlike production, which is why the tests passed. Fixreal vectors are loaded before checking, and the mocks now mirror production; on the real store, contradictions 0 → 174 and duplicates 0 → 1,473.

  3. v3.0.0 · 2026-08-24

    合成记忆的结论少于输入。dream 生成的洞察结论密度为 14.4%,低于原始会话记录的 25.1%;2,427 条洞察全部是事件摘要;28 条记忆的正文是它自己的系统提示词。根因洞察使用分块摘要提示词,从不要求结论,也无法弃权;写库前只检查回复长度是否小于 5。修复改用可弃权的合成契约,写库前逐项校验。Synthesis produced fewer conclusions than its input. Insights from dream scored 14.4% conclusion density against 25.1% for raw transcripts; all 2,427 insight rows were episode summaries; 28 memories held their own system prompt as their body. Causeinsights used a chunk-summarizer prompt that never asked for a conclusion and could not abstain; the only pre-write check was a response length under 5. Fixa synthesis contract that may abstain, validated field by field before writing.

  4. v3.0.0 · 2026-08-24

    限流响应触发请求风暴。面对要求降速的端点,5 秒内发出 61,724 次请求。根因超长重试会分块并递归;短文本分块后原样返回,同一错误反复出现;判断超长的正则同时匹配了限流提示中的 exceeded。修复无法缩短输入时直接报错,分块后的请求不再进入同一分支:4 毫秒、1 次请求。该问题由新增的 HTTP 契约测试发现,此前的测试都替换了 SDK,从未经过网络层。A rate-limit reply triggered a request storm. Against an endpoint asking the client to slow down, 61,724 requests went out in five seconds. Causethe context-length retry chunked and recursed; short text came back from chunking unchanged and reproduced the same error; and the length check’s regex also matched the word “exceeded” in rate-limit replies. Fixchunking that cannot shrink its input now throws, and a chunk’s request cannot re-enter the branch: 4 ms, one request. The new HTTP contract tests found it; every earlier test had stubbed the SDK and never touched a socket.

  5. v3.0.0 · 2026-08-24

    一次从未生效的调参。2026-07-16 将 candidatePoolSize 调到 30,没有产生任何效果。根因两路候选都会经过 store.ts 中的上限 20,这一限制自首个提交起就存在,而那次调参只改了检索器。处理写入文档,参数保持不动:扩大候选池已于 2026-08-22 实测并否决。A tuning that never took effect. candidatePoolSize was raised to 30 on 2026-07-16 and had no effect. Causeboth candidate legs pass through a limit of 20 in store.ts, present since the first commit, while the tuning touched only the retriever. Handlingdocumented and deliberately left alone: widening the candidate pool was measured and rejected on 2026-08-22.

  6. v3.0.1 · 2026-09-06

    嵌入重试叠加成 90 分钟停顿。端点无响应时,一次 embedPassage 调用会发出 9 次请求,最坏约 90 分钟。根因SDK 自身重试两次,Embedder 再重试两次,叠加 SDK 默认的 600 秒超时。修复新增可选超时,默认行为不变。统一调低默认值的方案被否决:长文档的批量嵌入本来就慢,会让正常的导入失败。Embedding retries stacked into a 90-minute stall. Against an endpoint that never answers, one embedPassage call issued 9 requests, about 90 minutes in the worst case. Causethe SDK retries twice and Embedder twice more, on top of the SDK’s 600-second default timeout. Fixan opt-in timeout, with the default unchanged. Lowering the default for everyone was rejected: bulk embedding of long documents is legitimately slow, and working ingests would fail.

  7. main · 2026-09-08

    子 agent 的任务说明被当作用户发言。Codex 子 agent 的会话按用户对话导入:它们占 Codex 会话文件的 45.6%,在所有标为 user 的轮次中占 46.7%。根因按 role 字段判断发言者,而子 agent 会话里的 user 轮次是父 agent 写的任务说明。修复首行带 parent_thread_id 的会话整体跳过;发言者改由结构字段判断,不看 role。Subagent briefs ingested as the user speaking. Codex subagent sessions were ingested as user conversation: 45.6% of Codex rollout files, holding 46.7% of all turns marked as user. Causethe speaker was decided from role, while a subagent’s user turns are its parent agent’s task briefs. Fixsessions whose first line carries parent_thread_id are skipped whole; the speaker is decided from structural fields, not from role.

  8. main · 2026-09-24

    记忆文件导入只追加、不对账。68% 的活跃文档片段与任何现行文本都对不上;回放 625 条真实查询,21% 返回了过期片段,其中 35 条排在第一。根因导入只追加,新版本又被去重闸挡在库外;分块在 UTF-16 代理对中间切开,有一段文字始终匹配不上自己那一行。修复全局对账,软下架、写日志、可撤销;生产库上插入 673 段、恢复 16 条断链、下架 5,455 段。Memory-file ingest only appended. 68% of active document slices matched no current text; replaying 625 real queries, 21% returned a stale slice, 35 of them at rank 1. Causeingest only appended, and the dedup gate kept new versions out; the chunker split a UTF-16 surrogate pair, so one paragraph never matched its own row. Fixa global reconcile with soft retirement, a journal and undo; in production, 673 slices inserted, 16 broken chains restored, 5,455 retired.

  9. main · 2026-09-25

    流行度压过相关度。几分钟前存入的记忆,用它自己的触发语句检索只排第 9;501 个案例中,目标在触发召回之后 99% 排第一,经过评分链后只剩 38%。根因访问次数、热度、频次三层流行度加成叠加,每层都截到 1.0,主要来自频次加成。修复合并为链尾一次加分,上限 +20%,排第一的案例 190 → 474;设为 legacy 可逐字节恢复旧输出。Popularity outranked relevance. A memory stored minutes earlier ranked 9th when searched with its own trigger; across 501 cases the target was first in 99% right after trigger recall and in 38% after the scoring chain. Causethree stacked popularity stages (access count, hotness, frequency), each clamped at 1.0, mostly the frequency boost. Fixone bonus at the end of the chain, capped at +20%: first place 190 → 474; legacy restores the old output byte for byte.

检索失败案例另按固定模板(查询、预期、实际、假设)记录在 FAILURES.md。Retrieval misses are logged separately in FAILURES.md, each with query, expected, actual and hypothesis.

09 · 安装Installation

以 Claude Code 插件安装Install as a Claude Code plugin

/plugin marketplace add AliceLJY/recallnest
/plugin install recallnest@AliceLJY

或通过 npm:Or via npm:

npx recallnest --help

运行环境:Bun 或 Node.js 22+;需要 Jina API key(用于生成嵌入向量)。Requires Bun or Node.js 22+ and a Jina API key for embeddings.

  • v3.0.1
  • MIT
  • 2,600 项测试通过2,600 tests passing
  • 44 个 MCP 工具44 MCP tools

查看 GitHub 仓库View on GitHub 中文 READMEREADME in Chinese