@chenhw7/dsh-memory 0.1.0 → 0.1.2

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 +95 -37
  2. package/README.zh-CN.md +96 -35
  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
@@ -10,6 +10,7 @@ This is a **self-contained single package** (not a multi-package workspace). It
10
10
 
11
11
  - [Features](#features)
12
12
  - [Install](#install)
13
+ - [Uninstall](#uninstall)
13
14
  - [Verify](#verify)
14
15
  - [Troubleshooting](#troubleshooting)
15
16
  - [Configuration](#configuration)
@@ -34,7 +35,7 @@ Your dsh agent normally forgets everything when you close a session. This bundle
34
35
 
35
36
  ### Prerequisites
36
37
 
37
- - [Node.js](https://nodejs.org) and npm installed.
38
+ - [Node.js](https://nodejs.org) installed.
38
39
  - The `dsh` CLI available (globally or from a source checkout):
39
40
 
40
41
  ```sh
@@ -62,59 +63,70 @@ Your dsh agent normally forgets everything when you close a session. This bundle
62
63
 
63
64
  - A profile you want to add memory to (this guide uses `web`).
64
65
 
65
- ### From GitHub (recommended)
66
+ ### From npm (recommended)
66
67
 
67
- pnpm blocks a git dependency's `prepare` (build) script until you explicitly allow it, so installation is **two steps**:
68
-
69
- **Step 1: allow the build script.** Edit your profile's `pnpm-workspace.yaml`:
68
+ One command. The published tarball ships prebuilt, so pnpm does not run any build script on your machine and no extra pnpm configuration is needed:
70
69
 
71
70
  ```sh
72
- # Windows: %USERPROFILE%\.dsh\profiles\web\pnpm-workspace.yaml
73
- # macOS/Linux: ~/.dsh/profiles/web/pnpm-workspace.yaml
74
- # Or $DSH_HOME/profiles/web/pnpm-workspace.yaml if you set DSH_HOME
71
+ dsh plugin add --profile web @chenhw7/dsh-memory
75
72
  ```
76
73
 
77
- Add this section (merge with existing content if the file already has fields):
74
+ With a source checkout, run it from the `deepseek-harness` directory instead:
78
75
 
79
- ```yaml
80
- allowBuilds:
81
- "@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/045a6f4402fac282fb649787bf3de38cad28c6bb": true
76
+ ```sh
77
+ pnpm dsh plugin add --profile web @chenhw7/dsh-memory
82
78
  ```
83
79
 
84
- > **Why this exact URL?** This is the dependency URL that pnpm prints in `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`. It includes the resolved commit (`045a6f...`). If you update `dsh-memory` to a newer commit, pnpm may report a different URL; update this `allowBuilds` entry to match, or keep using the pinned commit shown here.
80
+ To pin a version instead of `latest`:
85
81
 
86
-
87
- Some pnpm versions use the older list form instead:
88
-
89
- ```yaml
90
- onlyBuiltDependencies:
91
- - "@chenhw7/dsh-memory"
82
+ ```sh
83
+ dsh plugin add --profile web @chenhw7/dsh-memory@0.1.1
92
84
  ```
93
85
 
94
- If your pnpm/dsh reports that form, add that entry; the important part is allowing this exact package's build script.
86
+ ### From GitHub (bleeding edge)
95
87
 
88
+ Use this only to test a commit that is newer than the latest npm release. pnpm blocks a git dependency's `prepare` (build) script until you explicitly allow it, so a profile without an `allowBuilds` entry needs **two runs**:
96
89
 
97
- This grants permission for the package's `prepare` script (`npm run build`) to run on your machine at install time. Only allow packages whose source you trust, and pin a commit so a later push cannot silently change what runs.
98
-
99
- **Step 2: install the plugin:**
90
+ **Step 1: run the install once.** It will stop with:
100
91
 
101
92
  ```sh
102
93
  dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
103
94
  ```
104
95
 
105
- If you are using a source checkout, replace `dsh` with `pnpm dsh` in the commands below and run them from the `deepseek-harness` directory; the profile path and `allowBuilds` step are the same. For example:
96
+ ```text
97
+ [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ... The git-hosted package "@chenhw7/dsh-memory@0.1.1"
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
+ **Step 2: allow the exact key pnpm printed.** Edit the profile's `pnpm-workspace.yaml`:
106
105
 
107
106
  ```sh
108
- pnpm dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
107
+ # Windows: %USERPROFILE%\.dsh\profiles\web\pnpm-workspace.yaml
108
+ # macOS/Linux: ~/.dsh/profiles/web/pnpm-workspace.yaml
109
+ # Or $DSH_HOME/profiles/web/pnpm-workspace.yaml if you set DSH_HOME
109
110
  ```
110
111
 
112
+ and add the key from the error message (merge with existing content):
111
113
 
112
- Or pinned to a specific commit for reproducibility:
114
+ ```yaml
115
+ allowBuilds:
116
+ "@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<the commit pnpm printed>": true
117
+ ```
113
118
 
114
- ```sh
115
- dsh plugin add --profile web https://github.com/chenhw7/dsh-memory/archive/045a6f4402fac282fb649787bf3de38cad28c6bb.tar.gz
119
+ Some pnpm versions use the older list form instead:
120
+
121
+ ```yaml
122
+ onlyBuiltDependencies:
123
+ - "@chenhw7/dsh-memory"
116
124
  ```
117
125
 
126
+ If your pnpm names that field, use that form. Then re-run the `dsh plugin add` command.
127
+
128
+ > **Copy the key from pnpm's error, not from an old copy of this README.** The key includes the resolved commit, so it changes every time you install from a newer commit. This entry grants permission for the package's `prepare` script (`npm run build`) to run on your machine at install time — only allow packages whose source you trust. For a reproducible install, pin a commit (`dsh plugin add --profile web https://github.com/chenhw7/dsh-memory/archive/<commit>.tar.gz`) and allow the key pnpm prints for that pin.
129
+
118
130
  ### From a local checkout
119
131
 
120
132
  If you want to hack on the plugin, clone and build it first, then install from the local path:
@@ -126,19 +138,41 @@ npm install && npm run build
126
138
  dsh plugin add --profile web file:.
127
139
  ```
128
140
 
129
- A `file:` install still runs `prepare`, so the same kind of `allowBuilds` allowance is needed unless `lib/` is already built (pnpm skips `prepare` when the entry points exist). If pnpm prints an exact dependency key to approve, add that key to `allowBuilds` (or use the older `onlyBuiltDependencies` list).
141
+ pnpm does not run build scripts for `file:` dependencies, so no `allowBuilds` entry is needed — the install copies the files as they are, which is why the `npm run build` step above matters: a missing or stale `lib/` is what you get installed.
130
142
 
131
143
  ### From a tarball (no build permission needed)
132
144
 
133
- If you'd rather not grant build-script permission, pack a tarball from a checkout with `lib/` already built, then install it -- a tarball install needs no `allowBuilds` entry:
145
+ If you'd rather not install from the npm registry, pack a tarball from a checkout with `lib/` already built and install it — a tarball ships prebuilt, so no `allowBuilds` entry is needed:
134
146
 
135
147
  ```sh
136
148
  cd dsh-memory
137
149
  npm install && npm run build
138
- npm pack # produces chenhw7-dsh-memory-0.1.0.tgz
139
- dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.0.tgz
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
+ ```
153
+
154
+ ## Uninstall
155
+
156
+ Remove the plugin from a profile:
157
+
158
+ ```sh
159
+ dsh plugin remove --profile web @chenhw7/dsh-memory
140
160
  ```
141
161
 
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.
163
+
164
+ Uninstall does **not** delete your saved memories. They live in one file under dsh's storage area:
165
+
166
+ ```sh
167
+ # macOS/Linux
168
+ ~/.dsh/storages/memory.json
169
+ # Windows
170
+ %USERPROFILE%\.dsh\storages\memory.json
171
+ # or $DSH_HOME/storages/memory.json if you set DSH_HOME
172
+ ```
173
+
174
+ Stop dsh, then delete that file to wipe all saved memories. Other files in the same directory belong to other features — do not remove the whole directory.
175
+
142
176
  ## Verify
143
177
 
144
178
  After install, confirm the four memory rows are in the composed profile tree:
@@ -173,11 +207,11 @@ dsh web
173
207
 
174
208
  ### `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`
175
209
 
176
- If `dsh plugin add` fails with an error like:
210
+ If a **git-hosted** install (`dsh plugin add ... https://github.com/...`) fails with an error like: (npm installs of `@chenhw7/dsh-memory` never trigger this.)
177
211
 
178
212
  ```text
179
213
  [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] Failed to prepare git-hosted package ...
180
- The git-hosted package "@chenhw7/dsh-memory@0.1.0" needs to execute build scripts but is not in the "allowBuilds" allowlist.
214
+ The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build scripts but is not in the "allowBuilds" allowlist.
181
215
  ```
182
216
 
183
217
  It means pnpm has not been told to allow this package's `prepare` build script.
@@ -203,7 +237,7 @@ All settings are editable from the dsh frontend settings page (the `memory` name
203
237
 
204
238
  | Setting | Default | Meaning |
205
239
  |---|---|---|
206
- | `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. |
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. `index`: inject an existence index (one line per entry) so the model can see what is stored and route to `memory_get`/`memory_search`. |
207
241
  | `memoryPolicyCustomText` | — | Custom policy text used when `memoryMode` is `custom`. |
208
242
  | `reviewEnabled` | `true` | Enable automatic periodic review extraction. |
209
243
  | `reviewCandidateThreshold` | `10` | Number of candidate messages before an LLM extraction runs. |
@@ -211,7 +245,31 @@ All settings are editable from the dsh frontend settings page (the `memory` name
211
245
  | `flushOnDispose` | `true` | Extract remaining context when a session is disposed. |
212
246
  | `memoryCharLimit` | `5000` | Per-scope character limit for injected memory content. |
213
247
 
214
- Example `$DSH_HOME/settings.yaml`:
248
+ ### Extraction & Dedup Settings
249
+
250
+ 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):
251
+
252
+ | Setting | Default | Meaning |
253
+ |---|---|---|
254
+ | `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). |
255
+ | `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
+ | `extractionBudget` | `20` | Max extraction + judge calls per session. `0` = unlimited. |
257
+ | `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). |
258
+
259
+ 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
+
261
+ Example composition config for a dedicated extraction model:
262
+
263
+ ```yaml
264
+ memory-review:
265
+ config:
266
+ extractionModelProvider: deepseek
267
+ extractionModelModel: deepseek-chat
268
+ extractionBudget: 20
269
+ judgeEnabled: true
270
+ ```
271
+
272
+ Example `$DSH_HOME/settings.yaml` (memory namespace):
215
273
 
216
274
  ```yaml
217
275
  memory:
@@ -280,7 +338,7 @@ The bundle inserts four rows over `dsh-base`, each pointing at this package's ow
280
338
 
281
339
  - **No semantic/vector retrieval** — `memory_search` is substring matching over structured KV entries, not embeddings.
282
340
  - **Extraction quality tracks the session model** — review/flush reuse the session's routed provider/model.
283
- - **git install needs a build allowance** — pnpm blocks the `prepare` script until you add an `allowBuilds` entry for the exact dependency. Use a tarball or npm publish to avoid this.
341
+ - **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.
284
342
  - **dsh is in developer preview** — breaking changes are expected; this bundle's peer dependency ranges track the dsh release line.
285
343
 
286
344
  ## License
package/README.zh-CN.md CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  - [功能特性](#功能特性)
12
12
  - [安装](#安装)
13
+ - [卸载](#卸载)
13
14
  - [验证](#验证)
14
15
  - [配置](#配置)
15
16
  - [架构](#架构)
@@ -31,7 +32,7 @@
31
32
 
32
33
  ### 前置要求
33
34
 
34
- - 已安装 [Node.js](https://nodejs.org) 和 npm。
35
+ - 已安装 [Node.js](https://nodejs.org)。
35
36
  - 可以使用 dsh CLI(全局安装或源码构建):
36
37
 
37
38
  ```sh
@@ -60,27 +61,57 @@
60
61
 
61
62
  - 准备一个要添加记忆能力的 profile(本文以 `web` 为例)。
62
63
 
63
- ### 从 GitHub 安装(推荐)
64
+ ### 从 npm 安装(推荐)
64
65
 
65
- pnpm 会阻止 git 依赖的 `prepare` 构建脚本,直到你显式允许,因此安装分两步。
66
+ 一条命令。npm 上的 tarball 是预构建的,安装时 pnpm 不会在你的机器上运行任何构建脚本,也不需要额外的 pnpm 配置:
66
67
 
67
- **第一步:允许构建脚本**
68
+ ```sh
69
+ dsh plugin add --profile web @chenhw7/dsh-memory
70
+ ```
71
+
72
+ 如果使用源码构建的 dsh,在 `deepseek-harness` 目录下执行:
73
+
74
+ ```sh
75
+ pnpm dsh plugin add --profile web @chenhw7/dsh-memory
76
+ ```
77
+
78
+ 需要锁定版本而不跟 `latest` 时:
79
+
80
+ ```sh
81
+ dsh plugin add --profile web @chenhw7/dsh-memory@0.1.1
82
+ ```
83
+
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
+ ```
68
101
 
69
- 编辑 profile 的 `pnpm-workspace.yaml`:
102
+ **第二步:把 pnpm 打印的精确 key 加入允许列表。** 编辑 profile 的 `pnpm-workspace.yaml`:
70
103
 
71
104
  - Windows:`%USERPROFILE%\.dsh\profiles\web\pnpm-workspace.yaml`
72
105
  - macOS/Linux:`~/.dsh/profiles/web/pnpm-workspace.yaml`
73
106
  - 如果设置了 `DSH_HOME`:`$DSH_HOME/profiles/web/pnpm-workspace.yaml`
74
107
 
75
- 添加(如果已有内容则合并):
108
+ 添加报错信息里的那条 key(与已有内容合并):
76
109
 
77
110
  ```yaml
78
111
  allowBuilds:
79
- "@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/045a6f4402fac282fb649787bf3de38cad28c6bb": true
112
+ "@chenhw7/dsh-memory@https://codeload.github.com/chenhw7/dsh-memory/tar.gz/<pnpm 打印的 commit>": true
80
113
  ```
81
114
 
82
- > **为什么是这个 URL?** 这是 pnpm 在 `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED` 中打印的依赖 URL,包含解析后的 commit(`045a6f...`)。如果更新 `dsh-memory` 到新 commit,pnpm 可能提示不同的 URL;请同步更新 `allowBuilds`,或继续使用这里固定的 commit。
83
-
84
115
  部分 pnpm 版本使用旧格式:
85
116
 
86
117
  ```yaml
@@ -88,25 +119,9 @@ onlyBuiltDependencies:
88
119
  - "@chenhw7/dsh-memory"
89
120
  ```
90
121
 
91
- **第二步:安装插件**
92
-
93
- ```sh
94
- dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
95
- ```
96
-
97
- 如果使用源码构建的 dsh,则在 `deepseek-harness` 目录下执行:
98
-
99
- ```sh
100
- pnpm dsh plugin add --profile web https://github.com/chenhw7/dsh-memory
101
- ```
102
-
103
- profile 路径和 `allowBuilds` 步骤与全局安装相同。
122
+ 如果你的 pnpm 提示的是这个字段,就用这个格式。然后重新执行 `dsh plugin add` 命令。
104
123
 
105
- 固定 commit 安装:
106
-
107
- ```sh
108
- dsh plugin add --profile web https://github.com/chenhw7/dsh-memory/archive/045a6f4402fac282fb649787bf3de38cad28c6bb.tar.gz
109
- ```
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。
110
125
 
111
126
  ### 从本地 checkout 安装
112
127
 
@@ -119,19 +134,41 @@ npm install && npm run build
119
134
  dsh plugin add --profile web file:.
120
135
  ```
121
136
 
122
- `file:` 安装仍然会运行 `prepare`,所以通常也需要同样的 `allowBuilds` 允许配置,除非 `lib/` 已经构建好(pnpm 在入口文件已存在时会跳过 `prepare`)。如果 pnpm 打印了需要批准的精确依赖 key,请将它加入 `allowBuilds`(或使用旧的 `onlyBuiltDependencies` 列表)。
137
+ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds` 条目——安装是按原样拷贝文件的,这也正是上面 `npm run build` 步骤的意义:`lib/` 缺失或过期,装到的就是缺失或过期的产物。
123
138
 
124
139
  ### 从 tarball 安装(无需构建权限)
125
140
 
126
- 如果你不想授予构建脚本权限,可以从已构建好 `lib/` 的 checkout 打包 tarball 再安装:
141
+ 如果不想从 npm registry 安装,可以从已构建好 `lib/` 的 checkout 打包 tarball 再安装——tarball 是预构建的,同样不需要 `allowBuilds` 条目:
127
142
 
128
143
  ```sh
129
144
  cd dsh-memory
130
145
  npm install && npm run build
131
- npm pack # 生成 chenhw7-dsh-memory-0.1.0.tgz
132
- dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.0.tgz
146
+ npm pack # 生成 chenhw7-dsh-memory-0.1.1.tgz
147
+ dsh plugin add --profile web ./chenhw7-dsh-memory-0.1.1.tgz
148
+ ```
149
+
150
+ ## 卸载
151
+
152
+ 从 profile 中移除插件:
153
+
154
+ ```sh
155
+ dsh plugin remove --profile web @chenhw7/dsh-memory
156
+ ```
157
+
158
+ (源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,四个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
159
+
160
+ 卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下的一个文件里:
161
+
162
+ ```sh
163
+ # macOS/Linux
164
+ ~/.dsh/storages/memory.json
165
+ # Windows
166
+ %USERPROFILE%\.dsh\storages\memory.json
167
+ # 如果设置了 DSH_HOME,则为 $DSH_HOME/storages/memory.json
133
168
  ```
134
169
 
170
+ 先停掉 dsh,再删除该文件即可清空所有已保存的记忆。同一目录下的其他文件属于其他功能,不要删除整个目录。
171
+
135
172
  ## 验证
136
173
 
137
174
  安装后,确认组合后的 profile 树中包含四个 memory 行:
@@ -168,7 +205,7 @@ dsh web
168
205
 
169
206
  | 设置 | 默认值 | 说明 |
170
207
  |---|---|---|
171
- | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入。 |
208
+ | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
172
209
  | `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
173
210
  | `reviewEnabled` | `true` | 启用自动周期性 review 提取。 |
174
211
  | `reviewCandidateThreshold` | `10` | 触发 LLM 提取前的候选消息数。 |
@@ -176,6 +213,30 @@ dsh web
176
213
  | `flushOnDispose` | `true` | 会话销毁时提取剩余上下文。 |
177
214
  | `memoryCharLimit` | `5000` | 每个作用域注入记忆内容的字符上限。 |
178
215
 
216
+ ### 提取与去重设置
217
+
218
+ 以下设置控制自动提取管线和去重裁决,位于 `memory-review` 插件配置中(通过组合层设置,不在 `memory` 设置命名空间里):
219
+
220
+ | 设置 | 默认值 | 说明 |
221
+ |---|---|---|
222
+ | `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
223
+ | `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
224
+ | `extractionBudget` | `20` | 每会话最大提取 + 裁决调用次数。`0` = 无限。 |
225
+ | `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
226
+
227
+ 默认情况下,提取和去重裁决使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,在 review 插件的组合配置中设置 `extractionModelProvider` 和 `extractionModelModel`。
228
+
229
+ 专用提取模型的组合配置示例:
230
+
231
+ ```yaml
232
+ memory-review:
233
+ config:
234
+ extractionModelProvider: deepseek
235
+ extractionModelModel: deepseek-chat
236
+ extractionBudget: 20
237
+ judgeEnabled: true
238
+ ```
239
+
179
240
  `$DSH_HOME/settings.yaml` 配置示例:
180
241
 
181
242
  ```yaml
@@ -245,11 +306,11 @@ memory:
245
306
 
246
307
  ### `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`
247
308
 
248
- 如果 `dsh plugin add` 报错,例如:
309
+ 如果**git 安装**(`dsh plugin add ... https://github.com/...`)报错,例如:(npm 安装 `@chenhw7/dsh-memory` 不会触发此错误。)
249
310
 
250
311
  ```text
251
312
  [ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] Failed to prepare git-hosted package ...
252
- The git-hosted package "@chenhw7/dsh-memory@0.1.0" needs to execute build scripts but is not in the "allowBuilds" allowlist.
313
+ The git-hosted package "@chenhw7/dsh-memory@0.1.1" needs to execute build scripts but is not in the "allowBuilds" allowlist.
253
314
  ```
254
315
 
255
316
  说明 pnpm 还没有被允许执行该包的 `prepare` 构建脚本。
@@ -272,7 +333,7 @@ The git-hosted package "@chenhw7/dsh-memory@0.1.0" needs to execute build script
272
333
 
273
334
  - **无语义/向量检索** — `memory_search` 是对结构化 KV 条目的子串匹配,不是 embeddings。
274
335
  - **提取质量跟随会话模型** — review/flush 复用会话当前路由的 provider/model。
275
- - **git 安装需要构建允许** — pnpm 会阻止 `prepare` 脚本,直到你为精确依赖添加 `allowBuilds` 条目。可以使用 tarball 或 npm publish 来避免。
336
+ - **git 安装需要构建允许** — pnpm 会阻止 git 依赖的 `prepare` 脚本,直到你在 profile 的 `pnpm-workspace.yaml` 中允许它(见上文两步流程)。npm 安装路径则完全不需要。
276
337
  - **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
277
338
 
278
339
  ## 许可证
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"}