@chenhw7/dsh-memory 0.1.1 → 0.1.3

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 (65) hide show
  1. package/README.md +65 -16
  2. package/README.zh-CN.md +64 -15
  3. package/cordis.patch.yml +10 -0
  4. package/lib/brand.d.ts +7 -0
  5. package/lib/brand.d.ts.map +1 -1
  6. package/lib/brand.js +7 -0
  7. package/lib/brand.js.map +1 -1
  8. package/lib/client/index.js +826 -0
  9. package/lib/context/conflict.d.ts +59 -0
  10. package/lib/context/conflict.d.ts.map +1 -0
  11. package/lib/context/conflict.js +75 -0
  12. package/lib/context/conflict.js.map +1 -0
  13. package/lib/context/index.d.ts +11 -2
  14. package/lib/context/index.d.ts.map +1 -1
  15. package/lib/context/index.js +36 -9
  16. package/lib/context/index.js.map +1 -1
  17. package/lib/context/policy.d.ts +23 -2
  18. package/lib/context/policy.d.ts.map +1 -1
  19. package/lib/context/policy.js +77 -1
  20. package/lib/context/policy.js.map +1 -1
  21. package/lib/index.d.ts +50 -4
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +22 -3
  24. package/lib/index.js.map +1 -1
  25. package/lib/invariant.d.ts.map +1 -1
  26. package/lib/remote/index.d.ts +146 -0
  27. package/lib/remote/index.d.ts.map +1 -0
  28. package/lib/remote/index.js +257 -0
  29. package/lib/remote/index.js.map +1 -0
  30. package/lib/remote/typert.remote-client.d.ts +75 -0
  31. package/lib/remote/typert.remote-client.js +86 -0
  32. package/lib/remote/types.d.ts +9 -0
  33. package/lib/remote/types.d.ts.map +1 -0
  34. package/lib/remote/types.js +9 -0
  35. package/lib/remote/types.js.map +1 -0
  36. package/lib/review/accumulator.d.ts +18 -5
  37. package/lib/review/accumulator.d.ts.map +1 -1
  38. package/lib/review/accumulator.js +52 -14
  39. package/lib/review/accumulator.js.map +1 -1
  40. package/lib/review/dedup.d.ts +79 -0
  41. package/lib/review/dedup.d.ts.map +1 -0
  42. package/lib/review/dedup.js +171 -0
  43. package/lib/review/dedup.js.map +1 -0
  44. package/lib/review/extract.d.ts +28 -8
  45. package/lib/review/extract.d.ts.map +1 -1
  46. package/lib/review/extract.js +161 -23
  47. package/lib/review/extract.js.map +1 -1
  48. package/lib/review/index.d.ts +10 -0
  49. package/lib/review/index.d.ts.map +1 -1
  50. package/lib/review/index.js +55 -11
  51. package/lib/review/index.js.map +1 -1
  52. package/lib/scanner.d.ts +16 -0
  53. package/lib/scanner.d.ts.map +1 -1
  54. package/lib/scanner.js +25 -2
  55. package/lib/scanner.js.map +1 -1
  56. package/lib/store/index.d.ts +49 -0
  57. package/lib/store/index.d.ts.map +1 -1
  58. package/lib/store/index.js +238 -15
  59. package/lib/store/index.js.map +1 -1
  60. package/lib/tool/index.d.ts.map +1 -1
  61. package/lib/tool/index.js +173 -3
  62. package/lib/tool/index.js.map +1 -1
  63. package/lib/types.d.ts +60 -4
  64. package/lib/types.d.ts.map +1 -1
  65. package/package.json +39 -17
package/README.md CHANGED
@@ -23,10 +23,12 @@ This is a **self-contained single package** (not a multi-package workspace). It
23
23
 
24
24
  Your dsh agent normally forgets everything when you close a session. This bundle fixes that:
25
25
 
26
- - **Persistent memory** — facts, preferences, and conventions stored in a durable KV backend.
26
+ - **Persistent memory** — facts, preferences, and conventions stored in a durable KV backend with audit logging.
27
27
  - **Three-layer scoping** — `global` (cross-project), `project` (per-repo, auto-detected), and `user` (cross-project profile).
28
- - **Six model-facing tools** — `memory_search`, `memory_add`, `memory_replace`, `memory_remove`, `memory_list`, `memory_get`.
28
+ - **Eight model-facing tools** — `memory_search`, `memory_add`, `memory_replace`, `memory_remove`, `memory_list`, `memory_get`, `memory_pin`, `memory_unpin`.
29
29
  - **Automatic learning** — a projection accumulator watches the conversation and extracts candidate memories via lightweight rules, then runs an LLM extraction when enough candidates accumulate.
30
+ - **Dedup pipeline** — two-stage deduplication (token Jaccard prefilter + LLM judge) prevents near-duplicate accumulation.
31
+ - **Memory lifecycle** — pin important memories, auto-decay stale project-scoped entries, and audit every write.
30
32
  - **Compaction-aware flush** — when compaction shadows old context, the raw events are scanned for anything worth remembering.
31
33
  - **Security scanning** — API keys, tokens, prompt-injection patterns, and exfiltration attempts are blocked from being saved.
32
34
  - **Frontend-configurable** — all settings exposed through the dsh settings UI, apply live.
@@ -80,7 +82,7 @@ pnpm dsh plugin add --profile web @chenhw7/dsh-memory
80
82
  To pin a version instead of `latest`:
81
83
 
82
84
  ```sh
83
- dsh plugin add --profile web @chenhw7/dsh-memory@0.1.1
85
+ dsh plugin add --profile web @chenhw7/dsh-memory@0.1.2
84
86
  ```
85
87
 
86
88
  ### From GitHub (bleeding edge)
@@ -94,7 +96,7 @@ dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
94
96
  ```
95
97
 
96
98
  ```text
97
- [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.1"
99
+ [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.2"
98
100
  needs to execute build scripts but is not in the "allowBuilds" allowlist.
99
101
  ...
100
102
  allowBuilds:
@@ -147,8 +149,8 @@ If you'd rather not install from the npm registry, pack a tarball from a checkou
147
149
  ```sh
148
150
  cd dsh-memory
149
151
  npm install && npm run build
150
- npm pack # produces chenhw7-dsh-memory-0.1.1.tgz
151
- dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.1.tgz
152
+ npm pack # produces chenhw7-dsh-memory-0.1.2.tgz
153
+ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.2.tgz
152
154
  ```
153
155
 
154
156
  ## Uninstall
@@ -159,7 +161,7 @@ Remove the plugin from a profile:
159
161
  dsh plugin remove --profile web @chenhw7/dsh-memory
160
162
  ```
161
163
 
162
- (with a source checkout: `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory` from the `deepseek-harness` directory). This runs `pnpm remove` in the profile directory and reconciles the layer list, so the four `memory-*` rows disappear from the composed config — you can confirm with the `--dump-config` check below.
164
+ (with a source checkout: `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory` from the `deepseek-harness` directory). This runs `pnpm remove` in the profile directory and reconciles the layer list, so the six `memory-*` rows disappear from the composed config — you can confirm with the `--dump-config` check below.
163
165
 
164
166
  Uninstall does **not** delete your saved memories. They live in one file under dsh's storage area:
165
167
 
@@ -175,7 +177,7 @@ Stop dsh, then delete that file to wipe all saved memories. Other files in the s
175
177
 
176
178
  ## Verify
177
179
 
178
- After install, confirm the four memory rows are in the composed profile tree:
180
+ After install, confirm the six memory rows are in the composed profile tree:
179
181
 
180
182
  ```sh
181
183
  # Windows
@@ -184,9 +186,11 @@ dsh --profile web --dump-config | findstr memory
184
186
  dsh --profile web --dump-config | grep memory
185
187
  ```
186
188
 
187
- You should see four rows pointing at `@chenhw7/dsh-memory/*`:
189
+ You should see six rows pointing at `@chenhw7/dsh-memory/*`:
188
190
 
189
191
  ```
192
+ - id: memory-root
193
+ name: '@chenhw7/dsh-memory'
190
194
  - id: memory-store
191
195
  name: '@chenhw7/dsh-memory/store'
192
196
  - id: tool-memory
@@ -195,6 +199,8 @@ You should see four rows pointing at `@chenhw7/dsh-memory/*`:
195
199
  name: '@chenhw7/dsh-memory/review'
196
200
  - id: memory-context
197
201
  name: '@chenhw7/dsh-memory/context'
202
+ - id: memory-remote
203
+ name: '@chenhw7/dsh-memory/remote-service'
198
204
  ```
199
205
 
200
206
  Then start dsh and check the settings UI shows the `memory` namespace:
@@ -211,7 +217,7 @@ If a **git-hosted** install (`dsh plugin add ... https://github.com/...`) fails
211
217
 
212
218
  ```text
213
219
  [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] Failed to prepare git-hosted package ...
214
- The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build scripts but is not in the "allowBuilds" allowlist.
220
+ The git-hosted package "@chenhw7/dsh-memory@0.1.2" needs to execute build scripts but is not in the "allowBuilds" allowlist.
215
221
  ```
216
222
 
217
223
  It means pnpm has not been told to allow this package's `prepare` build script.
@@ -237,7 +243,7 @@ All settings are editable from the dsh frontend settings page (the `memory` name
237
243
 
238
244
  | Setting | Default | Meaning |
239
245
  |---|---|---|
240
- | `memoryMode` | `policy-only` | `full`: inject memory content + guidance. `policy-only`: inject guidance only, model searches on demand. `custom`: inject user-defined policy text. `off`: no injection. |
246
+ | `memoryMode` | `policy-only` | `full`: inject memory content + guidance. `policy-only`: inject guidance only, model searches on demand. `custom`: inject user-defined policy text. `off`: no injection. `index`: inject an existence index (one line per entry) so the model can see what is stored and route to `memory_get`/`memory_search`. |
241
247
  | `memoryPolicyCustomText` | — | Custom policy text used when `memoryMode` is `custom`. |
242
248
  | `reviewEnabled` | `true` | Enable automatic periodic review extraction. |
243
249
  | `reviewCandidateThreshold` | `10` | Number of candidate messages before an LLM extraction runs. |
@@ -245,7 +251,48 @@ All settings are editable from the dsh frontend settings page (the `memory` name
245
251
  | `flushOnDispose` | `true` | Extract remaining context when a session is disposed. |
246
252
  | `memoryCharLimit` | `5000` | Per-scope character limit for injected memory content. |
247
253
 
248
- Example `$DSH_HOME/settings.yaml`:
254
+ ### Extraction & Dedup Settings
255
+
256
+ These settings control the automatic extraction pipeline and the dedup judge. They live in the `memory-review` plugin config (set via the composition layer, not the `memory` settings namespace):
257
+
258
+ | Setting | Default | Meaning |
259
+ |---|---|---|
260
+ | `extractionModelProvider` | `""` (session route) | Override the LLM provider for extraction/judge calls. Empty = use the session's conversational model (the default — extraction reuses the same model the user is chatting with, no extra keys or billing channel). |
261
+ | `extractionModelModel` | `""` (session route) | Override the model name for extraction/judge calls. Empty = use the session's conversational model. Set both fields to route extraction to a cheaper/faster model. |
262
+ | `extractionBudget` | `20` | Max extraction + judge calls per session. `0` = unlimited. |
263
+ | `judgeEnabled` | `true` | Run the LLM dedup judge on prefilter hits. When `false`, prefilter hits merge directly (cheaper, but may false-merge same-template different-topic pairs). |
264
+ | `decayDays` | `30` | Auto-decay project-scoped entries not recalled within N days. `0` = disabled. Pinned, `global`, and `user` entries are never decayed. |
265
+
266
+ ### Tool Settings
267
+
268
+ These settings control the model-facing tools. They live in the `tool-memory` plugin config (set via the composition layer, not the `memory` settings namespace):
269
+
270
+ | Setting | Default | Meaning |
271
+ |---|---|---|
272
+ | `maxSearchResults` | `50` | Maximum number of entries returned by `memory_search`. `0` = no limit. |
273
+
274
+ Example composition config:
275
+
276
+ ```yaml
277
+ tool-memory:
278
+ config:
279
+ maxSearchResults: 100
280
+ ```
281
+
282
+ By default, extraction and the dedup judge use the **same model the user is chatting with** — the session's provider/model route. To run them on a dedicated cheaper model, set `extractionModelProvider` and `extractionModelModel` in the review plugin's composition config.
283
+
284
+ Example composition config for a dedicated extraction model:
285
+
286
+ ```yaml
287
+ memory-review:
288
+ config:
289
+ extractionModelProvider: deepseek
290
+ extractionModelModel: deepseek-chat
291
+ extractionBudget: 20
292
+ judgeEnabled: true
293
+ ```
294
+
295
+ Example `$DSH_HOME/settings.yaml` (memory namespace):
249
296
 
250
297
  ```yaml
251
298
  memory:
@@ -284,14 +331,16 @@ memory:
284
331
 
285
332
  ## Architecture
286
333
 
287
- The bundle inserts four rows over `dsh-base`, each pointing at this package's own export sub-path:
334
+ The bundle inserts six rows over `dsh-base`, each pointing at this package's own export sub-path:
288
335
 
289
336
  | Row | Export | Role |
290
337
  |---|---|---|
338
+ | `memory-root` | `@chenhw7/dsh-memory` | No-op root entry for client-module scanner discovery |
291
339
  | `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain, registers `ctx.memory` |
292
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | Six model-facing tools |
293
- | `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + flush) |
340
+ | `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools |
341
+ | `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + flush + dedup + janitor) |
294
342
  | `memory-context` | `@chenhw7/dsh-memory/context` | System-prompt injection + settings namespace |
343
+ | `memory-remote` | `@chenhw7/dsh-memory/remote-service` | `@Remote` service for memory management UI |
295
344
 
296
345
  **Storage**: this bundle does **not** insert `storage-json` / `storage-domain` rows. The `dsh-web-app` bundle already provides them (with the correct root path under `$DSH_HOME/storages`). Inserting them here would clobber that config (patches replace whole rows, last-write-wins). The memory store provider consumes the `storageDomain` service as a peer dependency.
297
346
 
@@ -312,7 +361,7 @@ The bundle inserts four rows over `dsh-base`, each pointing at this package's ow
312
361
 
313
362
  ## Known Limitations
314
363
 
315
- - **No semantic/vector retrieval** — `memory_search` is substring matching over structured KV entries, not embeddings.
364
+ - **No semantic/vector retrieval** — `memory_search` is token-based lexical matching (CJK per-character + Latin word tokens) over structured KV entries, not embeddings.
316
365
  - **Extraction quality tracks the session model** — review/flush reuse the session's routed provider/model.
317
366
  - **git install needs a build allowance** — pnpm blocks the git dependency's `prepare` script until you allow it in the profile's `pnpm-workspace.yaml` (two-step procedure above). The npm install path avoids this entirely.
318
367
  - **dsh is in developer preview** — breaking changes are expected; this bundle's peer dependency ranges track the dsh release line.
package/README.zh-CN.md CHANGED
@@ -20,10 +20,12 @@
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`。
25
+ - **八个模型可用工具** — `memory_search`、`memory_add`、`memory_replace`、`memory_remove`、`memory_list`、`memory_get`、`memory_pin`、`memory_unpin`。
26
26
  - **自动学习** — 投影累加器观察对话,并通过轻量规则提取候选记忆;当候选足够多时,运行 LLM 提取。
27
+ - **去重管线** — 两阶段去重(分词 Jaccard 预过滤 + LLM 判定),防止近似重复条目累积。
28
+ - **记忆生命周期** — 固定重要记忆、自动衰减过期的 project 作用域条目、审计每次写入。
27
29
  - **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
28
30
  - **安全扫描** — 阻止 API Key、Token、提示注入模式和泄露尝试被写入记忆。
29
31
  - **前端可配置** — 所有设置都通过 dsh 设置界面暴露,实时生效。
@@ -78,7 +80,7 @@ pnpm dsh plugin add --profile web @chenhw7/dsh-memory
78
80
  需要锁定版本而不跟 `latest` 时:
79
81
 
80
82
  ```sh
81
- dsh plugin add --profile web @chenhw7/dsh-memory@0.1.1
83
+ dsh plugin add --profile web @chenhw7/dsh-memory@0.1.2
82
84
  ```
83
85
 
84
86
  ### 从 GitHub 安装(尝鲜最新 commit)
@@ -92,7 +94,7 @@ dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
92
94
  ```
93
95
 
94
96
  ```text
95
- [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.1"
97
+ [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.2"
96
98
  needs to execute build scripts but is not in the "allowBuilds" allowlist.
97
99
  ...
98
100
  allowBuilds:
@@ -143,8 +145,8 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
143
145
  ```sh
144
146
  cd dsh-memory
145
147
  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
148
+ npm pack # 生成 chenhw7-dsh-memory-0.1.2.tgz
149
+ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.2.tgz
148
150
  ```
149
151
 
150
152
  ## 卸载
@@ -155,7 +157,7 @@ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.1.tgz
155
157
  dsh plugin remove --profile web @chenhw7/dsh-memory
156
158
  ```
157
159
 
158
- (源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,四个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
160
+ (源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,六个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
159
161
 
160
162
  卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下的一个文件里:
161
163
 
@@ -171,7 +173,7 @@ dsh plugin remove --profile web @chenhw7/dsh-memory
171
173
 
172
174
  ## 验证
173
175
 
174
- 安装后,确认组合后的 profile 树中包含四个 memory 行:
176
+ 安装后,确认组合后的 profile 树中包含六个 memory 行:
175
177
 
176
178
  ```sh
177
179
  # Windows
@@ -180,9 +182,11 @@ dsh --profile web --dump-config | findstr memory
180
182
  dsh --profile web --dump-config | grep memory
181
183
  ```
182
184
 
183
- 你应该看到四个指向 `@chenhw7/dsh-memory/*` 的行:
185
+ 你应该看到六个指向 `@chenhw7/dsh-memory/*` 的行:
184
186
 
185
187
  ```
188
+ - id: memory-root
189
+ name: '@chenhw7/dsh-memory'
186
190
  - id: memory-store
187
191
  name: '@chenhw7/dsh-memory/store'
188
192
  - id: tool-memory
@@ -191,6 +195,8 @@ dsh --profile web --dump-config | grep memory
191
195
  name: '@chenhw7/dsh-memory/review'
192
196
  - id: memory-context
193
197
  name: '@chenhw7/dsh-memory/context'
198
+ - id: memory-remote
199
+ name: '@chenhw7/dsh-memory/remote-service'
194
200
  ```
195
201
 
196
202
  然后启动 dsh,检查设置界面是否显示 `memory` 命名空间:
@@ -205,7 +211,7 @@ dsh web
205
211
 
206
212
  | 设置 | 默认值 | 说明 |
207
213
  |---|---|---|
208
- | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入。 |
214
+ | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
209
215
  | `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
210
216
  | `reviewEnabled` | `true` | 启用自动周期性 review 提取。 |
211
217
  | `reviewCandidateThreshold` | `10` | 触发 LLM 提取前的候选消息数。 |
@@ -213,6 +219,47 @@ dsh web
213
219
  | `flushOnDispose` | `true` | 会话销毁时提取剩余上下文。 |
214
220
  | `memoryCharLimit` | `5000` | 每个作用域注入记忆内容的字符上限。 |
215
221
 
222
+ ### 提取与去重设置
223
+
224
+ 以下设置控制自动提取管线和去重裁决,位于 `memory-review` 插件配置中(通过组合层设置,不在 `memory` 设置命名空间里):
225
+
226
+ | 设置 | 默认值 | 说明 |
227
+ |---|---|---|
228
+ | `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
229
+ | `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
230
+ | `extractionBudget` | `20` | 每会话最大提取 + 裁决调用次数。`0` = 无限。 |
231
+ | `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
232
+ | `decayDays` | `30` | 自动衰减 N 天内未召回的 project 作用域条目。`0` = 禁用。固定的、`global` 和 `user` 条目永不衰减。 |
233
+
234
+ ### 工具设置
235
+
236
+ 以下设置控制模型可用工具,位于 `tool-memory` 插件配置中(通过组合层设置,不在 `memory` 设置命名空间里):
237
+
238
+ | 设置 | 默认值 | 说明 |
239
+ |---|---|---|
240
+ | `maxSearchResults` | `50` | `memory_search` 返回的最大条目数。`0` = 无限制。 |
241
+
242
+ 组合配置示例:
243
+
244
+ ```yaml
245
+ tool-memory:
246
+ config:
247
+ maxSearchResults: 100
248
+ ```
249
+
250
+ 默认情况下,提取和去重裁决使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,在 review 插件的组合配置中设置 `extractionModelProvider` 和 `extractionModelModel`。
251
+
252
+ 专用提取模型的组合配置示例:
253
+
254
+ ```yaml
255
+ memory-review:
256
+ config:
257
+ extractionModelProvider: deepseek
258
+ extractionModelModel: deepseek-chat
259
+ extractionBudget: 20
260
+ judgeEnabled: true
261
+ ```
262
+
216
263
  `$DSH_HOME/settings.yaml` 配置示例:
217
264
 
218
265
  ```yaml
@@ -252,14 +299,16 @@ memory:
252
299
 
253
300
  ## 架构
254
301
 
255
- 该 bundle 在 `dsh-base` 之上插入四行,每行指向本包自己的导出子路径:
302
+ 该 bundle 在 `dsh-base` 之上插入六行,每行指向本包自己的导出子路径:
256
303
 
257
304
  | 行 | 导出 | 作用 |
258
305
  |---|---|---|
306
+ | `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
259
307
  | `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory` |
260
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | 六个模型可用工具 |
261
- | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush) |
308
+ | `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具 |
309
+ | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush + 去重 + janitor) |
262
310
  | `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入 + 设置命名空间 |
311
+ | `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务 |
263
312
 
264
313
  **存储**:本 bundle **不**插入 `storage-json` / `storage-domain` 行。`dsh-web-app` bundle 已经提供它们(并在 `$DSH_HOME/storages` 下使用正确的根路径)。如果在这里重复插入,会覆盖已有配置(patch 会替换整行,后写覆盖先写)。memory store provider 将 `storageDomain` 服务作为 peer dependency 使用。
265
314
 
@@ -286,7 +335,7 @@ memory:
286
335
 
287
336
  ```text
288
337
  [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] Failed to prepare git-hosted package ...
289
- The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build scripts but is not in the "allowBuilds" allowlist.
338
+ The git-hosted package "@chenhw7/dsh-memory@0.1.2" needs to execute build scripts but is not in the "allowBuilds" allowlist.
290
339
  ```
291
340
 
292
341
  说明 pnpm 还没有被允许执行该包的 `prepare` 构建脚本。
@@ -307,7 +356,7 @@ The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build script
307
356
 
308
357
  ## 已知限制
309
358
 
310
- - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的子串匹配,不是 embeddings。
359
+ - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的分词词法匹配(CJK 逐字 + Latin 逐词),不是 embeddings。
311
360
  - **提取质量跟随会话模型** — review/flush 复用会话当前路由的 provider/model。
312
361
  - **git 安装需要构建允许** — pnpm 会阻止 git 依赖的 `prepare` 脚本,直到你在 profile 的 `pnpm-workspace.yaml` 中允许它(见上文两步流程)。npm 安装路径则完全不需要。
313
362
  - **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
package/cordis.patch.yml CHANGED
@@ -13,6 +13,12 @@
13
13
  # Row order carries no load semantics; the grouping is for readers.
14
14
 
15
15
  - insert:
16
+ # Root entry: lets the host client-module scanner discover dsh.client.
17
+ # No host-side code runs; this is a no-op plugin that exists solely so
18
+ # the scanner can resolve this package's package.json from a root spec.
19
+ - id: memory-root
20
+ name: '@chenhw7/dsh-memory'
21
+
16
22
  # Memory store provider — opens the 'memory' domain, registers ctx.memory.
17
23
  # Requires the storage-domain facility (provided by dsh-web-app; headless
18
24
  # users must add storage-domain themselves — see README).
@@ -30,3 +36,7 @@
30
36
  # System-prompt section injection + frontend settings namespace.
31
37
  - id: memory-context
32
38
  name: '@chenhw7/dsh-memory/context'
39
+
40
+ # @Remote service for the memory management UI (§3.8).
41
+ - id: memory-remote
42
+ name: '@chenhw7/dsh-memory/remote-service'
package/lib/brand.d.ts CHANGED
@@ -7,4 +7,11 @@ export type MemoryId = Branded<'MemoryId'>;
7
7
  * @returns a fresh branded id.
8
8
  */
9
9
  export declare function MemoryId(id?: string): MemoryId;
10
+ /** Identifies one audit-record entry in the audit table. */
11
+ export type AuditId = Branded<'AuditId'>;
12
+ /**
13
+ * Mint a new unique audit id.
14
+ * @returns a fresh branded id.
15
+ */
16
+ export declare function AuditId(id?: string): AuditId;
10
17
  //# sourceMappingURL=brand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGrD,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,GAAE,MAAqB,GAAG,QAAQ,CAE5D"}
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGrD,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,GAAE,MAAqB,GAAG,QAAQ,CAE5D;AAED,4DAA4D;AAC5D,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAExC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAE,MAAqB,GAAG,OAAO,CAE1D"}
package/lib/brand.js CHANGED
@@ -7,4 +7,11 @@ import { randomUUID } from 'node:crypto';
7
7
  export function MemoryId(id = randomUUID()) {
8
8
  return id;
9
9
  }
10
+ /**
11
+ * Mint a new unique audit id.
12
+ * @returns a fresh branded id.
13
+ */
14
+ export function AuditId(id = randomUUID()) {
15
+ return id;
16
+ }
10
17
  //# sourceMappingURL=brand.js.map
package/lib/brand.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"brand.js","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,UAAU,EAAE;IAChD,OAAO,EAAc,CAAA;AACvB,CAAC"}
1
+ {"version":3,"file":"brand.js","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,GAAW,UAAU,EAAE;IAChD,OAAO,EAAc,CAAA;AACvB,CAAC;AAKD;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,GAAW,UAAU,EAAE;IAC/C,OAAO,EAAa,CAAA;AACtB,CAAC"}