dsh-read-url 1.0.0 → 1.2.0

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 CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0] - 2026-08-22
4
+
5
+ ### 修复三处隐患 + 进一步省 token
6
+
7
+ 秉持核心理念不变:零运行时依赖、只返回干净正文 + 关键元数据、静态 schema 保 KV-cache。
8
+
9
+ **修复**
10
+ - **raceFetch 错误归因去位置化**:`fetchPage` 不再假设 `failures[0]`=直连、`failures[1]`=代理,race 失败时由 `raceFetch` 在定义尝试顺序处附加 `label: 'direct'|'proxy'`,调用方按 label 取错——调整尝试顺序不会再静默归因错误
11
+ - **失败缓存独立**:30s 失败条目原先与成功条目共用同一个 FIFO Map(占 `cacheMax=32` 名额,可能挤掉热点成功页)。拆为独立 `failCache`(容量 8),成功缓存容量完整保留
12
+ - **smartTruncate 长段落退化**:offset 后首段超过 maxChars 时原先直接硬切 slice,丢失段落对齐承诺。现在先按句读(。!?!?. 换行)二次对齐,单句仍超长才硬切
13
+
14
+ **省 token**
15
+ - **JSON 紧凑渲染**:`JSON.stringify(x, null, 1)` 的逐层缩进改为无缩进紧凑输出,且超长字符串值(内嵌 HTML / base64,>1500 字符)截断并附 `…[+N chars]` 标记。典型 API 响应实测省约 21% 字符,大字段响应节省无上限
16
+ - **状态行合并**:renderResult 的 `(chars …)`、`(cached)`、`(已自动拼接 N 页)`、`(rendered)` 多行括号提示合并为单行 ` · ` 分隔;`charset utf-8`(绝大多数响应)不再输出
17
+
18
+ **效果增强**
19
+ - **分页识别放宽**:NEXT_TEXT_RE 允许箭头包裹的变体(`下一页 ›`、`Next »`、`下一頁` 繁体等),仍保持全匹配保守策略,不做模糊猜测;findNextLink 锚点扫描加上限(400),巨型导航栏不再全文扫描
20
+
21
+ ### 同日第二轮:对抗性审查 + 多轮实网测试
22
+
23
+ 静态通读全部源码 + 对抗性探针(`probe.mjs`)+ 扩展类别实测(`extended-sites.mjs`,JSON API / 文档生成器站 / 学术 / raw 内容 / 韩文 euc-kr / 重定向等 24 类)+ 152 站三轮回归,发现并修复 6 个问题:
24
+
25
+ **修复(含 1 个二次复杂度 DoS 向量)**
26
+ - **对抗页面线性化(重要)**:正则标签扫描存在多类二次复杂度路径——无 `>` 配对的 `<` 尾部(每个位置重扫至串尾)、主正则属性组的组合回溯、无闭合标签的懒扫描(`<li>`/`<tr>`/feed `<item>`/`<article>`)、`[^>]+` 无界属性扫描。实测 60KB 恶意输入耗时 2.2s,3MB 上限页面可放大到分钟级。修复:`defuseLt`(中和必然无法成标签的尾部 `<`)、属性扫描统一加 `{0,1000}` 界、无闭合守卫(`includes('</li')` 类短路)、markdown 递归深度帽 100 层(防栈溢出)。修复后全部向量线性(输入翻倍耗时翻倍)
27
+ - **散文 `&lt;` 内容丢失(长期存在)**:`revealEscapedTags` 无条件解码 `&lt;` 后,正文里 "a &lt; b" 的裸 `<` 被标签剥离器吞到下一个 `>`,丢一段正文。改为只揭示"标签形状"(后跟字母或 `/`)的 `&lt;`;裸 `&gt;`/`&quot;` 安全揭示
28
+ - **代理路径重定向丢最终 URL**:curl 代理路径 `finalUrl` 硬编码原始 URL,跨域重定向后分页与链接解析落在错误主机。改用 `%{url_effective}`
29
+ - **compactJson 深嵌套崩溃**:5000 层嵌套 JSON 触发原生 stringify 栈溢出直接抛异常(生产路径有 JSON.parse 兜底,PTC 直调会崩)。加 try/catch 降级为裁剪的字符串渲染
30
+ - **unload 漏清 failCache**:v1.2.0 拆出的失败缓存未在插件卸载时清理,违反"unload 完全回退"承诺
31
+ - **extractLinks 协议过滤**:`ftp:` 等非 web 协议链接原先能通过 URL 归一化进入链接列表与爬虫队列,现在只保留 http/https
32
+
33
+ **验证**:88 单元断言(新增对抗输入限时回归、散文保留、深 JSON 降级)+ 12 SPA 断言全绿;对抗探针全部向量线性化(80k 恶意标签 <5s,修复前 80s+);扩展类别 20/24 OK(失败均为环境边界:Stack Overflow/Wikipedia/doi 403 或超时);152 站三轮回归 85/83/100 OK、0 崩溃、0 内容性回归,轮间抖动经交叉比对全部为环境性(反爬 403/503、连接超时),三连败站点均为已知边界(README 已记载的登录墙/反爬/境外不可达)
34
+
35
+ ## [1.1.0] - 2026-08-22
36
+
37
+ ### 适配 DSH 0.1.1-rc.2:并行工具调用声明
38
+
39
+ 对 `@deepseek-ai/dsh` 0.1.0-rc.8 → 0.1.1-rc.2 做了逐包静态对比(dsh-tools / dsh-tool-web / dsh-base / dsh-headless / dsh-tool-call-timeout-policy / dsh-agent-loop 的 lib 逐字节一致,唯一变化是 dsh-tool-cordis 新增 host 侧 API——authorization flows、session projections host-only units、image attachment policy、webserver index injections,全部为增量,无删除),插件所依赖的 API 面(`ctx.tools.register` / `ctx.effect` / `ctx.web` seam / `ToolDefinition.timeoutMs` / `exec.signal`)**零破坏性变化**,cordis 核心 4.0.1 两版一致。
40
+
41
+ **新增:`isConcurrencySafe` 并行声明(4 个工具全部启用)**
42
+ - DSH agent loop 会把连续的并行安全工具调用归入有界滚动池——此前 read_url 系工具未声明,即使模型同时发多个请求也被逐个串行执行
43
+ - 全部共享状态审查确认交换性安全:会话缓存 Map(get/set 原子,重叠 miss 最多重复抓一次)、解码器缓存(TextDecoder 无状态)、readability 延迟 import(幂等)、SPA 渲染(共享 browser 单例 + 每次调用独立 `newPage`,page 间隔离)、系统代理检测缓存(读环境变量,双写同值)、爬虫去重集合(调用局部)
44
+ - 效果:多源阅读任务(一次读 3–5 个 URL 对比观点)由串行变并行,墙钟时间按最慢一站计
45
+ - 新增单测:4 工具声明锁定 + 6 路并发 read_url 缓存竞态烟雾测试(每个结果必须携带自己的正文,绝不串扰)
46
+
47
+ **验证**:79 单元断言(+2)+ 12 SPA 断言全绿;新版 DSH `--dump-config` 配置树正常解析;headless 端到端实测 read_url 真实调用成功(example.com 返回正确标题)。
48
+
3
49
  ## [1.0.0] - 2026-08-21
4
50
 
5
51
  ### 量大管饱的持久版本:一次把「读网页」这件事做全
package/README.md CHANGED
@@ -41,7 +41,8 @@ Implemented per official docs (`docs/capability-seams.md`, `docs/cordis-primer.m
41
41
  1. **Web access via the `ctx.web` capability seam** — all web requests go through `ctx.web.fetch()` first (provider resolved inside the seam, same as official `tool-web`), falling back to global fetch when the seam is absent. The network layer is replaceable, not bound to any provider;
42
42
  2. **Reversible side effects** — the session cache is registered under `ctx.effect`, auto-cleared on plugin unload (temporal composability);
43
43
  3. **Cooperative tool-call timeout** — `ToolDefinition.timeoutMs` declares the budget, `execute(args, exec)` forwards `exec.signal` to fetch; the timeout policy is enforced by the pipeline, never exposed to the model;
44
- 4. **Model-facing simplicity** — render emits compact text (`title:` header + body); the model consumes it directly with no JSON parsing. Defaults are the most token-efficient; structured output is opt-in.
44
+ 4. **Model-facing simplicity** — render emits compact text (`title:` header + body); the model consumes it directly with no JSON parsing. Defaults are the most token-efficient; structured output is opt-in;
45
+ 5. **Parallel tool calls** — all four tools declare `isConcurrencySafe` (since v1.1.0): every piece of shared state (session cache, decoder cache, per-render isolated browser pages) is commutative-safe, so the agent loop may fan out several read_url calls into one parallel group — the wall-clock time of a multi-source reading task is that of the slowest site, not the sum.
45
46
 
46
47
  ## Install
47
48
 
@@ -106,7 +107,7 @@ chars 800+800/12398 · cached
106
107
 
107
108
  ### Tools
108
109
 
109
- **`read_url(url, maxChars?, offset?, mode?, includeLinks?)`** — fetch and extract clean body. Handles HTML pages, JSON APIs (compact re-indented render) and RSS/Atom feeds (entry list + `feedCount`); paginated articles (novel/news/forum) are auto-joined up to `paginateMax` pages; page metadata (`published`, `author`) is harvested automatically — meta tags first, with a byline fallback from the body text when meta is absent
110
+ **`read_url(url, maxChars?, offset?, mode?, includeLinks?)`** — fetch and extract clean body. Handles HTML pages, JSON APIs (fully compact render with long-value clipping) and RSS/Atom feeds (entry list + `feedCount`); paginated articles (novel/news/forum) are auto-joined up to `paginateMax` pages; page metadata (`published`, `author`) is harvested automatically — meta tags first, with a byline fallback from the body text when meta is absent
110
111
 
111
112
  | Param | Type | Default | Description |
112
113
  |---|---|---|---|
@@ -220,7 +221,7 @@ const results = await Promise.all([
220
221
  ## Technical notes
221
222
 
222
223
  - **Encoding**: BOM-first detection (UTF-8 / UTF-16LE / UTF-16BE — byte-level evidence beats any declared charset), then HTTP `Content-Type` charset → HTML meta; built-in `TextDecoder` transcoding (Node 20+ full-icu, so declared Shift-JIS/EUC-JP/GBK/Big5 all decode), GB2312 normalized to GBK, auto-fallback to UTF-8 on mojibake;
223
- - **Content dispatch**: a URL is not always an HTML page — JSON APIs are re-rendered compact (indent 1), RSS 2.0 / Atom feeds parse into an entry list (`title — url` + summary, `feedCount` field, full items via `includeLinks`; entry summaries are iteratively tag-stripped and entity-decoded until stable, so double-escaped `&lt;a&gt;` never leaks as a literal tag); XML sitemaps are rejected with a clear reason (no reading value); everything else falls through to the HTML pipeline;
224
+ - **Content dispatch**: a URL is not always an HTML page — JSON APIs are re-rendered fully compact with no indentation, and string values over 1500 chars are clipped with a visible marker (since v1.2.0), RSS 2.0 / Atom feeds parse into an entry list (`title — url` + summary, `feedCount` field, full items via `includeLinks`; entry summaries are iteratively tag-stripped and entity-decoded until stable, so double-escaped `&lt;a&gt;` never leaks as a literal tag); XML sitemaps are rejected with a clear reason (no reading value); everything else falls through to the HTML pipeline;
224
225
  - **Extraction**: prefers `<article>` (all articles joined on aggregation pages; an unrelated tiny article — e.g. a newsletter card — falls through to `<main>` when its text is under 200 chars and `<main>` exists) / `<main>` / `role="main"`; `role="main"` containers are closed via **depth counting of balanced tags** (nested divs no longer cut the block at the first `</div>` — measured: gnu.org used to lose 7/8 of its body this way); strips `nav/footer/header/aside/form/iframe` and ad-like containers, heuristic fallback to `<body>`; on the body path a **text-density pass** drops link-dominated segments (related posts, category sidebars, hot-article widgets) — pages with standard containers never reach it;
225
226
  - **Pagination**: auto-follows `rel=next` or a short next-page anchor (下一页 / next / › / » — conservative, no fuzzy guessing); same-host only, loop-guarded, repeated paragraphs across the seam de-duplicated; continuation pages take the fast static path (a paginated SPA chain would cost one full render per page);
226
227
  - **Metadata**: `published` / `author` harvested from meta tags into the output and the status line; when the page has no such meta (ruanyifeng.com ships zero author/date tags) a **byline fallback** harvests the body head (600-char window: `作者:X / 日期:Y` — meta wins, deep-body mentions ignored, markdown link syntax stripped); empty-body pages (login walls, JS shells) fall back to `og:description` as a hint instead of nothing;
@@ -232,7 +233,7 @@ const results = await Promise.all([
232
233
  - **Optional enhancement 2 (SPA page rendering)**: run `npm i playwright && npx playwright install chromium` in the DSH profile directory to auto-enable it. When the extracted body is empty and the page is script-heavy (likely Vue/React client-rendered) or a JS-redirect shell (few scripts but an empty `<body>`), the plugin automatically renders it with headless Chromium before extracting (a `rendered` flag tells the model); the rendered text is accepted only when it meaningfully beats the static one (≥20 chars from an empty static extraction — short real content is no longer rejected); **bot-challenge defense** — Cloudflare-style interstitials ("Just a moment...") get an extra 8s poll for the auto-redirect, and if the page still looks like a challenge the rendered result is rejected and the static body kept (an interstitial can carry MORE text than the real body — measured 259 vs 135 chars — and must never be mistaken for an improvement); the interstitial DOM never feeds pagination/link extraction either; rendering waits for the DOM to stabilize (content stops growing) instead of `networkidle` — heartbeat-polling sites never idle, so this avoids 30s timeouts; when not installed it degrades with a clear install hint, never errors — the core stays zero-dependency;
233
234
  - **Boundaries**: login-walled pages are not readable; SPA pages need the Playwright enhancement; **structured data (e.g. which like-count belongs to which comment) is out of text-extraction scope** — this plugin flattens HTML into readable text, so exact field↔value associations are lost; for precise fields, intercept the page's actual data API (see "Real-world validation" below).
234
235
 
235
- ## Real-world validation (2026-08-21, v1.0.0)
236
+ ## Real-world validation (2026-08-21, v1.0.0; re-verified 2026-08-22 against DSH 0.1.1-rc.2)
236
237
 
237
238
  152-site sweep driven by `multi-site.mjs` (committed, re-runnable, 8-way concurrent): **115 OK / 17 expected boundaries (login-walls·captcha·short static pages) / 20 attributed network·anti-bot errors / 0 crashes** (final round with all pre-release fixes in; network-class errors vary ±5 between runs, all environment-attributed). Coverage: CN portals/media, e-commerce (JD/Taobao/Pinduoduo/Suning/Dangdang), video (Bilibili/iQiyi/Youku/Mango), music, games, novels (Qidian/Zongheng/JJWXC legacy GBK), Q&A/forums, government, universities (Tsinghua/PKU/Fudan/SJTU…), Traditional-Chinese TW/HK (PTT/LTN/UDN), JP/KR portals (Yahoo JP/Hatena/goo/naver/daum), overseas tech docs (GitHub/dev.to/react.dev/nodejs.org/rust/go/python), feeds, JSON APIs, encoding stress (GBK/GB2312/Big5/gb18030), anti-bot & network boundaries. All errors are environment-attributed (Wikipedia/Reddit/UDN connect-timeout; W3C/Tieba/NGA/StackOverflow 403; BUPT 412; DNS-fail…) — every one returned as a structured, correctly-attributed error, never a crash.
238
239
 
@@ -257,7 +258,7 @@ Plus a **15-item DSH acceptance round** (a real agent driving every read_url too
257
258
  | Batch + failure isolation | 4-URL mix | ✅ 2/4 ok, failures isolated |
258
259
  | Site crawl | Ruan Yifeng blog | ✅ 5/5 pages tree map |
259
260
 
260
- - **77 zero-dep assertions** (incl. entity decoding, description-budget guard, link dedupe, table-separator escaping, proxy-fallback function, missing-args tolerance, race logic, empty-race guard, schema budget, bare-main pick, worst-case timeout budgets, yml string coercion + clamping, strict-host seam degradation, UTF-16 BOM, Shift-JIS, density filter, pagination join/cap/disable, JSON render, RSS parse, sitemap rejection, 429 Retry-After retry, image alt, code-fence language, metadata, og:description fallback, double-escaped feed, headerless binary sniff, nested role=main, tiny-article fallback, unbalanced-tag degradation, byline fallback, challenge-page detection) + **12 SPA-test assertions** all green;
261
+ - **88 zero-dep assertions** (v1.2.0 adds: sentence-aligned truncation, compact JSON, pagination variants, adversarial-input time bounds, prose &lt; preservation, deep-JSON degradation) (incl. entity decoding, description-budget guard, link dedupe, table-separator escaping, proxy-fallback function, missing-args tolerance, race logic, empty-race guard, schema budget, bare-main pick, worst-case timeout budgets, yml string coercion + clamping, strict-host seam degradation, UTF-16 BOM, Shift-JIS, density filter, pagination join/cap/disable, JSON render, RSS parse, sitemap rejection, 429 Retry-After retry, image alt, code-fence language, metadata, og:description fallback, double-escaped feed, headerless binary sniff, nested role=main, tiny-article fallback, unbalanced-tag degradation, byline fallback, challenge-page detection, isConcurrencySafe declaration + concurrent cache-race smoke) + **12 SPA-test assertions** all green;
261
262
  - Real case: on a Xiaoheihe post, comment like-counts (`up` field) could not be attributed from flattened text — **precise fields should come from the page's underlying data API** (e.g. `/bbs/app/link/tree` JSON). This is a shared boundary of text extractors, not a defect.
262
263
 
263
264
  ## Roadmap
@@ -272,6 +273,9 @@ Plus a **15-item DSH acceptance round** (a real agent driving every read_url too
272
273
  - [x] Text-density fallback + metadata harvesting (v1.0.0)
273
274
  - [x] Bot-challenge defense (Cloudflare interstitial detection + auto-redirect wait + rejection, v1.0.0)
274
275
  - [x] Byline fallback for meta-less pages (author / published, v1.0.0)
276
+ - [x] Parallel tool-call declaration (isConcurrencySafe; multi-source wall-clock time = slowest site, v1.1.0)
277
+ - [x] Separate failure cache, label-based race attribution, sentence-aligned truncation, fully compact JSON render (~21% smaller), merged status flags, arrow-wrapped pagination variants (v1.2.0)
278
+ - [x] Adversarial-page linearization (unclosed-tag/unpaired-lt/attribute-scan bounds + recursion depth cap, fixing a quadratic DoS vector), prose &lt; preservation, proxy-path redirects keep the final URL, deep-JSON degradation instead of crash (v1.2.0 round 2)
275
279
 
276
280
  > From v1.0.0 the plugin enters maintenance mode: bug fixes first, updates kept rare.
277
281
 
package/README.zh.md CHANGED
@@ -41,7 +41,8 @@ DSH 的 Agent 能搜索(返回链接和片段),但缺"把 URL 读成干净
41
41
  1. **网络访问走 `ctx.web` 能力缝**——所有 web 访问优先通过 `ctx.web.fetch()`(seam 内解析 provider,与官方 `tool-web` 一致),seam 缺失时回退全局 fetch。网络层可替换,不绑定任何具体 provider;
42
42
  2. **可逆副作用**——会话缓存注册在 `ctx.effect` 下,插件卸载即自动清理(时间可组合性);
43
43
  3. **协作式工具调用超时**——`ToolDefinition.timeoutMs` 声明预算,`execute(args, exec)` 把 `exec.signal` 转发给 fetch,超时策略由管线强制执行,不把超时暴露给模型;
44
- 4. **模型视角精简**——render 输出紧凑文本(`title:` 头部 + 正文),模型直接消费,无需解析 JSON;默认参数最省 token,结构化能力按需开启。
44
+ 4. **模型视角精简**——render 输出紧凑文本(`title:` 头部 + 正文),模型直接消费,无需解析 JSON;默认参数最省 token,结构化能力按需开启;
45
+ 5. **并行工具调用**——4 个工具全部声明 `isConcurrencySafe`(v1.1.0 起):共享状态(会话缓存 / 解码器缓存 / SPA 浏览器 page 隔离)均满足交换性安全,agent loop 可把多个 read_url 调用归入并行池——多源阅读任务的墙钟时间按最慢一站计,而非各站之和。
45
46
 
46
47
  ## 安装
47
48
 
@@ -220,7 +221,7 @@ const results = await Promise.all([
220
221
  ## 技术说明
221
222
 
222
223
  - **编码**:BOM 优先探测(UTF-8 / UTF-16LE / UTF-16BE——字节级证据优先于任何声明),其次 HTTP `Content-Type` charset → HTML meta;内置 `TextDecoder` 转码(Node 20+ full-icu,页面声明的 Shift-JIS/EUC-JP/GBK/Big5 均可正确解码),GB2312 归一为 GBK,检测到乱码自动回退 UTF-8;
223
- - **内容类型分发**:URL 不一定是 HTML——JSON 接口紧凑重排渲染(缩进 1 格),RSS 2.0 / Atom 订阅源解析为条目列表(`标题 — 链接` + 摘要,`feedCount` 字段,`includeLinks` 时附完整 items;条目摘要迭代「剥标签+解实体」直到稳定,双重转义的 `&lt;a&gt;` 不会漏成字面标签);XML sitemap 明确拒绝(对模型无阅读价值);其余全部走 HTML 管线;
224
+ - **内容类型分发**:URL 不一定是 HTML——JSON 接口紧凑重排渲染(无缩进,超长字符串值 >1500 字符截断并标注,v1.2.0 起缩进 1 格改为完全紧凑),RSS 2.0 / Atom 订阅源解析为条目列表(`标题 — 链接` + 摘要,`feedCount` 字段,`includeLinks` 时附完整 items;条目摘要迭代「剥标签+解实体」直到稳定,双重转义的 `&lt;a&gt;` 不会漏成字面标签);XML sitemap 明确拒绝(对模型无阅读价值);其余全部走 HTML 管线;
224
225
  - **正文提取**:优先 `<article>`(聚合页多篇合并;无关小卡片 article——如订阅挂件——文本不足 200 字符且页面有 `<main>` 时自动回落 main)/ `<main>` / `role="main"`,`role="main"` 容器用**深度计数找平衡闭合标签**(嵌套 div 不会在第一个 `</div>` 被截断——实测 gnu.org 曾因此只取到 1/8 正文);剥离 `nav/footer/header/aside/form/iframe` 及广告类容器,启发式回归到 `<body>`;body 路径上追加**文本密度过滤**——丢弃链接主导的短块(相关推荐/分类侧栏/热门文章挂件),标准容器页面完全不走此路径;
225
226
  - **分页拼接**:识别 `rel=next`(标准)或纯「下一页 / next / › / »」短锚文本(刻意保守,不做模糊猜测);同域限定 + 防环;跨页重复段落自动去重;续页走静态快路径(分页 SPA 链每页一次完整渲染不划算);
226
227
  - **元数据**:`published` / `author` 从 meta 标签提取进输出字段与状态行;页面无相关 meta 时(如阮一峰博客零 meta 标签)从**正文头部 600 字符的署名行兜底**(「作者:X / 日期:2026年8月21日」,meta 优先、正文深部提及不误采、markdown 链接语法不泄漏);空正文页(登录墙/JS 壳)回落到 `og:description` 作为提示,不再返回空;
@@ -232,7 +233,7 @@ const results = await Promise.all([
232
233
  - **可选增强二(SPA 页面渲染)**:在 DSH profile 目录执行 `npm i playwright && npx playwright install chromium` 后自动启用。检测到正文为空且(页面脚本密集 疑似 Vue/React 客户端渲染,或 body 为空的 JS 跳转壳——script 数不多但正文全靠跳转)时,自动用无头 Chromium 渲染后再提取(`rendered` 标记告知模型);渲染结果仅在**显著优于**静态提取时采用(静态为空时 ≥20 字符即接受,防短正文被拒);**人机验证页防御**——Cloudflare「Just a moment...」等指纹页识别后额外轮询 8s 供其自动跳转,仍未通过则拒绝渲染结果、保留静态正文(指纹页文字量可能超过真实正文,实测 259 vs 135 字符,绝不当作提升),指纹页 DOM 也不污染分页/链接提取;渲染采用 `domcontentloaded` + **DOM 稳定轮询**(内容停止增长即收,上限 10s)而非 `networkidle`——心跳轮询站永不空闲,避免 30s 超时;未安装时优雅提示安装方法、不报错——核心保持零依赖;
233
234
  - **边界**:登录墙页面无法读取;SPA 页面需安装 Playwright 增强后渲染读取(未安装时返回明确提示);**结构化数据(如评论的点赞数归属、榜单数值)不在文本提取范围**——本插件把 HTML 扁平化为可读文本,字段与数值的精确对应关系会丢失;需要精确字段时,用 Playwright 拦截页面实际调用的数据 API 获取(见下方「真实世界验证」)。
234
235
 
235
- ## 真实世界验证(2026-08-21,v1.0.0)
236
+ ## 真实世界验证(2026-08-21,v1.0.0;2026-08-22 适配 DSH 0.1.1-rc.2 复验)
236
237
 
237
238
  152 站全量实测(`multi-site.mjs` 已提交可复跑,8 并发):**115 OK / 17 预期边界(登录墙·验证页·静态小页) / 20 网络·反爬归因错误 / 0 崩溃**(含全部发布前修复的终态轮;网络类错误逐轮有 ±5 波动,均为环境归因)。覆盖国内门户 / 媒体 / 电商(京东·淘宝·拼多多·苏宁·当当)/ 视频(B 站·爱奇艺·优酷·芒果)/ 音乐 / 游戏 / 小说(起点·纵横·晋江 legacy GBK)/ 问答 / 论坛 / 政府 / 高校(清北复交等 8 所)/ 港台繁体(PTT·自由时报·联合报)/ 日韩(Yahoo JP·Hatena·goo·naver·daum)/ 海外技术站(GitHub·dev.to·react.dev·nodejs·rust·go·python docs)/ 订阅源 / JSON API / 编码压力(GBK·GB2312·Big5·gb18030)/ 反爬与网络边界。错误全部环境归因(维基/Reddit/UDN 连接超时;W3C/贴吧/NGA/StackOverflow 403;北邮 412;DNS 失败等)——每一个都返回结构化、准确归因的错误,无一崩溃。
238
239
 
@@ -257,7 +258,7 @@ const results = await Promise.all([
257
258
  | **批量 + 失败隔离** | 4 URL 混合 | ✅ 2/4 成功、失败隔离 |
258
259
  | **整站爬取** | 阮一峰博客 | ✅ 5/5 页树状站点地图 |
259
260
 
260
- - **77 个单元断言**(含实体解码、description/schema 预算守卫、链接去重、表格分隔行转义、代理回退函数、空参容错、竞速逻辑、空竞速守卫、裸 main 提取、最坏链路超时预算、yml 字符串强转+钳制、严格宿主 seam 降级、UTF-16 BOM、Shift-JIS、密度过滤、分页拼接/封顶/关闭、JSON 渲染、RSS 解析、sitemap 拒绝、429 Retry-After 重试、图片 alt、代码语言、元数据、og:description 回落、双转义 feed、无头二进制嗅探、嵌套 role=main、薄 article 回落、不平衡标签降级、byline 兜底、人机验证页识别)+ **12 个 SPA 测试断言**全绿;
261
+ - **88 个单元断言**(v1.2.0 新增:长段落句级对齐、紧凑 JSON、分页变体、对抗输入限时、散文 &lt; 保留、深 JSON 降级)(含实体解码、description/schema 预算守卫、链接去重、表格分隔行转义、代理回退函数、空参容错、竞速逻辑、空竞速守卫、裸 main 提取、最坏链路超时预算、yml 字符串强转+钳制、严格宿主 seam 降级、UTF-16 BOM、Shift-JIS、密度过滤、分页拼接/封顶/关闭、JSON 渲染、RSS 解析、sitemap 拒绝、429 Retry-After 重试、图片 alt、代码语言、元数据、og:description 回落、双转义 feed、无头二进制嗅探、嵌套 role=main、薄 article 回落、不平衡标签降级、byline 兜底、人机验证页识别、isConcurrencySafe 声明 + 并发缓存竞态烟雾)+ **12 个 SPA 测试断言**全绿;
261
262
  - 一个真实案例:小黑盒帖子的评论点赞数(`up` 字段)无法从扁平文本确定归属——**精确字段应走页面背后的数据 API**(如 `/bbs/app/link/tree` JSON),这是同类文本提取器的共同边界,不是缺陷。
262
263
 
263
264
  ## Roadmap
@@ -272,6 +273,9 @@ const results = await Promise.all([
272
273
  - [x] 文本密度兜底 + 元数据提取(v1.0.0)
273
274
  - [x] 人机验证页防御(Cloudflare 指纹页识别 + 等待自动跳转 + 拒绝误采,v1.0.0)
274
275
  - [x] 无 meta 页面署名行兜底(author / published,v1.0.0)
276
+ - [x] 并行工具调用声明(isConcurrencySafe,多源阅读墙钟时间按最慢一站计,v1.1.0)
277
+ - [x] 失败缓存独立(不再挤占成功缓存名额)、race 错误按 label 归因、长段落句级对齐截断、JSON 完全紧凑渲染 + 长值截断(约省 21%)、状态行合并、分页箭头变体(v1.2.0)
278
+ - [x] 对抗页面线性化(无配对尖括号/无闭合标签/属性扫描加界 + 递归深度帽,修复 60KB→2.2s 的二次复杂度 DoS 向量)、散文 &lt; 不再被吞、代理重定向保留最终 URL、深 JSON 降级不崩溃(v1.2.0 第二轮)
275
279
 
276
280
  > v1.0.0 起进入维护期:以修 bug 为主,减少更新频率。
277
281