dsh-memento 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.zh.md CHANGED
@@ -1,214 +1,217 @@
1
+ <div align="center">
2
+
1
3
  # dsh-memento
2
4
 
3
5
  **给 DeepSeek Harness 补上有界、分层、带审批门、可审计的跨会话记忆。**
4
6
 
5
- [![license](https://img.shields.io/badge/license-Apache--2.0-3a7d44)](LICENSE)
6
- [![dsh](https://img.shields.io/badge/dsh-0.1.0--rc.6-4e51e8)](https://www.npmjs.com/package/@deepseek-ai/dsh)
7
- [![node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-339933)](https://nodejs.org/)
8
- [![platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey)]()
9
- [![no build step](https://img.shields.io/badge/build-none%20%28pure%20ESM%29-8a6d3b)]()
7
+ *一个类型安全的 `ctx.memory` 接缝、模型绕不过去的写入审批门,以及能从会话日志重建的审计链。*
8
+
9
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
10
+ [![DSH plugin](https://img.shields.io/badge/dsh-plugin-✅-green)](https://github.com/topics/dsh-plugin)
11
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](#)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/PerryLink/dsh-memento/ci.yml?branch=main&label=CI)](https://github.com/PerryLink/dsh-memento/actions)
13
+ [![Version](https://img.shields.io/github/v/tag/PerryLink/dsh-memento?label=version)](https://github.com/PerryLink/dsh-memento/releases)
10
14
  [![npm version](https://img.shields.io/npm/v/dsh-memento)](https://www.npmjs.com/package/dsh-memento)
11
15
  [![npm downloads](https://img.shields.io/npm/dm/dsh-memento)](https://www.npmjs.com/package/dsh-memento)
12
- [![CI](https://github.com/PerryLink/dsh-memento/actions/workflows/ci.yml/badge.svg)](https://github.com/PerryLink/dsh-memento/actions/workflows/ci.yml)
13
16
 
14
- [English](README.md) · [中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
17
+ [English](README.md) · [简体中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
15
18
 
16
- > 别的记忆插件卖**仓库**,dsh-memento 卖**接缝**:类型安全的 `ctx.memory` 服务、模型绕不过去的写入审批门、能从会话日志重建的审计链。DeepSeek Harness 的原生第一方记忆——记忆协议 + 信任门 + 审计,零网络、零凭据。
19
+ </div>
17
20
 
18
- ## ✨ 为什么是 dsh-memento?
21
+ ---
19
22
 
20
- - **它是能力接缝,不是又一个 store。** Service Definition(`ctx.memory`)+ 本地 SQLite Provider(`node:sqlite`,WAL,`0600`)+ Consumer(`memory` 工具 + 冻结快照注入)。任何未来的插件——dsh-claude-move 的 seed 集成、桥接、面板——都通过**同一个门**读写**同一份** store。
21
- - **审批门不可绕过。** 每条写路径(`add`/`replace`/`remove`/`seed`)都被强制经过审批 waterfall,且强制点在**服务内部**而非工具层。`writePolicy: ask | auto | off` 是模型看不见、改不了的配置;会话级 `never` 姿态依旧先于一切。`replace`/`remove`/`consolidate` 的审批载荷携带将被改动的条目全文——批准什么就看到什么;被拒的写同样落 `*-denied` 审计行。
22
- - **模型可见 ⟺ 落盘。** 注入的快照逐字进入 `request/header.system`;每次写都能从 `approval/asked`(完整载荷)+ `approval/decided`(结果)+ 插件自有审计表重建。
23
- - **有界且诚实。** 每轨每层硬字符预算(默认 user 2000 / agent 4000)。写满**返回结构化错误**(用量 + 上限)——模型整合后重试。绝不截断、绝不自动压缩。
23
+ ## Compatibility
24
24
 
25
- ## ⚡ 30 秒上手
25
+ | Surface | Status |
26
+ |---|---|
27
+ | Harness | DeepSeek Harness `0.1.0-rc.6` |
28
+ | Node | `^22.19.0 || >=24.0.0` |
29
+ | Platforms | Windows / macOS / Linux(纯 host;无原生代码、无网络) |
30
+ | Model | 任意 |
26
31
 
27
- ```sh
28
- # 要求 Node ^22.19 || >=24、DSH 0.1.0-rc.6
29
- dsh plugin --profile web add dsh-memento # 或 ./dsh-memento / tarball / GitHub 地址
30
- dsh --profile web --dump-config # 应看到 "# == dsh-memento" 层,启动无 FAILED
31
- ```
32
+ ## What you get
32
33
 
33
- 然后在 Web UI 里:让模型记住一件事 → 批准这次写入 → 开一个**新会话**问它记得什么。演示到此结束。
34
+ `dsh-memento` 是能力接缝,不是又一个仓库:一个类型安全的 `ctx.memory` 服务、一个本地 SQLite 提供方(`node:sqlite`,WAL,`0600`,位于 `$DSH_HOME/dsh-memento/memory.db`),以及它的消费方——`memory` 工具与注入系统提示的冻结快照。
34
35
 
35
- ```yaml
36
- # 可选覆盖(写在 profile 的 cordis.patch.yml)
37
- - id: memento
38
- config:
39
- writePolicy: ask # ask(默认)| auto | off —— 模型不可见
40
- budgets:
41
- user: { userGlobal: 4000, workspace: 2000 } # 中文记忆多:调大并在 PR 说明理由
42
- agent: { userGlobal: 4000, workspace: 4000 }
43
- ```
36
+ - **审批门不可绕过。** 每条写路径(`add` / `replace` / `remove` / `seed`)都被强制经过服务内部的审批 waterfall,而非工具层。`writePolicy: ask | auto | off` 是模型看不见的配置;`replace` / `remove` / `consolidate` 的审批载荷携带将被改动条目的全文,被拒的写同样落一条 `*-denied` 审计行。
37
+ - **模型可见 ⟺ 已记录。** 注入的快照逐字进入 `request/header.system`;每次写都能从 `approval/asked` + `approval/decided` + 插件自有审计表重建。
38
+ - **有界且诚实。** 每轨每层硬字符预算(默认 user 2000 / agent 4000)。写满返回结构化错误(用量 + 上限)——绝不截断、绝不自动压缩。
44
39
 
45
- ## 🧠 它提供什么
40
+ 两条轨道 × 两个层级 × 按 agent 隔离:`user` 轨(关于用户的事实)与 `agent` 轨(环境事实与约定),各自再分为 `user-global` 与 `workspace` 层,并按 `agentPreset` 隔离。快照在会话首次组装提示时冻结一次,会话中途不再变化。
46
41
 
47
- | | 组件 | 你得到什么 |
48
- | --- | --- | --- |
49
- | 🧩 Service Definition | `ctx.memory` —— `add` / `replace` / `remove` / `query` / `seed` / `budgets()` | 类型化、声明合并的服务;写方法内部强制过门 |
50
- | 🧬 适配器注册表 | `ctx.memoryAdapters` —— `register` / `list` / `adapt` / `export` | 第三方记忆插件把自己的 store 接进协议;内置 mem0、Hermes `memory.md`、`CLAUDE.md` 参考适配器 |
51
- | 💾 Provider | `lib/store.mjs` —— `node:sqlite` 单文件(`$DSH_HOME/dsh-memento/memory.db`,WAL) | 零依赖、零网络;条目表 + 审计表;唯一子串匹配 |
52
- | 🛠 Consumers | `memory` 工具 · 冻结快照注入(systemPrompt 段,顺序 `-50`)· `memory_recall` 工具 · `/memory` 命令 · 只读 Web 面板 | 模型读写、带用量头的冻结快照、两段式召回、用户侧命令、浏览器抽屉 |
42
+ ## Quick start
53
43
 
54
- **双轨 × 双层 × per-agent 键。** `user` 轨 = 用户画像(偏好、沟通风格、雷区);`agent` 轨 = 环境事实、项目约定、教训。每轨分 `user-global`(跨工作区)与 `workspace`(按会话 cwd)两层——学 Codex 的合并分层,不学 Hermes 的纯全局。第三维按会话 `agentPreset` 隔离条目(per-agent 作用域);无 preset 的条目留在人人可见的共享层。会话内读与写定位遵循同一可见集:会话只能看到(`replace`/`remove` 也只能改到)共享条目 + 本 agent 条目,`workspace` 条目仅限本会话 cwd;管理面(`/memory`、面板)保持跨 agent 全量视图。
44
+ ```sh
45
+ # 1. install the bundle into your profile
46
+ dsh plugin --profile web add "github:PerryLink/dsh-memento#main"
55
47
 
56
- **冻结快照。** 快照在会话首个 prompt 组装时渲染一次(SQLite 同步读 + 按会话缓存),会话内不再变化——前缀缓存天然稳定。会话内变更只落盘 + 落审计。
48
+ # or from npm (published releases)
49
+ dsh plugin --profile web add dsh-memento
57
50
 
58
- ```
59
- Consumer: memory 工具 Consumer: 冻结快照(systemPrompt 段,顺序 -50)
60
- add/replace/remove/query 按会话冻结,带用量头
61
- │ 写(agent+callId) │ 读(同步,session cwd)
62
- ▼ ▼
63
- Service Definition: ctx.memory —— budgets/add/replace/remove/query/seed
64
- 每次写:预算预检 → ctx.approval.request(审批 waterfall)→ 预算复审 → 落盘 → 审计
65
- │
66
- ▼
67
- Provider: lib/store.mjs —— node:sqlite(WAL,0600),条目表+审计表,唯一子串匹配
51
+ # 2. restart and verify the row
52
+ dsh --profile web --dump-config | grep -A3 'id: memento'
68
53
  ```
69
54
 
70
- ## 🧰 安装与卸载
55
+ ## Install & uninstall
56
+
57
+ - **git channel**(最新 `main`):`dsh plugin --profile web add git+https://github.com/PerryLink/dsh-memento.git`。
58
+ - **npm channel**(发布版本):`dsh plugin --profile web add dsh-memento`。
59
+ - **tarball channel**:在本仓库执行 `npm pack`,然后 `dsh plugin --profile web add ./dsh-memento-<version>.tgz`。
60
+ - **uninstall**:`dsh plugin --profile web remove dsh-memento`(记忆库与会话日志保留)。
71
61
 
72
- ```sh
73
- dsh plugin --profile <name> add ./dsh-memento # 本地 checkout(无构建步骤)
74
- dsh plugin --profile <name> add dsh-memento # npm 包(0.2.0 起已发布)
75
- dsh plugin --profile <name> add git+https://github.com/PerryLink/dsh-memento.git # GitHub 安装
76
- dsh plugin --profile <name> remove dsh-memento # 卸载:库与会话日志保留
77
- ```
62
+ ## Configuration
78
63
 
79
- 卸载后记忆库与记录过记忆活动的会话日志保留,旧会话仍可正常加载。
64
+ 所有可调项均为 Schemastery `Config` 字段(可在 cordis.yml 中修改)。非法值在加载期响亮失败。在 `memento` 行下覆盖。
65
+
66
+ | Key | Default | Meaning |
67
+ |---|---|---|
68
+ | `enabled` | `true` | 总开关;`false` 移除服务、工具、快照、命令、面板与 answerer |
69
+ | `dbPath` | `''` → `$DSH_HOME/dsh-memento/memory.db` | 绝对路径,或相对 `$DSH_HOME`(Windows 上回退到 `~/.dsh`) |
70
+ | `budgets.user.userGlobal` | `2000` | user 轨 user-global 层的硬字符预算 |
71
+ | `budgets.user.workspace` | `2000` | user 轨 workspace 层的硬字符预算 |
72
+ | `budgets.agent.userGlobal` | `4000` | agent 轨 user-global 层的硬字符预算 |
73
+ | `budgets.agent.workspace` | `4000` | agent 轨 workspace 层的硬字符预算 |
74
+ | `writePolicy` | `'ask'` | 默认写策略:`ask` / `auto` / `off`(模型不可见) |
75
+ | `writePolicies` | `{}` | 按轨/作用域或按来源的覆盖(如 `user/workspace`、`source:claude`) |
76
+ | `language` | `'en'` | 模型可见文本与命令输出语言:`en` / `zh` |
77
+ | `snapshotOrder` | `-50` | 快照段顺序(在 harness 身份之后、persona 之前) |
78
+ | `maxEntriesPerQuery` | `20` | 每次查询默认结果上限(硬上限 1000) |
79
+ | `commandListLimit` | `50` | 每次 `/memory list` / `query` 渲染的条目数 |
80
+ | `commandAuditLimit` | `10` | 每次 `/memory audit` 渲染的审计行数 |
81
+ | `recall.historyLimitDefault` | `8` | `memory_recall` 默认扫描的会话数 |
82
+ | `recall.snippetCap` | `5` | `memory_recall` 每个会话的片段数 |
83
+ | `recall.snippetChars` | `300` | `memory_recall` 片段字符数 |
84
+ | `recall.windowDays` | `30` | `memory_recall` 近期窗口天数 |
85
+ | `panelEntriesLimit` | `200` | Web 面板条目分页大小 |
86
+ | `panelAuditLimit` | `20` | Web 面板默认审计行数 |
87
+ | `auditRetentionDays` | `0` | 审计保留天数(0 = 永久保留) |
88
+ | `proposals.enabled` | `true` | 每次成功压缩后自动捕获一条记忆提案 |
89
+ | `proposals.maxChars` | `2000` | 提案字符上限 |
90
+ | `proposals.maxPending` | `8` | 待处理提案上限 |
80
91
 
81
- ## ⚙️ 配置
92
+ ## Tools & surfaces
82
93
 
83
- 所有字段都是经过校验的 Schemastery `Config`;非法值加载期响亮失败。在 cordis.yml 的 `memento` 行覆盖。
94
+ | Surface | Kind | Notes |
95
+ |---|---|---|
96
+ | `memory` | tool | 带 Save/Skip 指引的 add/replace/remove/consolidate/query;写入走审批门 |
97
+ | `memory_recall` | tool | 有界的记忆匹配 + 近期会话历史匹配 |
98
+ | `/memory` | command | `list` · `query` · `add` · `remove` · `consolidate` · `proposals` · `budgets` · `audit` · `export` · `import <path>` · `adapters` |
99
+ | web panel | client drawer | 只读:浏览条目、搜索、预算条、审计尾部 |
84
100
 
85
- | 字段 | 默认 | 含义 |
86
- | --- | --- | --- |
87
- | `enabled` | `true` | `false` 时服务/工具/快照/命令/面板/answerer 整体消失(不留半残状态) |
88
- | `dbPath` | `''` → `$DSH_HOME/dsh-memento/memory.db` | 绝对路径,或相对 `$DSH_HOME`;`$DSH_HOME` 未导出时(Windows 默认——`dsh web` 不会把解析出的主目录写回环境变量)两者都回退 `~/.dsh` |
89
- | `budgets.user.userGlobal` / `budgets.user.workspace` | `2000` / `2000` | user 轨每层硬字符预算 |
90
- | `budgets.agent.userGlobal` / `budgets.agent.workspace` | `4000` / `4000` | agent 轨每层硬字符预算 |
91
- | `writePolicy` | `'ask'` | `'ask'`=用户审批;`'auto'`=放行但记录审批来源;`'off'`=拒绝。模型不可见 |
92
- | `writePolicies` | `{}` | 按 track/scope 或来源覆盖:键 `user/workspace`、`agent/user-global`、`source:claude` 等 → `ask`/`auto`/`off`;未命中回退 `writePolicy` |
93
- | `language` | `'en'` | 模型可见文案与命令输出语言:`'en'`(默认)或 `'zh'`——工具描述、冻结快照、`/memory` 命令、Web 面板全部跟随 |
94
- | `snapshotOrder` | `-50` | 快照段注入顺序:harness identity(`-100`) 之后、persona(`0`) 之前 |
95
- | `maxEntriesPerQuery` | `20` | query 默认返回上限(显式 `limit` 可超出,硬钳 1000) |
96
- | `commandListLimit` | `50` | `/memory list`/`query` 命令单次渲染条目上限 |
97
- | `commandAuditLimit` | `10` | `/memory audit` 命令单次渲染审计行上限 |
98
- | `recall.historyLimitDefault` / `recall.snippetCap` / `recall.snippetChars` / `recall.windowDays` | `8` / `5` / `300` / `30` | `memory_recall` 历史段默认值:扫描会话数 / 每会话片段数 / 片段字符数 / 回溯天数 |
99
- | `panelEntriesLimit` | `200` | Web 面板条目页大小(兼钳制上限) |
100
- | `panelAuditLimit` | `20` | Web 面板审计默认条数(天花板 200) |
101
- | `auditRetentionDays` | `0` | 审计保留天数:0 = 永久,>0 = 打开库时裁剪更早的审计行 |
102
- | `proposals.enabled` / `proposals.maxChars` / `proposals.maxPending` | `true` / `2000` / `8` | auto-capture:每次压缩成功后生成待审批记忆提案(截断、每会话一条);可关闭或调上限 |
101
+ ## How it's different
103
102
 
104
- ## 🛠 工具与观察面
103
+ | Plugin | 是什么 | dsh-memento 的差异 |
104
+ |---|---|---|
105
+ | dsh-memory-evolve | 记忆仓库 / 进化循环 | 类型化服务接缝、审批门与会话日志审计;无仓库野心 |
106
+ | dsh-mnemon | 记忆存储助手 | 协议 + 门 + 审计,而非又一个 store |
107
+ | dsh-kb-sieve | 知识库筛选 | 无检索工程:小语料子串搜索,经 `session_search`/`sessionQuery` 跨会话召回 |
108
+ | dsh-tdai-memory | 任务驱动记忆工具 | 预算按 track×layer 且在服务内强制执行,而非尽力而为 |
109
+ | claude-bridge | Claude Code 桥接 | DSH 原生;未来的 `seed(source:'claude')` 路径让桥接写入同一 store |
110
+ | dsh-external/Recall | 外部 agent 记忆 | 本地优先、零网络、走 DSH 自有审批接缝 |
111
+ | Official MCP memory examples | DSH 宣称的"memory = 外部 MCP"立场 | **原生第一方**补充:同目标、无外部服务器;两者共存 |
105
112
 
106
- - **`memory`** —— add/replace/remove/consolidate/query,工具描述内嵌 Save/Skip 行为指引(存用户偏好、纠正、环境事实、项目约定、教训;跳过琐碎事实、可再查的百科知识、大数据转储、一次性路径)。写走审批门,读免费;replace/remove 用**唯一子串**定位(歧义时报候选清单);consolidate 一次审批 + 一次原子写把 1..20 条整合为一条。条目携带协议 v1 字段:短 `tags`(≤16 个 × ≤32 字符)与每次 replace 自增的条目 `version`。
107
- - **`memory_recall`** —— 两段式召回:有界记忆匹配 **+** 经 `ctx.sessionQuery` 的近期会话历史匹配(服务缺失时优雅降级为纯记忆结果)。
108
- - **`/memory`** —— 用户触发命令(非模型回合):`list` · `query <词>` · `add [--track=user|agent] [--scope=user-global|workspace] <文本>` · `remove [选项] <子串>` · `consolidate [选项] <子串...> => <新文本>` · `proposals [approve|dismiss <id>]` · `budgets` · `audit` · `export [--adapter=<id>]` · `import <路径> [--adapter=<id>]` · `adapters`。命令写走同一 waterfall 与策略;审计落插件审计表 + `command/done`。`export` 只读,把所有条目 + 预算导出为一份 JSON 文档;`import` 把它恢复回来(文件路径或内联 JSON,单次审批、预算预检)——备份/迁移完整闭环。适配器动词转换外部记忆格式:`import --adapter=mem0 <facts.json>` 把事实喂进带审批门的 `seed`;`export --adapter=<id>` 只读转换输出到 stdout。导入条目获得新 id 与新时间戳;提案、审计行与召回计数不迁移。
109
- - **Auto-capture 提案** —— 会话压缩成功后,摘要落为待审批记忆提案(`agent/workspace`);approve 经审批门写入记忆,dismiss 丢弃。待审批提案出现在冻结快照与面板中。
110
- - **Web 面板** —— 零构建 `dsh.client` 抽屉:按轨/层浏览条目、搜索、预算用量条、审计尾。设计上只读:写与审批走 `memory` 工具与内置审批 UI。
113
+ 名称是 **`dsh-memento`**(已发布到 npm 与 GitHub)。不是 `dsh-recall`(易与 dsh-external/Recall 混淆),也不是已删除的旧名 `dsh-memory`。
111
114
 
112
- ## 🎓 向终端记忆们学到的优点
115
+ ## dsh-memory-protocol v1
113
116
 
114
- dsh-memento 不是 Claude Code、Codex 或 Hermes 的移植版——但它的设计刻意吸收了这三家各自做对的部分,也刻意拒绝了它们吃过的亏:
117
+ `dsh-memento` 是 DSH 记忆协议的社区预演——官方 `ctx.memory` 接缝的一个候选形态。该协议把本插件的接缝规范化为跨插件契约:
115
118
 
116
- | 终端记忆 | 做对了什么 | dsh-memento 吸收了 |
117
- | --- | --- | --- |
118
- | **Claude Code** —— `CLAUDE.md` | 分层**纯文本记忆文件**(用户级 → 项目级),人可读、人可改,每个会话自动合并——你能自己读、自己修的记忆 | 纯文本条目;每会话合并 `user-global` / `workspace` 层;可浏览、可 `export`、可审计的库——透明即特性 |
119
- | **Codex** —— `AGENTS.md` | **按目录作用域的指令**自动发现、零摩擦注入——就近比堆量更重要,加载记忆无需任何工具调用 | `workspace` 层按会话 cwd 隔离(Windows 大小写不敏感);冻结快照会话启动时自动注入 |
120
- | **Hermes** —— `memory.md` | **主动记忆保存**(存/改/删),以及 [issue #48181](https://github.com/NousResearch/hermes-agent/issues/48181) 的安全教训:只做在工具层的门会被迟到的工具注入绕过——应把门做在所有写路径的交汇处 | 内嵌 Save/Skip 指引的 `memory` 工具 + 走审批门的 auto-capture 提案;审批门做在 **`ctx.memory` 写方法内部**,不在工具层 |
119
+ - **Entry spec** — 两条轨道 × 两个层级 × 按 agent 隔离,外加短 `tags`(≤16 × ≤32 字符)与每次 `replace` 递增的每条目 `version`。
120
+ - **Write semantics** — 幂等的唯一子串条件写;批准即所见载荷(`replace` / `remove` / `consolidate` 携带将被改动的全文)。
121
+ - **Audit contract** — 每次写都能从 `approval/asked` + `approval/decided` + 提供方账本重建。
122
+ - **Budget model** — `BUDGET_EXCEEDED` / `AMBIGUOUS_MATCH` 语义。
123
+ - **Schema versioning** — 带响亮版本检查的迁移规则。
121
124
 
122
- 出处:[Claude Code 记忆](https://code.claude.com/docs/en/memory) · [Codex AGENTS.md](https://developers.openai.com/codex/cli/agents-md) · [Hermes 记忆](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/memory.md) · [Hermes #48181](https://github.com/NousResearch/hermes-agent/issues/48181)。
125
+ - **Spec** — [docs/protocol-v1.md](docs/protocol-v1.md)(中文: [protocol-v1.zh.md](docs/protocol-v1.zh.md));规范性 JSON Schema 见 [docs/schemas/dsh-memory-protocol-v1.schema.json](docs/schemas/dsh-memory-protocol-v1.schema.json)。
123
126
 
124
- 刻意拒绝的部分:把自动摘要写进模型私有状态的隐藏记忆(本插件把压缩摘要变成**待审批提案**,等人 approve/dismiss)、仓库/向量库野心、以及任何缺少人可见审批或审计痕迹的写入。同时采纳 Hermes 文档的警告:两个进程共用一个 home 目录会写同一份记忆文件——见安全边界。
127
+ **Adapter registry** — `ctx.memoryAdapters`(`register` / `list` / `adapt` / `export`)让第三方记忆插件通过注册纯数据转换器接入协议(可逆 `register()`;导入走审批门 `seed`,导出只读)。接入指南:[docs/adapters-guide.md](docs/adapters-guide.md)(中文: [adapters-guide.zh.md](docs/adapters-guide.zh.md))。
125
128
 
126
- ## 🆚 与其它记忆插件的差异
129
+ | Built-in adapter | External format | Notes |
130
+ |---|---|---|
131
+ | `mem0` | mem0 fact collections(`{facts: [{memory, metadata?}]}`) | `metadata.category` / `metadata.tags` 成为 tags;原始 `messages` 数组被拒绝——适配器只转换、绝不抽取 |
132
+ | `hermes-memory-md` | Hermes `memory.md`(`## section` + 列表项) | 章节名成为 tags;非列表散文响亮失败 |
133
+ | `claude-code-memory-md` | `CLAUDE.md` 风格 markdown(标题、列表、段落) | 列表项与段落成为条目;章节名成为 tags |
127
134
 
128
- | 插件 | 是什么 | dsh-memento 的差异 |
129
- | --- | --- | --- |
130
- | dsh-memory-evolve | 记忆仓库 / 演化循环 | 类型化服务接缝、审批门、会话日志审计;不碰仓库野心 |
131
- | dsh-mnemon | 记忆存储助手 | 协议 + 门 + 审计,不是又一个 store |
132
- | dsh-kb-sieve | 知识库筛选 | 不重造检索:小语料子串检索,跨会话回忆用 `session_search`/`sessionQuery` |
133
- | dsh-tdai-memory | 任务驱动记忆工具 | 预算是每轨×每层硬约束且在服务层执行,不是尽力而为 |
134
- | claude-bridge | Claude Code 桥接 | DSH 原生;未来的 `seed(source:'claude')` 让桥接插件喂同一个 store |
135
- | dsh-external/Recall | 外部 agent 记忆 | 本地优先、零网络,走 DSH 自己的审批 seam |
136
- | 官方 MCP 记忆示例 | 官方"记忆 = 外接 MCP"立场 | **原生第一方**补充:目标一致、无需外部服务,两者可共存 |
135
+ **Conformance suite** — [test/protocol-conformance/](test/protocol-conformance/README.md):可分发用例集,任何声明兼容的提供方都能跑(`node test/protocol-conformance/run.mjs --provider ./your-factory.mjs`);本仓库 CI 以自有提供方为黄金参考运行它(`npm run test:conformance`)。
137
136
 
138
- 命名已定 **`dsh-memento`**(npm 与 GitHub 均已发布)。不用 `dsh-recall`(与 dsh-external/Recall 混淆),不用已删除的旧名 `dsh-memory`。
137
+ - **Upstream proposal** — [docs/upstream-proposal.md](docs/upstream-proposal.md)(中文: [upstream-proposal.zh.md](docs/upstream-proposal.zh.md)):为何官方 `ctx.memory` 接缝应采纳该协议、差异与迁移路径。
139
138
 
140
- ## 🧬 dsh-memory-protocol v1
139
+ ## Permissions & data
141
140
 
142
- dsh-memento 是 **DSH 记忆协议**的社区预演——官方 `ctx.memory` seam 的候选形态。协议把本插件接缝规范化为跨插件契约:条目规范(双轨 × 双层 × per-agent 键 + `tags` + 条目级 `version`)、写操作语义(唯一子串条件写的幂等性、approve-what-you-see 载荷)、审计契约(任何写入可由 `approval/asked` + `approval/decided` + Provider 账本重建)、预算模型(`BUDGET_EXCEEDED` / `AMBIGUOUS_MATCH` 语义)与 schema 版本/迁移规则。
141
+ - **Permissions**:workshop 清单声明 `harness:tool`、`filesystem:read`、`filesystem:write`,以及 `network:none` / `subprocess:none` / `shell:none` / `python:none` / `credentials:none`。写审批走官方审批接缝。
142
+ - **Data**:本地 SQLite 数据库(`0600`),零网络、零凭据。
143
+ - **Session log**:审计完整性来自审批对(`approval/asked` + `approval/decided`)加插件自有审计表。
143
144
 
144
- - **规范** —— [docs/protocol-v1.zh.md](docs/protocol-v1.zh.md)(英文: [protocol-v1.md](docs/protocol-v1.md));规范性 JSON Schema 在 [docs/schemas/dsh-memory-protocol-v1.schema.json](docs/schemas/dsh-memory-protocol-v1.schema.json)。
145
- - **适配器注册表** —— `ctx.memoryAdapters` 让第三方记忆插件通过注册纯数据转换器说协议(`register()` 可逆;导入走带审批门的 `seed`,导出只读)。接入指南:[docs/adapters-guide.zh.md](docs/adapters-guide.zh.md)(英文: [adapters-guide.md](docs/adapters-guide.md))。
145
+ ## Security boundaries
146
146
 
147
- | 内置适配器 | 外部格式 | 说明 |
148
- | --- | --- | --- |
149
- | `mem0` | mem0 事实集合(`{facts: [{memory, metadata?}]}`) | `metadata.category`/`metadata.tags` 变成标签;原始 `messages` 数组被拒——适配器只转换、绝不抽取 |
150
- | `hermes-memory-md` | Hermes `memory.md`(`## 小节` + 项目符号) | 小节名变标签;非项目符号散文响亮失败 |
151
- | `claude-code-memory-md` | `CLAUDE.md` 风格 markdown(标题、项目符号、段落) | 项目符号与段落各成条目;小节名变标签 |
147
+ - **仅公开服务。** 只消费 `tools`、`systemPrompt` 与审批接缝;不改 engine / agent-loop / apiproxy / 官方 UI。
148
+ - **零网络、零凭据。** 本地数据库,POSIX 文件权限 `0600`。
149
+ - **失败要大声。** 库损坏、schema 过新或非法配置在加载期抛错;写满与子串歧义返回结构化错误。
150
+ - **一进程一库。** 多个会话共享 SQLite 库;共享同一 `$DSH_HOME` 的两个进程写同一文件(SQLite 锁下后写覆盖)。
152
151
 
153
- - **一致性套件** —— [test/protocol-conformance/](test/protocol-conformance/README.md):可对外分发的用例集,任何声称兼容的 Provider 都跑(`node test/protocol-conformance/run.mjs --provider ./你的工厂.mjs`);本仓库 CI 以黄金参考全绿(`npm run test:conformance`)。
154
- - **上游化提案** —— [docs/upstream-proposal.zh.md](docs/upstream-proposal.zh.md)(英文: [upstream-proposal.md](docs/upstream-proposal.md)):官方 `ctx.memory` seam 为何应采纳本协议、差异与迁移路径。
152
+ ## Known limitations
155
153
 
156
- ## 🔒 安全边界
154
+ - **会话事件已声明、尚未发出(rc.6)。** `memory/added|updated|removed|recalled|snapshot` 已合并声明,但 rc.6 没有仓库外事件类型的注册面;一旦 harness 构建收录这些类型即自动开启发出。
155
+ - **`ask` 策略需要 answerer。** 未组合 UI/ACP answerer 时,写入失败关闭。
156
+ - **无 FTS5 索引。** 子串搜索走大小写不敏感的 `instr`(对 CJK 正确)。
157
157
 
158
- - **只消费公开服务**(`tools`、`systemPrompt`、审批 seam)。不修改引擎 / agent-loop / apiproxy / 官方 UI 包。
159
- - **零网络、零凭据。** 库在本地,POSIX 文件权限 `0600`。
160
- - **失败大声。** 库损坏/版本过新加载期报错;写满与子串歧义报结构化错误。绝不静默吞、绝不静默截断。
161
- - **单进程共库。** 单进程多会话共享 SQLite(串行写、每会话审计独立)。两个**进程**共用一个 `$DSH_HOME` 会写同一个库文件:SQLite 锁下"谁后写谁赢"——不要对同一 `$DSH_HOME` 跑两个 harness 实例(与 Hermes 项目文档的官方警告一致)。
158
+ ## What we learned from the terminal memories
162
159
 
163
- ## ⚠️ 已知局限
160
+ `dsh-memento` 不是 Claude Code、Codex 或 Hermes 的移植——但其设计刻意吸收了它们各自做对的部分,并拒绝有害的部分:
164
161
 
165
- - **会话事件词汇已声明、rc.6 上暂不派发。** `memory/added|updated|removed|recalled|snapshot` 已在 `types.d.ts` 声明合并,但 rc.6 没有仓外插件事件类型的注册面(append 未注册类型会让持久化会话无法加载)。审计完整性由审批审计对 + 审计表承担;harness 收录这些类型后自动开启派发。见 [ARCHITECTURE.md](ARCHITECTURE.md) 决策 4。
166
- - **`ask` 策略需要 answerer。** 没有 UI/ACP answerer 组合时写失败封闭(`unavailable`)——这是审批 seam 的失败封闭姿态,属设计行为。
167
- - **不使用 FTS5 索引。** 子串检索走大小写不敏感 `instr`(对 CJK 正确);召回排序用逐条目命中计数。FTS5 的 trigram 分词器无法索引单字 CJK 字符,故不采用——见 [ARCHITECTURE.md](ARCHITECTURE.md) 决策 10。
162
+ | Terminal memory | 做对了什么 | dsh-memento 采纳了什么 |
163
+ |---|---|---|
164
+ | **Claude Code** — `CLAUDE.md` | 分层纯文本记忆文件(用户级 → 项目级),人类可读、可编辑,自动合并进每个会话 | 纯文本条目;`user-global` / `workspace` 层按会话合并;可浏览、`export`、审计的 store——透明即特性 |
165
+ | **Codex** — `AGENTS.md` | 按目录作用域自动发现并注入的指令,零模型摩擦 | 按会话 cwd 隔离的 `workspace` 层(Windows 大小写不敏感);会话开始时自动注入冻结快照 |
166
+ | **Hermes** — `memory.md` | 主动记忆保存,以及"只在工具层强制门可被后期工具注入绕过"的安全教训 | 带 Save/Skip 指引的 `memory` 工具 + 审批门控的自动捕获提案;门位于 `ctx.memory` 写方法内部,而非工具层 |
168
167
 
169
- ## 🧪 开发
168
+ 来源:[Claude Code memory](https://code.claude.com/docs/en/memory) · [Codex AGENTS.md](https://developers.openai.com/codex/cli/agents-md) · [Hermes memory](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/memory.md) · [Hermes #48181](https://github.com/NousResearch/hermes-agent/issues/48181)。
170
169
 
171
- ```sh
172
- npm install
173
- npm test # node --test:133 个测试——预算、唯一子串、审批策略、store、快照、mock ctx 集成(S2/S3 不变量)、V2 命令/召回/面板/导入、协议适配器与一致性
174
- npm run test:conformance # dsh-memory-protocol v1 一致性套件(黄金参考;第三方 Provider 用 --provider)
175
- npm run typecheck # tsc --checkJs 类型检查门(index.mjs / lib / scripts)
176
- npm run check:coverage # 行覆盖率门:lib ≥90%、index.mjs ≥85%、全部 ≥90%
177
- npm run check:readmes # 五语 README 一致性门
178
- ```
170
+ 刻意拒绝的部分:隐藏地自动摘要进模型私有状态(此处压缩摘要成为等待人类 approve/dismiss 的**待处理提案**)、仓库/向量库野心,以及任何缺少人类可见审批或审计链的写入。也采纳了:Hermes 记载的"两个进程共享一个主目录写同一记忆文件"的告诫——见 Security boundaries。
179
171
 
180
- `lib/` 零 DSH 依赖(仅 node: 内置模块);DSH 依赖只出现在 `index.mjs`。完整纪律见 [AGENTS.md](AGENTS.md);设计决策见 [ARCHITECTURE.md](ARCHITECTURE.md)。
172
+ ## Development
181
173
 
182
- ## 🏷 话题
174
+ ```sh
175
+ npm install # node ^22.19 || >=24
176
+ npm test # node --test: 133 tests
177
+ npm run test:conformance # dsh-memory-protocol v1 conformance suite
178
+ npm run typecheck # tsc --checkJs gate
179
+ npm run check:coverage # line-coverage gate
180
+ npm run check:readmes # five-language README consistency gate
181
+ ```
183
182
 
184
- 建议的 GitHub topics:`dsh` · `dsh-plugin` · `deepseek-harness` · `memory` · `agent-memory` · `approval` · `audit` · `sqlite` · `cordis` · `llm`
183
+ `lib/` 零 DSH 依赖(仅 node: 内置模块);DSH 导入只出现在 `index.mjs`。
185
184
 
186
- ## 👥 贡献者
185
+ ## Topics
187
186
 
188
- 特别感谢 [@Niuniu-Sir](https://github.com/Niuniu-Sir) 的 issue [#1](https://github.com/PerryLink/dsh-memento/issues/1)——这份详尽的启动崩溃报告促成了 0.3.1 中 `~/.dsh` 回退的落地。
187
+ `dsh`, `dsh-plugin`, `deepseek-harness`, `memory`, `agent-memory`, `approval`, `audit`, `sqlite`, `cordis`, `llm`
189
188
 
190
- ## 📄 许可证
189
+ ## Contributors
191
190
 
192
- Apache License 2.0——见 [LICENSE](LICENSE)。不分发任何第三方代码;见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
191
+ - [@Niuniu-Sir](https://github.com/Niuniu-Sir) — [issue #1](https://github.com/PerryLink/dsh-memento/issues/1) 中的启动崩溃报告,催生了 0.3.1 引入的 `~/.dsh` 回退。
193
192
 
194
- ## PerryLink DSH 插件家族
193
+ ## PerryLink DSH Plugin Family
195
194
 
196
- 本项目是 [PerryLink](https://github.com/PerryLink) 维护的 [15 个 DeepSeek Harness 插件](https://github.com/PerryLink)之一。如果你觉得这个插件有用,其余的很可能同样有用:
195
+ 本项目是 [PerryLink](https://github.com/PerryLink) 维护的 [15 个 DeepSeek Harness 插件](https://github.com/PerryLink) 之一。如果这个对你有用,其他插件多半也有用:
197
196
 
198
- | 插件 | 一句话说明 |
197
+ | Plugin | One-liner |
199
198
  |---|---|
200
- | [dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel) | 只读 MCP 运行时面板:/mcp 命令 + 设置页,状态/工具/错误一览 |
201
- | [dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck) | 工程纪律守门:需求审讯、测试证据门、对抗评审 |
202
- | [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) | 持久化后台子代理:Web 侧边栏进度、随时留言与打断 |
203
- | [dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions) | 基于语言服务器的诊断/格式化/补全/代码动作/重命名 |
204
- | [dsh-output-styles](https://github.com/PerryLink/dsh-output-styles) | 对标 Claude Code outputStyles 的运行时风格切换 |
205
- | [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | 对标 Claude Code /rewind:快照、会话 fork、一键回退 |
206
- | [dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules) | Claude Code 风格声明式 allow/deny/ask 权限规则,带审计 |
207
- | [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | 审批链上的第二模型自动审查,默认 fail-closed |
208
- | **[dsh-memento](https://github.com/PerryLink/dsh-memento)** | 带审批门的跨会话记忆:ctx.memory + SQLite + memory 工具 |
209
- | [dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security) | 安全审计技能包:密钥扫描、依赖与供应链审查 |
210
- | [dsh-session-pin](https://github.com/PerryLink/dsh-session-pin) | 在 Web 侧边栏置顶会话,持久排序 |
211
- | [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | Web 作曲器终端式输入历史:方向键、Ctrl+R 搜索 |
212
- | [dsh-github](https://github.com/PerryLink/dsh-github) | DSH 的 GitHub PR/issue 集成,所有写操作经审批门 |
213
- | [dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide) | 插件开发知识库,随 bundle 安装的按需 agent 技能 |
214
- | [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) | 把 Claude Code 会话、记忆、技能和 CLAUDE.md 迁入 DSH |
199
+ | [dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel) | Read-only MCP runtime panel: /mcp command + Settings tab with status, tools and errors |
200
+ | [dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck) | Engineering-discipline guard: requirements grill, test gates, adversary review |
201
+ | [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) | Durable background child agents with a Web UI sidebar, messaging and interrupt |
202
+ | [dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions) | LSP diagnostics, formatting, completion, code actions and rename over language servers |
203
+ | [dsh-output-styles](https://github.com/PerryLink/dsh-output-styles) | Claude Code outputStyles-equivalent runtime style switching |
204
+ | [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | Claude Code /rewind-equivalent: snapshots, session forks, one-shot restore |
205
+ | [dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules) | Claude Code-style declarative allow/deny/ask permission rules with audit |
206
+ | [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | Second-model auto-review on the approval chain, fail-closed by default |
207
+ | **[dsh-memento](https://github.com/PerryLink/dsh-memento)** | Approval-gated cross-session memory: ctx.memory seam + SQLite + memory tool |
208
+ | [dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security) | Security-audit skill pack: secret scan, dependency and supply-chain review |
209
+ | [dsh-session-pin](https://github.com/PerryLink/dsh-session-pin) | Pin sessions in the Web sidebar with durable ordering |
210
+ | [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | Terminal-style input history for the web composer: arrows, Ctrl+R search |
211
+ | [dsh-github](https://github.com/PerryLink/dsh-github) | GitHub PR/issues integration for DSH, every write gated by approval |
212
+ | [dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide) | Plugin-development knowledge base as an on-demand agent skill |
213
+ | [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) | Migrate Claude Code sessions, memory, skills and CLAUDE.md into DSH |
214
+
215
+ ## License
216
+
217
+ [Apache License 2.0](LICENSE) © 2026 dsh-memento contributors