@chenhw7/dsh-memory 0.4.0 → 0.5.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.
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- 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 +1 -1
- package/lib/notes/index.d.ts.map +1 -1
- package/lib/notes/index.js +37 -7
- package/lib/notes/index.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/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 +5 -1
package/README.md
CHANGED
|
@@ -35,7 +35,9 @@ Your dsh agent normally forgets everything when you close a session. This bundle
|
|
|
35
35
|
- **Compaction-aware flush** — when compaction shadows old context, the raw events are scanned for anything worth remembering.
|
|
36
36
|
- **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
37
|
- **Frontend-configurable** — all settings exposed through four cards in the dsh settings UI, apply live.
|
|
38
|
-
- **
|
|
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.
|
|
39
|
+
- **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.
|
|
39
41
|
|
|
40
42
|
## Install
|
|
41
43
|
|
package/README.zh-CN.md
CHANGED
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
- **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
|
|
33
33
|
- **安全扫描:写入时 + 读取时** — API Key、Token、提示注入模式和泄露尝试会被阻止写入;漏网内容在重新进入 prompt 的任何位置都会被替换为 `[BLOCKED: …]` 占位符。
|
|
34
34
|
- **前端可配置** — 所有设置通过 dsh 设置界面的四张卡片暴露,实时生效。
|
|
35
|
-
-
|
|
35
|
+
- **可选的写入前人工确认** — 打开一个开关后,自动提取与工具产生的写入一律先进入待确认队列(同一提议反复出现会累计次数并置顶);采纳才落库(可先编辑),拒绝即丢弃。模型永不自我提升:对既有条目的修改提议在你采纳前不会改动原文。
|
|
36
|
+
- **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25 搜索、类别筛选、远程分页列表,并带完整写操作(编辑 / 置顶 / 归档 / 删除),中英双语。
|
|
37
|
+
- **时间窗浏览** — `memory_list` 支持 `since`/`until` 毫秒时间戳边界,「上周学了什么」这类查询直接在窗口内分页。
|
|
36
38
|
|
|
37
39
|
## 安装
|
|
38
40
|
|
|
@@ -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,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,IAA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wD;IACxD,QAAQ,CAAC,EAAE,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5E,wDAAwD;IACxD,QAAQ,CAAC,EAAE,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAA;CAC7E;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAE,MAAU,GAAG,UAAU,CAmC5E;AAID,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,eAAe,EAAE,MAAM,EACvB,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3D,aAAa,CAQf;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,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,EAAE,SAAS,EAAE;IAC5H,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,+EAA+E,EAAE,QAAQ,EAAE,WAAW,EAAE;IAC9I,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,kFAAkF,EAAE;IAC1H,8BAA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,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"}
|