@chenhw7/dsh-memory 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +42 -20
  2. package/README.zh-CN.md +42 -21
  3. package/cordis.patch.yml +5 -3
  4. package/lib/client/index.js +10 -22
  5. package/lib/context/index.d.ts +2 -6
  6. package/lib/context/index.d.ts.map +1 -1
  7. package/lib/context/index.js +17 -20
  8. package/lib/context/index.js.map +1 -1
  9. package/lib/context/policy.d.ts +5 -5
  10. package/lib/context/policy.d.ts.map +1 -1
  11. package/lib/context/policy.js +5 -5
  12. package/lib/context/policy.js.map +1 -1
  13. package/lib/notes/cleanup.d.ts +42 -0
  14. package/lib/notes/cleanup.d.ts.map +1 -0
  15. package/lib/notes/cleanup.js +93 -0
  16. package/lib/notes/cleanup.js.map +1 -0
  17. package/lib/notes/index.d.ts +21 -23
  18. package/lib/notes/index.d.ts.map +1 -1
  19. package/lib/notes/index.js +31 -117
  20. package/lib/notes/index.js.map +1 -1
  21. package/lib/notes/render.d.ts +13 -13
  22. package/lib/notes/render.d.ts.map +1 -1
  23. package/lib/notes/render.js +13 -13
  24. package/lib/notes/render.js.map +1 -1
  25. package/lib/notes/scope.d.ts +8 -7
  26. package/lib/notes/scope.d.ts.map +1 -1
  27. package/lib/notes/scope.js +8 -7
  28. package/lib/notes/scope.js.map +1 -1
  29. package/lib/notes/settings.d.ts +9 -10
  30. package/lib/notes/settings.d.ts.map +1 -1
  31. package/lib/notes/settings.js +9 -10
  32. package/lib/notes/settings.js.map +1 -1
  33. package/lib/review/accumulator.d.ts +5 -5
  34. package/lib/review/accumulator.d.ts.map +1 -1
  35. package/lib/review/accumulator.js +3 -3
  36. package/lib/review/accumulator.js.map +1 -1
  37. package/lib/review/index.d.ts.map +1 -1
  38. package/lib/review/index.js +14 -12
  39. package/lib/review/index.js.map +1 -1
  40. package/lib/tool/index.d.ts.map +1 -1
  41. package/lib/tool/index.js +2 -3
  42. package/lib/tool/index.js.map +1 -1
  43. package/package.json +50 -31
  44. package/lib/notes/writer.d.ts +0 -65
  45. package/lib/notes/writer.d.ts.map +0 -1
  46. package/lib/notes/writer.js +0 -131
  47. package/lib/notes/writer.js.map +0 -1
package/README.md CHANGED
@@ -1,13 +1,22 @@
1
- # @chenhw7/dsh-memory
1
+ # Cairn
2
2
 
3
- Long-term memory for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), packaged as one installable profile bundle. Cross-session persistent memory — facts, preferences, corrections, and lessons survive across sessions and restarts.
3
+ **Cairn** is long-term memory for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), packaged as the `@chenhw7/dsh-memory` profile bundle — facts, preferences, corrections, and lessons survive across sessions and restarts.
4
4
 
5
5
  This is a **self-contained single package** (not a multi-package workspace). It depends on dsh core services as **peer dependencies** (provided by the dsh installation you already have) and ships its own `cordis.patch.yml` so `dsh plugin add` activates it as one profile layer.
6
6
 
7
7
  **English** | [简体中文](README.zh-CN.md)
8
8
 
9
+ ## Interactive Deep-Dive
10
+
11
+ A single-file, zero-dependency illustrated walkthrough of the whole pipeline — signal capture, storage, retrieval, injection, and decay. The figures are not static: the extraction loop, the write-path security gates, the BM25 kernel ported from `src/store/bm25.ts`, and a decay simulator all run live in your browser. It is served from this repo via GitHub Pages:
12
+
13
+ [![Hero preview](assets/memory-architecture-hero.png)](https://chenhw7.github.io/dsh-memory/memory-architecture.html)
14
+
15
+ → **Open the live page: [memory-architecture.html](https://chenhw7.github.io/dsh-memory/memory-architecture.html)** · [简体中文版](https://chenhw7.github.io/dsh-memory/memory-architecture.zh-CN.html)
16
+
9
17
  ## Table of Contents
10
18
 
19
+ - [Interactive Deep-Dive](#interactive-deep-dive)
11
20
  - [Features](#features)
12
21
  - [Install](#install)
13
22
  - [Update](#update)
@@ -26,18 +35,19 @@ Your dsh agent normally forgets everything when you close a session. This bundle
26
35
  - **Persistent memory** — facts, preferences, and conventions stored in a durable KV backend with audit logging.
27
36
  - **Three-layer scoping** — `global` (cross-project), `project` (per-repo, auto-detected), and `user` (cross-project profile).
28
37
  - **Eight model-facing tools** — `memory_search`, `memory_add`, `memory_replace`, `memory_remove`, `memory_list`, `memory_get`, `memory_pin`, `memory_unpin`.
29
- - **BM25 relevance search** — dependency-free Okapi BM25 over CJK-aware tokenization (Latin word tokens; CJK unigrams + bigrams), pinned entries surfaced ahead of equal-relevance matches.
30
- - **Automatic learning** — a projection accumulator watches the conversation for explicit remember-intent, corrections, and *verified failure streaks* (repeated same-signature tool failures resolved by a success), then runs LLM extraction when enough candidates accumulate.
31
- - **In-repo project notes** — coding conventions and a pitfall log render into your repo (`docs/agent-memory/` by default) as git-manageable markdown, inject into every session's system prompt, and stay discoverable via a managed `AGENTS.md` pointer.
38
+ - **BM25 relevance search** — dependency-free Okapi BM25 over CJK-aware tokenization (Latin word tokens; CJK unigrams + bigrams), pinned entries surfaced ahead of equal-relevance matches. Retrieval quality is not vibes: a fixed golden set (24 entries × 24 queries, English + Chinese) is evaluated in CI — success@5 = 100%, MRR = 0.958 — with injection-cost numbers per prompt mode (see [docs/INDEX_MODE_EVALUATION.zh-CN.md](docs/INDEX_MODE_EVALUATION.zh-CN.md)).
39
+ - **Automatic learning** — a projection accumulator watches the conversation for explicit remember-intent, corrections, and *verified failure streaks* (repeated same-signature tool failures resolved by a success), then runs LLM extraction when enough candidates accumulate. Admission rules exclude anything the repository already records (code structure, git history, fixed-bug narratives), and model-handwritten date prefixes are stripped so timestamps always come from the program.
40
+ - **Project notes prompt section** — coding conventions and a pitfall log render into every session's system prompt (`project-notes` section). Nothing is written into your repository: memory lives entirely in the host-side store, is managed in the Memory settings UI, and upgrades automatically clean up notes files left by ≤0.5.x installs.
32
41
  - **Dedup pipeline** — two-stage deduplication (stop-word-filtered Jaccard prefilter + optional LLM judge with bounded merges) prevents near-duplicate accumulation; a low-frequency curator pass re-summarizes oversized entries.
33
- - **Two-tier memory lifecycle** — pin important memories; overdue project-scoped entries are removed while overdue `global`/`user` entries are soft-decayed (hidden from standing injections, still searchable, un-stamped on recall); every write is audited.
42
+ - **Two-tier memory lifecycle** — pin important memories; overdue project-scoped entries are removed while overdue `global`/`user` entries are soft-decayed (hidden from standing injections, still searchable, un-stamped on recall); entries can also be manually archived from the UI; every write is audited.
34
43
  - **Step-level auto recall (opt-in)** — 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.
35
44
  - **Compaction-aware flush** — when compaction shadows old context, the raw events are scanned for anything worth remembering.
36
45
  - **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.
37
46
  - **Frontend-configurable** — all settings exposed through four cards in the dsh settings UI, apply live.
38
- - **Optional human review before write** — flip one setting and every extraction/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.
47
+ - **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.
39
48
  - **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.
40
- - **Time-window browsing** — `memory_list` accepts `since`/`until` epoch-ms bounds so "what did we learn last week" pages within the window.
49
+ - **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.
50
+ - **Optional summaries for progressive disclosure** — `memory_add`/`memory_replace` accept a `summary`, and extraction can emit a `[summary:…]` tag; index mode and auto-recall render summaries instead of truncated content.
41
51
 
42
52
  ## Install
43
53
 
@@ -71,6 +81,13 @@ Your dsh agent normally forgets everything when you close a session. This bundle
71
81
 
72
82
  - A profile you want to add memory to (this guide uses `web`).
73
83
 
84
+ > [!IMPORTANT]
85
+ > **Harness channel: `alpha` (0.1.2-alpha.x).** This bundle is built against the
86
+ > `@deepseek-ai/dsh-settings` 0.1.2-alpha API (`ctx.settings.installSection`)
87
+ > and declares `^0.1.2-alpha.2` peers. Install dsh from the `alpha` channel —
88
+ > the rc (`next`) line ships the removed module-level helpers and cannot load
89
+ > this bundle. See [Known Limitations](#known-limitations).
90
+
74
91
  ### From npm (recommended)
75
92
 
76
93
  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:
@@ -111,8 +128,8 @@ If you'd rather not install from the npm registry, pack a tarball from a checkou
111
128
  ```sh
112
129
  cd dsh-memory
113
130
  npm install && npm run build
114
- npm pack # produces chenhw7-dsh-memory-0.4.0.tgz
115
- dsh plugin add --profile web ./chenhw7-dsh-memory-0.4.0.tgz
131
+ npm pack # produces chenhw7-dsh-memory-0.5.0.tgz
132
+ dsh plugin add --profile web ./chenhw7-dsh-memory-0.5.0.tgz
116
133
  ```
117
134
 
118
135
  ## Update
@@ -131,6 +148,10 @@ With a source checkout:
131
148
  pnpm dsh plugin --profile web update @chenhw7/dsh-memory
132
149
  ```
133
150
 
151
+ ### Upgrading from 0.5.x
152
+
153
+ Version 0.6 stops exporting memory into repository files. The `docs/agent-memory/CONVENTIONS.md` / `PITFALLS.md` renders and the managed `AGENTS.md` pointer block are gone; memory is prompt-injected and managed in the Memory settings UI only. On the first session in each project, the plugin removes what ≤0.5.x left behind: the managed pointer block is stripped from `AGENTS.md` (a pointer-only `AGENTS.md` is deleted) and the generated files under `docs/agent-memory/` are deleted (only files the plugin generated; anything else in that directory is kept). You can also delete them by hand at any time — nothing writes there anymore.
154
+
134
155
  ## Uninstall
135
156
 
136
157
  Remove the plugin from a profile:
@@ -205,13 +226,12 @@ Every namespace resolves in layers: schema defaults → the composition `config:
205
226
  | `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`. |
206
227
  | `memoryPolicyCustomText` | — | Custom policy text used when `memoryMode` is `custom`. |
207
228
  | `memoryCharLimit` | `5000` | Character budget for the frozen per-session memory snapshot injected in `full` mode (`0` = no content). |
229
+ | `memoryMaxEntries` | `20` | Entry-count cap for the same frozen snapshot (`0` = no limit). The snapshot ends with a `≈N tokens` estimate so injection cost stays visible. |
208
230
  | `maxSearchResults` | `50` | Default cap for `memory_search` / `memory_list` when the call omits `limit`; read live by the tool plugin. `0` = no limit. |
209
231
  | `decayDays` | `30` | Lifecycle window for entries not recalled within N days; read live by the review plugin's janitor. `0` = disabled. Overdue `project` entries are **removed** (hard decay); overdue `global`/`user` entries are instead **soft-decayed** — stamped `stale`, hidden from injection surfaces and notes files, still searchable, un-stamped automatically once recalled. Pinned entries are always exempt. |
210
- | `notesEnabled` | `true` | Export project notes (conventions + pitfall log) into the repo and inject them into the system prompt. Entries rendered into the notes files are excluded from the memory section to avoid double injection. |
211
- | `notesDir` | `docs/agent-memory` | Repo-relative directory holding the generated `CONVENTIONS.md` / `PITFALLS.md`. |
232
+ | `notesEnabled` | `true` | Inject the project-notes prompt section (conventions + pitfall log) into the system prompt. Entries rendered into the section are excluded from the memory section to avoid double injection. No repo files are written. |
212
233
  | `notesCharLimit` | `4000` | Character budget for the injected `project-notes` prompt section. |
213
- | `notesAgentsPointer` | `true` | Maintain the managed pointer block in the repo's `AGENTS.md`. |
214
- | `notesMaxEntriesPerFile` | `100` | Max entries per generated notes file (newest kept). |
234
+ | `notesMaxEntriesPerFile` | `100` | Max entries rendered into the project-notes section (newest kept). |
215
235
  | `autoRecallEnabled` | `false` | Step-level auto recall: on every agent step, run a BM25 search over the store keyed on the step's user text and append a fenced `<recalled-memory>` message. The system prompt is untouched, so the KV-cache prefix stays stable. |
216
236
  | `autoRecallLimit` | `5` | Max entries in one auto-recall fence (min 1). The fence itself is capped at 1200 characters. |
217
237
  | `autoRecallMinChars` | `12` | Skip recall when the step's user text is shorter than this many characters (min 1). |
@@ -233,6 +253,7 @@ Every namespace resolves in layers: schema defaults → the composition `config:
233
253
  | `curatorEveryNSessions` | `20` | Run the curator pass every N session creations. |
234
254
  | `curatorMaxEntries` | `5` | Max entries selected per curation pass (longest first). |
235
255
  | `curatorMinChars` | `400` | Only entries at least this long are selected for re-summarization. |
256
+ | `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. |
236
257
 
237
258
  > There is deliberately **no separate `tool-memory` settings namespace**: the tool plugin reads `maxSearchResults` live from the `memory` namespace above. Its composition `config.maxSearchResults` only serves as the fallback base when no settings service is mounted.
238
259
 
@@ -262,12 +283,11 @@ memory:
262
283
  memoryMode: policy-only
263
284
  memoryPolicyCustomText: ""
264
285
  memoryCharLimit: 5000
286
+ memoryMaxEntries: 20
265
287
  maxSearchResults: 50
266
288
  decayDays: 30
267
289
  notesEnabled: true
268
- notesDir: docs/agent-memory
269
290
  notesCharLimit: 4000
270
- notesAgentsPointer: true
271
291
  notesMaxEntriesPerFile: 100
272
292
  autoRecallEnabled: false
273
293
  autoRecallLimit: 5
@@ -286,6 +306,7 @@ memory-review:
286
306
  curatorEveryNSessions: 20
287
307
  curatorMaxEntries: 5
288
308
  curatorMinChars: 400
309
+ confirmBeforeWrite: false
289
310
  ```
290
311
 
291
312
  `memoryPolicyCustomText` is optional and only used when `memoryMode` is `custom`.
@@ -319,10 +340,10 @@ The bundle inserts seven rows over `dsh-base`, each pointing at this package's o
319
340
  | Row | Export | Role |
320
341
  |---|---|---|
321
342
  | `memory-root` | `@chenhw7/dsh-memory` | No-op root entry for client-module scanner discovery |
322
- | `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain, registers `ctx.memory` (BM25 search + two-tier decay) |
323
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools |
324
- | `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator) and the `memory-review` settings namespace |
325
- | `memory-notes` | `@chenhw7/dsh-memory/notes` | Project-notes export (render conventions/pitfalls + atomic write + AGENTS.md pointer), registers `ctx.projectNotes` |
343
+ | `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain (entries + audit + suggestion-queue tables), registers `ctx.memory` (BM25 search + two-tier decay) |
344
+ | `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools (confirm-mode writes queue as proposals) |
345
+ | `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator + human-review queue) and the `memory-review` settings namespace |
346
+ | `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 |
326
347
  | `memory-context` | `@chenhw7/dsh-memory/context` | System-prompt injection (`memory` @90 + `project-notes` @91), step-level auto recall, owns the `memory` settings namespace |
327
348
  | `memory-remote` | `@chenhw7/dsh-memory/remote-service` | `@Remote` service behind the settings UI's Memory section (consumed over the `/api` channel) |
328
349
 
@@ -349,6 +370,7 @@ The bundle inserts seven rows over `dsh-base`, each pointing at this package's o
349
370
  - **Extraction quality tracks the session model** — review/flush/curator reuse the session's routed provider/model unless explicitly overridden.
350
371
  - **Mid-session extractions stay out of the prompt until the next compaction or session** — the injected snapshot is frozen for KV-cache stability; step-level auto recall (opt-in) covers per-step freshness instead.
351
372
  - **dsh is in developer preview** — breaking changes are expected; this bundle's peer dependency ranges track the dsh release line.
373
+ - **Alpha channel (0.1.2-alpha.x) required** — the bundle uses the 0.1.2-alpha settings API (`ctx.settings.installSection`, host-only projection registrations) and declares `^0.1.2-alpha.2` peers. The rc (`next`) line still ships the removed module-level `installSettingsSection` helper and cannot load this bundle; install dsh from the `alpha` dist-tag. The client bundle likewise targets the alpha client packages (`@deepseek-ai/dsh-client-store` / `dsh-client-ui-settings`), which replaced the removed `dsh-client-runtime`.
352
374
 
353
375
  ## License
354
376
 
package/README.zh-CN.md CHANGED
@@ -1,13 +1,22 @@
1
- # @chenhw7/dsh-memory
1
+ # Cairn
2
2
 
3
3
  [English](README.md) | **简体中文**
4
4
 
5
- 为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 提供长期记忆能力的可安装 profile bundle。跨会话持久化记忆——事实、偏好、修正和经验在会话与重启后仍然保留。
5
+ **Cairn** 是为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 提供长期记忆能力的 `@chenhw7/dsh-memory` profile bundle —— 事实、偏好、修正和经验在会话与重启后仍然保留。
6
6
 
7
7
  这是一个**自包含的单一包**(不是多包 workspace)。它依赖 dsh 核心服务作为 **peer dependencies**(由你已经安装的 dsh 提供),并通过自带的 `cordis.patch.yml` 让 `dsh plugin add` 将其激活为一个 profile 层。
8
8
 
9
+ ## 交互式技术解析
10
+
11
+ 单文件、零依赖的图解技术深潜——完整拆解从信号捕获到存储、检索、注入、衰减的全流水线。图不是静态的:提取循环、写入路径安全闸、从 `src/store/bm25.ts` 移植的 BM25 内核、衰减模拟器,全部在你的浏览器里实时运行。页面由本仓库通过 GitHub Pages 托管:
12
+
13
+ [![首页预览](assets/memory-architecture-hero-zh-CN.png)](https://chenhw7.github.io/dsh-memory/memory-architecture.zh-CN.html)
14
+
15
+ → **打开在线页面:[memory-architecture.zh-CN.html](https://chenhw7.github.io/dsh-memory/memory-architecture.zh-CN.html)** · [English version](https://chenhw7.github.io/dsh-memory/memory-architecture.html)
16
+
9
17
  ## 目录
10
18
 
19
+ - [交互式技术解析](#交互式技术解析)
11
20
  - [功能特性](#功能特性)
12
21
  - [安装](#安装)
13
22
  - [更新](#更新)
@@ -23,18 +32,19 @@
23
32
  - **持久化记忆** — 将事实、偏好和约定存储在持久的 KV 后端中,带审计日志。
24
33
  - **三层作用域** — `global`(跨项目)、`project`(按仓库自动检测)、`user`(跨项目 profile)。
25
34
  - **八个模型可用工具** — `memory_search`、`memory_add`、`memory_replace`、`memory_remove`、`memory_list`、`memory_get`、`memory_pin`、`memory_unpin`。
26
- - **BM25 相关性检索** — 零依赖的 Okapi BM25,CJK 感知分词(Latin 逐词;CJK 一元 + 相邻二元 bigram),固定(pin)条目在同等相关时优先靠前。
27
- - **自动学习** — 投影累加器观察对话中的显式记忆意图、修正语句以及*已验证的失败序列*(同签名连续失败后最终成功),候选足够多时运行 LLM 提取。
28
- - **仓库内项目笔记** — 编码约定与踩坑日志渲染为仓库内可 git 管理的 markdown(默认 `docs/agent-memory/`),每次会话注入 system prompt,并在 `AGENTS.md` 中维护一行托管指针块供其他工具发现。
35
+ - **BM25 相关性检索** — 零依赖的 Okapi BM25,CJK 感知分词(Latin 逐词;CJK 一元 + 相邻二元 bigram),固定(pin)条目在同等相关时优先靠前。检索质量不是玄学:固定 golden set(24 条 × 24 组查询,中英混合)在 CI 中实测——success@5 = 100%、MRR = 0.958——并附各注入模式的成本数字(见 [docs/INDEX_MODE_EVALUATION.zh-CN.md](docs/INDEX_MODE_EVALUATION.zh-CN.md))。
36
+ - **自动学习** — 投影累加器观察对话中的显式记忆意图、修正语句以及*已验证的失败序列*(同签名连续失败后最终成功),候选足够多时运行 LLM 提取。准入规则排除一切"仓库已记录的内容"(代码结构、git 历史、已修复 bug 的经过),模型手写的日期前缀会被剥离,时间戳永远由程序盖戳。
37
+ - **项目笔记 prompt 段落** — 编码约定与踩坑日志渲染进每次会话的 system prompt(`project-notes` 段)。不向仓库写入任何文件:记忆完全保存在 host 侧存储中,在 Memory 设置 UI 里管理;升级时自动清理 ≤0.5.x 留下的笔记文件。
29
38
  - **去重管线** — 两阶段去重(停用词过滤的 Jaccard 预过滤 + 可选 LLM 裁决,合并长度有上限),防止近似重复条目累积;低频 curator pass 会将过长条目改写为简洁单行。
30
- - **两层记忆生命周期** — 固定重要记忆;过期的 project 作用域条目被移除,而过期的 `global`/`user` 条目做软衰减(从常驻注入面隐藏但仍可搜索,再次召回即解除);每次写入都有审计。
39
+ - **两层记忆生命周期** — 固定重要记忆;过期的 project 作用域条目被移除,而过期的 `global`/`user` 条目做软衰减(从常驻注入面隐藏但仍可搜索,再次召回即解除);条目也可以从界面手动归档;每次写入都有审计。
31
40
  - **步级自动召回(可选)** — 每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息;不触碰 system prompt,保持 KV-cache 前缀稳定。
32
41
  - **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
33
42
  - **安全扫描:写入时 + 读取时** — API Key、Token、提示注入模式和泄露尝试会被阻止写入;漏网内容在重新进入 prompt 的任何位置都会被替换为 `[BLOCKED: …]` 占位符。
34
43
  - **前端可配置** — 所有设置通过 dsh 设置界面的四张卡片暴露,实时生效。
35
- - **可选的写入前人工确认** — 打开一个开关后,自动提取与工具产生的写入一律先进入待确认队列(同一提议反复出现会累计次数并置顶);采纳才落库(可先编辑),拒绝即丢弃。模型永不自我提升:对既有条目的修改提议在你采纳前不会改动原文。
36
- - **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25 搜索、类别筛选、远程分页列表,并带完整写操作(编辑 / 置顶 / 归档 / 删除),中英双语。
37
- - **时间窗浏览** — `memory_list` 支持 `since`/`until` 毫秒时间戳边界,「上周学了什么」这类查询直接在窗口内分页。
44
+ - **可选的写入前人工确认** — 打开一个开关(`confirmBeforeWrite`)后,自动提取*与*工具调用产生的写入一律先进入待确认队列(同一提议反复出现会累计次数并置顶);采纳才落库(可先编辑),拒绝即丢弃。模型永不自我提升:对既有条目的修改提议在你采纳前不会改动原文。
45
+ - **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25 搜索、类别筛选、懒加载条目列表,并带完整写操作(编辑 / 置顶 / 归档 / 删除),中英双语。
46
+ - **时间窗浏览 + 智能列表视图** — `memory_list` 默认按最新在前返回,附带 `earliest`/`latest`/`hasStale` 元数据,支持 `since`/`until` 毫秒时间戳边界(「上周学了什么」这类查询直接在窗口内分页);过滤条件命中 0 条但库非空时,会提示放宽过滤条件。
47
+ - **可选摘要(渐进式披露)** — `memory_add`/`memory_replace` 接受 `summary`,提取也可以输出 `[summary:…]` 标签;index 模式与自动召回优先渲染摘要而非截断正文。
38
48
 
39
49
  ## 安装
40
50
 
@@ -69,6 +79,12 @@
69
79
 
70
80
  - 准备一个要添加记忆能力的 profile(本文以 `web` 为例)。
71
81
 
82
+ > [!IMPORTANT]
83
+ > **Harness 渠道:`alpha`(0.1.2-alpha.x)。** 本 bundle 按 `@deepseek-ai/dsh-settings`
84
+ > 0.1.2-alpha API(`ctx.settings.installSection`)构建,peer 范围为 `^0.1.2-alpha.2`。
85
+ > 请从 `alpha` 渠道安装 dsh——rc(`next`)线仍带着已被移除的模块级 helper,无法加载
86
+ > 本 bundle。见[已知限制](#已知限制)。
87
+
72
88
  ### 从 npm 安装(推荐)
73
89
 
74
90
  一条命令。npm 上的 tarball 是预构建的,安装时 pnpm 不会在你的机器上运行任何构建脚本,也不需要额外的 pnpm 配置:
@@ -109,8 +125,8 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
109
125
  ```sh
110
126
  cd dsh-memory
111
127
  npm install && npm run build
112
- npm pack # 生成 chenhw7-dsh-memory-0.4.0.tgz
113
- dsh plugin add --profile web ./chenhw7-dsh-memory-0.4.0.tgz
128
+ npm pack # 生成 chenhw7-dsh-memory-0.5.0.tgz
129
+ dsh plugin add --profile web ./chenhw7-dsh-memory-0.5.0.tgz
114
130
  ```
115
131
 
116
132
  ## 更新
@@ -129,6 +145,10 @@ dsh plugin --profile web update @chenhw7/dsh-memory
129
145
  pnpm dsh plugin --profile web update @chenhw7/dsh-memory
130
146
  ```
131
147
 
148
+ ### 从 0.5.x 升级
149
+
150
+ 0.6 版本停止向仓库导出记忆文件:`docs/agent-memory/CONVENTIONS.md` / `PITFALLS.md` 渲染文件与 `AGENTS.md` 托管指针块一并移除,记忆只通过 prompt 注入并在 Memory 设置 UI 中管理。升级后在每个项目的第一次会话里,插件会自动清理 ≤0.5.x 留下的产物:从 `AGENTS.md` 中剥离托管指针块(若文件只含指针块则整文件删除),并删除 `docs/agent-memory/` 下由插件生成的文件(只删插件生成的;目录中的其他文件保留)。你也可以随时手动删除它们——现在不会再有任何文件被写入仓库。
151
+
132
152
  ## 卸载
133
153
 
134
154
  从 profile 中移除插件:
@@ -203,13 +223,12 @@ dsh web
203
223
  | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
204
224
  | `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
205
225
  | `memoryCharLimit` | `5000` | 会话内冻结记忆快照注入 `full` 模式时的字符预算(`0` = 不注入内容)。 |
226
+ | `memoryMaxEntries` | `20` | 同一冻结快照的条目数上限(`0` = 无限制)。快照尾部附 `≈N tokens` 估算,注入成本始终可见。 |
206
227
  | `maxSearchResults` | `50` | `memory_search` / `memory_list` 在调用未传 `limit` 时的默认返回条数上限,由工具插件实时读取。`0` = 无限制。 |
207
228
  | `decayDays` | `30` | N 天内未召回条目的生命周期窗口,由 review 插件的 janitor 实时读取。`0` = 禁用。过期的 `project` 条目被**移除**(硬衰减);过期的 `global`/`user` 条目改为**软衰减**——打上 `stale` 戳,从注入面和笔记文件中隐藏但仍可搜索,再次召回即自动解除。固定(pin)条目始终豁免。 |
208
- | `notesEnabled` | `true` | 启用项目笔记的仓库内文件导出与 system prompt 注入。已渲染进笔记文件的条目会从 memory 段落中排除,避免重复注入。 |
209
- | `notesDir` | `docs/agent-memory` | 仓库内生成 `CONVENTIONS.md` / `PITFALLS.md` 的目录。 |
229
+ | `notesEnabled` | `true` | 注入项目笔记 prompt 段落(约定 + 踩坑日志)。已渲染进该段落的条目会从 memory 段落中排除,避免重复注入。不写任何仓库文件。 |
210
230
  | `notesCharLimit` | `4000` | 注入的 `project-notes` 段落字符上限。 |
211
- | `notesAgentsPointer` | `true` | 维护仓库 `AGENTS.md` 中的托管指针块。 |
212
- | `notesMaxEntriesPerFile` | `100` | 每个生成笔记文件的最大条目数(保留最新)。 |
231
+ | `notesMaxEntriesPerFile` | `100` | 渲染进项目笔记段落的最大条目数(保留最新)。 |
213
232
  | `autoRecallEnabled` | `false` | 步级自动召回:每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息。不触碰 system prompt,保持 KV-cache 前缀稳定。 |
214
233
  | `autoRecallLimit` | `5` | 单次自动召回围栏内的最大条数(最小 1)。围栏本身上限 1200 字符。 |
215
234
  | `autoRecallMinChars` | `12` | 该步用户文本短于该字符数时跳过召回(最小 1)。 |
@@ -231,6 +250,7 @@ dsh web
231
250
  | `curatorEveryNSessions` | `20` | 每 N 次会话创建运行一次 curator pass。 |
232
251
  | `curatorMaxEntries` | `5` | 每次 curation 最多选中的条目数(最长优先)。 |
233
252
  | `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
253
+ | `confirmBeforeWrite` | `false` | 人审模式:所有提取(review/flush/curator)*与*每次 `memory_add`/`memory_replace` 调用都改为在待确认队列中生成提议,而非直接写库,直到有人在设置「记忆」区(待确认页)采纳。同一提议被反复观察会累计 `hits` 并置顶;对既有条目的修改提议携带其 id,在人工采纳前不会改动原文。 |
234
254
 
235
255
  > 特意**没有独立的 `tool-memory` 设置命名空间**:工具插件从上面的 `memory` 命名空间实时读取 `maxSearchResults`。其组合配置 `config.maxSearchResults` 仅作为无 settings 服务挂载时的回退 base。
236
256
 
@@ -260,12 +280,11 @@ memory:
260
280
  memoryMode: policy-only
261
281
  memoryPolicyCustomText: ""
262
282
  memoryCharLimit: 5000
283
+ memoryMaxEntries: 20
263
284
  maxSearchResults: 50
264
285
  decayDays: 30
265
286
  notesEnabled: true
266
- notesDir: docs/agent-memory
267
287
  notesCharLimit: 4000
268
- notesAgentsPointer: true
269
288
  notesMaxEntriesPerFile: 100
270
289
  autoRecallEnabled: false
271
290
  autoRecallLimit: 5
@@ -284,6 +303,7 @@ memory-review:
284
303
  curatorEveryNSessions: 20
285
304
  curatorMaxEntries: 5
286
305
  curatorMinChars: 400
306
+ confirmBeforeWrite: false
287
307
  ```
288
308
 
289
309
  `memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
@@ -317,10 +337,10 @@ memory:
317
337
  | 行 | 导出 | 作用 |
318
338
  |---|---|---|
319
339
  | `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
320
- | `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域,注册 `ctx.memory`(BM25 检索 + 两层衰减) |
321
- | `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具 |
322
- | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator),持有 `memory-review` 设置命名空间 |
323
- | `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 + 原子写 + AGENTS.md 指针),注册 `ctx.projectNotes` |
340
+ | `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域(entries + audit + 待确认队列三张表),注册 `ctx.memory`(BM25 检索 + 两层衰减) |
341
+ | `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具(人审模式下写入改为入队) |
342
+ | `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator + 人审队列),持有 `memory-review` 设置命名空间 |
343
+ | `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记 prompt 投影(渲染约定/踩坑进 `project-notes` 段落;0.6 起不写仓库文件),注册 `ctx.projectNotes`;会话创建时清理 ≤0.5.x 的文件导出残留 |
324
344
  | `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入(`memory` @90 + `project-notes` @91)、步级自动召回,持有 `memory` 设置命名空间 |
325
345
  | `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务(设置「记忆」区经 `/api` 通道消费) |
326
346
 
@@ -347,6 +367,7 @@ memory:
347
367
  - **提取质量跟随会话模型** — review/flush/curator 复用会话当前路由的 provider/model,除非显式覆盖。
348
368
  - **会话中途的提取在下次压缩或新会话前不会出现在提示里** — 注入快照为 KV-cache 稳定性而冻结;步级自动召回(可选)提供逐步新鲜度。
349
369
  - **dsh 仍处于开发者预览阶段** — 可能会有破坏性变更;本 bundle 的 peer dependency 范围跟随 dsh 发布线。
370
+ - **要求 alpha 渠道(0.1.2-alpha.x)** — 本 bundle 使用 0.1.2-alpha 的 settings API(`ctx.settings.installSection`、host-only 投影注册),peer 范围为 `^0.1.2-alpha.2`。rc(`next`)线仍是旧的模块级 `installSettingsSection` helper,无法加载本 bundle;请从 `alpha` dist-tag 安装 dsh。client bundle 同样对齐 alpha 客户端包(`@deepseek-ai/dsh-client-store` / `dsh-client-ui-settings`),它们取代了已移除的 `dsh-client-runtime`。
350
371
 
351
372
  ## 许可证
352
373
 
package/cordis.patch.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  # @chenhw7/dsh-memory — long-term memory bundle patch for the DeepSeek Harness.
2
2
  #
3
3
  # Installs the memory store provider, six model-facing memory tools, automatic
4
- # review + flush extraction, the project-notes exporter, and system-prompt
5
- # context injection as ONE layer over dsh-base. The memory rows point at this
4
+ # review + flush extraction, the project-notes prompt projection, and
5
+ # system-prompt context injection as ONE layer over dsh-base. The memory rows
6
+ # point at this
6
7
  # package's own export sub-paths; the two storage rows are NOT inserted here
7
8
  # because dsh-web-app already provides them (storage-json + storage-domain
8
9
  # with the correct root path). For a headless profile that has no storage
@@ -34,7 +35,8 @@
34
35
  name: '@chenhw7/dsh-memory/review'
35
36
 
36
37
  # Project notes: renders habit/convention/pitfall entries from the store
37
- # into in-repo files (CONVENTIONS.md / PITFALLS.md) + AGENTS.md pointer.
38
+ # into the `project-notes` prompt section (no repo files since 0.6) and
39
+ # cleans up file-export artifacts left by ≤0.5.x.
38
40
  - id: memory-notes
39
41
  name: '@chenhw7/dsh-memory/notes'
40
42
 
@@ -535,9 +535,7 @@ var DEFAULTS = {
535
535
  maxSearchResults: 50,
536
536
  decayDays: 30,
537
537
  notesEnabled: true,
538
- notesDir: "docs/agent-memory",
539
538
  notesCharLimit: 4e3,
540
- notesAgentsPointer: true,
541
539
  notesMaxEntriesPerFile: 100
542
540
  };
543
541
  var NUMERIC_FIELDS = ["memoryCharLimit", "memoryMaxEntries", "maxSearchResults", "decayDays", "notesCharLimit", "notesMaxEntriesPerFile"];
@@ -747,7 +745,7 @@ function MemoryPluginCard(props) {
747
745
  var import_react2 = require("react");
748
746
 
749
747
  // src/client/memory-section-store.ts
750
- var import_client = require("@deepseek-ai/dsh-client-runtime/client");
748
+ var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
751
749
  var MEMORY_BATCH_SIZE = 50;
752
750
  var MEMORY_CATEGORIES = [
753
751
  "failure",
@@ -796,7 +794,7 @@ var MemorySectionController = class {
796
794
  }
797
795
  api;
798
796
  /** Page snapshot the renderer subscribes to. */
799
- store = (0, import_client.createSnapshotStore)(INITIAL);
797
+ store = (0, import_dsh_client_store.createSnapshotStore)(INITIAL);
800
798
  /** Guards against overlapping loads painting partial results. */
801
799
  seq = 0;
802
800
  /**
@@ -2383,17 +2381,13 @@ var en = {
2383
2381
  decayDaysHint: "Auto-decay project entries not recalled within N days; 0 disables.",
2384
2382
  // Project notes card (memory namespace).
2385
2383
  notesCardTitle: "Project Notes",
2386
- notesCardDescription: "Export conventions and a pitfall log into repo files and inject them into the prompt.",
2384
+ notesCardDescription: "Inject conventions and a pitfall log into the prompt; entries are managed in the Memory section.",
2387
2385
  notesEnabled: "Project notes",
2388
- notesEnabledHint: "Export conventions and the pitfall log into repo files and inject them into the prompt.",
2389
- notesDir: "Notes directory",
2390
- notesDirHint: "Repo-relative directory for the generated CONVENTIONS.md / PITFALLS.md.",
2386
+ notesEnabledHint: "Inject conventions and the pitfall log into the system prompt (no repo files; manage entries in the Memory section).",
2391
2387
  notesCharLimit: "Notes character limit",
2392
2388
  notesCharLimitHint: "Character budget for the injected project-notes section.",
2393
- notesAgentsPointer: "AGENTS.md pointer",
2394
- notesAgentsPointerHint: "Maintain the managed pointer block in the repo AGENTS.md so other tools discover the notes.",
2395
- notesMaxEntriesPerFile: "Max entries per notes file",
2396
- notesMaxEntriesPerFileHint: "Per-file entry cap; the oldest entries are truncated.",
2389
+ notesMaxEntriesPerFile: "Max rendered entries",
2390
+ notesMaxEntriesPerFileHint: "Entry cap for the injected notes; the oldest entries are truncated.",
2397
2391
  // Auto recall card (memory namespace).
2398
2392
  autoRecallCardTitle: "Auto Recall",
2399
2393
  autoRecallCardDescription: "Append a per-step recalled-memory block from a store search; the system prompt stays untouched.",
@@ -2550,17 +2544,13 @@ var zh = {
2550
2544
  decayDaysHint: "N \u5929\u672A\u53EC\u56DE\u7684 project \u6761\u76EE\u81EA\u52A8\u8870\u51CF\uFF1B0 \u8868\u793A\u7981\u7528\u3002",
2551
2545
  // 项目笔记卡片(memory 命名空间)
2552
2546
  notesCardTitle: "\u9879\u76EE\u7B14\u8BB0",
2553
- notesCardDescription: "\u628A\u7F16\u7801\u7EA6\u5B9A\u4E0E\u8E29\u5751\u65E5\u5FD7\u5BFC\u51FA\u5230\u4ED3\u5E93\u6587\u4EF6\u5E76\u6CE8\u5165\u63D0\u793A\u8BCD\u3002",
2547
+ notesCardDescription: "\u628A\u7F16\u7801\u7EA6\u5B9A\u4E0E\u8E29\u5751\u65E5\u5FD7\u6CE8\u5165\u7CFB\u7EDF\u63D0\u793A\u8BCD\uFF1B\u6761\u76EE\u5728 Memory \u5206\u533A\u4E2D\u7BA1\u7406\u3002",
2554
2548
  notesEnabled: "\u9879\u76EE\u7B14\u8BB0",
2555
- notesEnabledHint: "\u628A\u7F16\u7801\u7EA6\u5B9A\u4E0E\u8E29\u5751\u65E5\u5FD7\u5BFC\u51FA\u5230\u4ED3\u5E93\u6587\u4EF6\uFF0C\u5E76\u6CE8\u5165\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002",
2556
- notesDir: "\u7B14\u8BB0\u76EE\u5F55",
2557
- notesDirHint: "\u4ED3\u5E93\u5185\u751F\u6210 CONVENTIONS.md / PITFALLS.md \u7684\u76F8\u5BF9\u76EE\u5F55\u3002",
2549
+ notesEnabledHint: "\u628A\u7F16\u7801\u7EA6\u5B9A\u4E0E\u8E29\u5751\u65E5\u5FD7\u6CE8\u5165\u7CFB\u7EDF\u63D0\u793A\u8BCD\uFF08\u4E0D\u5199\u4ED3\u5E93\u6587\u4EF6\uFF1B\u6761\u76EE\u5728 Memory \u5206\u533A\u4E2D\u7BA1\u7406\uFF09\u3002",
2558
2550
  notesCharLimit: "\u7B14\u8BB0\u5B57\u7B26\u4E0A\u9650",
2559
2551
  notesCharLimitHint: "\u6CE8\u5165\u7684\u9879\u76EE\u7B14\u8BB0\u6BB5\u843D\u7684\u5B57\u7B26\u9884\u7B97\u3002",
2560
- notesAgentsPointer: "AGENTS.md \u6307\u9488",
2561
- notesAgentsPointerHint: "\u5728\u4ED3\u5E93 AGENTS.md \u4E2D\u7EF4\u62A4\u6258\u7BA1\u6307\u9488\u5757\uFF0C\u4F9B\u5176\u4ED6\u5DE5\u5177\u53D1\u73B0\u7B14\u8BB0\u3002",
2562
- notesMaxEntriesPerFile: "\u5355\u6587\u4EF6\u6700\u5927\u6761\u76EE\u6570",
2563
- notesMaxEntriesPerFileHint: "\u6BCF\u4E2A\u7B14\u8BB0\u6587\u4EF6\u7684\u6761\u76EE\u4E0A\u9650\uFF0C\u8D85\u51FA\u622A\u65AD\u6700\u65E7\u7684\u6761\u76EE\u3002",
2552
+ notesMaxEntriesPerFile: "\u6700\u5927\u6E32\u67D3\u6761\u76EE\u6570",
2553
+ notesMaxEntriesPerFileHint: "\u6CE8\u5165\u7B14\u8BB0\u7684\u6761\u76EE\u4E0A\u9650\uFF0C\u8D85\u51FA\u622A\u65AD\u6700\u65E7\u7684\u6761\u76EE\u3002",
2564
2554
  // 自动召回卡片(memory 命名空间)
2565
2555
  autoRecallCardTitle: "\u81EA\u52A8\u53EC\u56DE",
2566
2556
  autoRecallCardDescription: "\u6BCF\u4E2A\u6B65\u9AA4\u68C0\u7D22\u8BB0\u5FC6\u5E93\u5E76\u8FFD\u52A0\u53EC\u56DE\u5757\uFF0C\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u4E0D\u53D8\u3002",
@@ -2688,9 +2678,7 @@ var NOTES_SPEC = {
2688
2678
  descriptionKey: "notesCardDescription",
2689
2679
  fields: [
2690
2680
  { key: "notesEnabled", kind: "checkbox" },
2691
- { key: "notesDir", kind: "text" },
2692
2681
  { key: "notesCharLimit", kind: "number" },
2693
- { key: "notesAgentsPointer", kind: "checkbox" },
2694
2682
  { key: "notesMaxEntriesPerFile", kind: "number" }
2695
2683
  ]
2696
2684
  };
@@ -50,15 +50,11 @@ export interface MemoryConfig {
50
50
  maxSearchResults: number;
51
51
  /** Days without recall before a project-scoped entry is decayed by the janitor. `0` = disabled. Defaults to `30`. */
52
52
  decayDays: number;
53
- /** Enable project-notes export + injection; defaults to `true`. */
53
+ /** Enable the `project-notes` prompt section; defaults to `true`. */
54
54
  notesEnabled: boolean;
55
- /** Repo-relative directory holding the generated notes files; defaults to `docs/agent-memory`. */
56
- notesDir: string;
57
55
  /** Character budget for the injected project-notes section; defaults to `4000`. */
58
56
  notesCharLimit: number;
59
- /** Maintain the AGENTS.md pointer block; defaults to `true`. */
60
- notesAgentsPointer: boolean;
61
- /** Max entries per generated notes file; defaults to `100`. */
57
+ /** Max entries rendered into the project-notes section; defaults to `100`. */
62
58
  notesMaxEntriesPerFile: number;
63
59
  /** Append a fenced auto-recall block to each step's messages (BM25 over the store). Defaults to `false`. */
64
60
  autoRecallEnabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAGxC,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA0B9C,OAAO,EAAkH,KAAK,UAAU,EAAmB,MAAM,aAAa,CAAA;AAE9K,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC3K,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACvE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEzD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,mBAAmB,CAAA;AAEpC,yEAAyE;AACzE,eAAO,MAAM,MAAM,UAAmB,CAAA;AAwCtC;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,UAAU,EAAE,UAAU,CAAA;IACtB,iFAAiF;IACjF,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,mFAAmF;IACnF,eAAe,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAA;IACxB,6HAA6H;IAC7H,gBAAgB,EAAE,MAAM,CAAA;IACxB,qHAAqH;IACrH,SAAS,EAAE,MAAM,CAAA;IACjB,mEAAmE;IACnE,YAAY,EAAE,OAAO,CAAA;IACrB,kGAAkG;IAClG,QAAQ,EAAE,MAAM,CAAA;IAChB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAA;IACtB,gEAAgE;IAChE,kBAAkB,EAAE,OAAO,CAAA;IAC3B,+DAA+D;IAC/D,sBAAsB,EAAE,MAAM,CAAA;IAC9B,4GAA4G;IAC5G,iBAAiB,EAAE,OAAO,CAAA;IAC1B,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAA;IACvB,oGAAoG;IACpG,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,YAAY,CAejC,CAAA;AA+BF;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EACzC,UAAU,GAAE,MAAU,GACrB,MAAM,CA2CR;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,GAAG,MAAM,CAqBzH;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA8H9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAKxC,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAwB9C,OAAO,EAAkH,KAAK,UAAU,EAAmB,MAAM,aAAa,CAAA;AAE9K,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC3K,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACvE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEzD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,mBAAmB,CAAA;AAEpC,yEAAyE;AACzE,eAAO,MAAM,MAAM,UAAmB,CAAA;AAsCtC;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,UAAU,EAAE,UAAU,CAAA;IACtB,iFAAiF;IACjF,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,mFAAmF;IACnF,eAAe,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAA;IACxB,6HAA6H;IAC7H,gBAAgB,EAAE,MAAM,CAAA;IACxB,qHAAqH;IACrH,SAAS,EAAE,MAAM,CAAA;IACjB,qEAAqE;IACrE,YAAY,EAAE,OAAO,CAAA;IACrB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAA;IACtB,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAA;IAC9B,4GAA4G;IAC5G,iBAAiB,EAAE,OAAO,CAAA;IAC1B,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAA;IACvB,oGAAoG;IACpG,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,YAAY,CAajC,CAAA;AA+BF;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EACzC,UAAU,GAAE,MAAU,GACrB,MAAM,CA2CR;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,GAAG,MAAM,CAqBzH;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAgI9D"}
@@ -16,11 +16,10 @@
16
16
  * @module @chenhw7/dsh-memory/context
17
17
  */
18
18
  import z from '@deepseek-ai/schemastery';
19
- import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
20
19
  import { redactBlocked } from '../scanner.js';
21
20
  import { annotateConflicts } from './conflict.js';
22
21
  import { isRenderedEntry } from '../notes/scope.js';
23
- import { DEFAULT_NOTES_AGENTS_POINTER, DEFAULT_NOTES_CHAR_LIMIT, DEFAULT_NOTES_DIR, DEFAULT_NOTES_ENABLED, DEFAULT_NOTES_MAX_ENTRIES_PER_FILE, } from '../notes/settings.js';
22
+ import { DEFAULT_NOTES_CHAR_LIMIT, DEFAULT_NOTES_ENABLED, DEFAULT_NOTES_MAX_ENTRIES_PER_FILE, } from '../notes/settings.js';
24
23
  import { createUserMessage } from '@deepseek-ai/dsh-llm';
25
24
  import { buildMemorySectionText, buildNotesSectionText, buildAutoRecallBlock, renderMemoryIndex, AUTO_RECALL_CHAR_LIMIT } from './policy.js';
26
25
  export { buildMemorySectionText, buildAutoRecallBlock, renderMemoryIndex, MEMORY_POLICY_TEXT, MEMORY_CONTEXT_NOTE, MEMORY_INDEX_NOTE, AUTO_RECALL_NOTE } from './policy.js';
@@ -30,13 +29,11 @@ export const name = 'memory-context';
30
29
  /** The prompt registry is required; settings and memory are optional. */
31
30
  export const inject = ['systemPrompt'];
32
31
  /** The settings namespace this plugin owns. */
33
- const NS = settingsNamespace('memory');
32
+ const NS = 'memory';
34
33
  const DEFAULT_MEMORY_MODE = 'policy-only';
35
34
  const DEFAULT_MEMORY_CHAR_LIMIT = 5000;
36
35
  const DEFAULT_MAX_SEARCH_RESULTS = 50;
37
36
  const DEFAULT_DECAY_DAYS = 30;
38
- /** Upper bound on any single generated notes file (defense-in-depth on top of the entry cap). */
39
- const MAX_NOTES_FILE_CHARS = 32_000;
40
37
  /**
41
38
  * Default maximum number of memory entries injected into the system-prompt
42
39
  * snapshot, regardless of the character budget (P0-6). Prevents a large
@@ -65,9 +62,7 @@ export const Config = z.object({
65
62
  maxSearchResults: z.number().step(1).min(0).default(DEFAULT_MAX_SEARCH_RESULTS),
66
63
  decayDays: z.number().step(1).min(0).default(DEFAULT_DECAY_DAYS),
67
64
  notesEnabled: z.boolean().default(DEFAULT_NOTES_ENABLED),
68
- notesDir: z.string().default(DEFAULT_NOTES_DIR),
69
65
  notesCharLimit: z.number().step(1).min(0).default(DEFAULT_NOTES_CHAR_LIMIT),
70
- notesAgentsPointer: z.boolean().default(DEFAULT_NOTES_AGENTS_POINTER),
71
66
  notesMaxEntriesPerFile: z.number().step(1).min(0).default(DEFAULT_NOTES_MAX_ENTRIES_PER_FILE),
72
67
  autoRecallEnabled: z.boolean().default(false),
73
68
  autoRecallLimit: z.number().step(1).min(1).default(5),
@@ -228,17 +223,19 @@ export function readMemoryIndex(memory, charLimit, exclude) {
228
223
  export function apply(ctx, config) {
229
224
  // Source thunk for the current resolved settings: the settings scope while
230
225
  // one is attached, the composition entry otherwise. Reassigned by
231
- // `installSettingsSection` on attach and detach.
226
+ // `installSection` on attach and detach.
232
227
  let current = () => config;
233
228
  // Per-session frozen memory snapshots (content + index), read once at session/created.
234
229
  const sessionMemory = new WeakMap();
235
- installSettingsSection(ctx, NS, Config, config, {
236
- setSource: (source) => {
237
- current = source;
238
- },
239
- // The section text provider reads settings live at each assembly, so a
240
- // committed change is picked up without re-judging registration-level facts.
241
- onChange: () => { },
230
+ ctx.inject(['settings'], (settingsCtx) => {
231
+ settingsCtx.settings.installSection(ctx, NS, Config, config, {
232
+ setSource: (source) => {
233
+ current = source;
234
+ },
235
+ // The section text provider reads settings live at each assembly, so a
236
+ // committed change is picked up without re-judging registration-level facts.
237
+ onChange: () => { },
238
+ });
242
239
  });
243
240
  /** Infer the current project name from a session's cwd (basename). */
244
241
  const projectNameOf = (session) => {
@@ -252,9 +249,8 @@ export function apply(ctx, config) {
252
249
  const freezeFor = (session) => {
253
250
  const settings = current();
254
251
  const memory = ctx.get('memory');
255
- // The project-notes snapshot: rendering is synchronous AND reconciles
256
- // (fires the async file persistence), so the frozen prompt content always
257
- // matches what lands on disk — no file-read lag, no ordering race.
252
+ // The project-notes snapshot: rendering is synchronous and side-effect
253
+ // free (prompt-only since 0.6 — nothing is written to the project).
258
254
  const notes = settings.notesEnabled
259
255
  ? ctx.get('projectNotes')?.snapshotFor(session.header?.cwd) ?? EMPTY_NOTES
260
256
  : EMPTY_NOTES;
@@ -264,8 +260,9 @@ export function apply(ctx, config) {
264
260
  }
265
261
  const charLimit = settings.memoryCharLimit;
266
262
  const maxEntries = settings.memoryMaxEntries ?? DEFAULT_MEMORY_MAX_ENTRIES;
267
- // No double injection: entries rendered into the notes files are excluded
268
- // from the memory section's snapshot/index while notes are enabled.
263
+ // No double injection: entries rendered into the project-notes section
264
+ // are excluded from the memory section's snapshot/index while notes are
265
+ // enabled.
269
266
  const exclude = settings.notesEnabled
270
267
  ? (entry) => isRenderedEntry(entry, projectNameOf(session)) !== undefined
271
268
  : undefined;