GongYuanCaiJi/dsh-pi-memory0

dsh-pi-memory

跨会话持久记忆插件,支持在 DSH 运行期间跨越不同会话持久化存储和检索关键上下文信息。

AI 分析

核心用途是解决 AI 会话遗忘问题,实现长期记忆。适合需要 Agent 记住个人偏好、项目背景或长期任务上下文的连续性工作场景。

包名
dsh-pi-memory
版本
0.1.0
许可证
MIT
最近更新
2026年8月15日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:GongYuanCaiJi/dsh-pi-memory

配置

变量取值默认说明
PI_MEMORY_DIR路径$DSH_HOME/agent/memory覆盖记忆存储目录(默认在 dsh home 下,而非 Pi 的 ~/.pi
PI_MEMORY_SNAPSHOTstable, per-turnstablestable 在检查点快照记忆以保 KV 缓存稳定;per-turn 每 turn 重建(旧行为)
PI_MEMORY_QMD_UPDATEbackground, manual, offbackground控制写入后的自动 qmd update + qmd embed
PI_MEMORY_QMD_SEARCH_TIMEOUT_MS正整数(毫秒)60000显式 memory_search 的 qmd 查询超时
PI_MEMORY_NO_SEARCH1未设置关闭 per-turn 模式的选择性注入(stable 模式无效)
PI_MEMORY_SUMMARIZE_TRANSITIONS1, true, yes, on未设置生命周期过渡(reload/new/resume/fork)也写退出总结;默认过渡跳过总结以提速
PI_MEMORY_EXIT_SUMMARY0, off, false, no 关闭未设置(启用)关闭会话结束时的退出总结(不做 LLM 调用、不跑 qmd update,退出即时)
PI_MEMORY_EXIT_SUMMARY_MODELprovider/model-id未设置(会话模型)写退出总结用的模型,比如更便宜的。无法解析则回退会话模型
PI_MEMORY_EXIT_SUMMARY_TIMEOUT_MS正整数(毫秒)10000退出总结自限超时;超时则不落盘

移植注:session_shutdown 在 dsh 上映射为 agent/disposed —— 该事件只在 dsh 主动销毁 agent 且服务仍存活时触发;headless 一次性任务结束时服务先于插件析构,退出总结会安静跳过(不崩溃、不落盘)。这是 dsh 生命周期与 Pi 的差异,详见移植票 #18。

Configuration

VariableValuesDefaultDescription
PI_MEMORY_DIRpath$DSH_HOME/agent/memoryOverride the memory storage directory (defaults under the dsh home, not Pi's ~/.pi)
PI_MEMORY_SNAPSHOTstable, per-turnstablestable snapshots memory at checkpoints for KV cache stability; per-turn rebuilds every turn (legacy behavior)
PI_MEMORY_QMD_UPDATEbackground, manual, offbackgroundControls automatic qmd update + qmd embed after writes
PI_MEMORY_QMD_SEARCH_TIMEOUT_MSpositive integer (milliseconds)60000Sets the timeout for explicit memory_search qmd queries
PI_MEMORY_NO_SEARCH1unsetDisable selective injection in per-turn mode (no effect in stable mode)
PI_MEMORY_SUMMARIZE_TRANSITIONS1, true, yes, onunsetAlso write exit summaries during lifecycle transitions (reload/new/resume/fork). By default these transitions skip summaries for speed.
PI_MEMORY_EXIT_SUMMARY0, off, false, no to disableunset (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_MODELprovider/model-idunset (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_MSpositive integer (milliseconds)10000Self-imposed timeout for exit-summary generation on session end. On expiry nothing is persisted.

Porting note: session_shutdown maps to dsh's agent/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.