dsh-cabinet-mode 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.1.6] - 2026-11-03
6
+
7
+ ### Fixed
8
+
9
+ - **The rollback guard reads a fresh baseline.** It now requests the published
10
+ index with a one-shot `?t=` cache-buster; without it, a five-minute-stale
11
+ `raw.githubusercontent.com` copy could let a lagging registry shrink the index.
12
+ (Dalisi verification §13, D-12.)
13
+ - **A missing published index is no longer confused with an unreadable one.** Only a
14
+ `404`/`ENOENT` is treated as "first release, nothing to protect"; any other read
15
+ or parse failure aborts the refresh instead of silently skipping the guard, unless
16
+ `MARKET_ALLOW_SHRINK=1` is set. (Dalisi verification §13, D-13.)
17
+ - `--check` reads the published index through the same cache-buster, so a stale CDN
18
+ copy can no longer fake a match or a mismatch.
19
+
20
+ These fixes ship in `0.1.6`; `0.1.5`'s tarball still contains the earlier script.
21
+ They only affect the maintainer-side index refresh, not installing the bundle.
22
+
5
23
  ## [0.1.5] - 2026-11-03
6
24
 
7
25
  ### Fixed
package/README.md CHANGED
@@ -61,7 +61,7 @@ If any step fails, show the exact error and stop. Do not retry more than once.
61
61
  ## Manual install (3 lines)
62
62
 
63
63
  ```sh
64
- dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.5/dsh-cabinet-mode-0.1.5.tgz
64
+ dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.6/dsh-cabinet-mode-0.1.6.tgz
65
65
  # fully quit and restart DeepSeek Harness
66
66
  # New session -> mode picker -> 内阁模式
67
67
  ```
@@ -85,7 +85,7 @@ commands work on Linux and macOS.
85
85
  > `dsh-cabinet-mode` in `dsh.profile.bundles`):
86
86
  >
87
87
  > ```sh
88
- > node "<DeepSeek Harness install>\resources\runtime\primary-runtime\dependencies\pnpm\bin\pnpm.mjs" --dir "%USERPROFILE%\.dsh\profiles\desktop" add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.5/dsh-cabinet-mode-0.1.5.tgz
88
+ > node "<DeepSeek Harness install>\resources\runtime\primary-runtime\dependencies\pnpm\bin\pnpm.mjs" --dir "%USERPROFILE%\.dsh\profiles\desktop" add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.6/dsh-cabinet-mode-0.1.6.tgz
89
89
  > ```
90
90
  >
91
91
  > Back up the profile's `package.json` / `pnpm-lock.yaml` first.
@@ -125,18 +125,16 @@ The index is regenerated from the npm registry after every tagged release and on
125
125
  lists published, non-deprecated stable versions; do not edit the `market-index`
126
126
  branch by hand.
127
127
 
128
- > **Release status (2026-11-03):** `dsh-cabinet-mode@0.1.4` is published on
129
- > `registry.npmjs.org` — the first release, published by the tag-triggered OIDC
130
- > workflow with a provenance attestation on sigstore — and the `market-index`
131
- > branch has been generated from it. The registry also carries a placeholder
132
- > `0.0.0-stage` prerelease, which the index intentionally does not list. The first
133
- > OIDC publish, the GitHub Release, the `market-index` branch, parsing the generated
134
- > index, and installing from the npm spec have all been exercised while handling
135
- > this release.
128
+ > **Release status (2026-11-03):** `dsh-cabinet-mode@0.1.4` and `0.1.5` are published
129
+ > on `registry.npmjs.org` by the tag-triggered OIDC workflow, each with a provenance
130
+ > attestation on sigstore, and the `market-index` branch is refreshed automatically
131
+ > after every publish. The v0.1.5 run of tag → publish → GitHub Release → index
132
+ > refresh succeeded end to end (GitHub Actions run 41657224370), and the index now
133
+ > lists 0.1.5 and 0.1.4. The registry also carries a placeholder `0.0.0-stage`
134
+ > prerelease, which the index intentionally does not list.
136
135
  >
137
136
  > **Not verified:** the exact plugin-market UI labels and click path in your DSH
138
- > build, a real install/update in that GUI, and the full tag → publish → automatic
139
- > index refresh chain; 0.1.5 is the first run of that chain. The
137
+ > build, and a real install/update in that GUI. The
140
138
  > `dsh-cabinet-mode@<version>` install spec is what the format-1 reader
141
139
  > (`@deepseek-ai/dsh-plugin-market-index@0.2.1-rc.5`, `marketInstallTarget`) returns
142
140
  > for an npm source; that function was executed locally, the UI was not.
@@ -150,7 +148,7 @@ the same install command with the new version URL (or pick the new `.tgz` in the
150
148
  plugin page), then fully quit and restart DeepSeek Harness:
151
149
 
152
150
  ```sh
153
- dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.5/dsh-cabinet-mode-0.1.5.tgz
151
+ dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.6/dsh-cabinet-mode-0.1.6.tgz
154
152
  ```
155
153
 
156
154
  `dsh plugin --profile desktop list` should report the new version. Upgrades were
@@ -318,9 +316,9 @@ long-lived npm token — creates the GitHub Release, and then refreshes the
318
316
  `market-index` branch that the plugin market reads.
319
317
 
320
318
  ```sh
321
- # package.json version and the matching CHANGELOG section must both be 0.1.5
322
- git tag v0.1.5
323
- git push origin v0.1.5
319
+ # package.json version and the matching CHANGELOG section must both be 0.1.6
320
+ git tag v0.1.6
321
+ git push origin v0.1.6
324
322
  ```
325
323
 
326
324
  One-time setup on npmjs.com (a maintainer action; it cannot be done from this
@@ -383,11 +381,11 @@ These were **not** tested on this machine and must not be presented as verified:
383
381
  - Whether `config.id` syntax rules reject unusual ids (this id is `cabinet`).
384
382
  - HMR behavior for preset declarations, and private-registry/proxied tarball
385
383
  installs.
386
- - **The plugin market in real use.** The npm publish, the GitHub Release, the
387
- `market-index` branch, parsing the index and installing from the npm spec were
388
- exercised for 0.1.4 (2026-11-03), but no real install or update has been performed
389
- in the DSH plugin-market GUI, and 0.1.5 is the first run of the whole
390
- tag → publish → automatic index refresh chain.
384
+ - **The plugin market in real use.** Parsing the published index, resolving the npm
385
+ install spec and installing `dsh-cabinet-mode@0.1.5` into a throwaway profile were
386
+ exercised locally, and the full tag → publish → automatic index refresh chain runs
387
+ in CI (v0.1.5, run 41657224370), but no install or update has been performed in
388
+ the DSH plugin-market GUI itself.
391
389
 
392
390
  ## Known limitations
393
391
 
package/README.zh.md CHANGED
@@ -49,7 +49,7 @@
49
49
  ## 手动安装(3 行)
50
50
 
51
51
  ```sh
52
- dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.5/dsh-cabinet-mode-0.1.5.tgz
52
+ dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.6/dsh-cabinet-mode-0.1.6.tgz
53
53
  # 完全退出并重启 DeepSeek Harness
54
54
  # 新建任务 -> 模式选择器 -> 内阁模式
55
55
  ```
@@ -70,7 +70,7 @@ dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/re
70
70
  > `dsh.profile.bundles` 里保留了 `dsh-cabinet-mode`:
71
71
  >
72
72
  > ```sh
73
- > node "<DeepSeek Harness 安装目录>\resources\runtime\primary-runtime\dependencies\pnpm\bin\pnpm.mjs" --dir "%USERPROFILE%\.dsh\profiles\desktop" add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.5/dsh-cabinet-mode-0.1.5.tgz
73
+ > node "<DeepSeek Harness 安装目录>\resources\runtime\primary-runtime\dependencies\pnpm\bin\pnpm.mjs" --dir "%USERPROFILE%\.dsh\profiles\desktop" add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.6/dsh-cabinet-mode-0.1.6.tgz
74
74
  > ```
75
75
  >
76
76
  > 操作前先备份该 profile 的 `package.json` / `pnpm-lock.yaml`。
@@ -92,16 +92,16 @@ https://raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketp
92
92
 
93
93
  索引在每次 tag 发布后由 npm registry 重新生成,只列出已发布、未弃用的稳定版本;不要手工编辑 `market-index` 分支。
94
94
 
95
- > **发布状态(2026-11-03):** `dsh-cabinet-mode@0.1.4` 已发布到 `registry.npmjs.org`——首版,由 tag 触发的 OIDC 流程发布,provenance 已上 sigstore——并且 `market-index` 分支已由它生成。registry 上另有占位版本 `0.0.0-stage`(预发布,索引不列)。首次 OIDC 发布、GitHub Release、`market-index` 分支、索引解析、按 npm spec 安装这五项已在处置本次发布时实测。
95
+ > **发布状态(2026-11-03):** `dsh-cabinet-mode@0.1.4` 与 `0.1.5` 已由 tag 触发的 OIDC 流程发布到 `registry.npmjs.org`,两者都带 sigstore provenance;`market-index` 分支在每次发布后自动刷新。v0.1.5 的 tag → 发布 → GitHub Release → 刷新索引全链路已端到端成功(GitHub Actions run 41657224370),索引现列出 0.1.5 与 0.1.4。registry 上另有占位版本 `0.0.0-stage`(预发布,索引不列)。
96
96
  >
97
- > **未验证:** 你所用 DSH 版本的插件市场界面文案与点击路径、该 GUI 里的真实安装/更新,以及 tag → 发布 → 自动刷新索引的全链路;0.1.5 是该链路第一次完整运行。上面的 `dsh-cabinet-mode@<版本>` 安装 spec 是格式 1 读取器(`@deepseek-ai/dsh-plugin-market-index@0.2.1-rc.5` 的 `marketInstallTarget`)对 npm 源返回的结果;该函数已在本机执行,界面未实测。
97
+ > **未验证:** 你所用 DSH 版本的插件市场界面文案与点击路径,以及该 GUI 里的真实安装/更新。上面的 `dsh-cabinet-mode@<版本>` 安装 spec 是格式 1 读取器(`@deepseek-ai/dsh-plugin-market-index@0.2.1-rc.5` 的 `marketInstallTarget`)对 npm 源返回的结果;该函数已在本机执行,界面未实测。
98
98
 
99
99
  ## 升级
100
100
 
101
101
  若通过插件市场安装:刷新市场,先在**已安装**页卸载旧版本,再从**插件市场**安装新版本,然后重启——没有 tgz URL 要换,也没有一键更新。否则用同一条安装命令换新版本 URL(或在插件页选新 `.tgz`),然后完全退出并重启 DeepSeek Harness:
102
102
 
103
103
  ```sh
104
- dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.5/dsh-cabinet-mode-0.1.5.tgz
104
+ dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.1.6/dsh-cabinet-mode-0.1.6.tgz
105
105
  ```
106
106
 
107
107
  `dsh plugin --profile desktop list` 应显示新版本。升级已在 Windows 实测:
@@ -204,9 +204,9 @@ node scripts/verify.mjs # 仓库校验 + dsh 合成
204
204
  推送版本 tag 会触发 `.github/workflows/release.yml`:校验工作树 → 打包 tarball → 用 **Trusted Publishing(OIDC)** 发布到 npm(不使用长期 npm token)→ 创建 GitHub Release → 刷新插件市场读取的 `market-index` 分支。
205
205
 
206
206
  ```sh
207
- # package.json 版本与 CHANGELOG 对应章节都必须是 0.1.5
208
- git tag v0.1.5
209
- git push origin v0.1.5
207
+ # package.json 版本与 CHANGELOG 对应章节都必须是 0.1.6
208
+ git tag v0.1.6
209
+ git push origin v0.1.6
210
210
  ```
211
211
 
212
212
  npmjs.com 侧的一次性配置(维护者在网页上完成,无法从本仓库完成)。为该包添加 GitHub Actions trusted publisher:
@@ -239,7 +239,7 @@ npmjs.com 侧的一次性配置(维护者在网页上完成,无法从本仓
239
239
  - DSH 升级后已装 bundle 或回退 patch 是否保留。
240
240
  - `config.id` 语法校验规则(本 id 为 `cabinet`,仅小写字母)。
241
241
  - preset 声明的 HMR 热生效、私有源/代理下的 tgz 安装。
242
- - **插件市场的真实使用。** npm 发布、GitHub Release、`market-index` 分支、索引解析、按 npm spec 安装这五项已在 0.1.4(2026-11-03)处置过程中实测;但 DSH 插件市场 GUI 里的真实安装/更新未执行,tag → 发布 → 自动刷新索引的完整链路以 0.1.5 为首次运行。
242
+ - **插件市场的真实使用。** 索引解析、npm 安装 spec 解析、把 `dsh-cabinet-mode@0.1.5` 装进一次性 profile 都已在本机执行;tag → 发布 → 自动刷新索引全链路已在 CI 跑通(v0.1.5,run 41657224370);但 DSH 插件市场 GUI 里的真实安装/更新仍未执行。
243
243
 
244
244
  ## 已知限制
245
245
 
@@ -20,7 +20,7 @@
20
20
  | 10 | 安装后生效 | 重启 Host → 新会话可选 | 同 | 同 | `P/dsh-plugin-manager/README.zh.md:14,73`;`P/dsh-plugin-manager/lib/index.js:2381` | Windows 已实测真实 `add`(2026-10-29,本地目录与 Release 资产 URL;`dsh plugin --profile desktop list` = 3 packages、bundles 写入);重启后新会话出现模式未实测,后段代码级 |
21
21
  | 11 | 是否需要 postinstall / build | 否(纯 YAML) | 否 | 否 | `P/dsh-plugin-manager/lib/types/build-approval.js:1,7-10`;README.zh:64 | 代码级 |
22
22
  | 12 | GitHub Release `.tgz` 直接安装 | 实测可用(Release 资产 URL 直装,2026-10-29) | 同 | 同 | `P/dsh-plugin-manager/lib/types/install-spec.js:16-17,62-76`;`pnpm add <tarball url>`(本机 `dsh plugin ... add --help` 实跑输出含 `<tarball url>`) | Windows 实测 + pnpm 帮助实测;Linux/macOS 代码级 |
23
- | 13 | npm 发布与插件市场索引 | `release.yml` 走 OIDC Trusted Publishing(v0.1.4 已实跑) | 同 | 同 | `.github/workflows/release.yml`、`scripts/market-index.mjs`;npm 官方文档 Trusted publishing;`@deepseek-ai/dsh-plugin-market-index@0.2.1-rc.5` `lib/index.js:32-36,209-225,280-318` | v0.1.4 OIDC 发布、GitHub Release 与 `market-index` 分支已实跑;首个索引 job 因传播延迟失败,0.1.5 验证自动刷新链路 |
23
+ | 13 | npm 发布与插件市场索引 | `release.yml` 走 OIDC Trusted Publishing(v0.1.4/v0.1.5 已实跑) | 同 | 同 | `.github/workflows/release.yml`、`scripts/market-index.mjs`;npm 官方文档 Trusted publishing;`@deepseek-ai/dsh-plugin-market-index@0.2.1-rc.5` `lib/index.js:32-36,209-225,280-318` | v0.1.4 OIDC 发布、GitHub Release 与 `market-index` 分支已实跑;v0.1.5 的全链路(tag → 发布 → 自动刷新索引)已成功(run 41657224370) |
24
24
 
25
25
  > 附加(不属于平台列):本包不声明 DSH 版本门禁(`package.json` 无 `engines.dsh`/DSH `peerDependencies`,`scripts/verify.mjs` 版本检查仅信息性 WARN);本文所有结论以 DSH 0.2.1-rc.3 实测为参照,其他 DSH 版本若内置插件集合不同,需按该版本 `presets/standard.patch.yml` 调整插件行——**未做多版本实测**。
26
26
 
@@ -128,7 +128,7 @@ async function runDesktopCli(runtimeDir, supportDir) {
128
128
  - bundle 身份:`dsh.bundle.patch` 指向 `cordis.patch.yml`(字符串或有序数组)。这是插件管理器识别「组合包层」的充要字段(`P/dsh-plugin-manager/lib/index.js:313,335-337`);缺它只会被当作普通依赖安装。
129
129
  - `files` 必须包含 `cordis.patch.yml`(npm 打包白名单)。
130
130
  - 兼容性:若要声明版本门,优先只写 `engines.dsh`(单一声明即决定,`P/dsh-app-boot/lib/index.js:280-284`);**不要**逐个声明 `@deepseek-ai/dsh-*` 的 `peerDependencies` 精确版本——否则会被逐包校验(`:286-304`),跨平台/跨补丁版本容易误判(本机已见 rc.2 插件在 rc.3 被警告的先例)。**本仓库的既定产品决定是不声明 `engines.dsh`(0.1.1 起),索引条目因此不写 `engines`**;这不影响 format 1 合法性。
131
- - **现状对照(本仓库 `package.json`)**:`name`/`version`(0.1.5)/`private: false`/`files` 含 `cordis.patch.yml`/`dsh.bundle.patch`/`repository`(`git+https://github.com/luodaoyi/dsh-cabinet-mode.git`,无 query/fragment,匹配 trusted publisher 的仓库)均在;未声明 `peerDependencies` 与 `engines.dsh`,因此 DSH 兼容性判定不触发(`P/dsh-app-boot/lib/index.js:280-304`);未声明 `os`/`cpu`。发布链路已由 `v0.1.4` 实跑成功(首个 market-index job 的传播延迟失败已在 0.1.5 修复)。
131
+ - **现状对照(本仓库 `package.json`)**:`name`/`version`(0.1.6)/`private: false`/`files` 含 `cordis.patch.yml`/`dsh.bundle.patch`/`repository`(`git+https://github.com/luodaoyi/dsh-cabinet-mode.git`,无 query/fragment,匹配 trusted publisher 的仓库)均在;未声明 `peerDependencies` 与 `engines.dsh`,因此 DSH 兼容性判定不触发(`P/dsh-app-boot/lib/index.js:280-304`);未声明 `os`/`cpu`。发布链路已由 `v0.1.4` 实跑成功(首个 market-index job 的传播延迟失败已在 0.1.5 修复)。
132
132
  - 不要声明 `os`/`cpu` 限制字段;纯 YAML 无平台二进制。
133
133
  - 可选元数据:`description`、`icon`(相对路径,须位于包内,`P/dsh-app-boot/lib/index.js:2074-2097`)、`locale/*.json`(`P/dsh-app-boot/lib/index.js:574` 附近)。
134
134
  - **桌面端**:`dsh plugin --profile desktop add` 在 Desktop 载体下可用(Windows 实测 `list`、`add --help` exit 0;`P/dsh-desktop-host/lib/cli.js:97` 的 `manageDesktopProfile: true` 是放行来源)。Windows 已实测本地目录与 Release 资产 URL 两种真实安装(2026-10-29,`dsh plugin --profile desktop list` = 3 packages);重启后新会话出现内阁模式仍未实测。
@@ -152,7 +152,7 @@ async function runDesktopCli(runtimeDir, supportDir) {
152
152
  4. ~~GitHub Release `.tgz` URL 的真实安装~~ → **Windows 已实测**(Release 资产 URL 直装成功,2026-10-29);Linux/macOS 未实测。
153
153
  5. ~~真实 `dsh plugin --profile desktop add <bundle>` 安装~~ → **Windows 已实测**(本地目录与 Release URL 两种方式,`list` = 3 packages、bundles 写入,2026-10-29);重启后新会话出现内阁模式仍未实测。
154
154
  6. Linux / macOS 上对 `<本仓库 cordis.patch.yml>` 执行 `dsh --profile web --patch ... --dump-config` 的组合校验(Windows 已实跑 exit 0)。
155
- 7. ~~npm Trusted Publishing 首次发布、`market-index` 分支发布~~ → **2026-11-03 已实跑**(v0.1.4 OIDC 发布成功、GitHub Release 与 `market-index` 分支已生成;首个索引 job 因传播延迟失败,0.1.5 修复)。仍未实跑:DSH 插件市场 GUI 里的真实安装/更新,以及 tag → npm 发布 → 自动刷新索引的全链路(0.1.5 首发验证)。`dsh-cabinet-mode@<version>` 安装 spec 仅由本机执行格式读取器核对。
155
+ 7. ~~npm Trusted Publishing 首次发布、`market-index` 分支发布、tag → npm 发布 → 自动刷新索引全链路~~ → **2026-11-03 已实跑**(v0.1.4 OIDC 发布成功;v0.1.5 全链路成功,run 41657224370,索引 job 等到 registry 出现目标版本后强推分支)。仍未实跑:DSH 插件市场 GUI 里的真实安装/更新。`dsh-cabinet-mode@<version>` 安装 spec 由本机执行格式读取器核对,并按该 spec 把 0.1.5 装进一次性 profile 验证过。
156
156
  8. HMR 开启时 preset 声明的热生效(仅代码级阅读 README 与注册表语义,未实跑)。
157
157
  9. 私有仓库/代理/认证下的 tgz 安装。
158
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cabinet-mode",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Cabinet Mode (内阁模式) for DeepSeek Harness: a declarative DSH bundle that adds a dual-identity Lead/teammate agent preset for the Great Ming Research Bureau cabinet team.",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.svg",
@@ -100,18 +100,34 @@ function readLocation(location) {
100
100
  try {
101
101
  return readFileSync(path, 'utf8');
102
102
  } catch (error) {
103
- throw new Error(`cannot read ${path}: ${error.code ?? error.message}`);
103
+ // Keep the code: the rollback guard distinguishes "no baseline yet" (ENOENT)
104
+ // from "the baseline exists but cannot be read".
105
+ const wrapped = new Error(`cannot read ${path}: ${error.code ?? error.message}`);
106
+ wrapped.code = error.code;
107
+ throw wrapped;
104
108
  }
105
109
  }
106
110
 
107
111
  async function readPublishedIndexForGuard() {
108
112
  try {
109
- const text = isHttpUrl(indexUrl) ? await fetchText(indexUrl) : readLocation(indexUrl);
113
+ // Cache-buster: raw.githubusercontent serves the branch copy with a 5-minute
114
+ // max-age, and a stale baseline would let a lagging registry shrink the index.
115
+ const location = isHttpUrl(indexUrl) ? withCacheBuster(indexUrl) : indexUrl;
116
+ const text = isHttpUrl(location) ? await fetchText(location) : readLocation(location);
110
117
  return JSON.parse(text);
111
118
  } catch (error) {
112
- // First release (no branch yet), an unpublished URL, or a network failure:
113
- // the guard is best-effort and must not block the very first index publish.
114
- console.log(`rollback guard skipped: cannot read the published index at ${indexUrl} (${error.message})`);
119
+ if (error?.status === 404 || error?.code === 'ENOENT') {
120
+ // First release (no branch yet): there is nothing to protect.
121
+ console.log(`rollback guard skipped: the published index does not exist yet (${error.message})`);
122
+ return null;
123
+ }
124
+ // Anything else (network failure, unreadable baseline, unparsable JSON) is a
125
+ // real problem: publishing now could replace a newer index with a smaller one.
126
+ const message =
127
+ `cannot read the published index at ${indexUrl} (${error.message}); refusing to publish ` +
128
+ 'without the rollback check';
129
+ if (!allowShrink) throw new Error(`${message} (set MARKET_ALLOW_SHRINK=1 to override)`);
130
+ console.log(`warning: ${message} (MARKET_ALLOW_SHRINK=1)`);
115
131
  return null;
116
132
  }
117
133
  }
@@ -146,10 +162,21 @@ async function fetchText(url, accept) {
146
162
  headers,
147
163
  signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
148
164
  });
149
- if (!response.ok) throw new Error(`${url} answered ${response.status}`);
165
+ if (!response.ok) {
166
+ const error = new Error(`${url} answered ${response.status}`);
167
+ error.status = response.status;
168
+ throw error;
169
+ }
150
170
  return response.text();
151
171
  }
152
172
 
173
+ function withCacheBuster(url) {
174
+ // Any origin in this script (registry, raw.githubusercontent) serves a cached copy
175
+ // for minutes; an unknown query parameter gives the request its own cache key.
176
+ const separator = url.includes('?') ? '&' : '?';
177
+ return `${url}${separator}t=${Date.now()}`;
178
+ }
179
+
153
180
  function registryPackumentUrl() {
154
181
  // The registry ignores unknown query parameters; the one-shot value defeats a
155
182
  // stale CDN or proxy entry for a packument that just changed.
@@ -310,7 +337,7 @@ const summary = `${versions.length} version(s)${skipped.length ? `; skipped: ${s
310
337
  if (process.argv.includes('--check')) {
311
338
  // Compare with the published copy so a stale index is visible: the registry moved
312
339
  // ahead of the branch, or the market-index job never ran after a release.
313
- const remote = isHttpUrl(indexUrl) ? await fetchText(indexUrl) : readLocation(indexUrl);
340
+ const remote = isHttpUrl(indexUrl) ? await fetchText(withCacheBuster(indexUrl)) : readLocation(indexUrl);
314
341
  assert.equal(remote, body, `the published index at ${indexUrl} is stale; refresh the market-index branch`);
315
342
  console.log(`published index matches the registry: ${summary}`);
316
343
  } else {