Long-term memory injected at session start: preferences/facts/summaries/knowledge in global and per-project scopes, budgeted recall via `agent/pre-step`, durable JSON store.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:yangyongzhen/dsh-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
This plugin publishes its README in Chinese only.
DeepSeek Harness 的长期记忆插件:把跨会话需要记住的事情(用户偏好、项目事实、会话摘要、可复用知识)持久化到磁盘,并在每个新会话开始时自动注入给 Agent。
特性
- 四类记忆:
preference(偏好,应默认遵守)、fact(项目/环境事实)、summary(会话/任务摘要)、knowledge(可复用知识/经验) - 两种作用域:
global(所有项目适用)、project(按项目隔离,slug 自动从会话 cwd 推导) - 四个 Agent 工具:
memory_write/memory_read/memory_search/memory_delete - 会话开始自动注入:监听
agent/pre-step,在第一步把全局+项目记忆渲染成带字节预算的<system-reminder>注入;内容寻址去重,resume 会话不会重复注入 - 原子持久化:临时文件 + rename,崩溃不产生撕裂文件;损坏的 unit 优雅降级为空而不是崩溃
- 半自动:写入由 Agent 判断(建议先
memory_search查重再写),符合你的「半自动」选型
安装
dsh plugin --profile <name> add dsh-memory
# 或从本地 checkout 安装
cd <dsh-memory目录> && dsh plugin --profile <name> add .
配置
在 profile 的 cordis.patch.yml(或 --patch 覆盖)中配置:
- id: memory
config:
enabled: true
root: C:/Users/<you>/.dsh/memory # 可选;默认 $DSH_HOME/memory(支持 ~ 前缀)
maxBytes: 4000 # 注入预算(UTF-8 字节),默认 4000
maxEntryBytes: 512 # 注入时单条内容上限,默认 512
injectOnStart: true # 会话开始自动注入,默认 true
searchLimit: 20 # memory_search 默认返回上限,默认 20
工具
memory_write
{
"type": "preference",
"scope": "global",
"content": "用户偏好中文回复",
"tags": ["language"],
"importance": 4
}
type:preference|fact|summary|knowledge(必填)scope:global|project(必填;project自动绑定当前会话 cwd)content: 记忆内容(必填)id: 已存在记忆的 id,传了则更新该条tags: 检索标签(可选)importance: 1..5 重要度(可选,注入与搜索排序参考)
memory_read
按作用域(+ 可选类型过滤)列出记忆,最新在前。
memory_search
在全局+当前项目记忆中检索:query(内容/标签不区分大小写包含匹配,多词须全命中)、tags(交集)、type 过滤;按重要度、再按更新时间排序。
memory_delete
按 id + scope 删除一条记忆。
数据布局
$DSH_HOME/memory/
├── global.json # 全局记忆(数组,version: 1)
└── projects/
└── <slug>.json # 每个项目一个 unit 文件
每条记录:
{
"id": "…",
"type": "preference",
"scope": "global",
"content": "…",
"tags": [],
"importance": 3,
"createdAt": "2026-08-20T…",
"updatedAt": "2026-08-20T…"
}
工作原理
- 存储(
src/store.ts):MemoryStore按作用域管理 JSON unit 文件,put/remove/clear全部原子写;搜索按重要度+时间排序。 - 渲染(
src/render.ts):renderMemoryBlock把条目逐条贪心装入<system-reminder>,严格遵守maxBytes预算;放不下的条目跳过而不是丢整个 section。 - 注入(
src/index.ts):agent/pre-step水瀑布中,仅step === 1且尚未注入过时,把渲染块追加到 claimed messages 之后进入第一次请求。source 带plugin: 'memory'+digest,alreadyInjected通过扫描会话 surface 去重,resume 安全。
开发
pnpm install
pnpm run build # tsc → lib/
pnpm test # store 单测(11 项)+ smoke(5 项)
设计取舍
- 半自动写入:注入块会提示 Agent「如需更新记忆,使用 memory_write / memory_delete」,由 Agent 判断何时沉淀;不做全自动摘要(那需要额外 LLM 调用)。
- 预算优先:注入默认 4000 字节,宁可少注入也不撑爆上下文;
importance高的条目优先。 - 文件即真相:不用 SQLite/额外服务,
global.json人类可读可手改,和你的dsh-session-report风格一致。
License
MIT
Links
More in this category
vectorize-io/hindsight#coding-agents★ 60728
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★ 42125
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★ 12376
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★ 3796
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★ 2866
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★ 1529
Reads the session files forty-two other coding agents on this machine already wrote (Claude Code, Codex, Cursor, VS Code Copilot Chat, opencode, OpenClaw, Hermes, Kimi, Cline, Zed and more), including sessions from before it was installed: six tools (deja_recall, deja_session, deja_blame, deja_fix, deja_how, deja_remember), a /deja command, and optional automatic recall added to the runtime context. Local BM25 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.