Memory in global and per-project scopes: memories are injected into the system prompt at session start, a settings panel edits them with confirmation on write, and the agent gets a read-only memory_query tool (npm: `dsh-my-memory`).
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-my-memory
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:baosfeng/my-dsh-plugins#path:/plugins/dsh-my-memory
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
dsh-my-memory:DSH 记忆插件——全局记忆持久化,每轮全量注入系统提示词,设置页三 tab 面板(全局记忆 / 全局提示词 / Agent 记忆)管理;提供 memory_query(只读查询)/ memory_save / memory_delete 三个 agent 工具,写操作默认经用户确认。条目带分类/来源/置信度/演进历史。项目层面的记忆归「Agent 记忆」的 projects/<id>/(每轮注入、独立工具),不再有第二套「项目记忆」。

功能
- 单一存储:全局记忆(跨项目偏好,存
$DSH_HOME/memory.json)。原「项目记忆」($DSH_HOME/memory/projects/<id>.json)已整体移除——它既不进系统提示词(只能靠memory_query手动查),又与 Agent 记忆的项目分层重复,留着只会让 agent 在两套「项目记忆」之间选错。 - 系统提示词注入(全量):注入全局记忆(order 10230,排在宿主固定段之后——易变内容不打散 system prompt 的缓存前缀,见
src/section-orders.ts),每一条都注入:不评分、不按条数截断,用户确认写下的每一条都随会话携带;唯一的裁剪是单条长度maxDescLength——注入只给结论(先剥掉解释性长括号,含命令 / 路径的括号保留,再取首句,默认上限 200 字),完整正文仍完整存在存储里,要用细节时memory_query查全文。- 为什么全量:记忆由用户显式确认写入,条目量小(实测本机 6 条 / 330 字 ≈ 220 token),而按分数挑选会把「44 天没更新的硬约束」漏掉——省下来的几百 token 换不来约束失效的代价。
- 可视化面板:设置 → 插件 → 「记忆」,三个 tab 切换:全局记忆 / 全局提示词 / Agent 记忆。记忆条目显示首句概要,可展开查看来源会话、分类、置信度与演进历史;新增与编辑用多行自适应输入框(带字数计数与超长精简提示),保存/删除走居中确认弹层。
- 写操作需确认:所有新增/修改/删除经自定义确认 UI(删除红色 + 二次确认,保存绿色),服务端强制
confirmed: true标记,缺失即 400 拒绝,记忆绝不静默变更。 - 工具:
memory_query只读查询(全局记忆 + 关键词过滤,输出带每条记忆的分类与 id);memory_save保存(desc必填,category为偏好/事实/技术栈/工作流,默认fact);memory_delete按 id 删除(删除不存在的 id 明确报错)。 - 渐进式索引:条目带分类/来源(会话 id + 时间)/置信度(上限 5)/更新时间/演进历史;同主题多次出现提升置信度或更新内容,内容分歧标记「待处理矛盾」,长期未用(默认 90 天)降权。
- 全局提示词(与记忆隔离):设置页「全局提示词」分区可新增 / 编辑 / 删除 / 启停 / 上移下移任意自由文本指令;启用的提示词每轮组装全量按序注入(独立 section
dsh-my-memory:prompts,order 10220,排在宿主固定段之后:改一条提示词只让系统提示尾部变化,稳定前缀仍可命中缓存),不评分、不截断、不占记忆的 top-N 名额,保存后下一轮即生效(无需重启)。注入正文只有一个短标题## 全局提示词加各条目本身——不写插件名、不写注入机制。它们不是记忆:独立文件$DSH_HOME/memory/prompts.json、独立端点/my-memory/api/prompts、agent 无写工具;首次运行迁入内置种子「中文思考」(可停用/删除,删除不复活)。 - Agent 记忆(issue #502,第四套体系):agent 自主维护的跨会话记忆,与全局记忆、全局提示词完全隔离。
- 注入策略:全局层 + 当前项目的每条原文全量注入(order 10210,排在宿主固定段之后):
user.md/feedback.md是全局层,projects/<当前项目>/decisions.md/pitfalls.md是项目层,逐条原文进系统提示词,其他项目一条都不进上下文——旧的「30 字目录摘要」既猜不准内容又把别的项目摊了进来(实测混入过 toolbar / norvels 的条目)。实测真实库约 11 KB / 83 条;超 20480 字节时按「全局优先 + 项目层尾部」截断并写明剩余条数,绝不静默丢。 - 工具只有一个:
agent_memory_save(追加一条;传replace替换那条原文,target选decisions(默认)/pitfalls/user/feedback),成功只回ok。正文已在上下文里,read / list / search 不再需要;删除与编辑归面板(破坏性操作不由 agent 做)。写入纪律收在工具描述里,常驻预算全留给正文。 - 写入时压缩(
agentMemory.compress,默认关):开启后超过compressMinChars(默认 60 字)的条目交给当前会话模型压一次——只删解释、举例与语气词,保留结论 / 命令 / 路径 / 数字,条数与顺序必须一致,任何失败都按原文写入。 - 存储与门禁:正文是纯 markdown(无日期、无 id),元数据(创建 / 最后读取 / 归档)单独存
index.json且 agent 不可见、不可写;路径白名单 + 尺寸红线(16 KB / 120 条 / 单条 200 字)+ 敏感信息扫描 + 全局层写入护栏(含项目路径 / IP / 端口 / 仓库名的条目拒写全局)+ 跨文件写入去重(字符级相似度 ≥ 0.5 拒写并指出重复位置)。项目层条目写projects/current/…,由系统解析成真实项目(agent 不必知道 hash)。 - 遗忘与恢复:超过
archiveDays(默认 180 天)未写入自动归档、不再注入(注入本身不计热度);归档后面板仍能看到正文并一键恢复(正文搬回原位 + 清归档标记),写入同名文件同样自动复活。设置页第四个 tab 提供文件视图、元数据、作用域徽标与删除二次确认。
- 注入策略:全局层 + 当前项目的每条原文全量注入(order 10210,排在宿主固定段之后):
- 持久化可靠:原子写(tmp+rename)+ 防抖(300ms),重启后自动恢复;提示词独立存
$DSH_HOME/memory/prompts.json,与正式记忆隔离。
安装
# npm 安装(推荐)
dsh plugin --profile web add dsh-my-memory --trust-lockfile
# 或从本仓库 link 安装
git clone https://github.com/baosfeng/my-dsh-plugins.git
dsh plugin --profile web add link:<仓库路径>/plugins/dsh-my-memory
配置
cordis.yml 中 my-memory 的 config 字段,均可省略:
| 配置键 | 默认 | 作用 |
|---|---|---|
maxDescLength |
200 |
单条记忆注入长度上限(字符):注入只给结论(剥解释性括号 + 取首句),不强行压低 |
maxEntryLength |
50 |
建议单条记忆长度上限(字符),超长时面板提示精简 |
proactivePropose |
false |
开启后引导 agent 主动向你提议保存记忆 |
saveApproval |
'auto' |
记忆写操作(保存 + 删除)确认策略:auto / always / never |
maxPromptItems |
20 |
注入系统提示词的全局提示词条数上限(超出不注入 + warn) |
maxPromptLength |
1000 |
单条提示词正文上限(字符,超出截断 + warn) |
agentMemory.enabled |
true |
是否启用 agent 记忆(第四套体系,issue #502) |
agentMemory.archiveDays |
180 |
冷记忆归档阈值(天):超过该天数未被 agent 读取即移入 archive/(面板可见并可恢复) |
agentMemory.compress |
false |
写入时用 LLM 压缩超长条目(默认关;开启后只删解释/举例、保留命令与事实,失败按原文写) |
agentMemory.compressMinChars |
60 |
触发压缩的条目长度门槛(短条目不动) |
权限模式与保存确认
DSH 会话权限 preset 同时决定 sandbox 与 approval policy:danger-full-access → approval policy = never,宿主对 { kind: 'ask' } 审批直接判 rejected(不弹窗)。插件因此按会话审批策略 + saveApproval 决策:
auto(默认):策略为ask(如 workspace-write)时弹原生确认;策略为never时免确认直接写入(条目标记来源会话、面板可见可删)。always:任何策略都要求确认;never下明确失败并返回可操作提示(改saveApproval/ 切 workspace-write / 面板手动新增)。never:从不确认,直接写入或删除(高级用法)。- 策略判定优先用宿主 approval 服务的
effectivePolicy(session),回落会话日志approval/policy,都不可用时按ask保守处理;memory_delete复用同一道tools/pre-execute确认门与同一矩阵,确认文案带待删内容摘要。
相关文档
→ 记忆概述
Links
More in this category
vectorize-io/hindsight#coding-agents★ 64308
Hindsight, agent memory that learns: long-term project memory with auto recall and retain, knowledge pages, deep reflection, and per-repo memory banks.
volcengine/OpenViking#examples/dsh-memory-plugin★ 43076
OpenViking memory and context bundle for DeepSeek Harness: pre-step auto-recall and profile injection, session capture, `viking://` URI guarding, and recall/write memory tools backed by an OpenViking server.
MemTensor/MemOS#memos-local-plugin★ 12546
Local-first memory plugin for DeepSeek Harness: layered L1/L2/L3 memory with automatic capture, manual memos_* retrieval tools, and a built-in memory viewer.
agentscope-ai/ReMe#dsh★ 3873
Connects DeepSeek Harness to ReMe's local-first, self-evolving personal knowledge base: automatically captures completed main-agent conversations as user-owned Markdown memory, searches conversations and source material through reme_search with BM25, optional embeddings, and wikilink expansion, and schedules daily memory consolidation.
zilliztech/memsearch#MemSearch★ 2971
Shared Markdown memory for DSH and other coding agents, with automatic capture, pre-step context injection, searchable recall, and memory-to-skill self-evolution through a review panel.
vshulcz/deja-vu#extensions/dsh★ 1709
Cross-session memory and context recovery across forty-five other coding agents (45+) on this machine, reading session files they already wrote before install (Claude Code, Codex, Cursor, Windsurf, Trae, Antigravity, VS Code Copilot Chat, opencode, OpenClaw, Hermes, Kimi, Qoder, Cline, Zed, Magpie and more): six tools (deja_recall, deja_session, deja_blame, deja_fix, deja_how, deja_remember), a /deja command, and optional automatic recall injected into runtime context. Local BM25 CLI/MCP index, no LLM, no embeddings, no network (dsh plugin --profile web add dsh-deja).
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.