@yolk_vat-y/dsh-project-memory 0.6.2 → 0.6.4
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 +178 -7
- package/README.md +26 -23
- package/README.zh-CN.md +24 -21
- package/client/client.js +432 -248
- package/client/client.js.map +1 -1
- package/package.json +3 -2
- package/scripts/bench-synthetic.mjs +22 -11
- package/src/audit.js +36 -32
- package/src/auto-inject.js +44 -23
- package/src/client/MemoryView.tsx +72 -4
- package/src/client/ShowTaskPanelNode.tsx +8 -5
- package/src/client/TaskCommandNode.tsx +23 -17
- package/src/client/TaskComponents.tsx +18 -3
- package/src/client/TaskPanel.tsx +60 -89
- package/src/client/client.ts +26 -6
- package/src/client/commands.ts +67 -0
- package/src/client/task-data-store.ts +33 -14
- package/src/client/task-scope.js +32 -0
- package/src/client/task-ui-store.ts +15 -2
- package/src/commands/insight-actions.js +5 -1
- package/src/commands/task-actions.js +59 -4
- package/src/commands/tasks.js +5 -2
- package/src/index.js +12 -0
- package/src/insight-store.js +286 -84
- package/src/lazy.js +3 -1
- package/src/ops.js +14 -3
- package/src/readiness.js +1 -1
- package/src/recall.js +76 -30
- package/src/setup/taskbridge.js +34 -3
- package/src/store.js +329 -46
- package/src/tools/forget.js +31 -8
- package/src/tools/index-doc.js +3 -5
- package/src/tools/index-repo.js +10 -11
- package/src/tools/lesson-tools.js +25 -35
- package/src/tools/query-memory.js +87 -29
- package/src/tools/remember.js +14 -11
- package/src/tools/stats.js +31 -4
- package/src/tools/task-tools.js +11 -12
- package/src/tools/watch-repo.js +3 -5
- package/src/types.js +9 -4
- package/src/util/fs.js +128 -1
- package/src/util/search.js +6 -27
- package/src/vector-index.js +175 -22
- package/src/watch.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,174 @@
|
|
|
1
|
+
## 0.6.4 (2026-10-23)
|
|
2
|
+
|
|
3
|
+
**0.6.3 之后的收口**:11 个提交全部是修复与内部整理,没有新增工具、没有删除配置项。用户能感觉到的变化集中在三处——语料开始跟随 `.gitignore`、几个"设成 0 本该关闭"的旋钮真的关闭了、面板里改一步不再整份回写。**升级前请读第一条与「向量层」那条**。
|
|
4
|
+
|
|
5
|
+
### 修改:索引语料改走 git 清单,`.gitignore` 与嵌套规则生效
|
|
6
|
+
|
|
7
|
+
**问题**:`walkDir` 是纯文件系统遍历,`.gitignore` 里写着的构建产物、内部文档、私有笔记一律进语料——用户 `index_repo` 之后才发现"这东西不该被记住"。
|
|
8
|
+
|
|
9
|
+
**改法**:
|
|
10
|
+
|
|
11
|
+
- 新增 `listProjectFiles()`:git 工作树走 `git ls-files -z --cached --others --exclude-standard`(已跟踪文件 + 未被忽略的未跟踪文件),嵌套 `.gitignore` 一并生效;非 git 目录回退 `walkDir`(忽略规则不生效,与旧版一致);之后再叠 `DEFAULT_IGNORE` 段名与 `maxScanFiles` / `maxScanDepth` 上限。
|
|
12
|
+
- 子模块只以 gitlink 出现,`statSync().isFile()` 为假直接丢弃;已删除但未暂存的路径也不会因此复活。
|
|
13
|
+
- 「读到即索引」对单个文件用 `git check-ignore -q` 判一次;显式 `index_doc` 不受此限。
|
|
14
|
+
- 扫描被截断(`capped`)时照旧**不清理**未见文件:没扫到 ≠ 被删了。
|
|
15
|
+
|
|
16
|
+
**升级注意**:老 store 里以前从被忽略路径索引进来的文件、以及子模块里的内容,会在升级后第一次**完整**索引时计入 `removed` 并删掉——那是派生索引,把文件重新纳入跟踪或显式 `index_doc` 即可重建。`index_repo` 的报告措辞也从 `code symbols updated` 改为 `code files updated`。
|
|
17
|
+
|
|
18
|
+
### 修复:两个进程同时写同一份 store 会互相覆盖
|
|
19
|
+
|
|
20
|
+
**问题**:`save()` 的"读—改—写"没有跨进程保护,后写的一方整段覆盖先写的一方:`insights.json` / `tasks.json` / `binding.json` 的改动直接丢。分片撞车时旧实现还会"跳过写入但内存以为写了",进程内与磁盘长期分叉。
|
|
21
|
+
|
|
22
|
+
**改法**:
|
|
23
|
+
|
|
24
|
+
- `acquireDirLock()`:在 store 目录下用 `openSync('wx')` 原子建 `.write.lock` 并写入 pid;2 秒内每 10 ms 重试一次,锁文件 mtime 超过 10 秒判为 stale 直接删;拿不到锁就**保留脏状态**、100 ms 间隔最多再试 3 次,只警告一次,而不是让工具调用失败。
|
|
25
|
+
- 锁内先 `_mergeAuxFromDisk()`:`insights` / `tasks` / `binding` / watchlist 按 `updatedAt`(任务用 `updatedAt || lastActiveAt`)取较新的一侧,平局取本地;本地删除用墓碑集合防复活;watchlist 取并集减墓碑。
|
|
26
|
+
- 分片冲突以"加载时 sha"为基线:磁盘 sha 既不是基线也不是本次写入 → 按 `indexedAt` 收敛(本地更新则覆盖,磁盘更新则读回内存),并只提示一次。
|
|
27
|
+
- 缓存逐出前先 `hasDirty()` 再 `save()`:延迟落盘之后,LRU 逐出不能把还没 flush 的任务热点直接扔掉。
|
|
28
|
+
|
|
29
|
+
**代价**:重试耗尽、或进程在 flush 前退出,仍可能丢掉这一回合尚未落盘的热点计数(正文写入同样依赖这次 flush)。
|
|
30
|
+
|
|
31
|
+
### 修复:经验层与洞察层各用一套打分器,`save_lesson` 写出的条目恒 0 分
|
|
32
|
+
|
|
33
|
+
**问题**:`save_lesson` 写出的 experience 条目没有 `problem` / `solution`,而旧 `rankExperienceScored` 拼给 BM25 的文档是三个字面量 `undefined` → 该条目**恒 0 分**;洞察桶又按 kind 排除了 experience,于是两条召回路径同时断掉:条目在库里,查不到,`query_memory` 还会印出 `Problem: undefined`。同一处还有两个连带问题:只给 `pattern` 的 lesson,`vectorText` 只认 title/problem/body,空串让 `vectorNear` 返回 null,0.9 自动覆盖与 0.7 近邻提示整体失效;只给 `choice` 的 decision,标题落成 `(untitled)`。影子审计里 `rel` 的分子是 BM25 分、分母却是融合 top,实测能到 5.925。
|
|
34
|
+
|
|
35
|
+
**改法**:经验层改用洞察层同一个 `insightToEntry` + `rankEntriesMergedScored`,命中后用 `byId` 换回原条目,`rankExperience(Scored)` 删除;`normalizeInsight` 的标题链补 `choice`;`vectorText` 用同一条链(title → pattern → problem → choice → topic → body)并截 200 字符;影子记录新增 `lexTop`,`rel = 词法分 / lexTop`,真实排序判据仍用融合分;渲染侧 problem→title、solution→fix→choice→body 兜底。
|
|
36
|
+
|
|
37
|
+
**影响**:experience 恢复可召回(短语加分、同义词展开都生效),不再输出 `undefined`。影子 `rel` 从"可以大于 1"变成"≤ 1"——按旧刻度做过的离线重放需要重标定。
|
|
38
|
+
|
|
39
|
+
### 修复:相关性闸门被整条关掉;缺向量分的条目按本轮均值补
|
|
40
|
+
|
|
41
|
+
**问题**:`matchedFloor` 的旧签名带 `hasVector`,只要 `Boolean(rerank)` 为真就整条通道不再筛。于是"装了 `leanvec` 但本轮给不出余弦"(查询编码失败、`embed` 抛异常、返回空 Map)时,单片段就 3.13 分的那种弱命中全漏进来——注释承诺的"逐字段退回纯词法"从来没成立过。另一头,缺向量分的条目按 `score = rel` 排序,等价于隐式补了一个 `α·0.5`;真实 store 里 7381 对余弦的中位数只有 0.28,查询→标题的 top-1 多在 0.51–0.63,于是"低余弦"条目反而被"完全没有向量"的压住。
|
|
42
|
+
|
|
43
|
+
**改法**:`matchedFloor(scored, queries)` 去掉 `hasVector`,改判 `typeof r.vector === 'number' || (r.matched ?? 0) >= need`(`need = min(2, 查询词数)`);顺序改为 融合 → 逐条闸门 → 截断 `limit`,经验层与洞察层同序;一条余弦都没有时 `fuseVectorHits` 原样返回未归一化的 `scored`,闸门对全体生效;缺分按 `neutral = 本轮已有余弦的均值` 补:`score = (1-α)·rel + α·(v ?? neutral)`。
|
|
44
|
+
|
|
45
|
+
**影响**:向量层开着但部分条目无分时,这两层单轮可能**少于** `limit` 条(旧行为是整条通道不筛);全量编码失败时与纯词法逐字段一致;低余弦条目不再被无分条目反超。
|
|
46
|
+
|
|
47
|
+
### 修复:`vectorAlpha: 0` 连带关掉写入去重,`autoMergeCos` / `hintCos: 0` 的语义反了
|
|
48
|
+
|
|
49
|
+
**问题**(四个都是"以为自己关了、其实全开或全关"):
|
|
50
|
+
|
|
51
|
+
- `forget` 只删条目,`vectors.json` 里那行 256 维均值池化还在——"真删"名不副实,下个进程还会把它复用回来。
|
|
52
|
+
- 写入侧的去重复用了召回侧的重排器,而后者 `alpha === 0` 直接返回 null:`vectorAlpha: 0`(只想关重排)会静默停掉 0.9 自动覆盖与 0.7 近邻提示。
|
|
53
|
+
- `autoMergeCos: 0` / `hintCos: 0` 在旧代码里是 `top1 >= 0` 恒真:设 0 等于"每条写入都覆盖最近一条 / 每次都给提示",而设 0 恰恰是关闭它最自然的写法。
|
|
54
|
+
- `vectorDir` 拼错和"没装 `leanvec`"在输出上毫无区别。
|
|
55
|
+
|
|
56
|
+
**改法**:
|
|
57
|
+
|
|
58
|
+
- 新增 `autoContext.vectorDedup`(默认 `true`),写入侧去重与 `vectorAlpha` 解耦;`createVectorCosine` 独立于 alpha。
|
|
59
|
+
- `autoMergeCos` / `hintCos` 设 0 现在是**关闭**(`!(cos > 0) → null`)。
|
|
60
|
+
- `forget` 同步清向量行:内存索引同时删 `usable` 快照与 `entryMap`(只删后者会被下次打分复活),磁盘 `vectors.json` 按 stride 重写;不加载模型,异常吞掉。
|
|
61
|
+
- `memory_stats` 多两行:向量层状态(`off` / `re-rank alpha` / `write-dedup`)与索引统计(rows / live / stale / KB / model / updated),`vectorDir` 配错不再静默。
|
|
62
|
+
- 新增实验性 `vectorItemMin` / `vectorSpeakMin`(绝对余弦闸门,不设即关,未标定)。
|
|
63
|
+
|
|
64
|
+
**影响**:`vectorAlpha: 0` 只关重排,写入去重默认仍开(会加载模型);`forget` 之后 `vectors.json` 会缩行、条目不再复活。`vectors.json` 格式未变(version 1 + ids / hashes / blob)。
|
|
65
|
+
|
|
66
|
+
### 修复:自动覆盖的绝对阈值在密集语料里会改错条目
|
|
67
|
+
|
|
68
|
+
**问题**:0.9 只对"当前语料 + 当前模型"成立。语料一模板化(大量同句式条目),池内最近邻余弦整体抬到 0.9 附近,0.9 就会去覆盖**不同**的知识;换模型、换向量表也会整体平移尺度。而自动覆盖是破坏性写入——直接改写既有条目正文,误合并等于静默丢数据。
|
|
69
|
+
|
|
70
|
+
**改法**:`vectorNear` 顺路累计有限余弦的 n / Σv / Σv²,返回 `mu` / `sigma` / `n`;μ 与 σ **排除候选自己**(`restN = n - 1`、`restSum = sum - top1`、`restSumSq = sumSq - top1²`,`restN > 1` 才算总体标准差);`autoMergeTarget` 的门槛改成 `floor = max(autoMergeCos, mu + 3σ)`,仍要求 `top1 - top2 >= autoMergeMargin`。`AUTO_MERGE_SIGMA = 3`:池 ≤300 时随机撞上的最大余弦约在 μ+2.9σ。只收紧不放宽——真实 store(122 条 / 7381 对)mean 0.281、sd 0.104 → μ+3σ ≈ 0.59 < 0.9,行为不变。
|
|
71
|
+
|
|
72
|
+
**影响**:密集语料里 0.92 不再自动覆盖(宁可多存一条,不改错一条);稀疏与中等密度池逐字段不变,`hintCos` 的 0.7 提示带不受影响。
|
|
73
|
+
|
|
74
|
+
### 修复:`query_memory` 的分节按固定顺序,最相关的常常落在最后
|
|
75
|
+
|
|
76
|
+
**问题**:结果按写死的分节顺序拼(Memory → Insights → Experience),分节内部有排序、分节之间没有。最相关的那条落在第三节时,被前面几节的弱结果挤到 4k 字符之后——分数明明是它最高。
|
|
77
|
+
|
|
78
|
+
**改法**:每个分节取一个 `bestHint`(最佳条目的 `rel × 层先验`:insight 1.15、doc/symbol 1.0、experience 0.9,与 `recallItems` 的 `flat.hint` 同口径),按它降序排段后再拼输出;稳定排序,同分保原序。只决定段落先后,不参与打分、不改任何条目自己的 `score`。
|
|
79
|
+
|
|
80
|
+
**影响**:同一查询的输出分节顺序会变(doc-only 查询仍 Memory 在前);条目分数、数量与 token 总量不变。
|
|
81
|
+
|
|
82
|
+
### 修复:符号的一行声明落盘了却不参与检索
|
|
83
|
+
|
|
84
|
+
**问题**:符号条目存了 `text`(签名 / 重载 / 类型体),但 `weightedFieldText` 只拼 title、keywords、summary、terms——于是"哪些函数收 union 类型""谁返回 `Promise<void>`"这类只能从签名回答的问题,检索侧完全看不到。顺带修掉 `query_memory` 里符号标题缺失时输出的 `- undefined`。
|
|
85
|
+
|
|
86
|
+
**改法**:`weightedFieldText` 并入 `entry.text`(只落盘不检索等于白存);渲染侧用 `text || title` 兜底。符号仍是每个一行、不新增字段,落盘体积不变;标题仍保留 5 倍权重,名字命中不会被签名盖过。
|
|
87
|
+
|
|
88
|
+
**影响**:带参数、返回类型或类型体的查询能命中符号;`query_memory` 的符号段会显示一行声明。
|
|
89
|
+
|
|
90
|
+
### 修改:工具 schema 压到约 5.4k 字符,并加了预算守卫
|
|
91
|
+
|
|
92
|
+
**问题**:工具描述与参数 schema 每次请求都要随上下文带上,是固定成本;0.6.x 期间它逐条膨胀到约 9100 字符。
|
|
93
|
+
|
|
94
|
+
**改法**:12 个工具的描述收敛成一句、参数说明去掉重复语义(`enum` / `required` 保留),`index_repo` / `query_memory` / `save_lesson` 等逐个重写;新增 `test/tool-schema-size.test.mjs`,把"描述 + 参数 schema"的总长钉在 5600 字符以内(当前 **5367** 字符 / 12 个工具,含工具名约 5493)。
|
|
95
|
+
|
|
96
|
+
**影响**:每轮固定开销降约 43%;工具行为与参数契约不变。
|
|
97
|
+
|
|
98
|
+
### 整理:审计写入器归一、global store 单例、`steps` 纳入密钥检测
|
|
99
|
+
|
|
100
|
+
- 影子审计与主审计共用一份配置归一(`cfgSideLog()`:默认开、只认显式 `false`、非法上限退回默认值)与一个写入器;两者只剩文件名与默认上限不同(审计 256 KB、影子 512 KB,各留一代 `.1`)。日志名、字段、轮转行为全不变。
|
|
101
|
+
- `GlobalStore` 按文件路径复用实例(与 project store 的 `storeCache` 同语义):两个工具 / 会话交错读写同一份 `global.json`,不再后写覆盖先写。
|
|
102
|
+
- 向量缓存的键加上模型指纹;taskbridge 的会话 Map 改成有界并在 `disposed` 时清理。
|
|
103
|
+
- `remember` 的 `source_file` 走 `normalizeCitationFiles()`:项目外的路径丢弃并回报,不再把任意绝对路径写进记忆。
|
|
104
|
+
- `containsSecretFields` 的默认字段加上 `steps`:流程类条目此前只查前八个字段,`steps` 数组里的密钥 / token 形态逃过检测。
|
|
105
|
+
- `index_repo` 透传 `allowUnsafe`,与其它工具对排除名单的处理保持一致。
|
|
106
|
+
|
|
107
|
+
### 修复:面板改一步要回写整份 steps;草稿会污染 project/global;切页把命令写进会话
|
|
108
|
+
|
|
109
|
+
**问题**(这一批的症状都在"看不见的写放大"上):
|
|
110
|
+
|
|
111
|
+
- 改一步状态就 `todos` 回写整份 `steps`:两个动作并发时互相覆盖,步数一多还带上整个数组。
|
|
112
|
+
- 反思草稿(`draft` / `source: reflect`)参与 project/global 的自动合并与自动提升——LLM 草稿能改写手写知识。
|
|
113
|
+
- 每切一次记忆页就发 `/tasks insight list`,会话里堆一串命令节点,历史被这些噪声占满。
|
|
114
|
+
- 文件工具每次调用写一次 `tasks.json`;拖动每 `mousemove` 写一次 localStorage,小窗口下卡片还能被拖出视口;"编辑中"的行不进去重指纹,写文件后模型一直看到旧的文件列表。
|
|
115
|
+
- 归档后 `binding.json` 仍指着那个任务;`_pruneBindings` 遇到畸形 JSON 直接抛错。
|
|
116
|
+
|
|
117
|
+
**改法**:
|
|
118
|
+
|
|
119
|
+
- 新增三个原子子命令 `/tasks step <i> <status>`、`/tasks step-text <i> <json>`、`/tasks step-move <from> <to>`(落点由服务端按拖拽语义算),RPC 收进 `src/client/commands.ts`(15 秒 AbortController、信封与错误归一);拖动只进本地 state,`mouseup` 才写 UI store,位置 clamp 在视口内;卡片头从 `button` 改成 `div[role=button]` 并补键盘处理。
|
|
120
|
+
- 草稿或 `source: reflect` 的条目跳过 project/global 合并与跨任务提升;跨任务池过滤 draft;显式编辑即转正(无变化也算确认)。
|
|
121
|
+
- 切页命中 30 秒缓存(键 `session|root|scope|boundTaskId`,换项目、换绑都会失效),列表型命令节点不再渲染;面板只在打开 / 切回任务页时补数据。
|
|
122
|
+
- 文件热点延迟落盘(`commit(..., { save: false })`),`turn/end` 与 `session/disposed` 统一 flush;缓存逐出前先落盘。
|
|
123
|
+
- 归档与 `load()` 时清理绑定;`_pruneBindings` 加形状防御。
|
|
124
|
+
|
|
125
|
+
**影响**:切页不再在对话里留行;换项目 / 换绑任务不串列表;`tasks.json` 写入频次明显下降。**已有草稿不再自动提升**,需要显式确认才进入 project/global。
|
|
126
|
+
|
|
127
|
+
### 整理:示例与文档里的专名中性化
|
|
128
|
+
|
|
129
|
+
README 双语与 CHANGELOG 里的具体框架名(`Vue`)、硬件与机器信息(`20 vCPU` / `本机` / 具体月份)、内部文件名(`PLAN-*` / `RELEASE-NOTES-*` / `de-TODO`)换成中性写法;测试夹具里的内部文件名改成 `notes.md` 这类占位。零运行时行为变化。
|
|
130
|
+
|
|
131
|
+
**测试**:`npm test` 720 → **756 项 / 44 个文件**(新增 `gitignore-index` / `store-concurrent` / `tool-schema-size`;`insight-store`、`recall`、`recall-vector-fusion`、`vector-index`、`auto-inject`、`client-toolview`、`client-task-sync` 等在既有 `ok` 块内补断言);`npm run typecheck` 通过;`npm run build:client` 重建与提交产物零差异。
|
|
132
|
+
|
|
133
|
+
## 0.6.3 (2026-10-20)
|
|
134
|
+
|
|
135
|
+
### 新增:删除留痕——`forget` 仍真删,但最近 5 条可从 `deleted.json` 找回
|
|
136
|
+
|
|
137
|
+
**问题**:删除是**不可逆**的,而 `forget` 的关键词通道是模糊匹配——判据本身没错(查询侧覆盖率是旧经验层的既定口径),但一次传错词就是一次没有痕迹的永久删除:实测 `forget 'x'` 一次删掉 9 条 global 记忆(真实事故,9 条已按原 id + 原始 `save_lesson` 参数从会话日志恢复)。
|
|
138
|
+
|
|
139
|
+
**改法**(保持"真删、无撤销"语义不变,只补可恢复性):
|
|
140
|
+
|
|
141
|
+
- `removeMemory` 在真正移除前,把**即将被删的完整条目**(正文、字段、`home`,task 级带 `taskId`)追加进该层 store 同目录的 `deleted.json`:项目 / 任务级落 `<root>/.dsh-project-memory/`,global 级落 global 文件同目录。滚动保留最近 **5** 条(`DELETED_KEEP`),最新在前。
|
|
142
|
+
- 留痕是**旁路**:写失败只丢留痕,绝不让删除本身失败;`recordDeleted()` 同样供面板的 `/tasks insight delete` 三个分支复用(面板删的也能找回)。
|
|
143
|
+
- `forget` 的删除回报末尾直接给出留痕文件的**真实路径**(描述里静态说不清项目目录在哪,路径随 `memoryDir`/会话根变化),并说明"读它、重新存一次即可恢复"。**不新增命令**:模型/人自己去读那个文件。
|
|
144
|
+
- 代价:盘上多一份最多 5 条正文的副本。不需要恢复能力的可以删文件,删了下一次删除会重新建。
|
|
145
|
+
|
|
146
|
+
### 修复:读路径传错 `root` 会在别处造出目录和空 store
|
|
147
|
+
|
|
148
|
+
`query_memory` / `memory_stats` 此前只做安全校验、不验根存在。可选的向量层(`leanvec`)在空 store 上会落 `vectors.json`,于是**拼写错误的 root 会在任意可写位置建出 `<root>/.dsh-project-memory`**,回报却是 "No memory matches"——看起来像"这个项目没有记忆"。两处补 `assertIndexRoot`(与 `index_repo` / `watch_repo` / `forget` / `save_lesson` / 任务工具同一道护栏),并加跨工具回归:不存在根一律拒绝且**不产生任何目录**。
|
|
149
|
+
|
|
150
|
+
### 修复:容量裁剪会归档"仍被会话绑定"的任务,把一次会话拆成两条记录
|
|
151
|
+
|
|
152
|
+
`pruneTasks()` 按 `lastActiveAt` 一刀切,一个长期挂着的绑定任务会被更新的任务挤成最旧而静默归档;会话回来写 todo 时 taskbridge 按"归档=停止同步"处理,于是**另建一条新任务**——同一会话的历史被静默拆开,原条目成归档孤儿。裁剪现在跳过仍被任何会话绑定的任务(加起来的历史更值钱:上限只是启发式,而"别把正在做的任务从脚底下抽走"是正确性)。想真正停掉一个任务,先解绑或显式归档。
|
|
153
|
+
|
|
154
|
+
### 修复:跨标签页任务广播不区分项目
|
|
155
|
+
|
|
156
|
+
`BroadcastChannel` 名是固定的(同源所有 dsh 页面共用),消息体只带任务数组:在 A 项目点一下刷新,B 项目的面板就被贴上 A 的任务列表(而它保留自己的 `boundTaskId`,表现为"绑定莫名丢了")。`/tasks` 载荷新增 `root`,广播按项目根作用域过滤(无根或本页未知根一律不接受),判定收进零依赖纯函数模块 `src/client/task-scope.js` 以便单测。
|
|
157
|
+
|
|
158
|
+
### 修复:打开/切换面板会往会话历史里写 `todo/write`
|
|
159
|
+
|
|
160
|
+
面板 `refresh()` 在"新 boundId 与内存里的不同"时会补一次 `/tasks switch`。那是多余的:宿主 todo 清单是 `sessionProjections` 的 `todos` 单元(由 `todo/write` 折叠),重启/换标签页都会从日志重建;而 switch 会 `session.append('todo/write')`,等于"看一眼面板"就写一次会话历史、顺带刷新任务的 `lastActiveAt`。绑定动作都有明确入口(`select_task` / `/tasks switch` / 面板按钮),各自由 `adoptStepsToSession` 推清单,不需要巡检式补写。
|
|
161
|
+
|
|
162
|
+
### 新增:测试保真闸门——测试必须跑在 lockfile 声明的宿主版本上
|
|
163
|
+
|
|
164
|
+
0.6.2 声明 devDependencies 升到 `0.2.1-rc.2`,但 `node_modules` 里仍是 `0.2.0-rc.2`(且 `cordis` 4.0.4 不满足四个 client 包的 `~4.0.5` peer)——当时的"全绿"与"已适配新宿主"都建立在不匹配的依赖上。`host-contract` 新增可判定检查:每个 `@deepseek-ai/*` devDependency 的**实际安装版本必须等于 lockfile 版本**(不等则报"先跑 npm ci"并列出差异),并校验 client 包对 `cordis` 的 peer 区间被实际安装版本满足。
|
|
165
|
+
|
|
166
|
+
### 修复:`2>/dev/null`、`2>&1` 被当成"写目标",让读命令误触发 `when.writes`
|
|
167
|
+
|
|
168
|
+
`ops.js` 的写盘判据里,重定向一支是 `>>?\s*\S`——它把**丢弃输出**也算成写文件。实测 `ls .agents 2>/dev/null | head` 抽出 `targets=['.agents']`、`cat package.json 2>&1` 抽出 `['package.json']`,而 `ops.targets` 正是 `when.writes` 的匹配面:列目录 / 看文件会误触发一条 `writes:['package.json']` 的教训。现在 `>` / `>>` / `2>` 之后是 `&`(合并 fd)或 `/dev/null`(丢弃)时不算写,`> file`、`2> file`、`1>> file` 照旧算。
|
|
169
|
+
|
|
170
|
+
**测试**:`npm test` 705 → **720 项 / 41 个文件**(新增 `client-task-sync`;`insight-store` +1、`host-contract` +1、`taskbridge` +1、`root-guards` +8,其余在既有 `ok` 块内补断言),`npm run typecheck` 通过。
|
|
171
|
+
|
|
1
172
|
## 0.6.2 (2026-10-17)
|
|
2
173
|
|
|
3
174
|
`npm test` **705 项 / 40 个文件**;`npm run typecheck` 通过。
|
|
@@ -140,13 +311,13 @@
|
|
|
140
311
|
|
|
141
312
|
- 同一个进程里再 load 第二个大 root 时仍会结算一次——那正是预算可能被撞上的情形。`bench --json` 现在把两个口径分开:`coldLoadMs` 只记空进程冷启动,`secondStoreLoadMs` 记同进程第二个 store;合成基准的冷加载也改成独立进程量(同进程连 load 5 份副本会攒下 5 个 store,既绕不开结算也不是"冷启动")。
|
|
142
313
|
- `test/store-cache.test.mjs` 34 → **43** 项:新增"预算宽裕时不精确计量(无版本戳)""上界 ≥ 精确值且不超 8 倍""写进来的条目计入上界""同一文件重写是替换而非累加"。
|
|
143
|
-
- README
|
|
314
|
+
- README 双语的性能表按新口径重测(冷加载:前端语料 8 ms、文档工作区 10 ms、3k 切片 70 ms、整棵树 278 ms)。
|
|
144
315
|
|
|
145
316
|
### 测试与修复
|
|
146
317
|
|
|
147
318
|
- 新增 **5 个自然语言对照**与 **3 个 hint-only 场景**(提示通道召回 0/3、精度 1.00,只报告不设门);其中 1 条对照在基线上就注入一条无关经验,属**已知缺陷并钉住上界**。
|
|
148
319
|
- 新增 `test/recall-vector-fusion.test.mjs`(13 项)与 `test/vector-index.test.mjs`(10 项),都不需要 leanvec。
|
|
149
|
-
- `test/run-test.mjs`
|
|
320
|
+
- `test/run-test.mjs` 读真实的全局 insight store,导致 `no-hit query shows store overview` 随经验条数变红(乱码查询被 `no` 片段命中)。现在 globalFile 指向临时文件,测试**密闭**。
|
|
150
321
|
|
|
151
322
|
## 0.5.16 (2026-10-11)
|
|
152
323
|
|
|
@@ -409,7 +580,7 @@ id 前缀规则 `replace(/[\\/:\s]/g, '_')` 曾在**三处各写一份**(`doc-
|
|
|
409
580
|
- 结论:**旧的 50 MB 允许单个文件把宿主进程推到 ~1.2 GB RSS**(还有一次最长 12.5 s 的同步解析),
|
|
410
581
|
这正是 issue #5 那类 OOM 的形状。原先文档与计划里写的「峰值是它的 2–4 倍」**低了 5 倍**。
|
|
411
582
|
- 默认值改为 **10 MB**:最坏情况单文件增量 ≈ **+300 MB RSS**(20.6 × 10)。误伤面实测很小 ——
|
|
412
|
-
|
|
583
|
+
实测多个真实项目里只有 1 个文件超过 10 MB(一个 28.7 MB 的生成物,
|
|
413
584
|
也正是最该跳过的那类:生成的、符号密集、索引收益低而内存最贵)。旋钮仍可调高,
|
|
414
585
|
双语 README 的配置表与「单文件内存预算」一节都写明了各自系数。
|
|
415
586
|
- 口径提醒:heap 峰值受 GC 时序影响会**非单调**(同一档符号密集语料,32 MB 量出 625 MB、
|
|
@@ -1122,7 +1293,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
|
|
|
1122
1293
|
- 索引逻辑收敛为 `src/index-pipeline.js`;auto-inject 会话状态收敛为 `InjectionSessions`
|
|
1123
1294
|
- 命令处理器共用 `invocationContext` / `fencedJson`
|
|
1124
1295
|
|
|
1125
|
-
|
|
1296
|
+
未修的低优先级发现见当期的发布笔记。
|
|
1126
1297
|
|
|
1127
1298
|
## 0.5.6 (2026-09-16) — injection admission (lessons/decisions/procedures stop arriving by coincidence)
|
|
1128
1299
|
|
|
@@ -1178,7 +1349,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
|
|
|
1178
1349
|
- **The READMEs now point at it** (`Performance → Reproduce it on your own project`, plus the Development block) instead of asking readers to trust the tables. The labeled-set figures in Design tradeoff #4 are scoped to their internal corpus, with the method shipped; the docs also state the two caveats found while building it — `read+hash` is OS-page-cache sensitive, and real projects score slower than the synthetic corpus.
|
|
1179
1350
|
- **Retired the local-only harnesses it replaces** (`test/ablation*.mjs`, `test/doc-coverage*.mjs`, `test/gen-queries.mjs`, `test/simulate-agent.mjs`, `test/queries.json`) together with the dead `.gitignore` entries for them and for the August debug scaffolding.
|
|
1180
1351
|
- **The synthetic harness ships too.** `bench/microbench.mjs` moved to `scripts/bench-synthetic.mjs` (`npm run bench:synthetic -- 5000`), so the synthetic table is reproducible as well; `bench/` itself stays local-only.
|
|
1181
|
-
- **Every published number re-measured on 2026-09-14** (Node 24.19
|
|
1352
|
+
- **Every published number re-measured on 2026-09-14** (Node 24.19): 5k-file cold index 269 ms avg (p50 267), cold load 40 ms, cached query over 20k entries p50 2.6 / p95 5.4 ms, hot single-file re-index p50 2.4 ms, 10k-file cold index 551 ms avg, cold load 90 ms, IDF rebuild 106 ms at 40k entries (57 ms at 20k, 12 ms at 4k), symbol scan 12.9–19.2 µs/file. Table captions now name the environment and the reproduce command; the real-project example quotes the warm-cache run and states the cold-cache first run (787 ms vs 253 ms) instead of hiding it. `README.md`, `README.zh-CN.md` and the local notes were updated together so no two documents quote different numbers.
|
|
1182
1353
|
|
|
1183
1354
|
### Docs (README realigned with shipped behaviour)
|
|
1184
1355
|
|
|
@@ -1304,7 +1475,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
|
|
|
1304
1475
|
|
|
1305
1476
|
### Changed (cold-index I/O)
|
|
1306
1477
|
|
|
1307
|
-
- **Single-read indexing — cold index ~4× faster**: every indexing path read each file twice (`await sha256OfFile()` for the hash, then `readFileSync()` for the body) and paid a per-file `async readFile` thread-pool round-trip. New `readFileForIndex()` does one synchronous read and hands the same buffer to both `createHash('sha256')` and `toString('utf8')`; `index_repo`, `watch`, and lazy read-on-observe all use it. Unchanged files are still hashed without decoding. Synthetic 5,000-file corpus (
|
|
1478
|
+
- **Single-read indexing — cold index ~4× faster**: every indexing path read each file twice (`await sha256OfFile()` for the hash, then `readFileSync()` for the body) and paid a per-file `async readFile` thread-pool round-trip. New `readFileForIndex()` does one synchronous read and hands the same buffer to both `createHash('sha256')` and `toString('utf8')`; `index_repo`, `watch`, and lazy read-on-observe all use it. Unchanged files are still hashed without decoding. Synthetic 5,000-file corpus (Node 24): cold index 1,093 ms → 272 ms (4.0×); the `read+hash` phase drops from 70% to 11% of the pipeline. Tests green.
|
|
1308
1479
|
|
|
1309
1480
|
### Fixed (host-contract + watch robustness)
|
|
1310
1481
|
|
|
@@ -1360,7 +1531,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
|
|
|
1360
1531
|
- Tests: insight-store 11 / reflection-pipeline 5 / auto-inject 9 / insight-actions 7 (total 209, exit 0)
|
|
1361
1532
|
|
|
1362
1533
|
### Notes
|
|
1363
|
-
- Design rationale, deviations (non-destructive migration; reflection triggers subset; auto-inject host verification) and the live-verification checklist live in
|
|
1534
|
+
- Design rationale, deviations (non-destructive migration; reflection triggers subset; auto-inject host verification) and the live-verification checklist live in the internal design notes.
|
|
1364
1535
|
- Requires a dsh web restart to load the new server code and rebuilt client bundle.
|
|
1365
1536
|
|
|
1366
1537
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-project-memory
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> If this plugin saves you an hour of debugging, a star would be appreciated.
|
|
4
4
|
|
|
5
5
|
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ A persistent **project development memory** for [DeepSeek Harness](https://githu
|
|
|
22
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
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
24
|
- **Hybrid recall** — ranked search over documents, symbols, experience notes and insights, with optional LLM query expansion. The experience/insight layers are re-ordered by cosine when `leanvec` is present — installed by default, absent ⇒ pure lexical. Tuned for CJK: phrase boost, a synonym table, and CJK-aware boundaries for doc↔symbol linking.
|
|
25
|
-
- **Experience notes** — problems → solutions, deduplicated by overlap rather than repeated, bounded by project size, and
|
|
25
|
+
- **Experience notes** — problems → solutions, deduplicated by overlap rather than repeated, bounded by project size, and surfaced both by search and by the same injection path as lessons.
|
|
26
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. That list is ordered newest-first and loaded incrementally: 30 entries at a time, with the next page prefetched before the reader reaches the bottom and off-screen rows skipped by the renderer, so a large memory stays responsive.
|
|
27
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.
|
|
28
28
|
|
|
@@ -48,10 +48,12 @@ Each indexed project has its own store at `<root>/.dsh-project-memory/`. It keep
|
|
|
48
48
|
|
|
49
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).
|
|
50
50
|
|
|
51
|
+
In a git work tree the corpus is whatever `git ls-files --cached --others --exclude-standard` lists — tracked files plus untracked files that are not ignored — so `.gitignore`, nested rules included, decides what gets remembered. A directory that is not a git work tree falls back to a plain walk (no ignore rules). Lazy indexing applies the same check per file; an explicit `index_doc` always indexes what you point it at.
|
|
52
|
+
|
|
51
53
|
| Tool | Purpose |
|
|
52
54
|
|---|---|
|
|
53
55
|
| `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,
|
|
56
|
+
| `index_repo root` | Index a whole project: documents get deterministic summaries, code files get a token-free symbol table. Incremental and self-healing: the store follows the file listing, so deleted, ignored or moved files are dropped, and documents are cross-linked to symbols. A non-existent or excluded root is rejected before anything is written. |
|
|
55
57
|
| `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
58
|
| `memory_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. |
|
|
57
59
|
| `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. |
|
|
@@ -59,9 +61,9 @@ The tools below are **invoked by the agent**, not typed by the user. In the chat
|
|
|
59
61
|
| `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. |
|
|
60
62
|
| `archive_task` | Archive a task (hide from default views, exclude from capacity, stop syncing). `select_task` restores it. |
|
|
61
63
|
| `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. |
|
|
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 [offset] [limit]` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` for memory. |
|
|
64
|
+
| `/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 …` / `step` / `step-move` / `step-text` for tasks, `insight list [scope] [offset] [limit]` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` for memory. |
|
|
63
65
|
| `remember problem solution` | Save an experience note. It is a `kind: 'experience'` insight — same store, same dedup and same delete path as lessons / decisions / procedures. Similar problems merge or overwrite instead of duplicating. |
|
|
64
|
-
| `forget id_or_query` | Delete memories — lessons / decisions / procedures and
|
|
66
|
+
| `forget id_or_query` | Delete memories — lessons / decisions / procedures and experience notes alike, across task / project / global in one call, without knowing which layer the entry lives in. An exact id deletes that one entry; keywords match by **query-side coverage** (matched query terms ÷ query terms). Real deletion, no undo; when keywords match more than the cap (default 10) it deletes nothing and only lists the candidates. The **5** most recently deleted entries are kept as full entries in that layer's `deleted.json` next to its store (`<root>/.dsh-project-memory/deleted.json` for the project layer, beside the global file for global), and the deletion result prints that path — read it and save again to recover a mis-delete. |
|
|
65
67
|
| `save_lesson` | Save a lesson / decision / procedure at task, project or global scope; passing `id` **overwrites that entry in place** (only the fields you pass, the previous values stay in `prev` — write them back with the same id). Before writing it compares against existing memory: cosine ≥ 0.9 auto-overwrites that entry, ≥ 0.7 reports the nearest id in the result; without `leanvec` it falls back to lexical overlap ≥ 0.7 merge / 0.65–0.7 reinforce. Two tasks hitting the same insight promote it task → project, three or more → global. Key params: `id`, `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). |
|
|
66
68
|
|
|
67
69
|
`/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.
|
|
@@ -72,12 +74,12 @@ The design follows four principles:
|
|
|
72
74
|
|
|
73
75
|
- **Volatility** — context is ephemeral; it is lost when a session is compacted.
|
|
74
76
|
- **Persistence** — the **memory** is stored on disk and survives compaction and new sessions.
|
|
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-10-13), not guarantees: a code-only
|
|
77
|
+
- **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-10-13), not guarantees: a code-only frontend app (289 files) lands at **325 bytes/entry ≈ 21% of source**, a symbol-dense TypeScript monorepo (12,634 files / 107 MB of code + 14 MB of docs) at **22% of source for the code layer (549 bytes/entry overall)** and **127% for the document layer**, and a document-heavy workspace (Markdown + PDFs) at **1,401 bytes/entry**.
|
|
76
78
|
- **Verifiability** — **recalls** carry a `path:line` citation where applicable, so the agent can confirm details against the source.
|
|
77
79
|
|
|
78
80
|
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.
|
|
79
81
|
|
|
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
|
|
82
|
+
The store is per-project and follows the codebase: changed files are re-extracted by content hash, deleted files are removed. Experience notes are `kind: 'experience'` entries in `insights.json` — retrieval-only, so accumulation does not affect context.
|
|
81
83
|
|
|
82
84
|
## Design
|
|
83
85
|
|
|
@@ -85,7 +87,6 @@ The store is per-project and follows the codebase: changed files are re-extracte
|
|
|
85
87
|
.dsh-project-memory/
|
|
86
88
|
format.json layout marker (v2, sharded)
|
|
87
89
|
shards/ one self-describing JSON per indexed source file — writes touch only dirty shards
|
|
88
|
-
experience.json.migrated read-only archive of v0.4 notes (imported into insights.json on first load)
|
|
89
90
|
watch.json watched roots
|
|
90
91
|
tasks.json TaskBridge task entities (cross-session)
|
|
91
92
|
binding.json current session ↔ task binding
|
|
@@ -98,7 +99,7 @@ The store is per-project and follows the codebase: changed files are re-extracte
|
|
|
98
99
|
- **Incremental** — a content hash per file; only changed files are re-extracted.
|
|
99
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.
|
|
100
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.
|
|
101
|
-
- **Consistency** — the fact layer follows the codebase (hash re-extract / remove-on-delete); the experience layer is retrieval-only with supersede and `forget`.
|
|
102
|
+
- **Consistency** — the fact layer follows the codebase (hash re-extract / remove-on-delete); the experience layer is retrieval-only with supersede and `forget`. Writes take a cross-process directory lock (`.write.lock`) around a short read-modify-write, so two dsh instances can share one project store: shards converge by `indexedAt`, and a save that cannot get the lock is deferred and retried.
|
|
102
103
|
|
|
103
104
|
## Architecture (Task Panel)
|
|
104
105
|
|
|
@@ -131,16 +132,18 @@ The workflow panel is collapsible, adapts to dsh and theme plugin styles, and of
|
|
|
131
132
|
| `llmQueryExpansion` / `expansionCount` | false / 6 | expand queries via the LLM before search (off by default to save tokens); max variants |
|
|
132
133
|
| `tsPath` / `enableTypeScript` | (auto) / true | optional absolute path to a specific `typescript` install; set `enableTypeScript: false` to disable the type-aware layer entirely |
|
|
133
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 |
|
|
134
|
-
| `insight.*` | dedupOverlap `0.7` · reinforceBand `0.65` · autoMergeCos `0.9` · autoMergeMargin `0.05` · hintCos `0.7` · maxForgetMatches `10` · maxProject `100` · maxGlobalProcedures `200` · promoteConfidence `0.7` · globalPromoteTasks `3` · decayDays `90` · `globalFile` (auto) | insight dedupe / auto-overwrite / near-neighbour hint / delete cap / reinforce / promotion / capacity / archive settings |
|
|
135
|
+
| `insight.*` | dedupOverlap `0.7` · reinforceBand `0.65` · autoMergeCos `0.9` · autoMergeMargin `0.05` · hintCos `0.7` · maxForgetMatches `10` · maxProject `100` · maxGlobalProcedures `200` · promoteConfidence `0.7` · globalPromoteTasks `3` · decayDays `90` · `globalFile` (auto) | insight dedupe / auto-overwrite / near-neighbour hint / delete cap / reinforce / promotion / capacity / archive settings. `autoMergeCos` / `hintCos` = `0` turns that band **off** |
|
|
135
136
|
| `reflection.enabled` | false | LLM reflection, **draft-only at task level** (fires on task switch-away / archive). `cooldownMs` `1800000`, `maxLessonsPerReflect` `3`, `maxDecisionsPerReflect` `2` |
|
|
136
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` |
|
|
137
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 |
|
|
138
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 |
|
|
139
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" |
|
|
140
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 |
|
|
141
|
-
| `autoContext.vectorDir` | unset | **optional** semantic layer over the experience/insight layers, on by default via the `leanvec` optionalDependency (79 MB, ≈+130 MB RSS). `off` forces pure lexical; a path or `DSH_LEANVEC_DIR` overrides it. Re-orders only, returned counts unchanged; while it is active
|
|
142
|
-
| `autoContext.vectorAlpha` | 0.5 | weight of `(1-α)·lexical + α·cosine` in those layers; `0` disables
|
|
143
|
-
| `autoContext.
|
|
142
|
+
| `autoContext.vectorDir` | unset | **optional** semantic layer over the experience/insight layers, on by default via the `leanvec` optionalDependency (79 MB, ≈+130 MB RSS). `off` forces pure lexical; a path or `DSH_LEANVEC_DIR` overrides it. Re-orders only, returned counts unchanged; while it is active only entries that got **no** cosine are still filtered by lexical match count |
|
|
143
|
+
| `autoContext.vectorAlpha` | 0.5 | weight of `(1-α)·lexical + α·cosine` in those layers; `0` disables re-ranking only (write-side dedup stays on), `1` (pure vector) measured worse |
|
|
144
|
+
| `autoContext.vectorDedup` | true | write-side near-duplicate detection (cosine ≥ 0.9 auto-overwrite, ≥ 0.7 near-neighbour hint). Independent of `vectorAlpha`; `false` keeps recall ranking untouched |
|
|
145
|
+
| `autoContext.vectorItemMin` / `autoContext.vectorSpeakMin` | unset | **experimental** absolute-cosine gates for the hint channel (per-entry floor / channel-level semantic rescue). Uncalibrated — unset means off; see the evidence in `src/auto-inject.js` before enabling |
|
|
146
|
+
| `autoContext.legacyScope` | `ignore` | how a legacy `trigger.scope` is treated: `ignore` (default) does not use it as a filter; `filter` applies it as a filter. `npm run selfcheck:triggers` lists entries that still carry a scope |
|
|
144
147
|
| `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 |
|
|
145
148
|
| `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 |
|
|
146
149
|
|
|
@@ -156,7 +159,7 @@ When the root comes from the working directory, the model gets one notice per se
|
|
|
156
159
|
|
|
157
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.
|
|
158
161
|
|
|
159
|
-
**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.4 KB), **≈22×** for symbol-dense code (1 per 220 B) and **≈20×** for a text-heavy PDF, on top of a ~52 MB process baseline plus a one-off ≈175 MB the first time a PDF is parsed. The 10 MB default therefore keeps a single file at roughly **+300 MB RSS** for code and **+370 MB** for a PDF; raising the cap raises that ceiling proportionally.
|
|
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.4 KB), **≈22×** for symbol-dense code (1 per 220 B) and **≈20×** for a text-heavy PDF, on top of a ~52 MB process baseline plus a one-off ≈175 MB the first time a PDF is parsed. The 10 MB default therefore keeps a single file at roughly **+300 MB RSS** for code and **+370 MB** for a PDF; raising the cap raises that ceiling proportionally.
|
|
160
163
|
|
|
161
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.
|
|
162
165
|
|
|
@@ -194,11 +197,11 @@ where `config.yml` contains the same override block.
|
|
|
194
197
|
|
|
195
198
|
### Measured on real projects (2026-10-13)
|
|
196
199
|
|
|
197
|
-
Four corpora, one machine (Node 24.19
|
|
200
|
+
Four corpora, one Linux machine (Node 24.19), 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.
|
|
198
201
|
|
|
199
202
|
| Corpus | Files / entries | Cold index | Cold load | Query p50 / p95 | Re-index 1 file | Store content / on disk | Heap after load |
|
|
200
203
|
|--------|-----------------|-----------|-----------|-----------------|-----------------|------------------------|-----------------|
|
|
201
|
-
|
|
|
204
|
+
| Frontend app (code only) | 289 / 2,142 | 246 ms | 8 ms | 0.76 / 1.4 ms | 0.3 ms | 0.66 MB / 1.52 MB | 6.3 MB |
|
|
202
205
|
| Docs workspace (Markdown + PDFs) | 249 / 977 | 705 ms | 10 ms | 1.8 / 5.5 ms | 0.4 ms | 1.31 MB / 1.84 MB | 6.8 MB |
|
|
203
206
|
| TypeScript monorepo, 3,000-file slice | 3,000 / 17,576 | 1.9 s | 70 ms | 9.2 / 18.9 ms | 1.9 ms | 10.9 MB / 18.9 MB | 22.7 MB |
|
|
204
207
|
| TypeScript monorepo, whole tree | 12,634 / 80,231 | 7.8 s | 278 ms | 40.6 / 74.8 ms | 7.2 ms | 42.0 MB / 75.7 MB | 75.2 MB |
|
|
@@ -207,7 +210,7 @@ Four corpora, one machine (Node 24.19, 20 vCPU, Linux file system), each run twi
|
|
|
207
210
|
|
|
208
211
|
> `read+hash` depends on the OS page cache — 2.3 s cold vs 0.27 s warm on the 12,634-file tree — so the table quotes the warm figure.
|
|
209
212
|
|
|
210
|
-
### Synthetic Benchmark (Node 24.19,
|
|
213
|
+
### Synthetic Benchmark (Node 24.19, Linux)
|
|
211
214
|
|
|
212
215
|
| Scenario | Scale | Measured |
|
|
213
216
|
|----------|-------|----------|
|
|
@@ -232,7 +235,7 @@ npm run bench -- /path/to/your/project
|
|
|
232
235
|
node scripts/bench.mjs /path/to/your/project [--json] [--samples 100] [--no-pdf] [--keep]
|
|
233
236
|
```
|
|
234
237
|
|
|
235
|
-
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
|
|
238
|
+
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 frontend app row above:
|
|
236
239
|
|
|
237
240
|
```
|
|
238
241
|
cold index 246 ms (read+hash 8 ms · extract 222 ms · commit 14 ms) ← 2nd, warm-cache run
|
|
@@ -246,16 +249,16 @@ Pass `--queries your-queries.json` to run the labeled-set method (hit@5 / hit@10
|
|
|
246
249
|
|
|
247
250
|
## Design tradeoffs
|
|
248
251
|
|
|
249
|
-
- **
|
|
252
|
+
- **A short filesystem lock, not an embedded database** — each save holds an exclusive `.write.lock` only for the read-modify-write (parsing stays outside it), waits at most 2 s for a busy peer and then retries. Two dsh instances can share one store. No WAL, no daemon, no native dependency.
|
|
250
253
|
- **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.
|
|
251
254
|
- **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.
|
|
252
|
-
- **Vectors re-rank, they do not rank** — on a paraphrased-query set, pure vector replacement is worse than BM25 (hit@10 **53% vs 69%**) while weighted fusion helps at small k (hit@3 **53% vs 50%**), so the optional layer only re-orders the experience/insight layers and never gates. Lexical retrieval still answers the queries this plugin targets: on a real
|
|
255
|
+
- **Vectors re-rank, they do not rank** — on a paraphrased-query set, pure vector replacement is worse than BM25 (hit@10 **53% vs 69%**) while weighted fusion helps at small k (hit@3 **53% vs 50%**), so the optional layer only re-orders the experience/insight layers and never gates. Lexical retrieval still answers the queries this plugin targets: on a real project with 29 labelled queries, file-level hit@5 is **96.6%**, and whole-chunk terms raise document term coverage from **27.3% to 100%** with MRR unchanged (**0.958** vs **0.955**).
|
|
253
256
|
- **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.
|
|
254
257
|
- **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.
|
|
255
258
|
- **Full entries returned directly** — entries are already compact, so returning them whole is more verifiable and one round-trip cheaper.
|
|
256
259
|
- **`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`.
|
|
257
260
|
- **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.
|
|
258
|
-
- **Subagent sessions are out of scope
|
|
261
|
+
- **Subagent sessions are out of scope**
|
|
259
262
|
|
|
260
263
|
## Development (for contributors)
|
|
261
264
|
|
|
@@ -263,8 +266,8 @@ These commands are for **maintaining the plugin code** — regular users do not
|
|
|
263
266
|
|
|
264
267
|
```bash
|
|
265
268
|
npm install
|
|
266
|
-
npm test #
|
|
267
|
-
npm run eval:injection # synthetic pool P/R: precision 0.
|
|
269
|
+
npm test # 756 tests
|
|
270
|
+
npm run eval:injection # synthetic pool P/R: precision 0.93 / recall 1.00, + a 3-scenario hint-only group
|
|
268
271
|
npm run eval:injection -- --store .dsh-project-memory/insights.json # replay on YOUR store; control group is a hard gate
|
|
269
272
|
npm run selfcheck:triggers # which entries can still push, which declarations are dead (reads your local store)
|
|
270
273
|
npm run bench -- /path/to/project # index/query performance on any project — no dsh needed
|