@kingsleyasher/dsh-knowledge-base 3.1.6 → 3.1.7

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.
@@ -2,27 +2,33 @@
2
2
 
3
3
  [English](PROJECT-RECORD.en.md) · [简体中文](PROJECT-RECORD.md)
4
4
 
5
- <!-- project-record-version: 3.1.6 -->
5
+ <!-- project-record-version: 3.1.7 -->
6
6
 
7
- **Plugin 3.1.6 and desktop client 2.0.3 · 2026-11-26.**
7
+ **Plugin 3.1.7 and desktop client 2.0.3 · 2026-12-03.**
8
8
 
9
- ## 2026-11-26 · Inbox completion receipts and knowledge-base checks
9
+ ## 2026-12-03 · Confirmation and retry after a large index drop
10
10
 
11
- The shared library stores inbox completions in `.kbmeta/shared-state.json`. Once the record is saved, `kb_inbox complete` returns the completed record and reports index synchronization in `indexSync`. When a large drop triggers index protection, `kb_check` returns scan differences, `execution`, `quality`, and the reason the index was kept. The previous index and recovery queue remain available. Shared-service checks honor `recover:true`. Host disconnects and authorization failures return errors that satisfy the tool output contract.
11
+ When the index loses a significant share of its entries, `kb_check` returns the diff, entry counts, and a confirmation token. After reviewing the changes, the user can retry with `confirmDrop` in embedded or shared mode. The inbox keeps the completed archive receipt and reports that index confirmation is pending. A successful confirmation preserves a snapshot of the old index and resumes background maintenance. With `recover=true`, the recovery queue is consumed after the index is written. A repeated request for the same pending index change logs the guard warning once.
12
12
 
13
- Windows shared-service regression coverage includes completion, same-request retry, index drop protection, and recovery-queue retention. Host error responses were checked for required fields. Repeating a request after validation fails returns the same invalid-argument error.
13
+ Focused Windows regression checks cover the shared-service inbox, invalid and stale tokens, snapshot preservation, and the recovery queue. The revised plugin 3.1.7 build includes this fix.
14
14
 
15
- ## 2026-11-26 · Plugin npm 3.1.5 candidate · Update discovery and installation
15
+ ## 2026-12-03 · Plugin 3.1.7 · Search results and Host authentication
16
16
 
17
- The npm edition checks the registry for stable versions of its own package. With the knowledge base UI open, shared service installs that support safe handoff can update automatically or retry manually from the version badge. The updater checks npm SHA-512, package identity, version, and build, then uses the transaction installer and retains the recovery record. Embedded mode detects updates and leaves installation to DSH. The legacy GitHub edition retains its separate package identity. In an isolated profile on Windows DSH Desktop 0.2.2-rc.5, a 3.1.3 test fixture running the candidate updater automatically installed the public npm 3.1.4 package. The transaction committed and the plugin UI and shared service both loaded the new version. npm 3.1.5 publication is pending.
17
+ Full-text search hits carried internal placeholders such as `text: undefined`. The embedded plugin and shared service now use the same code to construct the `kb_search` JSON response, preserving titles, paths, snippets, revisions, and coverage notes. A focused Windows regression test used real Markdown and verified that both matching and empty results survive a lossless JSON round trip. Plugin 3.1.7 includes this fix.
18
18
 
19
- <!-- project-record-version: 3.1.4 -->
19
+ Embedded and shared mode verify DSH Host identity before reading or changing settings, returning handoff status, or subscribing to events. Requests are rejected when the session is missing, the identity lacks access, or Host authentication is unavailable. Focused HTTP tests cover signed-in and unsigned requests, non-owners, cross-site requests, and authentication service failures.
20
20
 
21
- **Plugin 3.1.4; desktop client 2.0.3 · 2026-11-16.**
21
+ ## 2026-11-27 · File tree session cache
22
22
 
23
- ## 2026-11-20 · npm distribution candidate
23
+ The desktop client reuses loaded folders, original-file categories and pages within the current session, and combines concurrent requests for the same branch. Loaded rows remain available across view changes and sidebar collapse. File changes refresh affected branches while keeping the current rows visible. Changes to the library, sort order, query or permissions invalidate the relevant cache and discard outdated responses.
24
24
 
25
- Prepared a separate npm candidate from the released plugin 3.1.4: use @kingsleyasher/dsh-knowledge-base, adjust host and client registration, and disable the built-in installer that targets the legacy package path. Update the npm package via the host manager. The official GitHub package and legacy update feed remain unchanged. Entry import, update guards and pack inventory checks passed; real host loading, upgrades and coexistence remain unverified.
25
+ The shared service bounds concurrent directory metadata reads and invalidates affected listings when a file changes. Original-file categories reuse the private path set for each catalog snapshot. Focused Windows regression checks cover branch caching, file changes, permissions and inbox behavior. Client 2.0.3 and its paired plugin 3.1.6 were rebuilt from the merged source for local delivery. The filenames include their build IDs.
26
+
27
+ ## 2026-11-26 · Inbox completion receipts and knowledge-base checks
28
+
29
+ The shared library stores inbox completions in `.kbmeta/shared-state.json`. Once the record is saved, `kb_inbox complete` returns the completed record and reports index synchronization in `indexSync`. When a large drop triggers index protection, `kb_check` returns scan differences, `execution`, `quality`, and the reason the index was kept. The previous index and recovery queue remain available. Shared-service checks honor `recover:true`. Host disconnects and authorization failures return errors that satisfy the tool output contract.
30
+
31
+ Windows shared-service regression coverage includes completion, same-request retry, index drop protection, and recovery-queue retention. Host error responses were checked for required fields. Repeating a request after validation fails returns the same invalid-argument error.
26
32
 
27
33
  ## 2026-11-17 · OCR provider save validation
28
34
 
package/PROJECT-RECORD.md CHANGED
@@ -2,27 +2,33 @@
2
2
 
3
3
  [English](PROJECT-RECORD.en.md) · [简体中文](PROJECT-RECORD.md)
4
4
 
5
- <!-- project-record-version: 3.1.6 -->
5
+ <!-- project-record-version: 3.1.7 -->
6
6
 
7
- **插件 3.1.6,客户端 2.0.3 · 2026-11-26。**
7
+ **插件 3.1.7,客户端 2.0.3 · 2026-12-03。**
8
8
 
9
- ## 2026-11-26 · 收件箱完成回执与知识库自检
9
+ ## 2026-12-03 · 索引条目大幅减少后的确认重试
10
10
 
11
- 共享库的收件箱登记写入库内 `.kbmeta/shared-state.json`。登记成功后,`kb_inbox complete` 返回已完成记录,并用 `indexSync` 报告索引同步结果。索引降幅触发保护时,`kb_check` 返回扫描差异、`execution`、`quality` 和索引未写入的原因,保留原索引和恢复队列。共享服务的自检也处理 `recover:true`,宿主断连或拒绝调用时返回符合工具输出契约的错误。
11
+ `kb_check` 在索引条目显著减少时返回差异、条目数和确认令牌。用户核对后可用 `confirmDrop` 重试,内嵌与共享模式均支持。收件箱保留已完成的归档回执,并返回索引待确认状态。确认成功后保留旧索引快照并恢复后台维护,带 `recover=true` 时在写入成功后消费恢复队列。同一待确认的索引变化只记录一次保护告警。
12
12
 
13
- Windows 共享服务回归覆盖实际登记、同请求重试、索引降幅保护及恢复队列保留。另验证了宿主错误回执的必填字段。同时验证路径或来源校验失败后,以同一请求重试仍返回参数错误。
13
+ Windows 定向回归覆盖共享服务收件箱、无效和过期令牌、快照保留及恢复队列。这项修复纳入插件 3.1.7 的修订构建。
14
14
 
15
- ## 2026-11-26 · 插件 npm 3.1.5 候选 · 更新检测与安装
15
+ ## 2026-12-03 · 插件 3.1.7 · 搜索结果与宿主身份校验
16
16
 
17
- npm 版按包名检查 npm 的正式版更新。知识库界面打开时,支持安全停服的共享服务安装可以自动升级,也可从版本栏手动重试。更新核对 npm 的 SHA-512、包身份、版本和构建号,随后通过现有事务安装方式切换包、保留恢复记录。嵌入模式可检测新版,由 DSH 管理安装。旧 GitHub 版仍是独立包身份。在 Windows DSH 桌面 0.2.2-rc.5 的隔离配置中,使用候选代码构造的 3.1.3 测试版自动升级到 npm 正式 3.1.4,确认事务提交、插件界面及共享服务均加载新版。3.1.5 待发布。
17
+ 正文检索命中会带有 `text: undefined` 等内部占位字段。内嵌插件和共享服务现在用同一段代码构造 `kb_search` 的 JSON 返回值,保留标题、路径、摘要、修订号和检索说明。Windows 定向回归用实际 Markdown 验证了命中和零命中两种结果均可无损往返 JSON。这项修复纳入插件 3.1.7。
18
18
 
19
- <!-- project-record-version: 3.1.4 -->
19
+ 内嵌和共享模式的设置读取、修改、交接状态和事件订阅在进入处理器前统一通过 DSH 宿主认证。无有效会话、身份无权访问或宿主认证服务不可用时立即拒绝。定向 HTTP 测试覆盖已登录请求、未登录请求、非所有者、跨站请求和认证服务不可用。
20
20
 
21
- **插件 3.1.4;客户端 2.0.3 · 2026-11-16。**
21
+ ## 2026-11-27 · 文件树会话缓存
22
22
 
23
- ## 2026-11-20 · npm 发行候选
23
+ 桌面客户端在同一会话内复用已加载的目录、原件分类和分页结果,合并同一分支的并发请求。切换视图或收起文件栏后可继续浏览已加载内容。文件变动会刷新受影响的分支,后台刷新期间保留现有列表。切库、排序、查询条件或权限变化时,相关缓存失效,旧请求结果随之丢弃。
24
24
 
25
- 基于插件 3.1.4 正式包制作独立 npm 发行候选:改用 @kingsleyasher/dsh-knowledge-base,调整宿主和客户端注册身份,并停用会操作旧包路径的内置安装更新;npm 包请通过宿主管理器更新。正式 GitHub 安装包及旧更新通道不变。入口模块导入、更新阻断和打包清单检查通过;真实宿主加载、升级与共存仍待验证。
25
+ 共享服务限制目录元数据读取的并发数,并在侦测到文件内容或属性变化时清除受影响的目录缓存。原件分类按目录快照复用隐私路径集合。Windows 定向回归覆盖分支缓存、服务文件变更、权限和收件箱行为。客户端 2.0.3 与配套插件 3.1.6 从合并后的源码重建为本地交付,安装包文件名包含构建号。
26
+
27
+ ## 2026-11-26 · 收件箱完成回执与知识库自检
28
+
29
+ 共享库的收件箱登记写入库内 `.kbmeta/shared-state.json`。登记成功后,`kb_inbox complete` 返回已完成记录,并用 `indexSync` 报告索引同步结果。索引降幅触发保护时,`kb_check` 返回扫描差异、`execution`、`quality` 和索引未写入的原因,保留原索引和恢复队列。共享服务的自检也处理 `recover:true`,宿主断连或拒绝调用时返回符合工具输出契约的错误。
30
+
31
+ Windows 共享服务回归覆盖实际登记、同请求重试、索引降幅保护及恢复队列保留。另验证了宿主错误回执的必填字段。同时验证路径或来源校验失败后,以同一请求重试仍返回参数错误。
26
32
 
27
33
  ## 2026-11-17 · OCR 配置保存错误提示
28
34
 
package/README.md CHANGED
@@ -1,14 +1,12 @@
1
- > npm 发行版:请先阅读 [npm 版身份、更新与限制](NPM-EDITION.md)。
2
-
3
1
  # Personal Knowledge Base · Plugin and Desktop Client
4
2
 
5
- > **Plugin 3.1.6:** File-tree reads now cache the parsed catalog and exclusion policy by file identity, reuse directory listings behind directory/policy/catalog signatures, and skip the periodic full-library rescan when nothing changed. Large directories load much faster and periodic stalls are greatly reduced. Desktop client 2.0.3 is published as an unsigned installer; the stable update feed points at plugin 3.1.6 / client 2.0.3.
3
+ > **Plugin 3.1.7** fixes a JSON validation error when `kb_search` finds matches in DSH. Desktop client 2.0.3 is available as an unsigned installer.
6
4
 
7
5
  > **Update recovery patch:** fixes abandoned prepared receipts. An already blocked older updater needs the [one-time safe recovery](docs/UPDATE-RECOVERY.en.md) before a normal update.
8
6
 
9
7
 
10
8
 
11
- > **Plugin 3.1.6 / client 2.0.3.** Independent/shared-library operation, scoped updates and release/visual review fixes. [Release notes](RELEASE.en.md).
9
+ > **Plugin 3.1.7 / client 2.0.3.** Independent/shared-library operation, scoped updates and release/visual review fixes. [Release notes](RELEASE.en.md).
12
10
 
13
11
  > **2.4.6 updater limitation:** a pristine installation stuck on a pending receipt cannot self-repair from the feed alone. The [general recovery entry](docs/LEGACY-246-BOOTSTRAP.md) is a one-time external migration, not a zero-intervention update.
14
12
 
@@ -23,9 +21,9 @@
23
21
  | Product | Published version | Direct download | Release notes |
24
22
  |---|---|---|---|
25
23
  | **Desktop client · Windows x64** | **2.0.3** | **[⬇ Download client installer (EXE)](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/client-v2.0.3/KnowledgeWorkbench-2.0.3-Setup.exe)** | [Client Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/client-v2.0.3) |
26
- | **DSH knowledge-base plugin** | **3.1.6** | **[⬇ Download plugin (TGZ)](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.6/local-dsh-knowledge-base-3.1.6.tgz)** | [Plugin Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6) |
24
+ | **DSH knowledge-base plugin** | **3.1.7** | **[⬇ Download plugin (TGZ)](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.7/local-dsh-knowledge-base-3.1.7.tgz)** | [Plugin Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7) |
27
25
 
28
- Release entries: [client 2.0.3](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/client-v2.0.3) · [plugin 3.1.6](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6). Choose the correct installer/TGZ and verify its product-specific manifest and digest.
26
+ Release entries: [client 2.0.3](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/client-v2.0.3) · [plugin 3.1.7](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7). Choose the correct installer/TGZ and verify its product-specific manifest and digest.
29
27
 
30
28
  ## One library, two entry points
31
29
 
@@ -43,15 +41,15 @@ Release entries: [client 2.0.3](https://github.com/KingsleyAsher/Personal-Knowle
43
41
 
44
42
  Run the EXE to install. The bundled-runtime package includes its runtime. This is the standalone client installer, not a DSH plugin bundle.
45
43
 
46
- ### DSH plugin 3.1.6
44
+ ### DSH plugin 3.1.7
47
45
 
48
- **[Download local-dsh-knowledge-base-3.1.6.tgz](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.6/local-dsh-knowledge-base-3.1.6.tgz)** · [Release notes and assets](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6)
46
+ **[Download local-dsh-knowledge-base-3.1.7.tgz](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.7/local-dsh-knowledge-base-3.1.7.tgz)** · [Release notes and assets](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7)
49
47
 
50
48
  Install the TGZ through DSH plugin management. GitHub highlights only one Latest release, but both products have independent releases. Use the product links above or browse [all Releases](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases).
51
49
 
52
50
  Source, issues and future releases are maintained here. In [Releases](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases), choose the correct product: Windows Setup.exe for the client, TGZ for the plugin.
53
51
 
54
- Published plugin 3.1.6: [Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6) · [TGZ](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.6/local-dsh-knowledge-base-3.1.6.tgz). See [plugin usage](WORKBENCH.en.md) and [mirror information](MIRROR-RELEASES.md) for extensions and regional sources. Mirror availability can vary.
52
+ Published plugin 3.1.7: [Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7) · [TGZ](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.7/local-dsh-knowledge-base-3.1.7.tgz). See [plugin usage](WORKBENCH.en.md) and [mirror information](MIRROR-RELEASES.md) for extensions and regional sources. Mirror availability can vary.
55
53
 
56
54
  The existing client installer retains its paper-green interface and animations, requires an empty application directory and preserves personal data on uninstall. Client online checks and verified downloads are implemented; automatic in-place installation and activation remain unfinished. The plugin keeps its existing update manifests and installation flow.
57
55
 
package/README.zh-CN.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # 个人知识库 · 插件与客户端
2
2
 
3
- > **当前版本:** 插件 3.1.6 / 客户端 2.0.3 优化文件树与周期维护:目录、排除策略和列表按文件身份缓存,未变化时巡检不再全库扫描。下载与更新清单已同步;客户端安装器未签名,需空目录安装。
3
+ > **当前版本**为插件 3.1.7 和客户端 2.0.3。插件修复 DSH 中 `kb_search` 命中时的 JSON 校验错误。客户端安装器未签名,需空目录安装。
4
4
 
5
5
  > **自动更新补丁:** 修复历史准备事务阻塞;已被旧更新器阻塞时,先按[一次性安全恢复说明](docs/UPDATE-RECOVERY.md)处理,再正常更新。
6
6
 
7
7
 
8
8
 
9
- > **插件 3.1.6 / 客户端 2.0.3**。汇总独立/共库使用、局部更新及发布与界面审查修复。[更新说明](RELEASE.md)。下方分别提供两端正式版本号的发布附件。
9
+ > **插件 3.1.7 / 客户端 2.0.3**。汇总独立/共库使用、局部更新及发布与界面审查修复。[更新说明](RELEASE.md)。下方分别提供两端正式版本号的发布附件。
10
10
 
11
11
  > **2.4.6 旧更新器限制:** 已卡在待确认的原版安装不能只靠新更新源自愈;[通用恢复入口](docs/LEGACY-246-BOOTSTRAP.md) 是一次性外部恢复,不等同于零操作自动迁移。
12
12
 
@@ -21,9 +21,9 @@
21
21
  | 产品 | 已发布版本 | 直接下载 | 发布说明 |
22
22
  |---|---|---|---|
23
23
  | **知识库客户端 · Windows x64** | **2.0.3** | **[⬇ 下载客户端安装包(EXE)](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/client-v2.0.3/KnowledgeWorkbench-2.0.3-Setup.exe)** | [客户端 Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/client-v2.0.3) |
24
- | **DSH 知识库插件** | **3.1.6** | **[⬇ 下载插件包(TGZ)](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.6/local-dsh-knowledge-base-3.1.6.tgz)** | [插件 Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6) |
24
+ | **DSH 知识库插件** | **3.1.7** | **[⬇ 下载插件包(TGZ)](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.7/local-dsh-knowledge-base-3.1.7.tgz)** | [插件 Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7) |
25
25
 
26
- 当前发布入口:[客户端 2.0.3](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/client-v2.0.3) · [插件 3.1.6](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6)。请按产品选择 Windows 安装包或 TGZ,摘要与构建号以各自清单为准。
26
+ 当前发布入口:[客户端 2.0.3](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/client-v2.0.3) · [插件 3.1.7](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7)。请按产品选择 Windows 安装包或 TGZ,摘要与构建号以各自清单为准。
27
27
 
28
28
  ## 一个知识库,两个入口
29
29
 
@@ -41,15 +41,15 @@
41
41
 
42
42
  下载后运行 EXE 安装。客户端安装包包含运行时的,运行环境随包提供。该文件是独立客户端安装器,不是 DSH 插件。
43
43
 
44
- ### 插件 3.1.6 · DSH
44
+ ### 插件 3.1.7 · DSH
45
45
 
46
- **[下载 local-dsh-knowledge-base-3.1.6.tgz](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.6/local-dsh-knowledge-base-3.1.6.tgz)** · [版本说明与全部附件](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6)
46
+ **[下载 local-dsh-knowledge-base-3.1.7.tgz](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.7/local-dsh-knowledge-base-3.1.7.tgz)** · [版本说明与全部附件](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7)
47
47
 
48
48
  通过 DSH 插件管理器安装 TGZ。GitHub 首页只突出显示一个 Latest,但两个产品都有独立 Release;请使用上面的对应入口或查看 [全部 Releases](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases)。
49
49
 
50
50
  所有后续源码、问题反馈和发布统一放在本仓库。访问 [Releases](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases),按产品名称选择文件:客户端使用 Windows Setup.exe,插件使用 TGZ。不要将插件包当作客户端安装程序。
51
51
 
52
- 已发布插件 3.1.6:[GitHub Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.6) · [直接安装包](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.6/local-dsh-knowledge-base-3.1.6.tgz)。浏览器扩展及地区镜像见 [插件使用说明](WORKBENCH.md) 和 [镜像说明](MIRROR-RELEASES.md)。镜像可能延迟,以实际校验结果为准。
52
+ 已发布插件 3.1.7:[GitHub Release](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/tag/v3.1.7) · [直接安装包](https://github.com/KingsleyAsher/Personal-Knowledge-Base/releases/download/v3.1.7/local-dsh-knowledge-base-3.1.7.tgz)。浏览器扩展及地区镜像见 [插件使用说明](WORKBENCH.md) 和 [镜像说明](MIRROR-RELEASES.md)。镜像可能延迟,以实际校验结果为准。
53
53
 
54
54
  客户端现有安装器保留纸页绿界面与动画,要求空的应用安装目录;卸载保留个人资料与设置。客户端已接入在线检查与校验下载;自动覆盖安装和自动激活尚未完成。插件继续使用既有插件更新清单与安装流程。
55
55
 
package/RELEASE.en.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 2026-12-03 · Revised plugin 3.1.7 build · Index rebuild confirmation
2
+
3
+ When the index loses many entries, `kb_check` returns the diff and a confirmation token. After reviewing the changes, pass `confirmDrop` to rebuild the index and resume background maintenance. The rebuild preserves a snapshot of the old index. With `recover: true`, recovery records are cleared after the index is written. The inbox retains completed archive receipts and reports pending confirmation.
4
+
5
+ ## 2026-12-03 · Plugin 3.1.7 · Search results and Host authentication
6
+
7
+ Fixes `value is not lossless JSON` when `kb_search` finds matches in DSH. Windows regression tests used Markdown files to verify lossless JSON round trips for both matching and empty results.
8
+
9
+ Knowledge-base settings and events now require DSH Host authentication before data reads, writes, handoff status responses, or event subscriptions.
10
+
11
+ ## 2026-11-27 · Plugin 3.1.6 / client 2.0.3 · Local file tree build
12
+
13
+ - The desktop client reuses loaded folders, original-file categories and pages within the current session. Loaded rows remain available when reopening branches, switching views or reopening the sidebar.
14
+ - File changes refresh affected branches and keep rows visible while loading. Library, sort, search and permission changes discard the relevant cache and outdated responses.
15
+ - The paired shared service bounds concurrent directory metadata reads, refreshes file properties after external edits and reuses the private path set for original-file categories. The installer and paired TGZ come from the same source. The filenames identify the local builds.
16
+
1
17
  ## 2026-11-26 · Plugin 3.1.6 · Inbox receipts and library checks
2
18
 
3
19
  - `kb_inbox complete` returns the saved completion and reports index synchronization in `indexSync`.
package/RELEASE.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 2026-12-03 · 插件 3.1.7 修订构建 · 索引重建确认
2
+
3
+ 当索引条目大幅减少时,`kb_check` 会返回差异和确认令牌。核对后可提交 `confirmDrop` 重建索引并恢复后台维护。旧索引会保留快照。使用 `recover: true` 时,恢复记录在写入成功后清理。收件箱会保留已完成的归档回执,并提示索引待确认。
4
+
5
+ ## 2026-12-03 · 插件 3.1.7 · 搜索结果与宿主身份校验
6
+
7
+ 修复 DSH 上 `kb_search` 有结果时返回 `value is not lossless JSON` 的问题。Windows 上使用实际 Markdown 验证命中和零命中均可无损往返 JSON。
8
+
9
+ 知识库设置和事件接口现在先通过 DSH 宿主身份校验,再读取或修改数据、查询交接状态或建立事件订阅。
10
+
11
+ ## 2026-11-27 · 插件 3.1.6 / 客户端 2.0.3 · 文件树优化本地构建
12
+
13
+ - 桌面客户端在会话内复用已加载的目录、原件分类和分页。折叠重开、切换浏览方式和收起侧栏后再打开时,可继续使用已加载内容。
14
+ - 文件变动按分支刷新,刷新期间保留列表。切库、排序、搜索或权限改变时,丢弃相关缓存和过期结果。
15
+ - 配套共享服务限制目录元数据并发读取,及时刷新外部编辑后的文件属性,并复用原件分类的隐私路径集合。安装包与配套 TGZ 使用同一份源码构建,按文件名中的构建号识别本地交付。
16
+
1
17
  ## 2026-11-26 · 插件 3.1.6 · 收件箱完成回执与知识库自检
2
18
 
3
19
  - `kb_inbox complete` 在归档登记成功后返回完成记录,并通过 `indexSync` 报告索引同步结果。
package/VERSIONING.en.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [中文](VERSIONING.md) · English
4
4
 
5
- Both products share this policy while retaining independent versions: plugin 3.1.6, desktop client 2.0.3. Shared implementation: packages/kb-contracts/version-policy.js; the plugin keeps its legacy import entry.
5
+ Both products share this policy while retaining independent versions: plugin 3.1.7, desktop client 2.0.3. Shared implementation: packages/kb-contracts/version-policy.js; the plugin keeps its legacy import entry.
6
6
 
7
7
  ## Names and ordering
8
8
 
package/VERSIONING.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](VERSIONING.en.md) · 简体中文
4
4
 
5
- 插件与客户端共用本规则,独立版本:插件 3.1.6,客户端 2.0.3。共享实现位于 packages/kb-contracts/version-policy.js;插件 src/host/versioning.js 保留兼容入口。
5
+ 插件与客户端共用本规则,独立版本:插件 3.1.7,客户端 2.0.3。共享实现位于 packages/kb-contracts/version-policy.js;插件 src/host/versioning.js 保留兼容入口。
6
6
 
7
7
  ## 版本格式与顺序
8
8
 
package/cordis.patch.yml CHANGED
@@ -14,7 +14,7 @@
14
14
  # 之后要改 kbPath / excludeFromSearch 请用设置页 / kb_bind / kb_check,或改 config.json 后重启。
15
15
  - insert:
16
16
  - id: kb-core
17
- name: '@kingsleyasher/dsh-knowledge-base'
17
+ name: '@local/dsh-knowledge-base'
18
18
  config:
19
19
  # Auto joins an already shared library; unmanaged existing libraries keep
20
20
  # their complete embedded mode until an explicit migration is approved.
@@ -2,9 +2,13 @@
2
2
 
3
3
  [English](PROJECT-RECORD.en.md) · [简体中文](PROJECT-RECORD.md)
4
4
 
5
- <!-- project-record-version: 3.1.3 -->
5
+ <!-- project-record-version: 3.1.6 -->
6
6
 
7
- **Source: plugin 3.1.3 / client 2.0.3 · Updated: 2026-11-16 · Published GitHub Releases; client installer unsigned.**
7
+ **Source versions: plugin 3.1.6 / client 2.0.3 · Updated 2026-11-27.**
8
+
9
+ ## 2026-11-27 · Client 2.0.3 · File tree session cache
10
+
11
+ Folders and original-file categories reuse loaded branches and pages and keep rows visible during refresh. File changes refresh the affected branch. Library, sort, query and permission changes discard outdated responses. The local client build is paired with plugin 3.1.6. See the [unified project record](../../PROJECT-RECORD.en.md) for implementation and verification details.
8
12
 
9
13
  ## 2026-11-16 · Client 2.0.3 · File tree and patrol performance
10
14
 
@@ -2,9 +2,13 @@
2
2
 
3
3
  [English](PROJECT-RECORD.en.md) · [简体中文](PROJECT-RECORD.md)
4
4
 
5
- <!-- project-record-version: 3.1.3 -->
5
+ <!-- project-record-version: 3.1.6 -->
6
6
 
7
- **对应源码:插件 3.1.3 / 客户端 2.0.3 · 更新日期:2026-11-16 · 已发布 GitHub Release;客户端安装器未签名。**
7
+ **对应源码:插件 3.1.6 / 客户端 2.0.3 · 更新日期 2026-11-27。**
8
+
9
+ ## 2026-11-27 · 客户端 2.0.3 · 文件树会话缓存
10
+
11
+ 目录和原件分类复用已加载的分支与分页,后台刷新期间保留列表。文件发生变化时刷新对应分支,切库、排序、查询或权限变化时丢弃过期结果。本地客户端与插件 3.1.6 配套构建。更多实现与验证范围见 [统一演进记录](../../PROJECT-RECORD.md)。
8
12
 
9
13
  ## 2026-11-16 · 客户端 2.0.3 · 文件树与周期维护性能
10
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingsleyasher/dsh-knowledge-base",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
4
4
  "description": "个人知识工作台:可控隐私、首次设置、目录地图、快速收集、阅读摘录、引用问答与按需备份。",
5
5
  "icon": "./src/client/capture-icon.svg",
6
6
  "type": "module",
@@ -52,8 +52,7 @@
52
52
  "PRIVACY.md",
53
53
  "SECURITY.md",
54
54
  "THIRD-PARTY-NOTICES.md",
55
- "CONTRIBUTING.md",
56
- "NPM-EDITION.md"
55
+ "CONTRIBUTING.md"
57
56
  ],
58
57
  "dsh": {
59
58
  "bundle": {
@@ -73,6 +72,5 @@
73
72
  "repository": {
74
73
  "type": "git",
75
74
  "url": "git+https://github.com/KingsleyAsher/Personal-Knowledge-Base.git"
76
- },
77
- "homepage": "https://github.com/KingsleyAsher/Personal-Knowledge-Base"
75
+ }
78
76
  }
@@ -26,7 +26,7 @@ import {catalogActive,readCatalog,refreshCatalog,classifyOriginal} from './file-
26
26
  import { CLASSIFICATION_VERSION } from './file-classification.js'
27
27
 
28
28
  // 版本单一来源:package.json 的 version 必须与此一致(详见 INSTALL 说明)
29
- export const VERSION = '3.1.6'
29
+ export const VERSION = '3.1.7'
30
30
 
31
31
  export const REQUIRED_FIELDS = ['title', 'type', 'tags', 'status', 'updated']
32
32
  export const SCHEMA_VERSION = 1
@@ -1480,6 +1480,11 @@ export function createCore(cfg, logger) {
1480
1480
  return { state: res.state, entries: [] }
1481
1481
  }
1482
1482
 
1483
+ let lastBlockedIndexDrop
1484
+ function indexDropDetails(error) {
1485
+ return { reason: error.code, needsConfirmation: true, confirmationToken: error.confirmationToken, oldCount: error.oldCount, newCount: error.newCount }
1486
+ }
1487
+
1483
1488
  async function writeIndex(conf, entries, options = {}) {
1484
1489
  const payload = { generatedAt: nowIso(), meta: await indexMetaOf(conf, entries), entries }
1485
1490
  const root = kbRootOf(conf)
@@ -1492,13 +1497,20 @@ export function createCore(cfg, logger) {
1492
1497
  if (disk.error || disk.fingerprint !== fingerprintOf(entries)) throw Object.assign(new Error('扫描期间文件发生变化或不可读,旧索引已保留'), { code: 'source-unstable' })
1493
1498
  const old = await readIndexState(indexPath(root))
1494
1499
  if (old.state === 'ok' && Array.isArray(old.value?.entries) && typeof old.value.meta?.kbId === 'string' && old.value.meta.kbId.trim() && old.value.meta.kbId !== payload.meta.kbId) throw Object.assign(new Error('索引知识库身份不匹配'), { code: 'index-kbid-mismatch' })
1495
- const oldCount = Array.isArray(old.value?.entries) ? old.value.entries.filter(e => e && typeof e.path === 'string').length : 0
1500
+ const oldEntries = Array.isArray(old.value?.entries) ? old.value.entries.filter(e => e && typeof e.path === 'string') : []
1501
+ const oldCount = oldEntries.length
1496
1502
  const drop = oldCount - entries.length
1497
- const token = sha12(Buffer.from(JSON.stringify([old.value?.meta?.fingerprint, payload.meta.fingerprint, oldCount, entries.length])))
1498
1503
  const nextPaths = new Set(entries.map(e => e.path)), known = new Set(options.knownRemovedPaths || [])
1499
- const onlyKnownRemovals = known.size > 0 && (old.value?.entries || []).filter(e => e && typeof e.path === 'string' && !nextPaths.has(e.path)).every(e => known.has(e.path))
1500
- if ((oldCount > 0 && !entries.length || oldCount >= 20 && drop / oldCount >= .2) && options.confirmDrop !== token && !onlyKnownRemovals) {
1501
- throw Object.assign(new Error('条目数量明显下降,已保留旧索引;请核对差异后确认'), { code: 'index-drop-confirmation', confirmationToken: token, oldCount, newCount: entries.length })
1504
+ const onlyKnownRemovals = known.size > 0 && oldEntries.every(e => nextPaths.has(e.path) || known.has(e.path))
1505
+ if ((oldCount > 0 && !entries.length || oldCount >= 20 && drop / oldCount >= .2) && !onlyKnownRemovals) {
1506
+ const token = sha12(Buffer.from(JSON.stringify([root, payload.meta.kbId, payload.meta.excludes, old.value?.generatedAt, fingerprintOf(oldEntries), payload.meta.fingerprint, oldCount, entries.length])))
1507
+ if (options.confirmDrop !== token) {
1508
+ if (lastBlockedIndexDrop !== token) {
1509
+ lastBlockedIndexDrop = token
1510
+ await writeLog('warn', `索引待确认 reason=index-drop-confirmation oldCount=${oldCount} newCount=${entries.length}`)
1511
+ }
1512
+ throw Object.assign(new Error('条目数量明显下降,已保留旧索引;请核对差异后确认'), { code: 'index-drop-confirmation', confirmationToken: token, oldCount, newCount: entries.length })
1513
+ }
1502
1514
  }
1503
1515
  if (options.snapshot !== false && old.state === 'ok' && validIndexPayload(old.value) && old.value.meta?.kbId === payload.meta.kbId) {
1504
1516
  const directory = path.join(path.dirname(indexPath(root)), 'snapshots')
@@ -1513,6 +1525,7 @@ export function createCore(cfg, logger) {
1513
1525
  const current = await getConfigFresh(), live = await diskFingerprint(conf, true)
1514
1526
  if (kbRootOf(current) !== root || current.revision !== conf.revision || live.error || live.fingerprint !== payload.meta.fingerprint) throw Object.assign(new Error('提交前资料或配置已改变,旧索引已保留'), { code: 'source-unstable' })
1515
1527
  } })
1528
+ lastBlockedIndexDrop = undefined
1516
1529
  indexCache.delete(indexPath(root)); ioMetrics.indexCommits++
1517
1530
  return payload
1518
1531
  }
@@ -1605,8 +1618,10 @@ export function createCore(cfg, logger) {
1605
1618
  if (mode !== 'unchanged') await writeLog('info', `索引维护 ${mode} entries=${entries.length} added=${diff.added.length} removed=${diff.removed.length} changed=${diff.changed.length}`)
1606
1619
  return { ok: true, execution: 'ok', indexWritten: mode !== 'unchanged', mode, entries: entries.length, diff, ...maintenanceState }
1607
1620
  } catch (e) {
1608
- maintenanceState = { ...maintenanceState, state: 'failed', reason: e.code || 'maintenance-failed', detail: e.message, confirmationToken: e.confirmationToken, oldCount: e.oldCount, newCount: e.newCount }
1609
- await writeLog('warn', `索引维护未替换旧索引 reason=${maintenanceState.reason}`)
1621
+ const blocked = e.code === 'index-drop-confirmation'
1622
+ maintenanceState = { ...maintenanceState, state: 'failed', reason: e.code || 'maintenance-failed', detail: e.message,
1623
+ ...(blocked ? indexDropDetails(e) : { needsConfirmation: undefined, confirmationToken: undefined, oldCount: undefined, newCount: undefined }) }
1624
+ if (!blocked) await writeLog('warn', `索引维护未替换旧索引 reason=${maintenanceState.reason}`)
1610
1625
  return { ok: false, ...maintenanceState, indexPreserved: true }
1611
1626
  }
1612
1627
  })) } finally { await releaseConfigLock(configLock.token) }
@@ -2250,7 +2265,7 @@ export function createCore(cfg, logger) {
2250
2265
  }
2251
2266
 
2252
2267
  // ── 检查(R2:走同一把库级锁;R4:扫描不完整不覆盖完整索引)─────────
2253
- async function checkLocked(conf) {
2268
+ async function checkLocked(conf, { confirmDrop, recover } = {}) {
2254
2269
  const root = kbRootOf(conf)
2255
2270
  const health = await healthOf(conf)
2256
2271
  // 一次读取、一个快照(旧实现 readIndex + indexFreshness 各读一遍)
@@ -2284,7 +2299,7 @@ export function createCore(cfg, logger) {
2284
2299
  // 故这里不再产生 noId 缺陷(见 PATCH-NOTES-派生id.md)。
2285
2300
  if (parsed.valid === false) defects.push({ kind: 'frontmatter', path: entry.path, detail: parsed.reason ?? 'frontmatter 非法' })
2286
2301
  }
2287
- for (const p0 of removed) defects.push({ kind: 'missingFile', path: p0, detail: '上一次索引里有、现在磁盘上没有(意外缺失或用户删除,需人工确认)' })
2302
+ for (const p0 of removed) defects.push({ kind: 'missingFile', path: p0, detail: '上一次索引里有、本次扫描未纳入,请核对文件及检索排除范围' })
2288
2303
  for (const err of fresh.scanErrors) defects.push({ kind: 'scanError', path: '-', detail: err })
2289
2304
  // P1-D:索引过期单独记为缺陷(kbId/排除规则/格式/内容指纹任一不符)
2290
2305
  if (!freshness.fresh && snap.state === 'ok') {
@@ -2296,15 +2311,22 @@ export function createCore(cfg, logger) {
2296
2311
  let indexWriteBlocked
2297
2312
  if (fresh.scanErrors.length === 0) {
2298
2313
  try {
2299
- await writeIndex(conf, fresh.entries)
2314
+ await writeIndex(conf, fresh.entries, { confirmDrop })
2300
2315
  indexWritten = true
2301
2316
  } catch (error) {
2302
2317
  if (error.code !== 'index-drop-confirmation') throw error
2303
- indexWriteBlocked = { reason: error.code, oldCount: error.oldCount, newCount: error.newCount }
2304
- defects.push({ kind: error.code, path: toPosix(path.relative(root, indexPath(root))), detail: error.message })
2318
+ indexWriteBlocked = indexDropDetails(error)
2319
+ defects.push({ kind: error.code, path: toPosix(path.relative(root, indexPath(root))), detail: `${error.message}。用户确认后,用 kb_check 的 confirmDrop 参数提交 indexWriteBlocked.confirmationToken` })
2305
2320
  }
2306
2321
  } else defects.push({ kind: 'index-not-written', path: '-.kbmeta/index', detail: `扫描不完整(${fresh.scanErrors.length} 处错误),已保留旧索引、未覆盖;恢复记录不删除` })
2307
- if (!indexWritten && existsSync(path.join(root, '.kbmeta', 'recover-todo.log'))) {
2322
+ let recovery
2323
+ const todo = path.join(root, '.kbmeta', 'recover-todo.log')
2324
+ if (recover) {
2325
+ if (!existsSync(todo)) recovery = { ok: true, consumed: 0 }
2326
+ else if (indexWritten) recovery = await consumeRecoverTodo(todo)
2327
+ else recovery = { ok: false, consumed: 0, kept: true, ...(indexWriteBlocked ?? { reason: 'scan-incomplete', scanErrors: fresh.scanErrors }) }
2328
+ }
2329
+ if (!indexWritten && !indexWriteBlocked && existsSync(todo)) {
2308
2330
  await writeLog('warn', '索引未写入:recover-todo 保留待下次消费')
2309
2331
  }
2310
2332
 
@@ -2321,6 +2343,7 @@ export function createCore(cfg, logger) {
2321
2343
  ...(indexWritten ? { rebuiltAt: nowIso() } : {}),
2322
2344
  indexWritten,
2323
2345
  ...(indexWriteBlocked ? { indexWriteBlocked } : {}),
2346
+ ...(recovery ? { recover: recovery } : {}),
2324
2347
  // 语义保持 P1 原样:index.fresh 反映**本次检查开始时**的新鲜度;
2325
2348
  // 本次是否已重建看 indexWritten / rebuiltAt(不要用"重建后状态"掩盖过期事实)
2326
2349
  index: { fresh: freshness.fresh, reason: freshness.reason, detail: freshness.detail ?? '' },
@@ -2329,48 +2352,48 @@ export function createCore(cfg, logger) {
2329
2352
  return result
2330
2353
  }
2331
2354
 
2332
- async function check(args) {
2355
+ async function check(args = {}) {
2333
2356
  const gate = await configGate()
2334
2357
  if (!gate.ok) {
2335
- return { ok: false, execution: 'error', quality: 'unknown', defects: [], reason: gate.refusal.reason, detail: gate.refusal.detail }
2358
+ return { ok: false, execution: 'error', quality: 'unknown', defects: [], reason: gate.refusal.reason, detail: gate.refusal.detail,
2359
+ ...(args.recover ? { recover: { ...gate.refusal, consumed: 0 } } : {}) }
2336
2360
  }
2337
2361
  const conf = gate.conf
2338
2362
  const root = kbRootOf(conf)
2339
2363
  // R2:维护性写入(rebuild)必须与 create/update 共用同一把锁,否则会覆盖对方刚写的索引
2340
- return withLock(root, () => withKbLock(root, 'check', () => checkLocked(conf)))
2364
+ return withLock(root, () => withKbLock(root, 'check', () => checkLocked(conf, args)))
2341
2365
  }
2342
2366
 
2343
2367
  /** 公开检查入口(含 recover):工具与自检共用同一条路径,避免"测的不是跑的" */
2344
2368
  async function checkEntry(args = {}) {
2345
- if (args && args.recover) {
2346
- const drained = await drainRecoverTodo()
2347
- const result = await check({ ...args, rebuild: true })
2348
- return { ...result, recover: drained }
2349
- }
2350
2369
  return check(args ?? {})
2351
2370
  }
2352
2371
 
2372
+ async function consumeRecoverTodo(file) {
2373
+ const lines = (await readFile(file, 'utf8')).split('\n').filter(Boolean)
2374
+ await rm(file, { force: true })
2375
+ await writeLog('info', `recover-todo 已消费 ${lines.length} 条并重建索引`)
2376
+ return { ok: true, consumed: lines.length }
2377
+ }
2378
+
2353
2379
  /** 已持锁版本的恢复消费(公开入口与自动消费者共用,避免两处逻辑漂移) */
2354
2380
  async function drainRecoverTodoLocked(conf) {
2355
2381
  const root = kbRootOf(conf)
2356
2382
  const file = path.join(root, '.kbmeta', 'recover-todo.log')
2357
2383
  if (!existsSync(file)) return { ok: true, consumed: 0 }
2358
- const lines = (await readFile(file, 'utf8')).split('\n').filter(Boolean)
2359
2384
  let rebuilt
2360
2385
  try {
2361
2386
  rebuilt = await reindexLocked(conf)
2362
2387
  } catch (error) {
2363
2388
  if (error.code !== 'index-drop-confirmation') throw error
2364
- return { ok: false, consumed: 0, kept: true, reason: error.code }
2389
+ return { ok: false, consumed: 0, kept: true, ...indexDropDetails(error) }
2365
2390
  }
2366
2391
  if (rebuilt.ok === false) {
2367
2392
  // 扫描不完整:保留旧索引与恢复记录,等下次再消费(不假装恢复成功)
2368
2393
  await writeLog('warn', `恢复未完成:扫描不完整(${(rebuilt.scanErrors ?? []).length} 处错误),索引与恢复记录均保留`)
2369
2394
  return { ok: false, consumed: 0, kept: true, reason: rebuilt.reason, scanErrors: rebuilt.scanErrors ?? [] }
2370
2395
  }
2371
- await rm(file, { force: true })
2372
- await writeLog('info', `recover-todo 已消费 ${lines.length} 条并重建索引`)
2373
- return { ok: true, consumed: lines.length }
2396
+ return consumeRecoverTodo(file)
2374
2397
  }
2375
2398
 
2376
2399
  async function drainRecoverTodo() {
@@ -91,11 +91,24 @@ export function createWorkbench({ stateDir, getCore, getParsing = () => null, ge
91
91
  const indexCompletedArchive = async b => {
92
92
  invalidatePolicyCaches()
93
93
  const result = await b.core.maintainIndex({ expectedKbId: b.st.kbId })
94
- if (!result.ok) throw fail(result.reason || 'INDEX_REBUILD_FAILED', result.detail || result.reason)
94
+ if (!result.ok) {
95
+ const error = fail(result.reason || 'INDEX_REBUILD_FAILED', result.detail || result.reason)
96
+ if (result.needsConfirmation) Object.assign(error, {
97
+ needsConfirmation: true, confirmationToken: result.confirmationToken, oldCount: result.oldCount, newCount: result.newCount,
98
+ })
99
+ throw error
100
+ }
95
101
  await relations(await binding(b.st.kbId), { force: true }); await retrieval.automatic()
96
102
  }
97
103
  const upgrades=createSystemUpgrades({binding,catalog:async()=>Object.entries(TEMPLATES).map(([name,content])=>({path:'_模板/'+name,content,version:VERSION})),runtime:getUpgradeContext,retrieval,now})
98
- const isPrivate = (b, file) => b.fileCatalog?.files.some(f=>f.path===file&&f.private) || privateRootOf(file, b.privateDirs) !== null || deliverablePrivate(b.deliverables, file) || Boolean(groupFor(b.indexPolicy, file)?.files.some(f => privateRootOf(f.normal, b.privateDirs) !== null))
104
+ const catalogPrivatePaths=new WeakMap()
105
+ const catalogPrivate = (catalog,file) => {
106
+ if(!catalog)return false
107
+ let paths=catalogPrivatePaths.get(catalog)
108
+ if(!paths){paths=new Set(catalog.files.filter(f=>f.private).map(f=>f.path));catalogPrivatePaths.set(catalog,paths)}
109
+ return paths.has(file)
110
+ }
111
+ const isPrivate = (b, file) => catalogPrivate(b.fileCatalog,file) || privateRootOf(file, b.privateDirs) !== null || deliverablePrivate(b.deliverables, file) || Boolean(groupFor(b.indexPolicy, file)?.files.some(f => privateRootOf(f.normal, b.privateDirs) !== null))
99
112
  const visible = (b, file, question = false, includePrivate = false) => (!question || !policyExcluded(b.indexPolicy, file)) && (!isPrivate(b, file) || (question ? b.preferences.showPrivate && b.preferences.allowPrivateQuestions && includePrivate : b.preferences.showPrivate))
100
113
  const indexable = (b, file) => !policyExcluded(b.indexPolicy, file)
101
114
  function redactReferences(b, file, text, allowPrivate = b.preferences.showPrivate) {
@@ -501,7 +514,11 @@ export function createWorkbench({ stateDir, getCore, getParsing = () => null, ge
501
514
  indexSync = { ok: true }
502
515
  } catch (error) {
503
516
  indexSync = { ok: false, reason: error.code || 'INDEX_SYNC_FAILED', detail: error.message }
504
- log('warn', '收件箱已登记,索引同步未完成:' + indexSync.reason)
517
+ if (error.needsConfirmation) {
518
+ const { confirmationToken, oldCount, newCount } = error
519
+ Object.assign(indexSync, { needsConfirmation: true, confirmationToken, oldCount, newCount,
520
+ detail: `${error.message}。请用 kb_check 核对差异,用户确认后再提交确认令牌` })
521
+ } else log('warn', '收件箱已登记,索引同步未完成:' + indexSync.reason)
505
522
  }
506
523
  return { ok: true, ...result, indexSync }
507
524
  }