Back to home

PEClound

dsh-harness-memory

DeepSeek Harness 跨对话记忆插件:重要性权重衰减遗忘(重要慢忘、琐事快忘)、主动记忆、所有预设可用、设置页查看与管理

Stars
0
Language
JavaScript
Created
Aug 16, 2026
Updated
Aug 16, 2026

Introduction

dsh-harness-memory

DeepSeek Harness 桌面应用打造的跨对话记忆插件——像 GPT / Claude 一样主动记住你的习惯、偏好、项目知识,带重要性权重衰减遗忘,并提供设置页查看与管理。

包含的包

作用
dsh-memory宿主插件:memory_save / memory_recall / memory_forget / memory_stats 四个工具 + memory:usage 主动记忆系统提示段 + /api/memory.* 设置页后端接口
dsh-client-ui-memory浏览器设置页:设置 → 插件 → 「Agent 记忆」 标签(查看 / 搜索 / 删除记忆)

功能特性

  • 主动记忆 —— 一小段系统提示引导 Agent:任务开始先回忆相关记忆,学到持久性事实(偏好、习惯、项目决策、环境约束)时自动保存,无需你明确说"记住";
  • 任何预设可用 —— 工具行注入所有随附预设(standard / minimal / cordis / code),不需要专门的"记忆模式";
  • 重要性权重遗忘 —— retention = (0.4 + 0.06 × 重要性) × 2^(−龄 / 半衰期);按重要性分档半衰期:2 天 / 30 天 / 180 天 / 730 天。琐事约 5 天遗忘,核心事实数年不淡忘;再次被用到会刷新(间隔重复),每访问 5 次重要性 +1(封顶 10);
  • 上下文经济 —— 平时零 token 开销;召回默认最多 8 条 / 4 KiB,超限明确提示"省略 N 条";
  • 设置页 —— 按作用域分组展示、搜索过滤、逐条删除;删除对运行中的会话即时生效(基于文件 mtime 的缓存自动收敛);
  • 跨会话 —— 记忆持久化在 ~/.dsh/storages/memory/,全局(用户级)与按工作区分文件,重启不丢。

安装(Windows · DSH Desktop)

powershell -ExecutionPolicy Bypass -File dsh-memory\install.ps1
# 自定义安装目录:
powershell -ExecutionPolicy Bypass -File dsh-memory\install.ps1 -DesktopInstall "D:\DSH Desktop"

安装脚本会自动完成:

  1. 把两个包复制到桌面应用运行时的 node_modules 与 profile 回退目录;
  2. 在所有随附预设中注入 memory-tool 行;
  3. 在每个 profile 的 cordis.patch.yml 中加入 memory-api(宿主)与 ui-memory(客户端)两行。

完成后重启 Harness 生效。 记忆存储位于 ~/.dsh/storages/memory/global.jsonl + workspaces/<hash>.jsonl)。

应用更新可能覆盖运行时 node_modules——更新后重新运行一次安装脚本即可。

验证

cd dsh-memory
node test/store.test.js        # 单元测试(衰减、持久化、跨实例收敛……)
node test/e2e-mount.test.js    # 模拟挂载,四工具端到端
node test/mount-real.test.js   # 真实 cordis + 真实 ToolRuntime + 提示段断言
# 对运行中的 Harness 实测(传入端口):
node test/verify-live.mjs http://127.0.0.1:<端口>
node test/verify-proactive.mjs http://127.0.0.1:<端口>
node test/verify-settings.mjs http://127.0.0.1:<端口>

回退

  • 删除各 profile cordis.patch.yml 中的 memory-api / ui-memory 行;
  • 删除随附预设中的 memory-tool 行;
  • 删除两个 node_modules 位置的 dsh-memory / dsh-client-ui-memory 目录。

回退不触碰任何既有记忆数据。

许可

MIT