
Nan Forget
io.github.NaNMesh由 GitHub 账号 NaNMesh 发布v0.6.8更新于 Oct 25, 2026
AI that remembers. Local-first cross-session, cross-project long-term memory for coding tools.
概览
本地优先的长期记忆服务器,让 AI 编程助手跨会话、跨项目保存、搜索并回忆决策、偏好和事实。
- 可以做什么
- 保存、更新、归档和按 ID 获取结构化记忆,支持类型、项目、问题、解决方案、概念、文件和置信度字段,并可在任务完成后写入检查点、把已持久化的 .md 记忆文件压缩为存根。以三阶段检索流程进行语义搜索,并支持跨项目扩展。同步会话、列出项目并查看记忆统计或服务健康状态。整合老化记忆、执行垃圾回收,并启动本地 Ollama 与 REST API 服务。与 REST API 和 CLI 共用同一个 SQLite 记忆数据库,其他代理可看到相同记忆。
- 适用场景
- 适合助手在会话之间不断丢失上下文、你希望决策、偏好和项目事实在本地持久保存且无需 Docker 或云服务的场景。适合每天使用 Claude Code、Codex 或 Cursor 并希望自动回忆与保存的开发者。
- 运行要求
- 以本地 npm 包通过 stdio 运行,用安装命令部署。需要 Node.js 和本地嵌入提供方:默认 Ollama,或通过环境变量 OPENAI_API_KEY 使用 OpenAI。可选环境变量 NAN_FORGET_EMBEDDING_PROVIDER、NAN_FORGET_PROJECT_ROOT 和 NAN_FORGET_USER_ID 用于配置提供方、项目根目录和多用户身份。REST API 监听 localhost:3456。
安装
在 SourceWeft 中
- 打开 控制台中的 Nan Forget,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
NaN Forget
Long-term memory for AI coding tools.
Your AI forgets everything when the session ends. NaN Forget fixes that.
Install (3 steps)
That's it. The wizard installs Ollama, embeddings, Claude hooks, MCP config, and a project AGENTS.md for Codex-style agents. Restart Claude Code or reopen Codex. Your AI now remembers.
No API keys needed. No Docker needed. Runs locally. Free forever.
How It Works
- You work normally. Your agent saves decisions, preferences, and facts to a local SQLite memory database as you go.
- Session ends. Memories persist in
~/.nan-forget/memories.db. Aging memories get automatically compacted into long-term entries. - New session starts. nan-forget loads context from past sessions. Auth decisions from 3 months ago on Project A surface when you work on Project B today.
Automatic Memory Handling
You never call save or search manually. Here's what happens behind the scenes:
Claude Code (fully automatic)
Four layers of protection ensure nothing is lost:
- Auto-recall on every message (UserPromptSubmit hook)
- Claude saves proactively (directive tool descriptions)
- Hook catches .md writes (PostToolUse intercept)
- End-of-session sweep (SessionEnd transcript scan)
Codex, Cursor, and other tools
Codex and similar agents work well with nan-forget, but they usually need instruction files or shell/API fallbacks instead of Claude's hook model:
- Run setup:
npx nan-forget setup - Use the generated
AGENTS.mdin your repo. It tells Codex-style agents tosync,search,save, andcheckpointautomatically. - Use REST or CLI fallback during conversation. Agents can call the REST API on
localhost:3456or local commands likenan-forget sync,nan-forget search,nan-forget add, andnan-forget checkpoint.
The REST API and CLI now mirror the important memory workflows closely enough that memories saved by Claude are searchable from Codex and vice versa.
Slash Commands
Type these in Claude Code:
Works with Any LLM
Claude uses MCP. Codex can use AGENTS.md plus CLI/REST fallback:
Codex, Cursor, and Claude all share the same memory database.
Quick Start (CLI)
Architecture (Expert Section)
Everything below is for developers who want to understand how nan-forget works under the hood.
The Problem
LLMs have no memory between sessions. Every conversation starts from zero. You re-explain your stack, Claude contradicts decisions from last month, and context disappears when the session ends.
Existing solutions (Mem0) target app developers embedding memory into products. We target you — the developer using AI tools daily who wants AI that just remembers.
Design: Brain-Inspired Two-Layer Memory
Short-term memory = Claude's built-in .md files. Disposable. Current session only.
Long-term memory = SQLite database with sqlite-vec vector search. Single file. Permanent. Searchable across all sessions, all projects, all LLM tools.
Three hooks handle memory automatically:
- PostToolUse intercepts
.mdfile writes and saves them to the DB. - UserPromptSubmit runs
nan-forget recallon every user message, auto-searching memory for relevant context. - SessionEnd scans the conversation transcript for unsaved decisions and saves the top 5.
Three-Stage Retrieval Pipeline
Memory search follows the same path as human recall:
Scoring formula:
High-confidence memories (debate-validated, human-approved) decay much slower and rank higher. A core memory at 0.85 confidence decays at ~15% of normal rate — effectively permanent unless superseded. Cross-project search means auth decisions from Project A surface when you work on Project B.
Consolidation Engine
Aging memories don't just get deleted — they get compacted into long-term entries:
Triggers automatically after every 10 saves or 24 hours. No user action needed.
13 MCP Tools
Structured Memories
memory_save accepts structured fields for richer vector representation:
All fields are embedded together into a single vector. Searches for "JWT auth bug" find memories tagged with those concepts even if the content text doesn't match literally.
Memory Tiers
Not all memories are equal. Debate-validated and human-approved memories are core — they decay slower, rank higher in search, and survive garbage collection longer.
Core memories are designed for the upcoming nan-debate system — multi-AI debate results validated by human approval get persisted as high-trust knowledge that almost never fades.
Checkpoint Workflow
After completing a task, call memory_checkpoint with task_summary, problem, solution, files, concepts, and project. Saves the full problem→solution context to long-term memory. Every completed task = one checkpoint.
Memory Compression
memory_compress scans .claude/projects/*/memory/ for .md files already persisted to the DB. Persisted files are replaced with minimal stubs. Reduces context window bloat.
REST API (for non-MCP LLMs)
Shares the same SQLite database as the MCP server — memories saved by Claude are searchable from Codex and vice versa.
Get the system prompt for any LLM:
Embeddings
Auto-detection: Ollama running? Use it. Not running? Check for OPENAI_API_KEY. No config needed.
Data Storage
All data lives in a single SQLite file at ~/.nan-forget/memories.db. No Docker, no services, no data loss on updates.
- Vector search: sqlite-vec extension (cosine distance, embedded in process)
- Metadata: Standard SQL tables with indexes on
user_id,status,project,type - Backup: Copy one file. Restore: Put it back.
- Export:
nan-forget exportdumps all memories as JSON.
Memory Lifecycle
Garbage Collection (Zero LLM Cost)
All cleanup is deterministic. No API calls. No LLM inference.
- Decay GC: Archives memories below 0.1 decay weight (~100 days for regular, ~600+ days for core)
- Expiration: Archives memories past
expires_atdate - Interference resolution: Deduplicates >0.95 similarity matches, keeps higher access count
- MEMORY.md sync: Refreshes working memory with top 5 scored memories per project
Core memories (confidence ≥ 0.85) survive GC far longer than regular ones because their decay formula dampens the time factor: decay^(1 - confidence). A 0.85-confidence memory at 200 days still has a decay weight above 0.1.
Design Philosophy
NaN Forget is built around three principles: lightweight, automatic, and local.
Lightweight
No Docker. No cloud services. No background processes eating RAM. The entire storage layer is a single SQLite file (~3 MB). Embeddings run through Ollama, which you likely already have. Memory operations (save, search, dedup, GC) use zero LLM calls — all deterministic.
Automatic
Four hooks capture context at every stage of a session — you never call save manually:
- UserPromptSubmit searches memory on every message you send
- Tool descriptions instruct Claude to save decisions and facts as they happen
- PostToolUse intercepts
.mdfile writes and persists them - SessionEnd sweeps the transcript for anything missed
Aging memories consolidate automatically. Duplicates merge. Unused memories decay on a 30-day half-life. No maintenance required.
Local
Your data stays on your machine in ~/.nan-forget/memories.db. No accounts, no API keys required (Ollama is free and local), no telemetry. Backup is copying one file. Works across Claude Code (MCP), Codex/Cursor (REST API), and the terminal (CLI) — same database, same memories.
How it differs from other memory tools
Most AI memory solutions (Mem0, claude-mem) are designed for app developers embedding memory into products, or require Docker/cloud services to run. NaN Forget is designed for you — the developer using AI tools daily who wants context that persists across sessions without managing infrastructure.
Key design differences:
- Retrieval: Three-stage pipeline (recognition → recall → spreading activation) with decay-weighted scoring, rather than flat vector search
- Structure: Memories carry
problem,solution,concepts, andfilesfields — searches find related context even when keywords don't match - Cost: Memory operations (save, search, dedup, consolidation, GC) are all deterministic — no LLM calls, no API costs
- Setup: One command (
npx nan-forget setup), no Docker, no containers, no services to manage
Source Structure
Built by NaN Logic LLC
- NaN Mesh — trust network for AI agents
- NaN Forget — long-term memory for any LLM
MIT License.
来源:README.md,提交 d3c8a10
工具
0版本历史
1- v0.6.8最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。