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.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

本地優先的長期記憶伺服器,讓 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。
安裝前請注意
安裝精靈會安裝 Ollama、鉤子、MCP 設定並在專案中產生 AGENTS.md,鉤子會攔截 .md 寫入並掃描工作階段紀錄,因此對話內容會存入本機資料庫。若設定了 OPENAI_API_KEY,記憶內容會傳送給 OpenAI 用於產生嵌入與整併摘要。記憶會被自動寫入、封存與垃圾回收,壓縮功能會把已持久化的 .md 檔案替換為存根。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Nan Forget,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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)

bash
npx nan-forget setup

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

mermaid
flowchart LR    A["You talk to your AI tool"] --> B["It learns things"]    B --> C["nan-forget saves to SQLite"]    C --> D["Session ends"]    D --> E["New session starts"]    E --> F["nan-forget loads context"]    F --> G["Your AI remembers"]
  1. You work normally. Your agent saves decisions, preferences, and facts to a local SQLite memory database as you go.
  2. Session ends. Memories persist in ~/.nan-forget/memories.db. Aging memories get automatically compacted into long-term entries.
  3. 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)

EventWhat firesWhat happens
Session startsmemory_syncLightweight handshake — checks health, loads stats, lists projects. No heavy search.
You send a messageUserPromptSubmit hooknan-forget recall auto-searches memory for relevant context and injects it into the conversation.
You discuss a topicmemory_searchClaude searches the DB dynamically whenever relevant context might exist — like how you recall things on-demand.
Claude learns somethingmemory_saveClaude saves decisions, preferences, and facts immediately. Tool descriptions tell Claude "you MUST call this."
Claude writes a .md filePostToolUse hookmemory-sync.js intercepts the write, parses frontmatter, and auto-saves it to SQLite via nan-forget add.
Session endsSessionEnd hooksession-end.js scans the conversation transcript for unsaved decisions/facts and saves the top 5 to the DB.
Every 10 saves or 24hAuto-consolidateAging memories get clustered and compacted into long-term entries. Originals are archived.

Four layers of protection ensure nothing is lost:

  1. Auto-recall on every message (UserPromptSubmit hook)
  2. Claude saves proactively (directive tool descriptions)
  3. Hook catches .md writes (PostToolUse intercept)
  4. 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:

  1. Run setup: npx nan-forget setup
  2. Use the generated AGENTS.md in your repo. It tells Codex-style agents to sync, search, save, and checkpoint automatically.
  3. Use REST or CLI fallback during conversation. Agents can call the REST API on localhost:3456 or local commands like nan-forget sync, nan-forget search, nan-forget add, and nan-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.

bash
# Start the REST APInan-forget api
# The system prompt tells your agent exactly what endpoints to callnan-forget prompt

Slash Commands

Type these in Claude Code:

CommandWhat it does
/nan-forgetLoad context from past sessions
/nan-forget statsShow memory health
/nan-forget cleanRun garbage collection
/nan-forget compactForce memory consolidation
/nan-forget healthCheck if services are running
/nan-forget startStart all services

Works with Any LLM

Claude uses MCP. Codex can use AGENTS.md plus CLI/REST fallback:

bash
# Start the APInan-forget api
# Get the system prompt for your agentnan-forget prompt

Codex, Cursor, and Claude all share the same memory database.

bash
curl http://localhost:3456/memories/search?q=authcurl -X POST http://localhost:3456/memories/sync -d '{"project":"my-app"}'curl -X POST http://localhost:3456/memories/checkpoint \  -H 'content-type: application/json' \  -d '{"task_summary":"Fixed auth regression","problem":"Expired tokens were not refreshed","solution":"Added refresh handling in middleware","files":["src/auth.ts"],"concepts":["auth","jwt"],"project":"my-app"}'

Quick Start (CLI)

bash
nan-forget add "We use FastAPI, not Django. Railway deploys faster."nan-forget add --type decision "Auth is Clerk, not custom JWT"nan-forget search "what auth system"nan-forget stats

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

mermaid
flowchart TB    subgraph Short["Short-Term Memory"]        MD[".md files<br/>Current session context<br/>Disposable scratch paper"]    end    subgraph Long["Long-Term Memory"]        DB["SQLite + sqlite-vec<br/>~/.nan-forget/memories.db<br/>Semantic search + decay"]    end    subgraph Auto["Automatic Processes"]        Hook["Hooks (3)<br/>PostToolUse: .md → DB<br/>UserPromptSubmit: auto-recall<br/>SessionEnd: transcript sweep"]        Consolidate["Consolidation Engine<br/>Clusters + summarizes aging memories"]        GC["Garbage Collection<br/>Decay, dedup, expiry"]    end    MD -->|"hook intercepts"| Hook    Hook -->|"nan-forget add"| DB    DB --> Consolidate    Consolidate --> DB    DB --> GC

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 .md file writes and saves them to the DB.
  • UserPromptSubmit runs nan-forget recall on 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:

mermaid
flowchart LR    Q["Query"] --> S1["Stage 1: Recognition<br/>Fast vector match<br/>Returns summaries only"]    S1 --> S2["Stage 2: Recall<br/>Full content fetch<br/>Cross-project expansion"]    S2 --> S3["Stage 3: Association<br/>Spreading activation<br/>Related memories surface"]    S3 --> R["Results ranked by<br/>similarity x decay x frequency x confidence"]
StageWhat happensCost
Recognition (blur)Prefetch 50 candidates, return top 5 summaries. Cheap.1 vector search
Recall (clarity)Fetch full content. Expand search cross-project (no project filter).N point lookups
AssociationCentroid-based related-memory search over sqlite-vec. Spreading activation from positive IDs.1 vector search

Scoring formula:

final_score = vector_similarity * decay_weight * frequency_boost * confidence_boostdecay_weight = (0.5 ^ (days / 30)) ^ (1 - confidence)frequency_boost = log2(access_count + 1) / 10 + 1confidence_boost = 0.5 + 0.5 * confidence

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:

mermaid
flowchart TB    A["10+ aging memories<br/>about the same topic"] --> B["Cluster by project + type<br/>+ vector similarity > 0.8"]    B --> C{"OpenAI key<br/>available?"}    C -->|"Yes"| D["LLM summarizes cluster<br/>into 1-2 sentences"]    C -->|"No"| E["Deterministic merge<br/>concatenate + deduplicate"]    D --> F["Save consolidated entry<br/>with fresh vector embedding"]    E --> F    F --> G["Archive originals<br/>with backlink"]

Triggers automatically after every 10 saves or 24 hours. No user action needed.

13 MCP Tools

ToolPurpose
memory_syncLightweight session handshake: health check + stats + project list
memory_saveSave a memory (auto-called by Claude, proactively)
memory_searchSemantic search with 3-stage retrieval (depth 1-3)
memory_getFetch a specific memory by ID
memory_updateChange content, type, or tags
memory_archiveSoft-delete (hidden from search, never truly deleted)
memory_consolidateForce consolidation of aging memories
memory_cleanGarbage collection (decay, dedup, expiry, MEMORY.md sync)
memory_statsMemory health dashboard
memory_healthCheck if Ollama, REST API are running
memory_startBoot Ollama + REST API
memory_checkpointSave full problem→solution context after completing a task
memory_compressCompress persisted .md memory files to minimal stubs

Structured Memories

memory_save accepts structured fields for richer vector representation:

FieldTypePurpose
contentstringFull description (required)
typestringfact, decision, preference, task, context
projectstringProject name
problemstringWhat was the challenge
solutionstringHow it was solved
conceptsstring[]Searchable tags (["auth", "jwt", "middleware"])
filesstring[]Files involved (["src/auth.ts"])
confidencenumberTrust level 0.0–1.0 (default based on provenance)
provenancestringsave, checkpoint, debate, human
tierstringregular or core (auto-derived from provenance)

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.

ProvenanceDefault ConfidenceAuto TierDecay Rate
save0.5regularNormal (30-day half-life)
checkpoint0.65regular~35% slower
debate0.85core~85% slower
human0.95core~95% slower

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.

POST   /memories              — Save a memory (supports problem/solution/files/concepts)POST   /memories/checkpoint   — Save completed-task contextPOST   /memories/sync         — Lightweight session handshakeGET    /memories/search?q=... — Semantic searchGET    /memories/:id          — Get by IDPATCH  /memories/:id          — UpdateDELETE /memories/:id          — ArchivePOST   /memories/consolidate  — Compact aging memoriesPOST   /memories/clean        — Garbage collectionGET    /memories/stats        — Memory healthGET    /memories/instructions — System prompt for LLMs

Get the system prompt for any LLM:

bash
nan-forget prompt# orcurl http://localhost:3456/memories/instructions

Embeddings

ProviderModelDimensionsCost
Ollama (default)nomic-embed-text768Free, local
OpenAItext-embedding-3-small1536Your API key

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 export dumps all memories as JSON.

Memory Lifecycle

mermaid
flowchart TB    A["New memory saved"] --> B["Active in SQLite<br/>Searchable, scored"]    B --> C{"Accessed<br/>recently?"}    C -->|"Yes"| D["Score stays high<br/>frequency_boost increases"]    C -->|"No"| E["Decay weight drops<br/>0.5^(days/30)"]    E --> F{"Decay < 0.3?"}    F -->|"Yes"| G["Consolidation candidate<br/>Clustered + summarized"]    F -->|"No"| B    G --> H["New consolidated entry<br/>Originals archived"]    D --> B    E --> I{"Decay < 0.1?"}    I -->|"Yes"| J["Archived by GC"]    I -->|"No"| F

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_at date
  • 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:

  1. UserPromptSubmit searches memory on every message you send
  2. Tool descriptions instruct Claude to save decisions and facts as they happen
  3. PostToolUse intercepts .md file writes and persists them
  4. 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, and files fields — 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

src/  sqlite.ts         SQLite + sqlite-vec storage layer (schema, CRUD, vector search)  embeddings.ts     OpenAI / Ollama abstraction  writer.ts         Memory writer with dedup (>0.92 = merge)  retriever.ts      Three-stage retrieval pipeline  consolidator.ts   LLM summarization + deterministic fallback  cleaner.ts        GC: decay, expiry, dedup, MEMORY.md sync  services.ts       Service management (Ollama, REST API)  memory-md.ts      MEMORY.md manager  types.ts          Shared types (Memory, MemoryType, etc.)  mcp/server.ts     MCP server, 13 tools  api/server.ts     REST API server  cli/index.ts      CLI commands + hook helpers  setup/index.ts    Setup wizard (Ollama, hooks, MCP config)
.claude/  commands/nan-forget.md   Slash command for manual control  hooks/memory-sync.js     PostToolUse hook (auto-saves .md → SQLite)  hooks/session-end.js     SessionEnd hook (transcript sweep for unsaved memories)  settings.json            Hook config (PostToolUse + SessionEnd + UserPromptSubmit)

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
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.6.8最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。