Skip to main content
S

dsh-keepsake

sunny-summer-dish/dsh-keepsake

Local append-only memory for DSH: remember, find, correct and forget, with page/compaction capture modes and optional offline embeddings.

Install

dsh plugin --profile web add github:sunny-summer-dish/dsh-keepsake

README

Keepsake · 留念

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-keepsake

0.3 adds two DSH surfaces, page/compact capture modes, and an optional offline embedding backend. All read/write stays local.

AI page: read-only records User page: search, correct, forget, settings

界面示意:布局随 DSH 主题变化,截图内记录为演示数据。

Two surfaces

AI pageUser page
seerecords with id / time / who / sourcesame
writeremember / find / correct (tools)delete (soft), export, settings
cannotdelete, 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:

modeforcapture behavior
pagepage-flippersrecords a page-boundary marker when the session changes; dedupes copied context
compactsingle long sessionsignores page boundaries; records compaction markers; never stores a summary as a user quote
auto (default)bothpage 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:

  1. A record has to exist. autoCapture is off by default; turn it on, or call memory_remember for the things that must survive.
  2. 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.
  3. 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.md or 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
categoryhit
字面10/10
改口2/2
按人2/2
换说法(种子内)5/5
精度(别被同义词带偏)3/3
无命中(该空就空)1/1
留出(种子里没有的说法)1/5
overall24/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_find behind settings.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.

benchmarklexical only+ local-onnx hybrid
overall24/28 (85.7%)27/28 (96.4%)
held-out paraphrases1/54/5
literal / precision10/10, 3/310/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.

backendrolerequires
none (default)literal + synonym seednothing
local-onnxprimary optional: truly offline, no other softwareone-time model download (~25–100 MB, user-confirmed)
openai-compatiblesecond option: use an existing local Ollama / LM Studio endpointuser already runs one

Rules:

  • The plugin must run fully with none; a missing/failed model falls back to literal search, never blocks remember / find.
  • local-onnx loads 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-redact keeps raw text.
  • forget is a tombstone: hidden from find, still present in export.
  • 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

Related plugins