Back to home

joyiok

dsh-memory

DSH plugin: shared persistent memory store across all sessions, with memory_* tools and a Web sidebar panel

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

Introduction

dsh-memory

DeepSeek Harness(DSH)共享持久记忆插件。

  • 一个所有会话共享的记忆库:存储在 $DSH_HOME/storages/dsh-memory.json, web / headless / 任何工作目录的会话都读写同一份数据。
  • Agent 工具memory_add / memory_search / memory_list / memory_remove, 新会话里 Agent 会自动先检索记忆、遇到值得记住的事实会主动写入。
  • Web 侧边栏:底部 Memory 按钮,面板支持查看、搜索、添加、删除记忆。
  • 原子写入:临时文件 + rename,跨进程写入安全;读取按 mtime 感知外部更新。

安装

cd /home/joy/Documents
dsh plugin --profile web add /home/joy/Documents/dsh-memory-plugin
dsh plugin --profile headless add /home/joy/Documents/dsh-memory-plugin

安装完成后重启 dsh web

dsh web

验证:dsh --profile web --dump-config 应出现:

# == dsh-memory
- id: memory
  name: dsh-memory

使用

让 Agent 记忆 / 回忆

用户:记住:我们的正式语言是中文,token 预算每月 5000 万
Agent:调用 memory_add(content: ..., tags: ["preference", "budget"])

(新会话)
用户:我们之前说过 token 预算多少?
Agent:调用 memory_search(query: "预算") 后回答

Web 面板

左下角 Memory → 输入框写内容 + 逗号分隔标签 → 保存;列表内可搜索、删除。

工具参数

工具参数说明
memory_addcontent 必填;tags / category 可选写入一条共享记忆
memory_searchquery 必填;limit 可选搜索内容 / 标签 / 分类
memory_listcategory / tags / limit 可选列出记忆
memory_removeid 必填按 id 删除记忆

配置

可在 profile 的 cordis.patch.yml 覆盖(覆盖整行 config):

- id: memory
  config:
    file: /path/to/shared-memory.json   # 默认 $DSH_HOME/storages/dsh-memory.json
    maxContentChars: 20000              # 单条记忆最大字符数
    defaultSearchLimit: 20
    maxToolLimit: 100

禁用插件:

- id: memory
  disabled: true

结构

src/index.js               # 宿主半体:Typert RPC + 4 个记忆工具 + 系统提示注入
src/store.js               # 持久化核心:原子读写、缓存、搜索
lib/client.js              # 浏览器半体:侧边栏 Memory 面板
lib/typert.host.js         # Typert host 清单(memory/*)
lib/typert.remote-client.js# Typert remote 描述符(参考)
cordis.patch.yml           # dsh bundle 补丁:插入 memory 行
scripts/build.mjs          # esbuild 构建脚本(node scripts/build.mjs)

注意

  • 记忆内容对所有会话可见,请勿写入密钥、口令等敏感信息。
  • 如果 JSON 文件损坏,插件会把损坏文件备份为 dsh-memory.json.corrupt-<ts> 并重新开始。