@chenhw7/dsh-memory 0.1.3 → 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.
- package/README.md +101 -120
- package/README.zh-CN.md +103 -119
- package/cordis.patch.yml +13 -8
- package/lib/client/index.js +616 -185
- package/lib/context/conflict.d.ts +19 -2
- package/lib/context/conflict.d.ts.map +1 -1
- package/lib/context/conflict.js +33 -0
- package/lib/context/conflict.js.map +1 -1
- package/lib/context/index.d.ts +34 -10
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +195 -24
- package/lib/context/index.js.map +1 -1
- package/lib/context/policy.d.ts +28 -1
- package/lib/context/policy.d.ts.map +1 -1
- package/lib/context/policy.js +60 -3
- package/lib/context/policy.js.map +1 -1
- package/lib/index.d.ts +27 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -1
- package/lib/notes/index.d.ts +66 -0
- package/lib/notes/index.d.ts.map +1 -0
- package/lib/notes/index.js +180 -0
- package/lib/notes/index.js.map +1 -0
- package/lib/notes/render.d.ts +32 -0
- package/lib/notes/render.d.ts.map +1 -0
- package/lib/notes/render.js +68 -0
- package/lib/notes/render.js.map +1 -0
- package/lib/notes/scope.d.ts +35 -0
- package/lib/notes/scope.d.ts.map +1 -0
- package/lib/notes/scope.js +44 -0
- package/lib/notes/scope.js.map +1 -0
- package/lib/notes/settings.d.ts +35 -0
- package/lib/notes/settings.d.ts.map +1 -0
- package/lib/notes/settings.js +36 -0
- package/lib/notes/settings.js.map +1 -0
- package/lib/notes/writer.d.ts +32 -0
- package/lib/notes/writer.d.ts.map +1 -0
- package/lib/notes/writer.js +71 -0
- package/lib/notes/writer.js.map +1 -0
- package/lib/review/accumulator.d.ts +53 -18
- package/lib/review/accumulator.d.ts.map +1 -1
- package/lib/review/accumulator.js +176 -36
- package/lib/review/accumulator.js.map +1 -1
- package/lib/review/dedup.d.ts +16 -3
- package/lib/review/dedup.d.ts.map +1 -1
- package/lib/review/dedup.js +21 -4
- package/lib/review/dedup.js.map +1 -1
- package/lib/review/extract.d.ts +81 -5
- package/lib/review/extract.d.ts.map +1 -1
- package/lib/review/extract.js +224 -31
- package/lib/review/extract.js.map +1 -1
- package/lib/review/index.d.ts +15 -2
- package/lib/review/index.d.ts.map +1 -1
- package/lib/review/index.js +137 -55
- package/lib/review/index.js.map +1 -1
- package/lib/scanner.d.ts +15 -0
- package/lib/scanner.d.ts.map +1 -1
- package/lib/scanner.js +20 -0
- package/lib/scanner.js.map +1 -1
- package/lib/store/bm25.d.ts +48 -0
- package/lib/store/bm25.d.ts.map +1 -0
- package/lib/store/bm25.js +115 -0
- package/lib/store/bm25.js.map +1 -0
- package/lib/store/index.d.ts +26 -3
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +111 -68
- package/lib/store/index.js.map +1 -1
- package/lib/tool/index.d.ts +3 -1
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +52 -9
- package/lib/tool/index.js.map +1 -1
- package/lib/types.d.ts +17 -1
- package/lib/types.d.ts.map +1 -1
- package/package.json +35 -30
package/README.zh-CN.md
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
- [功能特性](#功能特性)
|
|
12
12
|
- [安装](#安装)
|
|
13
|
+
- [更新](#更新)
|
|
13
14
|
- [卸载](#卸载)
|
|
14
15
|
- [验证](#验证)
|
|
15
16
|
- [配置](#配置)
|
|
16
17
|
- [架构](#架构)
|
|
17
|
-
- [故障排查](#故障排查)
|
|
18
18
|
- [已知限制](#已知限制)
|
|
19
19
|
- [许可证](#许可证)
|
|
20
20
|
|
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
- **持久化记忆** — 将事实、偏好和约定存储在持久的 KV 后端中,带审计日志。
|
|
24
24
|
- **三层作用域** — `global`(跨项目)、`project`(按仓库自动检测)、`user`(跨项目 profile)。
|
|
25
25
|
- **八个模型可用工具** — `memory_search`、`memory_add`、`memory_replace`、`memory_remove`、`memory_list`、`memory_get`、`memory_pin`、`memory_unpin`。
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
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 前缀稳定。
|
|
29
32
|
- **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
|
|
30
|
-
-
|
|
31
|
-
- **前端可配置** —
|
|
33
|
+
- **安全扫描:写入时 + 读取时** — API Key、Token、提示注入模式和泄露尝试会被阻止写入;漏网内容在重新进入 prompt 的任何位置都会被替换为 `[BLOCKED: …]` 占位符。
|
|
34
|
+
- **前端可配置** — 所有设置通过 dsh 设置界面的四张卡片暴露,实时生效。
|
|
32
35
|
|
|
33
36
|
## 安装
|
|
34
37
|
|
|
@@ -77,54 +80,12 @@ dsh plugin add --profile web @chenhw7/dsh-memory
|
|
|
77
80
|
pnpm dsh plugin add --profile web @chenhw7/dsh-memory
|
|
78
81
|
```
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
需要锁定特定版本时:
|
|
81
84
|
|
|
82
85
|
```sh
|
|
83
|
-
dsh plugin add --profile web @chenhw7/dsh-memory@0.
|
|
86
|
+
dsh plugin add --profile web @chenhw7/dsh-memory@0.3.0
|
|
84
87
|
```
|
|
85
88
|
|
|
86
|
-
### 从 GitHub 安装(尝鲜最新 commit)
|
|
87
|
-
|
|
88
|
-
只有当你要测试比最新 npm 版本更新的 commit 时才用这种方式。pnpm 会阻止 git 依赖的 `prepare` 构建脚本,直到你显式允许,所以没有 `allowBuilds` 条目的 profile 需要**跑两次**:
|
|
89
|
-
|
|
90
|
-
**第一步:先跑一次安装。** 它会停下并报错:
|
|
91
|
-
|
|
92
|
-
```sh
|
|
93
|
-
dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
```text
|
|
97
|
-
[ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.2"
|
|
98
|
-
needs to execute build scripts but is not in the "allowBuilds" allowlist.
|
|
99
|
-
...
|
|
100
|
-
allowBuilds:
|
|
101
|
-
@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<commit>: true
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**第二步:把 pnpm 打印的精确 key 加入允许列表。** 编辑 profile 的 `pnpm-workspace.yaml`:
|
|
105
|
-
|
|
106
|
-
- Windows:`%USERPROFILE%\.dsh\profiles\web\pnpm-workspace.yaml`
|
|
107
|
-
- macOS/Linux:`~/.dsh/profiles/web/pnpm-workspace.yaml`
|
|
108
|
-
- 如果设置了 `DSH_HOME`:`$DSH_HOME/profiles/web/pnpm-workspace.yaml`
|
|
109
|
-
|
|
110
|
-
添加报错信息里的那条 key(与已有内容合并):
|
|
111
|
-
|
|
112
|
-
```yaml
|
|
113
|
-
allowBuilds:
|
|
114
|
-
"@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<pnpm 打印的 commit>": true
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
部分 pnpm 版本使用旧格式:
|
|
118
|
-
|
|
119
|
-
```yaml
|
|
120
|
-
onlyBuiltDependencies:
|
|
121
|
-
- "@chenhw7/dsh-memory"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
如果你的 pnpm 提示的是这个字段,就用这个格式。然后重新执行 `dsh plugin add` 命令。
|
|
125
|
-
|
|
126
|
-
> **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。
|
|
127
|
-
|
|
128
89
|
### 从本地 checkout 安装
|
|
129
90
|
|
|
130
91
|
如果你想修改插件,先 clone 并构建,再从本地路径安装:
|
|
@@ -145,8 +106,24 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
|
|
|
145
106
|
```sh
|
|
146
107
|
cd dsh-memory
|
|
147
108
|
npm install && npm run build
|
|
148
|
-
npm pack # 生成 chenhw7-dsh-memory-0.
|
|
149
|
-
dsh plugin add --profile web ./chenhw7-dsh-memory-0.
|
|
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
|
|
150
127
|
```
|
|
151
128
|
|
|
152
129
|
## 卸载
|
|
@@ -157,7 +134,7 @@ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.2.tgz
|
|
|
157
134
|
dsh plugin remove --profile web @chenhw7/dsh-memory
|
|
158
135
|
```
|
|
159
136
|
|
|
160
|
-
(源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove`
|
|
137
|
+
(源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,七个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
|
|
161
138
|
|
|
162
139
|
卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下的一个文件里:
|
|
163
140
|
|
|
@@ -173,7 +150,7 @@ dsh plugin remove --profile web @chenhw7/dsh-memory
|
|
|
173
150
|
|
|
174
151
|
## 验证
|
|
175
152
|
|
|
176
|
-
安装后,确认组合后的 profile
|
|
153
|
+
安装后,确认组合后的 profile 树中包含七个 memory 行:
|
|
177
154
|
|
|
178
155
|
```sh
|
|
179
156
|
# Windows
|
|
@@ -182,7 +159,7 @@ dsh --profile web --dump-config | findstr memory
|
|
|
182
159
|
dsh --profile web --dump-config | grep memory
|
|
183
160
|
```
|
|
184
161
|
|
|
185
|
-
|
|
162
|
+
你应该看到七个指向 `@chenhw7/dsh-memory/*` 的行:
|
|
186
163
|
|
|
187
164
|
```
|
|
188
165
|
- id: memory-root
|
|
@@ -193,6 +170,8 @@ dsh --profile web --dump-config | grep memory
|
|
|
193
170
|
name: '@chenhw7/dsh-memory/tool'
|
|
194
171
|
- id: memory-review
|
|
195
172
|
name: '@chenhw7/dsh-memory/review'
|
|
173
|
+
- id: memory-notes
|
|
174
|
+
name: '@chenhw7/dsh-memory/notes'
|
|
196
175
|
- id: memory-context
|
|
197
176
|
name: '@chenhw7/dsh-memory/context'
|
|
198
177
|
- id: memory-remote
|
|
@@ -207,70 +186,101 @@ dsh web
|
|
|
207
186
|
|
|
208
187
|
## 配置
|
|
209
188
|
|
|
210
|
-
|
|
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` 命名空间
|
|
211
197
|
|
|
212
198
|
| 设置 | 默认值 | 说明 |
|
|
213
199
|
|---|---|---|
|
|
214
200
|
| `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
|
|
215
201
|
| `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
-
| `
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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` 命名空间
|
|
225
215
|
|
|
226
216
|
| 设置 | 默认值 | 说明 |
|
|
227
217
|
|---|---|---|
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
218
|
+
| `reviewEnabled` | `true` | 启用自动周期性 review 提取。 |
|
|
219
|
+
| `reviewCandidateThreshold` | `10` | 触发一次提取 drain 所需的未处理候选信号数(最小 1)。 |
|
|
220
|
+
| `flushOnCompaction` | `true` | 压缩后从被遮蔽的事件中提取记忆。 |
|
|
221
|
+
| `flushOnDispose` | `true` | 会话销毁时提取剩余上下文(5 秒上限)。 |
|
|
222
|
+
| `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决/curator 调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
|
|
223
|
+
| `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决/curator 调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
|
|
224
|
+
| `extractionBudget` | `20` | 每会话 LLM 调用配额,由 review drain、两种 flush 和 curator pass 共享。`0` = 无限。 |
|
|
231
225
|
| `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
|
|
232
|
-
| `
|
|
226
|
+
| `pitfallStreakThreshold` | `2` | 判定踩坑所需的同签名连续失败次数(最终被一次成功解决后才发出一条结构化踩坑候选,提取进笔记文件)。一次性失败不提取。 |
|
|
227
|
+
| `curatorEnabled` | `true` | 低频 curator pass:每 `curatorEveryNSessions` 次会话创建,把最长的超长条目交给提取模型改写为简洁单行(受预算约束)。 |
|
|
228
|
+
| `curatorEveryNSessions` | `20` | 每 N 次会话创建运行一次 curator pass。 |
|
|
229
|
+
| `curatorMaxEntries` | `5` | 每次 curation 最多选中的条目数(最长优先)。 |
|
|
230
|
+
| `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
|
|
233
231
|
|
|
234
|
-
|
|
232
|
+
> 特意**没有独立的 `tool-memory` 设置命名空间**:工具插件从上面的 `memory` 命名空间实时读取 `maxSearchResults`。其组合配置 `config.maxSearchResults` 仅作为无 settings 服务挂载时的回退 base。
|
|
235
233
|
|
|
236
|
-
|
|
234
|
+
### 组合配置与 UI 设置
|
|
237
235
|
|
|
238
|
-
|
|
239
|
-
|---|---|---|
|
|
240
|
-
| `maxSearchResults` | `50` | `memory_search` 返回的最大条目数。`0` = 无限制。 |
|
|
241
|
-
|
|
242
|
-
组合配置示例:
|
|
236
|
+
两个命名空间均接受来自两个层的相同键。组合 `config:` 条目设置 base;UI 在其上写入用户层。例如,要把 `maxSearchResults: 100` 钉为部署默认值(用户仍可覆盖):
|
|
243
237
|
|
|
244
238
|
```yaml
|
|
245
|
-
|
|
239
|
+
memory:
|
|
246
240
|
config:
|
|
247
241
|
maxSearchResults: 100
|
|
248
242
|
```
|
|
249
243
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
专用提取模型的组合配置示例:
|
|
244
|
+
默认情况下,提取、去重裁决和 curation 使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,设置 `extractionModelProvider` 和 `extractionModelModel`(在组合配置或 UI 中均可——UI 提供由宿主模型目录驱动的下拉框):
|
|
253
245
|
|
|
254
246
|
```yaml
|
|
255
247
|
memory-review:
|
|
256
248
|
config:
|
|
257
249
|
extractionModelProvider: deepseek
|
|
258
250
|
extractionModelModel: deepseek-chat
|
|
259
|
-
extractionBudget: 20
|
|
260
|
-
judgeEnabled: true
|
|
261
251
|
```
|
|
262
252
|
|
|
263
|
-
`$DSH_HOME/settings.yaml`
|
|
253
|
+
`$DSH_HOME/settings.yaml` 示例(两个命名空间):
|
|
264
254
|
|
|
265
255
|
```yaml
|
|
266
256
|
memory:
|
|
267
257
|
memoryMode: policy-only
|
|
268
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:
|
|
269
271
|
reviewEnabled: true
|
|
270
272
|
reviewCandidateThreshold: 10
|
|
271
273
|
flushOnCompaction: true
|
|
272
274
|
flushOnDispose: true
|
|
273
|
-
|
|
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
|
|
274
284
|
```
|
|
275
285
|
|
|
276
286
|
`memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
|
|
@@ -299,16 +309,17 @@ memory:
|
|
|
299
309
|
|
|
300
310
|
## 架构
|
|
301
311
|
|
|
302
|
-
该 bundle 在 `dsh-base`
|
|
312
|
+
该 bundle 在 `dsh-base` 之上插入七行,每行指向本包自己的导出子路径:
|
|
303
313
|
|
|
304
314
|
| 行 | 导出 | 作用 |
|
|
305
315
|
|---|---|---|
|
|
306
316
|
| `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
|
|
307
|
-
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory
|
|
317
|
+
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory`(BM25 检索 + 两层衰减) |
|
|
308
318
|
| `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具 |
|
|
309
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush + 去重 + janitor
|
|
310
|
-
| `memory-
|
|
311
|
-
| `memory-
|
|
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` 服务 |
|
|
312
323
|
|
|
313
324
|
**存储**:本 bundle **不**插入 `storage-json` / `storage-domain` 行。`dsh-web-app` bundle 已经提供它们(并在 `$DSH_HOME/storages` 下使用正确的根路径)。如果在这里重复插入,会覆盖已有配置(patch 会替换整行,后写覆盖先写)。memory store provider 将 `storageDomain` 服务作为 peer dependency 使用。
|
|
314
325
|
|
|
@@ -327,38 +338,11 @@ memory:
|
|
|
327
338
|
backend: json
|
|
328
339
|
```
|
|
329
340
|
|
|
330
|
-
## 故障排查
|
|
331
|
-
|
|
332
|
-
### `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`
|
|
333
|
-
|
|
334
|
-
如果**git 安装**(`dsh plugin add ... https://github.com/...`)报错,例如:(npm 安装 `@chenhw7/dsh-memory` 不会触发此错误。)
|
|
335
|
-
|
|
336
|
-
```text
|
|
337
|
-
[ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] Failed to prepare git-hosted package ...
|
|
338
|
-
The git-hosted package "@chenhw7/dsh-memory@0.1.2" needs to execute build scripts but is not in the "allowBuilds" allowlist.
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
说明 pnpm 还没有被允许执行该包的 `prepare` 构建脚本。
|
|
342
|
-
|
|
343
|
-
**解决方法:**
|
|
344
|
-
|
|
345
|
-
1. 打开 profile 的 `pnpm-workspace.yaml`(路径见上文)。
|
|
346
|
-
2. 根据错误信息添加精确的 `allowBuilds` 条目,格式类似:
|
|
347
|
-
|
|
348
|
-
```yaml
|
|
349
|
-
allowBuilds:
|
|
350
|
-
"@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<commit>": true
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
3. 重新执行 `dsh plugin add`。
|
|
354
|
-
|
|
355
|
-
> 如果你更新了 `dsh-memory` 到新 commit,错误中的 URL 可能会变化。请将 `allowBuilds` 更新为新 URL,或者继续固定使用已经允许的 commit。
|
|
356
|
-
|
|
357
341
|
## 已知限制
|
|
358
342
|
|
|
359
|
-
- **无语义/向量检索** — `memory_search` 是对结构化 KV
|
|
360
|
-
- **提取质量跟随会话模型** — review/flush 复用会话当前路由的 provider/model
|
|
361
|
-
-
|
|
343
|
+
- **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的 BM25 词法排序(Latin 逐词、CJK 一元 + 二元分词),不是 embeddings;不含相同词元的同义表述无法命中。
|
|
344
|
+
- **提取质量跟随会话模型** — review/flush/curator 复用会话当前路由的 provider/model,除非显式覆盖。
|
|
345
|
+
- **会话中途的提取在下次压缩或新会话前不会出现在提示里** — 注入快照为 KV-cache 稳定性而冻结;步级自动召回(可选)提供逐步新鲜度。
|
|
362
346
|
- **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
|
|
363
347
|
|
|
364
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
|
|
5
|
-
# over dsh-base. The
|
|
6
|
-
# sub-paths; the two storage rows are NOT inserted here
|
|
7
|
-
# already provides them (storage-json + storage-domain
|
|
8
|
-
# path). For a headless profile that has no storage
|
|
9
|
-
# "headless" section — add the storage rows to your
|
|
10
|
-
# instead of letting this bundle insert them
|
|
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'
|