dsh-memory
给 DeepSeek Harness(
dsh)用的长期记忆插件:跨会话、跨工作区记住你做过什么,生成不断变准确的用户画像,并在你进入某个工作区开始会话时自动加载对应记忆。
English | 中文
功能
- 按工作区自动回忆:新会话开始于哪个工作区,就注入哪个工作区的记忆快照(通过 Harness
systemPrompt.context,由框架物化为可重放的运行上下文)。 - 总记忆 + 工作区记忆:全局用户画像、全局笔记与最近动态;每个工作区独立归档会话总结、进展、下一步、话题、难点和偏好。
- 昨天与最近一周:每次渲染从会话总结实时聚合「昨天做了什么、做到哪了」和「最近 7 天」进展,不依赖定时日报。
- 不断变准的用户画像:后台用 Harness 默认模型总结每次会话,并分批刷新画像;没有模型时自动退化为确定性摘要。
- 顶部 AI 总结:跨会话综合生成的模型简报(最近在做 / 下一步 / 当前卡点 / 话题),默认缓存并在新总结到达后自动刷新,可手动「重新生成」。
- 模型工具:
memory_recall、memory_profile、memory_note,让助手主动检索记忆、读取画像、记录持久事实。 - 可读的页面:默认只显示 2–3 行摘要与标签,画像细节、工作区明细、笔记表单全部折叠展开,减少文字堆叠。
- 本地优先:记忆保存为
DSH_HOME/memory/memory.json(普通 JSON,原子写入并保留.bak),只把总结请求发送到你已配置的模型服务。 - 子代理隔离:子代理会话不会污染用户画像或工作区记忆。
安装
要求:DeepSeek Harness 0.2.x(桌面版或 Web 版均可)。
git clone https://github.com/duxingxiake3/dsh-memory.git
cd dsh-memory
# 将插件装进你的 profile(把 default 换成实际 profile 名)
dsh plugin --profile default add ./dsh-memory
也可以在 Web 界面左侧 插件 → 添加插件 中选择本地目录 dsh-memory/。安装后插件默认启用,左侧边栏会出现「记忆」入口。
卸载:
dsh plugin --profile default remove dsh-memory
记忆数据在
$DSH_HOME/memory/,卸载插件不会删除它;需要彻底清除时手动删除该目录。
使用
- 打开左侧边栏「记忆」:顶部是 AI 总结,下面是画像/统计、按工作区折叠的会话记忆、最近动态与笔记。
- 对话中直接说「记住……」或问「我们上次做到哪了?」,助手会调用
memory_note/memory_recall。 - 页面右上角:
- 刷新:重新读取本地记忆。
- 整理画像:立即触发一次画像刷新。
- 重新生成(AI 总结卡内):立即重新综合一份 AI 简报。
- 新会话会自动携带当前工作区的记忆,无需手动操作。
配置
在 profile 的 cordis.patch.yml 中按 row id memory 覆盖配置:
- id: memory
name: dsh-memory
config:
summarize: true
injectContext: true
maxContextChars: 3500
profileEvery: 2
briefRefreshMinutes: 120
briefEveryDigests: 2
完整字段见 dsh-memory/README.md,包括数据目录、模型路由、补录天数、保留策略和日志级别。
记忆模型
全局:用户画像 / 全局笔记 / 最近动态 / AI 简报缓存
工作区:会话总结(摘要、进展、下一步、话题、难点、偏好、工具、文件)
会话:来自 Harness 会话日志的行为事实,由摘要模型转成结构化记忆
- 会话总结:每个 turn 结束后防抖(默认 45 秒)读取会话历史,先写确定性摘要,再调用模型生成精简结构化总结。
- 画像:每新增若干条总结后刷新,只做有证据的合并,保留置信度。
- AI 简报:跨最近 10 条会话 + 画像 + 笔记综合,写入
global.brief缓存。 - 补录:首次启用回填最近 21 天的会话头/标题,并逐步补齐较新会话的详细总结。
开发与测试
纯逻辑模块只依赖 Node 内置模块;本仓库自带无需第三方依赖的测试:
node tests/test-memory.mjs
node scripts/check-locales.mjs
for f in dsh-memory/index.js dsh-memory/client.js dsh-memory/lib/*.js; do node --check "$f"; done
CI 配置见 .github/workflows/ci.yml。
已知限制
- 记忆按
DSH_HOME共享,不跨机器同步。 - 检索是会话总结/笔记的文本匹配,不是向量检索。
- 后台总结会消耗少量模型调用;
summarize: false可关闭。 - 首轮补录只读取会话头与标题,更早会话没有详细进展。
- 页面上的 AI 总结是缓存结果,刚结束的会话可能延迟 1–2 分钟出现。
License
English
dsh-memory is a local-first long-term memory plugin for DeepSeek Harness:
- records session behavior and summarizes it in the background through the Harness LLM service;
- keeps a global user profile plus per-workspace session memories, progress, next steps and difficulties;
- injects the right workspace memory automatically when a session starts;
- renders an AI-summary-first sidebar page with collapsible details, and exposes
memory_recall/memory_profile/memory_notetools.
Install from a checkout with dsh plugin --profile <name> add ./dsh-memory, enable the bundle in Plugins, then open Memory in the left sidebar. Memory is stored under $DSH_HOME/memory/memory.json; only summaries are sent to the model provider you already configured.
Keywords: DeepSeek Harness plugin, long-term memory, user profile, workspace memory.
No comments yet. Be the first to write one.