dsh-wiki-notes 1.6.0 → 1.6.1
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 +95 -0
- package/README.md +10 -1
- package/lib/bridge.js +30 -2
- package/lib/calls.js +3 -1
- package/lib/client.js +62 -12
- package/lib/config.js +72 -10
- package/lib/corpus.js +78 -12
- package/lib/engine.js +104 -12
- package/lib/index.js +58 -11
- package/lib/text.js +20 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,101 @@
|
|
|
2
2
|
|
|
3
3
|
本文件的体例:只记「对使用者有影响的行为变化」,不记内部重构。版本号遵循 semver,`0.x` 阶段不承诺兼容。
|
|
4
4
|
|
|
5
|
+
## 1.6.1
|
|
6
|
+
|
|
7
|
+
### 检索面板(设置页 / 右侧栏)
|
|
8
|
+
|
|
9
|
+
- **输入法组词时不再误提交**:中文输入法里按回车是「确认候选词」,原来会直接触发查询;Esc 也会顺手清空输入框。现在 `isComposing` / `keyCode === 229` 时整个 keydown 立刻返回 —— 连 `preventDefault` 都不做,避免把 IME 自己的确认吃掉。
|
|
10
|
+
- **请求在飞时不再丢弃新查询**:原来 `if (trimmed === '' || busy) return`,边打边查时会出现「输入框写着 A、下面列的是 B 的结果」。先发的请求由 `seqRef` 作废,并发不会互相覆盖。
|
|
11
|
+
- **兜底措辞分清两条路**:`degraded` 既可能是 OR 降级,也可能是 v1.6 起的字面覆盖率兜底。面板原来一律说「已降级为「命中任一」」,现在读 `coverageFallback` 分开说。
|
|
12
|
+
- **结果变化报给读屏**:检索中与计数行加 `role="status"` + `aria-live="polite"`;被省略号截断的页名补 `title`,悬停能看全名。
|
|
13
|
+
- **长词不再顶破面板**:正文里出现没有空格的英文长串或 URL 时,`pre-wrap` 不换行会把横向滚动条撑出来,给 `.wn-hit-text` 加 `overflow-wrap:anywhere`。
|
|
14
|
+
- **「N 份资料」改回「资料页 N 个」**:设置页三处(保存前试扫、探测结果标签、检索面板空状态)都拿 `stats.resources` 当份数显示,而那个数字数的是 `类型: 资料` 的**页数**;原始资料份数在各页的 `来源数量` 里,两者能差好几倍。写成「N 份资料」等于把资料量报小。空状态那一行的「实时同步开」也补上冒号。
|
|
15
|
+
- **两个页签成了真正的 tablist**:原来只是两个并排的按钮,读屏软件念的是「按钮 概览」「按钮 调用记录」,听不出这是一组里选一个、更听不出当前选的是哪个。现在外层 `role="tablist"` + `aria-label`,按钮 `role="tab"` + `aria-selected`。
|
|
16
|
+
- **页签补上焦点环**:页签没带 `.wn-btn`,而焦点样式只挂在 `.wn-btn` 上 —— 用 Tab 键走过去时「焦点在哪」完全看不见。补 `.wn-tab:focus-visible`。
|
|
17
|
+
- **没配库时不再显示「库 0 页」**:`/state` 在未配置时 `stats` 全是 0,检索面板的空状态就照实写「库 0 页 · 资料页 0 个 · 实时同步:关」—— 读起来像「你的库里什么也没有」,实际是「还没填路径」。现在读 `source: 'unset'` 或空 `root`,直接说「还没有配置知识库路径 —— 填一个装了 .md 笔记的文件夹,或设置 DSH_WIKI_ROOT」。
|
|
18
|
+
- **次要文字达到 AA 对比度**:`--wn-faint`(`#8a7f6e`)落在白卡片上只有 **3.87:1**、在浅底条上 3.68:1,低于 WCAG AA 对正文的 4.5:1,而它被拿去印「命中率分母不含 verify / observe」这类说明文字和「未命中」的词条。改成 `--wn-muted`(5.62:1 / 5.34:1);`--wn-faint` 只留给装饰(状态点、`▸` 折叠符号)。
|
|
19
|
+
|
|
20
|
+
### Python 通路(`wiki_context` / `wiki_verify` / `wiki_observe`)
|
|
21
|
+
|
|
22
|
+
- **三种「通不上」不再报同一个码**:以前没配 `bridge.toolsRoot`、目录不存在、目录里没有 `wiki_bridge.py`、`bridge.python` 写错,全都落到 `E_PYTHON_UNAVAILABLE`「找不到 Python 解释器」—— 而 Node 对「工作目录不存在」也报 ENOENT,于是「工具目录配错了」会把人引去改 `bridge.python`。现在先自己看一眼:没配或目录不存在 → `E_TOOLS_ROOT_MISSING`,目录在但缺入口文件 → `E_BRIDGE_SCRIPT_MISSING`,只有解释器真的找不到才是 `E_PYTHON_UNAVAILABLE`。
|
|
23
|
+
- 顺带发现一条**因为共用错误码而误通过的测试**:`tests/gateway.mjs` 的「python 不存在」在没配 `WIKI_TOOLS` 时,实际走的是「工具目录为空」那条路,却因为两者同码而判为通过。现在改用临时目录 + 假 `wiki_bridge.py`,让只有 python 这一环坏掉。
|
|
24
|
+
|
|
25
|
+
### 设置页 API(`/api/wiki-notes`)
|
|
26
|
+
|
|
27
|
+
- **`enabled: "false"` 不再被读成「开」**:原来只认 `raw.enabled !== false`,而字符串 `"false"` 是真值 —— 想关掉观察反而把它打开了,之后开始往账本里记东西。现在 `lib/config.js` 的 `toFlag` 认 `"false"/"0"/"off"/"no"` 与 `"true"/"1"/"on"/"yes"`,认不出来的值走默认。
|
|
28
|
+
- **`/check` 的坏 JSON 不再退化成「测当前库」**:请求体解析失败时原来走 `body?.root`(undefined),于是测的是配置里的库,「我刚测的是不是新路径」看不出来。现在直接 400。
|
|
29
|
+
- **`/check` 与 `/save` 指到文件时说清是路径问题**:给一个 `.md` 文件而不是目录时,原来只报「这个目录里没有任何页面」,现在报「这个路径不是一个目录(指向了文件)。要填的是装着 .md 笔记的那个文件夹」。
|
|
30
|
+
- **还没配库时检索回 400 而不是 500**:`/search` 在没配 `root` 时抛的是普通错误,统一被 catch 成 500 —— 日志和界面读起来像「插件坏了,重试看看」,其实是「你还没填库路径」。现在带 `NOT_CONFIGURED` 码,回 400 并原样给出配置指引。
|
|
31
|
+
|
|
32
|
+
### 回写骨架(`draft`)
|
|
33
|
+
|
|
34
|
+
- **标题不像文件名时先提醒,并改用能用的路径**:标题里的 `\ / : * ? " < > |` 是文件名禁用字符,原来会原样拼成 `概念-concepts/../../etc/passwd.md` 这种路径 —— 照着骨架建就会把文件写到知识层外面。现在路径按替代名生成(`../../etc/passwd` → `..-..-etc-passwd`),标题仍原样写在正文第一行,并在骨架前给出警告。
|
|
35
|
+
- **类型没有对应目录时提醒**:以前兜底放进 `概念-concepts/`,而 frontmatter 写的还是用户给的类型 —— 类型与目录自相矛盾,提交时会被 lint 拦下。现在给 `typeWarning`,把现有类型与「新目录还要同步目录表与 SKILL.md 白名单」一起说清。
|
|
36
|
+
- **`来源数量` 只写非负整数**:`-3` → `0`,`2.7` → `2`(原来原样落盘,读的人没法判断「2.7 份资料」是什么意思)。
|
|
37
|
+
|
|
38
|
+
### 扫描
|
|
39
|
+
|
|
40
|
+
- **跳过的链接目录不再无声无息**:junction / symlink 本来就不跟进去扫(跟进去会重复、也可能绕成环,Windows 上遍历不受信任的装入点还会抛 `0x800701C0`),但以前不留痕 —— 把另一个目录链接进库,看到的现象是「页不见了」。现在记 `stats.linksSkipped` / `stats.linkSkips`,`overview` 里报一行。
|
|
41
|
+
|
|
42
|
+
### 巡检(`lint`)
|
|
43
|
+
|
|
44
|
+
- **「更新」不是 `YYYY-MM-DD` 的页不再被静默跳过**:以前 `2026/11/01`、`2026-11` 这类写法算不出天数,那一页就既不进「久未更新」也不出声 —— 于是「0 页久未更新」看起来像「全库都新」。现在单独列一组「更新日期读不出来」,状态降为 `partial` 并说明原因。
|
|
45
|
+
|
|
46
|
+
### 总览(`overview`)
|
|
47
|
+
|
|
48
|
+
- **库里没有总览页时会说出来**:以前 `overview` 照样返回规模、index 一致性与最近日志,`overview` 字段是 `null` 却没有任何提示,读起来像「这库的总览是空的」。现在附一句说明并把状态降为 `partial`。
|
|
49
|
+
- **扫描行的措辞改准**:`N 份资料` 改成 `其中资料页 N 个` —— 那个数字数的是「类型: 资料」的页数,不是原始资料份数(份数在各页的「来源数量」里),原来的写法让人以为库里只有 N 份原文。
|
|
50
|
+
- **最近日志标明顺序**:由旧到新、最后一条最新(原来只写「最近日志:」,容易把第一条当成最新)。
|
|
51
|
+
- **`log.md` 在、但一条都对不上格式时会说出来**:`log.md` 只有 `## [日期] 类型 | 标题` 这种行才认。文件在、却一条也解析不出来时,以前「最近日志」直接是空的 —— 读起来就是「库里最近没有改动」。现在区分「没有 log.md」和「有但格式不对」,后者降为 `partial` 并明说这是格式没对上。
|
|
52
|
+
- **缺总览时的说明不再替别人的库下判断**:「按库结构约定每个库都该有一页总览」改成「按**本库**的结构约定」——别人用自己的目录树时,没有总览页是正常的。
|
|
53
|
+
- **两条「看起来空」会一起报**:缺总览页、且 `log.md` 在但一条格式都对不上时,原来第一个 `if` 直接 return,第二条警告永远不出现。现在合并成一个块,两条都进 `warnings`。
|
|
54
|
+
|
|
55
|
+
### 检索(`search`)
|
|
56
|
+
|
|
57
|
+
- **片段被截断时会明说**:命中的那一小节超过 `sectionChars`(默认 900)时,以前只是把正文砍断再补个「…」——可原文自己也可能以省略号结尾,模型分不出「这节看全了」和「这节被砍了一半」。截断的表格尤其容易让后半截被当成不存在,然后照着半张表回答。现在每条命中带 `section.chars`(整节字符数)与 `section.truncated`,渲染时补一行「本节正文已截断:全文 2924 字符;要整节用 page 取「页名」」。实测有一节正文 2924 字符,命中默认只给 900。
|
|
58
|
+
|
|
59
|
+
### 参数校验
|
|
60
|
+
|
|
61
|
+
- **「query 为空」不再用来解释「query 全是标点」**:传 `???!!!` 这种切不出任何字元的查询时,以前回「query 为空:请传 1–4 个关键词」,让人反复怀疑自己少传了参数。现在分两种话:真没传 → 还是「query 为空」;传了但切不出字 → 「query 切不出可检索的字:???!!! 全是标点或空白,换个具体的词」。
|
|
62
|
+
- **`tests/params.mjs` 打印真实条数**:原来 print 写死「5 项边界」而实际只断言了 4 条,现在按计数输出(8 项)。
|
|
63
|
+
|
|
64
|
+
### 取页
|
|
65
|
+
|
|
66
|
+
- **超大页不再被说成空页**:`page` 取到超过 512KB 的页时,原来会同时印出「这页没有正文(只有 frontmatter 或文件是空的)」和「正文超过 512KB 未载入」两条互相矛盾的说明;现在只说后者。
|
|
67
|
+
|
|
68
|
+
### 截断
|
|
69
|
+
|
|
70
|
+
- **截断不再切半个字符**:所有按长度截断的位置(命中小节正文、查询词元、账本里的 query、网关错误的 detail、系统提示词的 override/extra)改走新的 `lib/text.js` 的 `clipChars`。以前切点正好落在表情或扩展区汉字(如 `𠮷`)中间时,会留下孤立代理,JSON 里变成 `\ud83d`、界面显示成「�」。这类问题取决于字数,人工测不出来。
|
|
71
|
+
|
|
72
|
+
### 正文解析
|
|
73
|
+
|
|
74
|
+
- **代码围栏里的 `## 标题` 不再被当成小节**:以前只按行首匹配,笔记里贴一段 markdown / YAML 示例就会多出一个并不存在的小节,选节时还可能把那段代码当正文交给模型。
|
|
75
|
+
- **`~~~` 围栏里的双链不再被当成链接**:以前只剥 ``` 围栏,用 `~~~` 写的示例仍会进图谱、被算成红链。现在两种围栏由同一套判定处理。
|
|
76
|
+
|
|
77
|
+
### 配置
|
|
78
|
+
|
|
79
|
+
- **配置文件改为原子写**(`.tmp` + `rename`):以前直写,写一半崩掉会得到一个被截断的 JSON,而读取侧把坏文件当空对象,用户看到的是「我配的路径怎么没了」。
|
|
80
|
+
- **覆盖坏文件前留 `.broken` 备份**:坏文件里可能还有主题词、桥路径这些没被读到的设置,直接覆盖等于把它们一起埋了。
|
|
81
|
+
|
|
82
|
+
### 测试门禁(本机回归,`tests/local/`)
|
|
83
|
+
|
|
84
|
+
- **库指纹改成量内容,不再只量正文长度**:旧算法 hash `页名|body.length`,等长改写、别名 / 标签改字、`index.md` 摘要改字全都测不出来 —— 而检索打分恰恰读这些字段,于是「库变了、基线没过期、指标悄悄变」是通的。现在 `tests/local/library-fingerprint.mjs` 把正文、frontmatter、index 摘要、规模行一起 hash;页顺序 / 键顺序 / mtime 变化不算改动。`metrics.mjs` 与 `recall.mjs` 共用同一个函数,`npm test` 新增 `tests/fingerprint.mjs`(20 项自检)。
|
|
85
|
+
- **`recall.mjs` 的 floor 绑定到库快照**:`queries.json` 新增 `libraryFingerprint`。库换了还拿旧 floor 硬比,会把「新页把老页挤到第 2」判成「引擎退步」;现在指纹不一致改报 `BASELINE_STALE`(退出码 3),照实打印实测数字但不下 PASS / GATE_FAIL 结论。重导提示顺带修了 PowerShell `>` 默认写 UTF-16 会写坏 JSON 的坑。
|
|
86
|
+
- 顺带修一处**文档假绿**:快照 §47.1 里 `76.3%` 是从旧版库的记录照抄的;同一份库上 HEAD(1.6.0) 与工作区引擎逐条排序零差异,都是 `44/59`。这次按当前库重标 floor 并在 `floorNote` 写明证据,不改 `expect`、不为凑数字调排序。
|
|
87
|
+
|
|
88
|
+
### 文件编码(UTF-8 BOM)
|
|
89
|
+
|
|
90
|
+
- **带 BOM 的笔记不再「看着正常、读着全丢」**:Windows 记事本 / PowerShell 5.1 写出的 `.md` 开头常有一个 BOM。插件以前只在「有 frontmatter」的页容忍它,于是无 frontmatter 页的首个 `##` 标题切不出小节、`log.md` 的第一条日志整条消失、`index.md` 首行目录也可能读歪;Python 侧的 `FM_RE` 与 `if text.startswith("---")` 更会让整页 frontmatter 变空,检索却不报错。现在插件三处读文件统一在入口剥掉开头那一个 BOM,Python 侧 17 个工具共 29 处读取统一走 `utf-8-sig`,正文中间的 `U+FEFF`(零宽不换行空格)仍按内容保留。
|
|
91
|
+
- **带 BOM 的配置文件不再被当成坏文件**:`wiki-notes.config.json` 带 BOM 时 `JSON.parse` 直接失败,界面报「还没配库」,下次写入还会把这份其实完好的配置备份成 `.broken`,把主题词、桥路径一起埋掉。现在读取侧先剥 BOM 再解析。
|
|
92
|
+
- **顺带修一个 HEAD 里就有的语法错误**:知识库 `工具-tools/maturity.py` 的 `out = Path(r"os.environ.get(...)")` 把表达式包成了字符串,整个模块连 import 都做不到(这是一次性 BOM 验证脚本第一次跑出来的)。已改回真实的 `os.environ.get(...)`,端到端跑通并生成报告。
|
|
93
|
+
- 新增 `tests/bom.mjs`(15 项,进 `npm test`,共 29 文件):无 frontmatter 页 / 有 frontmatter 页 / index / log / 配置 / 正文中间 BOM 六种场景。Python 侧两条路径(工作区读取 / `lint.py --staged` 读暂存区 blob)另用一次性脚本各验过 14 项与 3 项,用完即删、不进仓库。
|
|
94
|
+
- **带 BOM 的 `lint-history.json` 不再让「与上次相比」凭空消失**:巡检历史是插件自己写、也可能被 PowerShell 重写的文件;它一旦带 BOM,原来 `JSON.parse` 抛错被当成「文件坏了」,于是每次都显示「第一次记录基线」。现在与配置文件共用同一个读 JSON 入口;`package.json` 带 BOM 时 `plugin_version` 退化成 `unknown` 也一并修好。
|
|
95
|
+
|
|
96
|
+
### 巡检报告与启动日志
|
|
97
|
+
|
|
98
|
+
- **不再把「资料页数」写成「份资料」**:总览与设置页早已改准,这两行是漏网的 —— 同一个数字数的是资料页而不是原文份数,写成「N 份资料」会让模型以为原文只有 N 份。现在统一写「其中资料页 N 个」。
|
|
99
|
+
|
|
5
100
|
## 1.6.0
|
|
6
101
|
|
|
7
102
|
### 检索
|
package/README.md
CHANGED
|
@@ -160,7 +160,16 @@ plugin_manager { action: "install_bundle", target: "<绝对路径>" }
|
|
|
160
160
|
|
|
161
161
|
没配时工具会直接告诉你「还没配置知识库路径」,不会静默扫空目录。
|
|
162
162
|
|
|
163
|
-
`wiki_context` / `wiki_verify` / `wiki_observe` 还需要一条 Python 通路(`bridge.python` + `bridge.toolsRoot`,后者是含 `wiki_bridge.py`
|
|
163
|
+
`wiki_context` / `wiki_verify` / `wiki_observe` 还需要一条 Python 通路(`bridge.python` + `bridge.toolsRoot`,后者是含 `wiki_bridge.py` 的目录)。没配或配错时这三个工具会明确报错,且**不会假装成「知识库里没有」**:
|
|
164
|
+
|
|
165
|
+
| 情况 | 错误码 |
|
|
166
|
+
|---|---|
|
|
167
|
+
| 还没配 `bridge.toolsRoot` | `E_TOOLS_ROOT_MISSING` |
|
|
168
|
+
| 配了但目录不存在 | `E_TOOLS_ROOT_MISSING` |
|
|
169
|
+
| 目录在、里面没有 `wiki_bridge.py` | `E_BRIDGE_SCRIPT_MISSING` |
|
|
170
|
+
| `bridge.python` 找不到(不在 PATH、路径写错) | `E_PYTHON_UNAVAILABLE` |
|
|
171
|
+
|
|
172
|
+
配置形状见 [docs/契约-stage0/阶段4-插件接入.md](docs/契约-stage0/阶段4-插件接入.md)。
|
|
164
173
|
|
|
165
174
|
---
|
|
166
175
|
|
package/lib/bridge.js
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* 并且带 stage='bridge'。绝不能把第 2 类伪装成「知识库里没有」。
|
|
10
10
|
*/
|
|
11
11
|
import { spawn } from 'node:child_process'
|
|
12
|
+
import { existsSync } from 'node:fs'
|
|
12
13
|
import path from 'node:path'
|
|
14
|
+
import { clipChars } from './text.js'
|
|
13
15
|
|
|
14
16
|
export const BRIDGE_VERSION = '0.1.0'
|
|
15
17
|
export const CONTRACT_VERSION = '1.0'
|
|
@@ -28,7 +30,7 @@ export function errorEnvelope(code, message, stage = 'bridge', detail = null, re
|
|
|
28
30
|
message,
|
|
29
31
|
stage,
|
|
30
32
|
retryable: retryable === true,
|
|
31
|
-
detail: detail === null || detail === undefined ? null : String(detail)
|
|
33
|
+
detail: detail === null || detail === undefined ? null : clipChars(String(detail), 2000),
|
|
32
34
|
},
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -71,13 +73,39 @@ export function runBridge({
|
|
|
71
73
|
data: null,
|
|
72
74
|
stderr: '',
|
|
73
75
|
ms: 0,
|
|
74
|
-
error: errorEnvelope('
|
|
76
|
+
error: errorEnvelope('E_TOOLS_ROOT_MISSING',
|
|
75
77
|
'还没配置工具目录(Python 管线所在文件夹)。请在插件配置里填 bridge.toolsRoot。',
|
|
76
78
|
'bridge'),
|
|
77
79
|
})
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
const script = path.join(toolsRoot, 'wiki_bridge.py')
|
|
83
|
+
|
|
84
|
+
// 目录没配对和 python 没装,在 spawn 眼里都是同一个 ENOENT(cwd 不存在也报 ENOENT)。
|
|
85
|
+
// 先自己看一眼,否则用户会去改 bridge.python 的路径 —— 那里根本没错。
|
|
86
|
+
if (!existsSync(toolsRoot)) {
|
|
87
|
+
return Promise.resolve({
|
|
88
|
+
ok: false,
|
|
89
|
+
data: null,
|
|
90
|
+
stderr: '',
|
|
91
|
+
ms: Date.now() - started,
|
|
92
|
+
error: errorEnvelope('E_TOOLS_ROOT_MISSING',
|
|
93
|
+
`工具目录不存在:${toolsRoot}(配置里的 bridge.toolsRoot 要指向放着 wiki_bridge.py 的那个文件夹)`,
|
|
94
|
+
'bridge'),
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
if (!existsSync(script)) {
|
|
98
|
+
return Promise.resolve({
|
|
99
|
+
ok: false,
|
|
100
|
+
data: null,
|
|
101
|
+
stderr: '',
|
|
102
|
+
ms: Date.now() - started,
|
|
103
|
+
error: errorEnvelope('E_BRIDGE_SCRIPT_MISSING',
|
|
104
|
+
`工具目录里没有 wiki_bridge.py:${toolsRoot}(这个目录还在,但缺了管线入口文件)`,
|
|
105
|
+
'bridge'),
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
81
109
|
const body = JSON.stringify({ ...(payload ?? {}), plugin_version: pluginVersion })
|
|
82
110
|
const pythonExe = python || 'python'
|
|
83
111
|
|
package/lib/calls.js
CHANGED
|
@@ -15,6 +15,7 @@ import { createJsonlStore } from './jsonl-store.js'
|
|
|
15
15
|
|
|
16
16
|
export { MAX_LINES, KEEP_LINES, TAIL_BYTES, lineCountOf } from './jsonl-store.js'
|
|
17
17
|
import { MAX_LINES, KEEP_LINES } from './jsonl-store.js'
|
|
18
|
+
import { clipChars } from './text.js'
|
|
18
19
|
|
|
19
20
|
/** 账本只认这 8 个字段。顺序就是表头顺序。 */
|
|
20
21
|
export const CALL_FIELDS = ['ts', 'source', 'tool', 'mode', 'query', 'hits', 'ms', 'ok']
|
|
@@ -44,7 +45,8 @@ function localDayOf(ts) {
|
|
|
44
45
|
|
|
45
46
|
function clipQuery(value) {
|
|
46
47
|
if (typeof value !== 'string') return ''
|
|
47
|
-
|
|
48
|
+
// 走 clipChars:账本里若留下半个表情,读回来是 \ud83d,设置页显示「�」
|
|
49
|
+
return value.length > QUERY_MAX ? clipChars(value, QUERY_MAX) + '…' : value
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
package/lib/client.js
CHANGED
|
@@ -302,7 +302,9 @@ window.__ModuleLoader__.load({
|
|
|
302
302
|
setProbeNote({
|
|
303
303
|
tone: 'ok',
|
|
304
304
|
text:
|
|
305
|
-
|
|
305
|
+
// 这里的 resources 数的是「类型: 资料」的页数,不是原始资料份数 ——
|
|
306
|
+
// 写成「N 份资料」会让人以为库里只有 N 份原文(份数在每页的「来源数量」里)。
|
|
307
|
+
'这条路径能扫:' + (stats.pages || 0) + ' 页 / 其中资料页 ' + (stats.resources || 0) + ' 个(' + (result.ms || 0) + ' ms)',
|
|
306
308
|
})
|
|
307
309
|
} else {
|
|
308
310
|
setProbeNote({ tone: 'err', text: (result && result.error) || '这个路径扫不出页面' })
|
|
@@ -400,13 +402,17 @@ window.__ModuleLoader__.load({
|
|
|
400
402
|
),
|
|
401
403
|
)
|
|
402
404
|
|
|
405
|
+
// 页签做成真正的 tablist:读屏软件才会报「第 2 个,共 2 个,已选中」,
|
|
406
|
+
// 而不是两个没有关系的按钮。
|
|
403
407
|
var tabs = h(
|
|
404
408
|
'div',
|
|
405
|
-
{ className: 'wn-tabs' },
|
|
409
|
+
{ className: 'wn-tabs', role: 'tablist', 'aria-label': '知识库设置分页' },
|
|
406
410
|
h(
|
|
407
411
|
'button',
|
|
408
412
|
{
|
|
409
413
|
type: 'button',
|
|
414
|
+
role: 'tab',
|
|
415
|
+
'aria-selected': tab === 'overview',
|
|
410
416
|
className: tab === 'overview' ? 'wn-tab wn-tab-on' : 'wn-tab',
|
|
411
417
|
onClick: function () {
|
|
412
418
|
setTab('overview')
|
|
@@ -418,6 +424,8 @@ window.__ModuleLoader__.load({
|
|
|
418
424
|
'button',
|
|
419
425
|
{
|
|
420
426
|
type: 'button',
|
|
427
|
+
role: 'tab',
|
|
428
|
+
'aria-selected': tab === 'calls',
|
|
421
429
|
className: tab === 'calls' ? 'wn-tab wn-tab-on' : 'wn-tab',
|
|
422
430
|
onClick: function () {
|
|
423
431
|
setTab('calls')
|
|
@@ -671,7 +679,7 @@ window.__ModuleLoader__.load({
|
|
|
671
679
|
'div',
|
|
672
680
|
{ className: 'wn-chips' },
|
|
673
681
|
h('span', { className: 'wn-chip' }, (probe.stats.pages || 0) + ' 页'),
|
|
674
|
-
h('span', { className: 'wn-chip' }, (probe.stats.resources || 0) + '
|
|
682
|
+
h('span', { className: 'wn-chip' }, (probe.stats.resources || 0) + ' 资料页'),
|
|
675
683
|
h(
|
|
676
684
|
'span',
|
|
677
685
|
{ className: 'wn-chip' + ((probe.stats.brokenPages || 0) > 0 ? ' wn-chip-warn' : '') },
|
|
@@ -937,7 +945,8 @@ window.__ModuleLoader__.load({
|
|
|
937
945
|
'span',
|
|
938
946
|
{ className: 'wn-hit-row' },
|
|
939
947
|
h('span', { className: 'wn-hit-rank' }, String(rank)),
|
|
940
|
-
|
|
948
|
+
// 页名会被 ellipsis 截断,鼠标停上去要能看到全名
|
|
949
|
+
h('span', { className: 'wn-hit-name', title: hit.name }, hit.name),
|
|
941
950
|
hit.type !== '' && props.hideType !== true ? h('span', { className: 'wn-hit-type' }, hit.type) : null,
|
|
942
951
|
hit.allTerms === false ? h('span', { className: 'wn-hit-partial' }, '部分词') : null,
|
|
943
952
|
h(
|
|
@@ -1011,7 +1020,15 @@ window.__ModuleLoader__.load({
|
|
|
1011
1020
|
shown < result.total ? '(显示前 ' + shown + ')' : '',
|
|
1012
1021
|
),
|
|
1013
1022
|
result.degraded === true
|
|
1014
|
-
? h(
|
|
1023
|
+
? h(
|
|
1024
|
+
'span',
|
|
1025
|
+
{ className: 'wn-count-degraded' },
|
|
1026
|
+
// 兜底有两条路:OR(命中任一)与字面覆盖率(v1.6 起的第三条路)。
|
|
1027
|
+
// 说错会让人以为自己看到的是「任一词命中」的结果,实际是整句都没命中。
|
|
1028
|
+
result.coverageFallback === true
|
|
1029
|
+
? '没有一页命中整句,已按字面覆盖率匹配(≥45%)'
|
|
1030
|
+
: '没有一条命中全部词,已降级为「命中任一」',
|
|
1031
|
+
)
|
|
1015
1032
|
: null,
|
|
1016
1033
|
h(
|
|
1017
1034
|
'span',
|
|
@@ -1097,11 +1114,26 @@ window.__ModuleLoader__.load({
|
|
|
1097
1114
|
function EmptyState(props) {
|
|
1098
1115
|
var lib = props.lib
|
|
1099
1116
|
var pick = typeof props.onPick === 'function' ? props.onPick : function () {}
|
|
1117
|
+
var unset = lib !== null && lib !== undefined && (lib.source === 'unset' || String(lib.root || '') === '')
|
|
1118
|
+
// 没配库时说「还没填路径」,不要说「库 0 页」:后者会被读成「你库里什么都没有」
|
|
1119
|
+
if (unset) {
|
|
1120
|
+
return h(
|
|
1121
|
+
'div',
|
|
1122
|
+
{ className: 'wn-empty' },
|
|
1123
|
+
h('div', { className: 'wn-empty-line' }, '还没有配置知识库路径 —— 上面「当前库」那一栏填一个装了 .md 笔记的文件夹,或设置环境变量 DSH_WIKI_ROOT。'),
|
|
1124
|
+
h('div', { className: 'wn-empty-cov' }, '没配置时检索会直接报错,而不是返回空结果 —— 免得把「还没连上」读成「库里没有」。'),
|
|
1125
|
+
)
|
|
1126
|
+
}
|
|
1100
1127
|
return h(
|
|
1101
1128
|
'div',
|
|
1102
1129
|
{ className: 'wn-empty' },
|
|
1103
1130
|
lib !== null && lib !== undefined
|
|
1104
|
-
? h(
|
|
1131
|
+
? h(
|
|
1132
|
+
'div',
|
|
1133
|
+
{ className: 'wn-empty-lib' },
|
|
1134
|
+
// 「份资料」是错的:stats.resources 数的是资料页数。原件份数在每页的「来源数量」里。
|
|
1135
|
+
'库 ' + lib.pages + ' 页 · 资料页 ' + lib.resources + ' 个 · 实时同步:' + lib.watch,
|
|
1136
|
+
)
|
|
1105
1137
|
: null,
|
|
1106
1138
|
lib !== null && lib !== undefined
|
|
1107
1139
|
? h(
|
|
@@ -1200,6 +1232,10 @@ window.__ModuleLoader__.load({
|
|
|
1200
1232
|
unreadable: stats.unreadable || 0,
|
|
1201
1233
|
skipped: stats.skipped || 0,
|
|
1202
1234
|
root: data.scannedRoot || data.root || '',
|
|
1235
|
+
// 没配库时 stats 全是 0,空状态会写成「库 0 页」—— 读起来像「库里什么都没有」,
|
|
1236
|
+
// 而实际是「还没填路径」。这两个字段用来分开这两种情况。
|
|
1237
|
+
source: typeof data.source === 'string' ? data.source : '',
|
|
1238
|
+
sourceLabel: typeof data.sourceLabel === 'string' ? data.sourceLabel : '',
|
|
1203
1239
|
})
|
|
1204
1240
|
})
|
|
1205
1241
|
.catch(function () {})
|
|
@@ -1231,7 +1267,10 @@ window.__ModuleLoader__.load({
|
|
|
1231
1267
|
|
|
1232
1268
|
function runSearch(text) {
|
|
1233
1269
|
var trimmed = String(text === undefined ? query : text).trim()
|
|
1234
|
-
|
|
1270
|
+
// 不再因为 busy 就丢弃新查询:中文边打边查时,上一个请求还在飞、
|
|
1271
|
+
// 用户已经改完词了,丢掉新查询的结果就是「输入框写着 A,下面列的是 B 的结果」。
|
|
1272
|
+
// 先发的请求由 seqRef 作废,所以并发不会互相覆盖。
|
|
1273
|
+
if (trimmed === '') return
|
|
1235
1274
|
setQuery(trimmed)
|
|
1236
1275
|
setActive(-1)
|
|
1237
1276
|
seqRef.current = seqRef.current + 1
|
|
@@ -1306,6 +1345,10 @@ window.__ModuleLoader__.load({
|
|
|
1306
1345
|
scheduleSearch(next)
|
|
1307
1346
|
},
|
|
1308
1347
|
onKeyDown: function (event) {
|
|
1348
|
+
// 中文输入法正在组词时,回车是「确认候选词」、Esc 是「取消候选」,都不是面板的动作。
|
|
1349
|
+
// 这里连 preventDefault 都不能做,否则会把 IME 自己的确认吃掉。
|
|
1350
|
+
var composing = event.isComposing === true || event.keyCode === 229
|
|
1351
|
+
if (composing) return
|
|
1309
1352
|
if (event.key === 'Enter') {
|
|
1310
1353
|
event.preventDefault()
|
|
1311
1354
|
submit()
|
|
@@ -1355,9 +1398,14 @@ window.__ModuleLoader__.load({
|
|
|
1355
1398
|
|
|
1356
1399
|
error !== '' ? h(Notice, { tone: 'err', message: error }) : null,
|
|
1357
1400
|
|
|
1358
|
-
busy
|
|
1401
|
+
busy
|
|
1402
|
+
? h('div', { className: 'wn-busy', role: 'status', 'aria-live': 'polite' }, '检索中…')
|
|
1403
|
+
: null,
|
|
1359
1404
|
|
|
1360
|
-
|
|
1405
|
+
// 结果行也报给读屏:没有 aria-live 时,「命中 3 页」这种变化只有看得见的人知道
|
|
1406
|
+
result !== null
|
|
1407
|
+
? h('div', { role: 'status', 'aria-live': 'polite' }, h(CountRow, { result: result }))
|
|
1408
|
+
: null,
|
|
1361
1409
|
|
|
1362
1410
|
result !== null ? h(TermRow, { termPages: result.termPages, matchMode: result.matchMode }) : null,
|
|
1363
1411
|
|
|
@@ -1837,7 +1885,7 @@ window.__ModuleLoader__.load({
|
|
|
1837
1885
|
'.wn-chip-detail{color:var(--wn-muted);font-variant-numeric:tabular-nums;}',
|
|
1838
1886
|
'.wn-chip-warn{color:var(--wn-warn);border-color:color-mix(in srgb,var(--wn-warn) 35%,transparent);}',
|
|
1839
1887
|
'.wn-chip-dim{opacity:.7;}',
|
|
1840
|
-
'.wn-chip-dim .wn-chip-term{font-weight:500;color:var(--wn-
|
|
1888
|
+
'.wn-chip-dim .wn-chip-term{font-weight:500;color:var(--wn-muted);}',
|
|
1841
1889
|
'.wn-actions-spacer{flex:1 1 auto;}',
|
|
1842
1890
|
'.wn-details{border-top:1px solid var(--wn-line-soft);padding-top:9px;margin-top:2px;}',
|
|
1843
1891
|
'.wn-details summary{font-size:11.5px;color:var(--wn-muted);cursor:pointer;user-select:none;list-style:none;}',
|
|
@@ -1873,7 +1921,7 @@ window.__ModuleLoader__.load({
|
|
|
1873
1921
|
'.wn-why{display:flex;flex-wrap:wrap;gap:5px;}',
|
|
1874
1922
|
'.wn-hit-section{font-size:11px;color:var(--wn-muted);}',
|
|
1875
1923
|
// 设置页正文不设高度上限(页面本来就长,截断反而多出滚动条);侧栏才封顶。
|
|
1876
|
-
'.wn-hit-text{font-size:12.5px;line-height:1.75;color:var(--wn-fg);white-space:pre-wrap;padding-right:4px;}',
|
|
1924
|
+
'.wn-hit-text{font-size:12.5px;line-height:1.75;color:var(--wn-fg);white-space:pre-wrap;overflow-wrap:anywhere;padding-right:4px;}',
|
|
1877
1925
|
'.wn-hit-cite{font-size:10.5px;color:var(--wn-muted);word-break:break-all;display:flex;align-items:baseline;gap:8px;}',
|
|
1878
1926
|
'.wn-hit-cite-text{flex:1 1 auto;min-width:0;}',
|
|
1879
1927
|
'.wn-cite-copy{flex:0 0 auto;font-family:inherit;font-size:10.5px;line-height:1.6;padding:0 6px;border-radius:5px;border:1px solid var(--wn-line);background:var(--wn-bar);color:var(--wn-muted);cursor:pointer;}',
|
|
@@ -1919,12 +1967,14 @@ window.__ModuleLoader__.load({
|
|
|
1919
1967
|
'.wn-tabs{display:flex;gap:4px;border-bottom:1px solid var(--wn-line);padding-bottom:0;}',
|
|
1920
1968
|
'.wn-tab{appearance:none;border:0;background:transparent;padding:7px 12px;font-size:12.5px;color:var(--wn-muted);cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;}',
|
|
1921
1969
|
'.wn-tab:hover{color:var(--wn-fg);}',
|
|
1970
|
+
// 页签不是 .wn-btn,得单独给焦点环:否则用 Tab 键走过去时「当前焦点在哪」完全看不见
|
|
1971
|
+
'.wn-tab:focus-visible{outline:2px solid var(--wn-brand);outline-offset:2px;}',
|
|
1922
1972
|
'.wn-tab-on{color:var(--wn-fg);font-weight:600;border-bottom-color:var(--wn-brand);}',
|
|
1923
1973
|
'.wn-calls-stats{display:flex;gap:10px;flex-wrap:wrap;}',
|
|
1924
1974
|
'.wn-calls-stat{flex:1 1 120px;display:flex;flex-direction:column;gap:2px;padding:10px 12px;background:var(--wn-card);border:1px solid var(--wn-line-soft);border-radius:10px;}',
|
|
1925
1975
|
'.wn-calls-stat b{font-size:20px;line-height:1.1;}',
|
|
1926
1976
|
'.wn-calls-stat span{font-size:11.5px;color:var(--wn-muted);}',
|
|
1927
|
-
'.wn-calls-note{font-size:11.5px;color:var(--wn-
|
|
1977
|
+
'.wn-calls-note{font-size:11.5px;color:var(--wn-muted);}',
|
|
1928
1978
|
'.wn-calls-bar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}',
|
|
1929
1979
|
'.wn-calls-check{display:inline-flex;gap:5px;align-items:center;font-size:12px;color:var(--wn-muted);}',
|
|
1930
1980
|
'.wn-calls-table{width:100%;border-collapse:collapse;font-size:12px;}',
|
package/lib/config.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** config.js —— 库位置解析与保存。插件、CLI、设置页共用同一套规则,避免三处跑出不同结果。 */
|
|
2
2
|
|
|
3
|
-
import { readFileSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { readFileSync, writeFileSync, existsSync, renameSync, copyFileSync } from 'node:fs'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
+
import { clipChars } from './text.js'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 内置默认库路径。
|
|
@@ -72,12 +73,27 @@ export function configPath(pluginRoot) {
|
|
|
72
73
|
return pluginRoot === '' ? '' : path.join(pluginRoot, CONFIG_FILE)
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
/**
|
|
77
|
+
* UTF-8 BOM 是编码标记,不是 JSON 内容。PowerShell 的 `Out-File -Encoding utf8`
|
|
78
|
+
* (PS 5.1)写出的是带 BOM 的文件,直接 JSON.parse 会失败 —— 后果不是「读不到」这么
|
|
79
|
+
* 简单:readRecord 把整份配置当空对象,界面显示「还没配库」;下一次写入又把这份
|
|
80
|
+
* 其实完好的配置当成坏文件备份成 .broken,用户的主题词/桥路径被埋进备份里。
|
|
81
|
+
* 读 JSON 的地方统一先剥掉开头那一个 BOM;中间的 U+FEFF 属于内容,不动。
|
|
82
|
+
*
|
|
83
|
+
* 导出给宿主半复用:package.json 与 lint-history.json 若裸 JSON.parse,带 BOM 时
|
|
84
|
+
* 分别会退化成「版本 unknown」和「第一次记录基线」,同样是静默丢信息。
|
|
85
|
+
*/
|
|
86
|
+
export function readJsonFile(file) {
|
|
87
|
+
const raw = readFileSync(file, 'utf8')
|
|
88
|
+
return JSON.parse(raw.charCodeAt(0) === 0xfeff ? raw.slice(1) : raw)
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
/** 读整个配置文件。文件缺失或坏掉都当空对象 —— 不能因为配置问题让工具消失。 */
|
|
76
92
|
function readRecord(pluginRoot) {
|
|
77
93
|
const file = configPath(pluginRoot)
|
|
78
94
|
if (file === '') return {}
|
|
79
95
|
try {
|
|
80
|
-
const parsed =
|
|
96
|
+
const parsed = readJsonFile(file)
|
|
81
97
|
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) return parsed
|
|
82
98
|
} catch {
|
|
83
99
|
// 没有配置文件或文件坏了,都退回默认值
|
|
@@ -85,10 +101,38 @@ function readRecord(pluginRoot) {
|
|
|
85
101
|
return {}
|
|
86
102
|
}
|
|
87
103
|
|
|
104
|
+
/** 现有文件是不是一份可用的配置对象(用来决定覆盖前要不要留备份)。 */
|
|
105
|
+
function isUsableRecord(file) {
|
|
106
|
+
try {
|
|
107
|
+
const parsed = readJsonFile(file)
|
|
108
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
109
|
+
} catch {
|
|
110
|
+
return false
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
88
114
|
/** 写回整个配置文件(保留不认识的字段,别把提示词配置顺手抹掉)。 */
|
|
89
115
|
function writeRecord(pluginRoot, record) {
|
|
90
116
|
const file = configPath(pluginRoot)
|
|
91
|
-
|
|
117
|
+
if (file === '') return ''
|
|
118
|
+
const text = `${JSON.stringify(record, null, 2)}\n`
|
|
119
|
+
|
|
120
|
+
// 现有文件若是坏的,直接覆盖等于把用户之前那份配置(主题词、桥路径、提示词)一起埋了 ——
|
|
121
|
+
// 写入前先留一份 `.broken` 备份,随后 readRecord 会把空对象当起点,界面照常能存。
|
|
122
|
+
if (existsSync(file) && !isUsableRecord(file)) {
|
|
123
|
+
try {
|
|
124
|
+
copyFileSync(file, `${file}.broken`)
|
|
125
|
+
} catch {
|
|
126
|
+
// 备份失败(权限、磁盘满)也要继续写,否则设置页直接存不了
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 原子写:崩在写一半只会留下 `.tmp`,配置文件本身仍是上一份完整内容。
|
|
131
|
+
// 以前是直写,一次意外断电就可能得到一个被截断的 JSON,而 readRecord 会把坏文件当空对象,
|
|
132
|
+
// 用户看到的是「我配的路径怎么没了」。
|
|
133
|
+
const tmp = `${file}.tmp`
|
|
134
|
+
writeFileSync(tmp, text, 'utf8')
|
|
135
|
+
renameSync(tmp, file)
|
|
92
136
|
return file
|
|
93
137
|
}
|
|
94
138
|
|
|
@@ -163,11 +207,29 @@ export function writeTopicConfig(pluginRoot, next) {
|
|
|
163
207
|
|
|
164
208
|
/* --------------------- 调用记录:开关与账本位置 --------------------- */
|
|
165
209
|
|
|
210
|
+
/**
|
|
211
|
+
* 把「开 / 关」这种输入统一成布尔。
|
|
212
|
+
*
|
|
213
|
+
* 只认显式 false 的写法(`raw.enabled !== false`)有个坑:字符串 `"false"` 是真值,
|
|
214
|
+
* 于是「想关掉观察」的调用会把它**打开** —— 方向反了,而且打开之后就开始往账本里记东西。
|
|
215
|
+
* 这里把常见的写法都认下来,认不出来的保留原值(调用方给的是 undefined 时不改语义)。
|
|
216
|
+
*/
|
|
217
|
+
function toFlag(value, fallback) {
|
|
218
|
+
if (typeof value === 'boolean') return value
|
|
219
|
+
if (typeof value === 'number') return value !== 0
|
|
220
|
+
if (typeof value === 'string') {
|
|
221
|
+
const text = value.trim().toLowerCase()
|
|
222
|
+
if (text === 'true' || text === '1' || text === 'on' || text === 'yes') return true
|
|
223
|
+
if (text === 'false' || text === '0' || text === 'off' || text === 'no') return false
|
|
224
|
+
}
|
|
225
|
+
return fallback
|
|
226
|
+
}
|
|
227
|
+
|
|
166
228
|
/**
|
|
167
229
|
* 调用记录配置。
|
|
168
230
|
*
|
|
169
|
-
* enabled
|
|
170
|
-
*
|
|
231
|
+
* enabled 的语义是「要不要记账」:一个拼错的字符串不该让审计悄悄停工,
|
|
232
|
+
* 但也不能把 `"false"` 读成开 —— 见 toFlag。
|
|
171
233
|
* log 空串表示「用插件根目录下的 calls.jsonl」。
|
|
172
234
|
*/
|
|
173
235
|
export const DEFAULT_CALLS_CONFIG = { enabled: true, log: '' }
|
|
@@ -176,7 +238,7 @@ export const DEFAULT_CALLS_CONFIG = { enabled: true, log: '' }
|
|
|
176
238
|
export function normalizeCallsConfig(raw) {
|
|
177
239
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return null
|
|
178
240
|
return {
|
|
179
|
-
enabled: raw.enabled
|
|
241
|
+
enabled: toFlag(raw.enabled, true),
|
|
180
242
|
log: typeof raw.log === 'string' ? raw.log.trim() : '',
|
|
181
243
|
}
|
|
182
244
|
}
|
|
@@ -206,9 +268,9 @@ export const PROMPT_MAX_CHARS = 600
|
|
|
206
268
|
export function normalizePromptConfig(raw) {
|
|
207
269
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return null
|
|
208
270
|
return {
|
|
209
|
-
enabled: raw.enabled
|
|
210
|
-
override: typeof raw.override === 'string' ? raw.override
|
|
211
|
-
extra: typeof raw.extra === 'string' ? raw.extra
|
|
271
|
+
enabled: toFlag(raw.enabled, true),
|
|
272
|
+
override: typeof raw.override === 'string' ? clipChars(raw.override, PROMPT_MAX_CHARS).trim() : '',
|
|
273
|
+
extra: typeof raw.extra === 'string' ? clipChars(raw.extra, PROMPT_MAX_CHARS).trim() : '',
|
|
212
274
|
}
|
|
213
275
|
}
|
|
214
276
|
|
|
@@ -224,7 +286,7 @@ export function mergePromptConfig(current, patch) {
|
|
|
224
286
|
if (patch === null || typeof patch !== 'object' || Array.isArray(patch)) return base
|
|
225
287
|
return (
|
|
226
288
|
normalizePromptConfig({
|
|
227
|
-
enabled:
|
|
289
|
+
enabled: toFlag(patch.enabled, base.enabled),
|
|
228
290
|
override: typeof patch.override === 'string' ? patch.override : base.override,
|
|
229
291
|
extra: typeof patch.extra === 'string' ? patch.extra : base.extra,
|
|
230
292
|
}) ?? base
|
package/lib/corpus.js
CHANGED
|
@@ -58,6 +58,18 @@ function failureOf(stage, rel, error) {
|
|
|
58
58
|
return { path: rel, stage, code }
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* UTF-8 BOM(U+FEFF)是编码标记,不是正文。Windows 的 PowerShell / 记事本写出的
|
|
63
|
+
* .md 常带一个,读进来若不剥,它会粘在首个标题、首个 `##` 小节、index 首条目录、
|
|
64
|
+
* log 首条记录的行首,让「## [日期] 类型 | 标题」这类行首匹配整条失效,
|
|
65
|
+
* 而且不报错 —— 看起来只是「库里没有」。只剥开头那一个:正文中间的 U+FEFF
|
|
66
|
+
* 是零宽不换行空格,属于内容,不能删。splitFrontmatter 里也留着 BOM 容忍,
|
|
67
|
+
* 那是给「不经过 loadCorpus、直接喂字符串」的调用兜底。
|
|
68
|
+
*/
|
|
69
|
+
function stripBom(text) {
|
|
70
|
+
return typeof text === 'string' && text.charCodeAt(0) === 0xfeff ? text.slice(1) : text
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
/** frontmatter 分隔线。允许文件开头有 BOM。 */
|
|
62
74
|
const FM_RE = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---\r?\n?/
|
|
63
75
|
|
|
@@ -169,8 +181,19 @@ export function splitSections(body) {
|
|
|
169
181
|
const lines = body.split(/\r?\n/)
|
|
170
182
|
const sections = []
|
|
171
183
|
let current = { title: '', level: 0, lines: [] }
|
|
184
|
+
// 代码围栏里的 `## xxx` 是示例,不是小节:当初只按行首匹配,
|
|
185
|
+
// 于是任何在笔记里贴了一段 markdown / JSON 的页面都会多出一个并不存在的小节,
|
|
186
|
+
// 选节时还可能把那段代码当正文交给模型。
|
|
187
|
+
let fence = null
|
|
172
188
|
for (const line of lines) {
|
|
173
|
-
const
|
|
189
|
+
const marker = line.match(/^\s*(`{3,}|~{3,})/)
|
|
190
|
+
if (marker !== null) {
|
|
191
|
+
if (fence === null) fence = marker[1][0]
|
|
192
|
+
else if (marker[1][0] === fence) fence = null
|
|
193
|
+
current.lines.push(line)
|
|
194
|
+
continue
|
|
195
|
+
}
|
|
196
|
+
const heading = fence === null ? line.match(/^(#{1,3})\s+(.*)$/) : null
|
|
174
197
|
if (heading !== null && heading[1].length === 2) {
|
|
175
198
|
if (current.title !== '' || current.lines.some((l) => l.trim() !== '')) sections.push(finish(current))
|
|
176
199
|
current = { title: heading[2].trim(), level: 2, lines: [] }
|
|
@@ -186,18 +209,37 @@ function finish(section) {
|
|
|
186
209
|
return { title: section.title, text: section.lines.join('\n').trim() }
|
|
187
210
|
}
|
|
188
211
|
|
|
212
|
+
/**
|
|
213
|
+
* 去掉围栏代码块(``` 与 ~~~ 两种都算),行内代码不动 —— 调用方自己处理。
|
|
214
|
+
* 与 splitSections 用同一套围栏判定,避免「同一条正文两种口径」。
|
|
215
|
+
*/
|
|
216
|
+
function stripCodeBlocks(text) {
|
|
217
|
+
const kept = []
|
|
218
|
+
let fence = null
|
|
219
|
+
for (const line of String(text ?? '').split(/\r?\n/)) {
|
|
220
|
+
const marker = line.match(/^\s*(`{3,}|~{3,})/)
|
|
221
|
+
if (marker !== null) {
|
|
222
|
+
if (fence === null) fence = marker[1][0]
|
|
223
|
+
else if (marker[1][0] === fence) fence = null
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
226
|
+
if (fence === null) kept.push(line)
|
|
227
|
+
}
|
|
228
|
+
return kept.join('\n')
|
|
229
|
+
}
|
|
230
|
+
|
|
189
231
|
/**
|
|
190
232
|
* 正文里的双链:`[[页名]]` 与 `[[页名|显示名]]`,去掉 `#锚点`。
|
|
191
233
|
*
|
|
192
234
|
* 两处细节都是实测踩出来的:
|
|
193
235
|
* - 表格里写双链要用 `\|` 转义,`[[甲\|别名]]` 早先会把页名读成 `甲\`(多一个反斜杠),
|
|
194
236
|
* 于是每张表格里的链接都变成红链。
|
|
195
|
-
* - 代码块和行内代码里的 `[[...]]`
|
|
196
|
-
*
|
|
237
|
+
* - 代码块和行内代码里的 `[[...]]` 是示例不是链接,不该进图谱;早先只认 ``` 一种围栏,
|
|
238
|
+
* 用 ~~~ 写的示例仍会被当链接,现在两种都剥。
|
|
197
239
|
*/
|
|
198
240
|
export function extractLinks(text) {
|
|
199
241
|
const names = []
|
|
200
|
-
const plain =
|
|
242
|
+
const plain = stripCodeBlocks(text).replace(/`[^`\n]*`/g, '')
|
|
201
243
|
const re = /\[\[([^\]|#\\]+)(?:#[^\]|]*)?(?:\\?\|[^\]]*)?\]\]/g
|
|
202
244
|
let match
|
|
203
245
|
while ((match = re.exec(plain)) !== null) {
|
|
@@ -250,7 +292,7 @@ export async function loadCorpus(wikiDir) {
|
|
|
250
292
|
}
|
|
251
293
|
let text = ''
|
|
252
294
|
try {
|
|
253
|
-
text = await fs.readFile(entry.abs, 'utf8')
|
|
295
|
+
text = stripBom(await fs.readFile(entry.abs, 'utf8'))
|
|
254
296
|
} catch (error) {
|
|
255
297
|
return { failure: failureOf('read', entry.rel, error) }
|
|
256
298
|
}
|
|
@@ -317,7 +359,8 @@ export async function loadCorpus(wikiDir) {
|
|
|
317
359
|
}
|
|
318
360
|
|
|
319
361
|
const indexData = await readIndex(indexFile)
|
|
320
|
-
const
|
|
362
|
+
const logInfo = await readLog(logFile)
|
|
363
|
+
const log = logInfo.entries
|
|
321
364
|
|
|
322
365
|
// 覆盖口径:discovered = pages + unreadable + skipped(文件级恒等式,tests/status.mjs 里断言)
|
|
323
366
|
const unreadable = failures.filter((item) => item.stage === 'read' || item.stage === 'parse').length
|
|
@@ -341,6 +384,14 @@ export async function loadCorpus(wikiDir) {
|
|
|
341
384
|
// 目录数与文件数分开记:walkFailures 是目录数,不参与上面的文件级等式
|
|
342
385
|
walkFailures: walked.walkFailures,
|
|
343
386
|
statFailures: walked.statFailures,
|
|
387
|
+
// 没跟的 junction / symlink:内容没扫,但不是丢页 —— 它们指向本库之外,
|
|
388
|
+
// 扫进来会重复也可能绕圈。留痕是为了让「链接没跟」不被读成「页不见了」。
|
|
389
|
+
linksSkipped: walked.linkSkips.length,
|
|
390
|
+
linkSkips: walked.linkSkips.slice(0, 10),
|
|
391
|
+
// log.md 在不在、解析出几条:两件事分开记。「在但 0 条」是格式对不上,
|
|
392
|
+
// 只看条数会把它读成「最近没有改动」。
|
|
393
|
+
logPresent: logInfo.present,
|
|
394
|
+
logEntries: log.length,
|
|
344
395
|
failuresTotal: failures.length + walked.statFailures,
|
|
345
396
|
failures: failures.slice(0, MAX_FAILURE_DETAILS),
|
|
346
397
|
scannedMs: Date.now() - startedAt,
|
|
@@ -360,6 +411,7 @@ export async function loadCorpus(wikiDir) {
|
|
|
360
411
|
async function walkMarkdown(root) {
|
|
361
412
|
const files = []
|
|
362
413
|
const failures = []
|
|
414
|
+
const linkSkips = []
|
|
363
415
|
let walkFailures = 0
|
|
364
416
|
let statFailures = 0
|
|
365
417
|
|
|
@@ -377,6 +429,13 @@ async function walkMarkdown(root) {
|
|
|
377
429
|
for (const dirent of dirents) {
|
|
378
430
|
const abs = path.join(dir, dirent.name)
|
|
379
431
|
const rel = relPrefix === '' ? dirent.name : `${relPrefix}/${dirent.name}`
|
|
432
|
+
// junction / symlink 不跟:跟进去会重复扫描同一批页,也可能绕成环(Windows 上
|
|
433
|
+
// 遍历不受信任的装入点还会直接抛 0x800701C0)。但「没跟」必须留痕 ——
|
|
434
|
+
// 否则用户把另一个目录链接进库,看到的现象是「页不见了」而不是「链接没跟」。
|
|
435
|
+
if (dirent.isSymbolicLink()) {
|
|
436
|
+
linkSkips.push(rel)
|
|
437
|
+
continue
|
|
438
|
+
}
|
|
380
439
|
if (dirent.isDirectory()) {
|
|
381
440
|
if (dirent.name.startsWith('.')) continue
|
|
382
441
|
await walk(abs, rel)
|
|
@@ -401,7 +460,7 @@ async function walkMarkdown(root) {
|
|
|
401
460
|
|
|
402
461
|
await walk(root, '')
|
|
403
462
|
files.sort((a, b) => a.rel.localeCompare(b.rel, 'zh'))
|
|
404
|
-
return { files, failures, walkFailures, statFailures }
|
|
463
|
+
return { files, failures, walkFailures, statFailures, linkSkips }
|
|
405
464
|
}
|
|
406
465
|
|
|
407
466
|
/**
|
|
@@ -414,7 +473,7 @@ async function readIndex(file) {
|
|
|
414
473
|
let scale = ''
|
|
415
474
|
let raw = ''
|
|
416
475
|
try {
|
|
417
|
-
raw = await fs.readFile(file, 'utf8')
|
|
476
|
+
raw = stripBom(await fs.readFile(file, 'utf8'))
|
|
418
477
|
} catch {
|
|
419
478
|
return { lines, scale }
|
|
420
479
|
}
|
|
@@ -541,10 +600,14 @@ export function normalizeFields(input) { const fields = { ...(input || {}) }
|
|
|
541
600
|
async function readLog(file) {
|
|
542
601
|
const entries = []
|
|
543
602
|
let raw = ''
|
|
603
|
+
// present 和「解析出几条」必须分开报:log.md 在、但格式对不上时,
|
|
604
|
+
// 只交出一个空数组,读起来就成了「库里最近没有改动」。
|
|
605
|
+
let present = false
|
|
544
606
|
try {
|
|
545
|
-
raw = await fs.readFile(file, 'utf8')
|
|
607
|
+
raw = stripBom(await fs.readFile(file, 'utf8'))
|
|
608
|
+
present = true
|
|
546
609
|
} catch {
|
|
547
|
-
return entries
|
|
610
|
+
return { entries, present }
|
|
548
611
|
}
|
|
549
612
|
let current = null
|
|
550
613
|
for (const line of raw.split(/\r?\n/)) {
|
|
@@ -557,8 +620,11 @@ async function readLog(file) {
|
|
|
557
620
|
if (current !== null) current.body.push(line)
|
|
558
621
|
}
|
|
559
622
|
if (current !== null) entries.push(current)
|
|
560
|
-
return
|
|
561
|
-
|
|
623
|
+
return {
|
|
624
|
+
entries: entries.map((entry) => ({ date: entry.date, type: entry.type, title: entry.title,
|
|
625
|
+
text: entry.body.join('\n').trim() })),
|
|
626
|
+
present,
|
|
627
|
+
}
|
|
562
628
|
}
|
|
563
629
|
|
|
564
630
|
export function asList(value) {
|
package/lib/engine.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { asList } from './corpus.js'
|
|
11
|
+
import { clipChars } from './text.js'
|
|
11
12
|
|
|
12
13
|
const DEFAULT_SECTION_CHARS = 900
|
|
13
14
|
const DEFAULT_PAGE_CHARS = 6000
|
|
@@ -81,7 +82,7 @@ export function tokenize(query) {
|
|
|
81
82
|
// 200 字上限放在这里,而不是只放在工具层:CLI、设置页 /search、Python 桥都走这条路,
|
|
82
83
|
// 上一层拦住的长度到这里不该又变回一个 300 字的「词元」——它会拖慢每个页面的比对,
|
|
83
84
|
// 还会被原样回显进 note(`"<整段查询>" 被当成一个词元`)。
|
|
84
|
-
const trimmed = String(query ?? '').normalize('NFKC').trim()
|
|
85
|
+
const trimmed = clipChars(String(query ?? '').normalize('NFKC').trim(), MAX_QUERY_CHARS)
|
|
85
86
|
if (trimmed === '') return []
|
|
86
87
|
const rawParts = trimmed
|
|
87
88
|
.split(/[\s,,、。;;/|]+/)
|
|
@@ -329,7 +330,7 @@ function pickSection(page, tokens) {
|
|
|
329
330
|
function clip(text, limit) {
|
|
330
331
|
const value = String(text ?? '')
|
|
331
332
|
if (limit <= 0 || value.length <= limit) return value
|
|
332
|
-
return `${value
|
|
333
|
+
return `${clipChars(value, limit)}…`
|
|
333
334
|
}
|
|
334
335
|
|
|
335
336
|
function buildIndexMap(corpus) {
|
|
@@ -546,7 +547,14 @@ export function search(corpus, query, options = {}) {
|
|
|
546
547
|
allTerms: item.allTerms,
|
|
547
548
|
gist: extractGist(item.page.body),
|
|
548
549
|
summary: item.indexLine?.summary ?? '',
|
|
549
|
-
section: {
|
|
550
|
+
section: {
|
|
551
|
+
title: section.title,
|
|
552
|
+
text: clip(section.text, sectionChars),
|
|
553
|
+
// 截断与否要明说:clip 只在真截断时补「…」,但原文自己也可能以省略号结尾,
|
|
554
|
+
// 模型光看 text 分不出「这段完整」和「这段被砍了一半」——截断的表格后半截最容易被当完整引用。
|
|
555
|
+
chars: String(section.text ?? '').length,
|
|
556
|
+
truncated: String(section.text ?? '').length > sectionChars,
|
|
557
|
+
},
|
|
550
558
|
citation: `← [[${item.page.name}]]${section.title === '' ? '' : ` §${section.title}`} → ${item.page.file}`,
|
|
551
559
|
brokenLinks: broken,
|
|
552
560
|
file: item.page.file,
|
|
@@ -648,7 +656,7 @@ export function page(corpus, name, options = {}) {
|
|
|
648
656
|
const exact = corpus.byName.get(wanted) ?? corpus.byName.get(wanted.replace(/\.md$/i, ''))
|
|
649
657
|
if (exact !== undefined) {
|
|
650
658
|
const found = renderPage(corpus, exact, indexMap, limit)
|
|
651
|
-
const note = pageBodyNote(found)
|
|
659
|
+
const note = pageBodyNote(found, exact.oversized === true)
|
|
652
660
|
return { mode: 'page', found, candidates: [], ...(note === '' ? {} : { note }) }
|
|
653
661
|
}
|
|
654
662
|
|
|
@@ -697,7 +705,10 @@ export function page(corpus, name, options = {}) {
|
|
|
697
705
|
}
|
|
698
706
|
|
|
699
707
|
/** 命中的页没有正文时会话里最容易出的错:模型引用一个空页当依据。 */
|
|
700
|
-
function pageBodyNote(found) {
|
|
708
|
+
function pageBodyNote(found, oversized = false) {
|
|
709
|
+
// 超大页的 body 也是空字符串,但原因不是「文件是空的」——那句说明由 decideStatus 给,
|
|
710
|
+
// 这里再说一遍就成了两条互相矛盾的提示(一条说文件空,一条说超过 512KB)。
|
|
711
|
+
if (oversized === true) return ''
|
|
701
712
|
const body = typeof found?.body === 'string' ? found.body.trim() : ''
|
|
702
713
|
return body === '' ? '这页没有正文(只有 frontmatter 或文件是空的):别把它当依据,回到原始资料或换一页' : ''
|
|
703
714
|
}
|
|
@@ -809,6 +820,9 @@ export function overview(corpus, options = {}) {
|
|
|
809
820
|
oversized: corpus.stats.oversized ?? 0,
|
|
810
821
|
scannedMs: corpus.stats.scannedMs,
|
|
811
822
|
duplicateNames: corpus.stats.duplicateNames ?? [],
|
|
823
|
+
// 没跟的 junction / symlink:不报的话,「链接里的页」会被读成「库里的页」本来就没有
|
|
824
|
+
linksSkipped: corpus.stats.linksSkipped ?? 0,
|
|
825
|
+
linkSkips: corpus.stats.linkSkips ?? [],
|
|
812
826
|
},
|
|
813
827
|
consistency: {
|
|
814
828
|
indexOnly: [...new Set(indexOnly)].slice(0, 10),
|
|
@@ -824,7 +838,20 @@ export function overview(corpus, options = {}) {
|
|
|
824
838
|
summary: indexMap.get(overviewPage.name)?.summary ?? '',
|
|
825
839
|
},
|
|
826
840
|
recentLog,
|
|
841
|
+
// 「最近日志」为空有两种原因:根本没有 log.md,或者 log.md 在、但一条也对不上
|
|
842
|
+
// 「## [日期] 类型 | 标题」。后者必须说出来,否则报表被读成「最近没有改动」。
|
|
843
|
+
logPresent: corpus.stats.logPresent === true,
|
|
844
|
+
logEntries: toCount(corpus.stats.logEntries),
|
|
827
845
|
broken: corpus.brokenLinks.slice(0, 10),
|
|
846
|
+
// 总览页是 overview 的正体;缺了它,模式还能跑(规模、index 一致性、日志都在),
|
|
847
|
+
// 但只交出这些而不说一声,等于把「这库没有总览」翻成「这库总览是空的」。
|
|
848
|
+
...(overviewPage === undefined
|
|
849
|
+
? {
|
|
850
|
+
note: '库里没有「总览-overview」页:下面只有规模、index 一致性与最近日志,没有总览正文。'
|
|
851
|
+
+ '按本库的结构约定该有一页总览(它决定「现在在回答什么、已有什么、分歧在哪、缺什么」);'
|
|
852
|
+
+ '换别人的库、没有总览页是正常的,规模与一致性照样能看。',
|
|
853
|
+
}
|
|
854
|
+
: {}),
|
|
828
855
|
}
|
|
829
856
|
}
|
|
830
857
|
|
|
@@ -917,6 +944,9 @@ export function draft(corpus, options = {}) {
|
|
|
917
944
|
|
|
918
945
|
const typeDirs = inferTypeDirs(corpus)
|
|
919
946
|
const type = String(options.type ?? '').trim() || '概念'
|
|
947
|
+
// 类型没有对应目录时,兜底放「概念」会让 frontmatter 的「类型」和目录自相矛盾 ——
|
|
948
|
+
// 而按库的改动—同步契约,这种页在提交时会被拦下。骨架阶段就该说,而不是等 lint。
|
|
949
|
+
const knownType = typeDirs.has(type) || Object.prototype.hasOwnProperty.call(DEFAULT_TYPE_DIRS, type)
|
|
920
950
|
const dir = typeDirs.get(type) ?? DEFAULT_TYPE_DIRS[type] ?? DEFAULT_TYPE_DIRS['概念']
|
|
921
951
|
// 日期只算一次,四处复用(frontmatter 创建/更新、indexLine、logLine)。
|
|
922
952
|
// 分别取四次的话,迟早出现「创建 03 号、log 02 号」这种自相矛盾的骨架。
|
|
@@ -926,13 +956,21 @@ export function draft(corpus, options = {}) {
|
|
|
926
956
|
|
|
927
957
|
const tags = asList(options.tags)
|
|
928
958
|
const aliases = asList(options.alias ?? options.aliases)
|
|
929
|
-
|
|
959
|
+
// 「来源数量」是要写进 frontmatter 的计数:负数、小数都不该原样落盘(2.7 份资料说不通)
|
|
960
|
+
const sourcesInput = Number(options.sources)
|
|
961
|
+
const sources = Number.isFinite(sourcesInput) ? Math.max(0, Math.trunc(sourcesInput)) : 0
|
|
930
962
|
const summary = String(options.summary ?? '').trim()
|
|
931
|
-
const file = `${dir}/${title}.md`
|
|
932
963
|
|
|
933
964
|
// 同名页已经存在时,回写会覆盖旧内容 —— 必须先在结果里警告,而不是让人写完才发现
|
|
934
965
|
const existing = corpus.byName.get(title) ?? corpus.byAlias.get(title) ?? null
|
|
935
966
|
|
|
967
|
+
// 文件名安全:AGENTS.md 的命名规则禁 `\ / : * ? " < > |`,但 draft 是「照着填就行」的骨架。
|
|
968
|
+
// 带冒号的标题在 Windows 上建不出来;带斜杠的更糟 —— `../../x` 会把路径带出库外,
|
|
969
|
+
// 而骨架里那行路径是给人照着建的。所以路径用替代名生成,原标题原样留在正文标题里。
|
|
970
|
+
const badName = /[\\/:*?"<>|]/.test(title)
|
|
971
|
+
const safeTitle = title.replace(/[\\/:*?"<>|]/g, '-').replace(/-{2,}/g, '-').replace(/^-+|-+$/g, '') || '未命名'
|
|
972
|
+
const file = `${dir}/${badName ? safeTitle : title}.md`
|
|
973
|
+
|
|
936
974
|
const frontmatter = [
|
|
937
975
|
'---',
|
|
938
976
|
`类型: ${type}`,
|
|
@@ -972,6 +1010,19 @@ export function draft(corpus, options = {}) {
|
|
|
972
1010
|
logType,
|
|
973
1011
|
indexLine: `- [[${title}]] — ${summary === '' ? '(一句话摘要)' : summary}(${sources} 份资料,更新于 ${date})`,
|
|
974
1012
|
logLine: `## [${date}] ${logType} | ${title}`,
|
|
1013
|
+
...(badName
|
|
1014
|
+
? {
|
|
1015
|
+
nameWarning: `标题里的 \\ / : * ? " < > | 是文件名禁用字符(斜杠还会把路径带出知识层)。`
|
|
1016
|
+
+ `回写骨架里的路径已按「${safeTitle}」生成,标题照旧写在正文第一行。`,
|
|
1017
|
+
safeTitle,
|
|
1018
|
+
}
|
|
1019
|
+
: {}),
|
|
1020
|
+
...(knownType
|
|
1021
|
+
? {}
|
|
1022
|
+
: {
|
|
1023
|
+
typeWarning: `类型「${type}」在本库里没有对应目录(现有类型:${[...new Set([...typeDirs.keys(), ...Object.keys(DEFAULT_TYPE_DIRS)])].join('、')}),`
|
|
1024
|
+
+ `骨架暂放在「${dir}/」。要么换成已有类型,要么先建目录 —— 按改动—同步契约,新目录还要同步 lint 的目录表与 SKILL.md 白名单。`,
|
|
1025
|
+
}),
|
|
975
1026
|
}
|
|
976
1027
|
}
|
|
977
1028
|
|
|
@@ -1043,11 +1094,17 @@ export function lint(corpus, options = {}) {
|
|
|
1043
1094
|
.filter((row) => row.pages.length > 1)
|
|
1044
1095
|
|
|
1045
1096
|
const stale = []
|
|
1097
|
+
// 「更新」写成 `2026/11/01`、`2026-11`、`2026 年 11 月` 时,久未更新判定只能跳过这一页 ——
|
|
1098
|
+
// 跳过的结果是「0 页久未更新」,而真相是「没算」。两者不能都显示成 0,所以单独收起来。
|
|
1099
|
+
const staleUnknown = []
|
|
1046
1100
|
for (const page of readable) {
|
|
1047
1101
|
const raw = page.fields['更新']
|
|
1048
|
-
if (typeof raw !== 'string' || raw.
|
|
1049
|
-
const time = Date.parse(`${raw.slice(0, 10)}T00:00:00Z`)
|
|
1050
|
-
if (!Number.isFinite(time))
|
|
1102
|
+
if (typeof raw !== 'string' || raw.trim() === '') continue // 缺字段归 frontmatter 合规那一项
|
|
1103
|
+
const time = raw.length < 10 ? Number.NaN : Date.parse(`${raw.slice(0, 10)}T00:00:00Z`)
|
|
1104
|
+
if (!Number.isFinite(time)) {
|
|
1105
|
+
staleUnknown.push({ name: page.name, updated: raw })
|
|
1106
|
+
continue
|
|
1107
|
+
}
|
|
1051
1108
|
const days = Math.floor((now - time) / 86400000)
|
|
1052
1109
|
if (days > staleDays) stale.push({ name: page.name, updated: raw.slice(0, 10), days })
|
|
1053
1110
|
}
|
|
@@ -1080,6 +1137,7 @@ export function lint(corpus, options = {}) {
|
|
|
1080
1137
|
missingFields: missingFields.length,
|
|
1081
1138
|
aliasConflicts: aliasConflicts.length,
|
|
1082
1139
|
stale: stale.length,
|
|
1140
|
+
staleUnknown: staleUnknown.length,
|
|
1083
1141
|
noLinks: noLinks.length,
|
|
1084
1142
|
drafts: drafts.length,
|
|
1085
1143
|
indexOnly: indexOnly.length,
|
|
@@ -1091,6 +1149,7 @@ export function lint(corpus, options = {}) {
|
|
|
1091
1149
|
missingFields: missingFields.slice(0, limit),
|
|
1092
1150
|
aliasConflicts: aliasConflicts.slice(0, limit),
|
|
1093
1151
|
stale: stale.slice(0, limit),
|
|
1152
|
+
staleUnknown: staleUnknown.slice(0, limit),
|
|
1094
1153
|
noLinks: noLinks.slice(0, limit),
|
|
1095
1154
|
drafts: drafts.slice(0, limit),
|
|
1096
1155
|
oversized: oversized.slice(0, limit),
|
|
@@ -1195,8 +1254,14 @@ export const MODES = ['search', 'page', 'list', 'overview', 'lint', 'draft', 'he
|
|
|
1195
1254
|
*/
|
|
1196
1255
|
export function validateArgs(mode, args = {}) {
|
|
1197
1256
|
if (!MODES.includes(mode)) return `未知 mode: ${mode}(可用 ${MODES.join(' / ')})`
|
|
1198
|
-
if (mode === 'search'
|
|
1199
|
-
|
|
1257
|
+
if (mode === 'search') {
|
|
1258
|
+
const rawQuery = String(args.query ?? '').trim()
|
|
1259
|
+
if (rawQuery === '') return 'query 为空:请传 1–4 个关键词'
|
|
1260
|
+
// 传了东西但全是标点/空白(???!!!、()、……)时别回「query 为空」——
|
|
1261
|
+
// 那会让人以为自己漏了参数,其实参数在,只是切不出可检索的字。
|
|
1262
|
+
if (tokenize(rawQuery).length === 0) {
|
|
1263
|
+
return `query 切不出可检索的字:${clipChars(rawQuery, 20)} 全是标点或空白,换个具体的词(1–4 个关键词)`
|
|
1264
|
+
}
|
|
1200
1265
|
}
|
|
1201
1266
|
if (mode === 'page' && String(args.name ?? args.query ?? '').trim() === '') {
|
|
1202
1267
|
return 'name 为空:请传要查的页名'
|
|
@@ -1330,6 +1395,33 @@ export function decideStatus(corpus, mode, args = {}, result = {}) {
|
|
|
1330
1395
|
const why = engineNote(result)
|
|
1331
1396
|
return { status: 'no_match', warnings: why === '' ? [] : [why] }
|
|
1332
1397
|
}
|
|
1398
|
+
// overview 的两个「看起来是空」可以同时成立:缺总览页 + log 格式不对。
|
|
1399
|
+
// 以前两条各写各的 `if … return`,第二条永远被第一条吞掉 —— 状态同样是 partial,
|
|
1400
|
+
// 却只给一句话,模型会以为只有一件事要交代。改成累积,几条事实都输出。
|
|
1401
|
+
if (mode === 'overview') {
|
|
1402
|
+
// 总览缺页:模式还能给出规模与一致性,但那是「没有总览」而不是「总览是空的」。
|
|
1403
|
+
if (result.overview === null) {
|
|
1404
|
+
warnings.push(engineNote(result) || '库里没有总览页,这次只给了规模与一致性信息')
|
|
1405
|
+
}
|
|
1406
|
+
// log.md 在、但一条记录也解析不出来:格式和「## [日期] 类型 | 标题」对不上。
|
|
1407
|
+
// 不报的话「最近日志 0 条」会被读成「库里最近没改动」—— 这是最容易被当真的那种空。
|
|
1408
|
+
if (result.logPresent === true && toCount(result.logEntries) === 0) {
|
|
1409
|
+
warnings.push('log.md 存在,但没有一条符合「## [日期] 类型 | 标题」的记录:'
|
|
1410
|
+
+ '所以「最近日志」是空的 —— 这是格式没对上,不代表库里最近没有改动')
|
|
1411
|
+
}
|
|
1412
|
+
if (warnings.length > 0) return { status: 'partial', warnings }
|
|
1413
|
+
}
|
|
1414
|
+
// lint 的「久未更新」只算得出能解析日期的页。日期写坏(`2026/11/01`、`2026-11`)的页会被跳过,
|
|
1415
|
+
// 不能让「0 页久未更新」冒充「全库都新」—— 这是两件不同的事。
|
|
1416
|
+
if (mode === 'lint') {
|
|
1417
|
+
const unknown = Array.isArray(result.staleUnknown) ? result.staleUnknown : []
|
|
1418
|
+
if (unknown.length > 0) {
|
|
1419
|
+
const sample = unknown[0]
|
|
1420
|
+
warnings.push(`${unknown.length} 页的「更新」不是 YYYY-MM-DD(如 [[${sample.name}]] 写的是「${sample.updated}」),`
|
|
1421
|
+
+ '久未更新检查跳过了这些页:别把「0 页久未更新」当成全库都新')
|
|
1422
|
+
return { status: 'partial', warnings }
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1333
1425
|
return { status: 'ok', warnings: [] }
|
|
1334
1426
|
}
|
|
1335
1427
|
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import path from 'node:path'
|
|
18
|
-
import { mkdirSync,
|
|
18
|
+
import { mkdirSync, statSync, watch, writeFileSync } from 'node:fs'
|
|
19
19
|
import { fileURLToPath } from 'node:url'
|
|
20
20
|
|
|
21
21
|
import { asList, loadCorpus } from './corpus.js'
|
|
@@ -23,8 +23,9 @@ import { createCallLog } from './calls.js'
|
|
|
23
23
|
import { buildRequiredChecks, createGovernance } from './governance.js'
|
|
24
24
|
import { mergePromptConfig, mergeTopicConfig, normalizeTopicConfig, readBridgeConfig, readCallsConfig, readTopicConfig, writeCallsConfig, writeTopicConfig } from './config.js'
|
|
25
25
|
import { MODES, freshnessOf, lint, run } from './engine.js'
|
|
26
|
-
import { configPath, DEFAULT_WIKI_ROOT, NOT_CONFIGURED_HINT, readConfigFile, normalizePromptConfig, readPromptConfig, resolveWikiRootInfo, writeConfigFile, writePromptConfig } from './config.js'
|
|
26
|
+
import { configPath, DEFAULT_WIKI_ROOT, NOT_CONFIGURED_HINT, readConfigFile, normalizePromptConfig, readPromptConfig, readJsonFile, resolveWikiRootInfo, writeConfigFile, writePromptConfig } from './config.js'
|
|
27
27
|
import { errorEnvelope, isObserveResult, runBridge } from './bridge.js'
|
|
28
|
+
import { clipChars } from './text.js'
|
|
28
29
|
|
|
29
30
|
export const name = 'wiki-notes'
|
|
30
31
|
|
|
@@ -534,7 +535,13 @@ export function apply(ctx, config = {}) {
|
|
|
534
535
|
async function getCorpus() {
|
|
535
536
|
// 没配库路径就直接说清楚。别让它扫出一个空库 —— 模型会把「0 页」当成
|
|
536
537
|
// 「你笔记里没有这条」,然后自信地给你编答案。
|
|
537
|
-
|
|
538
|
+
// 这条错误带码:HTTP 侧要把它当「请求还缺配置」回 400,
|
|
539
|
+
// 而不是回 500 —— 500 读起来像「插件坏了,重试看看」。
|
|
540
|
+
if (root === '') {
|
|
541
|
+
const error = new Error(NOT_CONFIGURED_HINT)
|
|
542
|
+
error.code = 'NOT_CONFIGURED'
|
|
543
|
+
throw error
|
|
544
|
+
}
|
|
538
545
|
const now = Date.now()
|
|
539
546
|
if (cache !== null && now - cachedAt < CACHE_TTL_MS) return cache
|
|
540
547
|
if (inflight !== null) return inflight
|
|
@@ -572,7 +579,7 @@ export function apply(ctx, config = {}) {
|
|
|
572
579
|
getCorpus()
|
|
573
580
|
.then((corpus) => {
|
|
574
581
|
ctx.logger?.info?.(
|
|
575
|
-
`LLM-Wiki 检索就绪:${corpus.stats.pages} 页 / ${corpus.stats.resources}
|
|
582
|
+
`LLM-Wiki 检索就绪:${corpus.stats.pages} 页 / 其中资料页 ${corpus.stats.resources} 个 / ${corpus.stats.brokenPages} 页存在红链(${root},首次扫描 ${Date.now() - warmStarted} ms)`,
|
|
576
583
|
)
|
|
577
584
|
})
|
|
578
585
|
.catch((error) => {
|
|
@@ -640,6 +647,15 @@ export function apply(ctx, config = {}) {
|
|
|
640
647
|
const started = Date.now()
|
|
641
648
|
const target = String(candidate ?? '').trim() || root
|
|
642
649
|
if (target === '') return { ok: false, root: '', ms: Date.now() - started, error: NOT_CONFIGURED_HINT }
|
|
650
|
+
// 指到文件而不是目录时,loadCorpus 只会扫出 0 页,于是提示「这个目录里没有任何页面」——
|
|
651
|
+
// 但用户明明给了路径,说错方向会让人以为路径写对了只是库是空的。
|
|
652
|
+
try {
|
|
653
|
+
if (!statSync(target).isDirectory()) {
|
|
654
|
+
return { ok: false, root: target, ms: Date.now() - started, error: '这个路径不是一个目录(指向了文件)。要填的是装着 .md 笔记的那个文件夹' }
|
|
655
|
+
}
|
|
656
|
+
} catch {
|
|
657
|
+
// 不存在 / 没权限:交给 loadCorpus 去报,它的失败明细更具体
|
|
658
|
+
}
|
|
643
659
|
try {
|
|
644
660
|
const corpus = await loadCorpus(target)
|
|
645
661
|
const stats = statsOf(corpus)
|
|
@@ -683,7 +699,7 @@ export function apply(ctx, config = {}) {
|
|
|
683
699
|
// explain 只在服务端打开;工具 schema 里没有这个参数,模型触发不到。
|
|
684
700
|
if (route === '/search' && req.method === 'GET') {
|
|
685
701
|
const parsed = new URL(req.url ?? '/', 'http://127.0.0.1')
|
|
686
|
-
const query = (parsed.searchParams.get('q') ?? '').trim()
|
|
702
|
+
const query = clipChars((parsed.searchParams.get('q') ?? '').trim(), MAX_QUERY_CHARS)
|
|
687
703
|
// 空查询不当作错误让面板弹红字:面板要显示的是「库现在什么样」,那是 /state 的事。
|
|
688
704
|
if (query === '') return sendJson(res, 400, { error: '缺少 q 参数(要查什么)' })
|
|
689
705
|
const started = Date.now()
|
|
@@ -748,6 +764,9 @@ export function apply(ctx, config = {}) {
|
|
|
748
764
|
}
|
|
749
765
|
if (route === '/check' && req.method === 'POST') {
|
|
750
766
|
const body = await readBody(req)
|
|
767
|
+
// 坏 JSON 以前会退化成「测试当前库」,于是「我测的是新路径」与
|
|
768
|
+
// 「刚才那次其实是旧路径」看不出区别 —— 宁可 400。
|
|
769
|
+
if (body === undefined) return sendJson(res, 400, { error: '请求体不是合法 JSON' })
|
|
751
770
|
return sendJson(res, 200, await probeRoot(body?.root))
|
|
752
771
|
}
|
|
753
772
|
if (route === '/save' && req.method === 'POST') {
|
|
@@ -811,6 +830,10 @@ export function apply(ctx, config = {}) {
|
|
|
811
830
|
if (error?.code === 'BODY_TOO_LARGE') {
|
|
812
831
|
return sendJson(res, 413, { error: String(error.message ?? error) })
|
|
813
832
|
}
|
|
833
|
+
// 「还没配库」是请求缺条件,不是服务端坏了:回 400,别让界面/日志把它读成插件故障
|
|
834
|
+
if (error?.code === 'NOT_CONFIGURED') {
|
|
835
|
+
return sendJson(res, 400, { error: String(error.message ?? error) })
|
|
836
|
+
}
|
|
814
837
|
return sendJson(res, 500, { error: String(error?.message ?? error) })
|
|
815
838
|
}
|
|
816
839
|
},
|
|
@@ -860,7 +883,8 @@ export function apply(ctx, config = {}) {
|
|
|
860
883
|
/** 读插件自己的版本号,用于契约里的 plugin_version。读不到就写 unknown。 */
|
|
861
884
|
function readPluginVersion(pluginRoot) {
|
|
862
885
|
try {
|
|
863
|
-
|
|
886
|
+
// 走统一的读 JSON 入口:带 BOM 的 package.json 裸 JSON.parse 会失败,版本号静默变 unknown
|
|
887
|
+
const pkg = readJsonFile(path.join(pluginRoot, 'package.json'))
|
|
864
888
|
return typeof pkg.version === 'string' ? pkg.version : 'unknown'
|
|
865
889
|
} catch {
|
|
866
890
|
return 'unknown'
|
|
@@ -1139,7 +1163,7 @@ const registerGateway = () => {
|
|
|
1139
1163
|
}
|
|
1140
1164
|
const cycle = governance.cycle()
|
|
1141
1165
|
const value = await callBridge('context', {
|
|
1142
|
-
query: query
|
|
1166
|
+
query: clipChars(query, MAX_QUERY_CHARS * 4),
|
|
1143
1167
|
limit: args?.limit,
|
|
1144
1168
|
engine: args?.engine,
|
|
1145
1169
|
ttl_seconds: args?.ttl_seconds,
|
|
@@ -1373,7 +1397,9 @@ function recordLintRun(corpus, args, pluginRoot) {
|
|
|
1373
1397
|
|
|
1374
1398
|
let previous = null
|
|
1375
1399
|
try {
|
|
1376
|
-
|
|
1400
|
+
// 统一读 JSON 入口:PowerShell 写出的 lint-history.json 可能带 BOM,
|
|
1401
|
+
// 裸 JSON.parse 会抛错 → previous=null → first=true,历史对比被静默重置成「第一次」。
|
|
1402
|
+
previous = readJsonFile(file)
|
|
1377
1403
|
} catch {
|
|
1378
1404
|
previous = null // 第一次跑,或文件坏了:都当作没有基线
|
|
1379
1405
|
}
|
|
@@ -1458,7 +1484,9 @@ function renderLint(value) {
|
|
|
1458
1484
|
const stats = value.stats || {}
|
|
1459
1485
|
const counts = value.counts || {}
|
|
1460
1486
|
const lines = [
|
|
1461
|
-
|
|
1487
|
+
// stats.resources 是「类型: 资料」的页数,不是原始资料份数(份数在每页的「来源数量」里)。
|
|
1488
|
+
// 与 renderOverview 同口径:写成「N 份资料」会让模型把库里的原文数量报小四倍。
|
|
1489
|
+
`库健康检查(只读)· ${stats.pages ?? 0} 页 · 其中资料页 ${stats.resources ?? 0} 个 · 扫描 ${stats.scannedMs ?? 0} ms`,
|
|
1462
1490
|
]
|
|
1463
1491
|
|
|
1464
1492
|
const since = value.sinceLast
|
|
@@ -1486,6 +1514,8 @@ function renderLint(value) {
|
|
|
1486
1514
|
block('🧩 缺 frontmatter 字段', counts.missingFields, value.missingFields, (row) => `${row.name}:缺 ${row.missing.join('、')}`)
|
|
1487
1515
|
block('🏷 别名冲突 —— 同一别名挂在多页,检索排序会漂', counts.aliasConflicts, value.aliasConflicts, (row) => `${row.alias} → ${row.pages.join(' / ')}`)
|
|
1488
1516
|
block(`⏳ 久未更新(> ${value.staleDays} 天)`, counts.stale, value.stale, (row) => `${row.name}(${row.updated},${row.days} 天前)`)
|
|
1517
|
+
// 「更新」写成别的格式的页,上面那项算不进去:不单独列出来,读的人会以为全库都新
|
|
1518
|
+
block('❓ 更新日期读不出来 —— 久未更新检查跳过了这些页', counts.staleUnknown, value.staleUnknown, (row) => `${row.name}(写的是「${row.updated}」)`)
|
|
1489
1519
|
block('🚪 无出链 —— 正文里没有任何 [[双链]]', counts.noLinks, value.noLinks, (name) => name)
|
|
1490
1520
|
block('📝 草稿状态', counts.drafts, value.drafts, (name) => name)
|
|
1491
1521
|
block('📇 index.md 登记了、磁盘上没有', counts.indexOnly, value.consistency?.indexOnly, (name) => name)
|
|
@@ -1521,6 +1551,10 @@ function renderDraft(value) {
|
|
|
1521
1551
|
? ''
|
|
1522
1552
|
: `(⚠ 已有同名页 ${value.exists.file},直接写会覆盖它 —— 换个名字,或确认就是要改那一页)`
|
|
1523
1553
|
out.push(`回写骨架:${value.file}${warn}`)
|
|
1554
|
+
// 文件名建不出来的问题必须在动笔之前说:等正文写完才发现,代价是整篇白写
|
|
1555
|
+
if (value.nameWarning) out.push(`⚠ ${value.nameWarning}`)
|
|
1556
|
+
// 类型没有目录时,frontmatter 的「类型」与落盘目录会自相矛盾(提交时会被 lint 拦下)
|
|
1557
|
+
if (value.typeWarning) out.push(`⚠ ${value.typeWarning}`)
|
|
1524
1558
|
out.push('')
|
|
1525
1559
|
out.push(value.frontmatter)
|
|
1526
1560
|
out.push('')
|
|
@@ -1613,6 +1647,10 @@ function renderSearch(value) {
|
|
|
1613
1647
|
const body = stripLeadingH1(hit.section.text, hit.name)
|
|
1614
1648
|
if (hit.section.title) out.push(` §${hit.section.title}`)
|
|
1615
1649
|
out.push(body)
|
|
1650
|
+
// 片段被砍过就说清楚:不然「表格只到一半」会被当成整节内容引用
|
|
1651
|
+
if (hit.section.truncated === true) {
|
|
1652
|
+
out.push(` (本节正文已截断:全文 ${hit.section.chars ?? '?'} 字符;要整节用 page 取「${hit.name}」)`)
|
|
1653
|
+
}
|
|
1616
1654
|
}
|
|
1617
1655
|
if (Array.isArray(hit.brokenLinks) && hit.brokenLinks.length > 0) {
|
|
1618
1656
|
out.push(` ⚠️ 红链:${hit.brokenLinks.slice(0, 6).join('、')}(库里没有这些页)`)
|
|
@@ -1680,7 +1718,9 @@ function renderOverview(value) {
|
|
|
1680
1718
|
if (value.scale) out.push(`规模:${value.scale}`)
|
|
1681
1719
|
const stats = value.stats ?? {}
|
|
1682
1720
|
const oversizedCount = Number(stats.oversized ?? 0)
|
|
1683
|
-
|
|
1721
|
+
// resources 数的是「类型: 资料」的页数,不是原始资料份数(份数在每页的「来源数量」里)。
|
|
1722
|
+
// 写成「N 份资料」会让模型以为库里只有 N 份原文,所以标清楚是页数。
|
|
1723
|
+
out.push(`扫描:${stats.pages ?? '?'} 页 / 其中资料页 ${stats.resources ?? '?'} 个 / ${stats.brokenPages ?? 0} 页有红链(共 ${stats.brokenTotal ?? 0} 处)${oversizedCount > 0 ? ` / ${oversizedCount} 页超大未读正文` : ''}`)
|
|
1684
1724
|
|
|
1685
1725
|
const consistency = value.consistency ?? {}
|
|
1686
1726
|
if ((consistency.indexOnlyTotal ?? 0) > 0) {
|
|
@@ -1693,6 +1733,13 @@ function renderOverview(value) {
|
|
|
1693
1733
|
if (dupNames.length > 0) {
|
|
1694
1734
|
out.push(`⚠️ 重名页(只保留最后一个,其余查不到):${dupNames.slice(0, 6).map((item) => `${item.name}(${item.file})`).join('、')}`)
|
|
1695
1735
|
}
|
|
1736
|
+
// 链接目录没跟进去:不写明的话,链接里的页看起来就是「库里没有」
|
|
1737
|
+
const linkSkips = Array.isArray(stats.linkSkips) ? stats.linkSkips : []
|
|
1738
|
+
if (Number(stats.linksSkipped ?? 0) > 0) {
|
|
1739
|
+
const shown = linkSkips.slice(0, 5).join('、')
|
|
1740
|
+
const more = Number(stats.linksSkipped) > linkSkips.length ? ` …共 ${stats.linksSkipped} 个` : ''
|
|
1741
|
+
out.push(`⚠️ 跳过了链接目录/文件(junction、symlink 不跟进去扫描):${shown}${more}`)
|
|
1742
|
+
}
|
|
1696
1743
|
|
|
1697
1744
|
if (value.overview !== null && value.overview !== undefined) {
|
|
1698
1745
|
out.push('')
|
|
@@ -1704,7 +1751,7 @@ function renderOverview(value) {
|
|
|
1704
1751
|
const log = Array.isArray(value.recentLog) ? value.recentLog : []
|
|
1705
1752
|
if (log.length > 0) {
|
|
1706
1753
|
out.push('')
|
|
1707
|
-
out.push('
|
|
1754
|
+
out.push('最近日志(由旧到新,最后一条最新):')
|
|
1708
1755
|
for (const entry of log) out.push(`- [${entry.date}] ${entry.type} | ${entry.title}`)
|
|
1709
1756
|
}
|
|
1710
1757
|
|
package/lib/text.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按「字符」截断,但绝不把表情或扩展区汉字切成半个。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要单独一个函数:JS 的 `String.length` 数的是 UTF-16 码元,
|
|
5
|
+
* 一个 😀 或一个扩展 B 区汉字(如 𠮷)占两个码元。`slice(0, 200)` 正好切在
|
|
6
|
+
* 前半截时,得到的是一个孤立高位代理(`\uD83D`),JSON 序列化后变成 `\ud83d`,
|
|
7
|
+
* 渲染出来就是「�」。截断点是否踩到代理对取决于字数,人工测不出来,
|
|
8
|
+
* 所以所有按长度截断的地方都要走这里。
|
|
9
|
+
*/
|
|
10
|
+
export function clipChars(value, max) {
|
|
11
|
+
const text = typeof value === 'string' ? value : String(value ?? '')
|
|
12
|
+
const limit = Number.isFinite(max) ? Math.floor(max) : 0
|
|
13
|
+
// 上限不是正数时返回空串:这个函数只回答「能放下几个字符」,
|
|
14
|
+
// 「不截断」是调用方的事(engine 的 clip 自己判 limit <= 0)。
|
|
15
|
+
if (limit <= 0) return ''
|
|
16
|
+
if (text.length <= limit) return text
|
|
17
|
+
// 切点前一个码元若高位代理,说明这一刀落在字符中间:退一格,宁可少一个字
|
|
18
|
+
const before = text.charCodeAt(limit - 1)
|
|
19
|
+
return text.slice(0, before >= 0xd800 && before <= 0xdbff ? limit - 1 : limit)
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-wiki-notes",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Read-only knowledge gateway over a local Markdown vault for DeepSeek Harness — recall, evidence pack, answer verification, call audit | 本地 Markdown 笔记库的只读知识网关:检索、证据包、核验、调用审计",
|
|
6
6
|
"keywords": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=20.13.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"test": "node tests/smoke.mjs && node tests/status.mjs && node tests/params.mjs && node tests/fields.mjs && node tests/robust.mjs && node tests/lint.mjs && node tests/lintdiff.mjs && node tests/config.mjs && node tests/explain.mjs && node tests/cli.mjs && node tests/api.mjs && node tests/help.mjs && node tests/contract.mjs && node tests/topics.mjs && node tests/draft.mjs && node tests/calls.mjs && node tests/governance.mjs && node tests/inject.mjs && node tests/watch.mjs && node tests/client.mjs && node tests/tier.mjs && node tests/render.mjs && node tests/calls-read.mjs && node tests/store.mjs && node tests/bridge.mjs",
|
|
43
|
+
"test": "node tests/smoke.mjs && node tests/status.mjs && node tests/params.mjs && node tests/fields.mjs && node tests/robust.mjs && node tests/lint.mjs && node tests/lintdiff.mjs && node tests/config.mjs && node tests/explain.mjs && node tests/cli.mjs && node tests/api.mjs && node tests/help.mjs && node tests/contract.mjs && node tests/topics.mjs && node tests/draft.mjs && node tests/calls.mjs && node tests/governance.mjs && node tests/inject.mjs && node tests/watch.mjs && node tests/client.mjs && node tests/tier.mjs && node tests/render.mjs && node tests/calls-read.mjs && node tests/store.mjs && node tests/bridge.mjs && node tests/text.mjs && node tests/parse.mjs && node tests/fingerprint.mjs && node tests/bom.mjs",
|
|
44
44
|
"cli": "node bin/cli.mjs",
|
|
45
45
|
"probe": "node tools/probe.mjs"
|
|
46
46
|
},
|