DEEPSEEK HARNESS · LONG-TERM MEMORY PLUGIN

Restart the session.
It still remembers.

Cairn is persistent cross-session memory for the DeepSeek Harness — one command to install · nine memory tools + one identity tool · six injection modes. Facts, preferences, conventions, and hard-won lessons survive across sessions: every new conversation starts with last time's experience already on the table.

INSTALL
$dsh plugin add --profile web @chenhw7/dsh-memory
WHY · WHY YOU NEED IT

The session ends. Everything resets.

By default an agent has no cross-session memory — what you said last week and what you debugged yesterday all start from zero today.

WITHOUT MEMORY

Every session starts from zero

"We use pnpm now" is gone by the next session; the same build pit swallows you twice; last week's verified conclusions get reconstructed from vibes. Context grows longer while the things that matter keep being re-explained.

preferences re-explainedpits re-fallenconclusions from vibes
WITH CAIRN

Say it once — it stays said

Worthwhile signals are extracted, scanned, audited, and stored; the next session opens with a digest of category counts and topic words already present, full text recalled on demand via memory_search / memory_get. Use keeps them fresh, forgetting follows rules.

auto-distilledrecalled on demanddecay with rules
CAPABILITIES · WHAT IT DOES

Five capabilities

01 · Persistent storage

Dual-backend KV store, fully audited

JSON (the host storage domain) or SQLite (node:sqlite, zero extra dependencies) backends with a one-time migration; cross-process single-writer detection guards against concurrent clobbering. Six tables — entries / audit / suggestions / meta / identity / identity_history — and every change is attributed and audited. Uninstall the plugin, keep the memories.

survives restartssingle-writer detection
02 · Smart retrieval

Dependency-free BM25, CJK as a first-class citizen

A hand-rolled Okapi BM25: conservative Latin stemming folds word forms, CJK runs emit unigrams plus adjacent bigrams — "记忆" no longer matches every entry containing "记". Three scopes (global / project / user), summary indexed alongside content, pinned entries surface first.

measured, not vibesCJK tokenization
03 · Auto-learning

Extraction, consolidation, supersession

Three signals (explicit intent / user correction / verified failure streaks) trigger LLM extraction; new entries face the old ones through an IDF-weighted prefilter and one batched consolidation call — duplicates merge, outdated ones supersede with a supersededBy mark. Optional review queue: models propose, you decide.

20 extractions/sessionyou stay in control
04 · Context injection

Six modes, KV-prefix stability

The memory snapshot freezes at session creation and is reused all session — prefix unchanged, KV-cache fully warm. Six injection modes (digest, the default, ships category counts and topic words) disclose progressively, with standing cost always visible (≈N tokens footer). Optional step-level auto-recall rides the message channel and never touches the system prompt.

progressive disclosurevisible cost
05 · Identity layer (opt-in)

SOUL.md & USER.md — written by the assistant itself

SOUL.md is the assistant's character; USER.md is its working profile of you. The assistant rewrites them whole via identity_update in conversation — every version is snapshotted and revertible; you review history in the Identity settings section but never edit directly. Off by default; when enabled, both inject into the system prompt.

identity_updateversioned & revertible
MEASURED · NUMBERS, NOT VIBES

Metrics with CI gates

9+1model-facing tools
9 memory tools + identity_update (identity layer off by default)
100%success@5 · retrieval hit rate
35×35 en+zh golden set · CI floor 85%
0.902MRR · ranking quality
same golden set · CI floor 0.75
≈344tokens · policy-only standing injection
independent of store size
1096test cases
1090 passing + 6 key-gated skips · every push
3scopes
global · project · user
HOW · HOW IT WORKS

Three steps: distill → store → inject

In session · distill

Three signals stream through a zero-LLM-cost accumulator: explicit intent ("remember / from now on"), user corrections ("actually, no"), and failure streaks resolved by success. Past the threshold (default 10), exactly one LLM extraction fires.

Store · settle

Every write passes 37 scanner rules and appends an audit record; entries are deduped and consolidated against the store — duplicates merge, outdated ones supersede. The BM25 index is ready as soon as the write lands, and every hit refreshes the freshness stamp.

Next session · inject

The snapshot freezes at session creation, and a one-time digest of category counts and topic words lands on the first step (digest mode by default): the model pulls full text via memory_search / memory_get; step-level auto-recall can add relevant memories on the fly — all with visible token cost.

TRUST · SAFETY & CONTROL

Every memory is gated and audited

Memories get re-read into future context — they are an attack surface, so defense is two-sided.

WRITE + READ · DUAL DEFENSE

Scanned in, redacted out

37 rules at write time (16 secrets · 17 prompt injections incl. 8 Chinese · 4 exfiltration) — rejected content never lands; every prompt-facing read re-redacts, leaked content renders as [BLOCKED: …]. The original stays inspectable — silent deletion only hides the attack.

AUDIT · FULL AUDIT

Who wrote it, when — forever queryable

Every change appends an audit record: action, source (tool / review / flush / ui / janitor), content preview — 200 rolling with a monotonic seq.

GUARD · DANGEROUS OPS GATED

Mass forgetting can't run away

memory_forget demands an explicit confirm: true; batches over the ceiling are refused, pinned entries are exempt and reported, every removal is individually audited.

HUMAN · ONE-VOTE VETO

Models propose, humans decide

With confirm-before-write on, every extraction and tool write degrades to a proposal; repeatedly observed proposals float to the top. Edits to existing entries never touch the original before adoption.

REMOTE · WRITES DENIED BY DEFAULT

A wide trust scope never escalates

The browser console is read-only until a deployment-level switch enables writes — what is trusted is the transport fence, not the storage face.

PROMPT · PROMPT DEFENSE

Memory is context, not instructions

Forged fence closers in stored content are neutralized at render time; every injection surface declares that the current user request, repository files, and tool output always outrank memory.

CONSOLE · MEMORY CONSOLE

Manage everything without a terminal

Overview Review3 Manage

Overview · health dashboard

The whole store at a glance, with telemetry for background-task failures.

  • total 128 · pinned 7 · decaying 3
  • global 41 / project 62 / user 25
  • audit 200 rolling · last extraction yesterday 22:41

Review · proposal queue

The human-veto desk: hits-descending, the most-raised proposals first.

  • adopt after editing · reject in one click
  • badge tracks the pending count live
  • edits to existing entries never auto-apply

Manage · full operations

Scope + workspace filters, BM25 search, category chips, lazy-loaded list.

  • edit · pin / unpin
  • archive / unarchive · delete
  • decay markers at a glance

The mock above illustrates the console UI (numbers are not real). The five settings cards — Memory, Project Notes, Auto Recall, Identity, Automatic Extraction — apply live with no restart; the UI is bilingual. The plugin never writes files into your repository.

HONESTY · FIT & BOUNDARIES

What it's for — and what it isn't

FIT · BUILT FOR

Long-lived personal and team assets

Cross-session personal preferences and working habits; a project's team conventions and commit norms; verified pitfalls and fixes from debugging; engineering judgment accumulated over long iterations. It helps an agent accrue experience — it is not a general knowledge base.

LIMITS · KNOWN LIMITS

Said up front, honestly

Retrieval is purely lexical: BM25 does no semantic vectors, so a paraphrased query misses (synonyms ride on summary indexing). Extraction quality tracks the session model — no extra keys. The host DeepSeek Harness is on the alpha channel (0.1.2-alpha.2); the plugin moves with it. The remote console is transport-trust only, writes off by default.

STATUS · PROJECT STATUS

Where the repo stands today

CURRENT VERSION
v0.9.3
npm registry · baked snapshot
TOTAL COMMITS
241
stats.json · baked snapshot
LAST UPDATE
2026-09-09
stats.json · baked snapshot
TEST CASES
1096
1090 passing + 6 key-gated skips

Version and commit figures are read live from the npm registry and the repo's stats.json (refreshed daily by CI) when you open the page; offline you see the baked snapshot above.

EXPLORE · GO DEEPER

Four paths