@chenhw7/dsh-memory 0.4.0 → 0.5.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.md +29 -13
- package/README.zh-CN.md +29 -13
- package/lib/benchmark/index.d.ts +125 -0
- package/lib/benchmark/index.d.ts.map +1 -0
- package/lib/benchmark/index.js +150 -0
- package/lib/benchmark/index.js.map +1 -0
- package/lib/brand.d.ts +11 -0
- package/lib/brand.d.ts.map +1 -1
- package/lib/brand.js +7 -0
- package/lib/brand.js.map +1 -1
- package/lib/client/index.js +844 -185
- package/lib/context/index.d.ts +22 -3
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +59 -13
- package/lib/context/index.js.map +1 -1
- package/lib/context/policy.d.ts +6 -0
- package/lib/context/policy.d.ts.map +1 -1
- package/lib/context/policy.js +26 -9
- package/lib/context/policy.js.map +1 -1
- package/lib/index.d.ts +44 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +48 -2
- package/lib/index.js.map +1 -1
- package/lib/notes/index.d.ts +2 -2
- package/lib/notes/index.d.ts.map +1 -1
- package/lib/notes/index.js +52 -10
- package/lib/notes/index.js.map +1 -1
- package/lib/notes/scope.d.ts +2 -2
- package/lib/notes/scope.js +2 -2
- package/lib/notes/settings.d.ts +10 -0
- package/lib/notes/settings.d.ts.map +1 -1
- package/lib/notes/settings.js +17 -0
- package/lib/notes/settings.js.map +1 -1
- package/lib/notes/writer.d.ts +33 -0
- package/lib/notes/writer.d.ts.map +1 -1
- package/lib/notes/writer.js +61 -1
- package/lib/notes/writer.js.map +1 -1
- package/lib/remote/index.d.ts +71 -1
- package/lib/remote/index.d.ts.map +1 -1
- package/lib/remote/index.js +94 -1
- package/lib/remote/index.js.map +1 -1
- package/lib/remote/typert.remote-client.d.ts +31 -3
- package/lib/review/accumulator.d.ts +1 -1
- package/lib/review/accumulator.js +1 -1
- package/lib/review/extract.d.ts +48 -4
- package/lib/review/extract.d.ts.map +1 -1
- package/lib/review/extract.js +164 -11
- package/lib/review/extract.js.map +1 -1
- package/lib/review/index.d.ts +6 -0
- package/lib/review/index.d.ts.map +1 -1
- package/lib/review/index.js +12 -10
- package/lib/review/index.js.map +1 -1
- package/lib/store/index.d.ts +56 -3
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +238 -9
- package/lib/store/index.js.map +1 -1
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +156 -25
- package/lib/tool/index.js.map +1 -1
- package/lib/types.d.ts +83 -2
- package/lib/types.d.ts.map +1 -1
- package/package.json +25 -2
package/README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cairn
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
[](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,16 +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
|
+
- **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. A drift guard backs up externally edited notes files instead of silently overwriting them.
|
|
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
|
-
- **
|
|
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.
|
|
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.
|
|
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.
|
|
39
51
|
|
|
40
52
|
## Install
|
|
41
53
|
|
|
@@ -109,8 +121,8 @@ If you'd rather not install from the npm registry, pack a tarball from a checkou
|
|
|
109
121
|
```sh
|
|
110
122
|
cd dsh-memory
|
|
111
123
|
npm install && npm run build
|
|
112
|
-
npm pack # produces chenhw7-dsh-memory-0.
|
|
113
|
-
dsh plugin add --profile web ./chenhw7-dsh-memory-0.
|
|
124
|
+
npm pack # produces chenhw7-dsh-memory-0.5.0.tgz
|
|
125
|
+
dsh plugin add --profile web ./chenhw7-dsh-memory-0.5.0.tgz
|
|
114
126
|
```
|
|
115
127
|
|
|
116
128
|
## Update
|
|
@@ -203,6 +215,7 @@ Every namespace resolves in layers: schema defaults → the composition `config:
|
|
|
203
215
|
| `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`. |
|
|
204
216
|
| `memoryPolicyCustomText` | — | Custom policy text used when `memoryMode` is `custom`. |
|
|
205
217
|
| `memoryCharLimit` | `5000` | Character budget for the frozen per-session memory snapshot injected in `full` mode (`0` = no content). |
|
|
218
|
+
| `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. |
|
|
206
219
|
| `maxSearchResults` | `50` | Default cap for `memory_search` / `memory_list` when the call omits `limit`; read live by the tool plugin. `0` = no limit. |
|
|
207
220
|
| `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. |
|
|
208
221
|
| `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. |
|
|
@@ -231,6 +244,7 @@ Every namespace resolves in layers: schema defaults → the composition `config:
|
|
|
231
244
|
| `curatorEveryNSessions` | `20` | Run the curator pass every N session creations. |
|
|
232
245
|
| `curatorMaxEntries` | `5` | Max entries selected per curation pass (longest first). |
|
|
233
246
|
| `curatorMinChars` | `400` | Only entries at least this long are selected for re-summarization. |
|
|
247
|
+
| `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. |
|
|
234
248
|
|
|
235
249
|
> 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.
|
|
236
250
|
|
|
@@ -260,6 +274,7 @@ memory:
|
|
|
260
274
|
memoryMode: policy-only
|
|
261
275
|
memoryPolicyCustomText: ""
|
|
262
276
|
memoryCharLimit: 5000
|
|
277
|
+
memoryMaxEntries: 20
|
|
263
278
|
maxSearchResults: 50
|
|
264
279
|
decayDays: 30
|
|
265
280
|
notesEnabled: true
|
|
@@ -284,6 +299,7 @@ memory-review:
|
|
|
284
299
|
curatorEveryNSessions: 20
|
|
285
300
|
curatorMaxEntries: 5
|
|
286
301
|
curatorMinChars: 400
|
|
302
|
+
confirmBeforeWrite: false
|
|
287
303
|
```
|
|
288
304
|
|
|
289
305
|
`memoryPolicyCustomText` is optional and only used when `memoryMode` is `custom`.
|
|
@@ -317,10 +333,10 @@ The bundle inserts seven rows over `dsh-base`, each pointing at this package's o
|
|
|
317
333
|
| Row | Export | Role |
|
|
318
334
|
|---|---|---|
|
|
319
335
|
| `memory-root` | `@chenhw7/dsh-memory` | No-op root entry for client-module scanner discovery |
|
|
320
|
-
| `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain, registers `ctx.memory` (BM25 search + two-tier decay) |
|
|
321
|
-
| `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools |
|
|
322
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator) and the `memory-review` settings namespace |
|
|
323
|
-
| `memory-notes` | `@chenhw7/dsh-memory/notes` | Project-notes export (render conventions/pitfalls + atomic write + AGENTS.md pointer), registers `ctx.projectNotes` |
|
|
336
|
+
| `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain (entries + audit + suggestion-queue tables), registers `ctx.memory` (BM25 search + two-tier decay) |
|
|
337
|
+
| `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools (confirm-mode writes queue as proposals) |
|
|
338
|
+
| `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 |
|
|
339
|
+
| `memory-notes` | `@chenhw7/dsh-memory/notes` | Project-notes export (render conventions/pitfalls + atomic write with drift guard + AGENTS.md pointer), registers `ctx.projectNotes` |
|
|
324
340
|
| `memory-context` | `@chenhw7/dsh-memory/context` | System-prompt injection (`memory` @90 + `project-notes` @91), step-level auto recall, owns the `memory` settings namespace |
|
|
325
341
|
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | `@Remote` service behind the settings UI's Memory section (consumed over the `/api` channel) |
|
|
326
342
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cairn
|
|
2
2
|
|
|
3
3
|
[English](README.md) | **简体中文**
|
|
4
4
|
|
|
5
|
-
|
|
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
|
+
[](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,16 +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
|
+
- **仓库内项目笔记** — 编码约定与踩坑日志渲染为仓库内可 git 管理的 markdown(默认 `docs/agent-memory/`),每次会话注入 system prompt,并在 `AGENTS.md` 中维护一行托管指针块供其他工具发现。漂移守卫保证被外部手改过的笔记文件会被备份而非静默覆盖。
|
|
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
|
-
-
|
|
44
|
+
- **可选的写入前人工确认** — 打开一个开关(`confirmBeforeWrite`)后,自动提取*与*工具调用产生的写入一律先进入待确认队列(同一提议反复出现会累计次数并置顶);采纳才落库(可先编辑),拒绝即丢弃。模型永不自我提升:对既有条目的修改提议在你采纳前不会改动原文。
|
|
45
|
+
- **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25 搜索、类别筛选、懒加载条目列表,并带完整写操作(编辑 / 置顶 / 归档 / 删除),中英双语。
|
|
46
|
+
- **时间窗浏览 + 智能列表视图** — `memory_list` 默认按最新在前返回,附带 `earliest`/`latest`/`hasStale` 元数据,支持 `since`/`until` 毫秒时间戳边界(「上周学了什么」这类查询直接在窗口内分页);过滤条件命中 0 条但库非空时,会提示放宽过滤条件。
|
|
47
|
+
- **可选摘要(渐进式披露)** — `memory_add`/`memory_replace` 接受 `summary`,提取也可以输出 `[summary:…]` 标签;index 模式与自动召回优先渲染摘要而非截断正文。
|
|
36
48
|
|
|
37
49
|
## 安装
|
|
38
50
|
|
|
@@ -107,8 +119,8 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
|
|
|
107
119
|
```sh
|
|
108
120
|
cd dsh-memory
|
|
109
121
|
npm install && npm run build
|
|
110
|
-
npm pack # 生成 chenhw7-dsh-memory-0.
|
|
111
|
-
dsh plugin add --profile web ./chenhw7-dsh-memory-0.
|
|
122
|
+
npm pack # 生成 chenhw7-dsh-memory-0.5.0.tgz
|
|
123
|
+
dsh plugin add --profile web ./chenhw7-dsh-memory-0.5.0.tgz
|
|
112
124
|
```
|
|
113
125
|
|
|
114
126
|
## 更新
|
|
@@ -201,6 +213,7 @@ dsh web
|
|
|
201
213
|
| `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
|
|
202
214
|
| `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
|
|
203
215
|
| `memoryCharLimit` | `5000` | 会话内冻结记忆快照注入 `full` 模式时的字符预算(`0` = 不注入内容)。 |
|
|
216
|
+
| `memoryMaxEntries` | `20` | 同一冻结快照的条目数上限(`0` = 无限制)。快照尾部附 `≈N tokens` 估算,注入成本始终可见。 |
|
|
204
217
|
| `maxSearchResults` | `50` | `memory_search` / `memory_list` 在调用未传 `limit` 时的默认返回条数上限,由工具插件实时读取。`0` = 无限制。 |
|
|
205
218
|
| `decayDays` | `30` | N 天内未召回条目的生命周期窗口,由 review 插件的 janitor 实时读取。`0` = 禁用。过期的 `project` 条目被**移除**(硬衰减);过期的 `global`/`user` 条目改为**软衰减**——打上 `stale` 戳,从注入面和笔记文件中隐藏但仍可搜索,再次召回即自动解除。固定(pin)条目始终豁免。 |
|
|
206
219
|
| `notesEnabled` | `true` | 启用项目笔记的仓库内文件导出与 system prompt 注入。已渲染进笔记文件的条目会从 memory 段落中排除,避免重复注入。 |
|
|
@@ -229,6 +242,7 @@ dsh web
|
|
|
229
242
|
| `curatorEveryNSessions` | `20` | 每 N 次会话创建运行一次 curator pass。 |
|
|
230
243
|
| `curatorMaxEntries` | `5` | 每次 curation 最多选中的条目数(最长优先)。 |
|
|
231
244
|
| `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
|
|
245
|
+
| `confirmBeforeWrite` | `false` | 人审模式:所有提取(review/flush/curator)*与*每次 `memory_add`/`memory_replace` 调用都改为在待确认队列中生成提议,而非直接写库,直到有人在设置「记忆」区(待确认页)采纳。同一提议被反复观察会累计 `hits` 并置顶;对既有条目的修改提议携带其 id,在人工采纳前不会改动原文。 |
|
|
232
246
|
|
|
233
247
|
> 特意**没有独立的 `tool-memory` 设置命名空间**:工具插件从上面的 `memory` 命名空间实时读取 `maxSearchResults`。其组合配置 `config.maxSearchResults` 仅作为无 settings 服务挂载时的回退 base。
|
|
234
248
|
|
|
@@ -258,6 +272,7 @@ memory:
|
|
|
258
272
|
memoryMode: policy-only
|
|
259
273
|
memoryPolicyCustomText: ""
|
|
260
274
|
memoryCharLimit: 5000
|
|
275
|
+
memoryMaxEntries: 20
|
|
261
276
|
maxSearchResults: 50
|
|
262
277
|
decayDays: 30
|
|
263
278
|
notesEnabled: true
|
|
@@ -282,6 +297,7 @@ memory-review:
|
|
|
282
297
|
curatorEveryNSessions: 20
|
|
283
298
|
curatorMaxEntries: 5
|
|
284
299
|
curatorMinChars: 400
|
|
300
|
+
confirmBeforeWrite: false
|
|
285
301
|
```
|
|
286
302
|
|
|
287
303
|
`memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
|
|
@@ -315,10 +331,10 @@ memory:
|
|
|
315
331
|
| 行 | 导出 | 作用 |
|
|
316
332
|
|---|---|---|
|
|
317
333
|
| `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
|
|
318
|
-
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory`
|
|
319
|
-
| `tool-memory` | `@chenhw7/dsh-memory/tool` |
|
|
320
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator
|
|
321
|
-
| `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 +
|
|
334
|
+
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域(entries + audit + 待确认队列三张表),注册 `ctx.memory`(BM25 检索 + 两层衰减) |
|
|
335
|
+
| `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具(人审模式下写入改为入队) |
|
|
336
|
+
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator + 人审队列),持有 `memory-review` 设置命名空间 |
|
|
337
|
+
| `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 + 带漂移守卫的原子写 + AGENTS.md 指针),注册 `ctx.projectNotes` |
|
|
322
338
|
| `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入(`memory` @90 + `project-notes` @91)、步级自动召回,持有 `memory` 设置命名空间 |
|
|
323
339
|
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务(设置「记忆」区经 `/api` 通道消费) |
|
|
324
340
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recall evaluation baseline (P1-4) and injection-cost comparison (P1-8).
|
|
3
|
+
*
|
|
4
|
+
* A fixed golden-set fixture — 24 topically distinct entries across the three
|
|
5
|
+
* scopes (English + CJK), each with one known relevant query — turns "the
|
|
6
|
+
* retrieval is strong" from a structural claim into numbers: precision@k,
|
|
7
|
+
* recall@k, and MRR over the shipping BM25 search, plus per-mode standing
|
|
8
|
+
* injection cost (characters ≈ tokens). Any future retrieval change
|
|
9
|
+
* (tokenization, weights, budgets) must run against this baseline first.
|
|
10
|
+
*
|
|
11
|
+
* Pure module: builds its own store-shaped searcher via a callback, so both
|
|
12
|
+
* the real DomainMemoryStore (spec) and offline copies can be evaluated.
|
|
13
|
+
*
|
|
14
|
+
* @module @chenhw7/dsh-memory/benchmark
|
|
15
|
+
*/
|
|
16
|
+
/** One fixture entry: scope + content (+ optional summary/category). */
|
|
17
|
+
export interface GoldenEntry {
|
|
18
|
+
/** Stable fixture id used in the golden table. */
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly scope: 'global' | 'project' | 'user';
|
|
21
|
+
readonly content: string;
|
|
22
|
+
readonly summary?: string;
|
|
23
|
+
readonly category?: string;
|
|
24
|
+
/** Project name for project-scoped entries. */
|
|
25
|
+
readonly projectName?: string;
|
|
26
|
+
}
|
|
27
|
+
/** One golden case: a query and the entry ids a correct recall must surface. */
|
|
28
|
+
export interface GoldenCase {
|
|
29
|
+
readonly query: string;
|
|
30
|
+
readonly relevant: readonly string[];
|
|
31
|
+
/** Language tag for slicing the report (en / zh / mixed). */
|
|
32
|
+
readonly lang: 'en' | 'zh';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The fixed memory fixture. Entries are deliberately topically separated so
|
|
36
|
+
* BM25 can discriminate them; several share a few decoy tokens (e.g. two
|
|
37
|
+
* entries mention 端口/port) to keep precision honest.
|
|
38
|
+
*/
|
|
39
|
+
export declare const GOLDEN_ENTRIES: readonly GoldenEntry[];
|
|
40
|
+
/**
|
|
41
|
+
* The golden query table: each query names exactly the entries a correct
|
|
42
|
+
* search must return within the top-k. Queries mix keyword style ("redis
|
|
43
|
+
* 缓存") and question style ("数据库迁移什么时候执行").
|
|
44
|
+
*/
|
|
45
|
+
export declare const GOLDEN_CASES: readonly GoldenCase[];
|
|
46
|
+
/** Minimal search face the evaluator needs (satisfied by MemoryStore.search). */
|
|
47
|
+
export interface Searcher {
|
|
48
|
+
search(query: {
|
|
49
|
+
query: string;
|
|
50
|
+
limit?: number;
|
|
51
|
+
}): {
|
|
52
|
+
entries: readonly {
|
|
53
|
+
id: string;
|
|
54
|
+
}[];
|
|
55
|
+
total: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Per-case outcome of one evaluation pass. */
|
|
59
|
+
export interface CaseResult {
|
|
60
|
+
readonly query: string;
|
|
61
|
+
readonly lang: 'en' | 'zh';
|
|
62
|
+
readonly expected: readonly string[];
|
|
63
|
+
/** Fixture ids of the returned top-k, in rank order. */
|
|
64
|
+
readonly ranked: readonly string[];
|
|
65
|
+
/** Whether every relevant id appeared within the top-k. */
|
|
66
|
+
readonly hit: boolean;
|
|
67
|
+
/** 1/rank of the best relevant hit (0 when none). */
|
|
68
|
+
readonly reciprocalRank: number;
|
|
69
|
+
}
|
|
70
|
+
export interface EvalReport {
|
|
71
|
+
/**
|
|
72
|
+
* Success@k: fraction of cases where ALL relevant ids appear within the
|
|
73
|
+
* top-k (for single-relevant cases this IS recall@k).
|
|
74
|
+
*/
|
|
75
|
+
readonly recallAtK: number;
|
|
76
|
+
/** Mean fraction of the top-k slots occupied by relevant ids. */
|
|
77
|
+
readonly precisionAtK: number;
|
|
78
|
+
/** Fraction of cases whose rank-1 result is relevant. */
|
|
79
|
+
readonly precisionAtOne: number;
|
|
80
|
+
/** Mean reciprocal rank across cases. */
|
|
81
|
+
readonly mrr: number;
|
|
82
|
+
readonly k: number;
|
|
83
|
+
readonly caseCount: number;
|
|
84
|
+
readonly perCase: readonly CaseResult[];
|
|
85
|
+
/** Same aggregates restricted to the zh query slice. */
|
|
86
|
+
readonly zh: {
|
|
87
|
+
readonly recallAtK: number;
|
|
88
|
+
readonly precisionAtOne: number;
|
|
89
|
+
};
|
|
90
|
+
/** Same aggregates restricted to the en query slice. */
|
|
91
|
+
readonly en: {
|
|
92
|
+
readonly recallAtK: number;
|
|
93
|
+
readonly precisionAtOne: number;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Run every golden case against `searcher` and aggregate P@k / R@k / MRR.
|
|
98
|
+
* @param searcher - the search face under test (typically the real store).
|
|
99
|
+
* @param k - the cut-off rank for precision/recall (default 5).
|
|
100
|
+
*/
|
|
101
|
+
export declare function evaluateRecall(searcher: Searcher, k?: number): EvalReport;
|
|
102
|
+
/** Standing injection cost of one prompt mode over the fixture store. */
|
|
103
|
+
export interface InjectionCost {
|
|
104
|
+
readonly mode: 'policy-only' | 'index' | 'full';
|
|
105
|
+
/** Rendered section characters. */
|
|
106
|
+
readonly chars: number;
|
|
107
|
+
/** ≈tokens at the ~4-chars/token heuristic used by readMemorySnapshot. */
|
|
108
|
+
readonly approxTokens: number;
|
|
109
|
+
/** Entry contents visible in the section (index lines count as half-hints). */
|
|
110
|
+
readonly entriesRendered: number;
|
|
111
|
+
/** Index existence lines rendered (index mode only; 0 otherwise). */
|
|
112
|
+
readonly indexLines: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Measure what each memory mode would stand-inject for a given snapshot pair.
|
|
116
|
+
* The caller renders the snapshots once with the shipping helpers so this
|
|
117
|
+
* module stays free of context-plugin imports.
|
|
118
|
+
*/
|
|
119
|
+
export declare function measureInjectionCost(mode: InjectionCost['mode'], renderedSection: string, opts?: {
|
|
120
|
+
entriesRendered?: number;
|
|
121
|
+
indexLines?: number;
|
|
122
|
+
}): InjectionCost;
|
|
123
|
+
/** Render one comparison row as aligned plain text (for reports/spec logs). */
|
|
124
|
+
export declare function formatCostRow(cost: InjectionCost): string;
|
|
125
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/benchmark/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAA;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,+CAA+C;IAC/C,QAAQ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C,IAAI,EAAE,aAAa,GAAG,MAAM,CAGzD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recall evaluation baseline (P1-4) and injection-cost comparison (P1-8).
|
|
3
|
+
*
|
|
4
|
+
* A fixed golden-set fixture — 24 topically distinct entries across the three
|
|
5
|
+
* scopes (English + CJK), each with one known relevant query — turns "the
|
|
6
|
+
* retrieval is strong" from a structural claim into numbers: precision@k,
|
|
7
|
+
* recall@k, and MRR over the shipping BM25 search, plus per-mode standing
|
|
8
|
+
* injection cost (characters ≈ tokens). Any future retrieval change
|
|
9
|
+
* (tokenization, weights, budgets) must run against this baseline first.
|
|
10
|
+
*
|
|
11
|
+
* Pure module: builds its own store-shaped searcher via a callback, so both
|
|
12
|
+
* the real DomainMemoryStore (spec) and offline copies can be evaluated.
|
|
13
|
+
*
|
|
14
|
+
* @module @chenhw7/dsh-memory/benchmark
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The fixed memory fixture. Entries are deliberately topically separated so
|
|
18
|
+
* BM25 can discriminate them; several share a few decoy tokens (e.g. two
|
|
19
|
+
* entries mention 端口/port) to keep precision honest.
|
|
20
|
+
*/
|
|
21
|
+
export const GOLDEN_ENTRIES = [
|
|
22
|
+
// ── global (8) ──
|
|
23
|
+
{ id: 'g1', scope: 'global', content: 'Prefer pnpm over npm for all package management tasks in every repository' },
|
|
24
|
+
{ id: 'g2', scope: 'global', content: 'The deployment targets Node 22 LTS with pure ESM modules end to end', category: 'convention' },
|
|
25
|
+
{ id: 'g3', scope: 'global', content: 'Vitest is the test runner; jest snapshots are banned from this organization', category: 'convention' },
|
|
26
|
+
{ id: 'g4', scope: 'global', content: 'Commit messages follow conventional commits with Chinese subject lines', category: 'convention' },
|
|
27
|
+
{ id: 'g5', scope: 'global', content: 'PostgreSQL 15 runs under docker-compose with port 5432 exposed locally' },
|
|
28
|
+
{ id: 'g6', scope: 'global', content: 'Redis cache uses allkeys-lru eviction with a 512mb memory cap', category: 'insight' },
|
|
29
|
+
{ id: 'g7', scope: 'global', content: 'Run the typecheck script before every commit; the CI gate rejects type errors', category: 'procedure' },
|
|
30
|
+
{ id: 'g8', scope: 'global', content: 'Feature flags are declared in the flags.json configuration file at the repo root' },
|
|
31
|
+
// ── project demo-repo (8) ──
|
|
32
|
+
{ id: 'p1', scope: 'project', projectName: 'demo-repo', content: 'Build runs through vite; the dev server proxies api calls to localhost port 3000' },
|
|
33
|
+
{ id: 'p2', scope: 'project', projectName: 'demo-repo', content: 'Auth middleware loads jwt secrets from vault during service boot', category: 'procedure' },
|
|
34
|
+
{ id: 'p3', scope: 'project', projectName: 'demo-repo', content: 'Database migrations apply automatically when the server starts up' },
|
|
35
|
+
{ id: 'p4', scope: 'project', projectName: 'demo-repo', content: 'The linter forbids default exports inside lib modules here', category: 'convention' },
|
|
36
|
+
{ id: 'p5', scope: 'project', projectName: 'demo-repo', content: 'End-to-end tests launch headless chromium on debug port 9222' },
|
|
37
|
+
{ id: 'p6', scope: 'project', projectName: 'demo-repo', content: 'Gateway rate limits allow sixty requests per minute for each client key' },
|
|
38
|
+
{ id: 'p7', scope: 'project', projectName: 'demo-repo', content: 'Application logs flow through the structured pino pipeline with request ids' },
|
|
39
|
+
{ id: 'p8', scope: 'project', projectName: 'demo-repo', content: 'Frontend state management uses zustand stores with one store per domain' }, // ── user (8) ──
|
|
40
|
+
{ id: 'u1', scope: 'user', content: '用户偏好简洁的中文回答,先给代码再解释原理', category: 'preference' },
|
|
41
|
+
{ id: 'u2', scope: 'user', content: '用户习惯在提交之前手动运行完整测试套件确认无误', category: 'preference' },
|
|
42
|
+
{ id: 'u3', scope: 'user', content: 'The user works from Tokyo and schedules meetings in JST timezone only' },
|
|
43
|
+
{ id: 'u4', scope: 'user', content: 'Prefers dark theme editors and minimal interface chrome without distractions', category: 'preference' },
|
|
44
|
+
{ id: 'u5', scope: 'user', content: '用户要求所有项目文档一律使用中文书写,包括 README', category: 'preference' },
|
|
45
|
+
{ id: 'u6', scope: 'user', content: 'The user dislikes emoji anywhere in commit messages or changelogs' },
|
|
46
|
+
{ id: 'u7', scope: 'user', content: '用户偏好 vim 键位绑定,编辑器与终端都保持一致', category: 'preference' },
|
|
47
|
+
{ id: 'u8', scope: 'user', content: 'Morning standup notes are posted to the team wiki page before ten' },
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* The golden query table: each query names exactly the entries a correct
|
|
51
|
+
* search must return within the top-k. Queries mix keyword style ("redis
|
|
52
|
+
* 缓存") and question style ("数据库迁移什么时候执行").
|
|
53
|
+
*/
|
|
54
|
+
export const GOLDEN_CASES = [
|
|
55
|
+
{ query: 'package manager preference pnpm', relevant: ['g1'], lang: 'en' },
|
|
56
|
+
{ query: 'node version runtime target', relevant: ['g2'], lang: 'en' },
|
|
57
|
+
{ query: 'test runner choice vitest jest', relevant: ['g3'], lang: 'en' },
|
|
58
|
+
{ query: 'commit message style convention', relevant: ['g4'], lang: 'en' },
|
|
59
|
+
{ query: '端口 5432 是什么数据库服务', relevant: ['g5'], lang: 'zh' },
|
|
60
|
+
{ query: 'redis 缓存淘汰策略 内存上限', relevant: ['g6'], lang: 'zh' },
|
|
61
|
+
{ query: 'typecheck 提交前检查 类型错误', relevant: ['g7'], lang: 'zh' },
|
|
62
|
+
{ query: 'feature flags 配置位置', relevant: ['g8'], lang: 'zh' },
|
|
63
|
+
{ query: 'dev server proxy api 地址', relevant: ['p1'], lang: 'en' },
|
|
64
|
+
{ query: 'jwt 密钥 从哪里读取 启动时', relevant: ['p2'], lang: 'zh' },
|
|
65
|
+
{ query: '数据库迁移 database migrations 自动执行', relevant: ['p3'], lang: 'zh' },
|
|
66
|
+
{ query: 'linter 默认导出 规则 lib 目录', relevant: ['p4'], lang: 'zh' },
|
|
67
|
+
{ query: 'e2e 浏览器 调试端口 chromium', relevant: ['p5'], lang: 'zh' },
|
|
68
|
+
{ query: 'rate limit 每分钟请求数 上限', relevant: ['p6'], lang: 'zh' },
|
|
69
|
+
{ query: '结构化日志 pino 请求 id', relevant: ['p7'], lang: 'zh' },
|
|
70
|
+
{ query: '前端状态管理 zustand store 划分', relevant: ['p8'], lang: 'zh' },
|
|
71
|
+
{ query: '中文 回答 风格 偏好', relevant: ['u1'], lang: 'zh' },
|
|
72
|
+
{ query: '提交之前 运行 测试 套件 习惯', relevant: ['u2'], lang: 'zh' },
|
|
73
|
+
{ query: 'meeting timezone tokyo schedule', relevant: ['u3'], lang: 'en' },
|
|
74
|
+
{ query: 'editor theme appearance preference dark', relevant: ['u4'], lang: 'en' },
|
|
75
|
+
{ query: '文档 语言 要求 中文 书写', relevant: ['u5'], lang: 'zh' },
|
|
76
|
+
{ query: 'emoji commit messages dislike', relevant: ['u6'], lang: 'en' },
|
|
77
|
+
{ query: 'vim 键位 编辑器 偏好', relevant: ['u7'], lang: 'zh' },
|
|
78
|
+
{ query: 'standup notes where posted morning wiki', relevant: ['u8'], lang: 'en' },
|
|
79
|
+
];
|
|
80
|
+
function sliceStats(perCase, k) {
|
|
81
|
+
if (perCase.length === 0)
|
|
82
|
+
return { recallAtK: 0, precisionAtOne: 0 };
|
|
83
|
+
const recallHits = perCase.filter(c => c.hit).length;
|
|
84
|
+
const topOneHits = perCase.filter(c => c.ranked[0] !== undefined && c.expected.includes(c.ranked[0])).length;
|
|
85
|
+
return {
|
|
86
|
+
recallAtK: recallHits / perCase.length,
|
|
87
|
+
precisionAtOne: topOneHits / perCase.length,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Run every golden case against `searcher` and aggregate P@k / R@k / MRR.
|
|
92
|
+
* @param searcher - the search face under test (typically the real store).
|
|
93
|
+
* @param k - the cut-off rank for precision/recall (default 5).
|
|
94
|
+
*/
|
|
95
|
+
export function evaluateRecall(searcher, k = 5) {
|
|
96
|
+
const perCase = GOLDEN_CASES.map(golden => {
|
|
97
|
+
const result = searcher.search({ query: golden.query, limit: k });
|
|
98
|
+
const ranked = result.entries.map(entry => entry.id);
|
|
99
|
+
const topK = ranked.slice(0, k);
|
|
100
|
+
const hitCount = topK.filter(id => golden.relevant.includes(id)).length;
|
|
101
|
+
let reciprocalRank = 0;
|
|
102
|
+
for (let i = 0; i < topK.length; i++) {
|
|
103
|
+
if (golden.relevant.includes(topK[i])) {
|
|
104
|
+
reciprocalRank = 1 / (i + 1);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
query: golden.query,
|
|
110
|
+
lang: golden.lang,
|
|
111
|
+
expected: [...golden.relevant],
|
|
112
|
+
ranked,
|
|
113
|
+
hit: hitCount === golden.relevant.length,
|
|
114
|
+
reciprocalRank,
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
...sliceStats(perCase, k),
|
|
119
|
+
// Mean top-k precision: relevant slots over k (single-relevant sets cap
|
|
120
|
+
// this at 1/k — report it alongside success/MRR, not instead of them).
|
|
121
|
+
precisionAtK: perCase.reduce((sum, c) => sum + c.ranked.slice(0, k).filter(id => c.expected.includes(id)).length / k, 0) / perCase.length,
|
|
122
|
+
recallAtK: perCase.filter(c => c.hit).length / perCase.length,
|
|
123
|
+
mrr: perCase.reduce((sum, c) => sum + c.reciprocalRank, 0) / perCase.length,
|
|
124
|
+
k,
|
|
125
|
+
caseCount: perCase.length,
|
|
126
|
+
perCase,
|
|
127
|
+
zh: sliceStats(perCase.filter(c => c.lang === 'zh'), k),
|
|
128
|
+
en: sliceStats(perCase.filter(c => c.lang === 'en'), k),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Measure what each memory mode would stand-inject for a given snapshot pair.
|
|
133
|
+
* The caller renders the snapshots once with the shipping helpers so this
|
|
134
|
+
* module stays free of context-plugin imports.
|
|
135
|
+
*/
|
|
136
|
+
export function measureInjectionCost(mode, renderedSection, opts = {}) {
|
|
137
|
+
return {
|
|
138
|
+
mode,
|
|
139
|
+
chars: renderedSection.length,
|
|
140
|
+
approxTokens: Math.ceil(renderedSection.length / 4),
|
|
141
|
+
entriesRendered: opts.entriesRendered ?? 0,
|
|
142
|
+
indexLines: opts.indexLines ?? 0,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/** Render one comparison row as aligned plain text (for reports/spec logs). */
|
|
146
|
+
export function formatCostRow(cost) {
|
|
147
|
+
const pad = (value, width) => value + ' '.repeat(Math.max(0, width - value.length));
|
|
148
|
+
return `${pad(cost.mode, 14)}${pad(String(cost.chars), 10)}${pad(String(cost.approxTokens), 12)}${pad(String(cost.entriesRendered), 18)}${String(cost.indexLines)}`;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/benchmark/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAsBH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,mBAAmB;IACnB,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,2EAA2E,EAAE;IACnH,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qEAAqE,EAAE,QAAQ,EAAE,YAAY,EAAE;IACrI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,6EAA6E,EAAE,QAAQ,EAAE,YAAY,EAAE;IAC7I,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,wEAAwE,EAAE,QAAQ,EAAE,YAAY,EAAE;IACxI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,wEAAwE,EAAE;IAChH,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,+DAA+D,EAAE,QAAQ,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AIG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAA2B,EAC3B,eAAuB,EACvB,IAAI,GAAsD,EAAE;IAE5D,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,eAAe,CAAC,MAAM;QAC7B,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;QACnD,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,CAAC;QAC1C,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,CAAC;KACjC,CAAA;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CAAC,IAAmB;IAC/C,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC3G,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAA;AACrK,CAAC"}
|
package/lib/brand.d.ts
CHANGED
|
@@ -14,4 +14,15 @@ export type AuditId = Branded<'AuditId'>;
|
|
|
14
14
|
* @returns a fresh branded id.
|
|
15
15
|
*/
|
|
16
16
|
export declare function AuditId(id?: string): AuditId;
|
|
17
|
+
/**
|
|
18
|
+
* Identifies one pending memory suggestion in the review queue (P1-1 optional
|
|
19
|
+
* human-confirm mode). Separate from {@link MemoryId}: a suggestion is a
|
|
20
|
+
* proposal, not yet a memory.
|
|
21
|
+
*/
|
|
22
|
+
export type SuggestionId = Branded<'SuggestionId'>;
|
|
23
|
+
/**
|
|
24
|
+
* Mint a new unique suggestion id.
|
|
25
|
+
* @returns a fresh branded id.
|
|
26
|
+
*/
|
|
27
|
+
export declare function SuggestionId(id?: string): SuggestionId;
|
|
17
28
|
//# sourceMappingURL=brand.d.ts.map
|
package/lib/brand.d.ts.map
CHANGED
|
@@ -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;AAED,4DAA4D;AAC5D,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAExC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAE,MAAqB,GAAG,OAAO,CAE1D"}
|
|
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;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAElD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,GAAE,MAAqB,GAAG,YAAY,CAEpE"}
|
package/lib/brand.js
CHANGED
|
@@ -14,4 +14,11 @@ export function MemoryId(id = randomUUID()) {
|
|
|
14
14
|
export function AuditId(id = randomUUID()) {
|
|
15
15
|
return id;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Mint a new unique suggestion id.
|
|
19
|
+
* @returns a fresh branded id.
|
|
20
|
+
*/
|
|
21
|
+
export function SuggestionId(id = randomUUID()) {
|
|
22
|
+
return id;
|
|
23
|
+
}
|
|
17
24
|
//# 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,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"}
|
|
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;AASD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,GAAW,UAAU,EAAE;IACpD,OAAO,EAAkB,CAAA;AAC3B,CAAC"}
|