@chenhw7/dsh-memory 0.1.2 → 0.3.0

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.
Files changed (75) hide show
  1. package/README.md +115 -109
  2. package/README.zh-CN.md +117 -108
  3. package/cordis.patch.yml +13 -8
  4. package/lib/client/index.js +616 -185
  5. package/lib/context/conflict.d.ts +19 -2
  6. package/lib/context/conflict.d.ts.map +1 -1
  7. package/lib/context/conflict.js +33 -0
  8. package/lib/context/conflict.js.map +1 -1
  9. package/lib/context/index.d.ts +34 -10
  10. package/lib/context/index.d.ts.map +1 -1
  11. package/lib/context/index.js +195 -24
  12. package/lib/context/index.js.map +1 -1
  13. package/lib/context/policy.d.ts +28 -1
  14. package/lib/context/policy.d.ts.map +1 -1
  15. package/lib/context/policy.js +60 -3
  16. package/lib/context/policy.js.map +1 -1
  17. package/lib/index.d.ts +27 -7
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +22 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/notes/index.d.ts +66 -0
  22. package/lib/notes/index.d.ts.map +1 -0
  23. package/lib/notes/index.js +180 -0
  24. package/lib/notes/index.js.map +1 -0
  25. package/lib/notes/render.d.ts +32 -0
  26. package/lib/notes/render.d.ts.map +1 -0
  27. package/lib/notes/render.js +68 -0
  28. package/lib/notes/render.js.map +1 -0
  29. package/lib/notes/scope.d.ts +35 -0
  30. package/lib/notes/scope.d.ts.map +1 -0
  31. package/lib/notes/scope.js +44 -0
  32. package/lib/notes/scope.js.map +1 -0
  33. package/lib/notes/settings.d.ts +35 -0
  34. package/lib/notes/settings.d.ts.map +1 -0
  35. package/lib/notes/settings.js +36 -0
  36. package/lib/notes/settings.js.map +1 -0
  37. package/lib/notes/writer.d.ts +32 -0
  38. package/lib/notes/writer.d.ts.map +1 -0
  39. package/lib/notes/writer.js +71 -0
  40. package/lib/notes/writer.js.map +1 -0
  41. package/lib/review/accumulator.d.ts +53 -18
  42. package/lib/review/accumulator.d.ts.map +1 -1
  43. package/lib/review/accumulator.js +176 -36
  44. package/lib/review/accumulator.js.map +1 -1
  45. package/lib/review/dedup.d.ts +16 -3
  46. package/lib/review/dedup.d.ts.map +1 -1
  47. package/lib/review/dedup.js +21 -4
  48. package/lib/review/dedup.js.map +1 -1
  49. package/lib/review/extract.d.ts +81 -5
  50. package/lib/review/extract.d.ts.map +1 -1
  51. package/lib/review/extract.js +224 -31
  52. package/lib/review/extract.js.map +1 -1
  53. package/lib/review/index.d.ts +15 -2
  54. package/lib/review/index.d.ts.map +1 -1
  55. package/lib/review/index.js +137 -55
  56. package/lib/review/index.js.map +1 -1
  57. package/lib/scanner.d.ts +15 -0
  58. package/lib/scanner.d.ts.map +1 -1
  59. package/lib/scanner.js +20 -0
  60. package/lib/scanner.js.map +1 -1
  61. package/lib/store/bm25.d.ts +48 -0
  62. package/lib/store/bm25.d.ts.map +1 -0
  63. package/lib/store/bm25.js +115 -0
  64. package/lib/store/bm25.js.map +1 -0
  65. package/lib/store/index.d.ts +26 -3
  66. package/lib/store/index.d.ts.map +1 -1
  67. package/lib/store/index.js +111 -68
  68. package/lib/store/index.js.map +1 -1
  69. package/lib/tool/index.d.ts +3 -1
  70. package/lib/tool/index.d.ts.map +1 -1
  71. package/lib/tool/index.js +52 -9
  72. package/lib/tool/index.js.map +1 -1
  73. package/lib/types.d.ts +17 -1
  74. package/lib/types.d.ts.map +1 -1
  75. package/package.json +35 -30
package/README.zh-CN.md CHANGED
@@ -10,23 +10,28 @@
10
10
 
11
11
  - [功能特性](#功能特性)
12
12
  - [安装](#安装)
13
+ - [更新](#更新)
13
14
  - [卸载](#卸载)
14
15
  - [验证](#验证)
15
16
  - [配置](#配置)
16
17
  - [架构](#架构)
17
- - [故障排查](#故障排查)
18
18
  - [已知限制](#已知限制)
19
19
  - [许可证](#许可证)
20
20
 
21
21
  ## 功能特性
22
22
 
23
- - **持久化记忆** — 将事实、偏好和约定存储在持久的 KV 后端中。
23
+ - **持久化记忆** — 将事实、偏好和约定存储在持久的 KV 后端中,带审计日志。
24
24
  - **三层作用域** — `global`(跨项目)、`project`(按仓库自动检测)、`user`(跨项目 profile)。
25
- - **六个模型可用工具** — `memory_search`、`memory_add`、`memory_replace`、`memory_remove`、`memory_list`、`memory_get`。
26
- - **自动学习** — 投影累加器观察对话,并通过轻量规则提取候选记忆;当候选足够多时,运行 LLM 提取。
25
+ - **八个模型可用工具** — `memory_search`、`memory_add`、`memory_replace`、`memory_remove`、`memory_list`、`memory_get`、`memory_pin`、`memory_unpin`。
26
+ - **BM25 相关性检索** — 零依赖的 Okapi BM25,CJK 感知分词(Latin 逐词;CJK 一元 + 相邻二元 bigram),固定(pin)条目在同等相关时优先靠前。
27
+ - **自动学习** — 投影累加器观察对话中的显式记忆意图、修正语句以及*已验证的失败序列*(同签名连续失败后最终成功),候选足够多时运行 LLM 提取。
28
+ - **仓库内项目笔记** — 编码约定与踩坑日志渲染为仓库内可 git 管理的 markdown(默认 `docs/agent-memory/`),每次会话注入 system prompt,并在 `AGENTS.md` 中维护一行托管指针块供其他工具发现。
29
+ - **去重管线** — 两阶段去重(停用词过滤的 Jaccard 预过滤 + 可选 LLM 裁决,合并长度有上限),防止近似重复条目累积;低频 curator pass 会将过长条目改写为简洁单行。
30
+ - **两层记忆生命周期** — 固定重要记忆;过期的 project 作用域条目被移除,而过期的 `global`/`user` 条目做软衰减(从常驻注入面隐藏但仍可搜索,再次召回即解除);每次写入都有审计。
31
+ - **步级自动召回(可选)** — 每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息;不触碰 system prompt,保持 KV-cache 前缀稳定。
27
32
  - **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
28
- - **安全扫描** — 阻止 API Key、Token、提示注入模式和泄露尝试被写入记忆。
29
- - **前端可配置** — 所有设置都通过 dsh 设置界面暴露,实时生效。
33
+ - **安全扫描:写入时 + 读取时** — API Key、Token、提示注入模式和泄露尝试会被阻止写入;漏网内容在重新进入 prompt 的任何位置都会被替换为 `[BLOCKED: …]` 占位符。
34
+ - **前端可配置** — 所有设置通过 dsh 设置界面的四张卡片暴露,实时生效。
30
35
 
31
36
  ## 安装
32
37
 
@@ -75,54 +80,12 @@ dsh plugin add --profile web @chenhw7/dsh-memory
75
80
  pnpm dsh plugin add --profile web @chenhw7/dsh-memory
76
81
  ```
77
82
 
78
- 需要锁定版本而不跟 `latest` 时:
83
+ 需要锁定特定版本时:
79
84
 
80
85
  ```sh
81
- dsh plugin add --profile web @chenhw7/dsh-memory@0.1.1
86
+ dsh plugin add --profile web @chenhw7/dsh-memory@0.3.0
82
87
  ```
83
88
 
84
- ### 从 GitHub 安装(尝鲜最新 commit)
85
-
86
- 只有当你要测试比最新 npm 版本更新的 commit 时才用这种方式。pnpm 会阻止 git 依赖的 `prepare` 构建脚本,直到你显式允许,所以没有 `allowBuilds` 条目的 profile 需要**跑两次**:
87
-
88
- **第一步:先跑一次安装。** 它会停下并报错:
89
-
90
- ```sh
91
- dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
92
- ```
93
-
94
- ```text
95
- [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.1"
96
- needs to execute build scripts but is not in the "allowBuilds" allowlist.
97
- ...
98
- allowBuilds:
99
- @chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<commit>: true
100
- ```
101
-
102
- **第二步:把 pnpm 打印的精确 key 加入允许列表。** 编辑 profile 的 `pnpm-workspace.yaml`:
103
-
104
- - Windows:`%USERPROFILE%\.dsh\profiles\web\pnpm-workspace.yaml`
105
- - macOS/Linux:`~/.dsh/profiles/web/pnpm-workspace.yaml`
106
- - 如果设置了 `DSH_HOME`:`$DSH_HOME/profiles/web/pnpm-workspace.yaml`
107
-
108
- 添加报错信息里的那条 key(与已有内容合并):
109
-
110
- ```yaml
111
- allowBuilds:
112
- "@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<pnpm 打印的 commit>": true
113
- ```
114
-
115
- 部分 pnpm 版本使用旧格式:
116
-
117
- ```yaml
118
- onlyBuiltDependencies:
119
- - "@chenhw7/dsh-memory"
120
- ```
121
-
122
- 如果你的 pnpm 提示的是这个字段,就用这个格式。然后重新执行 `dsh plugin add` 命令。
123
-
124
- > **key 要从 pnpm 的报错里复制,不要从旧版本文档里复制。** key 包含解析后的 commit,每换一个新 commit 安装都会变。这条允许项的含义是:允许该包的 `prepare` 脚本(`npm run build`)在安装时于你的机器上运行——只允许你信任源码的包。需要可复现的安装时,请固定 commit(`dsh plugin add --profile web https://github.com/chenhw7/dsh-memory/archive/<commit>.tar.gz`),并允许 pnpm 为该固定地址打印的 key。
125
-
126
89
  ### 从本地 checkout 安装
127
90
 
128
91
  如果你想修改插件,先 clone 并构建,再从本地路径安装:
@@ -143,8 +106,24 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
143
106
  ```sh
144
107
  cd dsh-memory
145
108
  npm install && npm run build
146
- npm pack # 生成 chenhw7-dsh-memory-0.1.1.tgz
147
- dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.1.tgz
109
+ npm pack # 生成 chenhw7-dsh-memory-0.3.0.tgz
110
+ dsh plugin add --profile web ./chenhw7-dsh-memory-0.3.0.tgz
111
+ ```
112
+
113
+ ## 更新
114
+
115
+ `dsh plugin add` 在**全新** profile 上始终从 npm 安装最新版。但一旦已安装某个版本,再次运行 `dsh plugin add` **不会**更新——pnpm 发现已有的版本范围(如 `^0.2.0`)已被最新版(如 `0.2.1`)满足,就跳过更新了。
116
+
117
+ 要更新到最新发布版本:
118
+
119
+ ```sh
120
+ dsh plugin --profile web update @chenhw7/dsh-memory
121
+ ```
122
+
123
+ 源码构建的 dsh:
124
+
125
+ ```sh
126
+ pnpm dsh plugin --profile web update @chenhw7/dsh-memory
148
127
  ```
149
128
 
150
129
  ## 卸载
@@ -155,7 +134,7 @@ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.1.tgz
155
134
  dsh plugin remove --profile web @chenhw7/dsh-memory
156
135
  ```
157
136
 
158
- (源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,四个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
137
+ (源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,七个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
159
138
 
160
139
  卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下的一个文件里:
161
140
 
@@ -171,7 +150,7 @@ dsh plugin remove --profile web @chenhw7/dsh-memory
171
150
 
172
151
  ## 验证
173
152
 
174
- 安装后,确认组合后的 profile 树中包含四个 memory 行:
153
+ 安装后,确认组合后的 profile 树中包含七个 memory 行:
175
154
 
176
155
  ```sh
177
156
  # Windows
@@ -180,17 +159,23 @@ dsh --profile web --dump-config | findstr memory
180
159
  dsh --profile web --dump-config | grep memory
181
160
  ```
182
161
 
183
- 你应该看到四个指向 `@chenhw7/dsh-memory/*` 的行:
162
+ 你应该看到七个指向 `@chenhw7/dsh-memory/*` 的行:
184
163
 
185
164
  ```
165
+ - id: memory-root
166
+ name: '@chenhw7/dsh-memory'
186
167
  - id: memory-store
187
168
  name: '@chenhw7/dsh-memory/store'
188
169
  - id: tool-memory
189
170
  name: '@chenhw7/dsh-memory/tool'
190
171
  - id: memory-review
191
172
  name: '@chenhw7/dsh-memory/review'
173
+ - id: memory-notes
174
+ name: '@chenhw7/dsh-memory/notes'
192
175
  - id: memory-context
193
176
  name: '@chenhw7/dsh-memory/context'
177
+ - id: memory-remote
178
+ name: '@chenhw7/dsh-memory/remote-service'
194
179
  ```
195
180
 
196
181
  然后启动 dsh,检查设置界面是否显示 `memory` 命名空间:
@@ -201,53 +186,101 @@ dsh web
201
186
 
202
187
  ## 配置
203
188
 
204
- 所有设置都可以在 dsh 前端设置页(`memory` 命名空间)中编辑并实时生效,持久化在 `$DSH_HOME/settings.yaml`。
189
+ 本 bundle 拥有**两个设置命名空间**,在「设置 → 插件 → 插件配置」中显示为四张卡片,且**全部实时生效**——改动在下一次事件或调用时即生效,无需重启:
190
+
191
+ - **`memory`**(卡片:*Memory*、*Project Notes*、*Auto Recall*)——注入模式、字符预算、生命周期、项目笔记、自动召回。由 `memory-context` 持有。
192
+ - **`memory-review`**(卡片:*Automatic Extraction*)——提取管线、模型路由、去重裁决、失败序列踩坑、curator pass。由 `memory-review` 插件持有。
193
+
194
+ 每个命名空间按分层 resolve:schema 默认 → 组合 `config:` 条目(base)→ `$DSH_HOME/settings.yaml` 中的用户文档。用户层缺失的字段继承组合值,因此部署可以固定默认值,用户只覆盖所需部分。当无 settings 服务挂载时(如 headless profile),各插件回退到组合条目,行为与组合配置完全一致。
195
+
196
+ ### `memory` 命名空间
205
197
 
206
198
  | 设置 | 默认值 | 说明 |
207
199
  |---|---|---|
208
200
  | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
209
201
  | `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
202
+ | `memoryCharLimit` | `5000` | 会话内冻结记忆快照注入 `full` 模式时的字符预算(`0` = 不注入内容)。 |
203
+ | `maxSearchResults` | `50` | `memory_search` / `memory_list` 在调用未传 `limit` 时的默认返回条数上限,由工具插件实时读取。`0` = 无限制。 |
204
+ | `decayDays` | `30` | N 天内未召回条目的生命周期窗口,由 review 插件的 janitor 实时读取。`0` = 禁用。过期的 `project` 条目被**移除**(硬衰减);过期的 `global`/`user` 条目改为**软衰减**——打上 `stale` 戳,从注入面和笔记文件中隐藏但仍可搜索,再次召回即自动解除。固定(pin)条目始终豁免。 |
205
+ | `notesEnabled` | `true` | 启用项目笔记的仓库内文件导出与 system prompt 注入。已渲染进笔记文件的条目会从 memory 段落中排除,避免重复注入。 |
206
+ | `notesDir` | `docs/agent-memory` | 仓库内生成 `CONVENTIONS.md` / `PITFALLS.md` 的目录。 |
207
+ | `notesCharLimit` | `4000` | 注入的 `project-notes` 段落字符上限。 |
208
+ | `notesAgentsPointer` | `true` | 维护仓库 `AGENTS.md` 中的托管指针块。 |
209
+ | `notesMaxEntriesPerFile` | `100` | 每个生成笔记文件的最大条目数(保留最新)。 |
210
+ | `autoRecallEnabled` | `false` | 步级自动召回:每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息。不触碰 system prompt,保持 KV-cache 前缀稳定。 |
211
+ | `autoRecallLimit` | `5` | 单次自动召回围栏内的最大条数(最小 1)。围栏本身上限 1200 字符。 |
212
+ | `autoRecallMinChars` | `12` | 该步用户文本短于该字符数时跳过召回(最小 1)。 |
213
+
214
+ ### `memory-review` 命名空间
215
+
216
+ | 设置 | 默认值 | 说明 |
217
+ |---|---|---|
210
218
  | `reviewEnabled` | `true` | 启用自动周期性 review 提取。 |
211
- | `reviewCandidateThreshold` | `10` | 触发 LLM 提取前的候选消息数。 |
219
+ | `reviewCandidateThreshold` | `10` | 触发一次提取 drain 所需的未处理候选信号数(最小 1)。 |
212
220
  | `flushOnCompaction` | `true` | 压缩后从被遮蔽的事件中提取记忆。 |
213
- | `flushOnDispose` | `true` | 会话销毁时提取剩余上下文。 |
214
- | `memoryCharLimit` | `5000` | 每个作用域注入记忆内容的字符上限。 |
221
+ | `flushOnDispose` | `true` | 会话销毁时提取剩余上下文(5 秒上限)。 |
222
+ | `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决/curator 调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
223
+ | `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决/curator 调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
224
+ | `extractionBudget` | `20` | 每会话 LLM 调用配额,由 review drain、两种 flush 和 curator pass 共享。`0` = 无限。 |
225
+ | `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
226
+ | `pitfallStreakThreshold` | `2` | 判定踩坑所需的同签名连续失败次数(最终被一次成功解决后才发出一条结构化踩坑候选,提取进笔记文件)。一次性失败不提取。 |
227
+ | `curatorEnabled` | `true` | 低频 curator pass:每 `curatorEveryNSessions` 次会话创建,把最长的超长条目交给提取模型改写为简洁单行(受预算约束)。 |
228
+ | `curatorEveryNSessions` | `20` | 每 N 次会话创建运行一次 curator pass。 |
229
+ | `curatorMaxEntries` | `5` | 每次 curation 最多选中的条目数(最长优先)。 |
230
+ | `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
215
231
 
216
- ### 提取与去重设置
232
+ > 特意**没有独立的 `tool-memory` 设置命名空间**:工具插件从上面的 `memory` 命名空间实时读取 `maxSearchResults`。其组合配置 `config.maxSearchResults` 仅作为无 settings 服务挂载时的回退 base。
217
233
 
218
- 以下设置控制自动提取管线和去重裁决,位于 `memory-review` 插件配置中(通过组合层设置,不在 `memory` 设置命名空间里):
234
+ ### 组合配置与 UI 设置
219
235
 
220
- | 设置 | 默认值 | 说明 |
221
- |---|---|---|
222
- | `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
223
- | `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
224
- | `extractionBudget` | `20` | 每会话最大提取 + 裁决调用次数。`0` = 无限。 |
225
- | `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
236
+ 两个命名空间均接受来自两个层的相同键。组合 `config:` 条目设置 base;UI 在其上写入用户层。例如,要把 `maxSearchResults: 100` 钉为部署默认值(用户仍可覆盖):
226
237
 
227
- 默认情况下,提取和去重裁决使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,在 review 插件的组合配置中设置 `extractionModelProvider` 和 `extractionModelModel`。
238
+ ```yaml
239
+ memory:
240
+ config:
241
+ maxSearchResults: 100
242
+ ```
228
243
 
229
- 专用提取模型的组合配置示例:
244
+ 默认情况下,提取、去重裁决和 curation 使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,设置 `extractionModelProvider` 和 `extractionModelModel`(在组合配置或 UI 中均可——UI 提供由宿主模型目录驱动的下拉框):
230
245
 
231
246
  ```yaml
232
247
  memory-review:
233
248
  config:
234
249
  extractionModelProvider: deepseek
235
250
  extractionModelModel: deepseek-chat
236
- extractionBudget: 20
237
- judgeEnabled: true
238
251
  ```
239
252
 
240
- `$DSH_HOME/settings.yaml` 配置示例:
253
+ `$DSH_HOME/settings.yaml` 示例(两个命名空间):
241
254
 
242
255
  ```yaml
243
256
  memory:
244
257
  memoryMode: policy-only
245
258
  memoryPolicyCustomText: ""
259
+ memoryCharLimit: 5000
260
+ maxSearchResults: 50
261
+ decayDays: 30
262
+ notesEnabled: true
263
+ notesDir: docs/agent-memory
264
+ notesCharLimit: 4000
265
+ notesAgentsPointer: true
266
+ notesMaxEntriesPerFile: 100
267
+ autoRecallEnabled: false
268
+ autoRecallLimit: 5
269
+ autoRecallMinChars: 12
270
+ memory-review:
246
271
  reviewEnabled: true
247
272
  reviewCandidateThreshold: 10
248
273
  flushOnCompaction: true
249
274
  flushOnDispose: true
250
- memoryCharLimit: 5000
275
+ extractionModelProvider: ""
276
+ extractionModelModel: ""
277
+ extractionBudget: 20
278
+ judgeEnabled: true
279
+ pitfallStreakThreshold: 2
280
+ curatorEnabled: true
281
+ curatorEveryNSessions: 20
282
+ curatorMaxEntries: 5
283
+ curatorMinChars: 400
251
284
  ```
252
285
 
253
286
  `memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
@@ -276,14 +309,17 @@ memory:
276
309
 
277
310
  ## 架构
278
311
 
279
- 该 bundle 在 `dsh-base` 之上插入四行,每行指向本包自己的导出子路径:
312
+ 该 bundle 在 `dsh-base` 之上插入七行,每行指向本包自己的导出子路径:
280
313
 
281
314
  | 行 | 导出 | 作用 |
282
315
  |---|---|---|
283
- | `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory` |
284
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | 六个模型可用工具 |
285
- | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush) |
286
- | `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入 + 设置命名空间 |
316
+ | `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
317
+ | `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory`(BM25 检索 + 两层衰减) |
318
+ | `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具 |
319
+ | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator),持有 `memory-review` 设置命名空间 |
320
+ | `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 + 原子写 + AGENTS.md 指针),注册 `ctx.projectNotes` |
321
+ | `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入(`memory` @90 + `project-notes` @91)、步级自动召回,持有 `memory` 设置命名空间 |
322
+ | `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 面向未来记忆管理 UI 的 `@Remote` 服务 |
287
323
 
288
324
  **存储**:本 bundle **不**插入 `storage-json` / `storage-domain` 行。`dsh-web-app` bundle 已经提供它们(并在 `$DSH_HOME/storages` 下使用正确的根路径)。如果在这里重复插入,会覆盖已有配置(patch 会替换整行,后写覆盖先写)。memory store provider 将 `storageDomain` 服务作为 peer dependency 使用。
289
325
 
@@ -302,38 +338,11 @@ memory:
302
338
  backend: json
303
339
  ```
304
340
 
305
- ## 故障排查
306
-
307
- ### `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`
308
-
309
- 如果**git 安装**(`dsh plugin add ... https://github.com/...`)报错,例如:(npm 安装 `@chenhw7/dsh-memory` 不会触发此错误。)
310
-
311
- ```text
312
- [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] Failed to prepare git-hosted package ...
313
- The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build scripts but is not in the "allowBuilds" allowlist.
314
- ```
315
-
316
- 说明 pnpm 还没有被允许执行该包的 `prepare` 构建脚本。
317
-
318
- **解决方法:**
319
-
320
- 1. 打开 profile 的 `pnpm-workspace.yaml`(路径见上文)。
321
- 2. 根据错误信息添加精确的 `allowBuilds` 条目,格式类似:
322
-
323
- ```yaml
324
- allowBuilds:
325
- "@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<commit>": true
326
- ```
327
-
328
- 3. 重新执行 `dsh plugin add`。
329
-
330
- > 如果你更新了 `dsh-memory` 到新 commit,错误中的 URL 可能会变化。请将 `allowBuilds` 更新为新 URL,或者继续固定使用已经允许的 commit。
331
-
332
341
  ## 已知限制
333
342
 
334
- - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的子串匹配,不是 embeddings。
335
- - **提取质量跟随会话模型** — review/flush 复用会话当前路由的 provider/model。
336
- - **git 安装需要构建允许** — pnpm 会阻止 git 依赖的 `prepare` 脚本,直到你在 profile 的 `pnpm-workspace.yaml` 中允许它(见上文两步流程)。npm 安装路径则完全不需要。
343
+ - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的 BM25 词法排序(Latin 逐词、CJK 一元 + 二元分词),不是 embeddings;不含相同词元的同义表述无法命中。
344
+ - **提取质量跟随会话模型** — review/flush/curator 复用会话当前路由的 provider/model,除非显式覆盖。
345
+ - **会话中途的提取在下次压缩或新会话前不会出现在提示里** — 注入快照为 KV-cache 稳定性而冻结;步级自动召回(可选)提供逐步新鲜度。
337
346
  - **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
338
347
 
339
348
  ## 许可证
package/cordis.patch.yml CHANGED
@@ -1,14 +1,14 @@
1
1
  # @chenhw7/dsh-memory — long-term memory bundle patch for the DeepSeek Harness.
2
2
  #
3
3
  # Installs the memory store provider, six model-facing memory tools, automatic
4
- # review + flush extraction, and system-prompt context injection as ONE layer
5
- # over dsh-base. The four memory rows point at this package's own export
6
- # sub-paths; the two storage rows are NOT inserted here because dsh-web-app
7
- # already provides them (storage-json + storage-domain with the correct root
8
- # path). For a headless profile that has no storage layer, see the README's
9
- # "headless" section — add the storage rows to your profile's cordis.patch.yml
10
- # instead of letting this bundle insert them (last-write-wins would clobber the
11
- # web-app's root config otherwise).
4
+ # review + flush extraction, the project-notes exporter, and system-prompt
5
+ # context injection as ONE layer over dsh-base. The memory rows point at this
6
+ # package's own export sub-paths; the two storage rows are NOT inserted here
7
+ # because dsh-web-app already provides them (storage-json + storage-domain
8
+ # with the correct root path). For a headless profile that has no storage
9
+ # layer, see the README's "headless" section — add the storage rows to your
10
+ # profile's cordis.patch.yml instead of letting this bundle insert them
11
+ # (last-write-wins would clobber the web-app's root config otherwise).
12
12
  #
13
13
  # Row order carries no load semantics; the grouping is for readers.
14
14
 
@@ -33,6 +33,11 @@
33
33
  - id: memory-review
34
34
  name: '@chenhw7/dsh-memory/review'
35
35
 
36
+ # Project notes: renders habit/convention/pitfall entries from the store
37
+ # into in-repo files (CONVENTIONS.md / PITFALLS.md) + AGENTS.md pointer.
38
+ - id: memory-notes
39
+ name: '@chenhw7/dsh-memory/notes'
40
+
36
41
  # System-prompt section injection + frontend settings namespace.
37
42
  - id: memory-context
38
43
  name: '@chenhw7/dsh-memory/context'