Persistent five-layer memory system with relevance injection, LLM auto-extraction, profile rotation, and six agent tools.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:NattoCB/dsh-plugin-memory
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
English | 中文
A persistent five-layer memory system for DeepSeek Harness (DSH): a user profile (L1), a per-project semantic index with topic files (L2), and append-only per-day logs (L3) under
~/.dsh/memory/and<cwd>/.dsh/memory/. It injects relevant memories into every request and auto-extracts durable facts from finished sessions via the LLM. Integrates as a DSH plugin on two cordis seams —agent/pre-stepfor injection,ctx.tools.registerfor sixmemory_*agent tools. Without anllmroute it still works: entry injection, keyword relevance, and profile rotation remain; only LLM ranking and auto-extraction are disabled.
✨ Features
- 🧠 Five-layer model: L0 user-owned identity (
~/.dsh/AGENTS.md, not managed by the plugin) → L1 profile → L2 project index + topics → L3 per-day append-only log → L4 skills (existing). Each layer has its own write path, truncation budget, and injection rule. - 📇 Index + topic split (L2):
MEMORY.mdis always an index of one-line pointers (≤150 chars each); details live in<topic>.md. Keeps single files small, searchable, and truncatable. - ✂️ Truncation budget: the booted index is hard-clamped to 200 lines / 40,000 chars, so cold-start context stays cheap.
- 🎯 Relevance injection: on each step, the latest user query selects relevant topic files (LLM ranking when
llmis configured, keyword scoring otherwise) and appends them as a<system-reminder data-role="memory">block; files already surfaced in this session are de-duplicated. The two channels are labeledmemory-entry(once per session) andmemory-relevance(per step) in the GUI context rows. - 🤖 LLM auto-extraction: when a session goes idle, a debounced (60 s) best-effort pass scans the recent 40 events, asks the LLM for new topic files and index lines, and writes them. Never overwrites existing memories; degrades silently if the model is unavailable.
- 🔄 Profile rotation (L1):
memory_profilemerges new facts into four fixed sections (工作背景 / 个人背景 / 当前关注 / 近期动态) and rotates the version, keeping the previous copy inprofile.md.bak. - 🔒 Read-back data, not instructions: memory is written with
fs/promisesdirectly to the memory roots — intended persistence, not self-modification — and paths are confined to the store root. Memory files are context the agent reads back, never permission grants. - 🧩 Pure harness plugin: no HTTP API or GUI panel — injection and tools only. DSH serves a single user, so paths carry no
<uid>layer. - 🛠️ Six agent tools registered via
ctx.tools.register(defineToolfrom@deepseek-ai/dsh-tools):
| Tool | Scope | Effect |
|---|---|---|
memory_write |
global/project | Write/overwrite a topic file; optionally add an index line. |
memory_read |
global/project | Read a topic file or the MEMORY index. |
memory_search |
global/project/both | Keyword-search topic files. |
memory_daily |
cwd | Append a dated line to <cwd>/.dsh/memory/YYYY-MM-DD.md. |
memory_forget |
global/project | Delete a topic file and its index pointer. |
memory_profile |
global | Read, or merge-and-rotate, the single-user profile. |
Quick Start
Prerequisites
- A DeepSeek Harness (DSH) installation with a plugin-capable profile (e.g.
web). - No LLM route required — the plugin falls back to keyword-only relevance.
Install
dsh plugin --profile web add github:NattoCB/dsh-plugin-memory
Run
Restart dsh web. On first use the plugin bootstraps both memory roots:
~/.dsh/memory/
MEMORY.md # global index (≤200 lines / 40K chars)
profile.md # L1 profile (Version N)
profile.md.bak # previous profile version
<topic>.md # global topic files
<cwd>/.dsh/memory/
MEMORY.md # project index
YYYY-MM-DD.md # daily memory (append-only)
<topic>.md # project topic files
Tell the agent something worth remembering, or let idle auto-extraction pick it up — then check the memory roots a session later.
Configuration
Deploy the plugin via a DSH bundle entry (see cordis.patch.yml and package.json exports):
| Key | Default | Meaning |
|---|---|---|
enableEntryInjection |
true |
Prepend the how-to-save + index block once per session. |
enableRelevance |
true |
Append relevant topic files per step (data-role=memory). |
enableExtraction |
true |
Idle-time LLM auto-extraction. |
maxRelevant |
5 |
Max files surfaced per step (1–20). |
relevanceTopK |
8 |
Max candidates the LLM selector may pick from (1–40). |
relevanceBudgetChars |
2000 |
Per-topic char cap fed to relevance selection (≥200). |
extractionDebounceMs |
60000 |
Idle debounce before an extraction pass runs. |
extractionLookback |
40 |
Recent events scanned per pass (5–200). |
llm.provider |
"" |
Provider for extraction / relevance ranking (empty → keyword-only). |
llm.model |
"" |
Model for extraction / relevance ranking. |
llm.maxTokens |
1024 |
Completion token cap for LLM calls. |
Example entry:
- id: memory
name: '@deepseek-ai/dsh-plugin-memory'
config:
enableEntryInjection: true
enableRelevance: true
enableExtraction: true
maxRelevant: 5
relevanceTopK: 8
relevanceBudgetChars: 2000
extractionDebounceMs: 60000
extractionLookback: 40
llm:
provider: deepseek # example: fill in your route
model: deepseek-chat
maxTokens: 1024
License
MIT — see LICENSE.
Links
More in this category
vectorize-io/hindsight#coding-agents★ 61856
Hindsight, agent memory that learns: long-term project memory with auto recall and retain, knowledge pages, deep reflection, and per-repo memory banks.
volcengine/OpenViking#examples/dsh-memory-plugin★ 42434
OpenViking memory and context bundle for DeepSeek Harness: pre-step auto-recall and profile injection, session capture, `viking://` URI guarding, and recall/write memory tools backed by an OpenViking server.
MemTensor/MemOS#memos-local-plugin★ 12444
Local-first memory plugin for DeepSeek Harness: layered L1/L2/L3 memory with automatic capture, manual memos_* retrieval tools, and a built-in memory viewer.
agentscope-ai/ReMe#dsh★ 3822
Connects DeepSeek Harness to ReMe's local-first, self-evolving personal knowledge base: automatically captures completed main-agent conversations as user-owned Markdown memory, searches conversations and source material through reme_search with BM25, optional embeddings, and wikilink expansion, and schedules daily memory consolidation.
zilliztech/memsearch#MemSearch★ 2900
Shared Markdown memory for DSH and other coding agents, with automatic capture, pre-step context injection, searchable recall, and memory-to-skill self-evolution through a review panel.
vshulcz/deja-vu#extensions/dsh★ 1621
Cross-session memory and context recovery across forty-five other coding agents (45+) on this machine, reading session files they already wrote before install (Claude Code, Codex, Cursor, Windsurf, Trae, Antigravity, VS Code Copilot Chat, opencode, OpenClaw, Hermes, Kimi, Qoder, Cline, Zed, Magpie and more): six tools (deja_recall, deja_session, deja_blame, deja_fix, deja_how, deja_remember), a /deja command, and optional automatic recall injected into runtime context. Local BM25 CLI/MCP index, no LLM, no embeddings, no network (dsh plugin --profile web add dsh-deja).
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.