@yolk_vat-y/dsh-project-memory 0.5.14 → 0.5.15
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/CHANGELOG.md +115 -0
- package/README.md +77 -108
- package/README.zh-CN.md +71 -100
- package/package.json +3 -1
- package/scripts/file-peak.mjs +356 -0
- package/scripts/tool-schema-size.mjs +131 -0
- package/src/doc-pipeline.js +3 -6
- package/src/enhancer.js +105 -41
- package/src/index.js +4 -1
- package/src/ops.js +11 -13
- package/src/parsers/pdfjs-parser.js +0 -30
- package/src/readiness.js +5 -12
- package/src/store.js +48 -7
- package/src/symbols.js +2 -1
- package/src/tools/forget.js +1 -1
- package/src/tools/index-doc.js +1 -1
- package/src/tools/index-repo.js +19 -5
- package/src/tools/lesson-tools.js +19 -16
- package/src/tools/query-memory.js +1 -1
- package/src/tools/remember.js +1 -1
- package/src/tools/stats.js +1 -1
- package/src/tools/task-tools.js +6 -5
- package/src/tools/watch-repo.js +1 -1
- package/src/util/entry-id.js +32 -0
- package/src/util/fs.js +18 -2
- package/src/util/path-token.js +40 -0
- package/src/watch.js +15 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
+
## 0.5.15 (2026-10-06)
|
|
2
|
+
|
|
3
|
+
`npm test` **563 → 592 项 / 30 个文件**;`npm run eval:injection` 逐项不变
|
|
4
|
+
(命中 14 / 假阳性 0 / 漏召 0,P/R 1.00/1.00,7 次注入 857 字符)。
|
|
5
|
+
|
|
6
|
+
### 变更:工具 schema 预算瘦身 —— 每次请求固定开销 -356 token(粗估)
|
|
7
|
+
|
|
8
|
+
工具定义是**每次请求都付**的固定开销(12 个工具一万多字符),这一版删掉重复与过时文本,
|
|
9
|
+
并给这件事配了一个可回归的实测脚本 —— 起因就是实际使用时模型抱怨工具描述太长。
|
|
10
|
+
|
|
11
|
+
- `save_lesson` 把 `kind` / `scope` 语义在**工具描述**与**参数描述**里各写了一遍 —— 等于付两遍钱。
|
|
12
|
+
现在只在参数上写一次,语义一条没少。
|
|
13
|
+
- `trigger` 的四个**旧字段**(`keywords` / `actions` / `paths` / `scope`)不再占描述预算:schema 形状
|
|
14
|
+
保留(历史条目与旧调用照常解析),语义见 README 与参数描述。
|
|
15
|
+
- 8 个工具各自重复的 `root` 说明统一成一句「项目根目录,默认当前工作目录。」
|
|
16
|
+
- 新增 `scripts/tool-schema-size.mjs`(`npm run schema:size`):用真实的 `defineTool` 投影算出每个工具
|
|
17
|
+
实际发出的字符数。**口径**:字符与 token 分开报,且 token 按语种加权(CJK 1 token/字符、其余 4 字符/token)——
|
|
18
|
+
拿一个固定的「字符/token」系数去乘中英混合文本,会把「英文改中文」掉下来的字符数误当成 token 省下来了。
|
|
19
|
+
- 实测(同机 A/B,对上一个提交建 worktree 跑同一个脚本):**10,341 → 8,388 字符(-18.9%)**、
|
|
20
|
+
**3,040 → 2,684 token 粗估(-356,-11.7%)**。字符降幅明显大于 token 降幅,正是因为其中一部分
|
|
21
|
+
文本由英文改成了中文;**真正的 token 节省来自删掉的重复描述与旧字段说明**,不是换了语种。
|
|
22
|
+
|
|
23
|
+
### 修复:读不到的目录被当成「已删除」,静默清掉派生索引
|
|
24
|
+
|
|
25
|
+
`walkDir` 对 `readdirSync` 失败直接 `catch { continue }`:那棵子树既不进 `seen`,又不置
|
|
26
|
+
`truncated`,而 `index_repo` 只在 `truncated` 时跳过 unseen 清理 —— 于是读失败的目录下的既有
|
|
27
|
+
条目被当「本轮没见到 = 已删除」清掉,下一次索引再把它们建回来。
|
|
28
|
+
|
|
29
|
+
- `walkDir` 新增 `unreadable`(失败的目录)与 `capped`(撞 `maxFiles`/`maxDepth`),
|
|
30
|
+
`truncated = capped || unreadable.length > 0`。**读不到 ≠ 不存在**,两者都按"扫描不完整"处理。
|
|
31
|
+
- `index_repo` 的报告区分两种截断:`could not read N director(y|ies) (permissions?): …` 与
|
|
32
|
+
`scan truncated at the safety limit (maxFiles=…, maxDepth=…)` —— 旧文案会把权限问题谎报成撞上限。
|
|
33
|
+
- watcher 同样分类告警(每个根一次),并照旧不传 `unseen`。
|
|
34
|
+
- 后果本来就有界:`removeFile()` 只删 `files`/`entries`(派生索引),insights / tasks /
|
|
35
|
+
experience 与源文件都不动 → 重新索引即恢复。但失败是静默的,所以照修。
|
|
36
|
+
- 测试:`walkDir` 报 `unreadable` 且 `truncated`(`capped=false`);EACCES 目录下的既有条目
|
|
37
|
+
在重跑 `index_repo` 后**仍在**,报告点名"读不到"。Windows / root 下 chmod 拦不住 `readdir`,
|
|
38
|
+
该用例显式跳过并打印原因。
|
|
39
|
+
|
|
40
|
+
### 修复:`a b.md` 与 `a_b.md` 撞同一个 entry id,检索静默少结果
|
|
41
|
+
|
|
42
|
+
id 前缀规则 `replace(/[\\/:\s]/g, '_')` 曾在**三处各写一份**(`doc-pipeline.js` 的 `relativeId`、
|
|
43
|
+
`symbols.js` 的 `buildSymbol`、`enhancer.js` 的 `applyEnhancedSymbols`),且把 `/ \ : 空白` 全部
|
|
44
|
+
映射成同一个 `_`。于是 `a b.md`、`a_b.md`、`a/b.md`、`a:b.md` 生成同一个 `${prefix}#0`。
|
|
45
|
+
|
|
46
|
+
撞 id 的代价不是"不好看":`rankEntriesStreaming` 按 id 合并多查询命中,两条不同文件的条目会被
|
|
47
|
+
合成一条、低分的那条**静默消失**。
|
|
48
|
+
|
|
49
|
+
- 新增 `src/util/entry-id.js`:`entryIdPrefix(relPath)` 单射编码 —— `/` → `_`(保持
|
|
50
|
+
`src/foo.js` 可读),其余风险字符(`\` `:` 各空白 `_` `%` `#`)→ `%` + 码点十六进制。
|
|
51
|
+
三处副本全部改为调用它。
|
|
52
|
+
- 单射理由:输出里的 `%` 只可能来自转义(源里的 `%` 一定是 `%25`),每个风险字符的转义串互不
|
|
53
|
+
相同且都不是 `_`;其余字符原样输出。CJK 不受影响(不像 `encodeURIComponent` 会把每个字变成
|
|
54
|
+
9 字节,那会让 id 变长、把 store 撑大)。
|
|
55
|
+
- 存量 store 不需要迁移:id 不是存储键(键是 `relPath`),旧 id 照常可比对;文件变化时自然换新。
|
|
56
|
+
- 测试:15 个互相"危险"的路径 → 15 个不同前缀;符号表路径同款单射;端到端 —— 索引
|
|
57
|
+
`a b.md` + `a_b.md` 后两个 doc id 不同,且**两条都留在检索结果里**(旧规则下必为 1 条)。
|
|
58
|
+
|
|
59
|
+
### 内存:剥离派生字段不再用 `delete`(1196 B/条 → 406 B/条)
|
|
60
|
+
|
|
61
|
+
`stripPersistedDerived` / `withoutPersistedDerived` 原本 `{...entry}` / 原地 `delete` 掉
|
|
62
|
+
`linkedSymbols` / `searchText` / `typeSig`。`delete` 会把 entry 推进 V8 字典模式,之后每个属性
|
|
63
|
+
都变成哈希表项 —— 加载路径上这是常驻内存(`storeCache` 里所有 store 都算),写盘路径同款浪费。
|
|
64
|
+
|
|
65
|
+
- 改为**按非派生键重建**:没有派生字段时原对象返回(零分配热路径),有则重建;
|
|
66
|
+
值为 `undefined` 的键(`typeSig: undefined` 是 enhancer 的实现细节)也不再占槽位。
|
|
67
|
+
`__proto__` 用 `Object.defineProperty` 写入,避免 `out[key] = value` 走去改原型。
|
|
68
|
+
- 实测(20k 条真实条目形状,`--expose-gc`):字典模式 **1196 B/条** → 重建 **406 B/条**;
|
|
69
|
+
按本仓库量级(10^5 条目)折算,加载后驻留省 10^1 MB 量级。
|
|
70
|
+
- 测试:行为面(键集、原对象不被改、零分配路径、存量 store 加载即剥离 + 下一次 `save()` 压实
|
|
71
|
+
磁盘)+ 形状面(子进程 `--expose-gc` 对照旧 `delete` 版本,断言至少省 25%)。
|
|
72
|
+
|
|
73
|
+
### 加固:TS 增强队列有上界,且正文/解析推迟到出队时
|
|
74
|
+
|
|
75
|
+
`enqueueEnhance` 原本在入队时就同步读正文 + `deepParseWithTS`(同步跑到第一个 `await`),
|
|
76
|
+
于是 `index_repo` 对整棵 TS 树一次性入队 = 同时持有**所有**文件的正文与符号数组;队列本身也没有
|
|
77
|
+
任何 cap。长驻 `dsh web` 的 RSS 单调爬升就是这个形状。
|
|
78
|
+
|
|
79
|
+
- 任务体推迟到出队:入队只读一次文件算 `cacheKey`(16 字节),正文与解析结果不留在队列里,
|
|
80
|
+
真正读正文/解析/提交发生在 `runEnhance()`。队列每条只剩元数据。
|
|
81
|
+
- 队列有界:`ENHANCE_QUEUE_MAX = 20000`(与 `maxScanFiles` 默认同量级,正常仓库够不到,是兜底阀)。
|
|
82
|
+
满了先挤队尾(最不紧急的),挤不动就丢新来的那条;被丢/被挤掉的任务 promise **立刻 resolve**
|
|
83
|
+
(调用方都是 fire-and-forget,不能让谁悬着),丢弃计数与一次告警不静默,
|
|
84
|
+
`index_repo` 把它写进报告(`N file(s) skipped TS enhancement …`)。
|
|
85
|
+
- 去重语义不变(同 relPath 同内容复用,内容变了换掉 —— 被换掉的那条 promise 同样 resolve)。
|
|
86
|
+
- 测试:入队上限收窄到 3 后断言队列不超上限、**同步阶段只解析 1 个文件**、超限计数 +1、
|
|
87
|
+
所有 promise 都 settle、队列最终排空且增强结果仍落进 store。
|
|
88
|
+
|
|
89
|
+
### 加固:`maxFileSizeMb` 降到实测安全区(50 → 10 MB),并补上峰值系数
|
|
90
|
+
|
|
91
|
+
`maxFileSizeMb` 是**单文件内存闸门**,但它的默认值 50 从 v0.1 起就没量过。这回补上阶梯实测
|
|
92
|
+
(新增 `scripts/file-peak.mjs` / `npm run bench:peak`:1 / 2 / 4 / 8 / 16 / 32 / 50 MB,每档一个独立
|
|
93
|
+
子进程 + `--expose-gc`,对「峰值 RSS = a + b × 磁盘 MB」做最小二乘):
|
|
94
|
+
|
|
95
|
+
| 语料(50 MB 单个文件) | 边际系数 b(峰值 RSS / 磁盘) | 实测峰值 RSS |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| 典型源码(≈1 个声明 / 1.2 KB) | **9.6×** | 590 MB |
|
|
98
|
+
| 符号密集代码(≈1 个 / 240 B) | **20.6×** | 1 189 MB |
|
|
99
|
+
| 文本型 PDF(未压缩流,≈0.9 字符/磁盘字节) | **19.0×** | 1 194 MB |
|
|
100
|
+
|
|
101
|
+
- 结论:**旧的 50 MB 允许单个文件把宿主进程推到 ~1.2 GB RSS**(还有一次最长 12.5 s 的同步解析),
|
|
102
|
+
这正是 issue #5 那类 OOM 的形状。原先文档与计划里写的「峰值是它的 2–4 倍」**低了 5 倍**。
|
|
103
|
+
- 默认值改为 **10 MB**:最坏情况单文件增量 ≈ **+300 MB RSS**(20.6 × 10)。误伤面实测很小 ——
|
|
104
|
+
本机 8 个真实 store 里只有 1 个文件超过 10 MB(`Demon/analysis/il2cpp/dump.cs`,28.7 MB 的生成物,
|
|
105
|
+
也正是最该跳过的那类:生成的、符号密集、索引收益低而内存最贵)。旋钮仍可调高,
|
|
106
|
+
双语 README 的配置表与「单文件内存预算」一节都写明了各自系数。
|
|
107
|
+
- 口径提醒:heap 峰值受 GC 时序影响会**非单调**(同一档符号密集语料,32 MB 量出 625 MB、
|
|
108
|
+
50 MB 反而 328 MB),所以脚本以 **RSS 为主口径**,heap 只作参考。
|
|
109
|
+
- 顺手清账:`parsePdfInfo()` 零调用方(且自己会整份读盘)→ 删除。
|
|
110
|
+
|
|
111
|
+
### 文档:README 测试数断言审计
|
|
112
|
+
|
|
113
|
+
README(英/中)的测试数此前停在 561,而 `npm test` 实测已是 563(`readiness` 15→16、
|
|
114
|
+
`ops` 6→7 两处漏更)。本次与新增用例一起对齐到 **592**,逐项相加与实测一致。
|
|
115
|
+
|
|
1
116
|
## 0.5.14 (2026-10-02)
|
|
2
117
|
|
|
3
118
|
`npm test` **540 → 561 项 / 28 → 30 个文件**;`npm run eval:injection` 逐项不变
|
package/README.md
CHANGED
|
@@ -15,33 +15,26 @@ A persistent **project development memory** for [DeepSeek Harness](https://githu
|
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
|
-
- **TaskBridge: cross-session development tasks** — the session's todo list and the files it touches are persisted as
|
|
19
|
-
- **Task panel
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
- **Read-time memorization** — a file is memorized the moment the model reads it, so memory is a byproduct of normal work rather than a separate upfront scan. Files that are never read are never indexed.
|
|
26
|
-
- **Doc ↔ code cross-linking** — a document that mentions a symbol is surfaced when that symbol is queried.
|
|
27
|
-
- **BM25 recall** — ranked search over documents, symbols, experience notes and insights, with optional LLM query expansion. Tuned for CJK: phrase boost, a synonym table and CJK-aware boundaries for doc↔symbol linking.
|
|
18
|
+
- **TaskBridge: cross-session development tasks** — the session's todo list and the files it touches are persisted as per-project task entities, so a workflow can be switched and resumed without re-scoping the project. Associated files stay in recency-weighted order (a read never outranks a written file), so a resumed session sees where to look first. New sessions continue with `list_tasks` → `select_task`. Work delegated to subagents creates no task. On hosts without session events the task tools still work as a plain record list.
|
|
19
|
+
- **Task panel and editing** — draggable cards show a task's steps and files, and can collapse to a mini-bar or be hidden. Title, steps and status can be edited inline, writing back through the same path as model updates; four visual themes change material, geometry, typeface and density only, and colours follow the host. The panel stays hidden until summoned, syncs in the background on session switch, never reopens itself after a refresh, and a render failure cannot take down the host.
|
|
20
|
+
- **Document memory** — PDF, Markdown and plain text are chunked and summarized without a model call. Each entry keeps a short summary for injection, a bounded term set for recall, and a citation back to the source.
|
|
21
|
+
- **Code symbol memory** — a dependency-free scanner extracts functions, classes, methods, interfaces and type aliases with full signatures across 8 languages. Where `typescript` is installed, an optional second layer adds inferred return types, generics and interface shapes; it runs in the background and never blocks indexing.
|
|
22
|
+
- **Automatic, read-time memorization** — a file is memorized the moment the model reads it, so memory is a byproduct of normal work rather than an upfront scan, and files nobody reads are never indexed. A background poll re-memorizes changed files only.
|
|
23
|
+
- **Doc ↔ code cross-linking** — a document that mentions a symbol is surfaced when that symbol is queried. Links are resolved against the current symbol table, so they cannot go stale.
|
|
24
|
+
- **BM25 recall** — ranked search over documents, symbols, experience notes and insights, with optional LLM query expansion. Tuned for CJK: phrase boost, a synonym table, and CJK-aware boundaries for doc↔symbol linking.
|
|
28
25
|
- **Experience notes** — problems → solutions, deduplicated by overlap rather than repeated, bounded by project size, and returned only when a search matches.
|
|
29
|
-
- **Tiered insight memory (lessons / decisions / procedures
|
|
30
|
-
- **Triggered injection** — an insight may carry an authored trigger: only `when` triggers, `guard` narrows it, and `prevents` records what breaks without the entry. Corpus text can never trigger an injection; the statistical channel is gated separately.
|
|
31
|
-
- **Streaming TF + IDF caching** — the query path caches term weights per store version (measured numbers under Performance). Only a real write drops the cache, so the watch poll never clears one a query just built.
|
|
32
|
-
- **Lock-free sync transactions** — all writes go through a synchronous transaction, so `remember` and `forget` never queue behind re-indexing. The lock is in-process: avoid pointing two dsh instances at the same store.
|
|
33
|
-
- **Minimal dependencies** — pure JavaScript; one runtime dependency for PDF text extraction, no native builds.
|
|
34
|
-
- **Negligible overhead** — memory work is in-process; the bottleneck is document extraction and disk I/O, not scoring.
|
|
26
|
+
- **Tiered insight memory (lessons / decisions / procedures)** — one entity across task, project and global scope. Near-duplicates merge or reinforce, and promotion moves an entry between scopes instead of copying it. Use is recorded, so decay and capacity rank by activity rather than age alone. The panel exposes a per-scope view for reviewing and editing entries.
|
|
27
|
+
- **Triggered injection** — an insight may carry an authored trigger: only `when` triggers, `guard` narrows it, and `prevents` records what breaks without the entry. Corpus text can never trigger an injection; the statistical channel is gated separately and silent by default.
|
|
35
28
|
|
|
36
29
|
## Installation
|
|
37
30
|
|
|
38
|
-
The plugin relies only on stable public APIs
|
|
31
|
+
The plugin relies only on stable public APIs declared through peerDependencies.
|
|
39
32
|
|
|
40
33
|
```bash
|
|
41
34
|
cd dsh-project-memory && dsh plugin --profile web add . -w
|
|
42
35
|
```
|
|
43
36
|
|
|
44
|
-
The `-w` (workspace-root) flag is required: the profile directory is a pnpm workspace root, and pnpm rejects `add` there without it. From
|
|
37
|
+
The `-w` (workspace-root) flag is required: the profile directory is a pnpm workspace root, and pnpm rejects `add` there without it. From elsewhere, use the same command with an absolute path.
|
|
45
38
|
|
|
46
39
|
The plugin is also published on npm as a scoped package:
|
|
47
40
|
|
|
@@ -49,35 +42,29 @@ The plugin is also published on npm as a scoped package:
|
|
|
49
42
|
dsh plugin --profile web add @yolk_vat-y/dsh-project-memory -w
|
|
50
43
|
```
|
|
51
44
|
|
|
52
|
-
Each indexed project has its own store at `<root>/.dsh-project-memory/`.
|
|
45
|
+
Each indexed project has its own store at `<root>/.dsh-project-memory/`. It keeps itself out of git by default — there is nothing to add to your `.gitignore`.
|
|
53
46
|
|
|
54
47
|
## Usage
|
|
55
48
|
|
|
56
|
-
The tools below are **invoked by the agent**, not typed by the user. In the chat, just ask naturally — e.g. "index this project" or "what does the auth module do?" — or simply keep working, and the agent calls the matching tool automatically. By default
|
|
49
|
+
The tools below are **invoked by the agent**, not typed by the user. In the chat, just ask naturally — e.g. "index this project" or "what does the auth module do?" — or simply keep working, and the agent calls the matching tool automatically. By default files are indexed the moment the model reads them, so memory fills in while you work. `watch_repo` keeps explicitly-watched roots fresh in the background; `index_repo` forces a full backfill (unchanged files are skipped).
|
|
57
50
|
|
|
58
51
|
| Tool | Purpose |
|
|
59
52
|
|---|---|
|
|
60
|
-
| `index_doc file_path` | Index one document (PDF/MD/txt): chunk
|
|
61
|
-
| `index_repo root` | Index a whole project:
|
|
62
|
-
| `watch_repo root` | Enable automatic refresh: a background poll detects new
|
|
63
|
-
| `memory_stats root` | Show what the store contains: totals
|
|
64
|
-
| `query_memory query` |
|
|
53
|
+
| `index_doc file_path` | Index one document (PDF/MD/txt): chunk, summarize deterministically, and store with a `path:line` citation. Unchanged files are skipped. |
|
|
54
|
+
| `index_repo root` | Index a whole project: documents get deterministic summaries, code files get a token-free symbol table. Incremental, cleans up deleted files, cross-links documents to symbols. A non-existent or excluded root is rejected before anything is written. |
|
|
55
|
+
| `watch_repo root` | Enable automatic refresh: a background poll detects new and changed files and re-indexes only those. Watched roots persist across restarts; a non-existent or excluded root is refused, roots that disappear are dropped rather than re-created. |
|
|
56
|
+
| `memory_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. |
|
|
57
|
+
| `query_memory query` | Ranked search over documents, symbols, experience and insights, optionally query-expanded by the LLM. `type` selects a layer (`all` / `doc` / `symbol` / `experience` / `insight` / `task`). Returns hits with relative scores, sources or insight ids, and doc→symbol references. |
|
|
65
58
|
| `list_tasks` | List task records for the project (archived marked). Call first in a new session before continuing work. |
|
|
66
59
|
| `select_task` | Bind the session to a task so its todo list and file reads sync into it. Exact `taskId`, or exact `title` (multiple matches return candidates; no match creates a new task). Pass `title` with `taskId` to rename. Auto-unarchives. |
|
|
67
60
|
| `archive_task` | Archive a task (hide from default views, exclude from capacity, stop syncing). `select_task` restores it. |
|
|
68
61
|
| `show_task_panel` | Show the task panel in the UI. Call when the user asks to see the task list or when you want to display the panel. |
|
|
69
|
-
| `/tasks` (typed by the user, not the model) | The only user command: shows the task stack
|
|
62
|
+
| `/tasks` (typed by the user, not the model) | The only user command: shows the task stack and drives the workflow card. Every other action is a **sub-verb** invoked by card buttons: `switch` / `archive` / `unbind` / `rename` / `todos …` for tasks, `insight list` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` for memory. |
|
|
70
63
|
| `remember problem solution` | Save an experience note. Similar problems supersede instead of duplicating. |
|
|
71
64
|
| `forget id_or_query` | Delete stale experience notes. |
|
|
72
|
-
| `save_lesson`
|
|
65
|
+
| `save_lesson` | Save a lesson / decision / procedure at task, project or global scope. Near-duplicates merge (≥ 0.7 overlap) or reinforce (0.65–0.7); two tasks hitting the same insight promote it task → project, three or more → global. Key params: `title`, `kind`, `scope`, the content (`pattern`/`fix`, `choice`/`reason` or `steps`), and `trigger` (`when` is the only trigger surface, `guard` narrows it, `prevents` records what breaks without it). |
|
|
73
66
|
|
|
74
|
-
`/tasks` appears in the web `/` menu inside an icon-bearing **Workflow** group,
|
|
75
|
-
entries — Tasks / Project Memory / Global Memory (labelled in the UI language). A host command always
|
|
76
|
-
shows up in the built-in **Commands** section and a plugin cannot hide it (`commands.list()` and
|
|
77
|
-
`commands.execute()` read the same view, and `CommandDefinition` has no hidden flag), so the plugin
|
|
78
|
-
registers **only `/tasks`** and every other action rides it as a sub-verb driven by card buttons: the
|
|
79
|
-
menu duplication is one row. Typing `/tasks` + Enter still executes immediately; typing an argued line
|
|
80
|
-
such as `/tasks switch x` is no longer recognised as a command — use the card buttons.
|
|
67
|
+
`/tasks` appears in the web `/` menu inside an icon-bearing **Workflow** group, with three view entries — Tasks / Project Memory / Global Memory (labelled in the UI language). It is the plugin's only registered command; every other action rides it as a sub-verb driven by card buttons.
|
|
81
68
|
|
|
82
69
|
## How it works
|
|
83
70
|
|
|
@@ -85,10 +72,10 @@ The design follows four principles:
|
|
|
85
72
|
|
|
86
73
|
- **Volatility** — context is ephemeral; it is lost when a session is compacted.
|
|
87
74
|
- **Persistence** — the **memory** is stored on disk and survives compaction and new sessions.
|
|
88
|
-
- **Compactness** —
|
|
75
|
+
- **Compactness** — one bounded declaration line per symbol, and a ≤300-char summary plus a bounded term set per document chunk. Derived data is never stored: doc→symbol links are computed at read time. Index size depends on symbol density and chunk length, so treat these as measurements of specific corpora (2026-09-25), not guarantees: a code-only Vue app (289 files) lands at **325 bytes/entry ≈ 21% of source**, a symbol-dense TypeScript monorepo (12,408 files / 106 MB of code + 14 MB of docs) at **22% of source for the code layer (553 bytes/entry overall)** and **130% for the document layer**, and a 274-document workspace (PDFs and Markdown) at **1,506 bytes/entry**.
|
|
89
76
|
- **Verifiability** — **recalls** carry a `path:line` citation where applicable, so the agent can confirm details against the source.
|
|
90
77
|
|
|
91
|
-
Building the **memory** does not require an upfront scan: files are memorized as the model reads them, so the **memory** grows to cover exactly what has been worked with. Re-reading
|
|
78
|
+
Building the **memory** does not require an upfront scan: files are memorized as the model reads them, so the **memory** grows to cover exactly what has been worked with. Re-reading an unchanged file is a no-op, so the **memory** stays fresh with minimal ongoing overhead.
|
|
92
79
|
|
|
93
80
|
The store is per-project and follows the codebase: changed files are re-extracted by content hash, deleted files are removed. Experience notes are retrieval-only, so accumulation does not affect context.
|
|
94
81
|
|
|
@@ -97,23 +84,22 @@ The store is per-project and follows the codebase: changed files are re-extracte
|
|
|
97
84
|
```
|
|
98
85
|
.dsh-project-memory/
|
|
99
86
|
format.json layout marker (v2, sharded)
|
|
100
|
-
shards/ one self-describing JSON per indexed source file
|
|
101
|
-
({ relPath, record, entries }) — writes touch only dirty shards
|
|
87
|
+
shards/ one self-describing JSON per indexed source file — writes touch only dirty shards
|
|
102
88
|
experience.json problem → solution notes (retrieval-only)
|
|
103
89
|
watch.json watched roots
|
|
104
90
|
tasks.json TaskBridge task entities (cross-session)
|
|
105
91
|
binding.json current session ↔ task binding
|
|
106
|
-
insights.json
|
|
92
|
+
insights.json project-scope insights (lessons / decisions / procedures)
|
|
107
93
|
injection-audit.jsonl one line per real injection (what / why / dropped / budget)
|
|
108
|
-
admission-shadow.jsonl one line
|
|
94
|
+
admission-shadow.jsonl one line per step, all scored candidates + features (offline replay)
|
|
109
95
|
```
|
|
110
96
|
|
|
111
|
-
Stores created before v0.2.0
|
|
97
|
+
Stores created before v0.2.0 migrate automatically and idempotently on first load. Within one dsh process, all tool calls share a single in-memory store per project, so hot-path indexing writes only the shard that changed.
|
|
112
98
|
|
|
113
|
-
- **Incremental** — content hash per file; only changed files are re-extracted.
|
|
114
|
-
- **Cross-linking** —
|
|
115
|
-
- **Query expansion** — when
|
|
116
|
-
- **Consistency** — the fact layer follows the codebase (hash re-extract / remove-on-delete); the experience layer is retrieval-only with supersede and `forget`.
|
|
99
|
+
- **Incremental** — a content hash per file; only changed files are re-extracted.
|
|
100
|
+
- **Cross-linking** — a returned document chunk resolves the symbols it mentions against the **current** symbol table and appends them as `references`, so a doc indexed before its symbols still links correctly.
|
|
101
|
+
- **Query expansion** — when enabled, `query_memory` asks the LLM to rewrite the query into several variants (synonyms, EN/CN, identifier guesses) and merges the scores; when off, queries never touch the LLM. Indexing itself is model-free.
|
|
102
|
+
- **Consistency** — the fact layer follows the codebase (hash re-extract / remove-on-delete); the experience layer is retrieval-only with supersede and `forget`. The store lock is in-process, so avoid running multiple dsh instances against the same project store.
|
|
117
103
|
|
|
118
104
|
## Architecture (Task Panel)
|
|
119
105
|
|
|
@@ -125,7 +111,7 @@ TaskPanel (Container)
|
|
|
125
111
|
└── TaskComponents (MiniBar, TaskCard — presentational only)
|
|
126
112
|
```
|
|
127
113
|
|
|
128
|
-
The workflow panel is collapsible,
|
|
114
|
+
The workflow panel is collapsible, adapts to dsh and theme plugin styles, and offers four card styles.
|
|
129
115
|
|
|
130
116
|

|
|
131
117
|
|
|
@@ -134,53 +120,32 @@ The workflow panel is collapsible, automatically adapts to dsh and theme plugin
|
|
|
134
120
|
| Key | Default | Meaning |
|
|
135
121
|
|---|---|---|
|
|
136
122
|
| `memoryDir` | `.dsh-project-memory` | store directory inside each indexed root |
|
|
137
|
-
| `chunkChars` | 3000 | max chars per document chunk |
|
|
138
|
-
| `
|
|
139
|
-
| `
|
|
123
|
+
| `chunkChars` / `maxChunksPerFile` | 3000 / 40 | max chars per document chunk, max chunks per document |
|
|
124
|
+
| `maxFileSizeMb` | 10 | skip documents (incl. PDF) and code files larger than this (MB); see the per-file memory budget below |
|
|
125
|
+
| `maxPdfPages` | 1000 | PDF page cap |
|
|
140
126
|
| `maxOutputChars` | 8000 | cap for `query_memory` result text (chars) |
|
|
141
|
-
| `
|
|
142
|
-
| `tasklist.syncHostOnAdopt` | true | when `select_task`/`/task switch` binds a task, push its steps to host `todo/write` so dsh's task list mirrors the task |
|
|
143
|
-
| `maxPdfPages` | 1000 | PDF page cap when pages are not otherwise limited |
|
|
144
|
-
| `llmQueryExpansion` | false | expand queries via `ctx.llm` before BM25 (off by default to save tokens) |
|
|
145
|
-
| `expansionCount` | 6 | max expansion variants |
|
|
146
|
-
| `lazyIndexing` | true | index files the moment the model reads them (`fs/observed`) |
|
|
127
|
+
| `lazyIndexing` | true | index files the moment the model reads them |
|
|
147
128
|
| `autoIndexOnFirstUse` | false | full scan of the current working directory on plugin load (opt-in) |
|
|
148
|
-
| `watch` | true
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
152
|
-
| `
|
|
153
|
-
| `
|
|
154
|
-
| `
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
|
159
|
-
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `autoContext.
|
|
163
|
-
| `autoContext.
|
|
164
|
-
| `autoContext.maxItemsPerSession` | 60 | **runaway fuse, not a throttle** — throttling is done by `maxTokens` (per step) and `gateCooldownSteps`. It is a hard per-session ceiling: once reached, the item channel stays silent for the rest of the session. The default sat at 12 until 0.5.14, which real usage did reach (longest observed session: 35 items), permanently blinding the tail of long sessions. Set it lower to reproduce the old behaviour |
|
|
165
|
-
| `autoContext.maxItemCharsPerSession` | 24000 | same, in characters |
|
|
166
|
-
| `autoContext.hintMinCoverage` | 0.45 | **absolute** floor for the statistical (hint) channel: IDF-weighted share of the query's information mass the entry covers. A ratio-only threshold cannot tell signal from "best of a bad lot" (`relative:1.00` on an unrelated entry). Raised from 0.30 in 0.5.8: on a real 43-entry store the control scenario injected 3 unrelated hints at cov 0.32–0.35, because a same-corpus store flattens IDF |
|
|
167
|
-
| `autoContext.hintMinMatched` | 2 | a hint must share at least this many terms with the query — one generic word ("plugin") is not evidence |
|
|
168
|
-
| `autoContext.hintMinSupport` | 0.15 | channel-level silence: if less than this share of the query's terms exist anywhere in the corpus, the hint channel says nothing this round — a long sentence that happens to share one word otherwise reports `cov:1.00` |
|
|
169
|
-
| `autoContext.legacyScope` | `filter` | how to treat a legacy `trigger.scope`: `filter` keeps the old semantics, `ignore` drops it. `npm run selfcheck:triggers` reports entries whose scope values cannot intersect the project tag space |
|
|
170
|
-
| `autoContext.auditLog` | true | append one JSONL line per **actual** injection to `<root>/.dsh-project-memory/injection-audit.jsonl` (what was injected, why it matched, what was dropped, session budget snapshot); rotates to `.1` past `auditMaxBytes` (`262144`). Silent on any I/O error — never affects the host request |
|
|
171
|
-
| `autoContext.shadowLog` | true | append one JSONL line **per step** (including steps that injected nothing) to `admission-shadow.jsonl`: the scored candidates near the head of the ranking (`rel` / `coverage` / `matched` / `decision` / `outcome`) plus the step's `query` / `scoreQuery` / `ops` / `writes`. This is what makes a threshold change answerable offline on real history (`decision` shows which gate rejected each candidate, `outcome` what the budget did with it). Rotates past `shadowMaxBytes` (`524288`), keeping one `.1` generation, so the per-project log ceiling is `2 × shadowMaxBytes + 2 × auditMaxBytes` ≈ 1.5 MB. Disk only — never enters the prompt, costs no tokens |
|
|
172
|
-
| `autoContext.shadowMaxBytes` | 524288 | rotation cap for `admission-shadow.jsonl` (one `.1` generation is kept) |
|
|
129
|
+
| `watch` / `watchInterval` | true / 30 | background refresh; base poll interval in seconds (idle polls back off up to 2 minutes and reset on any change) |
|
|
130
|
+
| `maxScanFiles` / `maxScanDepth` | 20000 / 12 | per-scan caps on files and directory depth; a truncated pass is reported and never removes what it did not reach. Set `0` to disable |
|
|
131
|
+
| `allowUnsafeRoots` | false | allow **explicit** tool calls to target a directory on the excluded list. Automatic paths (lazy indexing, session audit, TaskBridge, `autoIndexOnFirstUse`) stay inert there regardless |
|
|
132
|
+
| `llmQueryExpansion` / `expansionCount` | false / 6 | expand queries via the LLM before search (off by default to save tokens); max variants |
|
|
133
|
+
| `tsPath` / `enableTypeScript` | (auto) / true | optional absolute path to a specific `typescript` install; set `enableTypeScript: false` to disable the type-aware layer entirely |
|
|
134
|
+
| `tasklist.enabled` / `tasklist.syncHostOnAdopt` | true / true | TaskBridge auto-sync (task entities from the session todo list and file reads); push a bound task's steps to the host task list so dsh mirrors it |
|
|
135
|
+
| `insight.*` | dedupOverlap `0.7` · reinforceBand `0.65` · maxProject `100` · maxGlobalProcedures `200` · promoteConfidence `0.7` · globalPromoteTasks `3` · decayDays `90` · `globalFile` (auto) | insight dedupe / reinforce / promotion / capacity / archive settings |
|
|
136
|
+
| `reflection.enabled` | false | LLM reflection, **draft-only at task level** (fires on task switch-away / archive). `cooldownMs` `1800000`, `maxLessonsPerReflect` `3`, `maxDecisionsPerReflect` `2` |
|
|
137
|
+
| `autoContext.enabled` | true | silent injection wrapper (resident task card + gated items); inert until the host exposes a resolvable session cwd. `maxTokens` `400` (per step), `editedMax` `3` (recently written files shown on the task card), `signalMinRatio` `0.5` (a hint must reach half of its layer's top score), `skipEchoSelfTodo` `true`, `budgetLog` `off`, `reinjectItemsAfter` `0` (steps before the same insight may be injected again), `rootNotice` `true` |
|
|
138
|
+
| `autoContext.gateCooldownSteps` | 2 | minimum number of pre-steps between two *item* injections (the resident task card is exempt — it is a state snapshot). This is the main "don't inject often" dial |
|
|
139
|
+
| `autoContext.maxItemsPerSession` / `autoContext.maxItemCharsPerSession` | 60 / 24000 | **runaway fuse, not a throttle** — a hard per-session ceiling by count and characters; once reached, the item channel stays silent for the rest of the session |
|
|
140
|
+
| `autoContext.hintMinCoverage` | 0.45 | **absolute** floor for the statistical channel: the IDF-weighted share of the query's information mass the entry covers. A ratio-only threshold cannot tell signal from "best of a bad lot" |
|
|
141
|
+
| `autoContext.hintMinMatched` / `autoContext.hintMinSupport` | 2 / 0.15 | a hint must share at least this many terms with the query, and at least this share of the query's terms must exist in the corpus at all — otherwise the channel stays silent this round |
|
|
142
|
+
| `autoContext.legacyScope` | `filter` | how to treat a legacy `trigger.scope`: `filter` keeps the old semantics, `ignore` drops it. `npm run selfcheck:triggers` reports entries whose scope cannot intersect the project tag space |
|
|
143
|
+
| `autoContext.auditLog` | true | append one JSONL line per **actual** injection to `injection-audit.jsonl` (what / why / dropped / budget); rotates to `.1` past `auditMaxBytes` (`262144`). Silent on I/O errors |
|
|
144
|
+
| `autoContext.shadowLog` / `autoContext.shadowMaxBytes` | true / 524288 | append one JSONL line **per step** (including steps that injected nothing) to `admission-shadow.jsonl`: scored candidates with their features and the gate that rejected each one — what makes a threshold change answerable offline. Disk only, never in the prompt; rotates keeping one `.1` generation |
|
|
173
145
|
|
|
174
146
|
### Injection admission (why it stays quiet)
|
|
175
147
|
|
|
176
|
-
Automatic injection used to be a *retrieval* problem ("which entry is most related to this text?"), which is total — a ranking always returns something, so noise was structural. It is now an **admission** problem ("is this step about to cross a boundary I have been burned by?"), with silence as the default:
|
|
177
|
-
|
|
178
|
-
- **Only `when` triggers**, and it is a low-dimensional typed signal: normalized `ops`, the files this step is about to **write**, and intent words from the human message *after* stripping quoted/path references. Corpus text — raw tool arguments, file contents, filenames — can never trigger anything.
|
|
179
|
-
- **`guard` only narrows.** Extension/name globs (`*.pptx`, `README*`) are ignored outright: they can only lie, never narrow.
|
|
180
|
-
- **Ratio *plus* an absolute floor.** The hint channel needs the relative score *and* an IDF-weighted coverage floor *and* at least two shared terms — `relative:1.00` also happens on entries that share nothing with the step.
|
|
181
|
-
- **Frequency is bounded.** At most one item injection every `gateCooldownSteps`, capped per session by count and characters. The resident task card is exempt (it is a snapshot that should update); the budget is a ceiling, not a target.
|
|
182
|
-
- **Prefix-cache discipline.** Injections are appended as a user message at the tail of the history, so the cached prefix is never rewritten. What they add is resident *cache-read* tokens, not cache misses; nothing is ever edited in place.
|
|
183
|
-
- **It is auditable.** Every real injection appends one line to `injection-audit.jsonl` (reason, dropped candidates, session budget), and `admission-shadow.jsonl` adds one line **per step** — including the steps that correctly injected nothing — with every candidate's features and the gate that rejected it. That second file is what makes a threshold question answerable offline instead of by re-running the agent. `npm run eval:injection` scores 8 labelled scenarios on a **synthetic** pool — currently precision 1.00 / recall 1.00 with a clean control group. That pool is the CI baseline, not evidence about your data: point the same harness at your own store and the control group becomes a **hard gate** (`--store`, exits non-zero on violation). That is how the 0.45 floor was chosen, and how you can re-choose it (`--hint-cov <n>` replays at another floor).
|
|
148
|
+
Automatic injection used to be a *retrieval* problem ("which entry is most related to this text?"), which is total — a ranking always returns something, so noise was structural. It is now an **admission** problem ("is this step about to cross a boundary I have been burned by?"), with silence as the default. Only `when` triggers, from a low-dimensional typed signal: normalized operations, the files this step is about to **write**, and intent words from the human message *after* stripping quoted/path references — tool arguments, file contents and filenames can never trigger anything. `guard` only narrows (extension/name globs such as `*.pptx` or `README*` are ignored outright: they can only lie). The statistical channel needs the relative score, an absolute coverage floor and at least two shared terms, and item injections are limited to one every `gateCooldownSteps` and capped per session — the resident task card is exempt, and the budget is a ceiling, not a target. Injections are appended at the tail of the history, so the cached prefix is never rewritten: they cost cache-read tokens, not cache misses. Every real injection is logged with its reason and dropped candidates, and a shadow log adds one line per step — including the steps that correctly injected nothing. `npm run eval:injection` scores 8 labelled scenarios on a **synthetic** pool (currently precision 1.00 / recall 1.00 with a clean control group); that pool is the CI baseline, not evidence about your data — point the harness at your own store (`--store`) and the control group becomes a **hard gate**.
|
|
184
149
|
|
|
185
150
|
### Toggling features
|
|
186
151
|
|
|
@@ -192,9 +157,11 @@ When the root comes from the working directory, the model gets one notice per se
|
|
|
192
157
|
|
|
193
158
|
**Excluded directories.** Not used as a root, matched exactly (subdirectories are unaffected): the filesystem root, the home directory, temp directories — `os.tmpdir()` and the shared ones (`/tmp`, `/var/tmp`, `%TEMP%`, `%SystemRoot%\Temp`) — and system / package-manager prefixes (`/opt/homebrew` on POSIX; `%SystemRoot%`, `%ProgramFiles%`, `%ProgramData%` on Windows). A session in one of these runs without memory, with one line on stderr.
|
|
194
159
|
|
|
195
|
-
**Scan limits.** One pass covers at most `maxScanFiles` files (20000) and `maxScanDepth` directory levels (12). A truncated pass is reported in the `index_repo` result and logged once per root by the watcher, and it does not remove entries it did not reach.
|
|
160
|
+
**Scan limits.** One pass covers at most `maxScanFiles` files (20000) and `maxScanDepth` directory levels (12). A truncated pass is reported in the `index_repo` result and logged once per root by the watcher, and it does not remove entries it did not reach. A directory that cannot be read (e.g. `EACCES`) counts as a truncated pass too and is named in the result: a read failure is not a deletion.
|
|
161
|
+
|
|
162
|
+
**Per-file memory budget.** `maxFileSizeMb` is a memory gate, not a disk-space preference. Indexing a file first materializes it — the whole buffer plus decoded text for code, or every PDF page's text plus the joined markdown for documents — and the peak scales with the file's size. Measured on this machine with `npm run bench:peak` (peak RSS fitted against disk size over a 1–50 MB ladder, one fresh process per point): **≈10×** for typical source code (1 declaration per ~1.2 KB), **≈21×** for symbol-dense code (1 per 240 B), **≈19×** for a text-heavy PDF, plus a one-off ≈150 MB floor the first time a PDF is parsed. The 10 MB default therefore keeps a single file at roughly **+300 MB RSS**; raising the cap raises that ceiling proportionally. The old default of 50 MB let one ordinary-sized file drive the host process to ~1.2 GB.
|
|
196
163
|
|
|
197
|
-
The store lives in the tree it indexes and **ignores itself**:
|
|
164
|
+
The store lives in the tree it indexes and **ignores itself**: a `*` rule inside the store keeps it out of `git status` and `git add -A`, and means `git clean -fd` leaves it alone. To commit project memory deliberately, `git add -f .dsh-project-memory` — tracked files are not affected by ignore rules.
|
|
198
165
|
|
|
199
166
|
Settings live in the plugin's config object. To change them, add an override entry to your profile's `cordis.patch.yml` — for the web profile that is `~/.dsh/profiles/web/cordis.patch.yml`:
|
|
200
167
|
|
|
@@ -208,7 +175,7 @@ Settings live in the plugin's config object. To change them, add an override ent
|
|
|
208
175
|
watchInterval: 30 # base poll interval; idle polls back off to at most 2 min
|
|
209
176
|
maxScanFiles: 20000 # per-scan file cap (truncation is reported, never deletes)
|
|
210
177
|
maxScanDepth: 12 # per-scan directory-depth cap
|
|
211
|
-
enableTypeScript: true # on:
|
|
178
|
+
enableTypeScript: true # on: type-aware enhancement when TS is installed (default)
|
|
212
179
|
# allowUnsafeRoots: false # keep false unless you really want to index a home/system dir explicitly
|
|
213
180
|
# budgetLog: once # debugging: log budget drops to stderr (default off = silent)
|
|
214
181
|
# reinjectItemsAfter: 20 # debugging: allow the same insight again after N steps (default 0 = once per session)
|
|
@@ -229,7 +196,7 @@ where `config.yml` contains the same override block.
|
|
|
229
196
|
|
|
230
197
|
### Measured on real projects (2026-09-25)
|
|
231
198
|
|
|
232
|
-
Four corpora, one machine (Node 24.19, 20 vCPU, Linux file system), each run twice with the **second, warm-cache run** quoted. "Cold index" is a full index pass (walk +
|
|
199
|
+
Four corpora, one machine (Node 24.19, 20 vCPU, Linux file system), each run twice with the **second, warm-cache run** quoted. "Cold index" is a full index pass (walk + hash + extract + commit); "query" runs the shipped scorer over 100 sampled queries; "re-index 1 file" is the watch/lazy hot path.
|
|
233
200
|
|
|
234
201
|
| Corpus | Files / entries | Cold index | Cold load | Query p50 / p95 | Re-index 1 file | Store content / on disk | Heap after load |
|
|
235
202
|
|--------|-----------------|-----------|-----------|-----------------|-----------------|------------------------|-----------------|
|
|
@@ -238,9 +205,9 @@ Four corpora, one machine (Node 24.19, 20 vCPU, Linux file system), each run twi
|
|
|
238
205
|
| TypeScript monorepo, 3,000-file slice | 3,000 / 17,733 | 2.1 s | 59 ms | 10.2 / 21.4 ms | 1.8 ms | 11.0 MB / 19.0 MB | 22.6 MB |
|
|
239
206
|
| TypeScript monorepo, whole tree | 12,408 / 79,168 | 8.6 s | 239 ms | 45.8 / 89.3 ms | 7.4 ms | 41.7 MB / 74.7 MB | 73.9 MB |
|
|
240
207
|
|
|
241
|
-
**How it scales.** Re-indexing a changed file costs O(file), not O(corpus) — 0.4–7.4 ms across every corpus above. Cold load (≈19 µs/file), query (≈0.6 µs/entry) and resident heap (≈1.4 KB/entry
|
|
208
|
+
**How it scales.** Re-indexing a changed file costs O(file), not O(corpus) — 0.4–7.4 ms across every corpus above. Cold load (≈19 µs/file), query (≈0.6 µs/entry) and resident heap (≈1.4 KB/entry) grow linearly with the index, which keeps small and mid-size projects in the single-digit-millisecond range.
|
|
242
209
|
|
|
243
|
-
> Two notes on method: `read+hash` depends on the OS page cache (2.5 s cold vs 0.3 s warm on the 12.4k-file tree), so the warm run is
|
|
210
|
+
> Two notes on method: `read+hash` depends on the OS page cache (2.5 s cold vs 0.3 s warm on the 12.4k-file tree), so the warm run is quoted; and these numbers drift by up to ~20% across days on the same machine, so compare runs measured in one session.
|
|
244
211
|
|
|
245
212
|
### Synthetic Benchmark (Node 24.19, 20 vCPU, Linux file system)
|
|
246
213
|
|
|
@@ -255,11 +222,11 @@ Four corpora, one machine (Node 24.19, 20 vCPU, Linux file system), each run twi
|
|
|
255
222
|
| Cold load | 10,000 files | 123 ms |
|
|
256
223
|
| Hot lazy re-index (single file) | 10k files | p50 5.9 ms / max 13.5 ms |
|
|
257
224
|
|
|
258
|
-
>
|
|
225
|
+
> Generated code (~4–5 symbols/file), measured 2026-09-25. Reproduce with `npm run bench:synthetic -- 5000` (`scripts/bench-synthetic.mjs`). Pure indexing overhead, no LLM calls. The first query after a write rebuilds the IDF cache (**142 ms at 40k entries**, 67 ms at 20k, 14 ms at 4k); later queries hit it.
|
|
259
226
|
|
|
260
227
|
### Reproduce it on your own project
|
|
261
228
|
|
|
262
|
-
|
|
229
|
+
The measurement ships with the repository **and with the published npm package** (`scripts/` is part of the tarball). It needs **no dsh instance, no network and no model calls**, and never touches your project's own store — results go to a temp directory and are removed afterwards:
|
|
263
230
|
|
|
264
231
|
```bash
|
|
265
232
|
npm run bench -- /path/to/your/project
|
|
@@ -267,7 +234,7 @@ npm run bench -- /path/to/your/project
|
|
|
267
234
|
node scripts/bench.mjs /path/to/your/project [--json] [--samples 100] [--no-pdf] [--keep]
|
|
268
235
|
```
|
|
269
236
|
|
|
270
|
-
It reports the cold index split into read+hash / extract / commit, cold load, IDF rebuild, cold and hot query latency (p50/p95/max over 100 sampled queries through the shipped scorer), single-file hot re-index, store
|
|
237
|
+
It reports the cold index split into read+hash / extract / commit, cold load, IDF rebuild, cold and hot query latency (p50/p95/max over 100 sampled queries through the shipped scorer), single-file hot re-index, store size, resident heap and bytes per entry. Example — the Vue app row above:
|
|
271
238
|
|
|
272
239
|
```
|
|
273
240
|
cold index 283 ms (read+hash 11 ms · extract 256 ms · commit 14 ms) ← 2nd, warm-cache run
|
|
@@ -281,15 +248,15 @@ Pass `--queries your-queries.json` to run the labeled-set method (hit@5 / hit@10
|
|
|
281
248
|
|
|
282
249
|
## Design tradeoffs
|
|
283
250
|
|
|
284
|
-
- **Synchronous lock-free transactions over async locks** —
|
|
285
|
-
- **Watch: compute outside, commit inside** — no lock is held during parsing and
|
|
286
|
-
- **Corrupt shards are quarantined, not repaired** — a shard that fails to parse is renamed
|
|
287
|
-
- **No vector embeddings, no semantic search at query time** —
|
|
288
|
-
- **Indexing is deterministic and model-free** —
|
|
289
|
-
- **Model-facing memory: the agent writes, no human in the loop** —
|
|
290
|
-
- **Full entries returned directly** —
|
|
291
|
-
- **`forget` by query is aggressive; use IDs for precision** —
|
|
292
|
-
- **TypeScript enhancement is optional, lazy
|
|
251
|
+
- **Synchronous lock-free transactions over async locks** — DSH runs single-process by architecture, so locking for a rare multi-process case would only slow the hot path (every `remember` / `forget` / `index_doc`).
|
|
252
|
+
- **Watch: compute outside, commit inside** — no lock is held during parsing, and polling with mtime + content hash is used instead of `fs.watch`: it behaves identically on network drives, Docker volumes and WSL, without duplicate-trigger or missed-event failure modes.
|
|
253
|
+
- **Corrupt shards are quarantined, not repaired** — a shard that fails to parse is renamed and only that file is re-indexed, so there is no WAL or embedded database adding native dependencies, lock contention and failure modes of their own.
|
|
254
|
+
- **No vector embeddings, no semantic search at query time** — lexical retrieval already answers the queries this plugin targets. On a real Vue project with 29 labelled queries, file-level hit@5 is **96.6%**, and whole-chunk terms lift document term coverage from **27.3% to 100%** with MRR unchanged (**0.958** vs **0.955**). The method ships with the code (`scripts/bench.mjs --queries your-queries.json`).
|
|
255
|
+
- **Indexing is deterministic and model-free** — a model at index time would make two indexings of one document differ, and a wrong translation at query time means zero recall; rules plus symbol links cover the common cases and work offline.
|
|
256
|
+
- **Model-facing memory: the agent writes, no human in the loop** — the consumer is the agent, usually headless, so memory that only promotes when someone clicks a card would never promote at all. `draft` is a provenance marker plus an evidence threshold, not an approval queue.
|
|
257
|
+
- **Full entries returned directly** — entries are already compact, so returning them whole is more verifiable and one round-trip cheaper.
|
|
258
|
+
- **`forget` by query is aggressive; use IDs for precision** — experience notes are low-risk, high-volume and retrieval-only, so stale noise hurts more than an over-broad delete. For exact deletion use the ID shown by `query_memory`.
|
|
259
|
+
- **TypeScript enhancement is optional, lazy and cached** — it runs in the background, never blocks indexing, and falls back to the regex scanner; its queue is bounded, and any dropped files are reported. The **default lib is not loaded**: inference that depends on global types (`Promise`/`Array`/DOM) degrades to `any`/`unknown`, while explicit annotations are unaffected.
|
|
293
260
|
- **Subagent sessions are out of scope for now**
|
|
294
261
|
|
|
295
262
|
## Development (for contributors)
|
|
@@ -298,11 +265,13 @@ These commands are for **maintaining the plugin code** — regular users do not
|
|
|
298
265
|
|
|
299
266
|
```bash
|
|
300
267
|
npm install
|
|
301
|
-
npm test #
|
|
268
|
+
npm test # 592 tests
|
|
302
269
|
npm run eval:injection # scenario P/R on the synthetic pool: 14/14 hits, 0 false positives, control group clean
|
|
303
270
|
npm run eval:injection -- --store .dsh-project-memory/insights.json # replay on YOUR store; control group is a hard gate
|
|
304
271
|
npm run selfcheck:triggers # which entries can still push, which declarations are dead (reads your local store)
|
|
305
272
|
npm run bench -- /path/to/project # index/query performance on any project — no dsh needed
|
|
273
|
+
npm run bench:peak # peak-RSS budget of maxFileSizeMb, measured on a 1–50 MB ladder
|
|
274
|
+
npm run schema:size # per-tool fixed prompt cost: chars and a same-scale token estimate
|
|
306
275
|
```
|
|
307
276
|
|
|
308
277
|
Release notes live in [`CHANGELOG.md`](CHANGELOG.md) and on [GitHub Releases](https://github.com/00080000/dsh-project-memory/releases).
|
|
@@ -311,4 +280,4 @@ Release notes live in [`CHANGELOG.md`](CHANGELOG.md) and on [GitHub Releases](ht
|
|
|
311
280
|
|
|
312
281
|
MIT — see [`LICENSE`](LICENSE).
|
|
313
282
|
|
|
314
|
-
Copyright (c) 2026 00080000 <3388065969@qq.com>
|
|
283
|
+
Copyright (c) 2026 00080000 <3388065969@qq.com>
|