Pular para o conteúdo principal
A

dsh-memory-rings-plugin

ayaojies/dsh-memory-rings-plugin

Condensa cada conversa do DeepSeek Harness em memórias por hora, dia, mês e ano que o modelo pode pesquisar por conta própria. As rotas HTTP não verificam o acesso do DSH, então uma página aberta no navegador pode chamá-las.

Instalar

dsh plugin --profile web add github:ayaojies/dsh-memory-rings-plugin

README

记忆年轮 · Memory rings

这是一个 DeepSeek Harness 插件:把每一轮对话记录到本地 SQLite,按小时 / 天 / 月 / 年逐级压缩,再把检索能力以工具的形式交还给模型。

A DeepSeek Harness plugin that records every turn into a local SQLite store, condenses it hour → day → month → year, and hands retrieval back to the model as tools.

支持作者 · Support the author

支持作者

它能做什么 · What it does

  • 每轮落库:一轮对话结束后,用户输入、模型回答、每一步工具调用与结果写入本地数据库。
  • Every turn is stored: after a turn ends, the user input, the model answer, and each tool call/result are written to a local database.
  • 逐级压缩:小时 → 天 → 月 → 年,每级只读下一级,摘要永远不重扫原始日志。
  • Condensed over time: hour → day → month → year; each level reads only the level below, so a summary never re-reads the raw log.
  • 三个检索工具:memory_bucket_ymd 取一条年/月/日桶;memory_hour 取小时区间摘要(区间收缩到单小时时返回原文);memory_turn 按轮次号、区间或时间段取原文。
  • Three retrieval tools: memory_bucket_ymd for one year/month/day bucket, memory_hour for hourly digests (a single-hour range also returns the originals), memory_turn for turns by number, range, or time window.
  • 时间工具:memory_now 只返回一行当前时间(含星期),模型遇到相对时间时先调用它再推算查询区间。
  • Time tool: memory_now returns a single line with the current local time and weekday; the model calls it first and derives the query range from it.
  • 数据浏览页:全窗口页面,按「工作区 → 会话 → 子会话」展示,支持小时 / 天 / 月 / 年切换与时间区间选择。
  • Data browser: a full-window page grouped as workspace → session → sub-agent session, with hour/day/month/year granularity and a time range.
  • 会话级开关:对话标题栏上的「记忆 开/关」,关闭后写入继续,汇总与检索暂停。
  • Per-session switch: a "记忆 开/关" pill in the conversation header; turning it off keeps writes running while pausing rollups and retrieval.

环境要求 · Requirements

  • DeepSeek Harness 桌面版 0.2.x(Electron 44 / Node 24,运行时自带 node:sqlite)。
  • DeepSeek Harness desktop 0.2.x (Electron 44 / Node 24, which ships node:sqlite).
  • 不需要原生模块、不需要构建步骤、不发起自己的网络请求。
  • No native modules, no build step, and no network calls of its own.

安装 · Install

发布到 npm 之后,也可以直接按包名安装: After it is published to npm, you can install it by package name:

dsh plugin install dsh-memory-rings-plugin

或者从源码安装: Or install from source:

  1. 克隆本仓库。 Clone this repository.
  2. 在 DeepSeek Harness 中打开 插件 → 添加插件,选择克隆下来的目录(或在会话里用插件管理器按目录路径安装)。 In DeepSeek Harness open Plugins → Add plugin and pick the cloned directory (or install it by directory path through the plugin manager in a session).
  3. 刷新窗口。侧边栏底部会出现一个年轮图标;插件自己的设置区里也能打开数据浏览页。 Refresh the window. A ring icon appears at the sidebar foot; the same data browser also opens from the plugin's settings section.
git clone https://github.com/AyaoJies/dsh-memory-rings-plugin.git

如果 git clone 长时间卡住或提示 Connection was reset,改用 SSH 克隆:

If git clone hangs or reports Connection was reset, clone over SSH instead:

git clone git@github.com:AyaoJies/dsh-memory-rings-plugin.git

如果 22 端口也不通(部分网络会封),改走 SSH 的 443 端口:

If port 22 is blocked too, use SSH over port 443:

git clone ssh://git@ssh.github.com:443/AyaoJies/dsh-memory-rings-plugin.git

配置 · Configuration

所有配置都在插件设置区里,保存在插件自己的数据库里,改完即时生效,不需要重启。

Every option lives in the plugin's settings section, is stored in the plugin's own database, and takes effect immediately without a restart.

配置项Option默认值 Default说明 Meaning
启用对话记忆Enable conversation memory开 on总开关 Master switch
新建对话自动开启Enable for new conversations开 on新会话创建时固化的初始状态 Initial state pinned when a session is created
生成小时/天/月/年汇总Build hour/day/month/year summaries开 on关闭后仍写入,只是不再汇总 Off stops rollups; writes continue
允许模型检索记忆Let the model search memory开 on关闭后三个工具不可用 Off disables the three tools
使用大模型生成记忆摘要Use a model for memory summaries开 on关闭后不再调模型,桶仍按规则生成 Off stops model calls; rule-based buckets continue
摘要模型Summary modeldeepseek-account / deepseek-flash生成摘要所用模型 Model used to write summaries
单次摘要生成最大会话数量(0=不限)Max summaries per pass (0 = unlimited)10每次维护最多升级多少个历史桶,0 表示不限 How many historical buckets upgrade per pass; 0 means no cap
每日 token 预算Daily token budget200000超出后摘要退化为规则文本 Above it summaries fall back to rule-based text
保留天数Retention days00 表示永久保留 0 keeps everything

数据与隐私 · Data and privacy

  • 数据全部保存在本机 $DSH_HOME/storages/memory-rings/memory.db(WAL 模式)。
  • Everything is stored locally at $DSH_HOME/storages/memory-rings/memory.db (WAL mode).
  • 插件不向任何自有服务端发送数据,只在生成摘要时调用 DSH 自己的模型服务。
  • The plugin never sends data to a service of its own; it only calls DSH's model service to write summaries.
  • HTTP 接口只挂在 DSH 的本机回环 Web 服务上(/memory-rings/api),没有额外鉴权。
  • The HTTP surface is served by DSH's loopback web server only (/memory-rings/api), with no extra authentication.

已知限制 · Limitations

  • 历史回填已可用(设置区的「导入历史对话」),但回填只生成规则摘要,不消耗 token,摘要升级要等后续维护任务。
  • Historical backfill is available from the settings section ("Import history"), but it only produces rule summaries (zero tokens); upgrades happen later during maintenance.
  • 保留天数目前只是配置项,清理任务还没执行。
  • Retention days is exposed but cleanup is not enforced yet.
  • 未闭合周期(当前小时 / 当天 / 当月 / 当年)生成的是规则拼接的 partial 桶,周期闭合后才会升级为模型摘要。
  • Open periods (current hour/day/month/year) produce rule-based partial buckets and are upgraded to model summaries once the period closes.
  • 会话级开关目前位于对话标题栏右侧工具区,不在 ··· 菜单里。
  • The per-session switch sits in the conversation header utilities, not in the ··· menu.
  • 摘要依赖配置的模型可用;不可用时退化为规则文本,设置区会显示提示。
  • Summaries need the configured model; otherwise they fall back to rule-based text and the settings section shows a warning.

目录结构 · Repository layout

index.js            Host 半:SQLite 存储、事件摄取、汇总引擎、三个工具、HTTP 接口 / Host half: SQLite store, event ingestion, rollup engine, three tools, HTTP API
client.js           Client 半:设置区、数据浏览页、会话开关、侧栏入口 / Client half: settings section, data browser, session toggle, sidebar entry
cordis.patch.yml    插入插件行的 bundle patch / Bundle patch that inserts the plugin row
locale/{en,zh}.json 插件标题与描述 / Display title and description
icon.svg            插件图标 / Plugin icon
docs/DETAIL.md      插件详情页内容 / Plugin detail page content
docs/DESIGN.md      完整需求与设计文档(中文)/ Full requirements and design notes (Chinese)

许可证 · License

MIT,见 LICENSE。

MIT — see LICENSE.

Plugins relacionados