@chenhw7/dsh-memory 0.1.3 → 0.4.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 +102 -120
- package/README.zh-CN.md +104 -119
- package/cordis.patch.yml +13 -8
- package/lib/client/index.js +1591 -195
- 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/remote/index.d.ts +31 -4
- package/lib/remote/index.d.ts.map +1 -1
- package/lib/remote/index.js +44 -7
- package/lib/remote/index.js.map +1 -1
- package/lib/remote/typert.remote-client.d.ts +7 -2
- package/lib/remote/typert.remote-client.js +8 -2
- 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 +44 -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,16 @@
|
|
|
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 设置界面的四张卡片暴露,实时生效。
|
|
35
|
+
- **记忆管理中心(一期只读)** — dsh 设置界面新增独立「记忆」区,可浏览整个 web profile 的记忆库:健康仪表盘、作用域与工作区筛选、BM25 搜索、类别筛选、远程分页与软衰减标记,中英双语。
|
|
32
36
|
|
|
33
37
|
## 安装
|
|
34
38
|
|
|
@@ -77,54 +81,12 @@ dsh plugin add --profile web @chenhw7/dsh-memory
|
|
|
77
81
|
pnpm dsh plugin add --profile web @chenhw7/dsh-memory
|
|
78
82
|
```
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
需要锁定特定版本时:
|
|
81
85
|
|
|
82
86
|
```sh
|
|
83
|
-
dsh plugin add --profile web @chenhw7/dsh-memory@0.
|
|
87
|
+
dsh plugin add --profile web @chenhw7/dsh-memory@0.4.0
|
|
84
88
|
```
|
|
85
89
|
|
|
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
90
|
### 从本地 checkout 安装
|
|
129
91
|
|
|
130
92
|
如果你想修改插件,先 clone 并构建,再从本地路径安装:
|
|
@@ -145,8 +107,24 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
|
|
|
145
107
|
```sh
|
|
146
108
|
cd dsh-memory
|
|
147
109
|
npm install && npm run build
|
|
148
|
-
npm pack # 生成 chenhw7-dsh-memory-0.
|
|
149
|
-
dsh plugin add --profile web ./chenhw7-dsh-memory-0.
|
|
110
|
+
npm pack # 生成 chenhw7-dsh-memory-0.4.0.tgz
|
|
111
|
+
dsh plugin add --profile web ./chenhw7-dsh-memory-0.4.0.tgz
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 更新
|
|
115
|
+
|
|
116
|
+
`dsh plugin add` 在**全新** profile 上始终从 npm 安装最新版。但一旦已安装某个版本,再次运行 `dsh plugin add` **不会**更新——pnpm 发现已有的版本范围(如 `^0.2.0`)已被最新版(如 `0.2.1`)满足,就跳过更新了。
|
|
117
|
+
|
|
118
|
+
要更新到最新发布版本:
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
dsh plugin --profile web update @chenhw7/dsh-memory
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
源码构建的 dsh:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
pnpm dsh plugin --profile web update @chenhw7/dsh-memory
|
|
150
128
|
```
|
|
151
129
|
|
|
152
130
|
## 卸载
|
|
@@ -157,7 +135,7 @@ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.2.tgz
|
|
|
157
135
|
dsh plugin remove --profile web @chenhw7/dsh-memory
|
|
158
136
|
```
|
|
159
137
|
|
|
160
|
-
(源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove`
|
|
138
|
+
(源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,七个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
|
|
161
139
|
|
|
162
140
|
卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下的一个文件里:
|
|
163
141
|
|
|
@@ -173,7 +151,7 @@ dsh plugin remove --profile web @chenhw7/dsh-memory
|
|
|
173
151
|
|
|
174
152
|
## 验证
|
|
175
153
|
|
|
176
|
-
安装后,确认组合后的 profile
|
|
154
|
+
安装后,确认组合后的 profile 树中包含七个 memory 行:
|
|
177
155
|
|
|
178
156
|
```sh
|
|
179
157
|
# Windows
|
|
@@ -182,7 +160,7 @@ dsh --profile web --dump-config | findstr memory
|
|
|
182
160
|
dsh --profile web --dump-config | grep memory
|
|
183
161
|
```
|
|
184
162
|
|
|
185
|
-
|
|
163
|
+
你应该看到七个指向 `@chenhw7/dsh-memory/*` 的行:
|
|
186
164
|
|
|
187
165
|
```
|
|
188
166
|
- id: memory-root
|
|
@@ -193,6 +171,8 @@ dsh --profile web --dump-config | grep memory
|
|
|
193
171
|
name: '@chenhw7/dsh-memory/tool'
|
|
194
172
|
- id: memory-review
|
|
195
173
|
name: '@chenhw7/dsh-memory/review'
|
|
174
|
+
- id: memory-notes
|
|
175
|
+
name: '@chenhw7/dsh-memory/notes'
|
|
196
176
|
- id: memory-context
|
|
197
177
|
name: '@chenhw7/dsh-memory/context'
|
|
198
178
|
- id: memory-remote
|
|
@@ -207,70 +187,101 @@ dsh web
|
|
|
207
187
|
|
|
208
188
|
## 配置
|
|
209
189
|
|
|
210
|
-
|
|
190
|
+
本 bundle 拥有**两个设置命名空间**,在「设置 → 插件 → 插件配置」中显示为四张卡片,且**全部实时生效**——改动在下一次事件或调用时即生效,无需重启:
|
|
191
|
+
|
|
192
|
+
- **`memory`**(卡片:*Memory*、*Project Notes*、*Auto Recall*)——注入模式、字符预算、生命周期、项目笔记、自动召回。由 `memory-context` 持有。
|
|
193
|
+
- **`memory-review`**(卡片:*Automatic Extraction*)——提取管线、模型路由、去重裁决、失败序列踩坑、curator pass。由 `memory-review` 插件持有。
|
|
194
|
+
|
|
195
|
+
每个命名空间按分层 resolve:schema 默认 → 组合 `config:` 条目(base)→ `$DSH_HOME/settings.yaml` 中的用户文档。用户层缺失的字段继承组合值,因此部署可以固定默认值,用户只覆盖所需部分。当无 settings 服务挂载时(如 headless profile),各插件回退到组合条目,行为与组合配置完全一致。
|
|
196
|
+
|
|
197
|
+
### `memory` 命名空间
|
|
211
198
|
|
|
212
199
|
| 设置 | 默认值 | 说明 |
|
|
213
200
|
|---|---|---|
|
|
214
201
|
| `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
|
|
215
202
|
| `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
-
| `
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
203
|
+
| `memoryCharLimit` | `5000` | 会话内冻结记忆快照注入 `full` 模式时的字符预算(`0` = 不注入内容)。 |
|
|
204
|
+
| `maxSearchResults` | `50` | `memory_search` / `memory_list` 在调用未传 `limit` 时的默认返回条数上限,由工具插件实时读取。`0` = 无限制。 |
|
|
205
|
+
| `decayDays` | `30` | N 天内未召回条目的生命周期窗口,由 review 插件的 janitor 实时读取。`0` = 禁用。过期的 `project` 条目被**移除**(硬衰减);过期的 `global`/`user` 条目改为**软衰减**——打上 `stale` 戳,从注入面和笔记文件中隐藏但仍可搜索,再次召回即自动解除。固定(pin)条目始终豁免。 |
|
|
206
|
+
| `notesEnabled` | `true` | 启用项目笔记的仓库内文件导出与 system prompt 注入。已渲染进笔记文件的条目会从 memory 段落中排除,避免重复注入。 |
|
|
207
|
+
| `notesDir` | `docs/agent-memory` | 仓库内生成 `CONVENTIONS.md` / `PITFALLS.md` 的目录。 |
|
|
208
|
+
| `notesCharLimit` | `4000` | 注入的 `project-notes` 段落字符上限。 |
|
|
209
|
+
| `notesAgentsPointer` | `true` | 维护仓库 `AGENTS.md` 中的托管指针块。 |
|
|
210
|
+
| `notesMaxEntriesPerFile` | `100` | 每个生成笔记文件的最大条目数(保留最新)。 |
|
|
211
|
+
| `autoRecallEnabled` | `false` | 步级自动召回:每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息。不触碰 system prompt,保持 KV-cache 前缀稳定。 |
|
|
212
|
+
| `autoRecallLimit` | `5` | 单次自动召回围栏内的最大条数(最小 1)。围栏本身上限 1200 字符。 |
|
|
213
|
+
| `autoRecallMinChars` | `12` | 该步用户文本短于该字符数时跳过召回(最小 1)。 |
|
|
214
|
+
|
|
215
|
+
### `memory-review` 命名空间
|
|
225
216
|
|
|
226
217
|
| 设置 | 默认值 | 说明 |
|
|
227
218
|
|---|---|---|
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
219
|
+
| `reviewEnabled` | `true` | 启用自动周期性 review 提取。 |
|
|
220
|
+
| `reviewCandidateThreshold` | `10` | 触发一次提取 drain 所需的未处理候选信号数(最小 1)。 |
|
|
221
|
+
| `flushOnCompaction` | `true` | 压缩后从被遮蔽的事件中提取记忆。 |
|
|
222
|
+
| `flushOnDispose` | `true` | 会话销毁时提取剩余上下文(5 秒上限)。 |
|
|
223
|
+
| `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决/curator 调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
|
|
224
|
+
| `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决/curator 调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
|
|
225
|
+
| `extractionBudget` | `20` | 每会话 LLM 调用配额,由 review drain、两种 flush 和 curator pass 共享。`0` = 无限。 |
|
|
231
226
|
| `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
|
|
232
|
-
| `
|
|
227
|
+
| `pitfallStreakThreshold` | `2` | 判定踩坑所需的同签名连续失败次数(最终被一次成功解决后才发出一条结构化踩坑候选,提取进笔记文件)。一次性失败不提取。 |
|
|
228
|
+
| `curatorEnabled` | `true` | 低频 curator pass:每 `curatorEveryNSessions` 次会话创建,把最长的超长条目交给提取模型改写为简洁单行(受预算约束)。 |
|
|
229
|
+
| `curatorEveryNSessions` | `20` | 每 N 次会话创建运行一次 curator pass。 |
|
|
230
|
+
| `curatorMaxEntries` | `5` | 每次 curation 最多选中的条目数(最长优先)。 |
|
|
231
|
+
| `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
|
|
233
232
|
|
|
234
|
-
|
|
233
|
+
> 特意**没有独立的 `tool-memory` 设置命名空间**:工具插件从上面的 `memory` 命名空间实时读取 `maxSearchResults`。其组合配置 `config.maxSearchResults` 仅作为无 settings 服务挂载时的回退 base。
|
|
235
234
|
|
|
236
|
-
|
|
235
|
+
### 组合配置与 UI 设置
|
|
237
236
|
|
|
238
|
-
|
|
239
|
-
|---|---|---|
|
|
240
|
-
| `maxSearchResults` | `50` | `memory_search` 返回的最大条目数。`0` = 无限制。 |
|
|
241
|
-
|
|
242
|
-
组合配置示例:
|
|
237
|
+
两个命名空间均接受来自两个层的相同键。组合 `config:` 条目设置 base;UI 在其上写入用户层。例如,要把 `maxSearchResults: 100` 钉为部署默认值(用户仍可覆盖):
|
|
243
238
|
|
|
244
239
|
```yaml
|
|
245
|
-
|
|
240
|
+
memory:
|
|
246
241
|
config:
|
|
247
242
|
maxSearchResults: 100
|
|
248
243
|
```
|
|
249
244
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
专用提取模型的组合配置示例:
|
|
245
|
+
默认情况下,提取、去重裁决和 curation 使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,设置 `extractionModelProvider` 和 `extractionModelModel`(在组合配置或 UI 中均可——UI 提供由宿主模型目录驱动的下拉框):
|
|
253
246
|
|
|
254
247
|
```yaml
|
|
255
248
|
memory-review:
|
|
256
249
|
config:
|
|
257
250
|
extractionModelProvider: deepseek
|
|
258
251
|
extractionModelModel: deepseek-chat
|
|
259
|
-
extractionBudget: 20
|
|
260
|
-
judgeEnabled: true
|
|
261
252
|
```
|
|
262
253
|
|
|
263
|
-
`$DSH_HOME/settings.yaml`
|
|
254
|
+
`$DSH_HOME/settings.yaml` 示例(两个命名空间):
|
|
264
255
|
|
|
265
256
|
```yaml
|
|
266
257
|
memory:
|
|
267
258
|
memoryMode: policy-only
|
|
268
259
|
memoryPolicyCustomText: ""
|
|
260
|
+
memoryCharLimit: 5000
|
|
261
|
+
maxSearchResults: 50
|
|
262
|
+
decayDays: 30
|
|
263
|
+
notesEnabled: true
|
|
264
|
+
notesDir: docs/agent-memory
|
|
265
|
+
notesCharLimit: 4000
|
|
266
|
+
notesAgentsPointer: true
|
|
267
|
+
notesMaxEntriesPerFile: 100
|
|
268
|
+
autoRecallEnabled: false
|
|
269
|
+
autoRecallLimit: 5
|
|
270
|
+
autoRecallMinChars: 12
|
|
271
|
+
memory-review:
|
|
269
272
|
reviewEnabled: true
|
|
270
273
|
reviewCandidateThreshold: 10
|
|
271
274
|
flushOnCompaction: true
|
|
272
275
|
flushOnDispose: true
|
|
273
|
-
|
|
276
|
+
extractionModelProvider: ""
|
|
277
|
+
extractionModelModel: ""
|
|
278
|
+
extractionBudget: 20
|
|
279
|
+
judgeEnabled: true
|
|
280
|
+
pitfallStreakThreshold: 2
|
|
281
|
+
curatorEnabled: true
|
|
282
|
+
curatorEveryNSessions: 20
|
|
283
|
+
curatorMaxEntries: 5
|
|
284
|
+
curatorMinChars: 400
|
|
274
285
|
```
|
|
275
286
|
|
|
276
287
|
`memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
|
|
@@ -299,16 +310,17 @@ memory:
|
|
|
299
310
|
|
|
300
311
|
## 架构
|
|
301
312
|
|
|
302
|
-
该 bundle 在 `dsh-base`
|
|
313
|
+
该 bundle 在 `dsh-base` 之上插入七行,每行指向本包自己的导出子路径:
|
|
303
314
|
|
|
304
315
|
| 行 | 导出 | 作用 |
|
|
305
316
|
|---|---|---|
|
|
306
317
|
| `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
|
|
307
|
-
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory
|
|
318
|
+
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory`(BM25 检索 + 两层衰减) |
|
|
308
319
|
| `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具 |
|
|
309
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush + 去重 + janitor
|
|
310
|
-
| `memory-
|
|
311
|
-
| `memory-
|
|
320
|
+
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator),持有 `memory-review` 设置命名空间 |
|
|
321
|
+
| `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 + 原子写 + AGENTS.md 指针),注册 `ctx.projectNotes` |
|
|
322
|
+
| `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入(`memory` @90 + `project-notes` @91)、步级自动召回,持有 `memory` 设置命名空间 |
|
|
323
|
+
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务(设置「记忆」区经 `/api` 通道消费) |
|
|
312
324
|
|
|
313
325
|
**存储**:本 bundle **不**插入 `storage-json` / `storage-domain` 行。`dsh-web-app` bundle 已经提供它们(并在 `$DSH_HOME/storages` 下使用正确的根路径)。如果在这里重复插入,会覆盖已有配置(patch 会替换整行,后写覆盖先写)。memory store provider 将 `storageDomain` 服务作为 peer dependency 使用。
|
|
314
326
|
|
|
@@ -327,38 +339,11 @@ memory:
|
|
|
327
339
|
backend: json
|
|
328
340
|
```
|
|
329
341
|
|
|
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
342
|
## 已知限制
|
|
358
343
|
|
|
359
|
-
- **无语义/向量检索** — `memory_search` 是对结构化 KV
|
|
360
|
-
- **提取质量跟随会话模型** — review/flush 复用会话当前路由的 provider/model
|
|
361
|
-
-
|
|
344
|
+
- **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的 BM25 词法排序(Latin 逐词、CJK 一元 + 二元分词),不是 embeddings;不含相同词元的同义表述无法命中。
|
|
345
|
+
- **提取质量跟随会话模型** — review/flush/curator 复用会话当前路由的 provider/model,除非显式覆盖。
|
|
346
|
+
- **会话中途的提取在下次压缩或新会话前不会出现在提示里** — 注入快照为 KV-cache 稳定性而冻结;步级自动召回(可选)提供逐步新鲜度。
|
|
362
347
|
- **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
|
|
363
348
|
|
|
364
349
|
## 许可证
|
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'
|