@yolk_vat-y/dsh-project-memory 0.6.0 → 0.6.2
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 +104 -2
- package/README.md +10 -10
- package/README.zh-CN.md +10 -10
- package/client/client.js +363 -123
- package/client/client.js.map +1 -1
- package/package.json +11 -8
- package/src/auto-inject.js +25 -1
- package/src/client/MemoryView.tsx +157 -44
- package/src/client/TaskPanel.module.css +23 -0
- package/src/client/locales.ts +10 -0
- package/src/client/paging.js +165 -0
- package/src/commands/insight-actions.js +85 -11
- package/src/commands/invocation.js +4 -1
- package/src/commands/task-actions.js +5 -0
- package/src/index.js +10 -0
- package/src/insight-store.js +361 -35
- package/src/lazy.js +5 -3
- package/src/recall.js +13 -8
- package/src/setup/taskbridge.js +13 -7
- package/src/store.js +170 -131
- package/src/tools/forget.js +26 -6
- package/src/tools/lesson-tools.js +21 -8
- package/src/tools/query-memory.js +10 -4
- package/src/tools/remember.js +30 -14
- package/src/tools/task-tools.js +3 -0
- package/src/types.js +8 -1
- package/src/util/fs.js +3 -1
- package/src/util/session-dir.js +48 -0
- package/src/vector-index.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,105 @@
|
|
|
1
|
+
## 0.6.2 (2026-10-17)
|
|
2
|
+
|
|
3
|
+
`npm test` **705 项 / 40 个文件**;`npm run typecheck` 通过。
|
|
4
|
+
|
|
5
|
+
### 兼容:dsh 0.2.1-rc.2
|
|
6
|
+
|
|
7
|
+
- **开发依赖对齐新宿主**:`@deepseek-ai/dsh-tools` / `dsh-llm` / 四个 client 包从 `0.2.0-rc.2` 升到 `0.2.1-rc.2`,`package-lock.json` 重新生成;`client/client.js` 按 0.2.1 的 seed 模块重建。
|
|
8
|
+
- **补 `dsh.engines.dsh` 声明**:0.2.1 起插件兼容性检查先读 `engines.dsh`,只有缺省时才回落到 `peerDependencies` 里的 `@deepseek-ai/dsh-*` 范围。这里写的是插件本来支持的区间(0.0.1-rc.1 起、0.3.0-0 之前),与 peer 范围保持一致。
|
|
9
|
+
- **0.2.1 的破坏性变更逐项核对**:client primitives 删除 `projectUserText` / `UserTextReferences`(本插件未使用);`tool-presentation` 的 `both` 模式被删除(本插件未声明);slots 只新增 `inline` / `keyed` 可选字段(增量兼容);`session.header.cwd` 不再是当前执行目录,取值已收口到 `workingDirectory` 服务(0.6.1 起)。
|
|
10
|
+
- **验证**:在干净的 0.2.1 profile 里用 `dsh plugin add <tarball>` 安装打包产物,配置能组装、插件能激活,无 `ERR_MODULE_NOT_FOUND`;本仓库 `npm run typecheck`、`npm test` 全绿。
|
|
11
|
+
|
|
12
|
+
> 注意:0.2.1 拒绝 `webserver.host` 通配地址(`0.0.0.0` / `::`),旧 profile 需改成具体地址(如 `127.0.0.1`),否则桌面端启动失败后会重置 profile 的 bundle 列表。
|
|
13
|
+
|
|
14
|
+
### 修复:0.6.1 新代码引入的三处回归(空根副作用 / 重放超上限 / Schema 漏声明)
|
|
15
|
+
|
|
16
|
+
- **`store.load()` 重新变成"空根零副作用"**:统一存储把 `experience.json` 导入的早退删掉了(`_migrateExperienceToInsights` 只判 `migratedAt`),于是**没有 `insights.json`、也没有旧经验**的全新根,只 `load()` 一次就会 `mkdirSync` 并写一份空 `insights.json`。`audit.js` 的 `auditDirReady` 靠"目录已存在"放行、`auto-inject` 靠 `store.hasContent` 决定要不要 `save()`——两处闸门同时失效后,容器目录会被 `resolveProjectMemoryRoot()` 当成项目根(issue #5 同类)。改法:导入落盘那支要求 `legacyOnDisk || legacy.length > 0`;旧文件归档是**另一支**、单独判 `legacyOnDisk`,三种真实升级形态都不受影响。
|
|
17
|
+
- **动作后的重放不再超过宿主单页上限**:`reloadWindowRequest()` 返回 `limit = 已加载条数`(客户端注释还写着"正常永远走 PAGE_SIZE=30"),而宿主 `INSIGHT_PAGE_MAX=200` 是**静默**截断;重放又是替换式 `setRows`,于是滚到 500 条再点任意动作,列表被打回 200 条。改法:客户端用 `HOST_PAGE_MAX=200` 夹住 `limit`,载荷回报的 `nextOffset` 让哨兵继续把 200..N 追加回来。`client/client.js` 已同步重建。`test/insight-paging.test.mjs` 加一条交叉断言,把客户端常量与宿主 `INSIGHT_PAGE_MAX` 钉在一起(browser bundle 进不了服务端模块,只能靠测试防漂移)。
|
|
18
|
+
- **`insight.*` 四个旋钮补进 Schema**:`autoMergeCos` / `autoMergeMargin` / `hintCos` / `maxForgetMatches` 在 `cfgInsight` 里读取、README 与 `types.js` 也写了,却没在 `src/index.js` 的 `Config` 里声明——与 0.5.8 给 `autoContext` 补声明是同一类问题:走 `cordis.patch.yml` 配它们,能不能活到代码取决于宿主是否按 `additionalProperties: false` 校验,但无论哪种,文档与 Schema 已经不一致。新增 `test/config-schema.test.mjs`:凡 `cfgInsight()` 会算出的数值键都必须在 `Config.insight` 声明,且 Schema 默认值等于运行时兜底值。
|
|
19
|
+
|
|
20
|
+
**测试**:`npm test` 701 → 705 项 / 39 → 40 个文件(新增空根零副作用、客户端上限三条、契约交叉断言、Schema 一致性);`npm run typecheck` 通过。
|
|
21
|
+
|
|
22
|
+
### 修改:统一存储——`experience.json` 退休,经验笔记成为 `kind:'experience'` 的 insight
|
|
23
|
+
|
|
24
|
+
**问题**:同一个概念有两个真相源——`experience.json` 服务 `remember`/`forget`/`query_memory`,`insights.json` 里又躺着一份 `source:'migrate'` 的**影子副本**,靠 `visibleInsights` 里一个特判(排除 `kind:'experience' && source:'migrate'`)才不至于在 `## Insights` 与 `## Experience` 里各出现一次。写入、删除、容量、向量索引各维护一套,正是"结构有点乱"的来源。上一版把 `forget` 做成了全层一套,但底下仍然是两套存储。
|
|
25
|
+
|
|
26
|
+
**改法**(insight 是唯一实体,`kind` 只是语义):
|
|
27
|
+
|
|
28
|
+
- **`experience.json` 降为一次性导入源**:加载时导入 `insights.json`,导入成功即改名 `experience.json.migrated` 只读归档(不删,升级后想人工比对还有原文)。归档那一步与"导入"**分开判**:0.5.x/0.6.x 用户的 `migratedAt` 早就写上了、文件却还在,只看 `migratedAt` 的话旧文件永远收不走。写盘失败则不收文件(宁可留着,也不丢数据)。
|
|
29
|
+
- **删掉旧层 API**:`addExperience` / `findSupersede` / `pruneExperience` / `removeExperience` 与 `store.experience` 的读写全部移除;容量归 insight 层的 `maxProject`(归档优先、超限才物理删),删除归 `forget` / `removeMemory`。
|
|
30
|
+
- **`remember` 改走 `saveInsight`**(`kind:'experience'`、project 级),于是它与 `save_lesson` 共享同一套去重 / 自动覆盖 / 近邻提示 / 就地更新。工具描述里删掉 "never auto-injected":那条承诺早已名不副实——`auto-inject` 的候选池(`insightCandidates`)一直是从 `insightItems()` 全量取的,影子条目本来就在池子里。
|
|
31
|
+
- **召回按 kind 分工**:`experience` 桶改由 `kind:'experience'` 的条目供给,`insight` 桶排除它(同一份池子、两边互斥,否则同一内容会同时出现在两个分节);`visibleInsights` 里的影子特判删除。`query_memory` 的经验桶现在也记 `hitCount`(同源了),`source` 显示兼容导入时落在 `files[0]` 的路径。
|
|
32
|
+
- **`insights.json` version → 3**:形状与 v2 相同(纯语义升级,v1/v2/v3 都能直接读),只是标记 `kind:'experience'` 从影子变成一等实体。
|
|
33
|
+
|
|
34
|
+
**升级路径**(至少覆盖 0.5.0,三种真实形态都有测试):只有 `experience.json`、没有 `insights.json` 的 0.4/0.5.0 store;`migratedAt` 已存在但旧文件还在的 0.5.x/0.6.x store;v1/v2 `insights.json`。都能直接加载,导入幂等、不重复。
|
|
35
|
+
**降级注意**:回到 ≤0.6.x 的老版本后,那些笔记在旧版里查不到——老版本从空的 `store.experience` 出发、又用特判排除 `source:'migrate'` 的影子。**数据没丢**(仍在 `insights.json`),只是旧版本不再展示。
|
|
36
|
+
|
|
37
|
+
**测试**:新增迁移归档 / 已迁移老 store 也要归档 / 无 insights.json 的旧版形态 3 项;删掉随能力一起消失的用例(经验层容量与动态上限、`store-cache` 的"经验写入"失效探针、run-test 的 `addExperience` 系列),并把 `supersede boundary`(共享前缀不互相顶掉)改到新写路径上继续钉住。707 → 701 项。
|
|
38
|
+
|
|
39
|
+
### 修改:`forget` 通吃全层(教训 / 决策 / 流程 / 经验笔记,task / project / global)
|
|
40
|
+
|
|
41
|
+
**问题**:`forget` 只删旧的 `experience.json`(`store.removeExperience`),insight 层**没有删除入口**——模型发现某条记错了、过时了,只能新写一条"本条修正 ins_xxx",于是矛盾的两条长期共存、又都在注入候选里(真实使用里出现过好几对这种"新条目声明修正旧条目"的记录,被修正的那条一直在注入)。写入侧上一版已经能就地改,删除侧一直缺着。
|
|
42
|
+
|
|
43
|
+
**改法**:新增 `removeMemory({ store, globalStore, idOrQuery, maxMatches })`,把四个 home(task 内嵌 / project / global / 旧经验层)当成一个记忆空间来查:
|
|
44
|
+
|
|
45
|
+
- **精确 id 优先**:命中即删那一条,不被当成关键词。
|
|
46
|
+
- **关键词**沿用旧经验层**一直以来的判据**——查询侧覆盖率(命中词 / 查询词数)≥ 0.5,而不是排序/去重用的两侧取大:删除查询通常只有一个词,用两侧取大会被长正文稀释到接近 0,"删掉 pnpm 那条"就永远删不掉。换层不顺带改判据。
|
|
47
|
+
- **上限保护**:关键词命中超过 `insight.maxForgetMatches`(默认 10)时**一条都不删**,只列出候选(id + 标题 + 所在层)让人给更具体的词或逐个 id。删除是真删且无撤销,一次 `forget 'pnpm'` 扫掉十几条精选记忆不可接受。
|
|
48
|
+
- **回报说清删了什么**:`Removed N memory entries:` + 每条的 `id《标题》(层)`。旧实现只回一个计数,事后无法审计。
|
|
49
|
+
|
|
50
|
+
`save_lesson` 的近邻提示同步补上"确认过时的用 forget 删掉它",写入与删除两条路闭环。`test/insight-store.test.mjs` 新增 2 项(+2):精确 id 删 project / global / task(global 要验落盘)、关键词删旧经验层、上限保护超限不删、无匹配不炸,以及 `forget` 工具端到端的回报内容。
|
|
51
|
+
|
|
52
|
+
### 新增:写入期向量带(相似度 ≥0.9 自动覆盖、≥0.7 提示近邻)+ `save_lesson` 带 `id` 就地更新
|
|
53
|
+
|
|
54
|
+
**问题**:写入期的自动管理实际上没在工作。真实 store(47 条 live / 1081 对)实测:`insightMatchText` 的词法重叠 **max 0.256**,而 `cfgInsight` 的合并带是 **0.70**——那条通道只在"逐字重写"时才可能触发。同时 `mergeInto` 的 `if (b && !existing[f])` 是**有值就丢掉新文本**,于是"我记错了、改成正确的"永远落不进去(只加 hitCount),而模型手里又没有修改既有条目的工具。
|
|
55
|
+
|
|
56
|
+
**判据**:写入时把条目标题喂给可选向量层(`leanvec`),取池内余弦最近的一条:
|
|
57
|
+
|
|
58
|
+
- **≥0.90 且领先第二名 ≥0.05 → 自动覆盖**该条目的正文字段(只覆盖本次显式给的字段),被挤掉的旧值进 `prev`;
|
|
59
|
+
- **≥0.70 → 不合并,只在返回里提示近邻 id**,由模型决定要不要带 id 重写;
|
|
60
|
+
- 0.90 的余量:真实池内余弦 max 0.655,而让一个本地小模型把同一条知识改写一遍后与原文的余弦 min 0.688 / p50 0.809,所以 0.90 落在"只会命中逐字级再记录"的位置;0.70 在全部 1081 对真实条目上零噪声(0.65 会开始误伤 1/1081)。
|
|
61
|
+
- 成本:每次写入 **≈0.2ms**(编码 0.09ms + 池内点积 0.089ms);模型加载 ~118ms/~120MB 是一次性的,注入路径本来就已经付过。`leanvec` 不在时 `cosine` 为 null,逐字段退回原来的纯词法带(行为不变)。
|
|
62
|
+
|
|
63
|
+
**覆盖语义修正**:`mergeInto` 从"有值就不动"改成"新值落地 + 旧值进 `prev` 单槽"。`prev` 不是历史——每个字段只留上一版,O(1)、不折叠、不压实,刚好够"误覆盖后写回";它跟着条目跨层移动(`carryUsageFields`),所以 promote/demote 不会把它丢掉。提升路径只传成员/文件/符号/置信,不传正文字段,语义一字未变。
|
|
64
|
+
|
|
65
|
+
**`save_lesson` 新增 `id`**:给了 id 就是就地更新,只覆盖本次显式传的字段,忽略 `scope`——条目留在原来的层(global → project → 各任务,`findInsightAnywhere` 负责定位)。未知 id **显式失败**,绝不静默新建。带 id 时跳过向量加载(不需要比对)。
|
|
66
|
+
|
|
67
|
+
**测试**:`test/insight-store.test.mjs` 新增两组(判定矩阵用注入的 fake cosine,不依赖 leanvec)+3 项:0.95 自动覆盖且旧值进 `prev`、0.80 只提示、0.50 不提示、0.95/0.93 领先不足不覆盖、跨层就地更新、未知 id 失败、`prev` 跨层保留,以及工具端到端的 id 更新/写回。
|
|
68
|
+
|
|
69
|
+
### 修复:dsh 0.2.1 起 `session.header.cwd` 不再是「当前工作目录」
|
|
70
|
+
|
|
71
|
+
0.2.1 引入 `@deepseek-ai/dsh-working-directory`:`header.cwd` 变成**原始项目身份 / 权限根**,而 `working_directory({cd})` 改的是会话投影里的当前执行目录,**不写回 header**。本插件的根解析(索引 / 检索 / 懒索引 / 审计注入 / 任务桥)此前一律读 `header.cwd`,于是用户 cd 到另一个项目后,记忆仍然读写**原项目**的 store——不报错,只是静默错根。
|
|
72
|
+
|
|
73
|
+
取值现在收敛到 `src/util/session-dir.js` 的 `sessionWorkingDir()`:`ctx.get('workingDirectory').get(session)` → `session.header.cwd` → `agent.session.header.cwd`。新服务用 `ctx.get()` **软探测**(不能进顶层 `inject`,那是装配期门控,老宿主上会让插件整个不挂载),服务缺失或抛错都回退 `header.cwd`。没 cd 过时该投影的 `init` 就是 `header.cwd`,两者恒等,因此对既有行为是 **no-op**。`test/session-dir.test.mjs` 9 项钉住每条取值路径。
|
|
74
|
+
|
|
75
|
+
### 新增:记忆列表新→旧排序 + 增量加载
|
|
76
|
+
|
|
77
|
+
**排序**:任务 / 项目 / 全局三个 scope 此前是插入序(旧→新),首屏看到的是**最旧**的条目。现在按 `updatedAt↓ → createdAt↓ → id↑` 排出**确定性全序**(面板先看到刚学到的),并列条目也有稳定次序;排序不就地修改 store 自己的数组。
|
|
78
|
+
|
|
79
|
+
**分页**:`/tasks insight list <scope> [offset] [limit]`,省略参数 = 旧的"返回全部",老客户端 bundle 不受影响。载荷新增 `total` / `offset` / `nextOffset`,`count` 保留为总数;单页封顶 200,畸形参数**显式报错**而不是静默降级成 0 或全部。
|
|
80
|
+
|
|
81
|
+
**客户端**:首屏只取 30 条,滚到底前 600px 由 `IntersectionObserver` 预取下一页并追加(按 id 去重)。动作后重放 `0..已加载条数` 的**前缀**,而不是重置回第一页——否则正在看第 5 页的用户会被弹回顶部。页脚常驻「已显示 N / 总数」,加载指示延迟 150ms 才出现以免本地快请求闪一下,失败给可点重试;环境没有 `IntersectionObserver` 时退化成手动「加载更多」。离屏行用 `content-visibility: auto` 跳过 layout/paint(DOM 仍在,保留 find-in-page 与无障碍,避免手写可变行高虚拟列表)。
|
|
82
|
+
|
|
83
|
+
分页决策抽到 `src/client/paging.js`(纯函数,客户端 React 测试替身验证不了滚动行为):`test/client-paging.test.mjs` 8 项 + `test/insight-paging.test.mjs` 10 项覆盖边界——逐页拼接必须等于全量(不重叠不漏条)、越界不谎报"还有下一页"、老宿主形态降级。
|
|
84
|
+
|
|
85
|
+
并发协调另抽成 `createRequestGate()` 并单独钉住一条**开发中真踩到的 bug**:早期用"有在途请求就 return"的布尔守卫,于是上一页还在飞的时候切 scope,新请求被直接丢掉、过期响应又被丢弃 → 新列表永远空白,只能手动刷新。现在语义拆成两件事:过期响应按"序号 + 作用域"丢弃,新请求照发(只有同一个 `scope|offset|limit|append` 在飞时才去重)。
|
|
86
|
+
|
|
87
|
+
## 0.6.1 (2026-10-15)
|
|
88
|
+
|
|
89
|
+
`npm test` **650 → 675 项 / 36 个文件**;`npm run typecheck` 通过。
|
|
90
|
+
|
|
91
|
+
### 修复:物化后的 `searchText` 不在 storeCache 的上界里
|
|
92
|
+
|
|
93
|
+
`residentBoundBytes` 只数 `_textChars`,而 `allEntries()` 物化 `searchText` 时只 bump 物化版本、不补这笔文本量。于是上界停在物化前的水位,门禁据此跳过精确计量与逐出——实测最多到预算的 **2.06 倍**(真实语料 1.07~1.15 倍)。现在物化按文件记进 `_textChars`,与写路径同一套替换语义。
|
|
94
|
+
|
|
95
|
+
### 修复:`load()` 之后写进来的辅助集合不在上界,也不在失效键里
|
|
96
|
+
|
|
97
|
+
`experience` / `insights` / `tasks` / `binding` / `watch` 的增长既不进 `_textChars`,也不进版本戳(原先只有 `_entriesVersion` 与 `_materializeVersion` 两维),所以精确估算停在旧水位、上界还是骨架常数——单 store 实测上界 **1024 B**、实际 **19.08 MB**。现在版本戳加一维内容版本(每个写口 bump,含 `markTasksDirty`),上界补一条辅助集合的腿(按内容版本记忆化;这几个集合条目数小,逐节点求和不进冷加载热路径)。
|
|
98
|
+
|
|
99
|
+
### 修复:直接改 task 内容后没标脏,改动不落盘、驻留账也不失效
|
|
100
|
+
|
|
101
|
+
`/tasks rename|todos|switch|archive`、`select_task`、`archive_task` 与 TaskBridge 的三个事件写口都是直接改 task 对象:有的只置 `_dirtyTasks`(漏掉本次新增的内容版本,上界继续停在旧水位),有的连脏标记都不置——`save()` 于是早退,改名 / 归档只活在内存里。现在统一走 `markTasksDirty()`(标脏 + 内容版本),`test/taskbridge.test.mjs` 16 → **19** 项钉住这三条写路径的落盘与失效。
|
|
102
|
+
|
|
1
103
|
## 0.6.0 (2026-10-13)
|
|
2
104
|
|
|
3
105
|
`npm test` **616 → 650 项 / 34 → 36 个文件**;`npm run typecheck` 通过。注入场景集 8 → **13** 个,另加 3 个 hint-only 场景。
|
|
@@ -77,7 +179,7 @@
|
|
|
77
179
|
### 修复:legacy `trigger.scope` 不再被当作过滤条件
|
|
78
180
|
|
|
79
181
|
`readiness.js` 的注释写的是"`scope` → 默认忽略",但 `src/index.js` 的 schema 默认值是 `filter`,
|
|
80
|
-
两处不一致。结果是唯一带 `scope`
|
|
182
|
+
两处不一致。结果是唯一带 `scope` 的条目(「发版流程」)永远无法命中:它的
|
|
81
183
|
`scope=['release','npm','dsh-project-memory']` 与项目画像 tag 无交集,guard 直接判死。
|
|
82
184
|
|
|
83
185
|
- 默认改为 `ignore`(`src/index.js` 的 schema 与 `cfgEngine` 两处同时改)。显式配
|
|
@@ -1108,7 +1210,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
|
|
|
1108
1210
|
|
|
1109
1211
|
### Added (unified recall: the insight layer becomes searchable — PR1)
|
|
1110
1212
|
|
|
1111
|
-
- **`query_memory` now searches insights.** `type: 'insight'` was added, and `type: 'all'` appends an `## Insights (lessons / decisions / procedures)` section. Before this, lessons/decisions/procedures had **no retrieval path at all**: `util/search.js` had no insight ranker and the tool's `type` enum had no insight value, so a lesson could only reach an agent through silent injection. Verified against this repository's own store: the "public face" lesson
|
|
1213
|
+
- **`query_memory` now searches insights.** `type: 'insight'` was added, and `type: 'all'` appends an `## Insights (lessons / decisions / procedures)` section. Before this, lessons/decisions/procedures had **no retrieval path at all**: `util/search.js` had no insight ranker and the tool's `type` enum had no insight value, so a lesson could only reach an agent through silent injection. Verified against this repository's own store: the "public face" lesson now returns at score 100 for a natural-language query.
|
|
1112
1214
|
- **New `src/recall.js` — one retrieval core, ranked per layer.** Every layer gets an adapter to the same entry contract (`title` / `keywords` / `summary` / `terms` / `sourcePath` — the shape `weightedFieldText` already scores), its own top-k, and a layer prior. Cross-layer order is only ever a *hint* (`flat`); it is never spliced into one score, because the doc/symbol streamer and the in-memory BM25 have different scales. `query_memory` routes doc / symbol / experience / insight through this single call, so the experience layer no longer carries its own scoring path inside the tool.
|
|
1113
1215
|
- **Scope visibility follows the session binding.** `project` / `global` insights are visible to every session; `task`-level insights only to a session bound to that task (`select_task`). Drafts stay out of recall. The v0.4 `experience.json` → `insights.json` migration shadow (`kind: 'experience'`, `source: 'migrate'`) is excluded from the insight layer so a note is not listed once as an insight and again as an experience — convergence the store's own comment had deferred to this PR.
|
|
1114
1216
|
- **Normative-heading prior.** A doc chunk whose heading matches the multilingual normative set (必须 / 禁止 / 铁律 / rules / must / must not / do not …) is boosted ×1.5 within the doc layer: deterministic, model-free, no new dependency. This is the "「必须遵守」never surfaced" case — `test/recall.test.mjs` first pins today's term-frequency ordering, then asserts the prior flips it.
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ A persistent **project development memory** for [DeepSeek Harness](https://githu
|
|
|
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
25
|
- **Experience notes** — problems → solutions, deduplicated by overlap rather than repeated, bounded by project size, and returned only when a search matches.
|
|
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.
|
|
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
|
|
|
29
29
|
## Installation
|
|
@@ -59,10 +59,10 @@ The tools below are **invoked by the agent**, not typed by the user. In the chat
|
|
|
59
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. |
|
|
60
60
|
| `archive_task` | Archive a task (hide from default views, exclude from capacity, stop syncing). `select_task` restores it. |
|
|
61
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. |
|
|
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. |
|
|
63
|
-
| `remember problem solution` | Save an experience note. Similar problems
|
|
64
|
-
| `forget id_or_query` | Delete
|
|
65
|
-
| `save_lesson` | Save a lesson / decision / procedure at task, project or global scope.
|
|
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. |
|
|
63
|
+
| `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 legacy 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** (the same rule the legacy experience layer always used). Real deletion, no undo; when keywords match more than the cap (default 10) it deletes nothing and only lists the candidates. |
|
|
65
|
+
| `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
66
|
|
|
67
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.
|
|
68
68
|
|
|
@@ -77,7 +77,7 @@ The design follows four principles:
|
|
|
77
77
|
|
|
78
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.
|
|
79
79
|
|
|
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.
|
|
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 now `kind: 'experience'` entries in `insights.json` — retrieval-only, so accumulation does not affect context.
|
|
81
81
|
|
|
82
82
|
## Design
|
|
83
83
|
|
|
@@ -85,11 +85,11 @@ The store is per-project and follows the codebase: changed files are re-extracte
|
|
|
85
85
|
.dsh-project-memory/
|
|
86
86
|
format.json layout marker (v2, sharded)
|
|
87
87
|
shards/ one self-describing JSON per indexed source file — writes touch only dirty shards
|
|
88
|
-
experience.json
|
|
88
|
+
experience.json.migrated read-only archive of v0.4 notes (imported into insights.json on first load)
|
|
89
89
|
watch.json watched roots
|
|
90
90
|
tasks.json TaskBridge task entities (cross-session)
|
|
91
91
|
binding.json current session ↔ task binding
|
|
92
|
-
insights.json project-scope
|
|
92
|
+
insights.json project-scope memory (lessons / decisions / procedures / experience notes) — one entity
|
|
93
93
|
vectors.json optional semantic index (only when the vector layer runs)
|
|
94
94
|
injection-audit.jsonl one line per real injection (what / why / dropped / budget)
|
|
95
95
|
admission-shadow.jsonl one line per step, all scored candidates + features (offline replay)
|
|
@@ -131,7 +131,7 @@ The workflow panel is collapsible, adapts to dsh and theme plugin styles, and of
|
|
|
131
131
|
| `llmQueryExpansion` / `expansionCount` | false / 6 | expand queries via the LLM before search (off by default to save tokens); max variants |
|
|
132
132
|
| `tsPath` / `enableTypeScript` | (auto) / true | optional absolute path to a specific `typescript` install; set `enableTypeScript: false` to disable the type-aware layer entirely |
|
|
133
133
|
| `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` · maxProject `100` · maxGlobalProcedures `200` · promoteConfidence `0.7` · globalPromoteTasks `3` · decayDays `90` · `globalFile` (auto) | insight dedupe / reinforce / promotion / capacity / archive settings |
|
|
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
135
|
| `reflection.enabled` | false | LLM reflection, **draft-only at task level** (fires on task switch-away / archive). `cooldownMs` `1800000`, `maxLessonsPerReflect` `3`, `maxDecisionsPerReflect` `2` |
|
|
136
136
|
| `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
137
|
| `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 |
|
|
@@ -263,7 +263,7 @@ These commands are for **maintaining the plugin code** — regular users do not
|
|
|
263
263
|
|
|
264
264
|
```bash
|
|
265
265
|
npm install
|
|
266
|
-
npm test #
|
|
266
|
+
npm test # 702 tests
|
|
267
267
|
npm run eval:injection # synthetic pool P/R: precision 0.94 / recall 1.00, + a 3-scenario hint-only group
|
|
268
268
|
npm run eval:injection -- --store .dsh-project-memory/insights.json # replay on YOUR store; control group is a hard gate
|
|
269
269
|
npm run selfcheck:triggers # which entries can still push, which declarations are dead (reads your local store)
|
package/README.zh-CN.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
- **文档 ↔ 代码交叉链接** — 文档提及的符号,在查询该符号时一并带出。链接按**当前**符号表解算,不会过期。
|
|
23
23
|
- **混合召回** — 对文档、符号、经验笔记与 insight 排序召回,可选 LLM 查询扩展。`leanvec` 是 optionalDependency:默认装上并按余弦重排经验/洞察两层,没装或 `vectorDir: 'off'` 则退回纯词法。针对 CJK 增强:短语加分、同义词表,以及文档↔符号链接的词边界处理。
|
|
24
24
|
- **经验笔记** — 记录问题 → 方案;相似问题覆盖而不重复,数量随项目规模有界,仅在检索命中时返回。
|
|
25
|
-
- **分层 insight 记忆(教训 / 决策 / 流程)** —
|
|
25
|
+
- **分层 insight 记忆(教训 / 决策 / 流程)** — 同一实体贯穿任务、项目、全局三级。近重复合并或强化;提升是更换归属而非复制。被使用会记账,因此衰减与容量按活跃度排序,而不是只按时间。面板提供分级的记忆视图用于审核与编辑;列表按新→旧排列并增量加载——每页 30 条,滚到底前就预取下一页,离屏行不参与渲染,记忆变多也不卡。
|
|
26
26
|
- **触发式注入** — insight 可携带 authored trigger:只有 `when` 能触发,`guard` 只能收窄,`prevents` 记下没有它会坏在哪。语料正文永远不能触发注入;统计通道另有独立门槛,默认沉默。
|
|
27
27
|
|
|
28
28
|
## 安装
|
|
@@ -58,10 +58,10 @@ dsh plugin --profile web add @yolk_vat-y/dsh-project-memory -w
|
|
|
58
58
|
| `select_task` | 将会话绑定到某任务(此后 todo 清单与读文件同步进该任务)。按 `taskId` 精确绑定,或按 `title` 完全匹配(多个同名返回候选;无则新建)。带 title 可改名;自动解归档。 |
|
|
59
59
|
| `archive_task` | 归档任务(隐藏默认视图、不占容量、停止同步)。`select_task` 可恢复。 |
|
|
60
60
|
| `show_task_panel` | 在 UI 中打开任务面板。用户要求查看任务列表或你想展示面板时调用。 |
|
|
61
|
-
| `/tasks`(用户输入,不经模型) | 唯一的用户命令:展示任务栈并驱动工作流卡片。其余动作是它的**子动词**,由卡片按钮调用:`switch` / `archive` / `unbind` / `rename` / `todos …` 为任务动作,`insight list` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` 为记忆动作。 |
|
|
62
|
-
| `remember problem solution` |
|
|
63
|
-
| `forget id_or_query` |
|
|
64
|
-
| `save_lesson` | 在 task/project/global 任一作用域保存教训 / 决策 /
|
|
61
|
+
| `/tasks`(用户输入,不经模型) | 唯一的用户命令:展示任务栈并驱动工作流卡片。其余动作是它的**子动词**,由卡片按钮调用:`switch` / `archive` / `unbind` / `rename` / `todos …` 为任务动作,`insight list [offset] [limit]` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` 为记忆动作。 |
|
|
62
|
+
| `remember problem solution` | 保存经验笔记。它就是 `kind: 'experience'` 的 insight——与教训 / 决策 / 流程同库、同去重、同删除入口。相似问题合并或覆盖而非重复。 |
|
|
63
|
+
| `forget id_or_query` | 删除记忆——教训 / 决策 / 流程与经验笔记一视同仁,task / project / global 全层一次搞定,不必先知道它在哪一层。精确 id 删那一条;关键词按**查询侧覆盖率**匹配(与旧经验层同判据)。真删、无撤销;关键词命中超过上限(默认 10)时**一条都不删**,只列出候选。 |
|
|
64
|
+
| `save_lesson` | 在 task/project/global 任一作用域保存教训 / 决策 / 流程;带 `id` 就是**就地覆盖**既有条目(只改本次显式传的字段,旧值留在 `prev`,用同一个 id 再写一次即可写回)。写入前与既有记忆比对:余弦 ≥ 0.9 自动覆盖那一条,≥ 0.7 在返回里提示近邻 id;`leanvec` 不在时退回词法 overlap ≥ 0.7 合并、0.65–0.7 强化。同一 insight 被 2+ 任务命中自动 task→project、3+ → global。主要参数:`id`、`title`、`kind`、`scope`、正文(`pattern`/`fix`、`choice`/`reason` 或 `steps`)、`trigger`(`when` 是唯一触发面,`guard` 只能收窄,`prevents` 记下没有它会坏在哪)。 |
|
|
65
65
|
|
|
66
66
|
`/tasks` 在 web 的 `/` 菜单里以带图标的**「工作流」**组呈现 —— 三个视图入口:任务 / 项目记忆 / 全局记忆(标题随界面语言切换)。它是插件唯一注册的命令,其余动作全部作为它的子动词由卡片按钮驱动。
|
|
67
67
|
|
|
@@ -76,7 +76,7 @@ dsh plugin --profile web add @yolk_vat-y/dsh-project-memory -w
|
|
|
76
76
|
|
|
77
77
|
构建**记忆**无需预先全量扫描:文件在模型读取时被记忆,**记忆**恰好覆盖实际处理过的内容。未变更的文件重读是空操作,因此持续维护开销很低。
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
存储按项目独立存放,并跟随代码库变化:文件变更按内容哈希重新抽取,文件删除则同步移除。经验笔记现在是 `insights.json` 里 `kind: 'experience'` 的条目,仅检索、累积不影响上下文。
|
|
80
80
|
|
|
81
81
|
## 设计
|
|
82
82
|
|
|
@@ -84,11 +84,11 @@ dsh plugin --profile web add @yolk_vat-y/dsh-project-memory -w
|
|
|
84
84
|
.dsh-project-memory/
|
|
85
85
|
format.json 布局标记(v2,分片式)
|
|
86
86
|
shards/ 每个被索引源文件一个自描述 JSON —— 写入只落脏分片
|
|
87
|
-
experience.json
|
|
87
|
+
experience.json.migrated v0.4 经验笔记的只读归档(首次加载已导入 insights.json)
|
|
88
88
|
watch.json 被监听根目录
|
|
89
89
|
tasks.json TaskBridge 任务实体(跨会话)
|
|
90
90
|
binding.json 当前会话 ↔ 任务绑定
|
|
91
|
-
insights.json
|
|
91
|
+
insights.json 项目级记忆(教训 / 决策 / 流程 / 经验笔记)——唯一实体
|
|
92
92
|
vectors.json 可选语义索引(只在向量层启用时存在)
|
|
93
93
|
injection-audit.jsonl 每次真实注入一行(注入了什么 / 为什么 / 丢了什么 / 额度)
|
|
94
94
|
admission-shadow.jsonl 每步一行,全部被评分的候选 + 特征(离线重放)
|
|
@@ -130,7 +130,7 @@ TaskPanel (Container)
|
|
|
130
130
|
| `llmQueryExpansion` / `expansionCount` | false / 6 | 检索前用 LLM 扩展查询(默认关闭,节省 token);扩展变体上限 |
|
|
131
131
|
| `tsPath` / `enableTypeScript` | (自动) / true | 可选:强制指定 `typescript` 安装路径;`enableTypeScript: false` 彻底禁用类型感知层 |
|
|
132
132
|
| `tasklist.enabled` / `tasklist.syncHostOnAdopt` | true / true | TaskBridge 自动同步(由会话 todo 清单与文件读取沉淀任务实体);绑定任务时把其步骤推给宿主任务清单,使 dsh 镜像该任务 |
|
|
133
|
-
| `insight.*` | dedupOverlap `0.7` · reinforceBand `0.65` · maxProject `100` · maxGlobalProcedures `200` · promoteConfidence `0.7` · globalPromoteTasks `3` · decayDays `90` · `globalFile`(自动) | insight 去重 / 强化 / 提升 / 容量 / 归档设置 |
|
|
133
|
+
| `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`(自动) | insight 去重 / 自动覆盖 / 近邻提示 / 删除上限 / 强化 / 提升 / 容量 / 归档设置 |
|
|
134
134
|
| `reflection.enabled` | false | LLM 反思,**只写任务级草稿**(触发于任务切走 / 归档)。`cooldownMs` `1800000`、`maxLessonsPerReflect` `3`、`maxDecisionsPerReflect` `2` |
|
|
135
135
|
| `autoContext.enabled` | true | 静默注入包装(常驻任务卡 + 受门槛约束的条目);宿主无法解析会话 cwd 时完全透传。`maxTokens` `400`(单轮)、`editedMax` `3`(任务卡显示的最近"编辑中"文件数)、`signalMinRatio` `0.5`(提示至少达到该层最高分的一半)、`skipEchoSelfTodo` `true`、`budgetLog` `off`、`reinjectItemsAfter` `0`(同一条 insight 重复注入的冷却步数)、`rootNotice` `true` |
|
|
136
136
|
| `autoContext.gateCooldownSteps` | 2 | **准入旋钮**:两次*条目*注入之间至少隔几步(常驻任务卡不受限——它是状态快照)。这是"别频繁注入"的主旋钮 |
|
|
@@ -262,7 +262,7 @@ node scripts/bench.mjs /你的/项目路径 [--json] [--samples 100] [--no-pdf]
|
|
|
262
262
|
|
|
263
263
|
```bash
|
|
264
264
|
npm install
|
|
265
|
-
npm test #
|
|
265
|
+
npm test # 702 项测试
|
|
266
266
|
npm run eval:injection # 合成池 P/R:精确率 0.94 / 召回率 1.00,另有 3 个 hint-only 场景
|
|
267
267
|
npm run eval:injection -- --store .dsh-project-memory/insights.json # 用你自己的 store 重放;对照组是硬闸门
|
|
268
268
|
npm run selfcheck:triggers # 哪些条目还推得动、哪些声明是死的(读你本地的 store)
|