@chenhw7/dsh-memory 0.9.3 → 0.10.1
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.i18n.yaml +2 -2
- package/README.md +88 -70
- package/README.zh.md +87 -69
- package/cordis.patch.yml +17 -8
- package/lib/client/index.js +2169 -2168
- package/lib/context/index.d.ts +35 -124
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +75 -201
- package/lib/context/index.js.map +1 -1
- package/lib/context/settings.d.ts +67 -0
- package/lib/context/settings.d.ts.map +1 -0
- package/lib/context/settings.js +69 -0
- package/lib/context/settings.js.map +1 -0
- package/lib/identity/index.d.ts +29 -8
- package/lib/identity/index.d.ts.map +1 -1
- package/lib/identity/index.js +31 -37
- package/lib/identity/index.js.map +1 -1
- package/lib/identity/settings.d.ts +26 -12
- package/lib/identity/settings.d.ts.map +1 -1
- package/lib/identity/settings.js +29 -13
- package/lib/identity/settings.js.map +1 -1
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/notes/index.d.ts +35 -4
- package/lib/notes/index.d.ts.map +1 -1
- package/lib/notes/index.js +26 -31
- package/lib/notes/index.js.map +1 -1
- package/lib/notes/settings.d.ts +30 -10
- package/lib/notes/settings.d.ts.map +1 -1
- package/lib/notes/settings.js +29 -9
- package/lib/notes/settings.js.map +1 -1
- package/lib/remote/index.d.ts +7 -7
- package/lib/remote/index.d.ts.map +1 -1
- package/lib/review/accumulator.d.ts.map +1 -1
- package/lib/review/accumulator.js +8 -12
- package/lib/review/accumulator.js.map +1 -1
- package/lib/review/consolidate.d.ts.map +1 -1
- package/lib/review/consolidate.js +2 -1
- package/lib/review/consolidate.js.map +1 -1
- package/lib/review/extract.d.ts.map +1 -1
- package/lib/review/extract.js +2 -1
- package/lib/review/extract.js.map +1 -1
- package/lib/review/index.d.ts +40 -4
- package/lib/review/index.d.ts.map +1 -1
- package/lib/review/index.js +83 -66
- package/lib/review/index.js.map +1 -1
- package/lib/review/sweep.d.ts.map +1 -1
- package/lib/review/sweep.js +2 -1
- package/lib/review/sweep.js.map +1 -1
- package/lib/sources.d.ts +37 -0
- package/lib/sources.d.ts.map +1 -0
- package/lib/sources.js +16 -0
- package/lib/sources.js.map +1 -0
- package/lib/store/index.d.ts +37 -15
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +20 -8
- package/lib/store/index.js.map +1 -1
- package/lib/store/settings.d.ts +84 -0
- package/lib/store/settings.d.ts.map +1 -0
- package/lib/store/settings.js +77 -0
- package/lib/store/settings.js.map +1 -0
- package/lib/store/sqlite.d.ts +6 -0
- package/lib/store/sqlite.d.ts.map +1 -1
- package/lib/store/sqlite.js +7 -0
- package/lib/store/sqlite.js.map +1 -1
- package/lib/tool/index.d.ts +10 -10
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +29 -60
- package/lib/tool/index.js.map +1 -1
- package/lib/types.d.ts +2 -2
- package/package.json +45 -47
- package/lib/invariant.d.ts +0 -27
- package/lib/invariant.d.ts.map +0 -1
- package/lib/invariant.js +0 -42
- package/lib/invariant.js.map +0 -1
package/README.i18n.yaml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
README.md:
|
|
2
|
-
README.zh.md:
|
|
1
|
+
README.md: b32ac9f6921ec4ba3363296db6c96688de0a3bd3
|
|
2
|
+
README.zh.md: e076b9f9d42834d7c7f961f0142587648d433fc4
|
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Your dsh agent normally forgets everything when you close a session. This bundle
|
|
|
52
52
|
- **Step-level auto recall (on by default)** — on each agent step, a BM25 search keyed on the step's user text appends a fenced `<recalled-memory>` message without touching the system prompt, keeping the KV-cache prefix stable. Fence hits refresh an entry's recency clock but never its access count, so query-word luck cannot inflate the eviction signal.
|
|
53
53
|
- **Compaction-aware flush** — when compaction shadows old context, the raw events are scanned for anything worth remembering.
|
|
54
54
|
- **Security scanning, write *and* load time** — API keys, tokens, prompt-injection patterns, and exfiltration attempts are blocked from being saved; anything that slips through is redacted (`[BLOCKED: …]`) wherever it would re-enter a prompt.
|
|
55
|
-
- **Frontend-configurable** — all settings exposed
|
|
55
|
+
- **Frontend-configurable** — all settings exposed on the bundle's page in the dsh settings UI, applied live.
|
|
56
56
|
- **Optional human review before write** — flip one setting (`confirmBeforeWrite`) and every extraction *and* tool write becomes a *proposal* in a pending queue (repeated signals accumulate hits and float up); adopting applies it (with your edits), rejecting discards it. The model never self-promotes: a proposed change to an existing entry rewrites nothing until you accept it.
|
|
57
57
|
- **Memory manager UI** — a dedicated "Memory" section in the dsh settings UI with three tabs: Overview (health dashboard), Review (the pending-proposal queue), and Manage — scope and workspace filters, BM25 search, category chips, a lazily loaded entry list, plus full write actions (edit / pin / archive / delete) — in English and Chinese.
|
|
58
58
|
- **Time-window browsing + smart list view** — `memory_list` returns newest-first with `earliest`/`latest`/`hasStale` metadata, accepts `since`/`until` epoch-ms bounds so "what did we learn last week" pages within the window, and suggests widening the filter when a narrowed query comes back empty over a non-empty store.
|
|
@@ -91,11 +91,13 @@ Your dsh agent normally forgets everything when you close a session. This bundle
|
|
|
91
91
|
- A profile you want to add memory to (this guide uses `web`).
|
|
92
92
|
|
|
93
93
|
> [!IMPORTANT]
|
|
94
|
-
> **Harness
|
|
95
|
-
>
|
|
96
|
-
>
|
|
97
|
-
>
|
|
98
|
-
>
|
|
94
|
+
> **Harness: 0.2.2 or newer within 0.2.x.** This bundle targets the 0.2 host
|
|
95
|
+
> contract — per-entry plugin `Config` (no `ctx.settings.installSection`), the
|
|
96
|
+
> `plugins.bundle.config` settings page, per-producer message sources, and tool
|
|
97
|
+
> results as standalone tool-role messages. It declares `^0.2.2-rc.1` peers and
|
|
98
|
+
> `engines.dsh: ">=0.2.2-rc.1 <0.3.0"`, so the plugin manager refuses an older
|
|
99
|
+
> or incompatible host instead of loading a broken bundle. See
|
|
100
|
+
> [Known Limitations](#known-limitations).
|
|
99
101
|
|
|
100
102
|
### From npm (recommended)
|
|
101
103
|
|
|
@@ -171,7 +173,7 @@ dsh plugin remove --profile web @chenhw7/dsh-memory
|
|
|
171
173
|
|
|
172
174
|
(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 seven `memory-*` rows disappear from the composed config — you can confirm with the `--dump-config` check below.
|
|
173
175
|
|
|
174
|
-
Uninstall does **not** delete your saved memories. They live under dsh's storage area, named by the `memory
|
|
176
|
+
Uninstall does **not** delete your saved memories. They live under dsh's storage area, named by the `memory` row's `storage` config: `host-medium` (default) keeps everything in `memory.json`; `sqlite` moves the store into the plugin-owned `memory.db` with a one-time migration (`memory.json` then holds only the migration marker):
|
|
175
177
|
|
|
176
178
|
```sh
|
|
177
179
|
# macOS/Linux
|
|
@@ -201,21 +203,23 @@ You should see seven rows pointing at `@chenhw7/dsh-memory/*`:
|
|
|
201
203
|
```
|
|
202
204
|
- id: memory-root
|
|
203
205
|
name: '@chenhw7/dsh-memory'
|
|
204
|
-
- id: memory
|
|
206
|
+
- id: memory
|
|
205
207
|
name: '@chenhw7/dsh-memory/store'
|
|
206
|
-
- id:
|
|
208
|
+
- id: memory-tools
|
|
207
209
|
name: '@chenhw7/dsh-memory/tool'
|
|
208
210
|
- id: memory-review
|
|
209
211
|
name: '@chenhw7/dsh-memory/review'
|
|
210
212
|
- id: memory-notes
|
|
211
213
|
name: '@chenhw7/dsh-memory/notes'
|
|
212
|
-
- id: memory-
|
|
214
|
+
- id: memory-identity
|
|
215
|
+
name: '@chenhw7/dsh-memory/identity'
|
|
216
|
+
- id: memory-autorecall
|
|
213
217
|
name: '@chenhw7/dsh-memory/context'
|
|
214
218
|
- id: memory-remote
|
|
215
219
|
name: '@chenhw7/dsh-memory/remote-service'
|
|
216
220
|
```
|
|
217
221
|
|
|
218
|
-
Then start dsh and
|
|
222
|
+
Then start dsh and open **Settings → Plugins → @chenhw7/dsh-memory**; its page holds the five configuration sections:
|
|
219
223
|
|
|
220
224
|
```sh
|
|
221
225
|
dsh web
|
|
@@ -223,15 +227,15 @@ dsh web
|
|
|
223
227
|
|
|
224
228
|
## Configuration
|
|
225
229
|
|
|
226
|
-
|
|
230
|
+
Every bundle row declares its own settings (`Config`), and the row id **is** the settings namespace the host addresses it by. The bundle's page in **Settings → Plugins** renders all five editable entries as sections; each section writes the entry that owns the field, and every change **applies live** — the host re-runs the plugin with the new config, so it takes effect on the next event or call without a restart:
|
|
227
231
|
|
|
228
|
-
- **`memory`**
|
|
229
|
-
- **`memory-notes`**
|
|
230
|
-
- **`memory-autorecall`**
|
|
231
|
-
- **`memory-identity`**
|
|
232
|
-
- **`memory-review`**
|
|
232
|
+
- **`memory`** — the store: injection modes, memory budgets, search cap, decay window, storage backend. Owned by the `/store` row.
|
|
233
|
+
- **`memory-notes`** — the project-notes prompt-section switch and budgets. Owned by `/notes`.
|
|
234
|
+
- **`memory-autorecall`** — the step-level recall fence and the usage-hit signal. Owned by `/context`.
|
|
235
|
+
- **`memory-identity`** — the identity layer's switch, budgets, and seed directory. Owned by `/identity`.
|
|
236
|
+
- **`memory-review`** — extraction pipeline, model routing, dedup judge, pitfall streaks, curator pass, human-review gate. Owned by `/review`.
|
|
233
237
|
|
|
234
|
-
|
|
238
|
+
Each value resolves in layers: schema defaults → the row's `config:` entry in the profile patch → the value saved from the settings page. A field left alone inherits the composition value, so a deployment can pin a default and users override only what they need. Sibling plugins never read each other's config directly: the entry that owns a knob publishes it through its service (`ctx.memory.settings()`, `ctx.projectNotes.settings()`, `ctx.identity.settings()`, `ctx.memoryReview.settings()`), which is why `maxSearchResults` and `decayDays` live on `memory` while `confirmBeforeWrite` lives on `memory-review`.
|
|
235
239
|
|
|
236
240
|
### `memory` namespace
|
|
237
241
|
|
|
@@ -254,7 +258,7 @@ Every namespace resolves in layers: schema defaults → the composition `config:
|
|
|
254
258
|
| `notesPitfallsCharLimit` | `800` | Character budget for the pitfall-log half of the notes section, so conventions can no longer starve it. Same freeze-time semantics and count-line folding. |
|
|
255
259
|
| `notesMaxEntriesPerFile` | `100` | Max entries selected into the notes section (pinned first, then importance, then recency); the rest fold into count lines. |
|
|
256
260
|
|
|
257
|
-
> **Settings migration**: the 0.9.x combined key `notesCharLimit` still works — when it is the only budget key set, both halves derive from it (conventions 60% / pitfalls 40%); each new key you set wins its own half. Rename the key in
|
|
261
|
+
> **Settings migration**: the 0.9.x combined key `notesCharLimit` still works — when it is the only budget key set, both halves derive from it (conventions 60% / pitfalls 40%); each new key you set wins its own half. Rename the key in the `memory-notes` row's `config:` (or clear it on the settings page) to migrate.
|
|
258
262
|
|
|
259
263
|
### `memory-autorecall` namespace
|
|
260
264
|
|
|
@@ -294,14 +298,15 @@ Every namespace resolves in layers: schema defaults → the composition `config:
|
|
|
294
298
|
| `curatorMinChars` | `400` | Only entries at least this long are selected for re-summarization. |
|
|
295
299
|
| `confirmBeforeWrite` | `false` | Human-review mode: every extraction (review/flush/curator) *and* every `memory_add`/`memory_replace` call lands as a proposal in the pending queue instead of the store, until a human adopts it in the Memory settings section (Review tab). Repeated observations of the same proposal accumulate `hits` and float it to the top; a proposed change to an existing entry carries its id and rewrites nothing until adopted. |
|
|
296
300
|
|
|
297
|
-
> There is deliberately **no
|
|
301
|
+
> There is deliberately **no `memory-tools` settings entry**: the tool row owns no knobs of its own. It reads `maxSearchResults` from `ctx.memory.settings()`, `confirmBeforeWrite` from `ctx.memoryReview.settings()`, and the identity gate/budgets from `ctx.identity.settings()`. Its own `config.maxSearchResults` is the fallback when no store is composed.
|
|
298
302
|
|
|
299
303
|
### Setting via composition vs. UI
|
|
300
304
|
|
|
301
|
-
Every
|
|
305
|
+
Every entry accepts the same keys from both layers: a row's `config:` block in the profile patch is the composition default, and the settings page writes the user layer on top of it. To pin `maxSearchResults: 100` as the deployment default while still letting a user override it:
|
|
302
306
|
|
|
303
307
|
```yaml
|
|
304
|
-
memory
|
|
308
|
+
- id: memory
|
|
309
|
+
name: '@chenhw7/dsh-memory/store'
|
|
305
310
|
config:
|
|
306
311
|
maxSearchResults: 100
|
|
307
312
|
```
|
|
@@ -315,48 +320,58 @@ memory-review:
|
|
|
315
320
|
extractionModelModel: deepseek-chat
|
|
316
321
|
```
|
|
317
322
|
|
|
318
|
-
Example
|
|
323
|
+
Example profile-patch rows pinning every entry (the settings page writes the same keys into the profile document):
|
|
319
324
|
|
|
320
325
|
```yaml
|
|
321
|
-
memory
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
326
|
+
- id: memory
|
|
327
|
+
name: '@chenhw7/dsh-memory/store'
|
|
328
|
+
config:
|
|
329
|
+
memoryMode: digest
|
|
330
|
+
memoryPolicyCustomText: ''
|
|
331
|
+
memoryCharLimit: 5000
|
|
332
|
+
memoryDigestCharLimit: 800
|
|
333
|
+
memoryMaxEntries: 20
|
|
334
|
+
maxSearchResults: 50
|
|
335
|
+
decayDays: 30
|
|
336
|
+
- id: memory-notes
|
|
337
|
+
name: '@chenhw7/dsh-memory/notes'
|
|
338
|
+
config:
|
|
339
|
+
notesEnabled: true
|
|
340
|
+
notesConventionsCharLimit: 1600
|
|
341
|
+
notesPitfallsCharLimit: 800
|
|
342
|
+
notesMaxEntriesPerFile: 100
|
|
343
|
+
- id: memory-autorecall
|
|
344
|
+
name: '@chenhw7/dsh-memory/context'
|
|
345
|
+
config:
|
|
346
|
+
autoRecallEnabled: true
|
|
347
|
+
autoRecallLimit: 5
|
|
348
|
+
autoRecallMinChars: 12
|
|
349
|
+
hitSignalEnabled: false
|
|
350
|
+
hitSignalThreshold: 0.25
|
|
351
|
+
- id: memory-identity
|
|
352
|
+
name: '@chenhw7/dsh-memory/identity'
|
|
353
|
+
config:
|
|
354
|
+
identityEnabled: false
|
|
355
|
+
soulCharLimit: 2000
|
|
356
|
+
userCharLimit: 3000
|
|
357
|
+
identitySeedDir: ''
|
|
358
|
+
- id: memory-review
|
|
359
|
+
name: '@chenhw7/dsh-memory/review'
|
|
360
|
+
config:
|
|
361
|
+
reviewEnabled: true
|
|
362
|
+
reviewCandidateThreshold: 10
|
|
363
|
+
flushOnCompaction: true
|
|
364
|
+
flushOnDispose: true
|
|
365
|
+
extractionModelProvider: ''
|
|
366
|
+
extractionModelModel: ''
|
|
367
|
+
extractionBudget: 20
|
|
368
|
+
judgeEnabled: true
|
|
369
|
+
pitfallStreakThreshold: 2
|
|
370
|
+
curatorEnabled: true
|
|
371
|
+
curatorEveryNSessions: 20
|
|
372
|
+
curatorMaxEntries: 5
|
|
373
|
+
curatorMinChars: 400
|
|
374
|
+
confirmBeforeWrite: false
|
|
360
375
|
```
|
|
361
376
|
|
|
362
377
|
`memoryPolicyCustomText` is optional and only used when `memoryMode` is `custom`.
|
|
@@ -364,9 +379,11 @@ memory-review:
|
|
|
364
379
|
When `memoryMode` is `custom`, `memoryPolicyCustomText` is injected verbatim as the memory section. It supports multi-line YAML with `|`. For example:
|
|
365
380
|
|
|
366
381
|
```yaml
|
|
367
|
-
memory
|
|
368
|
-
|
|
369
|
-
|
|
382
|
+
- id: memory
|
|
383
|
+
name: '@chenhw7/dsh-memory/store'
|
|
384
|
+
config:
|
|
385
|
+
memoryMode: custom
|
|
386
|
+
memoryPolicyCustomText: |
|
|
370
387
|
<memory-policy>
|
|
371
388
|
Persistent memory is available through memory tools. Do not assume memory has already been loaded into the prompt.
|
|
372
389
|
|
|
@@ -390,11 +407,12 @@ The bundle inserts seven rows over `dsh-base`, each pointing at this package's o
|
|
|
390
407
|
| Row | Export | Role |
|
|
391
408
|
|---|---|---|
|
|
392
409
|
| `memory-root` | `@chenhw7/dsh-memory` | No-op root entry for client-module scanner discovery |
|
|
393
|
-
| `memory
|
|
394
|
-
| `
|
|
395
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator + human-review queue)
|
|
410
|
+
| `memory` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain (entries + audit + suggestion-queue + meta tables), registers `ctx.memory` (BM25 search + two-tier decay) and publishes the shared injection/recall settings through `ctx.memory.settings()` |
|
|
411
|
+
| `memory-tools` | `@chenhw7/dsh-memory/tool` | Nine model-facing tools (confirm-mode writes queue as proposals) |
|
|
412
|
+
| `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator + human-review queue); publishes `ctx.memoryReview` for the tool's confirm gate |
|
|
396
413
|
| `memory-notes` | `@chenhw7/dsh-memory/notes` | Project-notes prompt projection (render conventions/pitfalls into the `project-notes` section; no repo files), registers `ctx.projectNotes`; cleans up ≤0.5.x file-export artifacts on session start |
|
|
397
|
-
| `memory-
|
|
414
|
+
| `memory-identity` | `@chenhw7/dsh-memory/identity` | Registers `ctx.identity`: seeds and reads the two self-documents (SOUL.md / USER.md) from the store's identity tables |
|
|
415
|
+
| `memory-autorecall` | `@chenhw7/dsh-memory/context` | System-prompt injection (`memory` @6000 + `project-notes` @6001, after tool guidance) and step-tail messages (one-time digest + per-step recall fence); owns the auto-recall settings |
|
|
398
416
|
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | `@Remote` service behind the settings UI's Memory section (consumed over the `/api` channel) |
|
|
399
417
|
|
|
400
418
|
**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.
|
|
@@ -421,7 +439,7 @@ The bundle inserts seven rows over `dsh-base`, each pointing at this package's o
|
|
|
421
439
|
- **Mid-session extractions stay out of the prompt until the next compaction or session** — the injected sections are frozen for KV-cache stability; step-level auto recall (on by default) covers per-step freshness instead, and the one-time digest re-appends once after compaction.
|
|
422
440
|
- **Remote management access relies on transport trust plus deployment valves** — any host admitted by the dsh host's `trustedHosts` setting can call read RPCs, but ordinary remote memory writes are denied by default (`remoteWritesEnabled: false`) and are exposed only when explicitly enabled, and `identityRevert` requires its own `identityRevertEnabled` valve (default `true`) on top of the write gate because it restores scanner-approved history rather than accepting arbitrary new content. Keep `trustedHosts` narrow and leave remote writes disabled unless every admitted host is trusted ([threat model](docs/TECH_DESIGN.md)).
|
|
423
441
|
- **dsh is in developer preview** — breaking changes are expected; this bundle's peer dependency ranges track the dsh release line.
|
|
424
|
-
- **
|
|
442
|
+
- **Harness 0.2.x required** — the bundle uses the 0.2 host contract (per-entry plugin `Config`, `plugins.bundle.config` settings page, per-producer message sources, tool results as tool-role messages) and declares `^0.2.2-rc.1` peers plus `engines.dsh: ">=0.2.2-rc.1 <0.3.0"`. 0.1.x hosts cannot load it: their `ctx.settings.installSection` model is gone in 0.2, and 0.2 removed `dsh-invariants`. Releases of this bundle before 0.10.0 target the 0.1.x line — pin those if you are still on a 0.1 host.
|
|
425
443
|
|
|
426
444
|
## License
|
|
427
445
|
|
package/README.zh.md
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
- **步级自动召回(默认开)** — 每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息;不触碰 system prompt,保持 KV-cache 前缀稳定。围栏命中只刷新条目的最近召回时间,不计入访问计数——查询词的运气不会污染逐出信号。
|
|
50
50
|
- **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
|
|
51
51
|
- **安全扫描:写入时 + 读取时** — API Key、Token、提示注入模式和泄露尝试会被阻止写入;漏网内容在重新进入 prompt 的任何位置都会被替换为 `[BLOCKED: …]` 占位符。
|
|
52
|
-
- **前端可配置** —
|
|
52
|
+
- **前端可配置** — 所有设置在 dsh 设置界面的 bundle 页面上暴露,实时生效。
|
|
53
53
|
- **可选的写入前人工确认** — 打开一个开关(`confirmBeforeWrite`)后,自动提取*与*工具调用产生的写入一律先进入待确认队列(同一提议反复出现会累计次数并置顶);采纳才落库(可先编辑),拒绝即丢弃。模型永不自我提升:对既有条目的修改提议在你采纳前不会改动原文。
|
|
54
54
|
- **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25 搜索、类别筛选、懒加载条目列表,并带完整写操作(编辑 / 置顶 / 归档 / 删除),中英双语。
|
|
55
55
|
- **时间窗浏览 + 智能列表视图** — `memory_list` 默认按最新在前返回,附带 `earliest`/`latest`/`hasStale` 元数据,支持 `since`/`until` 毫秒时间戳边界(「上周学了什么」这类查询直接在窗口内分页);过滤条件命中 0 条但库非空时,会提示放宽过滤条件。
|
|
@@ -89,10 +89,11 @@
|
|
|
89
89
|
- 准备一个要添加记忆能力的 profile(本文以 `web` 为例)。
|
|
90
90
|
|
|
91
91
|
> [!IMPORTANT]
|
|
92
|
-
> **Harness
|
|
93
|
-
>
|
|
94
|
-
>
|
|
95
|
-
>
|
|
92
|
+
> **Harness:0.2.x 线,且 ≥ 0.2.2。** 本 bundle 面向 0.2 宿主契约——每个条目自带
|
|
93
|
+
> 插件 `Config`(不再有 `ctx.settings.installSection`)、`plugins.bundle.config` 设置页、
|
|
94
|
+
> 由生产者各自声明的消息来源、tool 结果为独立 tool 角色消息。peer 声明 `^0.2.2-rc.1`、
|
|
95
|
+
> `engines.dsh: ">=0.2.2-rc.1 <0.3.0"`,因此插件管理器会拒绝过旧或不兼容的宿主,
|
|
96
|
+
> 而不是加载一个坏掉的 bundle。见[已知限制](#已知限制)。
|
|
96
97
|
|
|
97
98
|
### 从 npm 安装(推荐)
|
|
98
99
|
|
|
@@ -168,7 +169,7 @@ dsh plugin remove --profile web @chenhw7/dsh-memory
|
|
|
168
169
|
|
|
169
170
|
(源码构建的 dsh:在 `deepseek-harness` 目录下执行 `pnpm dsh plugin remove --profile web @chenhw7/dsh-memory`。)这会在 profile 目录里执行 `pnpm remove` 并同步层列表,七个 `memory-*` 行会从组合后的配置中消失——可以用下面的 `--dump-config` 检查确认。
|
|
170
171
|
|
|
171
|
-
卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下,具体文件由 `memory
|
|
172
|
+
卸载**不会**删除你已保存的记忆。它们存放在 dsh 存储目录下,具体文件由 `memory` 行的 `storage` 配置决定:`host-medium`(默认)全部保存在 `memory.json`;`sqlite` 经一次性迁移把 store 移入插件自有的 `memory.db`(此后 `memory.json` 只保留迁移标记):
|
|
172
173
|
|
|
173
174
|
```sh
|
|
174
175
|
# macOS/Linux
|
|
@@ -198,21 +199,23 @@ dsh --profile web --dump-config | grep memory
|
|
|
198
199
|
```
|
|
199
200
|
- id: memory-root
|
|
200
201
|
name: '@chenhw7/dsh-memory'
|
|
201
|
-
- id: memory
|
|
202
|
+
- id: memory
|
|
202
203
|
name: '@chenhw7/dsh-memory/store'
|
|
203
|
-
- id:
|
|
204
|
+
- id: memory-tools
|
|
204
205
|
name: '@chenhw7/dsh-memory/tool'
|
|
205
206
|
- id: memory-review
|
|
206
207
|
name: '@chenhw7/dsh-memory/review'
|
|
207
208
|
- id: memory-notes
|
|
208
209
|
name: '@chenhw7/dsh-memory/notes'
|
|
209
|
-
- id: memory-
|
|
210
|
+
- id: memory-identity
|
|
211
|
+
name: '@chenhw7/dsh-memory/identity'
|
|
212
|
+
- id: memory-autorecall
|
|
210
213
|
name: '@chenhw7/dsh-memory/context'
|
|
211
214
|
- id: memory-remote
|
|
212
215
|
name: '@chenhw7/dsh-memory/remote-service'
|
|
213
216
|
```
|
|
214
217
|
|
|
215
|
-
然后启动 dsh
|
|
218
|
+
然后启动 dsh,打开 **设置 → 插件 → @chenhw7/dsh-memory**,它的页面承载五个配置 section:
|
|
216
219
|
|
|
217
220
|
```sh
|
|
218
221
|
dsh web
|
|
@@ -220,15 +223,15 @@ dsh web
|
|
|
220
223
|
|
|
221
224
|
## 配置
|
|
222
225
|
|
|
223
|
-
|
|
226
|
+
每个 bundle 行都自带设置(`Config`),**行 id 就是宿主寻址它的设置命名空间**。bundle 在**设置 → 插件**里的页面把五个可编辑条目渲染成 section;每个 section 写入拥有该字段的条目,且改动**全部实时生效**——宿主用新配置重跑插件,因此在下一次事件或调用时即生效,无需重启:
|
|
224
227
|
|
|
225
|
-
- **`memory
|
|
226
|
-
- **`memory-notes
|
|
227
|
-
- **`memory-autorecall
|
|
228
|
-
- **`memory-identity
|
|
229
|
-
- **`memory-review
|
|
228
|
+
- **`memory`**——store:注入模式、记忆预算、检索上限、衰减窗口、存储后端。由 `/store` 行持有。
|
|
229
|
+
- **`memory-notes`**——项目笔记 prompt 段开关与预算。由 `/notes` 持有。
|
|
230
|
+
- **`memory-autorecall`**——步级召回围栏与使用命中信号。由 `/context` 持有。
|
|
231
|
+
- **`memory-identity`**——身份层开关、预算与种子目录。由 `/identity` 持有。
|
|
232
|
+
- **`memory-review`**——提取管线、模型路由、去重裁决、失败序列踩坑、curator pass、人审闸门。由 `/review` 持有。
|
|
230
233
|
|
|
231
|
-
|
|
234
|
+
每个值按分层 resolve:schema 默认 → profile patch 中该行的 `config:` 条目 → 设置页保存的值。未动的字段继承组合值,因此部署可以固定默认值,用户只覆盖所需部分。兄弟插件之间不直接读对方的配置:拥有某个旋钮的条目通过自己的服务发布它(`ctx.memory.settings()`、`ctx.projectNotes.settings()`、`ctx.identity.settings()`、`ctx.memoryReview.settings()`)——这就是 `maxSearchResults` 与 `decayDays` 落在 `memory`、而 `confirmBeforeWrite` 落在 `memory-review` 的原因。
|
|
232
235
|
|
|
233
236
|
### `memory` 命名空间
|
|
234
237
|
|
|
@@ -251,7 +254,7 @@ dsh web
|
|
|
251
254
|
| `notesPitfallsCharLimit` | `800` | 项目笔记「踩坑」半区的字符预算,约定区不再能把它挤死。同样按冻结时应用、同样折叠计数行。 |
|
|
252
255
|
| `notesMaxEntriesPerFile` | `100` | 选中进项目笔记段落的最大条目数(置顶优先,其次重要性、再新鲜度);其余折叠为计数行。 |
|
|
253
256
|
|
|
254
|
-
> **设置迁移**:0.9.x 的合并键 `notesCharLimit` 仍然生效——当只有它被设置时,两个半区按 60%/40%(约定/踩坑)派生;每设置一个新键即接管对应半区。把
|
|
257
|
+
> **设置迁移**:0.9.x 的合并键 `notesCharLimit` 仍然生效——当只有它被设置时,两个半区按 60%/40%(约定/踩坑)派生;每设置一个新键即接管对应半区。把 `memory-notes` 行的 `config:`(或设置页)里的键改名即完成迁移。
|
|
255
258
|
|
|
256
259
|
### `memory-autorecall` 命名空间
|
|
257
260
|
|
|
@@ -291,14 +294,15 @@ dsh web
|
|
|
291
294
|
| `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
|
|
292
295
|
| `confirmBeforeWrite` | `false` | 人审模式:所有提取(review/flush/curator)*与*每次 `memory_add`/`memory_replace` 调用都改为在待确认队列中生成提议,而非直接写库,直到有人在设置「记忆」区(待确认页)采纳。同一提议被反复观察会累计 `hits` 并置顶;对既有条目的修改提议携带其 id,在人工采纳前不会改动原文。 |
|
|
293
296
|
|
|
294
|
-
>
|
|
297
|
+
> 特意**没有 `memory-tools` 设置条目**:工具行本身不拥有旋钮。它从 `ctx.memory.settings()` 读 `maxSearchResults`、从 `ctx.memoryReview.settings()` 读 `confirmBeforeWrite`、从 `ctx.identity.settings()` 读身份开关与预算。它自己的 `config.maxSearchResults` 只在没有 store 组合时兜底。
|
|
295
298
|
|
|
296
299
|
### 组合配置与 UI 设置
|
|
297
300
|
|
|
298
|
-
|
|
301
|
+
每个条目都接受来自两个层的相同键:profile patch 中该行的 `config:` 块是组合默认值,设置页在其上写用户层。要把 `maxSearchResults: 100` 钉为部署默认值(用户仍可覆盖):
|
|
299
302
|
|
|
300
303
|
```yaml
|
|
301
|
-
memory
|
|
304
|
+
- id: memory
|
|
305
|
+
name: '@chenhw7/dsh-memory/store'
|
|
302
306
|
config:
|
|
303
307
|
maxSearchResults: 100
|
|
304
308
|
```
|
|
@@ -306,54 +310,65 @@ memory:
|
|
|
306
310
|
默认情况下,提取、去重裁决和 curation 使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,设置 `extractionModelProvider` 和 `extractionModelModel`(在组合配置或 UI 中均可——UI 提供由宿主模型目录驱动的下拉框)。在此指定 provider 会把对话摘录与已存条目发送给它,因此请选择你愿意托付对话内容的一方;两者留空则不会新增任何数据通路,只用你本来就在对话的模型:
|
|
307
311
|
|
|
308
312
|
```yaml
|
|
309
|
-
memory-review
|
|
313
|
+
- id: memory-review
|
|
314
|
+
name: '@chenhw7/dsh-memory/review'
|
|
310
315
|
config:
|
|
311
316
|
extractionModelProvider: deepseek
|
|
312
317
|
extractionModelModel: deepseek-chat
|
|
313
318
|
```
|
|
314
319
|
|
|
315
|
-
|
|
320
|
+
profile patch 示例(把每个条目的默认值钉住;设置页写入的也是同一批键):
|
|
316
321
|
|
|
317
322
|
```yaml
|
|
318
|
-
memory
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
323
|
+
- id: memory
|
|
324
|
+
name: '@chenhw7/dsh-memory/store'
|
|
325
|
+
config:
|
|
326
|
+
memoryMode: digest
|
|
327
|
+
memoryPolicyCustomText: ''
|
|
328
|
+
memoryCharLimit: 5000
|
|
329
|
+
memoryDigestCharLimit: 800
|
|
330
|
+
memoryMaxEntries: 20
|
|
331
|
+
maxSearchResults: 50
|
|
332
|
+
decayDays: 30
|
|
333
|
+
- id: memory-notes
|
|
334
|
+
name: '@chenhw7/dsh-memory/notes'
|
|
335
|
+
config:
|
|
336
|
+
notesEnabled: true
|
|
337
|
+
notesConventionsCharLimit: 1600
|
|
338
|
+
notesPitfallsCharLimit: 800
|
|
339
|
+
notesMaxEntriesPerFile: 100
|
|
340
|
+
- id: memory-autorecall
|
|
341
|
+
name: '@chenhw7/dsh-memory/context'
|
|
342
|
+
config:
|
|
343
|
+
autoRecallEnabled: true
|
|
344
|
+
autoRecallLimit: 5
|
|
345
|
+
autoRecallMinChars: 12
|
|
346
|
+
hitSignalEnabled: false
|
|
347
|
+
hitSignalThreshold: 0.25
|
|
348
|
+
- id: memory-identity
|
|
349
|
+
name: '@chenhw7/dsh-memory/identity'
|
|
350
|
+
config:
|
|
351
|
+
identityEnabled: false
|
|
352
|
+
soulCharLimit: 2000
|
|
353
|
+
userCharLimit: 3000
|
|
354
|
+
identitySeedDir: ''
|
|
355
|
+
- id: memory-review
|
|
356
|
+
name: '@chenhw7/dsh-memory/review'
|
|
357
|
+
config:
|
|
358
|
+
reviewEnabled: true
|
|
359
|
+
reviewCandidateThreshold: 10
|
|
360
|
+
flushOnCompaction: true
|
|
361
|
+
flushOnDispose: true
|
|
362
|
+
extractionModelProvider: ''
|
|
363
|
+
extractionModelModel: ''
|
|
364
|
+
extractionBudget: 20
|
|
365
|
+
judgeEnabled: true
|
|
366
|
+
pitfallStreakThreshold: 2
|
|
367
|
+
curatorEnabled: true
|
|
368
|
+
curatorEveryNSessions: 20
|
|
369
|
+
curatorMaxEntries: 5
|
|
370
|
+
curatorMinChars: 400
|
|
371
|
+
confirmBeforeWrite: false
|
|
357
372
|
```
|
|
358
373
|
|
|
359
374
|
`memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
|
|
@@ -361,9 +376,11 @@ memory-review:
|
|
|
361
376
|
当 `memoryMode` 为 `custom` 时,`memoryPolicyCustomText` 会作为 memory 段落原样注入。它支持使用 YAML 的 `|` 写多行文本。例如:
|
|
362
377
|
|
|
363
378
|
```yaml
|
|
364
|
-
memory
|
|
365
|
-
|
|
366
|
-
|
|
379
|
+
- id: memory
|
|
380
|
+
name: '@chenhw7/dsh-memory/store'
|
|
381
|
+
config:
|
|
382
|
+
memoryMode: custom
|
|
383
|
+
memoryPolicyCustomText: |
|
|
367
384
|
<memory-policy>
|
|
368
385
|
Persistent memory is available through memory tools. Do not assume memory has already been loaded into the prompt.
|
|
369
386
|
|
|
@@ -387,11 +404,12 @@ memory:
|
|
|
387
404
|
| 行 | 导出 | 作用 |
|
|
388
405
|
|---|---|---|
|
|
389
406
|
| `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
|
|
390
|
-
| `memory
|
|
391
|
-
| `
|
|
407
|
+
| `memory` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域(entries + audit + 待确认队列 + meta 四张表),注册 `ctx.memory`(BM25 检索 + 两层衰减),并通过 `ctx.memory.settings()` 发布共享的注入/召回设置 |
|
|
408
|
+
| `memory-tools` | `@chenhw7/dsh-memory/tool` | 九个模型可用工具(人审模式下写入改为入队) |
|
|
392
409
|
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator + 人审队列),持有 `memory-review` 设置命名空间 |
|
|
393
410
|
| `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记 prompt 投影(渲染约定/踩坑进 `project-notes` 段落;0.6 起不写仓库文件),注册 `ctx.projectNotes`;会话创建时清理 ≤0.5.x 的文件导出残留 |
|
|
394
|
-
| `memory-
|
|
411
|
+
| `memory-identity` | `@chenhw7/dsh-memory/identity` | 注册 `ctx.identity`:从 store 的身份表播种并读取两份自我文档(SOUL.md / USER.md) |
|
|
412
|
+
| `memory-autorecall` | `@chenhw7/dsh-memory/context` | 系统提示注入(`memory` @6000 + `project-notes` @6001,位于工具指引之后)与消息尾部注入(一次性清单 + 每步召回围栏),持有 auto-recall 设置 |
|
|
395
413
|
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务(设置「记忆」区经 `/api` 通道消费) |
|
|
396
414
|
|
|
397
415
|
**存储**:本 bundle **不**插入 `storage-json` / `storage-domain` 行。`dsh-web-app` bundle 已经提供它们(并在 `$DSH_HOME/storages` 下使用正确的根路径)。如果在这里重复插入,会覆盖已有配置(patch 会替换整行,后写覆盖先写)。memory store provider 将 `storageDomain` 服务作为 peer dependency 使用。
|
|
@@ -418,7 +436,7 @@ memory:
|
|
|
418
436
|
- **会话中途的提取在下次压缩或新会话前不会出现在提示里** — 注入段落为 KV-cache 稳定性而冻结;步级自动召回(默认开)提供逐步新鲜度,一次性清单在压缩后补发一次。
|
|
419
437
|
- **远程管理访问同时依赖传输信任与部署开关** — 任何被 dsh 宿主 `trustedHosts` 放行的主机都能调用读取 RPC;普通远程记忆写入默认拒绝(`remoteWritesEnabled: false`),只有显式启用后才开放,且 `identityRevert` 在写开关之上还要求独立的 `identityRevertEnabled` 开关(默认 `true`)——它恢复的是通过 scanner 的历史版本,而非接受任意新内容。应收紧 `trustedHosts`,且除非放行的每台主机都可信,否则保持远程写入关闭(见[威胁模型](docs/TECH_DESIGN.zh.md))。
|
|
420
438
|
- **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
|
|
421
|
-
- **要求
|
|
439
|
+
- **要求 Harness 0.2.x** — 本 bundle 使用 0.2 宿主契约(每条目插件 `Config`、`plugins.bundle.config` 设置页、生产者自声明消息来源、tool 结果为 tool 角色消息),peer 声明 `^0.2.2-rc.1` 且 `engines.dsh: ">=0.2.2-rc.1 <0.3.0"`。0.1.x 宿主无法加载:其 `ctx.settings.installSection` 模型在 0.2 已移除,且 0.2 去掉了 `dsh-invariants`。本 bundle 0.10.0 之前的版本面向 0.1.x 线——若你仍在 0.1 宿主上,请钉住那些版本。
|
|
422
440
|
|
|
423
441
|
## 许可证
|
|
424
442
|
|
package/cordis.patch.yml
CHANGED
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
# (last-write-wins would clobber the web-app's root config otherwise).
|
|
14
14
|
#
|
|
15
15
|
# Row order carries no load semantics; the grouping is for readers.
|
|
16
|
+
#
|
|
17
|
+
# Row ids are also the settings namespaces: each row's module declares the
|
|
18
|
+
# Config its page edits (`memory`, `memory-review`, `memory-identity`,
|
|
19
|
+
# `memory-notes`, `memory-autorecall`), and the host's plugin pages address a
|
|
20
|
+
# row's configuration by exactly this id. Renaming a row renames its settings
|
|
21
|
+
# entry, so stored user overrides under the old id stop applying.
|
|
16
22
|
|
|
17
23
|
- insert:
|
|
18
24
|
# Root entry: lets the host client-module scanner discover dsh.client.
|
|
@@ -21,14 +27,16 @@
|
|
|
21
27
|
- id: memory-root
|
|
22
28
|
name: '@chenhw7/dsh-memory'
|
|
23
29
|
|
|
24
|
-
# Memory store provider — opens the 'memory' domain, registers ctx.memory
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
-
|
|
30
|
+
# Memory store provider — opens the 'memory' domain, registers ctx.memory,
|
|
31
|
+
# and publishes the shared injection/recall settings the sibling rows read
|
|
32
|
+
# back through that service. Requires the storage-domain facility
|
|
33
|
+
# (provided by dsh-web-app; headless users must add storage-domain
|
|
34
|
+
# themselves — see README).
|
|
35
|
+
- id: memory
|
|
28
36
|
name: '@chenhw7/dsh-memory/store'
|
|
29
37
|
|
|
30
38
|
# Model-facing memory tools (memory_search/add/replace/remove/list/get).
|
|
31
|
-
- id:
|
|
39
|
+
- id: memory-tools
|
|
32
40
|
name: '@chenhw7/dsh-memory/tool'
|
|
33
41
|
|
|
34
42
|
# Automatic extraction: projection accumulator + compaction/dispose flush.
|
|
@@ -42,13 +50,14 @@
|
|
|
42
50
|
name: '@chenhw7/dsh-memory/notes'
|
|
43
51
|
|
|
44
52
|
# Identity layer: seeds and reads the agent's self-documents (SOUL.md /
|
|
45
|
-
# USER.md) from the store's identity tables; memory-
|
|
53
|
+
# USER.md) from the store's identity tables; memory-autorecall injects them
|
|
46
54
|
# as the `soul` (80) and `user-profile` (81) prompt sections.
|
|
47
55
|
- id: memory-identity
|
|
48
56
|
name: '@chenhw7/dsh-memory/identity'
|
|
49
57
|
|
|
50
|
-
# System-prompt section injection +
|
|
51
|
-
|
|
58
|
+
# System-prompt section injection + the step-tail digest/recall fence. Owns
|
|
59
|
+
# the `memory-autorecall` settings entry (the fence and the hit signal).
|
|
60
|
+
- id: memory-autorecall
|
|
52
61
|
name: '@chenhw7/dsh-memory/context'
|
|
53
62
|
|
|
54
63
|
# @Remote service for the memory management UI (§7.7). The write switch
|