DSH Hub
dsh-layered-memory cover

JunNanLYS/dsh-layered-memory

dsh-layered-memory

UIMemory6 GitHub stars· updated 2026-08-23

Long-term memory for DeepSeek Harness: conversations auto-distilled into facts, scenes & persona, recalled before every step — so the AI speaks from evidence, not guesses. Zero effort.

Install

npx @deepseek-ai/dsh plugin --profile web add dsh-layered-memory

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

dsh-layered-memory DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/dsh-layered-memory.svg)](https://dshhub.dev/plugins/dsh-layered-memory)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from JunNanLYS/dsh-layered-memory, cleaned of badges and images.

<img src="./assets/img/Hero.png" width="100%" alt="DeepSeek Harness hero 横幅:对话自动分层蒸馏成记忆,模型每步前自动召回注入——右侧对话气泡逐层溶解为三层渐亮光带,流入带发光圆球与渐变轨道的玻璃胶囊(下有 日常·工作·智能·关闭 四档刻度),光丝回流示意召回注入">

dsh-layered-memory

DeepSeek Harness 的分层蒸馏记忆插件:对话在后台自动完成 L0 捕获 → L1 原子记忆 → L2 场景整合 → L3 画像蒸馏,模型每一步前自动把相关记忆注入上下文。

English · 最新发行版 · 反馈问题

快速开始

需要 Node ≥ 22.16。两种调用方式任选(npx 前缀可替换下面任何 dsh 命令):

# 方式一:npx 直接跑官方 CLI(无需预装 dsh;可 pin 版本,如 [email protected])
npx -y @deepseek-ai/dsh plugin --profile web add dsh-layered-memory

# 方式二:已装 dsh CLI(dsh 是 pnpm 转发器,未装 pnpm 时先 npm i -g pnpm)
dsh plugin --profile web add dsh-layered-memory

# 包源备选:GitHub 仓库 / 本地路径(开发调试,link: 指向仓库,npm run build + 重启 dsh 即生效)
dsh plugin --profile web add https://github.com/JunNanLYS/dsh-layered-memory
dsh plugin --profile web add /path/to/dsh-layered-memory

让 Agent 安装(推荐)

如果当前 Agent 可以执行终端命令,把下面这段话完整发送给它:

请为 DeepSeek Harness 的 web Profile 安装 dsh-layered-memory 插件。

只执行下面两条命令,不要修改其他 Profile:
dsh plugin --profile web add dsh-layered-memory
dsh --profile web --dump-config

确认输出中出现 dsh-layered-memory 后告诉我安装结果。
不要替我关闭或重启正在运行的 DSH;安装完成后提醒我手动重启 DSH Web Host。

Agent 应当返回安装结果,并明确告诉你配置中是否已经出现 dsh-layered-memory

本包声明了 dsh.bundle 组合包层(cordis.patch.yml),安装后会自动挂载插件行—— 不需要再手改 $DSH_HOME/profiles/web/cordis.patch.yml。然后重启 DeepSeek Harness, 验证:~/.dsh/memory/ 下出现 conversations/ records/ scenes/ 目录和 memory.db 即插件 apply 成功;设置页出现"记忆"页面、输入栏出现档位 pill 即 client 半边就绪。

卸载dsh plugin --profile web remove dsh-layered-memory + 重启。数据保留在 ~/.dsh/memory/,不需要时手动删除整个目录即可。

从源码开发

git clone https://github.com/JunNanLYS/dsh-layered-memory
cd dsh-layered-memory
npm install && npm run build
dsh plugin --profile web add .        # link: 安装,改代码后 npm run build + 重启 dsh 即生效
npm run smoke                         # 冒烟测试(先重编:见下方命令)
npx tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution nodenext --target es2022 --strict --skipLibCheck --esModuleInterop

运行时数据流

<img src="./assets/readme/flow.svg" width="100%" alt="dsh-layered-memory 运行时数据流:左侧 User 与 Assistant 的会话事件流入插件(L0 捕获、L1–L3 蒸馏、检索召回、记忆工具),插件经 agent/pre-step 把相关记忆注入右侧 DSH 核心;蒸馏复用核心的 ctx.llm,数据双写 ~/.dsh/memory/">

插件挂在 dsh 原生事件上(session/event 捕获、agent/pre-step 注入),蒸馏调用复用宿主 ctx.llm。召回以消息侧注入呈现:相关记忆作为一条合成消息排在用户新消息之前,会话流里显示为**"上下文注入 · memory"**行(点开看命中内容)——用户能直接看到"记忆生效了";注入内容有长度预算与时间预算,超限截断/超时跳过,绝不拖慢对话。

记忆工具(3):

  • memory_search
  • conversation_search
  • memory_read_scene

真机实录:召回注入与工具调用在对话里的样子——"上下文注入 · memory"行先带出相关记忆,模型再按需调 memory_read_scene 读取场景块,凭记忆直接作答:

<img src="./assets/img/MemoryTools.png" width="60%" alt="对话界面实录(浅色主题):用户消息"我们最近要干什么?"上方可见"上下文注入 · memory"行;助手回答前列出 4 次 memory_read_scene 工具调用(参数为 scenes 场景块的 .md 文件名),随后凭记忆梳理近期目标与推进路线">

在只开放代码执行入口的受限会话中,模型经由 run_code 间接调用记忆工具(轨迹视图中的 SUBTOOL 嵌套):

<img src="./assets/img/ToolTrajectory.png" width="80%" alt="工具调用轨迹视图:顶部彩色时间线与左侧步骤列表(SYSTEM/CONTEXT/USER/ASSISTANT/TOOL/SUBTOOL 彩色标签),run_code 工具步骤内嵌套 5 次 memory_read_scene 子工具调用(SUBTOOL 标记),右侧为所选步骤的详情面板">

分层记忆(L0–L3)

<img src="./assets/img/Layers.png" width="100%" alt="分层记忆四层(自左上向右下逐层精炼):L0 原始对话(对话气泡)→ L1 原子记忆(发光事实粒子)→ L2 场景块(玻璃文档板)→ L3 核心画像(发光晶核);层间由 LLM 提取/整合/蒸馏光束相连,宽度递减表示数据逐层精炼">

会话级记忆档位

Related plugins