# dsh-knowledge v0.5.1 — 文档排除检索与 DSH 目录操作修复 0.5.1 增加检索排除条件,并修复 DSH 0.2 上本地模型与 MinerU 的目录按钮。适合需要排除书目、目录或处理记录等非正文资料的知识库,以及使用 DSH 0.2 的桌面用户。 ## 检索支持排除文档(#39) - HTTP `/knowledge/search` 的 `filter` 新增 `excludeDocIds` 和 `titleExcludes`;`knowledge_search` 提供同名顶层参数,客户端类型同步更新。 - 文档 ID 精确匹配;标题关键词去除首尾空白、忽略大小写,任一非空子串命中即排除,不使用正则。 - 包含与排除条件可叠加,重叠时排除优先。排除在词法/向量候选截断、融合、MMR 和重排之前生效,避免非正文篇占用 TopK 配额。 - 支持超过 500 项的 ID 集合。空排除数组和未知 ID 不影响结果;新增 HTTP 字段格式错误返回 `400 invalid_request`。 示例: ```json { "query": "方剂用法", "topK": 5, "filter": { "titleExcludes": ["书目信息", "目录", "处理记录"] } } ``` 省略 `baseId` 可搜索全部知识库;搜索指定库时填写有效的 `baseId`。 ## 修复目录按钮(#42) - 恢复 DSH 0.2 的本地模型缓存目录「选择文件夹/打开目录」以及 MinerU 目录选择,修复 `pickDirectory/openPath is not a function`。 - 使用新版宿主接口,同时保留旧版兼容。按具体方法判断能力;取消选择保留原路径,能力缺失时保留手动输入,操作错误可见。 - 打开缓存目录前由后端解析绝对路径、展开 `~`;空输入使用当前有效缓存目录,可在显式打开时创建缺失目录。 - 打开目录不保存配置、不迁移模型、不启动下载。 ## 升级与验证 从 0.5.0 升级无需数据库迁移、重新索引或迁移书籍。本版本没有新增依赖,排除检索按请求启用,现有包含式过滤保持兼容。 修复代码已通过本机 529 项回归测试、类型检查、构建、检索基准和包检查。检索基准中的主要召回与证据指标保持 100%。目录回归覆盖新旧宿主契约、实际按钮回调及真实 HTTP 请求;真实 DSH 0.2 原生弹窗与文件管理器的交互仍需实机验收。 原有托管 MinerU 仍为实验性功能。生产审计策略保留了 `@huggingface/transformers > sharp` 的两项既有高危例外,截止日期为 **2026-10-14**;本补丁不改变这些依赖或例外。 ## English summary - **Search exclusions (#39):** add `excludeDocIds` and `titleExcludes` to HTTP search filters and matching top-level `knowledge_search` arguments. Exclusions win over inclusions and apply before candidate limits, fusion, MMR and reranking. ID sets larger than 500 are supported. - **DSH directory compatibility (#42):** restore cache Browse/Open and MinerU directory selection on DSH 0.2 while retaining legacy interfaces. Preserve cancellation and manual input; resolve the effective absolute cache path before opening it. - **Upgrade:** no database migration, reindexing, document relocation or new dependencies. Opening a directory does not save configuration, migrate models or download weights. - **Validation:** 529 local tests, typecheck, build, retrieval benchmark and package checks passed for the fixes. Native desktop dialog/file-manager acceptance remains separate; managed MinerU remains experimental. The existing, time-limited `sharp` audit exceptions are unchanged. Related fixes: [PR #41](https://github.com/Soren-ABT/dsh-knowledge/pull/41), [PR #45](https://github.com/Soren-ABT/dsh-knowledge/pull/45).