TindalosKorone/dsh-agent-memory ↗★ 0
@dsh-agent/dsh-agent-memory
为智能体提供基于NDJSON文件的跨会话长期记忆 适合需要智能体记住跨会话事实、偏好和教训的开发任务。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:TindalosKorone/dsh-agent-memory说明文档
阅读完整 README ↗dsh-agent-memory
给 DSH Agent 用的跨会话长期记忆:四个工具(memory_remember / memory_recall / memory_expand / memory_prune)把值得留下的结论写进一份人类可读的 NDJSON 文件,下次会话按需召回。
注意:没有「按话题自动召回」。 自动进上下文的只有一行索引(条数 + 条件规则 + 标签锚点)和一条稳定规则;记忆正文不会自动注入,要内容必须由模型显式调用
memory_recall(再按 id 调memory_expand取正文)。那条规则是提示,不是保证。
适用场景
- 适合:跨会话留结论 —— 事实、教训、偏好、指路。
- 不适合:多用户 / 多租户共享记忆;「一问就自动想起相关内容」的场景(本插件不自动召回)。
安装
按 1 → 2 → 3 走:clone 到本地 → 构建产物 → 用命令装进 profile。
-
克隆到本地
git clone https://github.com/TindalosKorone/dsh-agent-memory.git cd dsh-agent-memory -
构建产物
pnpm install # 取 TypeScript 等 devDependencies(本包运行时零依赖) pnpm run build # 等价 node node_modules/typescript/bin/tsc -p .lib/是 tsc 产物且已随包入库;只安装、不改源码时,这一步可跳过。 -
安装进 profile
dsh plugin --profile
add /绝对路径/dsh-agent-memory
把 `
` 换成目标 profile(如 `web`)。装完**重启 DSH** —— 插件在 boot 时载入,不重启不会出现。
只想用、不打算改代码的话,也可以跳过 clone 直接一行装远端:`dsh plugin --profile
add github:TindalosKorone/dsh-agent-memory`。
**或者,让你的 agent 按 [docs/install.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/install.md) 安装** —— 那份文档写全了三种方式、profile 侧软链、路径与验证步骤。
## 怎么用
1. `memory_remember`:写一条。`kind` 四选一(`fact` / `lesson` / `preference` / `pointer`),`title` 单行 8..120 字符,`tags` 1..12 个,`source` 非空;`scope` **可选**(建议 `project:`,省略 = `global`,非空单行 `,结构化 `rows` 另带 `scope` 字段(打印行仍是 10 列)。
`match` 由 `rel`、两个阈值与**内容量闸门**共同判定(复算口径见契约 §5);多样性启用时 `score` 不能仅由 `rel`/`graph` 复算。库规模离标定点过远时表头会提示重标,实际重跑用 `pnpm run calibrate -- --write`。
3. `memory_expand`:拿 `recall` 回的 `id` 取正文(L2)。
4. `memory_prune`:同 kind 同标题合并(留最新、累加 hits),再按 `pruneScore = decay(ts)*(1+hits)` 从低到高淘汰;`dryRun: false` 才真删。
完整列语义、打分常数、写入协议与闸门见 [docs/recall-contract.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/recall-contract.md)。
## 故障排查
装完工具不出现、插件卡在 PENDING、`lib/` 没构建、注入行为不变、库在哪与怎么备份 —— 这些排查步骤已移到 **[docs/troubleshooting.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/troubleshooting.md)**。
## 安全
- 记忆库是**本地纯文本**文件,位置 `$DSH_HOME/agent-memory/memory.ndjson`;**不含任何凭据**。
- 上限:默认 2000 条 / 4 MiB;单条默认 ≤ 总上限(`maxBytes`,默认 4 MiB)的 10%;写超限直接拒收(不落盘、不触发淘汰)。
- 许可:本插件采用 [CC BY-NC-SA 4.0](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/LICENSE)。
## 上游与署名
本插件参考了 [lioensky/VCPToolBox](https://github.com/lioensky/VCPToolBox) 的记忆系统设计(该项目同样采用 CC BY-NC-SA 4.0)。
## 链接
- [docs/glossary.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/glossary.md) — 术语表(`rel`/`cov`/`match`/`qTok`/`L1`/`L2` 等符号的唯一定义)
- [docs/install.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/install.md) — 三种安装方式(远端一行 / 本地 clone + 构建 / 交给 agent)、重启与验证
- [docs/troubleshooting.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/troubleshooting.md) — 故障排查(工具不出现、卡 PENDING、注入不变、库位置与备份)
- [docs/design.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/design.md) — 分期实现、7 条硬不变量、两条注入机制、为什么不自动召回
- [docs/recall-contract.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/recall-contract.md) — 10 列逐列含义、打分常数、写入协议与 fail-closed 闸门
- [docs/development.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/development.md) — 构建、测试纪律与失败证据、脚本、环境事实
- [docs/limitations.md](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/docs/limitations.md) — 9 条诚实局限、标定出处、发布注意
- [redproof/](https://github.com/TindalosKorone/dsh-agent-memory/tree/main/redproof) — 失败证据目录(每条机制一份「能让测试变红」的证据)
- [NOTICE](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/NOTICE) / [LICENSE](https://github.com/TindalosKorone/dsh-agent-memory/blob/336d2a6c32275c85fb9e91978f206d41c8753ce0/LICENSE)