dsh-trajectory-traceview-plus 0.11.10 → 0.11.12

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,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.12 — 声明审计(2026-11-29)
4
+
5
+ - **「声明审计」第一轮:挖掉两处会自己腐化的数字,并给其中一处加了守卫。**
6
+ 0.11.7 以来新增的文档里,"摘要覆盖 15 个文件"和"48 组 / 314 条断言"都是**写死的当前值**。
7
+ 后者当时就过期了(已是 51 组 / 332 条)。数字只该有一个真相源:
8
+ - `DESIGN §13.69.9` 与 `probe-receipt-check.mjs` 注释里的具体数字直接删掉,改成说明
9
+ "数字由 `readme-numbers` 从探针文件数出来"
10
+ - README 的"摘要覆盖 15 个文件"改成由 `readme-numbers` 拿 `probeInputs().length` 核对
11
+ (变异:故意写 16 → 红)
12
+ - **顺带第三次踩到 TDZ,而 Z1/Z2 只守 `src/`。** 把 `digestFileCount` 定义在了使用点旁边,
13
+ 模块直接抛 `Cannot access 'digestFileCount' before initialization`。之前两次分别在
14
+ `probe-detail2.js`(`tick`)和 `probe-detail3.js`(`tick`)。同类错误在 `scripts/`
15
+ 和 `test/` 里没有任何守卫。
16
+
17
+ ## 0.11.11 — 折叠按钮的真 ARIA(2026-11-29)
18
+
19
+ - **折叠按钮的 ARIA 语义是假的,已改成真正的 toggle。** 上一版那个「显示全文」按钮点完
20
+ 就把自己换成全文,却硬编码了 `aria-expanded="false"`:那个状态永远变不成 true,
21
+ 而屏幕阅读器用户被告知存在一个可折叠区域,却既收不回也导航不到(没有 `aria-controls`)。
22
+ 现在按钮保留、`aria-expanded` 跟随状态翻转、`aria-controls` 指向真实区域,标签在
23
+ 「显示全文(N 字符)」与「收起」之间切换。探针 23q 增加三条:`aria-controls` 必须解析
24
+ 到元素、展开后 `aria-expanded` 变 true、再点必须收回且 DOM 回落;
25
+ 变异(`aria-expanded` 恒 false)→ 红。
26
+
3
27
  ## 0.11.10 — 详情面板折叠(2026-11-29)
4
28
 
5
29
  - **详情面板打开一条 1 MB 消息要 0.5 秒——这次两全了。** 之前 README 把它写成明示取舍
package/README.en.md CHANGED
@@ -136,7 +136,7 @@ dsh-trajectory-traceview-plus/ # repo root (directory name == npm package name
136
136
  Install from npm (recommended — **pin the exact version**):
137
137
 
138
138
  ```powershell
139
- dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.10
139
+ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.12
140
140
  ```
141
141
 
142
142
  > **Why not `@latest`**: `dsh plugin` forwards to pnpm, and **pnpm 12 ships a supply-chain delay** (`minimumReleaseAge`, default **1440 minutes = 24 hours**): a version published less than a day ago is not selected by `@latest`, and pnpm **silently falls back to the previous release** — no warning at all. Right after 0.11.0 was published, `pnpm add pkg@latest` installed 0.10.0, which the newer DSH hosts skip entirely. An exact version has no such ambiguity (verified with both cold and warm caches).
@@ -148,10 +148,10 @@ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.10
148
148
  Install from GitHub (**always pin the tag**):
149
149
 
150
150
  ```powershell
151
- dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.10"
151
+ dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.12"
152
152
  ```
153
153
 
154
- > **Why the `#v0.11.10` matters**: a `github:` spec without a ref installs the **default branch HEAD**, not any released version. This repository keeps committing after a release (v0.11.0 was followed by five docs/scripts commits), so an unpinned install can hand you different code tomorrow while still reporting version 0.11.0. Pinning the tag is what makes "installed" and "released" the same code.
154
+ > **Why the `#v0.11.12` matters**: a `github:` spec without a ref installs the **default branch HEAD**, not any released version. This repository keeps committing after a release (v0.11.0 was followed by five docs/scripts commits), so an unpinned install can hand you different code tomorrow while still reporting version 0.11.0. Pinning the tag is what makes "installed" and "released" the same code.
155
155
 
156
156
  Then **restart `dsh web`** to take effect.
157
157
 
@@ -268,7 +268,7 @@ The tests run the helper region against mock snapshots covering: tree building /
268
268
  **What needs a real browser** (`react-dom/server` cannot see scroll, focus, clipboard, intervals or layout):
269
269
 
270
270
  ```powershell
271
- node scripts/browser-check.mjs # builds the harness; 327 assertions over 51 recorded groups
271
+ node scripts/browser-check.mjs # builds the harness; 332 assertions over 51 recorded groups
272
272
  node scripts/browser-check.mjs --shots # saves screenshots and adds 1 more group / 3 assertions: 375px overflow (52 total)
273
273
  ```
274
274
 
@@ -332,15 +332,15 @@ node scripts/browser-check.mjs # 4.5 run the real browser probe (needs
332
332
  npm run check # 5. the 11 local gates; all green before going further
333
333
  git add -A; git commit -m "..." # 6.
334
334
  git push origin main # 7.
335
- git tag -a v0.11.10 -m "..." # 8.
336
- git push origin v0.11.10 # 9.
335
+ git tag -a v0.11.12 -m "..." # 8.
336
+ git push origin v0.11.12 # 9.
337
337
  npm publish # 10. runs prepublishOnly -> the whole check again
338
- gh release create v0.11.10 --notes-file … # 11. the badge reads the Release, not the tag
338
+ gh release create v0.11.12 --notes-file … # 11. the badge reads the Release, not the tag
339
339
 
340
340
  node scripts/release-status.mjs # 12. do all four agree? (tag / Release / npm metadata / tarball)
341
341
  ```
342
342
 
343
- **Touch `src/` and you must rerun step 4.5**, or the receipt gate goes red:
343
+ **Touch `src/`, the fixture, any probe file, or either driver script, and you must rerun step 4.5**, or the receipt gate goes red:
344
344
  `probe-receipt-check` compares the digest inside `test/browser/probe-receipt.json` against
345
345
  the current tree and fails with `STALE — the probe inputs changed…`. The digest covers 15
346
346
  files (`src/*.js`, `fixture.js`, the five `probe*.js`, two driver scripts) — **including
package/README.md CHANGED
@@ -139,7 +139,7 @@ dsh-trajectory-traceview-plus/ # 仓库根(目录名 = npm 包名)
139
139
  从 npm 安装(推荐,**写死版本号**):
140
140
 
141
141
  ```powershell
142
- dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.10
142
+ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.12
143
143
  ```
144
144
 
145
145
  > **为什么不用 `@latest`**:`dsh plugin` 底层是 pnpm,而 **pnpm 12 有供应链延迟保护**
@@ -160,10 +160,10 @@ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.10
160
160
  从 GitHub 安装(**必须带 tag**):
161
161
 
162
162
  ```powershell
163
- dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.10"
163
+ dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.12"
164
164
  ```
165
165
 
166
- > **为什么必须带 `#v0.11.10`**:`github:` 规格不带 ref 时装的是**默认分支的 HEAD**,
166
+ > **为什么必须带 `#v0.11.12`**:`github:` 规格不带 ref 时装的是**默认分支的 HEAD**,
167
167
  > 不是任何发布版本。而这个仓库在发版后还会继续提交(本轮 v0.11.0 之后就有 5 个
168
168
  > 文档/脚本提交),所以"不带 ref"装到的东西**明天可能是另一个样子**,而版本号
169
169
  > 仍写着 0.11.0。带 tag 才能让"装到的"和"发布过的"是同一份代码。
@@ -286,7 +286,7 @@ npm test # 只跑 smoke
286
286
  **需要真实浏览器的部分**(`react-dom/server` 测不到滚动、焦点、剪贴板、定时器、响应式):
287
287
 
288
288
  ```powershell
289
- node scripts/browser-check.mjs # 起 harness,跑 327 条断言 / 记录 51 组观测
289
+ node scripts/browser-check.mjs # 起 harness,跑 332 条断言 / 记录 51 组观测
290
290
  node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 3 条断言(375px 溢出,共 52 组)
291
291
  ```
292
292
 
@@ -306,9 +306,10 @@ node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 3 条
306
306
  - **版本不兼容会大声说**:如果 DSH 升级后字段名或节点类型变了,头部显示 `⚠ N 条记录无法识别 [类型名]`;若**一条都认不出**,显示「无法识别当前会话的轨迹数据格式」并列出原因码——**不会伪装成"暂无数据"或一份看起来正常的残缺轨迹**。
307
307
  - **超长文本有明确取舍**:站点卡是缩略图,正文封顶 20,000 字符、tooltip 封顶 300(末尾补 `…`)——
308
308
  不封顶时一条 1 MB 消息会整条塞进 DOM(实测单卡 1,575 ms、1,000,007 字符)。**完整内容不丢**:
309
- 复制、详情面板、导出都拿到原文。详情面板对超长正文先渲染前 50,000 字符并给一个
310
- 「显示全文(N 字符)」按钮——**被截断的只是 DOM,不是数据**:打开单条 1 MB 消息从
311
- 实测 488 ms 降到 19 ms,点按钮展开全文约 430 ms,复制和导出始终是全文。
309
+ 复制、详情面板、导出都拿到原文。详情面板对超长正文先渲染前 50,000 字符,并给一个
310
+ **可来回切换**的「显示全文(N 字符)/收起」按钮(`aria-expanded` 与 `aria-controls`
311
+ 都如实指向那块区域)——**被截断的只是 DOM,不是数据**:打开单条 1 MB 消息从实测
312
+ 488 ms 降到 19 ms,展开约 430 ms,复制和导出始终是全文。
312
313
  - **不冤枉宿主**:`kind: "unknown"` 是契约里**有名字**的节点类型(宿主明确表示"这条事件我不建模"),所以它被当成一等站点画出来,标出事件类型与原始数据,**不计入"版本不兼容"**。只有真正没见过的节点类型才报警。这条区别很重要:一个陌生事件不该让整棵树改口说"格式不认识"。
313
314
 
314
315
  `engines.dsh` 是 `>=0.2.2-rc.2 <0.2.3-0`——**只覆盖 0.2.2 这一条实测过的线**,不跨 minor。旧钉版 `=0.2.1-rc.5`、`=0.2.2-rc.2` 的历史结论保留在 `docs/DESIGN.md` §12.25–§12.27、§13.43。
@@ -359,15 +360,15 @@ node scripts/browser-check.mjs # 4.5 跑真正的浏览器探针(需
359
360
  npm run check # 5. 11 步门禁,全绿再往下(含凭证校验)
360
361
  git add -A; git commit -m "..." # 6.
361
362
  git push origin main # 7.
362
- git tag -a v0.11.10 -m "..." # 8.
363
- git push origin v0.11.10 # 9.
363
+ git tag -a v0.11.12 -m "..." # 8.
364
+ git push origin v0.11.12 # 9.
364
365
  npm publish # 10. 触发 prepublishOnly → 再跑一遍 check
365
- gh release create v0.11.10 --notes-file … # 11. 徽章读的是 Release,不是 tag
366
+ gh release create v0.11.12 --notes-file … # 11. 徽章读的是 Release,不是 tag
366
367
 
367
368
  node scripts/release-status.mjs # 12. 四处对齐了吗?(tag / Release / npm 元数据 / tarball)
368
369
  ```
369
370
 
370
- **改过 `src/`、夹具或任何一个探针文件,就必须重跑步骤 4.5**,否则步骤 5 会红:
371
+ **改过 `src/`、夹具、任何一个探针文件,或两个驱动脚本之一,就必须重跑步骤 4.5**,否则步骤 5 会红:
371
372
  `probe-receipt-check` 拿 `test/browser/probe-receipt.json` 里的摘要和当前树对比,不一致就报
372
373
  `STALE — the probe inputs changed…`。摘要覆盖 15 个文件(`src/*.js`、`fixture.js`、
373
374
  五个 `probe*.js`、两个驱动脚本)——**包括断言本身**,否则"删掉一百条断言"也能让凭证保持绿色。这条守卫存在的原因很具体:浏览器探针
package/docs/DESIGN.md CHANGED
@@ -9703,7 +9703,7 @@ panel text: Trace ViewUserStepToolCompactionerror⏮⇤◀…
9703
9703
 
9704
9704
  ### 13.69.9 探针跑不进 CI,于是"探针通过了"可以是关于一段不再存在的代码
9705
9705
 
9706
- 浏览器探针(48 组 / 314 条断言)跑不进 CI,这是**有意的**:`.github/workflows/check.yml`
9706
+ 浏览器探针跑不进 CI,这是**有意的**:`.github/workflows/check.yml`
9707
9707
  末尾写着理由——需要真 Chrome over CDP,而一个时红时绿的浏览器 job 会训练人忽略红构建。
9708
9708
 
9709
9709
  代价在 2026-11-28 这一周具体地暴露了两次:
@@ -9726,6 +9726,10 @@ panel text: Trace ViewUserStepToolCompactionerror⏮⇤◀…
9726
9726
  `probe-receipt-check.mjs` 重算 `src/*.js` 的摘要并对比,不一致就红,并直接告诉你该跑哪条命令。
9727
9727
  它进了 `npm run check`(第 11 步)和 CI,所以 `prepublishOnly` 也覆盖到了。
9728
9728
 
9729
+ **数字一律不写在这一节里**:探针的组数与断言数由 `readme-numbers.mjs` 从
9730
+ `test/browser/probe*.js` 数出来并核对 README,这里再抄一遍就是第二个真相源,
9731
+ 而第二个真相源一定会先腐化——本节初稿写的是当时的「48 组 / 314 条断言」,两天后就是错的。
9732
+
9729
9733
  **它证明什么、不证明什么**(写在这里,因为这类守卫最容易变成"有它就安心"):
9730
9734
 
9731
9735
  - 证明:探针在某个摘要上通过过,而那个摘要与当前的树相同。
@@ -10795,6 +10799,8 @@ boundary: false ← 没有渲染失败卡
10795
10799
  | 30 | 凭证只覆盖 `src/`,弱化断言不被发现 | 删掉一百条断言仍绿 | 摘要覆盖 15 个文件(`probe-digest.mjs`) |
10796
10800
  | 31 | 搜索计数/回放推进没有守卫 | 验证过但没写断言 | 探针 23o / 23p(均做过变异验证) |
10797
10801
  | 32 | 详情面板打开 1 MB 消息 488 ms | 全文当 markdown 一次灌进 DOM | 折叠到 50k + 「显示全文」,探针 23q(变异 → 红) |
10802
+ | 33 | 折叠按钮的 `aria-expanded` 永远为 false | 按钮点完即消失,状态无从翻转 | 改成真 toggle + `aria-controls`,探针 23q(变异 → 红) |
10803
+ | 34 | 文档里写死探针数字,两天就过期 | 「48 组 / 314 条」写进 DESIGN 与脚本注释 | 删除 + `readme-numbers` 核对文件数(变异 → 红) |
10798
10804
 
10799
10805
  ### 13.82.9 夹具与官方契约的一处偏差:`callSchemas` 是 Map,不是对象
10800
10806
 
package/lib/client.js CHANGED
@@ -111,6 +111,7 @@ window.__ModuleLoader__.load({
111
111
  "detail.request": "请求配置",
112
112
  "detail.systemPrompt": "系统提示",
113
113
  "detail.showAll": "显示全文",
114
+ "detail.collapse": "收起",
114
115
  "detail.systemOutside": "来自窗口外的系统事件 e{seq}",
115
116
  "detail.systemNone": "(当前窗口内没有系统提示)",
116
117
  "detail.toolsCatalog": "工具目录",
@@ -299,6 +300,7 @@ window.__ModuleLoader__.load({
299
300
  "detail.request": "Request config",
300
301
  "detail.systemPrompt": "System prompt",
301
302
  "detail.showAll": "Show all",
303
+ "detail.collapse": "Collapse",
302
304
  "detail.systemOutside": "from system event e{seq} outside the window",
303
305
  "detail.systemNone": "(no system prompt in this window)",
304
306
  "detail.toolsCatalog": "Tool catalog",
@@ -3794,23 +3796,37 @@ window.__ModuleLoader__.load({
3794
3796
  const DETAIL_TEXT_MAX = 50000;
3795
3797
 
3796
3798
  /** Long text rendered as markdown, with an explicit "show all" affordance. */
3797
- function FoldedMarkdown({ text, expandLabel, suffix }) {
3799
+ function FoldedMarkdown({ text, expandLabel, collapseLabel, suffix }) {
3798
3800
  const expandedState = (0, react.useState)(false);
3799
3801
  const expanded = expandedState[0];
3800
3802
  const setExpanded = expandedState[1];
3801
3803
  const value = typeof text === "string" ? text : "";
3802
3804
  const long = value.length > DETAIL_TEXT_MAX;
3803
- if (!long || expanded) return jsx(MarkdownText, { text: value }, long ? "mdAll" : "md");
3805
+ if (!long) return jsx(MarkdownText, { text: value }, "md");
3806
+ // A real TOGGLE, not a one-way reveal.
3807
+ //
3808
+ // The first version rendered a button labelled "show all" with a hard-coded
3809
+ // `aria-expanded="false"`, and clicking it replaced the button with the full
3810
+ // text. That is a lie in two ways: the attribute can never become true (the
3811
+ // control disappears), and a screen-reader user is told a collapsible region
3812
+ // exists that they can neither re-collapse nor locate, because nothing carries
3813
+ // an id they could navigate to. Now the button stays, flips its label and its
3814
+ // `aria-expanded`, and owns a labelled region — so every state it announces is
3815
+ // a state that actually exists.
3816
+ const regionId = "dstv_fold_" + String(value.length) + "_" + String(value.charCodeAt(0) || 0);
3804
3817
  return jsxs("div", { children: [
3805
- jsx(MarkdownText, { text: value.slice(0, DETAIL_TEXT_MAX) }, "mdPart"),
3818
+ jsx("div", { id: regionId, children: jsx(MarkdownText, { text: expanded ? value : value.slice(0, DETAIL_TEXT_MAX) }, expanded ? "mdAll" : "mdPart") }, "mdWrap"),
3806
3819
  jsx("button", {
3807
3820
  type: "button",
3808
3821
  className: "dstv_foldBtn",
3809
- // The count is in the label so a screen-reader user knows how much is hidden
3810
- // before deciding to render it.
3811
- "aria-expanded": "false",
3812
- onClick: () => setExpanded(true),
3813
- children: `${expandLabel} (${value.length - DETAIL_TEXT_MAX} ${suffix})`
3822
+ "aria-expanded": expanded ? "true" : "false",
3823
+ "aria-controls": regionId,
3824
+ onClick: () => setExpanded(!expanded),
3825
+ // The hidden count is in the label so the reader knows the cost before
3826
+ // opting in; after expanding, the label is the way back out.
3827
+ children: expanded
3828
+ ? collapseLabel
3829
+ : `${expandLabel} (${value.length - DETAIL_TEXT_MAX} ${suffix})`
3814
3830
  }, "foldBtn")
3815
3831
  ] }, "foldWrap");
3816
3832
  }
@@ -5723,7 +5739,7 @@ window.__ModuleLoader__.load({
5723
5739
  // Markdown too: users paste code blocks and lists just as often.
5724
5740
  return jsxs("div", { className: "dstv_dBody", children: jsxs("div", { className: "dstv_dSection dstv_dSectionBody", children: [
5725
5741
  jsx("span", { className: "dstv_dLabel", children: s.who }, "dLbl"),
5726
- jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(FoldedMarkdown, { text: s.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "uMd") : "…" }, "dTxt")
5742
+ jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(FoldedMarkdown, { text: s.text, expandLabel: t("detail.showAll"), collapseLabel: t("detail.collapse"), suffix: t("detail.chars") }, "uMd") : "…" }, "dTxt")
5727
5743
  ] }) });
5728
5744
  }
5729
5745
  if (s.kind === "step") {
@@ -5736,9 +5752,9 @@ window.__ModuleLoader__.load({
5736
5752
  jsx("span", { className: "dstv_dLabel", children: t("node.assistant") }, "aLbl"),
5737
5753
  cell.thinking !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
5738
5754
  jsx("summary", { children: [`💭 ${t("chip.thinking")}`, jsx("span", { className: "sub", children: String(cell.thinking.length) }, "aThLen")] }, "aThSum"),
5739
- jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(FoldedMarkdown, { text: cell.thinking, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aThMd") }, "aThText") }, "aThInner")
5755
+ jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(FoldedMarkdown, { text: cell.thinking, expandLabel: t("detail.showAll"), collapseLabel: t("detail.collapse"), suffix: t("detail.chars") }, "aThMd") }, "aThText") }, "aThInner")
5740
5756
  ] }, `dth${cell.id}`) : null,
5741
- cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(FoldedMarkdown, { text: cell.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aMd") }, "aText") : null
5757
+ cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(FoldedMarkdown, { text: cell.text, expandLabel: t("detail.showAll"), collapseLabel: t("detail.collapse"), suffix: t("detail.chars") }, "aMd") }, "aText") : null
5742
5758
  ] }, `da${cell.id}`);
5743
5759
  }
5744
5760
  if (cell.kind === "tool") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-trajectory-traceview-plus",
3
- "version": "0.11.10",
3
+ "version": "0.11.12",
4
4
  "description": "轨迹视图增强版(Plus):在「轨迹」标签旁新增可回放的横向时间轴——minimap、窗口内检索(显式标注覆盖边界)、回放、轮次跳转、跟随模式、历史分页、步骤/子调用耗时与吞吐、时钟轴切换、稳定锚点复制与深链、孤立工具结果站点、提示词变更对比、原始请求分析与 Markdown 导出。基于 AFAP/dsh-trajectory-traceview (MIT) 改造。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -6,7 +6,10 @@
6
6
  * `scripts/browser-check.mjs` needs a real Chrome over CDP, and wiring that into the
7
7
  * CI runner is deliberately not done (see the note at the bottom of
8
8
  * `.github/workflows/check.yml`: a flaky browser job trains people to ignore red
9
- * builds). So 48 observation groups / 314 assertions run on a maintainer machine only.
9
+ * builds). So the observation groups and assertions run on a maintainer machine only.
10
+ * (The counts are deliberately NOT written here: `readme-numbers.mjs` derives them from
11
+ * the probe files and guards the READMEs. A second copy in a comment is a second truth
12
+ * source, and a second truth source rots first — this line said "48 / 314" within a day.)
10
13
  *
11
14
  * That left a hole this script closes. Twice in one week a change was justified by a
12
15
  * probe run that could not be trusted:
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * - "CI 门禁 7 项" ← the number of named steps in check.yml, minus Install
9
9
  * - "npm run check 跑 N 步" ← the number of `&&` segments in package.json
10
- * - "13 组观测 / 47 条断言" ← probe.js: `info.X =` assignments, `fail(` calls
10
+ * - "N 组观测 / M 条断言" ← probe.js: `info.X =` assignments, `fail(` calls
11
11
  *
12
12
  * Reading the README and comparing it to the workflow by eye already failed twice
13
13
  * (the directory tree said "5 项门禁" for weeks after the count became 7). A number
@@ -20,6 +20,15 @@
20
20
  * node scripts/readme-numbers.mjs --print # show what it thinks the counts are
21
21
  */
22
22
  import { readFileSync } from 'node:fs';
23
+ import { probeInputs } from './probe-digest.mjs';
24
+
25
+ // The receipt claims a coverage COUNT ("covers 15 files"); that number rots the moment a
26
+ // probe file is added, which is exactly what a second truth source does. Derive it.
27
+ //
28
+ // Hoisted HERE, next to the import, and not next to its first use: putting it below made
29
+ // the module throw "Cannot access 'digestFileCount' before initialization" — the same TDZ
30
+ // class that Z1/Z2 guard in `src/`, which does not reach this directory.
31
+ const digestFileCount = probeInputs().length;
23
32
  import { dirname, join } from 'node:path';
24
33
  import { fileURLToPath } from 'node:url';
25
34
 
@@ -98,7 +107,7 @@ if (process.argv.includes('--print')) {
98
107
  // it looked for `N 项` — the audit was wrong, not the document. Anchoring on the
99
108
  // sentence is what made it correct.
100
109
  const problems = [];
101
- const counted = { ciGates: 0, localSteps: 0, groups: 0, assertions: 0, extraGroups: 0, extraAssertions: 0, shotsTotalGroups: 0 };
110
+ const counted = { ciGates: 0, localSteps: 0, groups: 0, assertions: 0, extraGroups: 0, extraAssertions: 0, shotsTotalGroups: 0, digestFiles: 0 };
102
111
 
103
112
  const claim = (file, lineNo, kind, found, want) => {
104
113
  counted[kind] += 1;
@@ -137,6 +146,9 @@ for (const file of ['README.md', 'README.en.md']) {
137
146
 
138
147
  // "CI:7 项门禁" / "the seven gates" / "门禁本身是 7 项" / "those 7 gates"
139
148
  for (const m of line.matchAll(/(\d+)\s*项门禁/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
149
+ // "摘要覆盖 N 个文件" / "The digest covers N files"
150
+ for (const m of line.matchAll(/摘要覆盖\s*(\d+)\s*个文件/g)) if (!isClaimed(m.index)) claim(file, at, 'digestFiles', Number(m[1]), digestFileCount);
151
+ for (const m of line.matchAll(/digest covers\s*(\d+)/g)) if (!isClaimed(m.index)) claim(file, at, 'digestFiles', Number(m[1]), digestFileCount);
140
152
  for (const m of line.matchAll(/(\d+)\s*gates\b/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
141
153
  for (const m of line.matchAll(/门禁(?:本身)?是\s*(\d+)\s*项/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
142
154
 
@@ -149,7 +161,7 @@ for (const file of ['README.md', 'README.en.md']) {
149
161
  }
150
162
  for (const m of line.matchAll(/(\d+)\s*of them/g)) if (!isClaimed(m.index)) claim(file, at, 'localSteps', Number(m[1]), localSteps);
151
163
 
152
- // "跑 47 条断言 / 记录 13 组观测" and its English twin
164
+ // "跑 M 条断言 / 记录 N 组观测" and its English twin
153
165
  for (const m of line.matchAll(/(\d+)\s*条断言/g)) if (!isClaimed(m.index)) claim(file, at, 'assertions', Number(m[1]), assertions);
154
166
  for (const m of line.matchAll(/(\d+)\s*assertions?/g)) if (!isClaimed(m.index)) claim(file, at, 'assertions', Number(m[1]), assertions);
155
167
  for (const m of line.matchAll(/(\d+)\s*组观测/g)) if (!isClaimed(m.index)) claim(file, at, 'groups', Number(m[1]), truth.groups);
package/src/00-locale.js CHANGED
@@ -100,6 +100,7 @@
100
100
  "detail.request": "请求配置",
101
101
  "detail.systemPrompt": "系统提示",
102
102
  "detail.showAll": "显示全文",
103
+ "detail.collapse": "收起",
103
104
  "detail.systemOutside": "来自窗口外的系统事件 e{seq}",
104
105
  "detail.systemNone": "(当前窗口内没有系统提示)",
105
106
  "detail.toolsCatalog": "工具目录",
@@ -288,6 +289,7 @@
288
289
  "detail.request": "Request config",
289
290
  "detail.systemPrompt": "System prompt",
290
291
  "detail.showAll": "Show all",
292
+ "detail.collapse": "Collapse",
291
293
  "detail.systemOutside": "from system event e{seq} outside the window",
292
294
  "detail.systemNone": "(no system prompt in this window)",
293
295
  "detail.toolsCatalog": "Tool catalog",
package/src/40-view.js CHANGED
@@ -123,23 +123,37 @@
123
123
  const DETAIL_TEXT_MAX = 50000;
124
124
 
125
125
  /** Long text rendered as markdown, with an explicit "show all" affordance. */
126
- function FoldedMarkdown({ text, expandLabel, suffix }) {
126
+ function FoldedMarkdown({ text, expandLabel, collapseLabel, suffix }) {
127
127
  const expandedState = (0, react.useState)(false);
128
128
  const expanded = expandedState[0];
129
129
  const setExpanded = expandedState[1];
130
130
  const value = typeof text === "string" ? text : "";
131
131
  const long = value.length > DETAIL_TEXT_MAX;
132
- if (!long || expanded) return jsx(MarkdownText, { text: value }, long ? "mdAll" : "md");
132
+ if (!long) return jsx(MarkdownText, { text: value }, "md");
133
+ // A real TOGGLE, not a one-way reveal.
134
+ //
135
+ // The first version rendered a button labelled "show all" with a hard-coded
136
+ // `aria-expanded="false"`, and clicking it replaced the button with the full
137
+ // text. That is a lie in two ways: the attribute can never become true (the
138
+ // control disappears), and a screen-reader user is told a collapsible region
139
+ // exists that they can neither re-collapse nor locate, because nothing carries
140
+ // an id they could navigate to. Now the button stays, flips its label and its
141
+ // `aria-expanded`, and owns a labelled region — so every state it announces is
142
+ // a state that actually exists.
143
+ const regionId = "dstv_fold_" + String(value.length) + "_" + String(value.charCodeAt(0) || 0);
133
144
  return jsxs("div", { children: [
134
- jsx(MarkdownText, { text: value.slice(0, DETAIL_TEXT_MAX) }, "mdPart"),
145
+ jsx("div", { id: regionId, children: jsx(MarkdownText, { text: expanded ? value : value.slice(0, DETAIL_TEXT_MAX) }, expanded ? "mdAll" : "mdPart") }, "mdWrap"),
135
146
  jsx("button", {
136
147
  type: "button",
137
148
  className: "dstv_foldBtn",
138
- // The count is in the label so a screen-reader user knows how much is hidden
139
- // before deciding to render it.
140
- "aria-expanded": "false",
141
- onClick: () => setExpanded(true),
142
- children: `${expandLabel} (${value.length - DETAIL_TEXT_MAX} ${suffix})`
149
+ "aria-expanded": expanded ? "true" : "false",
150
+ "aria-controls": regionId,
151
+ onClick: () => setExpanded(!expanded),
152
+ // The hidden count is in the label so the reader knows the cost before
153
+ // opting in; after expanding, the label is the way back out.
154
+ children: expanded
155
+ ? collapseLabel
156
+ : `${expandLabel} (${value.length - DETAIL_TEXT_MAX} ${suffix})`
143
157
  }, "foldBtn")
144
158
  ] }, "foldWrap");
145
159
  }
@@ -2052,7 +2066,7 @@
2052
2066
  // Markdown too: users paste code blocks and lists just as often.
2053
2067
  return jsxs("div", { className: "dstv_dBody", children: jsxs("div", { className: "dstv_dSection dstv_dSectionBody", children: [
2054
2068
  jsx("span", { className: "dstv_dLabel", children: s.who }, "dLbl"),
2055
- jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(FoldedMarkdown, { text: s.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "uMd") : "…" }, "dTxt")
2069
+ jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(FoldedMarkdown, { text: s.text, expandLabel: t("detail.showAll"), collapseLabel: t("detail.collapse"), suffix: t("detail.chars") }, "uMd") : "…" }, "dTxt")
2056
2070
  ] }) });
2057
2071
  }
2058
2072
  if (s.kind === "step") {
@@ -2065,9 +2079,9 @@
2065
2079
  jsx("span", { className: "dstv_dLabel", children: t("node.assistant") }, "aLbl"),
2066
2080
  cell.thinking !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
2067
2081
  jsx("summary", { children: [`💭 ${t("chip.thinking")}`, jsx("span", { className: "sub", children: String(cell.thinking.length) }, "aThLen")] }, "aThSum"),
2068
- jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(FoldedMarkdown, { text: cell.thinking, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aThMd") }, "aThText") }, "aThInner")
2082
+ jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(FoldedMarkdown, { text: cell.thinking, expandLabel: t("detail.showAll"), collapseLabel: t("detail.collapse"), suffix: t("detail.chars") }, "aThMd") }, "aThText") }, "aThInner")
2069
2083
  ] }, `dth${cell.id}`) : null,
2070
- cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(FoldedMarkdown, { text: cell.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aMd") }, "aText") : null
2084
+ cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(FoldedMarkdown, { text: cell.text, expandLabel: t("detail.showAll"), collapseLabel: t("detail.collapse"), suffix: t("detail.chars") }, "aMd") }, "aText") : null
2071
2085
  ] }, `da${cell.id}`);
2072
2086
  }
2073
2087
  if (cell.kind === "tool") {