dsh-memory-map
A map for DeepSeek Harness memory. One pointer per row: a word, a one-liner, and where the full record lives. It never stores the body — it only answers "where is this kept".
Most memory plugins paste everything they remember into the system prompt. The prompt then blows up, and once it is compacted the reasons go first. This package takes the other path: carry a few-dozen-row map every turn, and open the source only when you need the detail.
中文说明见 README.zh.md。
What it fixes
| Pain | What this does |
|---|---|
| Compaction eats "why we chose this last time" | The reasoning stays in your memory store; only a pointer row lives here, and pointers are cheap to keep |
| You remember a lot, yet recall nothing when it matters | The last 30 days of the map are injected each turn; index_search finds the pointer by word |
| Re-reading old history to find one thing | Map first, then open exactly one source — cost drops from O(everything) to O(one record) |
| You do not know what you recorded, or which row is still true | The index is plain text: grep-able, diff-able, backup-able, and stale pointers are marked |
What it is: a directory layer, a routing layer, an event layer. What it is not: not a memory store, no vectors, no semantic judgement, no rewriting of your text. That stays with chain / mnemon or whatever backend you already use.
How fragments become event cards
What matters is "one thing that happened", not "a day of chatting". Three steps, no setup beyond the plugin itself:
- Filter — pure acknowledgements ("ok", "yeah", "haha"), greetings, one-liners and punctuation-only fragments are dropped. Pure emotion (goodnight, hugs, mood words with no action and no time anchor) is dropped too — that belongs to persona material, not to the map. Host injections (
<system-reminder>, runtime snapshots, another plugin's review prompt) never count as something you said. - Group — split by a 90-minute gap, cluster by two or more shared keywords, so the same matter spread over several days still lands in one group.
- Confirm — a group never becomes a card by itself. It waits in
pending.jsonl; the model reads the samples, gives it a specific title and one line, then callsevent_fileto write the card and the index row — orevent_discardto skip it.
An event does not need to be long. One sentence that says "when + what" ("went out to dinner with a friend last month") is enough to become a candidate. Process chatter ("okay that's fixed now", "restarted it") is not collected even when it carries an action verb.
Every card carries three things so you can find it later:
type:事件 event(already happened) /计划 plan(to do later) /项目 project(spans several days);time: "last month", "next week" is resolved against the fragment's own date into a concrete day (2026-11-01 / 2026-12-07). Plan cards are marked·planin the injection and use the plan day as the index date, so they show up before they happen;tags: 2–4 words. A badly named card is survivable; tags still find the same matter.
Three modes (digestMode):
| Value | Behaviour | For whom |
|---|---|---|
agent (default) |
candidates only; a model or a human confirms before a card exists | people who want the map to stay clean |
rules |
write cards by rule, title from frequent keywords | unattended setups that still want cards |
off |
no automatic digest at all | manual event_log only |
Where fragments come from (no companion plugin)
By default the plugin reads DSH's own session logs under $DSH_HOME/sessions/ (session*.jsonl.zstd). Those files are append-only: every record is its own zstd frame, so the reader parses frame boundaries from block headers, keeps a byte cursor per file and decodes only the frames written since the last pass. A 10 MB session re-reads in a few hundred milliseconds the first time and near zero afterwards. Nothing else has to be installed, and no third-party code is imported.
fragmentSource picks the input:
| Value | Behaviour |
|---|---|
auto (default) |
built-in session logs first; fall back to chainFile when session logs yield nothing (older DSH build, moved DSH_HOME) |
session |
built-in session logs only |
chain |
only dsh-chain's fragment store |
off |
fragments off; manual event_log only |
Two behaviours worth knowing:
- First run records a baseline. Old conversations are not turned into retroactive cards; the cursor starts at the end of each log, and cards begin with what you say next. Call
event_digest(source: "session")if you deliberately want to scan now. - Only logs touched in the last
sessionScanDaysdays are read; assistant replies are off by default (includeAssistant), because plans and events almost always come from the user side.
One matter, one card: mergePolicy
Talking about "the index plugin" can produce three names — "index plugin", "index coverage", "memory index rework" — and three scattered cards ruin the map. Before filing, the candidate's title + tags are compared with existing cards:
- Same title, or a single-tag candidate hitting an existing tag → confident, append to that card (a timeline line, index word stays the old title);
- A multi-tag candidate must hit ≥2 tags on the same card to count as confident, so one sentence spanning two matters is not force-merged;
- A tie (several cards with the same score) is never guessed.
mergePolicy decides what happens when it is not confident:
| Value | Behaviour | For whom |
|---|---|---|
ask (default) |
hold the candidate, mark it with suggestCard, and let the model or a human decide with one event_file(title=...) |
keeps the map clean, at the cost of one extra question |
conservative |
merge into the nearest card anyway | prefer a few fuzzy cards over a pile of fragments |
conservative only affects weak hits and ties; with no tag hit at all it still follows digestMode (rules creates a card, agent holds). Both policies reopen a closed card when a line is appended — new progress should not stay closed.
Install
Requirements
| Item | Requirement | Why |
|---|---|---|
| DSH | >= 0.2.1-rc.2 (tested on 0.2.2-rc.1) |
Uses the 0.2.x dsh.client browser half and the plugin-page slots; older builds have neither, so the config page never appears |
| Node | >= 22.15 |
Per-frame session decoding and node:test; the first memory_doctor check verifies it |
@deepseek-ai/schemastery |
optional | Needed only for the graphical settings form; without it everything runs on defaults |
dsh-chain |
optional | Fallback fragment source only; a fresh install uses DSH's own session logs |
Local directory (development, or your own machine)
cd ~/.dsh/plugins
git clone https://github.com/jinlingfang-lab/dsh-memory-map.git
Add the dependency to the profile's package.json:
"dsh-memory-map": "file:C:/Users/<you>/.dsh/plugins/dsh-memory-map"
Append this to the profile's cordis.patch.yml:
- insert:
- id: memory-index
name: dsh-memory-map
config:
autoIndex: true
digestMode: agent
digestEvery: 5
mergePolicy: ask
The
- insert:wrapper is required. A bare- id:is read as an override of an existing entry and fails withpatch: entry "memory-index" not found.
From GitHub (recommended)
pnpm add github:jinlingfang-lab/dsh-memory-map
Not published on npm yet:
npm view dsh-memory-mapreturns 404 right now, sopnpm add dsh-memory-mapwould fail. Use GitHub or the local-directory route above until the npm release lands.
Then paste the same - insert: block into cordis.patch.yml and restart DSH. Plugin inventory changes are not hot-loaded.
After upgrading, quit DSH completely and start a new session. The tool catalog is a per-session snapshot: a session that was already open keeps the old parameter list, so new tools such as index_remove or event_digest(rescan) will not appear there.
Verify it actually works
Do these in order; each step names what a failure looks like.
- Restart and open a new session. Do not verify in an old session — its tool table predates the install.
- Check the plugin page: sidebar → Plugins → 记忆地图. The title should carry a version (
v0.6.x) and the component row should say running; opening the row should show the merge-policy form, which proves the browser half loaded too. - Call
memory_doctorin the session. Expect 12 checks and nofail. Look at four of them: Node version, memory directory writable, index file, JSONL integrity. On a fresh install the index check is awarn("no index file yet") — that is normal. - Run it from a terminal:
npx dsh-memory-doctor(ornode ~/.dsh/profiles/desktop/node_modules/dsh-memory-map/bin/doctor.mjs). Expect the same checks andok: true. - Check what lands on disk: have the model call
index_addonce ("index 'started using the memory map'"), then look for~/.dsh/memory/index.mdand that row inside it; then ask what the injected map starts with — 「记忆索引」 should be there. - Optional, auto digest: after a few real turns
~/.dsh/memory/pending.jsonlshould hold candidates; empty is normal when there is no fragment source or only small talk.
If steps 3 and 4 pass, the plugin itself is healthy; a failing step 2 usually means DSH was not restarted or is older than 0.2.1-rc.2.
Configuration
Every path defaults under $DSH_HOME/memory (DSH_HOME defaults to ~/.dsh); there is no absolute path in the code.
| Key | Default | Meaning |
|---|---|---|
memoryDir |
$DSH_HOME/memory |
data root; DSH_MEMORY_DIR also works |
indexFile |
<memoryDir>/index.md |
the human-readable map (rendered; do not hand-edit) |
storeFile |
same name, .jsonl |
the real index |
eventDir |
<memoryDir>/events |
event cards, one folder per month |
sessionsDir |
$DSH_HOME/sessions |
built-in fragment source; no plugin needed |
fragmentSource |
auto |
auto / session / chain / off |
sessionScanDays |
7 |
only read session logs touched in the last N days |
includeAssistant |
false |
also treat assistant replies as fragments |
chainFile |
$DSH_HOME/memories/.chain-shared/chains.jsonl |
optional fallback source; false disables |
autoIndex |
true |
add an index row after a memory write succeeds |
autoIndexTools |
mnemon_remember and 2 more |
point these at your own backend's tool names |
removeTools |
mnemon_forget |
drop the index row when a memory is deleted |
digestMode |
agent |
agent / rules / off |
digestEvery |
5 |
digest after N useful fragments; 0 disables |
mergePolicy |
ask |
ask holds, conservative merges |
language |
auto |
auto follows the system language; zh / en force one |
injectMaxRows |
40 |
rows per turn |
injectMaxChars |
2600 |
character budget per turn |
injectFreshDays |
30 |
only rows written in the last N days |
categories |
学习 / 生活 / 系统 |
event categories, replace with your own |
Settings page (no file editing)
With @deepseek-ai/schemastery installed, the plugin exports a Config schema and the DSH settings page shows these fields directly: language, fragmentSource, sessionScanDays, includeAssistant, mergePolicy, digestMode, digestEvery, injection rows and character budget, injectFreshDays, autoIndex.
Changes apply without a restart: options are resolved again before every injection. Missing schemastery does no harm — the plugin runs on defaults, and the "settings page" check in the doctor tells you which case you are in.
Path-like keys are deliberately not in the form: they are machine-bound and break on the next computer, so use the DSH_HOME / DSH_MEMORY_DIR environment variables.
Language
Three layers, each with its own switch:
- Plugin page — DSH itself reads
locale/en.jsonandlocale/zh.json(meta.title,meta.description,meta.detail) and picks one by client language. Nothing to configure. - Settings form — schemastery descriptions are
{ en, zh }dictionaries; the host renders them in the client language. - Runtime text — injected map, tool replies, doctor report, and the rendered
index.mdheader. This one is ours:language: autoreads the system locale (Intl.DateTimeFormat().resolvedOptions().locale),DSH_MEMORY_LANG/LC_ALL/LANGcan override it, andzh/enforce it.
Event card files keep the Chinese field labels (类型: / 标签:) because they are data, not UI — an existing card must keep parsing after a language switch.
Tools
| Tool | Purpose |
|---|---|
index_add |
add one row: word, one-liner, source; re-renders the map immediately |
index_remove |
drop rows exactly: by source pointer or by word (map only, never the record) |
index_search |
find pointers by word, return sources, do not expand |
index_sync |
re-render Markdown, mark rows whose file no longer exists |
index_import |
bulk-build rows from a chain-style JSONL (dryRun to count first; missing chain now errors instead of silently importing 0) |
memory_doctor |
self-check: paths, permissions, JSONL integrity, duplicate words, stale rows, event cards, injection size |
event_log / event_close / event_list |
one card per matter, append to the timeline, close when done |
event_digest |
review candidates: type, time anchor, tags, one-liner, samples, suspected existing card; source re-scans now, rescan: true ignores cursors to backfill older chats |
event_file |
confirm one candidate → write the card + one index row (title/category/line/type/time/tags editable); same title appends |
event_discard |
drop a candidate that is not worth a card |
index_import exists because most people already have hundreds of records when they first install. An empty map is useless — seed it once.
Self-check
npx dsh-memory-doctor
# or: node bin/doctor.mjs --json
Twelve items report OK / WARN / FAIL. Only FAIL means unusable; WARN means it works but one link is broken — a wrong path, a missing chain source, an empty index, an injection over budget.
You can also just ask the agent to call memory_doctor inside a session.
Relationship to the other two plugins
- dsh-chain: optional now. Its JSONL can still be used (
fragmentSource: "chain",chain:<id>pointers), and it is always read-only — no import, no edit, no redistribution of its code. A new install does not need it at all. - dsh-mnemon: only its registered tool names are watched, to add a row after a successful write. It is an npm package, so upgrading it does not touch this one.
- Either can be absent: the built-in session source still produces candidates, and the map keeps working. Without mnemon there is no automatic write to index, so use manual
index_add.
Migrating from dsh-indexer
dsh-indexer is this package's predecessor and uses the same JSONL format. To switch:
- point
indexFileat the old索引.mdandstoreFileat索引.jsonl; - remove
dsh-indexerfrom the profile dependencies and patch entries, adddsh-memory-map; - restart, then run
memory_doctorand check the row count.
Do not mount both: two processes would write the same table.
Privacy
Everything is a local file: index, event cards and logs live under memoryDir. No network calls, no telemetry. The index holds only "word + one line + source", never the body — so it is safe to back up, and safe to put in git if you want.
Status
0.4.0: built-in event extraction — the plugin decodes DSH's own .jsonl.zstd session logs itself (incremental byte cursors, fake-frame-safe, baseline on first run), so no companion plugin is required; fragmentSource / sessionScanDays / includeAssistant settings, event_digest(source) re-scan, plus everything from 0.3.5 (index, injection, auto rows, event cards, chatter and emotion filtering, card matching with mergePolicy, settings page, chain import, self-check, English/Chinese with system-language detection).
Roadmap at the end of docs/DESIGN.md.
License
MIT. Third-party notes are in LICENSE: this repository contains no third-party plugin code.
No comments yet. Be the first to write one.