本地、只追加的 DSH 记忆:记、找、改口、忘掉;支持翻页/压缩两种采集模式与可选离线向量。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:sunny-summer-dish/dsh-keepsake
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
Local, append-only memory for DeepSeek Harness (DSH).
No cloud. No persona card. No telemetry. One JSONL file on your machine.
Package:
dsh-keepsake· CLI:keepsake· data:~/.dsh-keepsake0.3 adds two DSH surfaces, page/compact capture modes, and an optional offline embedding backend. All read/write stays local.
界面示意:布局随 DSH 主题变化,截图内记录为演示数据。
Two surfaces
| AI page | User page | |
|---|---|---|
| see | records with id / time / who / source | same |
| write | remember / find / correct (tools) | delete (soft), export, settings |
| cannot | delete, export, change settings | — |
The permission split is enforced by the server routes, not just hidden in the UI.
User correction is off by default
The user page has a 更正 button, but it is rejected until the user turns on
allowUserCorrect in settings (default false). Toggling the switch does not
write anything to the ledger, so repeated on/off cannot spam it.
Instead, memory_find reports the current state to the AI on every query:
(用户记忆权限:更正 开/关;语义 开/关)
A correction itself is still additive: a new record points back to the old id, and the original is never overwritten.
Two modes, one core
The difference between page-flipping users and compaction users is how turns are captured, not how memory is stored. One plugin, three settings:
mode |
for | capture behavior |
|---|---|---|
page |
page-flippers | records a page-boundary marker when the session changes; dedupes copied context |
compact |
single long sessions | ignores page boundaries; records compaction markers; never stores a summary as a user quote |
auto (default) |
both | page boundary when the session changes, compaction marker when a compaction event appears |
autoCapture remains off by default. When on, each user/assistant turn is
stored separately with session, page, turn, who, source. Long pages
never become one giant record.
Verified against real DSH event names: compaction/start, compaction/summary,
compaction/end, compaction/prune; only start writes one marker. A replay of
22 real sessions (255k events, 43 compactions) produced 43 compaction markers and
21 page markers. captureAssistant is also off by default; injected prompts
(starting with 【, <system-reminder>, Current runtime context, etc.) are
skipped.
If your context gets compacted
Keepsake is built for compact-style sessions: the ledger lives outside the context window, so compaction does not delete it.
compaction rewrites the session context
ledger.jsonl is a separate append-only file
memory_find still searches it after compaction
compact records one compaction/start marker, not the summary. A summary is
never stored as a user quote, so compaction cannot create a fake memory.
What still depends on the agent:
- A record has to exist.
autoCaptureis off by default; turn it on, or callmemory_rememberfor the things that must survive. - The query has to hit. Use nouns, names, dates, or a synonym from the
editable
src/synonyms.json. With semantic search off, purely different wording may miss. - The agent has to decide to search. The tools stay registered after
compaction, but the agent may not remember that a memory exists. Add one
line to the profile's
AGENTS.mdor system prompt:
Before saying you don't remember something from an earlier page or from before
a compaction, call memory_find with the nouns / names / dates first.
That line is the difference between "the memory is still there" and "the agent actually goes and gets it". Keepsake stores and retrieves; it does not inject the whole ledger into every prompt.
What it does
- remember — append a note, with who said it and where it came from
- find — by word, by day, by speaker; every hit carries an id and time
- correct — a new record points back to the old one; the original is never overwritten
- forget — soft delete; the record stays exportable
- export / import — plain JSONL, no lock-in
Install (0.3, from source)
git clone <this repo> dsh-keepsake
cd dsh-keepsake
node bin/keepsake.mjs help
No dependencies for the core. Node 20+.
After the npm release, npm i -g dsh-keepsake gives you the keepsake command.
Use inside DSH
# 发布后
dsh plugin --profile desktop add dsh-keepsake
# 或者先装本地目录(路径按实际位置)
dsh plugin --profile desktop add "D:/dsh-stuff/projects/dsh-keepsake"
重启 DSH 后,侧栏会出现两个入口:
- 留念 · AI:只读列表,按词/天搜
- 留念 · 我的:搜索、忘掉、导出 JSONL、打码/自动收设置
AI 那一侧的工具是 memory_remember / memory_find / memory_correct;
forget 和 export 只在用户页面,由服务端拒绝 AI 路由。
Use (CLI)
# 记
node bin/keepsake.mjs remember --text "今天去看了海。" --who user --source cli
# 找(词 / 天 / 谁)
node bin/keepsake.mjs find "海"
node bin/keepsake.mjs find "海" --day 2026-11-30
node bin/keepsake.mjs find "海" --who user --limit 5
# 改口(原文不动,新条指向旧 id)
node bin/keepsake.mjs correct --id m_000001 --text "今天去看了海,风很大。"
# 忘掉(软删)
node bin/keepsake.mjs forget --id m_000002
# 导出 / 导入
node bin/keepsake.mjs export --file keepsake.jsonl
node bin/keepsake.mjs import --file keepsake.jsonl
Default store: ~/.dsh-keepsake/ledger.jsonl. Override with DSH_KEEPSAKE_HOME or --home.
Retrieval benchmark (0.3)
Synthetic data, not anyone's real memories. Two sets:
npm run bench
| category | hit |
|---|---|
| 字面 | 10/10 |
| 改口 | 2/2 |
| 按人 | 2/2 |
| 换说法(种子内) | 5/5 |
| 精度(别被同义词带偏) | 3/3 |
| 无命中(该空就空) | 1/1 |
| 留出(种子里没有的说法) | 1/5 |
| overall | 24/28 (85.7%) |
Honest reading: a small editable synonym seed (src/synonyms.json) covers the
five seeded paraphrases, but held-out paraphrases ("毛孩子", "远行", "伴手礼")
still fail. That is a dictionary, not understanding. Vectors or a larger
semantic layer are the next step; do not report 100% from the seeded set alone.
Optional semantic retrieval (off by default)
No download is required to install or use this plugin. Without a semantic
backend, find uses literal + multi-word + the synonym seed only.
Semantic retrieval is an optional enhancement, off by default. Nothing is downloaded until the user turns it on and confirms the model size/source.
Status: wired into
memory_findbehindsettings.semantic(off by default). The default stays usable without any model; a failed load falls back to literal.
Tested model: Xenova/bge-small-zh-v1.5 (q8), about 23 MB on disk.
To enable the local backend, install the optional peer in the same DSH profile:
cd "$DSH_HOME/profiles/desktop" && pnpm add @huggingface/transformers
Not installing it is supported: none remains the default and lexical search
still works.
| benchmark | lexical only | + local-onnx hybrid |
|---|---|---|
| overall | 24/28 (85.7%) | 27/28 (96.4%) |
| held-out paraphrases | 1/5 | 4/5 |
| literal / precision | 10/10, 3/3 | 10/10, 3/3 |
The model is not bundled; first use downloads it to ~/.dsh-keepsake/models
(or DSH_KEEPSAKE_MODEL_CACHE). In mainland China,
DSH_KEEPSAKE_MODEL_HOST=https://hf-mirror.com is a working mirror. Text never
leaves the machine.
| backend | role | requires |
|---|---|---|
none (default) |
literal + synonym seed | nothing |
local-onnx |
primary optional: truly offline, no other software | one-time model download (~25–100 MB, user-confirmed) |
openai-compatible |
second option: use an existing local Ollama / LM Studio endpoint | user already runs one |
Rules:
- The plugin must run fully with
none; a missing/failed model falls back to literal search, never blocksremember/find. local-onnxloads dynamically only after opt-in; text never leaves the machine.- A model switch rebuilds the sidecar vector index; the ledger is untouched.
- Enable only if the held-out benchmark improves without hurting literal or precision cases; otherwise keep it off.
Privacy defaults
- Everything stays local; there is no network code.
token,password,Bearer,sk-…are masked by default.--no-redactkeeps raw text.forgetis a tombstone: hidden fromfind, still present inexport.- Deleting the store directory deletes everything.
Deliberately out of scope
- persona / identity generation
- QQ / group chat / bridge integrations
- mood / diary / drawing
- cloud sync or accounts
Tests
npm test
链接
同类插件
vectorize-io/hindsight#coding-agents★ 64571
Hindsight:会学习的 Agent 长期记忆系统,自动召回/保存、知识页、深度反思与按仓库隔离的记忆银行。
volcengine/OpenViking#examples/dsh-memory-plugin★ 43161
面向 DeepSeek Harness 的 OpenViking 记忆与上下文插件:pre-step 自动召回与画像注入、会话捕获、`viking://` URI 防护,以及对接 OpenViking 服务端的 recall/write 记忆工具。
MemTensor/MemOS#memos-local-plugin★ 12564
DeepSeek Harness 本地记忆插件:分层 L1/L2/L3 记忆,自动沉淀与手动 memos_* 检索工具并存,内置记忆浏览器。
agentscope-ai/ReMe#dsh★ 3886
将 DeepSeek Harness 接入 ReMe 本地优先、自进化的个人知识库:自动把已完成的主 Agent 对话沉淀为用户掌控的 Markdown 记忆,通过 reme_search 结合 BM25、可选向量检索和 wikilink 展开搜索对话与资料,并按日整理长期记忆。
zilliztech/memsearch#MemSearch★ 2983
供 DSH 与其他编程 Agent 共享的 Markdown 记忆,支持自动捕获、步骤前上下文注入、搜索召回,以及通过审阅面板实现 memory-to-skill 自进化。
vshulcz/deja-vu#extensions/dsh★ 1725
跨会话长期记忆与上下文恢复:读取本机上其他四十五个(45+)编程智能体已经写下的会话文件,支持安装前历史找回与中断恢复(Claude Code、Codex、Cursor、Windsurf、Trae、Antigravity、VS Code Copilot Chat、opencode、OpenClaw、Hermes、Kimi、Qoder、Cline、Zed、Magpie 等):提供 deja_recall、deja_session、deja_blame、deja_fix、deja_how、deja_remember 六个工具与 /deja 命令,并可选地把召回结果加入运行时上下文。共享本地 BM25 CLI/MCP 索引,不用大模型,不用向量嵌入,不联网(dsh plugin --profile web add dsh-deja)。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。