GongYuanCaiJi/dsh-pi-memory ↗★ 0
dsh-pi-memory
跨会话持久记忆插件,支持在 DSH 运行期间跨越不同会话持久化存储和检索关键上下文信息。
AI 分析
核心用途是解决 AI 会话遗忘问题,实现长期记忆。适合需要 Agent 记住个人偏好、项目背景或长期任务上下文的连续性工作场景。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:GongYuanCaiJi/dsh-pi-memory说明文档
阅读完整 README ↗配置
| 变量 | 取值 | 默认 | 说明 |
|---|---|---|---|
PI_MEMORY_DIR | 路径 | $DSH_HOME/agent/memory | 覆盖记忆存储目录(默认在 dsh home 下,而非 Pi 的 ~/.pi) |
PI_MEMORY_SNAPSHOT | stable, per-turn | stable | stable 在检查点快照记忆以保 KV 缓存稳定;per-turn 每 turn 重建(旧行为) |
PI_MEMORY_QMD_UPDATE | background, manual, off | background | 控制写入后的自动 qmd update + qmd embed |
PI_MEMORY_QMD_SEARCH_TIMEOUT_MS | 正整数(毫秒) | 60000 | 显式 memory_search 的 qmd 查询超时 |
PI_MEMORY_NO_SEARCH | 1 | 未设置 | 关闭 per-turn 模式的选择性注入(stable 模式无效) |
PI_MEMORY_SUMMARIZE_TRANSITIONS | 1, true, yes, on | 未设置 | 生命周期过渡(reload/new/resume/fork)也写退出总结;默认过渡跳过总结以提速 |
PI_MEMORY_EXIT_SUMMARY | 0, off, false, no 关闭 | 未设置(启用) | 关闭会话结束时的退出总结(不做 LLM 调用、不跑 qmd update,退出即时) |
PI_MEMORY_EXIT_SUMMARY_MODEL | provider/model-id | 未设置(会话模型) | 写退出总结用的模型,比如更便宜的。无法解析则回退会话模型 |
PI_MEMORY_EXIT_SUMMARY_TIMEOUT_MS | 正整数(毫秒) | 10000 | 退出总结自限超时;超时则不落盘 |
移植注:
session_shutdown在 dsh 上映射为agent/disposed—— 该事件只在 dsh 主动销毁 agent 且服务仍存活时触发;headless 一次性任务结束时服务先于插件析构,退出总结会安静跳过(不崩溃、不落盘)。这是 dsh 生命周期与 Pi 的差异,详见移植票 #18。
Configuration
| Variable | Values | Default | Description |
|---|---|---|---|
PI_MEMORY_DIR | path | $DSH_HOME/agent/memory | Override the memory storage directory (defaults under the dsh home, not Pi's ~/.pi) |
PI_MEMORY_SNAPSHOT | stable, per-turn | stable | stable snapshots memory at checkpoints for KV cache stability; per-turn rebuilds every turn (legacy behavior) |
PI_MEMORY_QMD_UPDATE | background, manual, off | background | Controls automatic qmd update + qmd embed after writes |
PI_MEMORY_QMD_SEARCH_TIMEOUT_MS | positive integer (milliseconds) | 60000 | Sets the timeout for explicit memory_search qmd queries |
PI_MEMORY_NO_SEARCH | 1 | unset | Disable selective injection in per-turn mode (no effect in stable mode) |
PI_MEMORY_SUMMARIZE_TRANSITIONS | 1, true, yes, on | unset | Also write exit summaries during lifecycle transitions (reload/new/resume/fork). By default these transitions skip summaries for speed. |
PI_MEMORY_EXIT_SUMMARY | 0, off, false, no to disable | unset (enabled) | Disable the exit summary on session end. Ending then does no LLM call and no qmd update, so it is instant; explicit memory_write during sessions is unaffected. |
PI_MEMORY_EXIT_SUMMARY_MODEL | provider/model-id | unset (session model) | Model used to write the exit summary, e.g. a cheaper/faster one. Unresolvable specs fall back to the session model. |
PI_MEMORY_EXIT_SUMMARY_TIMEOUT_MS | positive integer (milliseconds) | 10000 | Self-imposed timeout for exit-summary generation on session end. On expiry nothing is persisted. |
Porting note:
session_shutdownmaps to dsh'sagent/disposed— that event fires only when dsh disposes an agent while services are still live; in headless one-shot runs the services are torn down before plugin disposers run, so the exit summary is silently skipped (no crash, nothing persisted). This is a dsh-vs-Pi lifecycle difference, detailed in porting ticket #18.