dsh-trajectory-traceview-plus 0.11.5 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-trajectory-traceview-plus",
3
- "version": "0.11.5",
3
+ "version": "0.11.7",
4
4
  "description": "轨迹视图增强版(Plus):在「轨迹」标签旁新增可回放的横向时间轴——minimap、窗口内检索(显式标注覆盖边界)、回放、轮次跳转、跟随模式、历史分页、步骤/子调用耗时与吞吐、时钟轴切换、稳定锚点复制与深链、孤立工具结果站点、提示词变更对比、原始请求分析与 Markdown 导出。基于 AFAP/dsh-trajectory-traceview (MIT) 改造。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "scripts": {
64
64
  "build": "node scripts/build-client.mjs",
65
- "check": "node scripts/build-client.mjs --check && node scripts/provenance.mjs --check && node scripts/version-check.mjs && node scripts/doc-ref-check.mjs && node scripts/doc-heading-check.mjs && node test/smoke.test.cjs && node scripts/readme-numbers.mjs && node scripts/shortcut-check.mjs && node scripts/harness-stamp.mjs",
65
+ "check": "node scripts/build-client.mjs --check && node scripts/provenance.mjs --check && node scripts/version-check.mjs && node scripts/doc-ref-check.mjs && node scripts/doc-heading-check.mjs && node test/smoke.test.cjs && node scripts/readme-numbers.mjs && node scripts/shortcut-check.mjs && node scripts/harness-stamp.mjs && node scripts/path-leak-check.mjs",
66
66
  "test": "node test/smoke.test.cjs",
67
67
  "prepublishOnly": "npm run check"
68
68
  }
@@ -29,7 +29,7 @@ run("agent-browser", ["wait", "1200"]);
29
29
  // BOTH halves share one page: the browser is opened once and the evals run in order, so
30
30
  // `probe-detail.js` continues from the state `probe.js` leaves. Split because
31
31
  // `agent-browser eval` aborts at 30 s and the single file had reached 27.4 s (§13.70).
32
- const probeFiles = ["test/browser/probe.js", "test/browser/probe-detail.js"];
32
+ const probeFiles = ["test/browser/probe.js", "test/browser/probe-detail.js", "test/browser/probe-detail2.js", "test/browser/probe-detail3.js"];
33
33
  const probe = fs.readFileSync(path.join(root, probeFiles[0]), "utf8");
34
34
  const out = run("agent-browser", ["eval", "--stdin"], probe);
35
35
  const raw = (out.stdout || "").trim();
@@ -44,16 +44,18 @@ try {
44
44
  process.exit(1);
45
45
  }
46
46
 
47
- // Second half of the assertions.
48
- {
49
- const outTail = run("agent-browser", ["eval", "--stdin"], fs.readFileSync(path.join(root, probeFiles[1]), "utf8"));
47
+ // Remaining halves of the assertions. Each is a separate `agent-browser eval` because the
48
+ // command aborts at 30 s; the probe was split twice for exactly that reason (§13.70). They
49
+ // run in order on ONE page, so each continues from the state the previous one left.
50
+ for (const rel of probeFiles.slice(1)) {
51
+ const outTail = run("agent-browser", ["eval", "--stdin"], fs.readFileSync(path.join(root, rel), "utf8"));
50
52
  try {
51
53
  const outerTail = JSON.parse((outTail.stdout || "").trim());
52
54
  const parsedTail = JSON.parse(outerTail);
53
55
  if (Array.isArray(parsedTail.failures)) parsed.failures.push(...parsedTail.failures);
54
56
  Object.assign(parsed.info, parsedTail.info);
55
57
  } catch {
56
- parsed.failures.push("the second probe half did not return a parsable result");
58
+ parsed.failures.push(rel + " did not return a parsable result");
57
59
  }
58
60
  }
59
61
 
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Fail when a file that ships in the npm tarball carries this machine's absolute paths.
4
+ *
5
+ * `docs/DESIGN.md` is published (`files` lists `docs/`). It accumulated ten paths such as
6
+ * `/Users/<name>/Documents/...` and `/Volumes/...` — the username, the working directory and
7
+ * the Node install layout, shipped to everyone who installs the plugin. No credentials, but
8
+ * it is fingerprint material that no reader needs, and it was invisible because the earlier
9
+ * sweep (§13.38) only covered `scripts/`.
10
+ *
11
+ * The rule: anything inside `files` may mention the repo's own NAME, never a home directory
12
+ * or a volume path. Documentation that legitimately describes a check (this file's own
13
+ * `$ git ls-files … grep -E '/Users/…'` example) is allowed through by the marker below.
14
+ *
15
+ * node scripts/path-leak-check.mjs
16
+ *
17
+ * Exempt: a line carrying `path-leak-check: allow` (the rule it documents) — used exactly
18
+ * once, in DESIGN §13.38, so the guard cannot be turned into a blanket excuse.
19
+ */
20
+ import fs from "node:fs";
21
+ import path from "node:path";
22
+
23
+ const root = path.resolve(import.meta.dirname, "..");
24
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
25
+
26
+ const ALLOW = "path-leak-check: allow";
27
+ const PATTERN = /\/Users\/[A-Za-z][\w.-]*|\/Volumes\/[A-Za-z]|\/home\/[A-Za-z][\w.-]*|\/private\/tmp\//;
28
+
29
+ /** Expand the `files` list into the concrete files npm would pack. */
30
+ function shippedFiles() {
31
+ const out = [];
32
+ const walk = (rel) => {
33
+ const abs = path.join(root, rel);
34
+ if (!fs.existsSync(abs)) return;
35
+ const st = fs.statSync(abs);
36
+ if (st.isDirectory()) {
37
+ for (const name of fs.readdirSync(abs)) walk(path.join(rel, name));
38
+ return;
39
+ }
40
+ out.push(rel);
41
+ };
42
+ for (const entry of pkg.files ?? []) {
43
+ const clean = entry.replace(/\/$/, "");
44
+ walk(clean);
45
+ }
46
+ return out;
47
+ }
48
+
49
+ const TEXT = /\.(md|js|mjs|cjs|json|yml|yaml|ts|txt)$/;
50
+ const problems = [];
51
+ let scanned = 0;
52
+
53
+ for (const rel of shippedFiles()) {
54
+ if (!TEXT.test(rel)) continue;
55
+ scanned += 1;
56
+ const lines = fs.readFileSync(path.join(root, rel), "utf8").split("\n");
57
+ lines.forEach((line, i) => {
58
+ if (line.includes(ALLOW)) return;
59
+ if (!PATTERN.test(line)) return;
60
+ problems.push(rel + ":" + (i + 1) + " — " + line.trim().slice(0, 120));
61
+ });
62
+ }
63
+
64
+ if (problems.length > 0) {
65
+ console.error("path-leak-check: " + problems.length + " absolute path(s) would be published:");
66
+ for (const p of problems) console.error(" ✗ " + p);
67
+ console.error(" replace them with <repo> / <workdir> / $NODE_HOME, or mark the line `" + ALLOW + "`");
68
+ process.exit(1);
69
+ }
70
+
71
+ console.log("path-leak-check: OK (" + scanned + " shipped text file(s), no local paths)");
@@ -39,7 +39,7 @@ const localSteps = pkg.scripts.check.split('&&').map((s) => s.trim()).filter(Boo
39
39
  // aborts at 30 s and the language switch pushed the single file over it (§13.69) — and
40
40
  // leaving it out of this count is exactly the one-source-vs-two-sources blindness this
41
41
  // very block has already been fixed for once (§13.44).
42
- const PROBE_FILES = ['test/browser/probe.js', 'test/browser/probe-detail.js', 'test/browser/probe-en.js'];
42
+ const PROBE_FILES = ['test/browser/probe.js', 'test/browser/probe-detail.js', 'test/browser/probe-detail2.js', 'test/browser/probe-detail3.js', 'test/browser/probe-en.js'];
43
43
  const probes = PROBE_FILES.map((f) => read(f));
44
44
  const observedGroups = new Set();
45
45
  let assertions = 0;
@@ -73,12 +73,19 @@ const extraAssertions = [...browserCheck.matchAll(/(?:parsed\.)?failures\.push\(
73
73
  const truth = {
74
74
  ciGates, localSteps, groups: observedGroups.size, assertions,
75
75
  extraGroups: extraGroupNames.size, extraAssertions,
76
+ // The `--shots` line ends with a TOTAL ("共 36 组" / "(36 total)"), not the extra.
77
+ // It was not a claim at all until now, so it drifted silently while the line's other
78
+ // numbers were gated: the English copy read "(30 total)" for six releases after the
79
+ // base grew past it. A number written down twice goes stale (§13.37) — including the
80
+ // one that is a SUM of two numbers the same file already checks.
81
+ shotsTotalGroups: observedGroups.size + extraGroupNames.size,
76
82
  };
77
83
 
78
84
  if (process.argv.includes('--print')) {
79
85
  console.log('CI 门禁 ' + ciGates + ' 项(workflow 具名步骤 ' + namedSteps.length + ' − Install)');
80
86
  console.log('npm run check ' + localSteps + ' 步');
81
87
  console.log('probe.js 观测组 ' + truth.groups + ' 个 / 断言 ' + assertions + ' 条');
88
+ console.log('--shots 合计 ' + truth.shotsTotalGroups + ' 组(基础 ' + truth.groups + ' + 额外 ' + truth.extraGroups + ')');
82
89
  console.log('browser-check 额外 ' + truth.extraGroups + ' 组 / ' + truth.extraAssertions + ' 条断言'
83
90
  + (extraGroupNames.size > 0 ? '(组:' + [...extraGroupNames].join(', ') + ')' : ''));
84
91
  process.exit(0);
@@ -91,7 +98,7 @@ if (process.argv.includes('--print')) {
91
98
  // it looked for `N 项` — the audit was wrong, not the document. Anchoring on the
92
99
  // sentence is what made it correct.
93
100
  const problems = [];
94
- const counted = { ciGates: 0, localSteps: 0, groups: 0, assertions: 0, extraGroups: 0, extraAssertions: 0 };
101
+ const counted = { ciGates: 0, localSteps: 0, groups: 0, assertions: 0, extraGroups: 0, extraAssertions: 0, shotsTotalGroups: 0 };
95
102
 
96
103
  const claim = (file, lineNo, kind, found, want) => {
97
104
  counted[kind] += 1;
@@ -123,6 +130,10 @@ for (const file of ['README.md', 'README.en.md']) {
123
130
  for (const m of line.matchAll(/--shots[^\n]{0,80}?另加\s*\d+\s*组\s*\/\s*(\d+)\s*条/g)) claimSpan(m, 'extraAssertions', Number(m[1]), truth.extraAssertions);
124
131
  for (const m of line.matchAll(/--shots[^\n]{0,60}?(?:adds?|plus)\s*(\d+)\s*(?:more\s*)?group/g)) claimSpan(m, 'extraGroups', Number(m[1]), truth.extraGroups);
125
132
  for (const m of line.matchAll(/--shots[^\n]{0,60}?adds?\s*\d+\s*more\s*group\s*\/\s*(\d+)\s*assertions?/g)) claimSpan(m, 'extraAssertions', Number(m[1]), truth.extraAssertions);
133
+ // The total at the end of the same line: "…(375px 溢出,共 36 组)" / "(36 total)".
134
+ // Scoped to the `--shots` line so an unrelated "共 N 组" elsewhere is not misread.
135
+ for (const m of line.matchAll(/--shots[^\n]{0,90}?共\s*(\d+)\s*组/g)) claimSpan(m, 'shotsTotalGroups', Number(m[1]), truth.shotsTotalGroups);
136
+ for (const m of line.matchAll(/--shots[^\n]{0,90}?\((\d+)\s*total\)/g)) claimSpan(m, 'shotsTotalGroups', Number(m[1]), truth.shotsTotalGroups);
126
137
 
127
138
  // "CI:7 项门禁" / "the seven gates" / "门禁本身是 7 项" / "those 7 gates"
128
139
  for (const m of line.matchAll(/(\d+)\s*项门禁/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
@@ -44,7 +44,14 @@ const table = tableEnd < 0 ? section : section.slice(0, tableEnd);
44
44
  // A row looks like: `| `←` / `→` | 上一个 / 下一个站点 |`
45
45
  // Take every backticked key in the FIRST cell. Cells like `` `↑` / `↓`(搜索时) ``
46
46
  // contain two keys and a qualifier; both keys must be covered.
47
- const rows = [...table.matchAll(/^\|\s*(`[^|]+?`)\s*\|/gm)].map((m) => m[1]);
47
+ // Take the whole FIRST CELL and pull the backticked keys out of it. The earlier pattern
48
+ // required the cell to END right after a backtick, so the two rows with a qualifier —
49
+ // "`↑` / `↓`(搜索时)" and "`Enter` / `Shift+Enter`(搜索时)" — were never parsed at all.
50
+ // The gate then reported "8 行 / 11 个键" as if that were the whole table: the two rows a
51
+ // reader most needs (search-time navigation) were promised and unverified.
52
+ const rows = [...table.matchAll(/^\|([^|]*)\|/gm)]
53
+ .map((m) => m[1])
54
+ .filter((cell) => cell.indexOf("`") >= 0);
48
55
  if (rows.length === 0) {
49
56
  problems.push('README §7 has no shortcut rows; the patterns have drifted from the table');
50
57
  }
@@ -56,22 +63,40 @@ const PROBE_NAME = {
56
63
  '→': 'ArrowRight',
57
64
  '↑': 'ArrowUp',
58
65
  '↓': 'ArrowDown',
59
- '空格': '" "',
66
+ '空格': ' ',
60
67
  Esc: 'Escape',
61
68
  '`Esc`': 'Escape',
62
- '`空格`': '" "',
69
+ '`空格`': ' ',
70
+ Enter: 'Enter',
63
71
  };
64
72
 
65
- const probe = read('test/browser/probe.js');
73
+ const PROBE_FILES = ['test/browser/probe.js', 'test/browser/probe-detail.js', 'test/browser/probe-en.js'];
74
+ // Comments are dropped first: `// await press("f")` is a note, not a test, but matching the
75
+ // raw text counted it as coverage. Verified by commenting the call out — the gate stayed
76
+ // green until the comment lines were excluded.
77
+ const codeOf = (f) => read(f).split('\n').filter((l) => !l.trim().startsWith('//')).join('\n');
78
+ const probe = PROBE_FILES.map(codeOf).join('\n');
66
79
  const covered = [];
67
80
  for (const row of rows) {
68
81
  const keys = [...row.matchAll(/`([^`]+)`/g)].map((m) => m[1]);
69
82
  for (const key of keys) {
83
+ // `Shift+Enter` is not a string literal in the probe: it is a key plus a modifier.
84
+ // Requiring both halves is what makes the row mean something.
85
+ if (key === "Shift+Enter") {
86
+ const shifted = /shiftPress\("Enter",\s*true\)/.test(probe);
87
+ if (!shifted) problems.push('README §7 documents `Shift+Enter` but no probe calls shiftPress("Enter", true)');
88
+ else covered.push(key);
89
+ continue;
90
+ }
70
91
  const needle = PROBE_NAME[key] ?? key;
71
- // `Enter` shows up as shiftPress("Enter", …) and press("Enter"); a bare
72
- // substring test is right here because the probe names keys as string literals.
73
- if (!probe.includes(needle)) {
74
- problems.push('README §7 documents `' + key + '` but test/browser/probe.js never mentions '
92
+ // A plain `includes` was worthless for one-character keys: `f` occurs 199 times in
93
+ // the probe as an ordinary letter, so the row could never fail. Require an actual
94
+ // key event — `press("<key>")` or `shiftPress("<key>"` — in any of the probe files.
95
+ const escaped = needle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
96
+ const call = new RegExp('(?:press|shiftPress)\\("' + escaped + '"');
97
+ const usedIn = PROBE_FILES.find((f) => call.test(codeOf(f)));
98
+ if (usedIn === void 0) {
99
+ problems.push('README §7 documents `' + key + '` but no probe ever presses '
75
100
  + JSON.stringify(needle) + ' — the key is promised and never exercised');
76
101
  } else {
77
102
  covered.push(key);
package/src/00-locale.js CHANGED
@@ -62,6 +62,10 @@
62
62
  "kpi.tokensIn": "请求 tokens",
63
63
  "kpi.tokensOut": "生成 tokens",
64
64
  "kpi.errors": "错误",
65
+ // The KPI counts STEPS that contain an error, not error events: one step with 24
66
+ // tool calls and 4 failures shows 1. The bare label "错误 / Errors" made that read
67
+ // as a wrong number; the chip says what it counts now.
68
+ "kpi.errorSteps": "出错步骤",
65
69
  // The Token-usage chips were hardcoded English ("in" / "out" / "cache-read" …)
66
70
  // inside a Chinese panel, while README §2 describes this section as
67
71
  // "入站(含缓存读 / 写)与出站(含思考)". Same words as the README, compact
@@ -78,6 +82,9 @@
78
82
  "detail.args": "调用参数",
79
83
  "detail.noArgs": "(无参数)",
80
84
  "detail.subCalls": "子调用",
85
+ // The budget silently dropped the tail: 20,000 children rendered 1,999 with no
86
+ // indication anywhere. Say how many exist when the list was cut.
87
+ "detail.subCallsCut": "只显示前 {shown} 个(共 {total} 个)",
81
88
  "detail.position": "站点",
82
89
  "detail.result": "工具结果",
83
90
  "detail.noResult": "(无结果内容)",
@@ -92,6 +99,8 @@
92
99
  "detail.items": "项",
93
100
  "detail.request": "请求配置",
94
101
  "detail.systemPrompt": "系统提示",
102
+ "detail.systemOutside": "来自窗口外的系统事件 e{seq}",
103
+ "detail.systemNone": "(当前窗口内没有系统提示)",
95
104
  "detail.toolsCatalog": "工具目录",
96
105
  "detail.messages": "消息列表",
97
106
  "detail.copy": "复制",
@@ -115,6 +124,8 @@
115
124
  "gap.idle": "空闲",
116
125
  "node.orphanTool": "孤立工具结果",
117
126
  "orphan.badge": "调用不在窗口内",
127
+ "node.replayedTool": "压缩重放的工具结果",
128
+ "orphan.replayBadge": "与 e{seq} 相同(上下文压缩后重放)",
118
129
  "orphan.noText": "(无结果文本)",
119
130
  "timing.notRecorded": "未记录耗时",
120
131
  "timing.notRecordedHint": "该步骤没有 timing 记录,无法得到耗时",
@@ -248,6 +259,7 @@
248
259
  "kpi.tokensIn": "Prompt tokens",
249
260
  "kpi.tokensOut": "Output tokens",
250
261
  "kpi.errors": "Errors",
262
+ "kpi.errorSteps": "steps with errors",
251
263
  "usage.in": "in",
252
264
  "usage.fresh": "fresh",
253
265
  "usage.cacheRead": "cache-read",
@@ -259,6 +271,7 @@
259
271
  "detail.args": "Call arguments",
260
272
  "detail.noArgs": "(no arguments)",
261
273
  "detail.subCalls": "Sub-calls",
274
+ "detail.subCallsCut": "showing the first {shown} of {total}",
262
275
  "detail.position": "Station",
263
276
  "detail.result": "Tool result",
264
277
  "detail.noResult": "(no result content)",
@@ -273,6 +286,8 @@
273
286
  "detail.items": "items",
274
287
  "detail.request": "Request config",
275
288
  "detail.systemPrompt": "System prompt",
289
+ "detail.systemOutside": "from system event e{seq} outside the window",
290
+ "detail.systemNone": "(no system prompt in this window)",
276
291
  "detail.toolsCatalog": "Tool catalog",
277
292
  "detail.messages": "Messages",
278
293
  "detail.copy": "Copy",
@@ -296,6 +311,8 @@
296
311
  "gap.idle": "Idle",
297
312
  "node.orphanTool": "Orphan tool result",
298
313
  "orphan.badge": "call outside window",
314
+ "node.replayedTool": "Replayed tool result",
315
+ "orphan.replayBadge": "same as e{seq} (re-sent after compaction)",
299
316
  "orphan.noText": "(no result text)",
300
317
  "timing.notRecorded": "no duration",
301
318
  "timing.notRecordedHint": "This step has no timing record at all",
package/src/10-styles.js CHANGED
@@ -242,6 +242,11 @@
242
242
  // surface one consistent, high-contrast focus indicator (WCAG 2.4.7/2.4.11).
243
243
  ".dstv_root button:focus-visible,.dstv_root summary:focus-visible,.dstv_root a:focus-visible,.dstv_root input:focus-visible{outline:2px solid var(--dstv-info);outline-offset:2px;border-radius:6px}",
244
244
  // Suppress the ring only for pointer users, never for keyboard users.
245
+ // The panel root is focusable (it owns the keyboard shortcuts), and it had NO focus
246
+ // ring: real Tab put focus on `.dstv_root` with `:focus-visible=true` and
247
+ // `outline-style:none`, so a keyboard user could not see where they were. Inset so
248
+ // the ring is not clipped by the panel's own overflow.
249
+ ".dstv_root:focus-visible{outline:2px solid var(--dstv-info);outline-offset:-2px}",
245
250
  ".dstv_root:focus:not(:focus-visible){outline:none}",
246
251
  ".dstv_station:focus:not(:focus-visible){outline:none}",
247
252
  ".dstv_search:focus-within{border-color:var(--dstv-info);box-shadow:0 0 0 2px color-mix(in srgb,var(--dstv-info) 18%,transparent)}",
@@ -284,8 +289,14 @@
284
289
  // Searching dims the non-matches. Driven from the listbox so a keystroke does not
285
290
  // rewrite every station element (§13.72): reached = not [data-dim], matched =
286
291
  // [data-match]. Same visual result, one attribute instead of N.
287
- ".dstv_listbox[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hcard{opacity:.5;filter:saturate(.3)}",
288
- ".dstv_listbox[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hDot{opacity:.35}",
292
+ // `.dstv_listbox` does not exist: the element carrying `data-searching` is the
293
+ // horizontally-scrolling flex row, whose class is `.dstv_hflow`. The rule matched
294
+ // nothing, so typing a query left every non-matching card at full opacity while
295
+ // the MINIMAP dimmed correctly (its selector uses `.dstv_minimap`, which is real).
296
+ // Measured after the move to a container attribute: card opacity 1 / filter none
297
+ // with `data-searching="true"` on the listbox, tick opacity .25.
298
+ ".dstv_hflow[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hcard{opacity:.5;filter:saturate(.3)}",
299
+ ".dstv_hflow[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hDot{opacity:.35}",
289
300
  ".dstv_miniTick[data-match=true]{box-shadow:0 0 0 1.5px var(--dstv-warn);height:14px}",
290
301
  // While searching, fade the ticks that did not match. Reached-only ticks fade via
291
302
  // [data-dim]; the search fade lives here so it costs no per-tick attribute (§13.72).