jipika/dsh-memory

Two-layer long-term memory for DeepSeek Harness (DSH): global + per-project markdown, live re-read, zero extra LLM cost, with a Settings panel. 给 DSH 的两层长期记忆。

Project Overview项目介绍

@jipika/dsh-memory is a progressive long-term memory plugin built specifically for DeepSeek Harness (DSH), shipped as an npm package and also listed in the DSH 1024Store directory. Memory is stored as plain sharded markdown files under ~/.dsh/memory/ — a global layer sliced by topic (preferences, platform facts, recurring pitfalls) plus a per-workspace project layer that swaps automatically when the working directory changes. Only a live-generated shard map (shard name, keywords, entry count, latest date) is injected into the system prompt; entry titles and bodies never enter the prompt, and the agent pulls them on demand by greping the memory directory for task keywords, reading the returned line numbers. Injection is wired through systemPrompt.section() with a functional text callback so every prompt assembly re-evaluates the file state, making edits live without an app restart.

The typical workflow starts with installation via dsh plugin --profile web add @jipika/dsh-memory, which auto-merges the bundled cordis.patch.yml into the active profile — no manual profile editing required. A new "记忆 / Memory" section then appears inside DSH Settings, listing each layer with expandable panels that read and write the underlying markdown files (a .bak is taken before each save), and the global rules file ~/.dsh/AGENTS.md is editable from the same panel. The same agent already running the conversation handles memory writes, so there is no second model, no vector index, and no background job; the discipline block injected by the plugin also enforces when the agent must read memory before acting and when it should delegate cross-shard lookups to a low-cost dedicated retrieval subagent. It targets developers running multi-session, multi-project agent workflows on DSH who care about flat prompt cost and reviewable, git-friendly plaintext storage.

The plugin depends on exactly four DSH seams: systemPrompt.section() with a functional text, webServer.register({kind:"prefix"}), the tools/pre-execute and tools/post-execute hook slots, and a client settings.section slot. Its own settings.json plus three HTTP routes (GET /dsh-memory/content, POST /dsh-memory/write, GET|POST /dsh-memory/settings, the write endpoints gated by the x-dsh-memory: 1 header) keep state outside the host settings service so the 0.1.7 cordis Config migration does not affect it. Verification ran 210 assertions under a temporary HOME against DSH 0.1.7-rc.2 Desktop; source installs use link: plus pnpm install and require one host restart because HMR base paths change. Three injection modes (map / index / full) are exposed in the panel with adjustable index budgets of 6K/12K/18K/24K/unlimited. License: MIT.

@jipika/dsh-memory 是一个面向 DeepSeek Harness(DSH)的渐进式长期记忆插件,以 npm 包形式发布,亦收录于 DSH 1024Store 目录。记忆以分片纯 markdown 文件存放于 ~/.dsh/memory/(全局层按主题切片,外加按工作区划分的项目层),进系统提示词的只是实时生成的片级地图(片名 · 关键词 · 条数 · 最新日期),条目标题与正文不进入提示词,agent 用关键词 grep 命中行号再 read 取回,因此上下文开销恒定。注入通过 systemPrompt.section() 的函数式 text 实现,每次提示词组装都重新求值,写完即生效、无需重启。

典型流程:安装后插件会自动挂入 profile 的组合树,DSH 设置面板多出"记忆"分栏,可分层展开、就地编辑并保存回文件,切换项目即切换内容;用户或会话中的 agent 可直接把新事实追加到对应 markdown 切片。适合需要在多项目、多会话中保留稳定事实、用户偏好与平台坑位的开发者,尤其关心成本控制与可 git/可手改的明文存储的人。

依赖 DSH 的四个 seam:systemPrompt.section()(函数式 text)、webServer.register({kind:"prefix"})、tools/pre-execute / tools/post-execute 与客户端 settings.section 槽位;插件自持 settings.json 与三条 HTTP 路由,绕开宿主设置服务的换代风险。已在 DSH 0.1.7-rc.2(Desktop 应用)验证通过,node tests/probe.mjs 共 210 项断言全绿。安装方式:dsh plugin --profile web add @jipika/dsh-memory,或 link: 源码方式挂入并 pnpm install 后建议重启一次 host。License: MIT,零额外 LLM 调用成本,不做向量检索、不落第二份数据。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add @jipika/dsh-memory

把 jipika/dsh-memory 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-memory

Progressive long-term memory for DeepSeek Harness (DSH) — memory lives as sharded plain markdown, and only a live-generated map (shard · keywords · count · latest date) enters the system prompt, so the prompt cost stays flat however large the memory grows; entries are pulled on demand with grep + read. Two layers (global + per-project) plus the global rule files, viewable and editable right in DSH Settings, zero extra LLM cost, live re-read.

给 DeepSeek Harness 的渐进式长期记忆:正文是分片的纯 markdown,进系统提示词的只有 实时生成的片级地图(片 · 关键词 · 条数 · 最新日期),条目按任务关键词 grep 命中行号再 read 取回 —— 记忆再长、提示词开销也恒定。两层结构 (全局层 + 项目层)外加全局规则文件,在设置里就能查看并编辑、不产生任何额外 LLM 调用、写完即生效。

npm license DSH 1024Store

拥有:~/.dsh/memory/** 的读写、每轮提示词注入与索引生成;tools/pre-execute / tools/post-execute 上的记忆写入守卫与审计日志。 冲突时:与 trinity-hooks(dsh-hooks-claude-code 桥)同为 tools/pre-execute 监听者 —— 本插件只审记忆路径,两者互不翻案;与官方 compaction 无交集。 回滚:从 dsh.profile.bundles 去掉 @jipika/dsh-memory + 重启应用。


它解决什么

Agent 每次会话都是失忆的。让记忆活下来通常只有两条路:

做法 代价
把记忆塞进系统提示词 需要"谁来写、写到哪、怎么注入"的一整套机制
用 LLM 从会话里提炼事实 每轮会话都在后台烧钱,且内容进了别人的向量库

本插件的取舍是:记忆就是几个 markdown 文件,注入走 DSH 原生的提示词 seam,写入由当前会话的 agent 顺手完成 —— 于是它既不花钱,也不出本机,还能被 git 跟踪、被人手编辑。

特性

  • 两层:~/.dsh/memory/topics/*.md(全局,按主题分片:用户偏好 / 环境事实 / 通用坑……)
    • 按工作区分级的项目层,切换项目自动切换内容。
  • 零 LLM 成本:插件本身不调用任何模型,只读文件;写记忆用的是会话已经在跑的那个模型。
  • 写完即生效:注册的是函数式 text,每次提示词组装都重读文件 —— 不需要重启、不需要刷新。 (对比:cordis.patch.yml 里 personaPrefix 的 !!js 只在 boot 求值一次。)
  • 渐进式注入,记忆再长也不炸上下文:默认地图模式 —— 提示词里只有片级地图 「片名 · 条数 · 体量 · 最新日期 · 关键词」,条目标题与正文都不进提示词;agent 拿任务关键词 grep 记忆目录,命中行自带行号,再按行 read 取那一条。条目 ≤ 12 条的层(典型是项目层单文件) 仍逐条内联 —— 这类层只有几百字符,内联出来比多跑一次检索更值。
  • 注入头不放动态统计(KV cache 友好):每段的头行只写档位名(… · 地图模式。), 片数 / 条数 / 字符数一律挪到该段最后一行(<!-- 本层:N 片 / M 条 / K 字符 -->)。 因为注入段位于 system prompt 很靠前的位置,而这三个数字每写一条记忆就会变 —— 放在头行会让 整个请求前缀失去 provider 的 KV cache(实测:写一条记忆后,同款子代理委派的首轮 cacheRead 从 85% 掉回 0%)。挪到段尾后,一次写入只让"被改的那一片之后"失效 (同条件实测公共前缀 0 → 3875 字符)。片级统计行本身仍是动态的 —— 那是路由信息,刻意保留。 实测:58k 字符的单文件拆成 10 片后,每轮注入从 29931 → 约 6.6k 字符; 35 片 / 333 条 / 233k 字符的真实库:地图模式 7.3k 字符,索引模式 12.9k 字符。
  • 三档注入方式(设置 → 记忆 →「注入方式」):
    • 地图模式(默认):只给片级地图,条目靠 grep + 按行 read 按需取 —— 注入最省, 且路由线索(片名 + 关键词)一条不少:没有它,agent 不知道自己缺什么,也就不会去查。
    • 索引模式:地图 + 每片最新 N 条「标题 · 行号」,超「索引预算」(默认 12000 字符,面板可调 6K/12K/18K/24K/不限制)时沿 [8,5,3,2,1] 逐档收缩为每片最新 N 条,每片都保留线索 (关键词 + 最新日期 + 「更早的 M 条在第 X–Y 行」),而不是把整层压成一行「N 条;索引预算已满」。 旧行为在 27 片规模下会让所有分片同时失去标题 —— agent 因此没有任何理由去 read, 表现就是「插件明明在注入,却不读记忆」。
    • 全文注入:分片正文整篇进提示词,总量超过字符上限时自动回退索引模式并说明原因 (分片规模下通常都会回退)。
  • 跨片检索交给子代理,并优先用低成本的专用检索子代理:注入的纪律块写明分级 —— 1–2 条自己 read; 要同时读 ≥3 条 / 跨 ≥2 片 / 某片正文 ≥3k 字符时派检索子代理,只让它回「事实 + 文件与行号」, 原文留在子代理的上下文里。工具表里存在 subagent_memory 时优先用它 —— 那是给检索挂的专属委派工具 (固定低档思考强度、工具面白名单只留 read/grep/glob),没有该工具时退回通用 subagent。
  • 片级关键词 = 最便宜的检索线索:分片首行注释 <!-- 片名 · 关键词… --> 里 ·(或 :) 之后那段会进地图/索引,对齐 Claude Skills 用 description 决定「要不要加载」的思路。
  • 设置面板可读可写:DSH 设置里多一个「记忆」分栏 —— 每层一个开关,点标题即可展开正文, 还能就地把改动保存回文件(保存前自动留一份 .bak)。全局层按片一个页签;同一个分栏里 可以查看并编辑全局规则文件 ~/.dsh/AGENTS.md。
  • 明文、可移植:就是 markdown。可以 git、可以 diff、可以手改;删掉文件即停用(段渲染为空串, 被 renderPrompt() 过滤,零残留)。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-plugins 下一个 Next dsh-podman →