dsh-trajectory-traceview-plus 0.11.1 → 0.11.3
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 +51 -0
- package/README.en.md +24 -15
- package/README.md +36 -22
- package/docs/DESIGN.md +800 -0
- package/docs/PROVENANCE.md +2 -0
- package/lib/client.js +12 -12
- package/package.json +2 -2
- package/scripts/guard-check.mjs +113 -0
- package/scripts/release-status.mjs +167 -23
- package/scripts/shortcut-check.mjs +93 -0
- package/src/00-locale.js +0 -12
- package/src/40-view.js +12 -0
package/docs/PROVENANCE.md
CHANGED
|
@@ -36,9 +36,11 @@
|
|
|
36
36
|
- `scripts/build-client.mjs`
|
|
37
37
|
- `scripts/doc-heading-check.mjs`
|
|
38
38
|
- `scripts/doc-ref-check.mjs`
|
|
39
|
+
- `scripts/guard-check.mjs`
|
|
39
40
|
- `scripts/provenance.mjs`
|
|
40
41
|
- `scripts/readme-numbers.mjs`
|
|
41
42
|
- `scripts/release-status.mjs`
|
|
43
|
+
- `scripts/shortcut-check.mjs`
|
|
42
44
|
- `scripts/version-check.mjs`
|
|
43
45
|
- `src/00-locale.js`
|
|
44
46
|
- `src/10-styles.js`
|
package/lib/client.js
CHANGED
|
@@ -21,9 +21,6 @@ window.__ModuleLoader__.load({
|
|
|
21
21
|
"block.unknown": "[未知内容]",
|
|
22
22
|
"block.toolAdded": "[工具新增] {name}",
|
|
23
23
|
"block.toolRemoved": "[工具移除] {name}",
|
|
24
|
-
"block.toolsAdded": "[已添加工具] {names}",
|
|
25
|
-
"block.toolsRemoved": "[已移除工具] {names}",
|
|
26
|
-
"block.toolsChanged": "[工具变更] 新增 {added} 个、移除 {removed} 个",
|
|
27
24
|
"note.compaction": "上下文压缩:",
|
|
28
25
|
"note.compacted": "历史已压缩",
|
|
29
26
|
"note.replace": "替换",
|
|
@@ -106,15 +103,12 @@ window.__ModuleLoader__.load({
|
|
|
106
103
|
"anchor.notLoaded": "该记录不在当前窗口,需先拉取更早历史",
|
|
107
104
|
"anchor.capped": "已向前翻页 {n} 页仍未找到;可先手动点「加载更早历史」再重试",
|
|
108
105
|
"anchor.bad": "锚点格式无法识别",
|
|
109
|
-
"anchor.jump": "跳转到锚点",
|
|
110
106
|
"anchor.clear": "清除锚点",
|
|
111
107
|
"anchor.jumpPlaceholder": "粘贴锚点,如 tvp1:e3019,回车定位",
|
|
112
108
|
"anchor.jumpTip": "粘贴任意站点详情里「复制锚点」得到的串,回车即可精确定位;目标在未加载的历史里时会自动向前翻页加载(有页数上限,超出会明确提示)。",
|
|
113
109
|
"anchor.searching": "正在向前加载更早历史以定位…",
|
|
114
110
|
"anchor.searchingPages": "正在向前加载更早历史以定位…(第 {n}/{max} 页,已载入 {stations} 站)",
|
|
115
111
|
"anchor.upgraded": "该记录已落定,请改用 {ref}",
|
|
116
|
-
"anchor.copiedLink": "已复制到你名下",
|
|
117
|
-
"anchor.badInput": "无法识别的锚点",
|
|
118
112
|
|
|
119
113
|
"detail.start": "开始",
|
|
120
114
|
"detail.end": "结束",
|
|
@@ -202,9 +196,6 @@ window.__ModuleLoader__.load({
|
|
|
202
196
|
"block.unknown": "[unknown content]",
|
|
203
197
|
"block.toolAdded": "[tool added] {name}",
|
|
204
198
|
"block.toolRemoved": "[tool removed] {name}",
|
|
205
|
-
"block.toolsAdded": "[tools added] {names}",
|
|
206
|
-
"block.toolsRemoved": "[tools removed] {names}",
|
|
207
|
-
"block.toolsChanged": "[tools changed] +{added} / -{removed}",
|
|
208
199
|
"note.compaction": "Context compacted: ",
|
|
209
200
|
"note.compacted": "history compacted",
|
|
210
201
|
"note.replace": "replaced",
|
|
@@ -287,15 +278,12 @@ window.__ModuleLoader__.load({
|
|
|
287
278
|
"anchor.notLoaded": "Not in the loaded window; load older history first",
|
|
288
279
|
"anchor.capped": "Paged back {n} pages without finding it; load older history manually and retry",
|
|
289
280
|
"anchor.bad": "Unrecognized anchor format",
|
|
290
|
-
"anchor.jump": "Jump to anchor",
|
|
291
281
|
"anchor.clear": "Clear anchor",
|
|
292
282
|
"anchor.jumpPlaceholder": "Paste an anchor (e.g. tvp1:e3019) and press Enter",
|
|
293
283
|
"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).",
|
|
294
284
|
"anchor.searching": "Loading older history to locate it…",
|
|
295
285
|
"anchor.searchingPages": "Loading older history to locate it… (page {n}/{max}, {stations} stations loaded)",
|
|
296
286
|
"anchor.upgraded": "This record is now durable; use {ref}",
|
|
297
|
-
"anchor.copiedLink": "Link copied",
|
|
298
|
-
"anchor.badInput": "Unrecognized anchor",
|
|
299
287
|
|
|
300
288
|
"detail.start": "Start",
|
|
301
289
|
"detail.end": "End",
|
|
@@ -4177,6 +4165,18 @@ window.__ModuleLoader__.load({
|
|
|
4177
4165
|
const onSearchKey = (ev) => {
|
|
4178
4166
|
ev.stopPropagation();
|
|
4179
4167
|
if (ev.key === "Enter") { gotoMatch(ev.shiftKey ? -1 : 1); ev.preventDefault(); }
|
|
4168
|
+
// README §7 has promised `↑` / `↓` for previous/next match since the
|
|
4169
|
+
// shortcut table existed, and NOTHING implemented it: the panel handler
|
|
4170
|
+
// bails out for `input` targets and this handler only knew Enter/Escape,
|
|
4171
|
+
// so the two most natural keys did nothing at all. Measured in the
|
|
4172
|
+
// browser probe: focus the box with 2/3 shown, press ArrowDown, counter
|
|
4173
|
+
// stays "2/3" — the documented feature simply was not there (§13.57).
|
|
4174
|
+
//
|
|
4175
|
+
// Inside a single-line search box there is no vertical caret movement to
|
|
4176
|
+
// steal, so binding these two is what a user coming from browser find
|
|
4177
|
+
// expects.
|
|
4178
|
+
else if (ev.key === "ArrowDown") { gotoMatch(1); ev.preventDefault(); }
|
|
4179
|
+
else if (ev.key === "ArrowUp") { gotoMatch(-1); ev.preventDefault(); }
|
|
4180
4180
|
else if (ev.key === "Escape") { setQueryRaw(""); ev.preventDefault(); }
|
|
4181
4181
|
};
|
|
4182
4182
|
const clearSearch = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-trajectory-traceview-plus",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
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",
|
|
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",
|
|
66
66
|
"test": "node test/smoke.test.cjs",
|
|
67
67
|
"prepublishOnly": "npm run check"
|
|
68
68
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Prove the P1 growth guard can still tell linear from quadratic.
|
|
4
|
+
*
|
|
5
|
+
* §13.55 found the guard was measuring the wrong thing: it took the MINIMUM of the
|
|
6
|
+
* three per-round ratios. Noise is one-sided (scheduling hiccups only lengthen a
|
|
7
|
+
* sample), so a round where the small sample got inflated and the big one did not
|
|
8
|
+
* produces an abnormally LOW ratio — and min() keeps exactly that round. With a
|
|
9
|
+
* known O(n^2) under jitter it missed 12 of 20 trials.
|
|
10
|
+
*
|
|
11
|
+
* Fixing the estimator is easy. Keeping it fixed is the hard part: nothing in the
|
|
12
|
+
* normal green suite would notice if a future edit reintroduced coupling, because
|
|
13
|
+
* the guard passes on healthy code either way. This script is the missing test —
|
|
14
|
+
* it feeds the SAME measurement protocol two functions whose complexity is known
|
|
15
|
+
* in advance and checks the verdict, under the same one-sided jitter that broke it.
|
|
16
|
+
*
|
|
17
|
+
* node scripts/bench-fold.mjs --guard-check
|
|
18
|
+
*
|
|
19
|
+
* Not in CI on purpose: it measures wall time, so a loaded machine makes it flaky,
|
|
20
|
+
* and a flaky gate trains people to ignore gates. Run it after touching the P1
|
|
21
|
+
* block, or when a performance claim is being made.
|
|
22
|
+
*/
|
|
23
|
+
const cpuMs = (fn, n, reps, jitter) => {
|
|
24
|
+
let best = Infinity;
|
|
25
|
+
for (let i = 0; i < 5; i += 1) {
|
|
26
|
+
const before = process.cpuUsage();
|
|
27
|
+
for (let r = 0; r < reps; r += 1) fn(n);
|
|
28
|
+
const used = process.cpuUsage(before);
|
|
29
|
+
// One-sided noise, exactly the shape real scheduling produces.
|
|
30
|
+
const ms = ((used.user + used.system) / 1000 / reps) * (1 + Math.random() * jitter);
|
|
31
|
+
if (ms < best) best = ms;
|
|
32
|
+
}
|
|
33
|
+
return best;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const callMs = (fn, n, jitter) => {
|
|
37
|
+
let reps = 1;
|
|
38
|
+
let ms = cpuMs(fn, n, 1, jitter);
|
|
39
|
+
while (ms * reps < 15 && reps < 64) {
|
|
40
|
+
reps *= 2;
|
|
41
|
+
ms = cpuMs(fn, n, reps, jitter);
|
|
42
|
+
}
|
|
43
|
+
return ms;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const linear = (n) => { let a = 0; for (let i = 0; i < n; i += 1) a += i; return a; };
|
|
47
|
+
const quadratic = (n) => { let a = 0; for (let i = 0; i < n; i += 1) for (let j = 0; j < n; j += 1) a += 1; return a; };
|
|
48
|
+
|
|
49
|
+
/** The production estimator: min of each size, then divide. */
|
|
50
|
+
const newEstimator = (fn, base, jitter) => {
|
|
51
|
+
const smalls = [];
|
|
52
|
+
const bigs = [];
|
|
53
|
+
for (let r = 0; r < 3; r += 1) {
|
|
54
|
+
smalls.push(callMs(fn, base, jitter));
|
|
55
|
+
bigs.push(callMs(fn, base * 2, jitter));
|
|
56
|
+
}
|
|
57
|
+
return Math.min(...bigs) / Math.min(...smalls);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** The estimator §13.55 replaced — kept here so the regression is demonstrable. */
|
|
61
|
+
const oldEstimator = (fn, base, jitter) => {
|
|
62
|
+
const ratios = [];
|
|
63
|
+
for (let r = 0; r < 3; r += 1) {
|
|
64
|
+
ratios.push(callMs(fn, base * 2, jitter) / callMs(fn, base, jitter));
|
|
65
|
+
}
|
|
66
|
+
return Math.min(...ratios);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const THRESHOLD = 3;
|
|
70
|
+
const JITTER = 2;
|
|
71
|
+
const TRIALS = 12;
|
|
72
|
+
|
|
73
|
+
let oldMissed = 0;
|
|
74
|
+
let newMissed = 0;
|
|
75
|
+
let newFalseAlarm = 0;
|
|
76
|
+
for (let t = 0; t < TRIALS; t += 1) {
|
|
77
|
+
if (oldEstimator(quadratic, 3100, JITTER) <= THRESHOLD) oldMissed += 1;
|
|
78
|
+
if (newEstimator(quadratic, 3100, JITTER) <= THRESHOLD) newMissed += 1;
|
|
79
|
+
if (newEstimator(linear, 400000, JITTER) > THRESHOLD) newFalseAlarm += 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log('guard-check: threshold ' + THRESHOLD + ', jitter ' + JITTER + 'x one-sided, ' + TRIALS + ' trials each');
|
|
83
|
+
console.log(' quadratic missed by min-of-ratios: ' + oldMissed + '/' + TRIALS
|
|
84
|
+
+ (oldMissed > TRIALS / 2 ? ' (this is the §13.55 bug — the estimator is blind)' : ''));
|
|
85
|
+
console.log(' quadratic missed by min/min: ' + newMissed + '/' + TRIALS);
|
|
86
|
+
console.log(' linear false alarms (min/min): ' + newFalseAlarm + '/' + TRIALS);
|
|
87
|
+
|
|
88
|
+
// The guard must (a) catch a real quadratic most of the time and (b) not cry wolf on
|
|
89
|
+
// linear code. Both bounds are loose because this measures wall time; the point is to
|
|
90
|
+
// fail loudly if the estimator regresses, not to certify a statistic.
|
|
91
|
+
//
|
|
92
|
+
// The decisive assertion is the COMPARISON, not either absolute number: if the current
|
|
93
|
+
// estimator misses at least as often as the one §13.55 replaced, the fix has been
|
|
94
|
+
// undone or neutralised and the guard is blind again. An absolute bound alone could
|
|
95
|
+
// not see that — replacing newEstimator with oldEstimator still scored 3/12 on one
|
|
96
|
+
// run, comfortably under a "> half" rule, because the two estimators draw different
|
|
97
|
+
// random jitter and the whole measurement is noisy.
|
|
98
|
+
if (newMissed >= oldMissed && oldMissed > 0) {
|
|
99
|
+
console.error('guard-check: FAIL — the current estimator is no better than the pre-§13.55 one ('
|
|
100
|
+
+ newMissed + '/' + TRIALS + ' vs ' + oldMissed + '/' + TRIALS + ' missed); the guard is blind again');
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
if (newMissed > TRIALS / 2) {
|
|
104
|
+
console.error('guard-check: FAIL — the current estimator misses a real O(n^2) more often than it catches it');
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
if (newFalseAlarm > 2) {
|
|
108
|
+
console.error('guard-check: FAIL — too many false alarms on linear code; the threshold or the estimator drifted');
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
console.log('guard-check: OK — the estimator separates the two complexities');
|
|
112
|
+
console.log(' (the comparison against the old estimator is what would catch a regression; the');
|
|
113
|
+
console.log(' absolute numbers alone are too noisy to rely on)');
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Report the
|
|
3
|
+
* Report the places a release has to exist, side by side.
|
|
4
4
|
*
|
|
5
|
-
* §13.43, §13.45 and §13.
|
|
6
|
-
* self-consistent while an outside world disagreed
|
|
5
|
+
* §13.43, §13.45, §13.47, §13.49, §13.51 and §13.52 are one failure repeated:
|
|
6
|
+
* the repository was self-consistent while an outside world disagreed, or while this
|
|
7
|
+
* very script reported success over a row it had just printed as missing.
|
|
7
8
|
*
|
|
8
9
|
* git tag ← what this checkout claims
|
|
10
|
+
* tag = shipped ← does the tree you would publish still match the tag?
|
|
9
11
|
* GitHub Release ← what the badge on the repo page reads
|
|
10
|
-
* npm registry ←
|
|
12
|
+
* npm registry ← metadata AND whether the tarball bytes actually serve
|
|
13
|
+
* npm @latest ← does the resolver hand out that version, or silently an older one?
|
|
11
14
|
*
|
|
12
|
-
* Each
|
|
15
|
+
* Each is invisible from inside the others. After `git push` + `git tag` +
|
|
13
16
|
* `gh release create` the repo looks finished; if `npm publish` never ran, everyone
|
|
14
17
|
* installing by package name still gets the previous version and nothing errors.
|
|
15
18
|
*
|
|
@@ -17,11 +20,12 @@
|
|
|
17
20
|
* api.github.com, and a gate that fails when the network is flaky trains people to
|
|
18
21
|
* ignore it. Run it before announcing a release:
|
|
19
22
|
*
|
|
20
|
-
* node scripts/release-status.mjs # report; exit 1 if
|
|
23
|
+
* node scripts/release-status.mjs # report; exit 1 if any row is missing
|
|
21
24
|
* node scripts/release-status.mjs --warn # report only, always exit 0
|
|
22
25
|
*/
|
|
23
26
|
import { execFileSync } from 'node:child_process';
|
|
24
|
-
import { readFileSync } from 'node:fs';
|
|
27
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
28
|
+
import { tmpdir } from 'node:os';
|
|
25
29
|
import { dirname, join } from 'node:path';
|
|
26
30
|
import { fileURLToPath } from 'node:url';
|
|
27
31
|
|
|
@@ -32,9 +36,9 @@ const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
|
32
36
|
const version = String(pkg.version);
|
|
33
37
|
const name = String(pkg.name);
|
|
34
38
|
|
|
35
|
-
const run = (cmd, args) => {
|
|
39
|
+
const run = (cmd, args, cwd = ROOT) => {
|
|
36
40
|
try {
|
|
37
|
-
return { ok: true, out: execFileSync(cmd, args, { cwd
|
|
41
|
+
return { ok: true, out: execFileSync(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim() };
|
|
38
42
|
} catch (e) {
|
|
39
43
|
return { ok: false, out: ((e.stdout ?? '') + (e.stderr ?? '')).trim() };
|
|
40
44
|
}
|
|
@@ -102,31 +106,171 @@ rows.push({
|
|
|
102
106
|
});
|
|
103
107
|
|
|
104
108
|
// 4. npm registry — what `npm i <name>@latest` installs.
|
|
109
|
+
//
|
|
110
|
+
// Two separate facts, because they failed separately: the VERSION being present in
|
|
111
|
+
// the packument (metadata) and the TARBALL being downloadable (bytes). Right after
|
|
112
|
+
// 0.11.1's publish, `versions` and `dist-tags.latest` both said 0.11.1 while
|
|
113
|
+
// `…/dsh-trajectory-traceview-plus-0.11.1.tgz` returned HTTP 404 for ~2 minutes —
|
|
114
|
+
// so `dsh plugin add pkg@0.11.1` failed with "Tarball server returned HTTP 404"
|
|
115
|
+
// while every metadata check looked perfect. `npm view <pkg>@<v> version` cannot
|
|
116
|
+
// see that; only fetching the URL can.
|
|
105
117
|
const npmView = run('npm', ['view', name + '@' + version, 'version']);
|
|
106
118
|
const latest = run('npm', ['view', name, 'dist-tags.latest']);
|
|
119
|
+
const published = npmView.ok && npmView.out.includes(version);
|
|
120
|
+
let tarballState = 'not checked';
|
|
121
|
+
let tarballCode = '';
|
|
122
|
+
if (published) {
|
|
123
|
+
const url = run('npm', ['view', name + '@' + version, 'dist.tarball']).out;
|
|
124
|
+
// HEAD, no cache-buster: a cache-buster would defeat the very cache that is stale,
|
|
125
|
+
// hiding exactly the window a real installer would fall into.
|
|
126
|
+
const code = run('curl', ['-s', '-o', '/dev/null', '-w', '%{http_code}', '-I', url]).out;
|
|
127
|
+
tarballCode = code;
|
|
128
|
+
tarballState = code === '200' ? 'tarball downloads' : 'tarball URL returns HTTP ' + code + ' (metadata is live, bytes are not)';
|
|
129
|
+
}
|
|
107
130
|
rows.push({
|
|
108
131
|
place: 'npm registry',
|
|
109
|
-
present:
|
|
110
|
-
detail:
|
|
111
|
-
? '
|
|
112
|
-
: '
|
|
113
|
-
missing: '
|
|
132
|
+
present: published && tarballState === 'tarball downloads',
|
|
133
|
+
detail: !published
|
|
134
|
+
? 'MISSING — `npm i ' + name + '@latest` still installs ' + (latest.ok ? latest.out : '(unknown)')
|
|
135
|
+
: 'published' + (latest.ok ? ' (dist-tags.latest = ' + latest.out + ')' : '') + ', ' + tarballState,
|
|
136
|
+
missing: published && tarballState !== 'tarball downloads'
|
|
137
|
+
? 'wait for the CDN (a few minutes) then re-check; `npm view` is not enough'
|
|
138
|
+
: 'npm publish',
|
|
114
139
|
});
|
|
115
140
|
|
|
141
|
+
// 5. npm @latest — does the resolver actually hand out that version?
|
|
142
|
+
//
|
|
143
|
+
// Advisory row, NOT part of the verdict. pnpm 12 applies a supply-chain delay
|
|
144
|
+
// (`minimumReleaseAge`) whose default appears in no config output: right after a
|
|
145
|
+
// publish, `pnpm add <pkg>@latest` silently resolves to the PREVIOUS version while
|
|
146
|
+
// `npm view` reports the new one (§13.49). The window clears by itself, so making it
|
|
147
|
+
// fail would light a red lamp for hours after every release and teach people to
|
|
148
|
+
// ignore the output — the exact way §13.45's permanent yellow was useless.
|
|
149
|
+
//
|
|
150
|
+
// The check is the pair a sibling session proposed: resolve `@latest` twice, once
|
|
151
|
+
// with the delay on and once with it disabled, `--lockfile-only` so nothing downloads.
|
|
152
|
+
// If the two disagree, the resolver is holding the new release back and anyone using
|
|
153
|
+
// `@latest` is getting the old one.
|
|
154
|
+
const resolveLatest = (extra) => {
|
|
155
|
+
const dir = mkdtempSync(join(tmpdir(), 'dsr-'));
|
|
156
|
+
try {
|
|
157
|
+
writeFileSync(join(dir, 'package.json'), '{"name":"probe","version":"1.0.0"}\n');
|
|
158
|
+
run('pnpm', ['add', name + '@latest', '--lockfile-only', ...extra], dir);
|
|
159
|
+
const lock = readFileSync(join(dir, 'pnpm-lock.yaml'), 'utf8');
|
|
160
|
+
const m = new RegExp('^\\s{2}' + name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '@([^:\\s]+):', 'm').exec(lock);
|
|
161
|
+
return m === null ? null : m[1];
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
} finally {
|
|
165
|
+
rmSync(dir, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const resolvedDefault = resolveLatest([]);
|
|
169
|
+
const resolvedNoDelay = resolveLatest(['--config.minimumReleaseAge=0']);
|
|
170
|
+
if (resolvedDefault === null || resolvedNoDelay === null) {
|
|
171
|
+
// A row that quietly disappears is its own kind of blindness: the reader cannot
|
|
172
|
+
// tell "nothing to report" from "could not check". Say which it is.
|
|
173
|
+
rows.push({
|
|
174
|
+
place: 'npm @latest',
|
|
175
|
+
present: false,
|
|
176
|
+
advisory: true,
|
|
177
|
+
detail: 'could not resolve (pnpm unavailable, or the lockfile shape changed) — check by hand',
|
|
178
|
+
missing: '',
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
const held = resolvedDefault !== resolvedNoDelay;
|
|
182
|
+
// "self-heals" without a number is not information. pnpm's built-in default is
|
|
183
|
+
// 1440 minutes (24 h) — not the "few hours" an earlier version of this message
|
|
184
|
+
// implied, which is why the same advisory was still showing 6.2 h after the
|
|
185
|
+
// publish and looked like a bug. Say how old the release is and when it clears.
|
|
186
|
+
let window = '';
|
|
187
|
+
if (held) {
|
|
188
|
+
// A dotted key like `time.0.11.2` returns empty from npm (digit segments do not
|
|
189
|
+
// resolve), so read the whole time map and pick the key out of it.
|
|
190
|
+
// so read the whole time map and pick the key out of it.
|
|
191
|
+
const times = run('npm', ['view', name, 'time', '--json']);
|
|
192
|
+
let published = '';
|
|
193
|
+
try {
|
|
194
|
+
// `npm view … --json` wraps the object in an array; unwrap before reading the key.
|
|
195
|
+
const raw = JSON.parse(times.out);
|
|
196
|
+
const map = Array.isArray(raw) ? raw[0] : raw;
|
|
197
|
+
published = map?.[version] ?? '';
|
|
198
|
+
} catch { published = ''; }
|
|
199
|
+
const t = Date.parse(published);
|
|
200
|
+
if (Number.isFinite(t)) {
|
|
201
|
+
const ageH = (Date.now() - t) / 3_600_000;
|
|
202
|
+
const leftH = Math.max(0, 24 - ageH);
|
|
203
|
+
window = '; published ' + ageH.toFixed(1) + ' h ago, clears in ~' + leftH.toFixed(1)
|
|
204
|
+
+ ' h (pnpm default minimumReleaseAge = 1440 min)';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
rows.push({
|
|
208
|
+
place: 'npm @latest',
|
|
209
|
+
present: !held,
|
|
210
|
+
advisory: true,
|
|
211
|
+
detail: held
|
|
212
|
+
? 'resolver holds the new release back: @latest → ' + resolvedDefault
|
|
213
|
+
+ ', with minimumReleaseAge=0 → ' + resolvedNoDelay
|
|
214
|
+
+ window + '; install docs pin the version'
|
|
215
|
+
: 'resolver reaches ' + resolvedDefault + (resolvedDefault === version ? ' (the current release)' : ''),
|
|
216
|
+
missing: '',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
116
220
|
const pad = (s, n) => s + ' '.repeat(Math.max(0, n - [...s].length));
|
|
117
221
|
console.log('release-status: ' + name + '@' + version + '\n');
|
|
118
|
-
|
|
119
|
-
const
|
|
222
|
+
const mark = (r) => (r.advisory && !r.present ? '◐' : r.present ? '●' : '○');
|
|
223
|
+
for (const r of rows) console.log(' ' + mark(r) + ' ' + pad(r.place, 16) + r.detail);
|
|
224
|
+
const absent = rows.filter((r) => !r.present && !r.advisory);
|
|
225
|
+
const advisories = rows.filter((r) => r.advisory && !r.present);
|
|
120
226
|
if (absent.length > 0) {
|
|
121
227
|
console.log('\nmissing from ' + absent.length + ' place(s):');
|
|
122
228
|
for (const r of absent) if (r.missing) console.log(' ' + r.place + ': ' + r.missing);
|
|
123
229
|
}
|
|
230
|
+
if (advisories.length > 0) {
|
|
231
|
+
console.log('\n◐ = real but time-bounded, does not block:');
|
|
232
|
+
for (const r of advisories) console.log(' ' + r.place + ': ' + r.detail);
|
|
233
|
+
}
|
|
234
|
+
// ── verdict ──────────────────────────────────────────────────────────────────
|
|
235
|
+
//
|
|
236
|
+
// Every absent row must fail, not just npm. The first version only exited non-zero
|
|
237
|
+
// for the npm row and then printed "consistent everywhere" with a missing GitHub
|
|
238
|
+
// Release — a false green produced by this script itself, and exactly the shape
|
|
239
|
+
// §13.37 / §13.44 / §13.50 record three times over (the checker is wrong, not the
|
|
240
|
+
// state). The verdict is now derived from `absent` as a whole.
|
|
241
|
+
if (absent.length === 0) {
|
|
242
|
+
// Say the advisory out loud in the summary line. §13.52 was this script printing
|
|
243
|
+
// 'consistent everywhere' while a row above it said ○; a reader who skims the last
|
|
244
|
+
// line must not be able to come away believing there was nothing to see.
|
|
245
|
+
console.log('\nrelease-status: consistent everywhere'
|
|
246
|
+
+ (advisories.length > 0 ? ' (' + advisories.length + ' advisory above, not blocking)' : ''));
|
|
247
|
+
process.exit(0);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const reasons = [];
|
|
251
|
+
if (absent.some((r) => r.place === 'git tag')) {
|
|
252
|
+
reasons.push('no git tag claims this version — nothing else can be trusted');
|
|
253
|
+
}
|
|
254
|
+
if (absent.some((r) => r.place === 'tag = shipped')) {
|
|
255
|
+
reasons.push('the working tree\'s runtime files differ from the tag — a publish now would ship something the tag does not describe');
|
|
256
|
+
}
|
|
257
|
+
if (absent.some((r) => r.place === 'GitHub Release')) {
|
|
258
|
+
reasons.push('no GitHub Release — the version badge on the repo page shows a red "no releases"');
|
|
259
|
+
}
|
|
124
260
|
if (absent.some((r) => r.place === 'npm registry')) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
261
|
+
// Two very different causes read the same to a user ("install fails"), so the
|
|
262
|
+
// message has to name which one it is.
|
|
263
|
+
reasons.push(!published
|
|
264
|
+
? 'not on npm at all — anyone installing by package name still gets the previous version'
|
|
265
|
+
: 'in the npm packument but the tarball is not downloadable yet (HTTP ' + tarballCode +
|
|
266
|
+
') — `dsh plugin add` fails rather than installing something wrong; this one is safe, wait for the CDN');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (WARN_ONLY) {
|
|
270
|
+
console.log('\nrelease-status (warn only):');
|
|
271
|
+
for (const r of reasons) console.log(' · ' + r);
|
|
272
|
+
process.exit(0);
|
|
131
273
|
}
|
|
132
|
-
console.
|
|
274
|
+
console.error('\nrelease-status: NOT consistent — ' + reasons.length + ' problem(s):');
|
|
275
|
+
for (const r of reasons) console.error(' · ' + r);
|
|
276
|
+
process.exit(1);
|
|
@@ -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": "替换",
|
|
@@ -95,15 +92,12 @@
|
|
|
95
92
|
"anchor.notLoaded": "该记录不在当前窗口,需先拉取更早历史",
|
|
96
93
|
"anchor.capped": "已向前翻页 {n} 页仍未找到;可先手动点「加载更早历史」再重试",
|
|
97
94
|
"anchor.bad": "锚点格式无法识别",
|
|
98
|
-
"anchor.jump": "跳转到锚点",
|
|
99
95
|
"anchor.clear": "清除锚点",
|
|
100
96
|
"anchor.jumpPlaceholder": "粘贴锚点,如 tvp1:e3019,回车定位",
|
|
101
97
|
"anchor.jumpTip": "粘贴任意站点详情里「复制锚点」得到的串,回车即可精确定位;目标在未加载的历史里时会自动向前翻页加载(有页数上限,超出会明确提示)。",
|
|
102
98
|
"anchor.searching": "正在向前加载更早历史以定位…",
|
|
103
99
|
"anchor.searchingPages": "正在向前加载更早历史以定位…(第 {n}/{max} 页,已载入 {stations} 站)",
|
|
104
100
|
"anchor.upgraded": "该记录已落定,请改用 {ref}",
|
|
105
|
-
"anchor.copiedLink": "已复制到你名下",
|
|
106
|
-
"anchor.badInput": "无法识别的锚点",
|
|
107
101
|
|
|
108
102
|
"detail.start": "开始",
|
|
109
103
|
"detail.end": "结束",
|
|
@@ -191,9 +185,6 @@
|
|
|
191
185
|
"block.unknown": "[unknown content]",
|
|
192
186
|
"block.toolAdded": "[tool added] {name}",
|
|
193
187
|
"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
188
|
"note.compaction": "Context compacted: ",
|
|
198
189
|
"note.compacted": "history compacted",
|
|
199
190
|
"note.replace": "replaced",
|
|
@@ -276,15 +267,12 @@
|
|
|
276
267
|
"anchor.notLoaded": "Not in the loaded window; load older history first",
|
|
277
268
|
"anchor.capped": "Paged back {n} pages without finding it; load older history manually and retry",
|
|
278
269
|
"anchor.bad": "Unrecognized anchor format",
|
|
279
|
-
"anchor.jump": "Jump to anchor",
|
|
280
270
|
"anchor.clear": "Clear anchor",
|
|
281
271
|
"anchor.jumpPlaceholder": "Paste an anchor (e.g. tvp1:e3019) and press Enter",
|
|
282
272
|
"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
273
|
"anchor.searching": "Loading older history to locate it…",
|
|
284
274
|
"anchor.searchingPages": "Loading older history to locate it… (page {n}/{max}, {stations} stations loaded)",
|
|
285
275
|
"anchor.upgraded": "This record is now durable; use {ref}",
|
|
286
|
-
"anchor.copiedLink": "Link copied",
|
|
287
|
-
"anchor.badInput": "Unrecognized anchor",
|
|
288
276
|
|
|
289
277
|
"detail.start": "Start",
|
|
290
278
|
"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 = () => {
|