dsh-trajectory-traceview-plus 0.11.0 → 0.11.2
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 +46 -0
- package/README.en.md +19 -7
- package/README.md +27 -7
- package/docs/DESIGN.md +345 -0
- package/package.json +1 -1
- package/scripts/readme-numbers.mjs +83 -13
- package/scripts/release-status.mjs +75 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.2 — 2026-11-24
|
|
4
|
+
|
|
5
|
+
`release-status` 增加第 4 个外部环节的检查:**tarball 是否真的可下载**。
|
|
6
|
+
|
|
7
|
+
### Why
|
|
8
|
+
|
|
9
|
+
0.11.1 发布后,packument 的 `versions`、`dist-tags.latest`、`time`、`dist.shasum` 全部正确,
|
|
10
|
+
但 `…-0.11.1.tgz` 返回 **HTTP 404** 约两分钟——`dsh plugin add pkg@0.11.1` 直接失败。
|
|
11
|
+
|
|
12
|
+
`npm view` 只读元数据、从不下载 tarball,所以对这个窗口完全失明;而这个窗口正是
|
|
13
|
+
真实安装器会命中的那个。带个 cache-buster 立刻 200,说明是 CDN 把 404 缓存住了。
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `release-status.mjs` 的 npm 行拆成两个事实:元数据存在 + tarball 可下载。失败时区分
|
|
18
|
+
「没发布」与「发布了但字节还没到位」——后者是安全失败(装不上,而不是装错版本)。
|
|
19
|
+
- 故意**不加 cache-buster**:加了会绕开正是过期的那个缓存,从而隐藏真实安装器会踩的坑。
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- 发布清单第 12 步从「三处对齐」改为「四处对齐(tag / Release / npm 元数据 / tarball)」。
|
|
24
|
+
|
|
25
|
+
### Notes
|
|
26
|
+
|
|
27
|
+
0.11.0 / 0.11.1 / 0.11.2 三者**运行时代码完全相同**(`lib/` 逐字节一致)。这三次发版
|
|
28
|
+
修的都只是「用户能不能正确装上」这件事。
|
|
29
|
+
|
|
30
|
+
## 0.11.1 — 2026-11-24
|
|
31
|
+
|
|
32
|
+
修正 **0.11.0 已发布包内文档的错误**:那份 README 会让读者装错东西。
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **安装命令**:0.11.0 的 README 只给了 `github:` 一条路,且**不带 tag** —— 装的是默认分支 HEAD,不是任何发布版本。现在给出两条并都写死版本:npm(`…@0.11.1`)与 GitHub(`… #v0.11.1`),并说明为什么不能用 `@latest`。
|
|
37
|
+
- **观测组/断言数**:`--shots` 模式实际是 14 组 / 49 条断言(`browser-check.mjs` 自己会加一组 375px 溢出探测),README 一直写 13 / 47。默认模式下是对的,所以长期未被发现。
|
|
38
|
+
- `scripts/browser-check.mjs` 已按其真实行为计入 `readme-numbers` 的两项真相源。
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- `readme-numbers` 新增两类核对:**安装命令里的版本号**必须等于 `package.json`(否则改版本忘改 README 会红),以及 **`browser-check` 在 probe.js 之外追加的观测组与断言数**。
|
|
43
|
+
- 匹配规则改为**显式优先级**:具体规则先占位它匹配的字符区间,通用规则跳过已占位部分。此前「另加 2 条断言」会被通用规则误读成总断言数,导致门禁自己报假警(第三次同类问题)。
|
|
44
|
+
|
|
45
|
+
### Notes
|
|
46
|
+
|
|
47
|
+
0.11.0 与 0.11.1 的**运行时代码完全相同**(`lib/` 逐字节一致),差异只在文档与 `scripts/`。已经装了 0.11.0 的人不需要为了功能升级,但 npm 页面上的安装指引是错的,所以重新发版。
|
|
48
|
+
|
|
3
49
|
## 0.11.0 — 2026-11-24
|
|
4
50
|
|
|
5
51
|
`engines.dsh` 从硬钉单一版本改为**已验证版本的区间**,插件不再因为宿主小版本升级就被整体跳过。
|
package/README.en.md
CHANGED
|
@@ -128,12 +128,24 @@ dsh-trajectory-traceview-plus/ # repo root (directory name == npm package name
|
|
|
128
128
|
|
|
129
129
|
## 5. Quick start
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
Install from npm (recommended — **pin the exact version**):
|
|
132
132
|
|
|
133
133
|
```powershell
|
|
134
|
-
dsh plugin --profile web add
|
|
134
|
+
dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.2
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
> **Why not `@latest`**: `dsh plugin` forwards to pnpm, and **pnpm 12 ships a supply-chain delay** (`minimumReleaseAge`): a version that is too new 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).
|
|
138
|
+
>
|
|
139
|
+
> Related: this package's early `0.0.0-stage` has malformed metadata (no `size` field), so resolving `@latest` against a cold cache fails outright (`numeric field was not a number`). Pinning the version avoids that path.
|
|
140
|
+
|
|
141
|
+
Install from GitHub (**always pin the tag**):
|
|
142
|
+
|
|
143
|
+
```powershell
|
|
144
|
+
dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.2"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> **Why the `#v0.11.2` 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.
|
|
148
|
+
|
|
137
149
|
Then **restart `dsh web`** to take effect.
|
|
138
150
|
|
|
139
151
|
> After installation the plugin lives at `$DSH_HOME\profiles\web\node_modules\dsh-trajectory-traceview-plus` (cloned by pnpm from GitHub), independent of the source checkout location.
|
|
@@ -234,7 +246,7 @@ The tests run the helper region against mock snapshots covering: tree building /
|
|
|
234
246
|
|
|
235
247
|
```powershell
|
|
236
248
|
node scripts/browser-check.mjs # builds the harness; 47 assertions over 13 recorded groups
|
|
237
|
-
node scripts/browser-check.mjs --shots #
|
|
249
|
+
node scripts/browser-check.mjs --shots # saves screenshots and adds 1 more group / 2 assertions: 375px overflow (14 total)
|
|
238
250
|
```
|
|
239
251
|
|
|
240
252
|
It needs `agent-browser` (Chrome via CDP). **Deliberately not in CI**: adding a browser to the runner is more moving parts than the check is worth, and a flaky browser job trains people to ignore red builds. Run it locally before releasing.
|
|
@@ -295,12 +307,12 @@ node scripts/provenance.mjs # 4. refresh the provenance list (rerun
|
|
|
295
307
|
npm run check # 5. the 7 local gates; all green before going further
|
|
296
308
|
git add -A; git commit -m "..." # 6.
|
|
297
309
|
git push origin main # 7.
|
|
298
|
-
git tag -a v0.11.
|
|
299
|
-
git push origin v0.11.
|
|
310
|
+
git tag -a v0.11.2 -m "..." # 8.
|
|
311
|
+
git push origin v0.11.2 # 9.
|
|
300
312
|
npm publish # 10. runs prepublishOnly -> the whole check again
|
|
301
|
-
gh release create v0.11.
|
|
313
|
+
gh release create v0.11.2 --notes-file … # 11. the badge reads the Release, not the tag
|
|
302
314
|
|
|
303
|
-
node scripts/release-status.mjs # 12. do all
|
|
315
|
+
node scripts/release-status.mjs # 12. do all four agree? (tag / Release / npm metadata / tarball)
|
|
304
316
|
```
|
|
305
317
|
|
|
306
318
|
**Step 10 is the easiest to miss and it fails silently.** After `git push` and `git tag` the repo looks "released" — but the registry still serves the old version, so `npm i <name>@latest` hands people the old package. That happened here once: tag and Release both present, npm still on the previous release (§13.47).
|
package/README.md
CHANGED
|
@@ -131,12 +131,32 @@ dsh-trajectory-traceview-plus/ # 仓库根(目录名 = npm 包名)
|
|
|
131
131
|
|
|
132
132
|
## 5. 快速开始
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
从 npm 安装(推荐,**写死版本号**):
|
|
135
135
|
|
|
136
136
|
```powershell
|
|
137
|
-
dsh plugin --profile web add
|
|
137
|
+
dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.2
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
> **为什么不用 `@latest`**:`dsh plugin` 底层是 pnpm,而 **pnpm 12 有供应链延迟保护**
|
|
141
|
+
> (`minimumReleaseAge`):太新的版本不会被 `@latest` 选中,pnpm 会**静默退回上一个版本**
|
|
142
|
+
> ——不打任何警告。0.11.0 刚发布时实测 `pnpm add pkg@latest` 装到的是 0.10.0,
|
|
143
|
+
> 而那版本在新宿主上会被跳过。写死版本号就没有这个歧义(冷/热缓存实测都能装到 0.11.0)。
|
|
144
|
+
>
|
|
145
|
+
> 顺带:本包的 `0.0.0-stage` 那个早期测试版本元数据残缺(缺 `size` 字段),
|
|
146
|
+
> 冷缓存下走 `@latest` 解析时 pnpm 会因此直接失败(`numeric field was not a number`)。
|
|
147
|
+
> 写死版本号绕开这条路径。
|
|
148
|
+
|
|
149
|
+
从 GitHub 安装(**必须带 tag**):
|
|
150
|
+
|
|
151
|
+
```powershell
|
|
152
|
+
dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.2"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
> **为什么必须带 `#v0.11.2`**:`github:` 规格不带 ref 时装的是**默认分支的 HEAD**,
|
|
156
|
+
> 不是任何发布版本。而这个仓库在发版后还会继续提交(本轮 v0.11.0 之后就有 5 个
|
|
157
|
+
> 文档/脚本提交),所以"不带 ref"装到的东西**明天可能是另一个样子**,而版本号
|
|
158
|
+
> 仍写着 0.11.0。带 tag 才能让"装到的"和"发布过的"是同一份代码。
|
|
159
|
+
|
|
140
160
|
然后**重启 `dsh web`** 生效。
|
|
141
161
|
|
|
142
162
|
> 安装后插件位于 `$DSH_HOME\profiles\web\node_modules\dsh-trajectory-traceview-plus`(pnpm 从 GitHub 克隆),与源码仓库位置无关。
|
|
@@ -237,7 +257,7 @@ npm test # 只跑 smoke
|
|
|
237
257
|
|
|
238
258
|
```powershell
|
|
239
259
|
node scripts/browser-check.mjs # 起 harness,跑 47 条断言 / 记录 13 组观测
|
|
240
|
-
node scripts/browser-check.mjs --shots #
|
|
260
|
+
node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 2 条断言(375px 溢出,共 14 组)
|
|
241
261
|
```
|
|
242
262
|
|
|
243
263
|
它需要 `agent-browser`(Chrome via CDP)。**故意不进 CI**:把浏览器塞进 runner 的
|
|
@@ -303,12 +323,12 @@ node scripts/provenance.mjs # 4. 刷新来源清单(新增/改名
|
|
|
303
323
|
npm run check # 5. 7 步门禁,全绿再往下
|
|
304
324
|
git add -A; git commit -m "..." # 6.
|
|
305
325
|
git push origin main # 7.
|
|
306
|
-
git tag -a v0.11.
|
|
307
|
-
git push origin v0.11.
|
|
326
|
+
git tag -a v0.11.2 -m "..." # 8.
|
|
327
|
+
git push origin v0.11.2 # 9.
|
|
308
328
|
npm publish # 10. 触发 prepublishOnly → 再跑一遍 check
|
|
309
|
-
gh release create v0.11.
|
|
329
|
+
gh release create v0.11.2 --notes-file … # 11. 徽章读的是 Release,不是 tag
|
|
310
330
|
|
|
311
|
-
node scripts/release-status.mjs # 12.
|
|
331
|
+
node scripts/release-status.mjs # 12. 四处对齐了吗?(tag / Release / npm 元数据 / tarball)
|
|
312
332
|
```
|
|
313
333
|
|
|
314
334
|
**第 10 步最容易漏,而且不会有任何报错**:`git push` + `git tag` 之后仓库看起来"发布完了",但 registry 上还是旧版本。任何人 `npm i <包名>@latest` 拿到的都是旧包。这个仓就发生过一次——tag 和 Release 都在,npm 还停在上一版(§13.47)。
|
package/docs/DESIGN.md
CHANGED
|
@@ -7795,3 +7795,348 @@ commit → push → tag → push tag → GitHub Release」,**漏掉了唯一
|
|
|
7795
7795
|
没有下一个门禁,所以它自己必须被写进清单。
|
|
7796
7796
|
3. 我给出的技术断言没有实测就说了,而且是**确定语气**。`file:` 的两种形式行为
|
|
7797
7797
|
不同,我拿一种的行为去描述另一种。对方实测才发现——这次是运气,不是严谨。
|
|
7798
|
+
|
|
7799
|
+
|
|
7800
|
+
### 13.48 发布过程本身暴露的三件事(2026-11-24)
|
|
7801
|
+
|
|
7802
|
+
用户批准后执行了 `npm publish`。过程里撞到三个值得记的东西。
|
|
7803
|
+
|
|
7804
|
+
#### 一、`npm publish` 打印成功,registry 却还没有
|
|
7805
|
+
|
|
7806
|
+
```
|
|
7807
|
+
+ dsh-trajectory-traceview-plus@0.11.0
|
|
7808
|
+
```
|
|
7809
|
+
|
|
7810
|
+
紧接着查询:`versions: 0.0.0-stage, 0.10.0`,`dist-tags.latest` 仍是 `0.10.0`。
|
|
7811
|
+
**看起来像失败。** 连 `curl` 直连 registry 也一样。
|
|
7812
|
+
|
|
7813
|
+
真相在 packument 的 `time` 字段里:
|
|
7814
|
+
|
|
7815
|
+
```json
|
|
7816
|
+
"0.11.0": "2026-11-24T04:33:54.570Z",
|
|
7817
|
+
"modified": "2026-11-24T04:33:54.733Z"
|
|
7818
|
+
```
|
|
7819
|
+
|
|
7820
|
+
发布时间已经写入,只是 `versions` 对象和 `dist-tags` 还在 CDN 复制中。等了约
|
|
7821
|
+
一分钟,三处全部就位。
|
|
7822
|
+
|
|
7823
|
+
**教训**:注册表的"写入成功"和"读到新值"之间有真实延迟,而延迟期内的读取结果
|
|
7824
|
+
**和"发布失败"长得一模一样**。差点因为一次过早的复查就重新发布(第二次会因
|
|
7825
|
+
版本已存在而失败,然后我可能误判成权限问题)。
|
|
7826
|
+
|
|
7827
|
+
正确的确认方式是查 `time` 字段——它是写入即生效的,不像 `versions` 走 CDN。
|
|
7828
|
+
|
|
7829
|
+
#### 二、本机 web profile 用的是软链,验证不到"发布出来的包"
|
|
7830
|
+
|
|
7831
|
+
本机 `~/.dsh/profiles/web/node_modules/dsh-trajectory-traceview-plus` 指向源码仓。
|
|
7832
|
+
所以此前所有"真机实跑"验证的都是**工作区源码**,不是 registry 上的 tarball。
|
|
7833
|
+
|
|
7834
|
+
于是补了两件事:
|
|
7835
|
+
|
|
7836
|
+
1. `npm pack dsh-trajectory-traceview-plus@0.11.0` 解包后与仓库**逐文件比 sha256**,
|
|
7837
|
+
27 个文件全部相同(含 `lib/client.js`、`package.json`、`src/`、两份 README)。
|
|
7838
|
+
既然包内容 == 已验证的源码,那些实跑结论就可以迁移过来,不需要重跑浏览器。
|
|
7839
|
+
2. 另起一个隔离 `DSH_HOME`,用真实 npm 安装路径装 0.11.0,
|
|
7840
|
+
`dsh --profile web --dump-config` **0 条 skip**,插件行进入组合树。
|
|
7841
|
+
|
|
7842
|
+
隔离 profile 里没有会话数据,所以顺带确认了一件边界事:**"能加载"和"能渲染"是两个
|
|
7843
|
+
不同的证据**,前者由 `dump-config` 给,后者只有真实会话能给。两者都拿到才算验证
|
|
7844
|
+
完整——这次前者在隔离环境拿到,后者在原环境(同一份源码)拿到,中间由 sha256 相等
|
|
7845
|
+
把两段证据接起来。
|
|
7846
|
+
|
|
7847
|
+
#### 三、`npm deprecate` 比 `unpublish` 更适合"旧版有坑"
|
|
7848
|
+
|
|
7849
|
+
`0.10.0` 并非全坏——它只在 `dsh > 0.2.2-rc.2` 上被跳过,在 rc.2 上工作正常。
|
|
7850
|
+
所以没有 unpublish(那会破坏已经锁版本的用户,且有 72 小时窗口限制),而是给
|
|
7851
|
+
`0.10.0` 挂了 deprecation:
|
|
7852
|
+
|
|
7853
|
+
```
|
|
7854
|
+
Superseded by 0.11.0. This version pins engines.dsh to =0.2.2-rc.2, so DSH skips it
|
|
7855
|
+
on 0.2.2-rc.3 and later (the whole tab disappears). Upgrade with: dsh plugin --profile
|
|
7856
|
+
web add dsh-trajectory-traceview-plus@latest
|
|
7857
|
+
```
|
|
7858
|
+
|
|
7859
|
+
实测用户装 0.10.0 时 npm 会打印 `npm warn deprecated …`,提示里**直接带修复命令**。
|
|
7860
|
+
|
|
7861
|
+
**教训**:坏版本的正确处理不是抹掉,是**让下游在踩到时立刻知道原因和解法**。
|
|
7862
|
+
`unpublish` 让痕迹消失,`deprecate` 把知识留在现场。
|
|
7863
|
+
|
|
7864
|
+
#### 事后状态
|
|
7865
|
+
|
|
7866
|
+
```
|
|
7867
|
+
git tag ● v0.11.0
|
|
7868
|
+
GitHub Release ● v0.11.0(徽章正常)
|
|
7869
|
+
npm registry ● 0.11.0 = latest;0.10.0 已 deprecate
|
|
7870
|
+
```
|
|
7871
|
+
|
|
7872
|
+
`node scripts/release-status.mjs` → `consistent everywhere`。
|
|
7873
|
+
|
|
7874
|
+
|
|
7875
|
+
### 13.49 `@latest` 会静默装到旧版本:pnpm 12 的供应链延迟(2026-11-24)
|
|
7876
|
+
|
|
7877
|
+
#### 现象
|
|
7878
|
+
|
|
7879
|
+
0.11.0 发布、`release-status` 三处全绿之后,我用 README 里写的命令在隔离
|
|
7880
|
+
`DSH_HOME` 里装:
|
|
7881
|
+
|
|
7882
|
+
```powershell
|
|
7883
|
+
dsh plugin --profile web add dsh-trajectory-traceview-plus@latest
|
|
7884
|
+
```
|
|
7885
|
+
|
|
7886
|
+
结果:
|
|
7887
|
+
|
|
7888
|
+
```
|
|
7889
|
+
Plugin dsh-trajectory-traceview-plus@0.10.0 is incompatible with dsh 0.2.2-rc.5
|
|
7890
|
+
dsh: plugin command failed
|
|
7891
|
+
```
|
|
7892
|
+
|
|
7893
|
+
**刚发布的 0.11.0 就在 registry 上,`@latest` 却装到了 0.10.0。**
|
|
7894
|
+
|
|
7895
|
+
#### 根因:pnpm 12 的 `minimumReleaseAge`
|
|
7896
|
+
|
|
7897
|
+
pnpm 12 内置供应链延迟保护:太新的版本不参与 `@latest` 解析。默认值让刚发布的
|
|
7898
|
+
版本在**一段时间内不可见**。实测判据很干脆:
|
|
7899
|
+
|
|
7900
|
+
```
|
|
7901
|
+
pnpm add pkg@latest → 0.10.0 (静默)
|
|
7902
|
+
pnpm add pkg@latest --config.minimumReleaseAge=0 → 0.11.0 (立刻正确)
|
|
7903
|
+
pnpm add pkg@0.11.0 → 0.11.0 (正确,冷/热缓存都行)
|
|
7904
|
+
```
|
|
7905
|
+
|
|
7906
|
+
`pnpm view pkg version` 报的是 `0.11.0`,`pnpm view pkg dist-tags` 也是
|
|
7907
|
+
`{"latest":"0.11.0"}`,缓存文件里的 `distTags` 也对——**只有真正的安装路径
|
|
7908
|
+
会退回旧版,而且不打任何警告**。
|
|
7909
|
+
|
|
7910
|
+
#### 为什么这个坑特别毒
|
|
7911
|
+
|
|
7912
|
+
它的表现和「发布失败」**完全一样**:装到旧版本 → 旧版本 `engines.dsh` 不匹配
|
|
7913
|
+
→ 宿主拒绝 → 报错信息里写的是旧版本号。上一轮我刚因为「以为发布了其实没发」
|
|
7914
|
+
坑过一次,这次是**真发布了,但安装路径自己退回去了**。
|
|
7915
|
+
|
|
7916
|
+
也就是说:§13.47 的教训(`npm publish` 是叶子步骤,漏了没报错)刚记住,
|
|
7917
|
+
它的下一个变体就出现了——**发布成功也不等于用户装得到**。
|
|
7918
|
+
|
|
7919
|
+
#### 附带发现的第二个问题
|
|
7920
|
+
|
|
7921
|
+
`0.0.0-stage` 是本包最早的测试版本,元数据残缺(`dist` 里缺 `size` 字段,
|
|
7922
|
+
只有 `fileCount` / `unpackedSize`)。后果是:**冷缓存下走 `@latest` 解析时,
|
|
7923
|
+
pnpm 会去拉这个版本的 tarball 并硬失败**:
|
|
7924
|
+
|
|
7925
|
+
```
|
|
7926
|
+
[WARN] GET .../dsh-trajectory-traceview-plus-0.0.0-stage.tgz error
|
|
7927
|
+
(numeric field was not a number: when getting size for package)
|
|
7928
|
+
× adding a new package
|
|
7929
|
+
╰─▶ numeric field was not a number: when getting size for package
|
|
7930
|
+
```
|
|
7931
|
+
|
|
7932
|
+
写死版本号不走这条路径,冷缓存实测成功。这条只能靠「别用 `@latest`」规避,
|
|
7933
|
+
已发布的元数据改不了。
|
|
7934
|
+
|
|
7935
|
+
#### 修法
|
|
7936
|
+
|
|
7937
|
+
两份 README 的安装命令从 `@latest` 改成**写死版本号**,并写明为什么:
|
|
7938
|
+
|
|
7939
|
+
> pnpm 12 有供应链延迟保护,太新的版本不会被 `@latest` 选中,pnpm 会静默退回
|
|
7940
|
+
> 上一个版本——不留任何警告。
|
|
7941
|
+
|
|
7942
|
+
这不是"绕过问题",而是**承认版本解析不该由本插件来承诺**。读者要的是「装上能用
|
|
7943
|
+
的 0.11.0」,写死版本号直接给出这个结果;`@latest` 把结果交给了三个变量(注册表
|
|
7944
|
+
CDN、pnpm 策略、时间),而这三样都不在插件的控制里。
|
|
7945
|
+
|
|
7946
|
+
#### 验证
|
|
7947
|
+
|
|
7948
|
+
隔离 `DSH_HOME` 用新命令实装:
|
|
7949
|
+
|
|
7950
|
+
```
|
|
7951
|
+
dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.0
|
|
7952
|
+
+ dsh-trajectory-traceview-plus 0.11.0
|
|
7953
|
+
dump-config: 0 条 skip,插件行存在
|
|
7954
|
+
```
|
|
7955
|
+
|
|
7956
|
+
#### 教训
|
|
7957
|
+
|
|
7958
|
+
1. **"发布成功"有三个后续环节**:registry 写入 → CDN 复制 → **包管理器愿意选它**。
|
|
7959
|
+
前两个我上一轮已经学到,第三个是新的:包管理器可能出于安全策略**主动不选**。
|
|
7960
|
+
2. **静默降级比报错危险**。这里 pnpm 在保护用户(防止刚发布的恶意包),但它
|
|
7961
|
+
不说,于是表现成"发布没成功"。**安全默认值 + 无提示 = 一个看起来像 bug 的正确行为。**
|
|
7962
|
+
3. 文档里的安装命令要**可验证**。我上一轮写 `@latest` 时没在干净环境跑过;
|
|
7963
|
+
这一轮跑一下就露了。凡是"用户会照抄"的命令,必须自己先照抄一遍。
|
|
7964
|
+
|
|
7965
|
+
|
|
7966
|
+
### 13.50 「数出来」的真相源也只读了一个文件(2026-11-24)
|
|
7967
|
+
|
|
7968
|
+
#### 现象
|
|
7969
|
+
|
|
7970
|
+
`readme-numbers` 上线后一直在核对「13 组观测 / 47 条断言」。跑一次带 `--shots` 的
|
|
7971
|
+
`browser-check`:
|
|
7972
|
+
|
|
7973
|
+
```
|
|
7974
|
+
browser-check: PASS (14 observation groups recorded, 0 failures)
|
|
7975
|
+
```
|
|
7976
|
+
|
|
7977
|
+
**14 组,而 README 一直写 13,门禁全绿。**
|
|
7978
|
+
|
|
7979
|
+
#### 根因:同一个坑,隔了一个文件
|
|
7980
|
+
|
|
7981
|
+
`readme-numbers` 从 `test/browser/probe.js` 数 `info.X =` 得到 13 组、数 `fail(`
|
|
7982
|
+
得到 47 条。而 `scripts/browser-check.mjs` **自己也会加一组**:
|
|
7983
|
+
|
|
7984
|
+
```js
|
|
7985
|
+
parsed.info.narrow = n; // ← 第 14 组
|
|
7986
|
+
if (n.overflow) parsed.failures.push("at 375px …"); // ← 第 48、49 条断言
|
|
7987
|
+
```
|
|
7988
|
+
|
|
7989
|
+
只在 `--shots` 模式生效。所以:
|
|
7990
|
+
|
|
7991
|
+
| 模式 | 真实观测组 | 真实断言 | README 说 |
|
|
7992
|
+
|---|---|---|---|
|
|
7993
|
+
| 默认 | 13 | 47 | 13 / 47 ✓ |
|
|
7994
|
+
| `--shots` | **14** | **49** | 13 / 47 ✗ |
|
|
7995
|
+
|
|
7996
|
+
默认模式下 README 是**对的**——这也是它一直没被发现的原因:门禁和文档在同一个
|
|
7997
|
+
模式下都正确,只在换模式时一起错。
|
|
7998
|
+
|
|
7999
|
+
**这和 §13.44 是同一个病,只是隔了一个文件。** 那一轮我学到「数量对了清单可能
|
|
8000
|
+
错」;这一轮发现「数出来的数量本身可能只数了一半」。
|
|
8001
|
+
|
|
8002
|
+
#### 修法:让真相源覆盖第二个文件
|
|
8003
|
+
|
|
8004
|
+
`readme-numbers` 现在同时读 `scripts/browser-check.mjs`:
|
|
8005
|
+
|
|
8006
|
+
- 它的 `(parsed.)?info.X =` 里,不在 probe.js 的那些 → `extraGroups`
|
|
8007
|
+
- 它的 `(parsed.)?failures.push(` → `extraAssertions`
|
|
8008
|
+
|
|
8009
|
+
README 的 `--shots` 行改为:
|
|
8010
|
+
|
|
8011
|
+
```
|
|
8012
|
+
node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 2 条断言(375px 溢出,共 14 组)
|
|
8013
|
+
```
|
|
8014
|
+
|
|
8015
|
+
#### 修的时候又踩了一个自己的坑
|
|
8016
|
+
|
|
8017
|
+
加完匹配后门禁立刻红:
|
|
8018
|
+
|
|
8019
|
+
```
|
|
8020
|
+
✗ README.md:260 — assertions says 2, actual 47
|
|
8021
|
+
```
|
|
8022
|
+
|
|
8023
|
+
原因:新句子里的「2 条断言」被**通用规则** `(\d+) 条断言 → 47` 抓到了。**门禁错,
|
|
8024
|
+
文档对**——和 §13.37、§13.44 一个味道,第三次了。
|
|
8025
|
+
|
|
8026
|
+
修法不是把文档改得绕口,而是给规则**显式优先级**:具体规则(`--shots … 另加 N 组
|
|
8027
|
+
/ M 条`)先跑并**占位**它匹配到的字符区间,通用规则跳过落在已占位区间里的匹配。
|
|
8028
|
+
|
|
8029
|
+
```js
|
|
8030
|
+
const claimedSpans = [];
|
|
8031
|
+
const claimSpan = (m, kind, found, want) => { claimedSpans.push([m.index, …]); claim(…); };
|
|
8032
|
+
const isClaimed = (idx) => claimedSpans.some(([s, e]) => idx >= s && idx < e);
|
|
8033
|
+
```
|
|
8034
|
+
|
|
8035
|
+
这样以后再加任何「例外写法」都不会去改通用规则的正则——顺序即优先级。
|
|
8036
|
+
|
|
8037
|
+
#### 变异验证
|
|
8038
|
+
|
|
8039
|
+
| 变异 | 结果 |
|
|
8040
|
+
|---|---|
|
|
8041
|
+
| `--shots` 行「1 组」→「3 组」 | `extraGroups says 3, actual 1` |
|
|
8042
|
+
| `--shots` 行「2 条」→「5 条」 | `extraAssertions says 5, actual 2` |
|
|
8043
|
+
| 主断言「47」→「50」 | `assertions says 50, actual 47`(通用规则仍生效) |
|
|
8044
|
+
| 真给 browser-check 加一组 `info.probe2` | 两份 README 同时报 `extraGroups says 1, actual 2` |
|
|
8045
|
+
|
|
8046
|
+
第三个变异很重要:加优先级不能把通用规则打瘸。**具体规则占位,通用规则自净。**
|
|
8047
|
+
|
|
8048
|
+
#### 教训
|
|
8049
|
+
|
|
8050
|
+
1. **「从代码里数出来」不等于「从全部代码里数出来」。** 上一轮我把手写数字换成了
|
|
8051
|
+
自动统计,以为解决了腐化问题;实际上只是把错误从「人抄错」换成了「尺子量短了」。
|
|
8052
|
+
2. 正确性依赖**模式**时最危险:默认模式全对,切模式一起错。这类 bug 只有真的换
|
|
8053
|
+
个模式跑一次才会露。
|
|
8054
|
+
3. 门禁报错时优先怀疑门禁。这已经是第三次(§13.37、§13.44、本节),而且三次都是
|
|
8055
|
+
同一个形状:**具体写法被通用规则误伤**。这次终于把「规则优先级」变成了显式机制,
|
|
8056
|
+
而不是每次都去改正则躲。
|
|
8057
|
+
|
|
8058
|
+
|
|
8059
|
+
### 13.51 元数据已发布,tarball 却 404(2026-11-24)
|
|
8060
|
+
|
|
8061
|
+
#### 现象
|
|
8062
|
+
|
|
8063
|
+
`npm publish` 0.11.1 成功,`time` 字段写入,`versions` 里有 0.11.1,
|
|
8064
|
+
`dist-tags.latest` 指向 0.11.1。然后按自己 README 里那条命令装:
|
|
8065
|
+
|
|
8066
|
+
```
|
|
8067
|
+
dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.1
|
|
8068
|
+
× adding a new package
|
|
8069
|
+
╰─▶ Tarball server returned HTTP 404 for
|
|
8070
|
+
https://registry.npmjs.org/dsh-trajectory-traceview-plus/-/dsh-trajectory-traceview-plus-0.11.1.tgz
|
|
8071
|
+
```
|
|
8072
|
+
|
|
8073
|
+
**所有元数据检查都通过,实际安装失败。**
|
|
8074
|
+
|
|
8075
|
+
#### 这是「发布」的第 4 个外部环节
|
|
8076
|
+
|
|
8077
|
+
§13.47 记了 `npm publish` 是叶子步骤(漏了没报错);
|
|
8078
|
+
§13.48 记了 registry 写入后 CDN 有延迟(`versions` 会滞后);
|
|
8079
|
+
§13.49 记了包管理器可能出于安全策略不选新版本(`@latest` 静默退回)。
|
|
8080
|
+
|
|
8081
|
+
这次是**第 4 个**:metadata 与 tarball 是两条独立的分发路径。
|
|
8082
|
+
|
|
8083
|
+
| 检查方式 | 0.11.1 发布后 2 分钟内 |
|
|
8084
|
+
|---|---|
|
|
8085
|
+
| `npm view <pkg>@0.11.1 version` | ✓ `0.11.1` |
|
|
8086
|
+
| packument `versions` / `dist-tags` | ✓ 都对 |
|
|
8087
|
+
| packument `time["0.11.1"]` | ✓ 已写入 |
|
|
8088
|
+
| `dist.shasum` / `integrity` / `fileCount` | ✓ 都在 |
|
|
8089
|
+
| **`HEAD <dist.tarball>`** | **✗ HTTP 404** |
|
|
8090
|
+
| **`dsh plugin add <pkg>@0.11.1`** | **✗ 失败** |
|
|
8091
|
+
|
|
8092
|
+
而且 404 不是权限问题——加个 cache-buster 立刻 200:
|
|
8093
|
+
|
|
8094
|
+
```
|
|
8095
|
+
HEAD ...-0.11.1.tgz → 404
|
|
8096
|
+
HEAD ...-0.11.1.tgz?x=12345 → 200
|
|
8097
|
+
```
|
|
8098
|
+
|
|
8099
|
+
**是 CDN 把一个 404 缓存住了。** 也就是说:真实安装器命中的那个 URL 上有负缓存,
|
|
8100
|
+
而换一个 URL(带参数)就能拿到正确的字节(shasum 与 registry 声明一致)。
|
|
8101
|
+
|
|
8102
|
+
#### 为什么这个特别难想到
|
|
8103
|
+
|
|
8104
|
+
`npm view` 是这个生态里"检查是否发布成功"的标准姿势,我刚在 §13.48 里还教了
|
|
8105
|
+
用 `time` 字段确认。但 `npm view` **只读元数据,从不下载 tarball**——它对这个
|
|
8106
|
+
窗口完全失明。
|
|
8107
|
+
|
|
8108
|
+
**正确的判据是 HEAD 一次 `dist.tarball`**,而这一点只有真的去装一次才会暴露。
|
|
8109
|
+
这已经是这一轮第三次「只有真的装一次才知道」了(§13.47 npm 没发、§13.49
|
|
8110
|
+
`@latest` 静默降级、本节 tarball 404)。
|
|
8111
|
+
|
|
8112
|
+
#### 修法
|
|
8113
|
+
|
|
8114
|
+
`release-status.mjs` 的 npm 行拆成两个事实:
|
|
8115
|
+
|
|
8116
|
+
```js
|
|
8117
|
+
const published = npmView.ok && npmView.out.includes(version);
|
|
8118
|
+
// HEAD the tarball URL, NO cache-buster: a cache-buster would defeat the very cache
|
|
8119
|
+
// that is stale, hiding exactly the window a real installer falls into.
|
|
8120
|
+
const code = run('curl', ['-s', '-o', '/dev/null', '-w', '%{http_code}', '-I', url]).out;
|
|
8121
|
+
```
|
|
8122
|
+
|
|
8123
|
+
输出变成 `published (dist-tags.latest = 0.11.1), tarball downloads`。失败时
|
|
8124
|
+
**区分两种原因**,因为用户看到的都是"装不上":
|
|
8125
|
+
|
|
8126
|
+
- 元数据不在 → 「tagged but NOT on npm」
|
|
8127
|
+
- 元数据在、tarball 404 → 「in the packument but its tarball is not downloadable yet
|
|
8128
|
+
— `dsh plugin add` will fail with HTTP rather than install something wrong. Wait
|
|
8129
|
+
for the CDN」
|
|
8130
|
+
|
|
8131
|
+
第二条里那句「rather than install something wrong」是有意的:**这个失败模式是安全
|
|
8132
|
+
的**——装不上,而不是装错。负缓存比"装到错误版本"好得多。
|
|
8133
|
+
|
|
8134
|
+
#### 教训
|
|
8135
|
+
|
|
8136
|
+
1. **"已发布"至少是四件事**:git tag、GitHub Release、registry 元数据、
|
|
8137
|
+
**tarball 可下载**。前三个各有一个读者(git / 徽章 / `npm view`),第四个
|
|
8138
|
+
只有一个读者:真正要装包的人。
|
|
8139
|
+
2. 标准姿势失明。`npm view` 被当作发布成功的判据用了很多年,但它不下载字节。
|
|
8140
|
+
**凡是"检查"和"使用"走不同路径的,检查就可能看不见使用时的失败。**
|
|
8141
|
+
3. 负缓存 ≠ 数据缺失,但表现一样。区分它们需要绕过缓存(换 URL 参数),而不是
|
|
8142
|
+
重试。**重试同一个被缓存的 URL 永远不会好。**
|
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.2",
|
|
4
4
|
"description": "轨迹视图增强版(Plus):在「轨迹」标签旁新增可回放的横向时间轴——minimap、窗口内检索(显式标注覆盖边界)、回放、轮次跳转、跟随模式、历史分页、步骤/子调用耗时与吞吐、时钟轴切换、稳定锚点复制与深链、孤立工具结果站点、提示词变更对比、原始请求分析与 Markdown 导出。基于 AFAP/dsh-trajectory-traceview (MIT) 改造。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,18 +32,42 @@ const namedSteps = [...wf.matchAll(/^\s+- name: (.+)$/gm)].map((m) => m[1]);
|
|
|
32
32
|
const ciGates = namedSteps.filter((n) => n !== 'Install').length;
|
|
33
33
|
|
|
34
34
|
const pkg = JSON.parse(read('package.json'));
|
|
35
|
+
const version = String(pkg.version);
|
|
35
36
|
const localSteps = pkg.scripts.check.split('&&').map((s) => s.trim()).filter(Boolean).length;
|
|
36
37
|
|
|
37
38
|
const probe = read('test/browser/probe.js');
|
|
38
39
|
const observedGroups = new Set([...probe.matchAll(/info\.([a-zA-Z]\w*)\s*=/g)].map((m) => m[1]));
|
|
39
40
|
const assertions = [...probe.matchAll(/\bfail\(/g)].length;
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
// ── checks added OUTSIDE probe.js ────────────────────────────────────────────
|
|
43
|
+
//
|
|
44
|
+
// The counts above read probe.js only, so they were blind to everything
|
|
45
|
+
// scripts/browser-check.mjs adds itself: `parsed.info.narrow` (a group) and two
|
|
46
|
+
// `parsed.failures.push(...)` calls (assertions) in the `--shots` 375px probe.
|
|
47
|
+
// The script therefore printed "14 observation groups" in that mode while both
|
|
48
|
+
// READMEs said 13, and the gate stayed green — the same one-source-vs-two-sources
|
|
49
|
+
// blindness as §13.44, one file over.
|
|
50
|
+
//
|
|
51
|
+
// Both extra counts are gated, and the READMEs state them on the `--shots` line.
|
|
52
|
+
const browserCheck = read('scripts/browser-check.mjs');
|
|
53
|
+
const extraGroupNames = new Set(
|
|
54
|
+
[...browserCheck.matchAll(/(?:parsed\.)?info\.([a-zA-Z]\w*)\s*=/g)]
|
|
55
|
+
.map((m) => m[1])
|
|
56
|
+
.filter((n) => !observedGroups.has(n)),
|
|
57
|
+
);
|
|
58
|
+
const extraAssertions = [...browserCheck.matchAll(/(?:parsed\.)?failures\.push\(/g)].length;
|
|
59
|
+
|
|
60
|
+
const truth = {
|
|
61
|
+
ciGates, localSteps, groups: observedGroups.size, assertions,
|
|
62
|
+
extraGroups: extraGroupNames.size, extraAssertions,
|
|
63
|
+
};
|
|
42
64
|
|
|
43
65
|
if (process.argv.includes('--print')) {
|
|
44
66
|
console.log('CI 门禁 ' + ciGates + ' 项(workflow 具名步骤 ' + namedSteps.length + ' − Install)');
|
|
45
67
|
console.log('npm run check ' + localSteps + ' 步');
|
|
46
68
|
console.log('probe.js 观测组 ' + truth.groups + ' 个 / 断言 ' + assertions + ' 条');
|
|
69
|
+
console.log('browser-check 额外 ' + truth.extraGroups + ' 组 / ' + truth.extraAssertions + ' 条断言'
|
|
70
|
+
+ (extraGroupNames.size > 0 ? '(组:' + [...extraGroupNames].join(', ') + ')' : ''));
|
|
47
71
|
process.exit(0);
|
|
48
72
|
}
|
|
49
73
|
|
|
@@ -54,7 +78,7 @@ if (process.argv.includes('--print')) {
|
|
|
54
78
|
// it looked for `N 项` — the audit was wrong, not the document. Anchoring on the
|
|
55
79
|
// sentence is what made it correct.
|
|
56
80
|
const problems = [];
|
|
57
|
-
const counted = { ciGates: 0, localSteps: 0, groups: 0, assertions: 0 };
|
|
81
|
+
const counted = { ciGates: 0, localSteps: 0, groups: 0, assertions: 0, extraGroups: 0, extraAssertions: 0 };
|
|
58
82
|
|
|
59
83
|
const claim = (file, lineNo, kind, found, want) => {
|
|
60
84
|
counted[kind] += 1;
|
|
@@ -67,24 +91,45 @@ for (const file of ['README.md', 'README.en.md']) {
|
|
|
67
91
|
read(file).split('\n').forEach((line, i) => {
|
|
68
92
|
const at = i + 1;
|
|
69
93
|
|
|
94
|
+
// ── specific claims first, generic ones afterwards ────────────────────
|
|
95
|
+
//
|
|
96
|
+
// The `--shots` line says "另加 1 组 / 2 条断言(375px …,共 14 组)". The
|
|
97
|
+
// generic `(\d+) 条断言 -> 47` rule happily matched that "2" and reported
|
|
98
|
+
// `assertions says 2, actual 47` — the gate was wrong, not the document
|
|
99
|
+
// (§13.37, §13.44). So: a specific rule claims a span of the line, and the
|
|
100
|
+
// generic rules skip any match that starts inside a claimed span. Order and
|
|
101
|
+
// precedence are explicit instead of accidental.
|
|
102
|
+
const claimedSpans = [];
|
|
103
|
+
const claimSpan = (m, kind, found, want) => {
|
|
104
|
+
claimedSpans.push([m.index, m.index + m[0].length]);
|
|
105
|
+
claim(file, at, kind, found, want);
|
|
106
|
+
};
|
|
107
|
+
const isClaimed = (idx) => claimedSpans.some(([s, e]) => idx >= s && idx < e);
|
|
108
|
+
|
|
109
|
+
for (const m of line.matchAll(/--shots[^\n]{0,80}?另加\s*(\d+)\s*组/g)) claimSpan(m, 'extraGroups', Number(m[1]), truth.extraGroups);
|
|
110
|
+
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);
|
|
111
|
+
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);
|
|
112
|
+
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);
|
|
113
|
+
|
|
70
114
|
// "CI:7 项门禁" / "the seven gates" / "门禁本身是 7 项" / "those 7 gates"
|
|
71
|
-
for (const m of line.matchAll(/(\d+)\s*项门禁/g)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
|
|
72
|
-
for (const m of line.matchAll(/(\d+)\s*gates\b/g)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
|
|
73
|
-
for (const m of line.matchAll(/门禁(?:本身)?是\s*(\d+)\s*项/g)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
|
|
115
|
+
for (const m of line.matchAll(/(\d+)\s*项门禁/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
|
|
116
|
+
for (const m of line.matchAll(/(\d+)\s*gates\b/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
|
|
117
|
+
for (const m of line.matchAll(/门禁(?:本身)?是\s*(\d+)\s*项/g)) if (!isClaimed(m.index)) claim(file, at, 'ciGates', Number(m[1]), ciGates);
|
|
74
118
|
|
|
75
119
|
// "其中 6 步" / "6 of them"
|
|
76
120
|
for (const m of line.matchAll(/(\d+)\s*步/g)) {
|
|
121
|
+
if (isClaimed(m.index)) continue;
|
|
77
122
|
// "7 项门禁(…)" style lines also contain 步 sometimes; require the verb nearby.
|
|
78
123
|
if (!/跑|runs?|其中|of them/.test(line)) continue;
|
|
79
124
|
claim(file, at, 'localSteps', Number(m[1]), localSteps);
|
|
80
125
|
}
|
|
81
|
-
for (const m of line.matchAll(/(\d+)\s*of them/g)) claim(file, at, 'localSteps', Number(m[1]), localSteps);
|
|
126
|
+
for (const m of line.matchAll(/(\d+)\s*of them/g)) if (!isClaimed(m.index)) claim(file, at, 'localSteps', Number(m[1]), localSteps);
|
|
82
127
|
|
|
83
128
|
// "跑 47 条断言 / 记录 13 组观测" and its English twin
|
|
84
|
-
for (const m of line.matchAll(/(\d+)\s*条断言/g)) claim(file, at, 'assertions', Number(m[1]), assertions);
|
|
85
|
-
for (const m of line.matchAll(/(\d+)\s*assertions?/g)) claim(file, at, 'assertions', Number(m[1]), assertions);
|
|
86
|
-
for (const m of line.matchAll(/(\d+)\s*组观测/g)) claim(file, at, 'groups', Number(m[1]), truth.groups);
|
|
87
|
-
for (const m of line.matchAll(/(\d+)\s*recorded groups/g)) claim(file, at, 'groups', Number(m[1]), truth.groups);
|
|
129
|
+
for (const m of line.matchAll(/(\d+)\s*条断言/g)) if (!isClaimed(m.index)) claim(file, at, 'assertions', Number(m[1]), assertions);
|
|
130
|
+
for (const m of line.matchAll(/(\d+)\s*assertions?/g)) if (!isClaimed(m.index)) claim(file, at, 'assertions', Number(m[1]), assertions);
|
|
131
|
+
for (const m of line.matchAll(/(\d+)\s*组观测/g)) if (!isClaimed(m.index)) claim(file, at, 'groups', Number(m[1]), truth.groups);
|
|
132
|
+
for (const m of line.matchAll(/(\d+)\s*recorded groups/g)) if (!isClaimed(m.index)) claim(file, at, 'groups', Number(m[1]), truth.groups);
|
|
88
133
|
});
|
|
89
134
|
}
|
|
90
135
|
|
|
@@ -139,16 +184,41 @@ for (const file of ['README.md', 'README.en.md']) {
|
|
|
139
184
|
}
|
|
140
185
|
}
|
|
141
186
|
|
|
187
|
+
// ── the version written into the install commands ────────────────────────────
|
|
188
|
+
//
|
|
189
|
+
// The README now teaches an exact pin (`…@0.11.1`) and a tag-pinned GitHub spec
|
|
190
|
+
// (`github:…#v0.11.1`), because `@latest` is unreliable here (pnpm's release-age
|
|
191
|
+
// policy) and an unpinned `github:` follows the branch HEAD (§13.49). That makes the
|
|
192
|
+
// version appear in the place a user copies FIRST — and it silently goes stale on the
|
|
193
|
+
// next release. So gate it: every `dsh-trajectory-traceview-plus@X.Y.Z` and every
|
|
194
|
+
// `#vX.Y.Z` in the READMEs must equal package.json's version.
|
|
195
|
+
//
|
|
196
|
+
// Deliberately only these two shapes: prose that mentions an older version on
|
|
197
|
+
// purpose ("0.11.0 shipped a wrong README") must stay writable.
|
|
198
|
+
let versionRefs = 0;
|
|
199
|
+
for (const file of ['README.md', 'README.en.md']) {
|
|
200
|
+
read(file).split('\n').forEach((line, i) => {
|
|
201
|
+
for (const m of line.matchAll(/dsh-trajectory-traceview-plus@(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/g)) {
|
|
202
|
+
versionRefs += 1;
|
|
203
|
+
if (m[1] !== version) problems.push(file + ':' + (i + 1) + ' — install command pins ' + m[1] + ', package.json says ' + version);
|
|
204
|
+
}
|
|
205
|
+
for (const m of line.matchAll(/#v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/g)) {
|
|
206
|
+
versionRefs += 1;
|
|
207
|
+
if (m[1] !== version) problems.push(file + ':' + (i + 1) + ' — tag spec pins v' + m[1] + ', package.json says ' + version);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
142
212
|
const total = Object.values(counted).reduce((a, b) => a + b, 0);
|
|
143
|
-
if (total === 0 || listChecked === 0) {
|
|
213
|
+
if (total === 0 || listChecked === 0 || versionRefs === 0) {
|
|
144
214
|
// A gate that matches nothing is worse than no gate: it reports success forever.
|
|
145
215
|
console.error('readme-numbers: found NO claim to check (numbers ' + total + ', `npm run check` lines '
|
|
146
|
-
+ listChecked + ') — the patterns have drifted from the prose');
|
|
216
|
+
+ listChecked + ', version refs ' + versionRefs + ') — the patterns have drifted from the prose');
|
|
147
217
|
process.exit(1);
|
|
148
218
|
}
|
|
149
219
|
|
|
150
220
|
console.log('readme-numbers: 核对 ' + total + ' 处数字(门禁 ' + ciGates + ' / 本地 ' + localSteps
|
|
151
|
-
+ ' / 观测组 ' + truth.groups + ' / 断言 ' + assertions + '
|
|
221
|
+
+ ' / 观测组 ' + truth.groups + ' / 断言 ' + assertions + ')+ ' + versionRefs + ' 处版本引用');
|
|
152
222
|
if (problems.length > 0) {
|
|
153
223
|
for (const p of problems) console.error(' ✗ ' + p);
|
|
154
224
|
console.error('readme-numbers: FAIL (' + problems.length + ' 处不一致)');
|
|
@@ -43,16 +43,56 @@ const run = (cmd, args) => {
|
|
|
43
43
|
const rows = [];
|
|
44
44
|
|
|
45
45
|
// 1. git tag — local truth, no network.
|
|
46
|
+
//
|
|
47
|
+
// The row asks ONE question: does `v<version>` exist? It deliberately does NOT ask
|
|
48
|
+
// "is HEAD exactly at that tag", which is the wrong question and was the original
|
|
49
|
+
// bug here: any repository that keeps working after a release has HEAD past the
|
|
50
|
+
// last tag, so that condition is false ~always. Reporting it as a ●/○ turned a
|
|
51
|
+
// permanent, normal state into a yellow light that could never clear — exactly the
|
|
52
|
+
// kind of noise that trains people to stop reading the output.
|
|
53
|
+
//
|
|
54
|
+
// What actually matters before a publish is whether the tree you would ship equals
|
|
55
|
+
// the tree the tag points at, so that gets its own row (2), with the file list when
|
|
56
|
+
// they differ.
|
|
46
57
|
const tag = run('git', ['tag', '--list', 'v' + version]);
|
|
58
|
+
const hasTag = tag.out.split('\n').filter(Boolean).includes('v' + version);
|
|
47
59
|
const headTagged = run('git', ['describe', '--tags', '--exact-match', 'HEAD']);
|
|
48
60
|
rows.push({
|
|
49
61
|
place: 'git tag',
|
|
50
|
-
present:
|
|
51
|
-
detail:
|
|
62
|
+
present: hasTag,
|
|
63
|
+
detail: hasTag
|
|
64
|
+
? 'v' + version + ' exists' + (headTagged.ok ? ' (and HEAD is exactly on it)' : ' (HEAD has moved past it, which is normal)')
|
|
65
|
+
: 'missing — nothing in git claims this version',
|
|
52
66
|
missing: 'git tag -a v' + version + ' -m "…" && git push origin v' + version,
|
|
53
67
|
});
|
|
54
68
|
|
|
55
|
-
// 2.
|
|
69
|
+
// 2. shipped tree vs tagged tree — only meaningful with a tag, and only for what
|
|
70
|
+
// actually ships at runtime. Documentation and scripts after the tag are fine;
|
|
71
|
+
// a different `lib/` after the tag means the tarball and the tag disagree.
|
|
72
|
+
const RUNTIME = ['lib', 'package.json', 'cordis.patch.yml'];
|
|
73
|
+
let drift = null;
|
|
74
|
+
if (hasTag) {
|
|
75
|
+
// `v<version>` against the WORKING TREE, not `v<version>..HEAD`: the dangerous case is an
|
|
76
|
+
// uncommitted edit to lib/ right before publishing, and a commit-range diff cannot see it.
|
|
77
|
+
// (Caught here: appending one line to lib/client.js sailed through and reported all green.)
|
|
78
|
+
const diff = run('git', ['diff', '--name-only', 'v' + version, '--', ...RUNTIME]);
|
|
79
|
+
const files = diff.out.split('\n').map((s) => s.trim()).filter(Boolean);
|
|
80
|
+
drift = files;
|
|
81
|
+
rows.push({
|
|
82
|
+
place: 'tag = shipped',
|
|
83
|
+
present: diff.ok && files.length === 0,
|
|
84
|
+
detail: !diff.ok
|
|
85
|
+
? 'could not compare (is this a git checkout with tag v' + version + '?)'
|
|
86
|
+
: files.length === 0
|
|
87
|
+
? 'runtime files identical to v' + version + ' (docs/scripts moved on, that is fine)'
|
|
88
|
+
: 'runtime files CHANGED after the tag: ' + files.slice(0, 4).join(', ') + (files.length > 4 ? ' …' : ''),
|
|
89
|
+
missing: files && files.length > 0
|
|
90
|
+
? 'publishing now would ship a tree the tag does not describe — bump the version and retag'
|
|
91
|
+
: '',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 3. GitHub Release — what the repo-page badge reads. No gh? Then say so, don't guess.
|
|
56
96
|
const gh = run('gh', ['api', 'repos/' + (run('git', ['remote', 'get-url', 'origin']).out.match(/github\.com[:/]([^/]+\/[^/.]+)/) ?? [])[1] + '/releases/tags/v' + version]);
|
|
57
97
|
rows.push({
|
|
58
98
|
place: 'GitHub Release',
|
|
@@ -61,16 +101,35 @@ rows.push({
|
|
|
61
101
|
missing: 'gh release create v' + version + ' --notes-file …',
|
|
62
102
|
});
|
|
63
103
|
|
|
64
|
-
//
|
|
104
|
+
// 4. npm registry — what `npm i <name>@latest` installs.
|
|
105
|
+
//
|
|
106
|
+
// Two separate facts, because they failed separately: the VERSION being present in
|
|
107
|
+
// the packument (metadata) and the TARBALL being downloadable (bytes). Right after
|
|
108
|
+
// 0.11.1's publish, `versions` and `dist-tags.latest` both said 0.11.1 while
|
|
109
|
+
// `…/dsh-trajectory-traceview-plus-0.11.1.tgz` returned HTTP 404 for ~2 minutes —
|
|
110
|
+
// so `dsh plugin add pkg@0.11.1` failed with "Tarball server returned HTTP 404"
|
|
111
|
+
// while every metadata check looked perfect. `npm view <pkg>@<v> version` cannot
|
|
112
|
+
// see that; only fetching the URL can.
|
|
65
113
|
const npmView = run('npm', ['view', name + '@' + version, 'version']);
|
|
66
114
|
const latest = run('npm', ['view', name, 'dist-tags.latest']);
|
|
115
|
+
const published = npmView.ok && npmView.out.includes(version);
|
|
116
|
+
let tarballState = 'not checked';
|
|
117
|
+
if (published) {
|
|
118
|
+
const url = run('npm', ['view', name + '@' + version, 'dist.tarball']).out;
|
|
119
|
+
// HEAD, no cache-buster: a cache-buster would defeat the very cache that is stale,
|
|
120
|
+
// hiding exactly the window a real installer would fall into.
|
|
121
|
+
const code = run('curl', ['-s', '-o', '/dev/null', '-w', '%{http_code}', '-I', url]).out;
|
|
122
|
+
tarballState = code === '200' ? 'tarball downloads' : 'tarball URL returns HTTP ' + code + ' (metadata is live, bytes are not)';
|
|
123
|
+
}
|
|
67
124
|
rows.push({
|
|
68
125
|
place: 'npm registry',
|
|
69
|
-
present:
|
|
70
|
-
detail:
|
|
71
|
-
? '
|
|
72
|
-
: '
|
|
73
|
-
missing: '
|
|
126
|
+
present: published && tarballState === 'tarball downloads',
|
|
127
|
+
detail: !published
|
|
128
|
+
? 'MISSING — `npm i ' + name + '@latest` still installs ' + (latest.ok ? latest.out : '(unknown)')
|
|
129
|
+
: 'published' + (latest.ok ? ' (dist-tags.latest = ' + latest.out + ')' : '') + ', ' + tarballState,
|
|
130
|
+
missing: published && tarballState !== 'tarball downloads'
|
|
131
|
+
? 'wait for the CDN (a few minutes) then re-check; `npm view` is not enough'
|
|
132
|
+
: 'npm publish',
|
|
74
133
|
});
|
|
75
134
|
|
|
76
135
|
const pad = (s, n) => s + ' '.repeat(Math.max(0, n - [...s].length));
|
|
@@ -79,10 +138,15 @@ for (const r of rows) console.log(' ' + (r.present ? '●' : '○') + ' ' + pad
|
|
|
79
138
|
const absent = rows.filter((r) => !r.present);
|
|
80
139
|
if (absent.length > 0) {
|
|
81
140
|
console.log('\nmissing from ' + absent.length + ' place(s):');
|
|
82
|
-
for (const r of absent) console.log(' ' + r.place + ': ' + r.missing);
|
|
141
|
+
for (const r of absent) if (r.missing) console.log(' ' + r.place + ': ' + r.missing);
|
|
83
142
|
}
|
|
84
143
|
if (absent.some((r) => r.place === 'npm registry')) {
|
|
85
|
-
|
|
144
|
+
// Two very different causes read the same to a user ("install fails"), so the
|
|
145
|
+
// message has to name which one it is.
|
|
146
|
+
const msg = !published
|
|
147
|
+
? 'release-status: ' + version + ' is tagged but NOT on npm — anyone installing by package name gets the old version'
|
|
148
|
+
: 'release-status: ' + version + ' is in the npm packument but its tarball is not downloadable yet — `dsh plugin add` will fail with HTTP ' +
|
|
149
|
+
'rather than install something wrong. Wait for the CDN, then re-run.';
|
|
86
150
|
if (WARN_ONLY) console.log('\n' + msg + ' (warn only)');
|
|
87
151
|
else {
|
|
88
152
|
console.error('\n' + msg);
|