
Claude Code 的长期内存。每次会话都以 SQLite+FTS5 索引,通过 MCP 暴露回忆,并提供 PreCompact/PostCompact 钩子,确保不会丢失任何内容。
概览
Claude Code 的长期记忆层,基于 JSONL 会话记录构建。 连续性(v1)在单一会话内防止压缩——PreCompact钩子保存检查点,SessionStart钩子注入该检查点,SSE代理在70/85/95%令牌压力下敲响铃声。 每个 Claude Code 会话都已经以 JSONL 形式写入磁盘——每轮、每一次工具调用、每一次响应。纯文本。仅附加。免费。 那个文件是一个隐藏在明处的情节存储。v2 是其上的索引、搜索和检索层。 用FTS5走 ~/.claude/projects/,将每一轮都提取到 SQLite 里: 字面意义上的全文搜索,涵盖了与克劳德·代码的每一次对话。可按项目筛选,时间倒序。 把它接到现有的Claude内存MCP(8200端口)或独立连接。
概述(AI 翻译)
Claude Code 的长期记忆层,基于 JSONL 会话记录构建。
这是什么
continuity(v1)在单一会话内防止压缩——PreCompact钩子保存检查点,SessionStart钩子将其注入回去,SSE代理在70/85/95%令牌压力下发出响铃。
continuity v2 解决了另一半问题:跨会话回忆。
每个 Claude Code 会话都已经以 JSONL 形式写入磁盘——每轮、每一次工具调用、每一次响应。纯文本。仅附加。免费。
那个文件是一个隐藏在明处的情节存储。v2 是其上的索引、搜索和检索层。
建筑
构建阶段
第一阶段 — 指数(MVP)
走 ~/.claude/projects/,用 FTS5 将每回合都提取到 SQLite:
字面意义上的全文搜索,涵盖了与克劳德·代码的每一次对话。可按项目筛选,时间倒序。
第二阶段 — MCP工具
可以把它接到现有的claude-memoryMCP(8200端口)或独立连接。
search_sessions(query, limit=10)— FTS5搜索,返回匹配回合 + 会话ID + 周边上下文recall_session(session_id, range="full")— 返回完整或切片会话
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
continuity v2
Long-term memory layer for Claude Code, built on the JSONL session record.
What this is
continuity (v1) protected against compaction within a single session — PreCompact hook saves a checkpoint, SessionStart hook injects it back, SSE proxy rings bells at 70/85/95% token pressure.
continuity v2 solves the other half: across-session recall.
Every Claude Code session is already written to disk as a JSONL — every turn, every tool call, every response. Plain text. Append-only. Free.
That file is an episodic memory store hiding in plain sight. v2 is the index, search, and retrieval layer on top of it.
Architecture
~/.claude/projects//.jsonl (raw episodic record, already there)
↓
v2 indexer
↓
SQLite + FTS5 + (later) embeddings
↓
MCP tool surface
↓
Claude calls search_sessions(query) mid-conversation
Build stages
Stage 1 — Index (MVP)
Walk ~/.claude/projects/, extract every turn into SQLite with FTS5:
sessions(id, project, started_at, ended_at, turn_count)
turns(session_id, turn_idx, ts, role, text)
turns_fts (FTS5 mirror of turns.text)
Literal full-text search across every conversation ever had with Claude Code. Filterable by project, reverse-chronological.
Stage 2 — MCP tool
Wire it into the existing claude-memory MCP (port 8200) or stand alone.
search_sessions(query, limit=10)— FTS5 search, returns matching turns + session ID + surrounding contextrecall_session(session_id, range="full")— return full or sliced sessionrecent_sessions(n=10)— list recent sessions with first/last user message
Stage 3 — Semantic recall
Sentence embeddings + SIMILAR_TO edges. Hybrid search: literal + semantic.
For when the words don’t match but the concept does (“when did we talk about the thread-home problem” should match conversations about “Hal”, “50 First Dates”, “Alice in Wonderland”).
find_similar(query, limit=10) — find semantically similar turns via ANN search over
all-MiniLM-L6-v2 embeddings, re-ranked by a hybrid score:
score = 0.7 * semantic_similarity
+ 0.2 * recency_decay # linear, full decay at 365 days
+ 0.1 * complexity_bonus # session turn count, normalized to 50 turns
Build: python embed.py (idempotent — skips turns already embedded), then
python wire_similar.py to wire SIMILAR_TO edges between turn pairs with cosine ≥ 0.85.
Stage 4 — Auto-tagging (later)
- Project mentions (saranna, dream-module, gold-402, etc.)
- Decision markers (
DECIDED,SAVE, session-close triggers) - File paths touched
Why this matters
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
"mcpServers": {
"continuity-v2": {
"type": "stdio",
"command": "python",
"args": ["/path/to/continuity-v2/mcp_server.py"],
"env": { "PYTHONIOENCODING": "utf-8" }
}
}