dsh-trajectory-traceview-plus 0.11.2 → 0.11.4

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.
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Every shortcut the README documents must have an assertion in the browser probe.
4
+ *
5
+ * §13.56 and §13.57 are the two halves of one bug class, found hours apart:
6
+ *
7
+ * §13.56 README §7 listed nine keys; the `keyboard` group tested four of them and
8
+ * then reported "ok". The other five — Space, PageUp/PageDown, `/`, `f`,
9
+ * `r` — were promised to users and verified by nothing.
10
+ * §13.57 One of the remaining rows, `↑` / `↓` in the search box, turned out to be
11
+ * not merely untested but NOT IMPLEMENTED. The panel handler bails out for
12
+ * input targets and the search handler only knew Enter/Escape, so the two
13
+ * most natural keys did nothing at all.
14
+ *
15
+ * Both were invisible for the same reason: the shortcut table is prose, and nothing
16
+ * connects prose to code. A reader of the table believes nine keys work; a reader of
17
+ * the probe report sees "ok". This gate is that missing connection — one-directional
18
+ * on purpose. It does NOT prove an assertion is meaningful (only that the key is
19
+ * named somewhere in the probe); it proves nobody added a documented key and forgot
20
+ * to look at it.
21
+ *
22
+ * The reverse direction is deliberately not enforced: the probe may test keys the
23
+ * table omits (arrow keys inside a focused station, for example), and requiring the
24
+ * table to be exhaustive would turn a useful doc into a mirror of the implementation.
25
+ */
26
+ import { readFileSync } from 'node:fs';
27
+ import { dirname, join } from 'node:path';
28
+ import { fileURLToPath } from 'node:url';
29
+
30
+ const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
31
+ const read = (rel) => readFileSync(join(ROOT, rel), 'utf8');
32
+
33
+ const problems = [];
34
+
35
+ // ── the table ────────────────────────────────────────────────────────────────
36
+ const sectionStart = read('README.md').indexOf('## 7. 快捷键');
37
+ if (sectionStart < 0) {
38
+ problems.push('README.md has no "## 7. 快捷键" section — the check has nothing to read');
39
+ }
40
+ const section = sectionStart < 0 ? '' : read('README.md').slice(sectionStart);
41
+ const tableEnd = section.indexOf('\n## ', 5);
42
+ const table = tableEnd < 0 ? section : section.slice(0, tableEnd);
43
+
44
+ // A row looks like: `| `←` / `→` | 上一个 / 下一个站点 |`
45
+ // Take every backticked key in the FIRST cell. Cells like `` `↑` / `↓`(搜索时) ``
46
+ // contain two keys and a qualifier; both keys must be covered.
47
+ const rows = [...table.matchAll(/^\|\s*(`[^|]+?`)\s*\|/gm)].map((m) => m[1]);
48
+ if (rows.length === 0) {
49
+ problems.push('README §7 has no shortcut rows; the patterns have drifted from the table');
50
+ }
51
+
52
+ // How each key appears in the probe source. A mismatch here is a silent hole: the
53
+ // gate would report OK while checking nothing.
54
+ const PROBE_NAME = {
55
+ '←': 'ArrowLeft',
56
+ '→': 'ArrowRight',
57
+ '↑': 'ArrowUp',
58
+ '↓': 'ArrowDown',
59
+ '空格': '" "',
60
+ Esc: 'Escape',
61
+ '`Esc`': 'Escape',
62
+ '`空格`': '" "',
63
+ };
64
+
65
+ const probe = read('test/browser/probe.js');
66
+ const covered = [];
67
+ for (const row of rows) {
68
+ const keys = [...row.matchAll(/`([^`]+)`/g)].map((m) => m[1]);
69
+ for (const key of keys) {
70
+ 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 '
75
+ + JSON.stringify(needle) + ' — the key is promised and never exercised');
76
+ } else {
77
+ covered.push(key);
78
+ }
79
+ }
80
+ }
81
+
82
+ if (covered.length === 0 && problems.length === 0) {
83
+ problems.push('not a single documented key matched the probe — the mapping has drifted');
84
+ }
85
+
86
+ if (problems.length > 0) {
87
+ for (const p of problems) console.error(' ✗ ' + p);
88
+ console.error('shortcut-check: FAIL (' + problems.length + ' problem(s))');
89
+ process.exit(1);
90
+ }
91
+ console.log('shortcut-check: README §7 的 ' + rows.length + ' 行 / ' + covered.length
92
+ + ' 个键在 probe 里都有断言');
93
+ console.log('SHORTCUTS OK');
package/src/00-locale.js CHANGED
@@ -10,9 +10,6 @@
10
10
  "block.unknown": "[未知内容]",
11
11
  "block.toolAdded": "[工具新增] {name}",
12
12
  "block.toolRemoved": "[工具移除] {name}",
13
- "block.toolsAdded": "[已添加工具] {names}",
14
- "block.toolsRemoved": "[已移除工具] {names}",
15
- "block.toolsChanged": "[工具变更] 新增 {added} 个、移除 {removed} 个",
16
13
  "note.compaction": "上下文压缩:",
17
14
  "note.compacted": "历史已压缩",
18
15
  "note.replace": "替换",
@@ -65,6 +62,17 @@
65
62
  "kpi.tokensIn": "请求 tokens",
66
63
  "kpi.tokensOut": "生成 tokens",
67
64
  "kpi.errors": "错误",
65
+ // The Token-usage chips were hardcoded English ("in" / "out" / "cache-read" …)
66
+ // inside a Chinese panel, while README §2 describes this section as
67
+ // "入站(含缓存读 / 写)与出站(含思考)". Same words as the README, compact
68
+ // enough for a chip. `fresh` = input tokens that came from the prompt rather
69
+ // than from cache (the API's `inputTokens` minus cache read/write).
70
+ "usage.in": "入站",
71
+ "usage.fresh": "未缓存",
72
+ "usage.cacheRead": "缓存读",
73
+ "usage.cacheWrite": "缓存写",
74
+ "usage.out": "出站",
75
+ "usage.think": "思考",
68
76
  "status.done": "已完成",
69
77
  "status.retry": "重试",
70
78
  "detail.args": "调用参数",
@@ -95,15 +103,12 @@
95
103
  "anchor.notLoaded": "该记录不在当前窗口,需先拉取更早历史",
96
104
  "anchor.capped": "已向前翻页 {n} 页仍未找到;可先手动点「加载更早历史」再重试",
97
105
  "anchor.bad": "锚点格式无法识别",
98
- "anchor.jump": "跳转到锚点",
99
106
  "anchor.clear": "清除锚点",
100
107
  "anchor.jumpPlaceholder": "粘贴锚点,如 tvp1:e3019,回车定位",
101
108
  "anchor.jumpTip": "粘贴任意站点详情里「复制锚点」得到的串,回车即可精确定位;目标在未加载的历史里时会自动向前翻页加载(有页数上限,超出会明确提示)。",
102
109
  "anchor.searching": "正在向前加载更早历史以定位…",
103
110
  "anchor.searchingPages": "正在向前加载更早历史以定位…(第 {n}/{max} 页,已载入 {stations} 站)",
104
111
  "anchor.upgraded": "该记录已落定,请改用 {ref}",
105
- "anchor.copiedLink": "已复制到你名下",
106
- "anchor.badInput": "无法识别的锚点",
107
112
 
108
113
  "detail.start": "开始",
109
114
  "detail.end": "结束",
@@ -191,9 +196,6 @@
191
196
  "block.unknown": "[unknown content]",
192
197
  "block.toolAdded": "[tool added] {name}",
193
198
  "block.toolRemoved": "[tool removed] {name}",
194
- "block.toolsAdded": "[tools added] {names}",
195
- "block.toolsRemoved": "[tools removed] {names}",
196
- "block.toolsChanged": "[tools changed] +{added} / -{removed}",
197
199
  "note.compaction": "Context compacted: ",
198
200
  "note.compacted": "history compacted",
199
201
  "note.replace": "replaced",
@@ -246,6 +248,12 @@
246
248
  "kpi.tokensIn": "Prompt tokens",
247
249
  "kpi.tokensOut": "Output tokens",
248
250
  "kpi.errors": "Errors",
251
+ "usage.in": "in",
252
+ "usage.fresh": "fresh",
253
+ "usage.cacheRead": "cache-read",
254
+ "usage.cacheWrite": "cache-write",
255
+ "usage.out": "out",
256
+ "usage.think": "think",
249
257
  "status.done": "Done",
250
258
  "status.retry": "Retry",
251
259
  "detail.args": "Call arguments",
@@ -276,15 +284,12 @@
276
284
  "anchor.notLoaded": "Not in the loaded window; load older history first",
277
285
  "anchor.capped": "Paged back {n} pages without finding it; load older history manually and retry",
278
286
  "anchor.bad": "Unrecognized anchor format",
279
- "anchor.jump": "Jump to anchor",
280
287
  "anchor.clear": "Clear anchor",
281
288
  "anchor.jumpPlaceholder": "Paste an anchor (e.g. tvp1:e3019) and press Enter",
282
289
  "anchor.jumpTip": "Paste the string produced by \"Copy anchor\" in any station detail, then press Enter. If the target sits in unloaded history, older pages are loaded automatically (page-bounded; you are told when the bound is hit).",
283
290
  "anchor.searching": "Loading older history to locate it…",
284
291
  "anchor.searchingPages": "Loading older history to locate it… (page {n}/{max}, {stations} stations loaded)",
285
292
  "anchor.upgraded": "This record is now durable; use {ref}",
286
- "anchor.copiedLink": "Link copied",
287
- "anchor.badInput": "Unrecognized anchor",
288
293
 
289
294
  "detail.start": "Start",
290
295
  "detail.end": "End",
package/src/40-view.js CHANGED
@@ -827,6 +827,18 @@
827
827
  const onSearchKey = (ev) => {
828
828
  ev.stopPropagation();
829
829
  if (ev.key === "Enter") { gotoMatch(ev.shiftKey ? -1 : 1); ev.preventDefault(); }
830
+ // README §7 has promised `↑` / `↓` for previous/next match since the
831
+ // shortcut table existed, and NOTHING implemented it: the panel handler
832
+ // bails out for `input` targets and this handler only knew Enter/Escape,
833
+ // so the two most natural keys did nothing at all. Measured in the
834
+ // browser probe: focus the box with 2/3 shown, press ArrowDown, counter
835
+ // stays "2/3" — the documented feature simply was not there (§13.57).
836
+ //
837
+ // Inside a single-line search box there is no vertical caret movement to
838
+ // steal, so binding these two is what a user coming from browser find
839
+ // expects.
840
+ else if (ev.key === "ArrowDown") { gotoMatch(1); ev.preventDefault(); }
841
+ else if (ev.key === "ArrowUp") { gotoMatch(-1); ev.preventDefault(); }
830
842
  else if (ev.key === "Escape") { setQueryRaw(""); ev.preventDefault(); }
831
843
  };
832
844
  const clearSearch = () => {
@@ -1819,9 +1831,9 @@
1819
1831
  usage !== null && usage.input + usage.output > 0 ? jsxs("div", { className: "dstv_dSection", children: [
1820
1832
  jsx("span", { className: "dstv_dLabel", children: `📊 ${t("detail.usage")}` }, "uLbl"),
1821
1833
  jsx("div", { className: "dstv_cfgChips", children: [
1822
- usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["in ", jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
1823
- usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["cache-read ", jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
1824
- usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["out ", jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null
1834
+ usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.in")} `, jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
1835
+ usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheRead")} `, jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
1836
+ usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.out")} `, jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null
1825
1837
  ] }, "uChips")
1826
1838
  ] }, "crUsage") : null,
1827
1839
  cr.outputText !== "" ? jsxs("div", { className: "dstv_dSection", children: [
@@ -1955,12 +1967,12 @@
1955
1967
  usage !== null && usage.input + usage.output > 0 ? jsxs("div", { className: "dstv_dSection", children: [
1956
1968
  jsx("span", { className: "dstv_dLabel", children: `📊 ${t("detail.usage")}` }, "uLbl"),
1957
1969
  jsx("div", { className: "dstv_cfgChips", children: [
1958
- usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["in ", jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
1959
- usage.raw > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["fresh ", jsx("b", { children: fmtInt(usage.raw) }, "v")] }, "uFresh") : null,
1960
- usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["cache-read ", jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
1961
- usage.cacheWrite > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["cache-write ", jsx("b", { children: fmtInt(usage.cacheWrite) }, "v")] }, "uCW") : null,
1962
- usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["out ", jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null,
1963
- usage.think > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["think ", jsx("b", { children: fmtInt(usage.think) }, "v")] }, "uThink") : null
1970
+ usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.in")} `, jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
1971
+ usage.raw > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.fresh")} `, jsx("b", { children: fmtInt(usage.raw) }, "v")] }, "uFresh") : null,
1972
+ usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheRead")} `, jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
1973
+ usage.cacheWrite > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheWrite")} `, jsx("b", { children: fmtInt(usage.cacheWrite) }, "v")] }, "uCW") : null,
1974
+ usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.out")} `, jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null,
1975
+ usage.think > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.think")} `, jsx("b", { children: fmtInt(usage.think) }, "v")] }, "uThink") : null
1964
1976
  ] }, "uChips")
1965
1977
  ] }, "uSec") : null,
1966
1978
  // messages