dsh-memory
Agent 与会话 活跃维护

dsh-memory

biubiu23333333/dsh-memory

轻量化记忆管理模块,支持多轮对话上下文持久化存储,可灵活配置记忆衰减、检索策略,接口简洁无额外依赖,几行代码即可集成到现有对话应用,快速落地稳定的记忆能力。

1
Stars 标星
0
Forks 分支
1
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
18 KB
仓库大小
3 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:biubiu23333333/dsh-memory
git clone https://github.com/biubiu23333333/dsh-memory.git
git clone git@github.com:biubiu23333333/dsh-memory.git
README.md main

dsh-memory

Persistent three-layer memory for DeepSeek Harness (DSH),
implemented as a host-side bundle plugin: cross-workspace storage, forced
per-turn auto-consolidation, agent-visible memory tools, and a system-prompt
section that makes every agent preset actively use memory.

DSH 持久三层记忆宿主插件:跨工作区共享记忆库 + 每回合强制自动沉淀 + agent 记忆工具

  • 对所有预设生效的主动记忆引导。

What it gives you / 能力

需求 实现
长期记忆 long-term/:profile / facts / decisions / projects(agent 用 memory_write 维护)
短期记忆 short-term/<sessionId>.md:每回合结束宿主自动追加原始流水
会话摘要 episodes/<sessionId>.md:每回合结束宿主自动用 LLM 追加一句话要点
跨 workspace 共享 记忆根固定为 $DSH_HOME/memory(默认 ~/.dsh/memory),与任何工作区解耦;读写走宿主层,不受 agent 文件沙箱限制
强制自动沉淀 宿主监听 session/event 的 turn/end(completed),回合自然结束即沉淀,不依赖 agent 自觉;无 LLM 可用时确定性摘要兜底
模型工具 memory_read / memory_write / memory_search(宿主执行)
主动记忆引导 注册 systemPrompt 段(host 层,对所有预设生效):会话开始必读长期记忆、学到事实主动写入、答"你记得吗"先检索。无需任何 agent 预设

插件装在宿主层,任何预设(standard / minimal / 自建)的会话都自动获得全部记忆能力——
不需要选择"记忆模式"。

Install / 安装

# 1. 构建 tarball 并安装进目标 profile(reconcile 自动加入 bundle 层)
cd dsh-memory
pnpm pack
dsh plugin --profile web add ./dsh-memory-0.1.0.tgz

# 2. 重启 dsh web
systemctl restart dsh-web        # systemd 部署
# 或重新运行 dsh web

或者一键:./install.sh [profile](默认 profile 为 web)。安装后记忆根自动初始化三层骨架。

Layout / 记忆库布局

$DSH_HOME/memory/
├── README.md
├── long-term/
│   ├── profile.md        # 用户画像
│   ├── facts.md          # 事实
│   ├── decisions.md      # 决定
│   └── projects.md       # 项目笔记
├── episodes/<sessionId>.md   # 自动:每回合追加一行 LLM 摘要
└── short-term/<sessionId>.md # 自动:每回合追加原始流水

根目录可用配置 root(profile patch 里给 dsh-memory 行加 config)或环境变量
DSH_MEMORY_ROOT 覆盖;legacyRoot 配置可把旧目录一次性并入。

Development notes / 开发说明

  • 纯 ESM、零构建:package.json 声明 dsh.bundle.patch → cordis.patch.yml
    在 profile root 插入一行,host 插件注册工具/事件/提示段。
  • 依赖 @deepseek-ai/dsh-tools / dsh-llm / dsh-home-paths,运行时由 DSH
    的 profiles module fallback 解析(无需自带依赖)。
  • 自动沉淀:监听 session/event firehose(host 可靠接收)上的
    turn/end(reason.kind === 'completed') → 追加 short-term 原始流水 → 尽力用
    ctx.llm.stream 生成一句话要点追加 episodes;同 session+turn 去重,不阻塞事件流。
  • 主动引导:ctx.systemPrompt.section({ name: 'dsh-memory', ... }) 在 host 注册,
    因此注入到每个预设的 agent 系统提示。

License

MIT