@chenhw7/dsh-memory 0.1.2 → 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 (3) hide show
  1. package/README.md +39 -14
  2. package/README.zh-CN.md +39 -14
  3. package/package.json +1 -1
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.
@@ -255,6 +261,23 @@ These settings control the automatic extraction pipeline and the dedup judge. Th
255
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. |
256
262
  | `extractionBudget` | `20` | Max extraction + judge calls per session. `0` = unlimited. |
257
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
+ ```
258
281
 
259
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.
260
283
 
@@ -308,14 +331,16 @@ memory:
308
331
 
309
332
  ## Architecture
310
333
 
311
- 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:
312
335
 
313
336
  | Row | Export | Role |
314
337
  |---|---|---|
338
+ | `memory-root` | `@chenhw7/dsh-memory` | No-op root entry for client-module scanner discovery |
315
339
  | `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain, registers `ctx.memory` |
316
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | Six model-facing tools |
317
- | `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) |
318
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 |
319
344
 
320
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.
321
346
 
@@ -336,7 +361,7 @@ The bundle inserts four rows over `dsh-base`, each pointing at this package's ow
336
361
 
337
362
  ## Known Limitations
338
363
 
339
- - **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.
340
365
  - **Extraction quality tracks the session model** — review/flush reuse the session's routed provider/model.
341
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.
342
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` 命名空间:
@@ -223,6 +229,23 @@ dsh web
223
229
  | `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
224
230
  | `extractionBudget` | `20` | 每会话最大提取 + 裁决调用次数。`0` = 无限。 |
225
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
+ ```
226
249
 
227
250
  默认情况下,提取和去重裁决使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,在 review 插件的组合配置中设置 `extractionModelProvider` 和 `extractionModelModel`。
228
251
 
@@ -276,14 +299,16 @@ memory:
276
299
 
277
300
  ## 架构
278
301
 
279
- 该 bundle 在 `dsh-base` 之上插入四行,每行指向本包自己的导出子路径:
302
+ 该 bundle 在 `dsh-base` 之上插入六行,每行指向本包自己的导出子路径:
280
303
 
281
304
  | 行 | 导出 | 作用 |
282
305
  |---|---|---|
306
+ | `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
283
307
  | `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory` |
284
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | 六个模型可用工具 |
285
- | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush) |
308
+ | `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具 |
309
+ | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + flush + 去重 + janitor) |
286
310
  | `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入 + 设置命名空间 |
311
+ | `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务 |
287
312
 
288
313
  **存储**:本 bundle **不**插入 `storage-json` / `storage-domain` 行。`dsh-web-app` bundle 已经提供它们(并在 `$DSH_HOME/storages` 下使用正确的根路径)。如果在这里重复插入,会覆盖已有配置(patch 会替换整行,后写覆盖先写)。memory store provider 将 `storageDomain` 服务作为 peer dependency 使用。
289
314
 
@@ -310,7 +335,7 @@ memory:
310
335
 
311
336
  ```text
312
337
  [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.
338
+ The git-hosted package "@chenhw7/dsh-memory@0.1.2" needs to execute build scripts but is not in the "allowBuilds" allowlist.
314
339
  ```
315
340
 
316
341
  说明 pnpm 还没有被允许执行该包的 `prepare` 构建脚本。
@@ -331,7 +356,7 @@ The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build script
331
356
 
332
357
  ## 已知限制
333
358
 
334
- - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的子串匹配,不是 embeddings。
359
+ - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的分词词法匹配(CJK 逐字 + Latin 逐词),不是 embeddings。
335
360
  - **提取质量跟随会话模型** — review/flush 复用会话当前路由的 provider/model。
336
361
  - **git 安装需要构建允许** — pnpm 会阻止 git 依赖的 `prepare` 脚本,直到你在 profile 的 `pnpm-workspace.yaml` 中允许它(见上文两步流程)。npm 安装路径则完全不需要。
337
362
  - **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenhw7/dsh-memory",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Long-term memory for the DeepSeek Harness: persistent cross-session memory (store, tools, auto-extraction, context injection) as one installable profile bundle",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",