@yolk_vat-y/dsh-project-memory 0.6.8 → 0.6.10
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 +59 -0
- package/README.md +11 -9
- package/README.zh-CN.md +11 -9
- package/client/client.js +411 -14
- package/client/client.js.map +1 -1
- package/cordis.patch.yml +4 -0
- package/package.json +4 -4
- package/skills/project-memory/SKILL.md +5 -1
- package/skills/project-memory/scripts/pm-digest.mjs +67 -5
- package/src/auto-inject.js +10 -5
- package/src/client/SettingsCard.module.css +185 -0
- package/src/client/client.ts +4 -1
- package/src/client/locales.ts +31 -0
- package/src/client/settings-card.tsx +346 -0
- package/src/commands/insight-actions.js +29 -7
- package/src/commands/tasks.js +1 -1
- package/src/enhancer.js +7 -3
- package/src/index-failures.js +46 -0
- package/src/index.js +36 -11
- package/src/insight-store.js +10 -3
- package/src/lazy.js +25 -5
- package/src/ops.js +13 -0
- package/src/parsers/pdfjs-parser.js +33 -4
- package/src/recall.js +2 -1
- package/src/setup/taskbridge.js +18 -5
- package/src/store.js +190 -78
- package/src/tools/index-doc.js +13 -3
- package/src/tools/index-repo.js +13 -4
- package/src/tools/lesson-tools.js +4 -2
- package/src/tools/query-memory.js +20 -8
- package/src/tools/stats.js +8 -0
- package/src/tools/task-tools.js +4 -0
- package/src/tools/watch-repo.js +14 -8
- package/src/util/config.js +65 -0
- package/src/util/fs.js +121 -17
- package/src/util/search.js +17 -13
- package/src/watch.js +92 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
## 0.6.10 (2026-11-04)
|
|
2
|
+
|
|
3
|
+
**兼容**:无新增配置键,无 store 格式变更。一处判据变化:`memoryDir` 只接受项目根内的相对路径,越界值(`.`、`..`、含 `..` 段、绝对路径)回落到默认目录并告警一次(此前会静默把 store 放到根上或根外)。
|
|
4
|
+
|
|
5
|
+
### 性能
|
|
6
|
+
|
|
7
|
+
- **CJK 分词从「逐字符判断」改成「整段匹配」**:`tokenizeRaw` 此前对整篇文本逐码点调用 `CJK_RANGE.test()` 并累积字符串,纯英文文档也要跑满整篇。现在用一条从 `CJK_RANGE` 派生的正则一次取出所有连续段,再按原有规则结算(段长 1 产单字、≥2 产全部相邻二元组)。**输出逐字节一致**,所以 `TOKENIZER_VERSION` 不动、旧 store 不需要回填;等价性由 `test/tokenizer-equivalence.test.mjs` 差分守住(冻结旧实现当标尺 + 固定输出契约 + 18 个边界串 + 5 个真实文件 + 2000 组固定种子随机拼接 + `stem` 两态)。
|
|
8
|
+
- **同会话 A/B**(Node 24.19 / WSL2 / 20 vCPU,同一小时内交替跑、每个版本两遍,引用页缓存已热的那遍):TypeScript 整树(14,528 文件 / 95,316 条目)首次查询的 IDF 重建 **1.44–1.53 s → 0.94–0.96 s**(约 −35%),抽取 9.42–9.51 s → 8.79–8.95 s(−6%),冷索引 10.66 s → 10.00 s(−6%);文档为主的语料(249 文件 / 889 条目)抽取 242–252 ms → 216–219 ms(−13%)、IDF 58–59 ms → 43–44 ms(−26%)。查询 p50 无可测变化(在噪声内)。
|
|
9
|
+
- **已知代价**:极端构造输入(CJK 单字与拉丁字母逐字交替,如 `中a文a` 重复)实测 **0.97×**——段长恒为 1 时,正则产出的段数组比逐字累积多一层分配;真实代码与文档里不出现这个密度。README 的性能表是 2026-10-13 的历史测量口径,本轮未重测。
|
|
10
|
+
|
|
11
|
+
### 修复
|
|
12
|
+
|
|
13
|
+
- **`save_lesson` 带 `id` 更新时静默改 `kind`**:`kind` 的 `'lesson'` 默认值此前也作用于就地更新,改一条 decision/procedure 的 `fix`/`reason` 会把它降级成 lesson;现在只在新建时补默认值,更新只覆盖调用方显式传入的字段。
|
|
14
|
+
- **watch / lazy 对超过 `maxFileSizeMb` 的文件只跳过、不摘旧条目**:文件涨过阈值后旧 entries 会永久可检索(watch 还把 `mtime:size` 写进快照,永远不再重试)。两处现在与 `index_repo` 一样走 `drop`;watch 轮询发现根已被删除时也不再经 `save()` 把根重新创建出来。
|
|
15
|
+
- **`archive_task` 归档后不解绑**:绑定会话下一步仍会注入归档任务卡与任务级 insights,任务级记忆也继续被召回;现在工具与 `/tasks archive` 一样清掉所有绑定,注入/召回侧同时挡 `task.archived`。
|
|
16
|
+
- **`autoContext.maxTokens: 0` 仍注入 root notice**:`buildInjection` 已零预算,但 `injectForStep` 在预算外补了“记忆根是推定的”提示;现在 0 预算时连状态声明也不发,真正零注入。
|
|
17
|
+
- **`watch_repo({watch:false})` 对已不存在的 root 重新创建目录**:stop 路径不再 load/commit 缺失根;避免 `save()` 的 `mkdirSync` 把用户刚停掉的路径复活。
|
|
18
|
+
- **宿主的 `str_replace_editor` 不被识别**:`ops` 现在按 `path` + `command` 把 create/str_replace/insert 归一成 `file-write`,`view` 不算写;TaskBridge 也把它的写/读分别记入任务热点文件。
|
|
19
|
+
- **面板 promote/demote 丢使用痕迹**:手工提升/降级此前直接走 `normalizeInsight`,丢掉 `triggerDerived`/`prev`/`lastHitAt`,也不执行 `maxProject`/`maxGlobalProcedures`;现在与自动提升共用 `carryUsageFields` 并收口容量。
|
|
20
|
+
- **空任务列表的 `/tasks` payload 缺 `root`**:跨标签页同步按项目根过滤,空列表时 root 为 null 会让本页失去项目作用域;现在空/非空两条路径都带 root。
|
|
21
|
+
- **`memoryDir` 为空 / `.` / `..` / 绝对路径时 store 落错位置**:空串与 `.` 让 `path.join(root, …)` 等于项目根本身,`save()` 的自我忽略会在那里写内容为 `*` 的 `.gitignore`(整个仓库从 git 视角消失),`format.json` / `shards/` 也会污染源码树;`..` 则把 store 写到根外。现在 `safeMemoryDirName()` 是读写两侧唯一的归一入口:空/空白、`.`、`..`、含 `..` 段、绝对路径(POSIX `/x`、Windows `C:\x`)一律回落到默认目录并告警一次;根内的嵌套目录(`a/b`)仍允许。
|
|
22
|
+
- **POSIX 上把 Windows 盘符路径当项目内相对路径**:`normalizeCitationFiles()` 现在丢弃 `C:\...` 这类在本平台不是绝对路径的盘符路径,避免生成 `C:/...` 的假引用。
|
|
23
|
+
- **`GlobalStore` 缓存键大小写未归一**:Windows/macOS 上同一 `global.json` 的两种写法会建两个实例;现在与项目 store 一样走 `storeKey()`。
|
|
24
|
+
- `save_lesson` 的 `scope` 描述改为与实现一致:绑定任务时默认 `task`,否则 `project`。
|
|
25
|
+
- **体检脚本读不到自定义 `memoryDir`**:`skills/project-memory/scripts/pm-digest.mjs` 把 store 目录写死成 `<root>/.dsh-project-memory`,配了自定义 `memoryDir` 的项目只会得到「no memory store」。现在依次按 `--memory-dir <name>` / `DSH_PROJECT_MEMORY_DIR` / 默认名解析;都没命中时在项目根下一层按 `format.json` 标记找唯一候选并标注 `auto-detected`,多个候选不猜、报错点名怎么传参。
|
|
26
|
+
|
|
27
|
+
**测试**:新增 `test/audit-2026-11-02.test.mjs`(13 项:save_lesson kind 保留、watch/lazy 超限摘旧条目、archive_task 解绑与注入/召回守卫、maxTokens 0 零注入、watch stop/poll 不重建缺失根、str_replace_editor 的 ops/TaskBridge、手工 promote 保留字段与容量、空任务 payload root、空 memoryDir 归一、POSIX 盘符路径丢弃)与 `test/tokenizer-equivalence.test.mjs`(5 项:固定输出契约、18 个边界串、5 个真实语料文件、2000 组固定种子随机拼接、`stem` 两态——全部与冻结的旧实现逐字节比对)与 `test/memorydir-guard.test.mjs`(4 项:空/`.`/`..`/含 `..` 段/绝对路径回落默认目录且不移动 store、嵌套相对目录仍允许、默认告警对同一坏值只发一次、`memoryDir: '.'` 不把 `*` 写进项目根);`test/skill.test.mjs` 补 1 项(自定义 `memoryDir` 的三种解析路径 + 多候选不猜)。`npm test` **956 项 / 57 个文件**全绿、`npm run typecheck` 通过。
|
|
28
|
+
|
|
29
|
+
## 0.6.9 (2026-11-02)
|
|
30
|
+
|
|
31
|
+
**兼容**:无新增配置键,无 store 格式变更(启动时会顺手把 `watch.json` 里大小写重复的根条目合并成一条;文件格式不变)。三个既有键——`watchInterval` / `autoIndexOnFirstUse` / `llmQueryExpansion`——在 `Config` 里标成 `.volatile()`:这是宿主设置表单的准入条件(只有 volatile 字段能被 settings 接口写入),也让它们在运行中原地更新而不重启插件。profile / 命令行的写法完全不变。插件内部读取统一走 `cfgValue()`:volatile 字段在运行时是 ref(`.get()`),直接把 ref 当布尔会读错。升级后**需要重启一次 dsh**——volatile 元数据只在装配期解析。两处**行为变化**:① 扫描与懒索引都跳过隐藏路径(任一段以 `.` 开头,如 `.env` / `.github/**`),显式 `index_doc` 仍可索引(已存在的隐藏路径条目会在下一次完整扫描被清理);② `autoContext.maxTokens: 0` 现在真的零注入(此前被 `|| 400` 顶回默认值)。
|
|
32
|
+
|
|
33
|
+
### 新增:插件页上的可视化设置(web)
|
|
34
|
+
|
|
35
|
+
- 座位是 `plugins.bundle.config`(key = 包名):**插件 → 项目记忆 → 详情页**,在描述与行列表之间出现「常用设置」卡片。
|
|
36
|
+
- 三个手调旋钮:启动时全量索引(`autoIndexOnFirstUse`,下次启动生效)、刷新间隔(`watchInterval`,秒)、检索时扩展查询(`llmQueryExpansion`)。后台监视**刻意不给开关**:关掉只会让记忆越来越旧,不是一个"偏好";`lazyIndexing` / `enableTypeScript` 属于内部取舍,也留在 profile。
|
|
37
|
+
- 卡片默认收起(与宿主的插件卡片同构:标题 + 说明 + 箭头),展开后三行、底部右对齐保存;未保存时标题旁有一个"未保存"标记。保存走宿主 `settings` 接口(Config 校验 + revision fence),不另写配置文件——卡片始终是宿主那份配置的投影。
|
|
38
|
+
- 立即生效:`watchInterval` 由 `applyWatchSettings()` 按新值重排定时器;`llmQueryExpansion` 每次查询时读取。`autoIndexOnFirstUse` 是一次性启动动作,卡片上写明"下次启动生效"。
|
|
39
|
+
- 门控是**两层**且都是软依赖:客户端只在宿主同时提供 `slots` / `configForms` / `locale`、且 `project-memory` 命名空间已被提供时才注册;旧宿主(ui-primitives 没有对应控件)上零注册,并打一条点名原因的告警而不是静默消失。组件存在性判定必须接受 `forwardRef` 返回的**对象**(宿主的 `Button` 就是对象)——用 `typeof x === 'function'` 会把真实组件当成不存在,卡片整块消失。
|
|
40
|
+
- 其余旋钮(`memoryDir`、`roots.*`、扫描上限、insight / 反思 / 自动注入)**不进卡片**:它们要么一改就换数据位置,要么需要理解上下文,仍写 profile。
|
|
41
|
+
|
|
42
|
+
### 修复
|
|
43
|
+
|
|
44
|
+
- **watch 设置保存 / 回合结束不再停摆或误退避**:`start()` 先复位 `_stopped` 再判断进行中的轮询(设置页走 `stop() → start()`,否则那一轮结束后永久不再排下一轮);回合结束只在没有在飞 poll 时补扫,避免把"本轮无变化"误记成退避。
|
|
45
|
+
- **删除分片失败不再被当成"已经没了"**:`unlink` 对 Windows 的 EPERM/EBUSY 重试,仍失败则保留删除意图、下次 save 继续删(否则下一次 load 会把旧分片复活)。锁释放失败时把锁内容改成死进程,避免自己堵自己 10 分钟。
|
|
46
|
+
- **`explicit` 标记在重新索引时保留**:`applyFileUpdate()` 从旧记录继承 `explicit`,否则显式 `index_doc` 的 .gitignored 文件活不过下一轮扫描清理。
|
|
47
|
+
- **`experience.json` 迁移放进跨进程目录锁**:锁内重读磁盘再决定是否导入,两个 dsh 同时升级同一个旧 store 时不再互相覆盖。
|
|
48
|
+
- **畸形 store 容错**:`insights.items` / `tasks` / `watchlist` 里的 null 与非数组形状不再让全局召回或容量裁剪整段抛错;任务缺 `files` / `fileMeta` 在 `load()` 时归一(此前每次文件工具调用都会在 `touchTaskFile()` 抛错,热点追踪静默失效)。
|
|
49
|
+
- **增强队列的孤儿符号**:文件在排队增强期间被删除时,不再写一条没有 `files` 记录的孤儿符号(`unseen` 清理看不到它,查询却会一直命中)。
|
|
50
|
+
- **相对 `root` 按会话工作目录解析**:`resolveIndexRoot()` / `resolveSafeIndexRoot()` 以及 `index_repo` / `watch_repo` / `index_doc` 的显式 root 不再用宿主 `process.cwd()` 解析相对路径——web profile 下一个进程服务多个会话,cd 之后两者不是一回事。
|
|
51
|
+
- **扫描跳过隐藏路径的口径统一**:git 清单分支与 `walkDir` 回退都跳过任一段以 `.` 开头的路径(`.env`、`.github/**`、`.claude/**`),同一棵树 `git init` 前后语料一致;显式 `index_doc` 仍可索引隐藏文件。
|
|
52
|
+
- **`autoContext.maxTokens: 0` 真正零注入**:不再被 `cfg.maxTokens || 400` 顶回默认值(任务卡与条目都静默)。
|
|
53
|
+
- **`GlobalStore.markDirty()` 登记退出 flush**:`query_memory` 只改内存的 global 命中记账/派生 trigger 回填不会在进程退出时丢失(project store 有下一次 save 兜底,global 没有周期性 save 点)。
|
|
54
|
+
- **后台索引失败不再静默**:watch 的失败过去只写一行日志、懒索引的单文件失败被 `catch {}` 吞掉,用户看不到"有文件一直没进语料"。现在失败按根记进进程内账本(最多 50 条,成功即清),并随 `index_repo` / `memory_stats` 的输出一起报出。
|
|
55
|
+
- **Electron 宿主里 PDF 索引全灭(issue #10)**:pdf.js 只在 `isNodeJS` 为真时兜底 `workerSrc`,而宿主进程是 Electron 且 `process.type !== 'browser'` → 默认值整块跳过,每次解析都抛 `No "GlobalWorkerOptions.workerSrc" specified`。现在 `loadPdfjs()` 在 worker 未配置时用 `import.meta.resolve`(老 Node 退回 `createRequire`)解析 `pdf.worker.mjs` 的 `file://` URL 兜底;显式 `configurePdfjsWorker()` 与 pdf.js 自己的默认值仍优先。原实现里的 `configuredWorkerSrc` 分支因无人调用恒为假,纯 Node 测试里 `isNodeJS` 又恰好为真,所以这个洞从首版起一直没人发现(0.6.3 与 0.6.8 上都能复现),且失败只写一条 W 级日志。
|
|
56
|
+
- **大小写不同的同一目录不再被登记两次**:`watch_repo` 先以 `D:\proj`、后以 `d:\PROJ` 登记时,`watch.json` 会留两条、watch 每轮扫两遍,而 `watch_repo({watch:false})` 只删得掉其中一条(另一条下次启动复活)。`WatchManager` 与 watchlist 现在按 `storeKey()` 归一(保留第一次出现的写法;加载时顺手把老 store 里的重复条目合并)。
|
|
57
|
+
|
|
58
|
+
**测试**:新增 `test/pdfjs-host.test.mjs`(2 项:纯 Node 对照组;子进程里把 `process.type` / `process.versions.electron` 改成 Electron 宿主形态后解析 PDF,并断言正文命中——只断言"没抛错"会放过空正文的假成功)。新增 `test/settings-card.test.mjs`(10 项:三个 volatile 键与默认值(并断言其余键不进命名空间)、`cfgValue()` 的 ref/普通值双形状、空路径 `[[]]` 读成"全部重读"、watch 关停/改间隔即重排、整份 `apply()` 在 ref 形状 Config 上装配、槽位注册的 key 与命名空间、默认收起与展开后 3 行、`Button` 以 forwardRef 对象形状参与注册、命名空间未提供与缺 settings 控件两种零注册)。本轮另补 7 项回归:`maxTokens: 0` 零注入、相对 root 按会话 cwd 解析、git / walk 两种扫描的隐藏路径口径一致、懒索引也跳过隐藏路径、畸形任务缺 `files` 的归一、`GlobalStore.markDirty()` 进入退出 flush、watch 根与 watch.json 的大小写归一(2 项)。新增 `test/index-failures.test.mjs`(3 项:账本按根隔离与上限、懒索引失败登记与成功清除、`index_repo` 报出后台失败)。`npm test` **930 项 / 54 个文件**全绿、`npm run typecheck` 通过;`npm run build:client` 后 `client/` 零 diff(CI 也会复核产物与源码一致)。
|
|
59
|
+
|
|
1
60
|
## 0.6.8 (2026-10-30)
|
|
2
61
|
|
|
3
62
|
**兼容**:条目上多一个可选的 `mtimeMs`(旧条目缺省时按老行为整读 + 哈希)。无新增配置键,无破坏性 store 变更。懒索引不再对已有记录的文件问 gitignore,新文件仍问。
|
package/README.md
CHANGED
|
@@ -50,18 +50,18 @@ Each indexed project has its own store at `<root>/.dsh-project-memory/`. It keep
|
|
|
50
50
|
|
|
51
51
|
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).
|
|
52
52
|
|
|
53
|
-
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.
|
|
53
|
+
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. Hidden paths (any path segment starting with `.`) and the built-in ignore list (`node_modules`, `dist`, …) are skipped in both modes; a directory that is not a git work tree falls back to a plain walk with the same filter. Lazy indexing applies the same check when a file first enters the store; a file that is already indexed is refreshed on later reads without asking git again — if `.gitignore` starts excluding it, the `index_repo` / `watch_repo` scan drops it. An explicit `index_doc` bypasses both `.gitignore` and the hidden-path filter, but still respects `roots.exclude`, readability and the size limit, and its entry survives later scan passes for as long as the file exists.
|
|
54
54
|
|
|
55
55
|
| Tool | Purpose |
|
|
56
56
|
|---|---|
|
|
57
57
|
| `index_doc file_path` | Index one document (PDF/MD/txt): chunk, summarize deterministically, and store with a `path:line` citation. Unchanged files are skipped. |
|
|
58
58
|
| `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 (an entry created by an explicit `index_doc` is kept while its file still exists), and documents are cross-linked to symbols. A non-existent or excluded root is rejected before anything is written. |
|
|
59
59
|
| `watch_repo root` | Enable automatic refresh: a background poll detects new and changed files and re-indexes only those. A watched root is recorded in that project's store, so it resumes when dsh starts there; a non-existent or excluded root is refused, roots that disappear are dropped rather than re-created. |
|
|
60
|
-
| `memory_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. |
|
|
60
|
+
| `memory_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. Background index failures (watch or lazy, per root, most recent 50) are reported alongside, so a file that never made it into the corpus stays visible. |
|
|
61
61
|
| `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. |
|
|
62
62
|
| `list_tasks` | List task records for the project (archived marked). Call first in a new session before continuing work. |
|
|
63
63
|
| `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. |
|
|
64
|
-
| `archive_task` | Archive a task (hide from default views, exclude from capacity, stop syncing). `select_task` restores it. |
|
|
64
|
+
| `archive_task` | Archive a task (hide from default views, exclude from capacity, stop syncing, unbind the sessions that had it selected; archived tasks are also skipped by injection and recall). `select_task` restores it. |
|
|
65
65
|
| `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. |
|
|
66
66
|
| `/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. |
|
|
67
67
|
| `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. |
|
|
@@ -123,9 +123,9 @@ The workflow panel is collapsible, adapts to dsh and theme plugin styles, and of
|
|
|
123
123
|
|
|
124
124
|
| Key | Default | Meaning |
|
|
125
125
|
|---|---|---|
|
|
126
|
-
| `memoryDir` | `.dsh-project-memory` | store directory inside each indexed root |
|
|
126
|
+
| `memoryDir` | `.dsh-project-memory` | store directory inside each indexed root. Must stay a relative path inside the root: `.`, `..`, any `..` segment or an absolute path falls back to the default with one warning (otherwise the store lands outside the root, or on the root itself and self-ignores the whole repository) |
|
|
127
127
|
| `chunkChars` / `maxChunksPerFile` | 3000 / 40 | max chars per document chunk, max chunks per document |
|
|
128
|
-
| `maxFileSizeMb` | 10 | skip documents (incl. PDF) and code files larger than this (MB); see the per-file memory budget below |
|
|
128
|
+
| `maxFileSizeMb` | 10 | skip documents (incl. PDF) and code files larger than this (MB); entries of an already-indexed file that later grows past the cap are dropped on the next scan / watch pass; see the per-file memory budget below |
|
|
129
129
|
| `maxPdfPages` | 1000 | PDF page cap |
|
|
130
130
|
| `maxOutputChars` | 8000 | cap for `query_memory` result text (chars) |
|
|
131
131
|
| `lazyIndexing` | true | index files the moment the model reads them |
|
|
@@ -139,7 +139,7 @@ The workflow panel is collapsible, adapts to dsh and theme plugin styles, and of
|
|
|
139
139
|
| `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 |
|
|
140
140
|
| `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** |
|
|
141
141
|
| `reflection.enabled` | false | LLM reflection, **draft-only at task level** (fires on task switch-away / archive). `cooldownMs` `1800000`, `maxLessonsPerReflect` `3`, `maxDecisionsPerReflect` `2` |
|
|
142
|
-
| `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` |
|
|
142
|
+
| `autoContext.enabled` | true | silent injection wrapper (resident task card + gated items); inert until the host exposes a resolvable session cwd. `maxTokens` `400` (per step; `0` turns injection off entirely), `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` |
|
|
143
143
|
| `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 |
|
|
144
144
|
| `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 |
|
|
145
145
|
| `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" |
|
|
@@ -169,7 +169,7 @@ When the root comes from the working directory, the model gets one notice per se
|
|
|
169
169
|
|
|
170
170
|
`deny` only decides whether the directory itself can be a root: when a parent is already a root, files under a denied child are still indexed by that parent — use `exclude` (or `.gitignore`, which the git-aware scan already honours) to drop the files too. Explicit `index_doc` also respects `exclude` and returns `Not indexed` for a file under it.
|
|
171
171
|
|
|
172
|
-
Priority is `exclude` > `deny` > `allow` > built-in list. `allowUnsafeRoots: true` only releases the built-in list; `deny` / `exclude` still win. The same verdict is shared by explicit tool calls, lazy indexing, watch, the session audit trail and TaskBridge. Roots refused by the current policy are dropped from `watch.json` on startup. Configure under `config:` of `- id: project-memory
|
|
172
|
+
Priority is `exclude` > `deny` > `allow` > built-in list. `allowUnsafeRoots: true` only releases the built-in list; `deny` / `exclude` still win. The same verdict is shared by explicit tool calls, lazy indexing, watch, the session audit trail and TaskBridge. Roots refused by the current policy are dropped from `watch.json` on startup. Configure under `config:` of `- id: project-memory`.
|
|
173
173
|
|
|
174
174
|
**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.
|
|
175
175
|
|
|
@@ -203,6 +203,8 @@ Settings live in the plugin's config object. To change them, add an override ent
|
|
|
203
203
|
|
|
204
204
|
Only list the keys you want to change; the rest fall back to the plugin defaults. Verify the result with `dsh --profile web --dump-config`.
|
|
205
205
|
|
|
206
|
+
**On the web profile, three of these keys also have a visual card.** It sits at **Plugins → Project memory → detail page → Common settings** (`plugins.bundle.config`, keyed by package name): `autoIndexOnFirstUse`, `watchInterval` (seconds) and `llmQueryExpansion`. Saving goes through the host's `settings` interface — the card is a projection of the same config the profile override above feeds, not a separate file. `watchInterval` and `llmQueryExpansion` take effect immediately (the poll timer is re-armed, the expansion flag is read per query); `autoIndexOnFirstUse` is a one-off startup action, so the card says "effective next start". Everything else — `memoryDir`, `roots.*`, scan caps, insight / reflection / autoContext — deliberately stays in the profile: those either move the store or need context a three-row card cannot carry, and there is no switch for background watching (turning it off only lets memory go stale). On a host that does not offer the `slots` / `configForms` / `locale` services the card registers nothing and logs one warning naming the missing piece, rather than disappearing silently. These three are resolved when the plugin is assembled, so **restart dsh once after upgrading** (saving the card itself needs no restart).
|
|
207
|
+
|
|
206
208
|
For a one-off run without editing the profile, pass the override as a CLI patch overlay:
|
|
207
209
|
|
|
208
210
|
```bash
|
|
@@ -241,7 +243,7 @@ Four corpora, one Linux machine (Node 24.19), each run twice with the **second,
|
|
|
241
243
|
| Cold load | 10,000 files | 117 ms |
|
|
242
244
|
| Hot lazy re-index (single file) | 10k files | p50 5.5 ms / max 8.4 ms |
|
|
243
245
|
|
|
244
|
-
> Generated code (~4–5 symbols/file), measured 2026-10-13. 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 (**141 ms at 40k entries**, 68 ms at 20k, 17 ms at 4k); later queries hit it.
|
|
246
|
+
> Generated code (~4–5 symbols/file), measured 2026-10-13. 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 (**141 ms at 40k entries**, 68 ms at 20k, 17 ms at 4k); later queries hit it. Those IDF figures are the pre-0.6.10 baseline — the 0.6.10 tokenizer rewrite makes that rebuild roughly a third faster on the same corpus (same-session A/B, numbers in the CHANGELOG).
|
|
245
247
|
|
|
246
248
|
### Reproduce it on your own project
|
|
247
249
|
|
|
@@ -283,7 +285,7 @@ These commands are for **maintaining the plugin code** — regular users do not
|
|
|
283
285
|
|
|
284
286
|
```bash
|
|
285
287
|
npm install
|
|
286
|
-
npm test #
|
|
288
|
+
npm test # 956 tests
|
|
287
289
|
npm run eval:injection # synthetic pool P/R: precision 0.93 / recall 1.00, + a 3-scenario hint-only group
|
|
288
290
|
npm run eval:injection -- --store .dsh-project-memory/insights.json # replay on YOUR store; control group is a hard gate
|
|
289
291
|
npm run selfcheck:triggers # which entries can still push, which declarations are dead (reads your local store)
|
package/README.zh-CN.md
CHANGED
|
@@ -48,18 +48,18 @@ dsh plugin --profile web add @yolk_vat-y/dsh-project-memory -w
|
|
|
48
48
|
|
|
49
49
|
以下工具由 **agent 自动调用**,无需用户手动输入。在对话中直接说自然语言即可——例如「给这个项目建个索引」或「auth 模块是干嘛的」,或者正常开发即可——agent 会自动调用对应工具。默认开启「读到即索引」:模型读哪个文件,就顺便索引哪个文件,记忆在你干活的过程中自然积累。`watch_repo` 让显式监听的根目录在后台保持新鲜;`index_repo` 强制对项目做一次全量回填(未变更文件自动跳过)。
|
|
50
50
|
|
|
51
|
-
在 git 工作树里,语料就是 `git ls-files --cached --others --exclude-standard` 的清单——已跟踪文件,加上未被忽略的未跟踪文件——因此 `.gitignore
|
|
51
|
+
在 git 工作树里,语料就是 `git ls-files --cached --others --exclude-standard` 的清单——已跟踪文件,加上未被忽略的未跟踪文件——因此 `.gitignore`(含嵌套规则)决定什么会被记忆。隐藏路径(任一段以 `.` 开头)与内置忽略名单(`node_modules`、`dist` …)在两种模式下都跳过;不是 git 工作树的目录退回普通遍历,套用同一套过滤。「读到即索引」只在文件**首次入库**时套用同一判据;已入库的条目后续只刷新内容、不再问 git——等 `.gitignore` 开始排除它时,由 `index_repo` / `watch_repo` 的扫描清理摘掉。显式 `index_doc` 不受 `.gitignore` 与隐藏路径过滤限制,但仍服从 `roots.exclude`、可读性与体积上限,且只要文件还在,它的条目就能活过后续扫描清理。
|
|
52
52
|
|
|
53
53
|
| 工具 | 用途 |
|
|
54
54
|
|---|---|
|
|
55
55
|
| `index_doc file_path` | 索引单个文档(PDF/MD/txt):分块、确定性摘要,带 `路径:行号` 入库。未变更文件自动跳过。 |
|
|
56
56
|
| `index_repo root` | 索引整个项目:文档生成确定性摘要,代码文件生成零 token 符号表。增量更新,store 跟随文件清单:已删除、被忽略或移走的文件会被清理(显式 `index_doc` 的条目只要文件还在就保留);文档与符号交叉链接。根目录不存在或在排除名单上时,会在写入任何内容前拒绝。 |
|
|
57
57
|
| `watch_repo root` | 启用自动刷新:后台轮询检测新增/变更文件,仅重抽这些文件。监听根会记在该项目的 store 里,在该项目下启动 dsh 时恢复监听;不存在或在排除名单上的根目录会被拒绝,已消失的根目录会被丢弃而不是被重新创建。 |
|
|
58
|
-
| `memory_stats root` |
|
|
58
|
+
| `memory_stats root` | 查看记忆库内容:总量、最近索引时间,以及按时间排序的逐文件清单。后台索引失败(watch / 懒索引,按根记账、最多 50 条)也会一并报出,让「文件一直没进语料」可见。 |
|
|
59
59
|
| `query_memory query` | 对文档、符号、经验与 insight 执行排序检索,可选 LLM 查询扩展。`type` 选择层(`all` / `doc` / `symbol` / `experience` / `insight` / `task`)。返回带相对分数、引用或 insight id、以及文档→符号链接的结果。 |
|
|
60
60
|
| `list_tasks` | 列出本项目任务记录(含归档,带标记)。新会话/续接前先调用。 |
|
|
61
61
|
| `select_task` | 将会话绑定到某任务(此后 todo 清单与读文件同步进该任务)。按 `taskId` 精确绑定,或按 `title` 完全匹配(多个同名返回候选;无则新建)。带 title 可改名;自动解归档。 |
|
|
62
|
-
| `archive_task` |
|
|
62
|
+
| `archive_task` | 归档任务(隐藏默认视图、不占容量、停止同步、清掉选中它的会话绑定;归档任务也不再参与注入与召回)。`select_task` 可恢复。 |
|
|
63
63
|
| `show_task_panel` | 在 UI 中打开任务面板。用户要求查看任务列表或你想展示面板时调用。 |
|
|
64
64
|
| `/tasks`(用户输入,不经模型) | 唯一的用户命令:展示任务栈并驱动工作流卡片。其余动作是它的**子动词**,由卡片按钮调用:`switch` / `archive` / `unbind` / `rename` / `todos …` / `step` / `step-move` / `step-text` 为任务动作,`insight list [scope] [offset] [limit]` / `confirm` / `promote` / `demote` / `archive` / `restore` / `delete` / `save` / `edit` 为记忆动作。 |
|
|
65
65
|
| `remember problem solution` | 保存经验笔记。它就是 `kind: 'experience'` 的 insight——与教训 / 决策 / 流程同库、同去重、同删除入口。相似问题合并或覆盖而非重复。 |
|
|
@@ -121,9 +121,9 @@ TaskPanel (Container)
|
|
|
121
121
|
|
|
122
122
|
| 键 | 默认值 | 含义 |
|
|
123
123
|
|---|---|---|
|
|
124
|
-
| `memoryDir` | `.dsh-project-memory` |
|
|
124
|
+
| `memoryDir` | `.dsh-project-memory` | 每个被索引根目录内的存储目录。必须是根内的相对路径:`.`、`..`、含 `..` 段或绝对路径都会回落到默认目录并告警一次(否则 store 会落到根外,或落到根上并把整个仓库自我忽略掉) |
|
|
125
125
|
| `chunkChars` / `maxChunksPerFile` | 3000 / 40 | 每个文档块最大字符数、每文档最大块数 |
|
|
126
|
-
| `maxFileSizeMb` | 10 | 大于该值(MB)的文档(含 PDF
|
|
126
|
+
| `maxFileSizeMb` | 10 | 大于该值(MB)的文档(含 PDF)/代码文件跳过;已经索引过的文件后来涨过阈值,旧条目会在下一轮扫描 / watch 时摘掉;峰值系数见下文「单文件内存预算」 |
|
|
127
127
|
| `maxPdfPages` | 1000 | PDF 页数上限 |
|
|
128
128
|
| `maxOutputChars` | 8000 | `query_memory` 返回文本上限(字符) |
|
|
129
129
|
| `lazyIndexing` | true | 模型读取文件的瞬间即索引 |
|
|
@@ -137,7 +137,7 @@ TaskPanel (Container)
|
|
|
137
137
|
| `tasklist.enabled` / `tasklist.syncHostOnAdopt` | true / true | TaskBridge 自动同步(由会话 todo 清单与文件读取沉淀任务实体);绑定任务时把其步骤推给宿主任务清单,使 dsh 镜像该任务 |
|
|
138
138
|
| `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 去重 / 自动覆盖 / 近邻提示 / 删除上限 / 强化 / 提升 / 容量 / 归档设置。`autoMergeCos` / `hintCos` 设 `0` 表示**关闭**那条带 |
|
|
139
139
|
| `reflection.enabled` | false | LLM 反思,**只写任务级草稿**(触发于任务切走 / 归档)。`cooldownMs` `1800000`、`maxLessonsPerReflect` `3`、`maxDecisionsPerReflect` `2` |
|
|
140
|
-
| `autoContext.enabled` | true | 静默注入包装(常驻任务卡 + 受门槛约束的条目);宿主无法解析会话 cwd 时完全透传。`maxTokens` `400
|
|
140
|
+
| `autoContext.enabled` | true | 静默注入包装(常驻任务卡 + 受门槛约束的条目);宿主无法解析会话 cwd 时完全透传。`maxTokens` `400`(单轮;`0` = 完全关闭注入)、`editedMax` `3`(任务卡显示的最近"编辑中"文件数)、`signalMinRatio` `0.5`(提示至少达到该层最高分的一半)、`skipEchoSelfTodo` `true`、`budgetLog` `off`、`reinjectItemsAfter` `0`(同一条 insight 重复注入的冷却步数)、`rootNotice` `true` |
|
|
141
141
|
| `autoContext.gateCooldownSteps` | 2 | **准入旋钮**:两次*条目*注入之间至少隔几步(常驻任务卡不受限——它是状态快照)。这是"别频繁注入"的主旋钮 |
|
|
142
142
|
| `autoContext.maxItemsPerSession` / `autoContext.maxItemCharsPerSession` | 60 / 24000 | **runaway 保险丝,不是节流阀** —— 按条数与字符计的每会话硬上限:一旦触顶,本会话余下部分条目通道持续沉默 |
|
|
143
143
|
| `autoContext.hintMinCoverage` | 0.45 | 提示通道的**绝对**下限:条目覆盖了查询多少 IDF 加权信息量。只用相对阈值分不出"有信号"和"矮子里拔将军" |
|
|
@@ -167,7 +167,7 @@ TaskPanel (Container)
|
|
|
167
167
|
|
|
168
168
|
注意 `deny` 只决定这个目录自己能不能当根:父目录已经是根时,`deny` 的子目录仍会被父根索引——要连文件一起排除请用 `exclude`(或 `.gitignore`,git 仓库里的扫描本来就尊重它)。显式 `index_doc` 也服从 `exclude`,被排除的文件会返回 `Not indexed`。
|
|
169
169
|
|
|
170
|
-
优先级是 `exclude` > `deny` > `allow` > 内置名单。`allowUnsafeRoots: true` 只放开内置名单,`deny` / `exclude` 仍然优先。生效面是同一套判定:显式工具调用、懒索引、watch、会话审计、任务桥。被当前策略拒绝的根会在下次启动时从 `watch.json` 摘掉。配置写在 `- id: project-memory` 的 `config:`
|
|
170
|
+
优先级是 `exclude` > `deny` > `allow` > 内置名单。`allowUnsafeRoots: true` 只放开内置名单,`deny` / `exclude` 仍然优先。生效面是同一套判定:显式工具调用、懒索引、watch、会话审计、任务桥。被当前策略拒绝的根会在下次启动时从 `watch.json` 摘掉。配置写在 `- id: project-memory` 的 `config:` 下。
|
|
171
171
|
|
|
172
172
|
**扫描上限。** 单次扫描最多 `maxScanFiles` 个文件(20000)、`maxScanDepth` 层目录(12)。被截断时,`index_repo` 的结果里会说明,watcher 每个根记一行,且不会删除没扫到的条目。**读不到的目录**(如 `EACCES`)同样算一次截断扫描并在结果里点名:读失败不等于被删除。
|
|
173
173
|
|
|
@@ -201,6 +201,8 @@ store 建在被索引的目录树里,并且**自我忽略**:自己目录内
|
|
|
201
201
|
|
|
202
202
|
只需列出要改的键,其余键回落到插件默认值。用 `dsh --profile web --dump-config` 验证生效。
|
|
203
203
|
|
|
204
|
+
**web profile 上有三个键同时提供可视化设置。** 位置是**插件 → 项目记忆 → 详情页 → 常用设置**(`plugins.bundle.config`,key 为包名):`autoIndexOnFirstUse`、`watchInterval`(秒)、`llmQueryExpansion`。保存走宿主的 `settings` 接口——卡片始终是上面那份 profile 配置的投影,不另写文件。`watchInterval` 与 `llmQueryExpansion` 立即生效(轮询定时器当场重排,扩展开关每次查询时读取);`autoIndexOnFirstUse` 是一次性启动动作,卡片上写明"下次启动生效"。其余旋钮——`memoryDir`、`roots.*`、扫描上限、insight / 反思 / 自动注入——**刻意留在 profile**:它们要么一改就换数据位置,要么需要理解上下文,三行卡片承载不了;后台监视也**不给开关**(关掉只会让记忆越来越旧)。宿主不提供 `slots` / `configForms` / `locale` 时卡片零注册,并打一条点名原因的告警,而不是静默消失。这三个键在插件装配期解析,所以**升级后需要重启一次 dsh**(在卡片里保存则无需重启)。
|
|
205
|
+
|
|
204
206
|
不想改 profile 文件、只想临时试一次,可用 CLI 补丁覆盖:
|
|
205
207
|
|
|
206
208
|
```bash
|
|
@@ -239,7 +241,7 @@ dsh web --patch ./config.yml
|
|
|
239
241
|
| 冷加载 | 10,000 文件 | 117 ms |
|
|
240
242
|
| 热路径懒记忆 | 单文件重记忆+落盘 | p50 5.5 ms / 最大 8.4 ms (10k) |
|
|
241
243
|
|
|
242
|
-
> 合成基准:生成代码(~4–5 符号/文件),实测于 2026-10-13。复现命令 `npm run bench:synthetic -- 5000`(脚本 `scripts/bench-synthetic.mjs`)。测量纯索引开销,不含 LLM 调用。写入后的首次查询会重建 IDF 缓存(**40k 条目 141 ms**,20k 条目 68 ms,4k 条目 17 ms
|
|
244
|
+
> 合成基准:生成代码(~4–5 符号/文件),实测于 2026-10-13。复现命令 `npm run bench:synthetic -- 5000`(脚本 `scripts/bench-synthetic.mjs`)。测量纯索引开销,不含 LLM 调用。写入后的首次查询会重建 IDF 缓存(**40k 条目 141 ms**,20k 条目 68 ms,4k 条目 17 ms),后续查询命中缓存。这组 IDF 数字是 0.6.10 之前的基线——0.6.10 的分词重写在同一语料上把这次重建缩短约三分之一(同会话 A/B,数字见 CHANGELOG)。
|
|
243
245
|
|
|
244
246
|
### 自己复现这些数字
|
|
245
247
|
|
|
@@ -281,7 +283,7 @@ node scripts/bench.mjs /你的/项目路径 [--json] [--samples 100] [--no-pdf]
|
|
|
281
283
|
|
|
282
284
|
```bash
|
|
283
285
|
npm install
|
|
284
|
-
npm test #
|
|
286
|
+
npm test # 956 项测试
|
|
285
287
|
npm run eval:injection # 合成池 P/R:精确率 0.93 / 召回率 1.00,另有 3 个 hint-only 场景
|
|
286
288
|
npm run eval:injection -- --store .dsh-project-memory/insights.json # 用你自己的 store 重放;对照组是硬闸门
|
|
287
289
|
npm run selfcheck:triggers # 哪些条目还推得动、哪些声明是死的(读你本地的 store)
|