dshmarket 1.73.13 → 1.73.14

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/client/client.js CHANGED
@@ -462,6 +462,10 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
462
462
  hostIncompatibleSearching: "正在查找还兼容当前 DSH 的版本…",
463
463
  hostIncompatibleFoundInstall: "可以装 {version}:它声明兼容当前 DSH。",
464
464
  hostIncompatibleFoundUpdate: "可以更新到 {version}:它声明兼容当前 DSH。",
465
+ hostIncompatibleHeldTarget: "可以选 {version}:它声明兼容当前 DSH,但还在发布等待期——新版本发布后要等 {window} 小时才算稳定,还差约 {hours} 小时。",
466
+ hostIncompatibleHeldTargetUnknown: "可以选 {version}:它声明兼容当前 DSH,但还在发布等待期,暂时算不出还要等多久。",
467
+ hostIncompatibleHeldButton: "还在等待期(约 {hours} 小时)",
468
+ hostIncompatibleHeldButtonUnknown: "还在等待期",
465
469
  hostIncompatibleNoCompat: "没有找到声明兼容当前 DSH 的版本。",
466
470
  hostIncompatibleSearchFailed: "暂时查不到兼容版本。",
467
471
  hostIncompatibleInstallCompat: "安装 {version}",
@@ -1250,6 +1254,10 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
1250
1254
  hostIncompatibleSearching: "Looking for a version that still supports this DSH…",
1251
1255
  hostIncompatibleFoundInstall: "You can install {version} — it declares support for this DSH.",
1252
1256
  hostIncompatibleFoundUpdate: "You can update to {version} — it declares support for this DSH.",
1257
+ hostIncompatibleHeldTarget: "{version} does declare support for this DSH, but it is still inside the release-age wait — a new release has to settle for {window} hours, so about {hours} more to go.",
1258
+ hostIncompatibleHeldTargetUnknown: "{version} does declare support for this DSH, but it is still inside the release-age wait, and this host cannot work out how long is left.",
1259
+ hostIncompatibleHeldButton: "Still waiting ({hours}h)",
1260
+ hostIncompatibleHeldButtonUnknown: "Still waiting",
1253
1261
  hostIncompatibleNoCompat: "No version declares support for this DSH.",
1254
1262
  hostIncompatibleSearchFailed: "Could not look up compatible versions.",
1255
1263
  hostIncompatibleInstallCompat: "Install {version}",
@@ -2038,6 +2046,10 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
2038
2046
  hostIncompatibleSearching: "現在の DSH と互換性のあるバージョンを探しています…",
2039
2047
  hostIncompatibleFoundInstall: "{version} をインストールできます。現在の DSH への対応を宣言しています。",
2040
2048
  hostIncompatibleFoundUpdate: "{version} に更新できます。現在の DSH への対応を宣言しています。",
2049
+ hostIncompatibleHeldTarget: "{version} は現在の DSH への対応を宣言していますが、まだ公開直後の待機期間中です — 新しい版は {window} 時間の経過が必要で、あと約 {hours} 時間です。",
2050
+ hostIncompatibleHeldTargetUnknown: "{version} は現在の DSH への対応を宣言していますが、まだ公開直後の待機期間中です。残り時間はこの環境では判定できません。",
2051
+ hostIncompatibleHeldButton: "待機中(約 {hours} 時間)",
2052
+ hostIncompatibleHeldButtonUnknown: "待機中",
2041
2053
  hostIncompatibleNoCompat: "現在の DSH への対応を宣言しているバージョンは見つかりませんでした。",
2042
2054
  hostIncompatibleSearchFailed: "互換性のあるバージョンを今は確認できません。",
2043
2055
  hostIncompatibleInstallCompat: "{version} をインストール",
@@ -8463,6 +8475,10 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
8463
8475
  function thumbUrl(src, height, options = {}) {
8464
8476
  let url = `https://images.weserv.nl/?url=${encodeURIComponent(src.replace(/^https?:\/\//, ""))}&h=${String(height)}&fit=inside&we=1`;
8465
8477
  if (options.webp === true && /\.(?:png|jpe?g|webp)(?:$|[?#])/iu.test(src)) url += "&output=webp";
8478
+ else if (/\.gif(?:$|[?#])/iu.test(src)) {
8479
+ const still = `${url}&output=webp`;
8480
+ url = `${url}&n=-1&output=webp&errorredirect=${encodeURIComponent(still)}`;
8481
+ }
8466
8482
  return url;
8467
8483
  }
8468
8484
  /**
@@ -10486,15 +10502,28 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
10486
10502
  return await response.json();
10487
10503
  }).then((data) => {
10488
10504
  if (controller.signal.aborted) return;
10489
- setFindingCompat(typeof data.compatibleVersion === "string" && data.compatibleVersion !== "" ? {
10505
+ if (!(typeof data.compatibleVersion === "string" && data.compatibleVersion !== "")) {
10506
+ setFindingCompat({ status: "not-found" });
10507
+ return;
10508
+ }
10509
+ const maturity = data.maturity !== null && typeof data.maturity === "object" ? data.maturity : null;
10510
+ setFindingCompat({
10490
10511
  status: "found",
10491
- version: data.compatibleVersion
10492
- } : { status: "not-found" });
10512
+ version: data.compatibleVersion,
10513
+ installable: typeof maturity?.installable === "boolean" ? maturity.installable : null,
10514
+ releaseAgeMs: typeof maturity?.releaseAgeMs === "number" ? maturity.releaseAgeMs : null,
10515
+ nextMaturityAt: typeof maturity?.nextMaturityAt === "string" ? maturity.nextMaturityAt : null
10516
+ });
10493
10517
  }).catch(() => {
10494
10518
  if (!controller.signal.aborted) setFindingCompat({ status: "error" });
10495
10519
  });
10496
10520
  return () => controller.abort();
10497
10521
  }, [hostIncompatible, compatRetry]);
10522
+ const hostCompatHeldUpdate = hostIncompatible === null ? void 0 : updates[hostIncompatible.npmName ?? ""];
10523
+ const hostCompatHeld = findingCompat.status === "found" && (findingCompat.installable === false || findingCompat.installable === null && hostCompatHeldUpdate?.heldUpdate !== void 0 && hostCompatHeldUpdate.heldUpdate.latest === findingCompat.version && Date.parse(hostCompatHeldUpdate.heldUpdate.until) > Date.now());
10524
+ const hostCompatNextMaturityAt = findingCompat.status === "found" && findingCompat.installable === null ? hostCompatHeldUpdate?.heldUpdate?.until ?? null : findingCompat.status === "found" ? findingCompat.nextMaturityAt : null;
10525
+ const hostCompatHeldHours = hostCompatHeld && hostCompatNextMaturityAt !== null ? Math.max(1, Math.ceil((Date.parse(hostCompatNextMaturityAt) - Date.now()) / 36e5)) : null;
10526
+ const hostCompatWindowHours = findingCompat.status === "found" && findingCompat.releaseAgeMs !== null ? Math.max(1, Math.round(findingCompat.releaseAgeMs / 36e5)) : 24;
10498
10527
  const [restoreBlocked, setRestoreBlocked] = (0, react.useState)(null);
10499
10528
  const [migrationConfirm, setMigrationConfirm] = (0, react.useState)(null);
10500
10529
  /** Determinate percent parsed from pnpm's Progress line, when available. */
@@ -17146,16 +17175,16 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
17146
17175
  open: true,
17147
17176
  onClose: () => setHostIncompatible(null),
17148
17177
  title: t("hostIncompatibleTitle"),
17149
- description: [t(hostIncompatible.kind === "install" ? "hostIncompatibleBodyInstall" : "hostIncompatibleBody").replace("{plugin}", `${hostIncompatible.name} ${hostIncompatible.version}`.trim()).replace("{requirement}", hostIncompatible.requirement ?? t("hostIncompatibleUnknown")).replace("{host}", hostIncompatible.hostVersion ?? t("hostIncompatibleUnknown")), hostIncompatible.npmName === null ? null : findingCompat.status === "loading" ? t("hostIncompatibleSearching") : findingCompat.status === "found" ? t(hostIncompatible.kind === "install" ? "hostIncompatibleFoundInstall" : "hostIncompatibleFoundUpdate").replace("{version}", findingCompat.version) : findingCompat.status === "not-found" ? t("hostIncompatibleNoCompat") : findingCompat.status === "error" ? t("hostIncompatibleSearchFailed") : null].filter((line) => line !== null).join("\n"),
17178
+ description: [t(hostIncompatible.kind === "install" ? "hostIncompatibleBodyInstall" : "hostIncompatibleBody").replace("{plugin}", `${hostIncompatible.name} ${hostIncompatible.version}`.trim()).replace("{requirement}", hostIncompatible.requirement ?? t("hostIncompatibleUnknown")).replace("{host}", hostIncompatible.hostVersion ?? t("hostIncompatibleUnknown")), hostIncompatible.npmName === null ? null : findingCompat.status === "loading" ? t("hostIncompatibleSearching") : findingCompat.status === "found" ? hostCompatHeld ? hostCompatHeldHours === null ? t("hostIncompatibleHeldTargetUnknown").replace("{version}", findingCompat.version) : t("hostIncompatibleHeldTarget").replace("{version}", findingCompat.version).replace("{window}", String(hostCompatWindowHours)).replace("{hours}", String(hostCompatHeldHours)) : t(hostIncompatible.kind === "install" ? "hostIncompatibleFoundInstall" : "hostIncompatibleFoundUpdate").replace("{version}", findingCompat.version) : findingCompat.status === "not-found" ? t("hostIncompatibleNoCompat") : findingCompat.status === "error" ? t("hostIncompatibleSearchFailed") : null].filter((line) => line !== null).join("\n"),
17150
17179
  footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
17151
17180
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
17152
- variant: findingCompat.status === "found" ? "outline" : "primary",
17181
+ variant: findingCompat.status === "found" && !hostCompatHeld ? "outline" : "primary",
17153
17182
  onClick: () => setHostIncompatible(null),
17154
17183
  children: t(hostIncompatible.kind === "install" ? "hostIncompatibleCancel" : "hostIncompatibleKeep")
17155
17184
  }),
17156
17185
  findingCompat.status === "found" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
17157
17186
  variant: "primary",
17158
- disabled: hostIncompatible.kind === "install" ? busyUrl !== null : updatingName !== null,
17187
+ disabled: hostCompatHeld || (hostIncompatible.kind === "install" ? busyUrl !== null : updatingName !== null),
17159
17188
  onClick: () => {
17160
17189
  const kind = hostIncompatible.kind;
17161
17190
  const target = hostIncompatible.name;
@@ -17166,7 +17195,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
17166
17195
  if (plugin !== null) doInstall(plugin, false, version);
17167
17196
  } else doUpdate(target, false, false, version);
17168
17197
  },
17169
- children: t(hostIncompatible.kind === "install" ? "hostIncompatibleInstallCompat" : "hostIncompatibleUpdateCompat").replace("{version}", findingCompat.version)
17198
+ children: hostCompatHeld ? hostCompatHeldHours === null ? t("hostIncompatibleHeldButtonUnknown") : t("hostIncompatibleHeldButton").replace("{hours}", String(hostCompatHeldHours)) : t(hostIncompatible.kind === "install" ? "hostIncompatibleInstallCompat" : "hostIncompatibleUpdateCompat").replace("{version}", findingCompat.version)
17170
17199
  }),
17171
17200
  findingCompat.status === "error" && hostIncompatible.npmName !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
17172
17201
  variant: "outline",
package/lib/changelog.js CHANGED
@@ -20,7 +20,7 @@
20
20
  * `source` instead: its history is where it came from, and the market says
21
21
  * it has none on hand rather than that the plugin publishes none (#819).
22
22
  */
23
- import { fileFromTarball } from './catalog-npm.js';
23
+ import { absoluteTarballUrl, fileFromTarball } from './catalog-npm.js';
24
24
  import { marketFetch } from './net.js';
25
25
  import { activeRegion, routesFor } from './regions.js';
26
26
  import { profileDir, readGitResolutionCommit, readInstalled, readInstalledRepoEvidence, readInstalledVersion, readLockCommits } from './profile.js';
@@ -61,7 +61,9 @@ export async function loadUpdateNotes(force = false) {
61
61
  const tarball = typeof meta.dist?.tarball === 'string' ? meta.dist.tarball : null;
62
62
  if (tarball === null)
63
63
  throw new Error(`${UPDATES_PACKAGE} names no tarball`);
64
- const tarRes = await marketFetch(tarball, { signal: AbortSignal.timeout(TIMEOUT_MS) });
64
+ // A registry under a path prefix may answer with a relative tarball, the
65
+ // same case the catalog route resolves (#1117).
66
+ const tarRes = await marketFetch(absoluteTarballUrl(tarball, routes.npmRegistry), { signal: AbortSignal.timeout(TIMEOUT_MS) });
65
67
  if (!tarRes.ok)
66
68
  throw new Error(`HTTP ${String(tarRes.status)} reading ${UPDATES_PACKAGE} tarball`);
67
69
  const bytes = fileFromTarball(Buffer.from(await tarRes.arrayBuffer()), UPDATES_FILE);
package/lib/check.js CHANGED
@@ -314,31 +314,61 @@ function parseSemver(value) {
314
314
  };
315
315
  }
316
316
  /**
317
- * Parse a comparator's target the way node-semver does: a PARTIAL version in
318
- * a range is zero-filled, so `<0.3` is `<0.3.0` and `>=2` is `>=2.0.0`.
317
+ * Rewrite a comparator whose target is a PARTIAL version into the full
318
+ * comparators node-semver desugars it to. Anything else comes back as is.
319
319
  *
320
- * Without this, every prerelease floor written as a partial — the
321
- * `@deepseek-ai/dsh-*` peers of a whole family of connector plugins say
322
- * `>=0.1.5 <0.3`, `>=0.1.7-rc <2`, `>=0.2.0-rc.0 <0.3` — parsed as unknown,
323
- * `satisfiesRange` answered null, and the gate stood aside: measured against
324
- * the host's own evaluator over 699 live catalog manifests, those were the
325
- * last 7 of 2796 (package, runtime) pairs where the host refuses a plugin
326
- * and the market still promised a restart would apply it.
320
+ * The `@deepseek-ai/dsh-*` peers of a whole family of connector plugins are
321
+ * written this way (`>=0.1.5 <0.3`, `>=0.1.7-rc <2`, `>=0.2.0-rc.0 <0.3`).
322
+ * Read as unknown, they left the activation gate standing aside: measured
323
+ * against the host's own evaluator over 699 live catalog manifests, those
324
+ * were the last 7 of 2796 (package, runtime) pairs where the host refuses a
325
+ * plugin and the market still promised a restart would apply it.
327
326
  *
328
- * A BARE partial (`1.2`) is a different thing in semver — an x-range that
329
- * means `>=1.2.0 <1.3.0` — so it deliberately stays unknown here rather than
330
- * being mistaken for the exact version `1.2.0`.
327
+ * Zero-filling the target is right for `>=` and wrong for the rest. A partial
328
+ * names a whole release line, so node-semver (`replaceXRange`, `replaceTilde`,
329
+ * `replaceCaret`) moves the bound to the edge of that line:
330
+ *
331
+ * `<0.3` → `<0.3.0-0` `<=0.3` → `<0.4.0-0`
332
+ * `>0.3` → `>=0.4.0` `>1` → `>=2.0.0`
333
+ * `~1` → `>=1.0.0 <2.0.0-0` `^0` → `>=0.0.0 <1.0.0-0`
334
+ * `^0.0` → `>=0.0.0 <0.1.0-0`
335
+ *
336
+ * Comparing against the raw partial string instead ordered `9.1.0` above
337
+ * `10` and `0.10.0` below `0.3`, character by character.
338
+ *
339
+ * A BARE partial (`1.2`) has no operator and is an x-range in semver
340
+ * (`>=1.2.0 <1.3.0`), so it stays as is and parses as unknown below rather
341
+ * than being mistaken for the exact version `1.2.0`.
331
342
  */
332
- function parseComparatorTarget(target, op) {
333
- const direct = parseSemver(target);
334
- if (direct !== null)
335
- return direct;
336
- if (op === '')
337
- return null;
338
- const parts = target.trim().split('.');
339
- if (parts.length > 3 || parts.some(part => !/^\d+$/u.test(part)))
340
- return null;
341
- return parseSemver([...parts, ...Array(3 - parts.length).fill('0')].join('.'));
343
+ function expandPartialComparator(part, includePrerelease) {
344
+ const m = /^(\^|~|>=|<=|>|<)(\d+)(?:\.(\d+))?$/u.exec(part.trim());
345
+ if (m === null)
346
+ return [part];
347
+ const op = m[1];
348
+ const major = Number(m[2]);
349
+ const minor = m[3] === undefined ? null : Number(m[3]);
350
+ // node-semver lowers a desugared floor to `-0` under includePrerelease, so
351
+ // `>=0.3` admits `0.3.0-rc.1` there. Ceilings always carry `-0`.
352
+ const z = includePrerelease ? '-0' : '';
353
+ const floor = `${String(major)}.${String(minor ?? 0)}.0`;
354
+ const nextLine = minor === null ? `${String(major + 1)}.0.0` : `${String(major)}.${String(minor + 1)}.0`;
355
+ switch (op) {
356
+ case '>=':
357
+ return [`>=${floor}${z}`];
358
+ case '>':
359
+ return [`>=${nextLine}${z}`];
360
+ case '<':
361
+ return [`<${exclusiveUpperBound(floor)}`];
362
+ case '<=':
363
+ return [`<${exclusiveUpperBound(nextLine)}`];
364
+ case '~':
365
+ return [`>=${floor}${z}`, `<${exclusiveUpperBound(nextLine)}`];
366
+ default: {
367
+ // `^`: the next major, except inside 0.x where the minor is breaking.
368
+ const ceiling = major > 0 || minor === null ? `${String(major + 1)}.0.0` : `0.${String(minor + 1)}.0`;
369
+ return [`>=${floor}${z}`, `<${exclusiveUpperBound(ceiling)}`];
370
+ }
371
+ }
342
372
  }
343
373
  function comparePre(a, b) {
344
374
  const len = Math.max(a.length, b.length);
@@ -468,7 +498,7 @@ export function satisfiesRange(version, range, options = {}) {
468
498
  const m = /^(\^|~|>=|<=|>|<|=)?(.*)$/.exec(p);
469
499
  const op = m?.[1] === '=' ? '' : (m?.[1] ?? '');
470
500
  const target = (m?.[2] ?? '').trim();
471
- const tv = parseComparatorTarget(target, op);
501
+ const tv = parseSemver(target);
472
502
  if (tv === null)
473
503
  return null;
474
504
  const major = tv.major;
@@ -516,13 +546,14 @@ export function satisfiesRange(version, range, options = {}) {
516
546
  // prerelease admission gate. Otherwise an unknown protocol such as
517
547
  // `workspace:^` or `catalog:default` is misreported as a definite false
518
548
  // whenever the resolved version happens to carry a prerelease tag.
519
- if (parseComparatorTarget(target, op) === null)
549
+ if (parseSemver(target) === null)
520
550
  return null;
521
551
  return { op, target };
522
552
  };
523
553
  /** Evaluate ONE comparator set (a `||` alternative) as a conjunction. */
524
554
  const evaluateSet = (set) => {
525
- const parts = set.trim().split(/\s+/).filter(part => part !== '');
555
+ const parts = set.trim().split(/\s+/).filter(part => part !== '')
556
+ .flatMap(part => expandPartialComparator(part, options.includePrerelease === true));
526
557
  if (parts.length === 0)
527
558
  return true;
528
559
  const parsed = parts.map(part => comparator(part));
package/lib/log.js CHANGED
@@ -62,7 +62,9 @@ export function logEvent(level, event, detail) {
62
62
  try {
63
63
  const line = `${JSON.stringify(entry)}\n`;
64
64
  appendFileSync(persistentFile, line);
65
- persistentBytes += line.length;
65
+ // Bytes, not UTF-16 units: CJK detail is 3 bytes a character on disk,
66
+ // and the counter has to agree with `statSync().size` it started from.
67
+ persistentBytes += Buffer.byteLength(line);
66
68
  // Trimming only on mount left the cap unenforced for the life of a
67
69
  // process: 20k events grew the file to 3.2 MB in a measurement, and a
68
70
  // retry loop is exactly the situation that both logs hardest and never
@@ -87,7 +89,7 @@ function trimPersistentLog(file) {
87
89
  let bytes = 0;
88
90
  for (let index = lines.length - 1; index >= 0 && bytes <= PERSISTENT_MAX_BYTES / 2; index -= 1) {
89
91
  kept.unshift(`${lines[index]}\n`);
90
- bytes += lines[index].length + 1;
92
+ bytes += Buffer.byteLength(lines[index]) + 1;
91
93
  }
92
94
  writeFileSync(file, kept.join(''));
93
95
  persistentBytes = bytes;
package/lib/patch.js CHANGED
@@ -158,11 +158,70 @@ function entryKeyValue(lines, start, key) {
158
158
  }
159
159
  return null;
160
160
  }
161
+ /**
162
+ * Whether a patch entry speaks for the row it names.
163
+ *
164
+ * The host skips an entry whose `name` is not the name that row's id composes
165
+ * to — `applyPatches` in dsh-app-boot, `if (name && name !== target.name)`,
166
+ * the same line in every published version. A row left behind by a package
167
+ * rename therefore never takes effect, while anything that counts the flag
168
+ * alone reports the plugin as off (#1113). Only a row that CARRIES a name is
169
+ * compared, and only when the composed name is known: an id that is not in
170
+ * the loader has nothing to compare against, and its flag stands.
171
+ *
172
+ * @param name - the `name` the entry carries, if any.
173
+ * @param expected - the composed entry's own name, or null when unknown.
174
+ */
175
+ function rowApplies(name, expected) {
176
+ if (typeof name !== 'string' || name === '')
177
+ return true;
178
+ return expected === null || name === expected;
179
+ }
180
+ /**
181
+ * The name the loader composed for a row, or null when the id is not there.
182
+ *
183
+ * This is the comparison the host makes, against the composed entry's own
184
+ * `name` — NOT `nameMatchesPackage()`, which judges package ownership and
185
+ * treats a subpath name and a foreign package name the same way (#1113).
186
+ */
187
+ export function composedRowName(host, rowId) {
188
+ for (const entry of host.loader.entries()) {
189
+ if (loaderEntryId(entry) !== rowId)
190
+ continue;
191
+ const name = entry.options?.name;
192
+ return typeof name === 'string' && name !== '' ? name : null;
193
+ }
194
+ return null;
195
+ }
196
+ /**
197
+ * Whether the user layer's flag for this row is a decision the host applies.
198
+ *
199
+ * @param state - the user patch state.
200
+ * @param rowId - the row being asked about.
201
+ * @param expected - the composed entry's name, or null when the id is not in
202
+ * the loader.
203
+ */
204
+ export function rowFlagApplies(state, rowId, expected) {
205
+ const carried = state.names?.[rowId];
206
+ return carried === undefined || rowApplies(carried, expected);
207
+ }
208
+ /** The state with one row's flags dropped when its `name` does not apply. */
209
+ function withoutMismatchedRow(state, rowId, expected) {
210
+ if (rowFlagApplies(state, rowId, expected))
211
+ return state;
212
+ return {
213
+ disables: state.disables.filter(id => id !== rowId),
214
+ forced: state.forced.filter(id => id !== rowId),
215
+ inserts: state.inserts,
216
+ ...(state.names !== undefined ? { names: state.names } : {}),
217
+ };
218
+ }
161
219
  export function readUserPatchState(patchPath) {
162
220
  // The host composes the file in order, later entries override earlier ones,
163
221
  // so a row has one final flag: listing it as both disabled and forced showed
164
222
  // a plugin as off while the file had it on (#1099).
165
223
  const flags = new Map();
224
+ const names = new Map();
166
225
  const inserts = [];
167
226
  let text = '';
168
227
  try {
@@ -190,11 +249,26 @@ export function readUserPatchState(patchPath) {
190
249
  continue;
191
250
  const id = (disableRow[1] ?? disableRow[2] ?? disableRow[3]);
192
251
  const value = entryKeyValue(lines, index + 1, 'disabled');
193
- if (value === 'true' || value === 'false')
194
- flags.set(id, value);
252
+ if (value !== 'true' && value !== 'false')
253
+ continue;
254
+ flags.set(id, value);
255
+ // A row that names a module is only applied by the host when that name is
256
+ // the one the row's id composes to; the flag stays here so the caller can
257
+ // make that comparison (#1113).
258
+ const named = entryKeyValue(lines, index + 1, 'name');
259
+ const unwrapped = named === null ? null : named.replace(/^(['"])(.*)\1$/u, '$2');
260
+ if (unwrapped !== null && unwrapped !== '')
261
+ names.set(id, unwrapped);
262
+ else
263
+ names.delete(id);
195
264
  }
196
265
  const withFlag = (flag) => [...flags.keys()].filter(id => flags.get(id) === flag);
197
- return { disables: withFlag('true'), forced: withFlag('false'), inserts };
266
+ return {
267
+ disables: withFlag('true'),
268
+ forced: withFlag('false'),
269
+ inserts,
270
+ ...(names.size > 0 ? { names: Object.fromEntries(names) } : {}),
271
+ };
198
272
  }
199
273
  /**
200
274
  * User-authored insert rows that still load `packageName` (or one of its
@@ -501,9 +575,13 @@ export function packagePatchFlags(host, profileDirectory, names, state) {
501
575
  // user's decisions ABOVE the bundle's own default count.
502
576
  const optOut = new Set(bundleOptOutRowIds(join(profileDirectory, 'node_modules', name)));
503
577
  const decidedByUser = (id) => !optOut.has(id);
504
- if (rows.some(id => decidedByUser(id) && state.disables.includes(id)))
578
+ // A row that names a module other than this id's does nothing in the
579
+ // host, so it is not a decision about this package (#1113): the shape a
580
+ // package rename leaves behind.
581
+ const applies = (id) => rowFlagApplies(state, id, composedRowName(host, id));
582
+ if (rows.some(id => decidedByUser(id) && applies(id) && state.disables.includes(id)))
505
583
  disabled.push(name);
506
- if (rows.some(id => decidedByUser(id) && state.forced.includes(id)))
584
+ if (rows.some(id => decidedByUser(id) && applies(id) && state.forced.includes(id)))
507
585
  forced.push(name);
508
586
  }
509
587
  return { disabled, forced };
@@ -527,7 +605,7 @@ function rowBlock(rowId, disabled) {
527
605
  * after the flag too: an indented config/name/key makes this a longer entry,
528
606
  * whose first lines must never be removed (#821). Trailing comments stay put.
529
607
  */
530
- function rewriteRowBlocks(text, rowId, disabled, replace) {
608
+ function rewriteRowBlocks(text, rowId, disabled, replace, expected = null) {
531
609
  const id = escapeRegExp(rowId);
532
610
  const idLine = new RegExp(`^- id: (?:${id}|'${id}'|"${id}")[ \t]*$`, 'u');
533
611
  const lines = text.match(/[^\n]*(?:\n|$)/gu)?.filter(Boolean) ?? [];
@@ -538,6 +616,11 @@ function rewriteRowBlocks(text, rowId, disabled, replace) {
538
616
  for (let index = 0; index < lines.length; index += 1) {
539
617
  if (!idLine.test(lines[index].replace(/\r?\n$/u, '')))
540
618
  continue;
619
+ // A row that names another module is skipped by the host, so rewriting it
620
+ // would report a change that never happens (#1113).
621
+ const named = entryKeyValue(lines, index + 1, 'name');
622
+ if (!rowApplies(named === null ? null : named.replace(/^(['"])(.*)\1$/u, '$2'), expected))
623
+ continue;
541
624
  const flagIndex = nextPatchContentLine(lines, index + 1);
542
625
  const flag = /^ {2}disabled: (true|false)[ \t]*(?:\r?\n)?$/u.exec(lines[flagIndex] ?? '');
543
626
  if (flag === null || (disabled !== 'any' && flag[1] !== disabled))
@@ -570,7 +653,7 @@ function rewriteRowBlocks(text, rowId, disabled, replace) {
570
653
  * text cannot be read as DSH's patch dialect — the caller then keeps the line
571
654
  * scanner's answer rather than guessing.
572
655
  */
573
- function composedRowFlag(text, rowId) {
656
+ function composedRowFlag(text, rowId, expected = null) {
574
657
  let rows;
575
658
  try {
576
659
  rows = parsePatchText(text);
@@ -587,6 +670,9 @@ function composedRowFlag(text, rowId) {
587
670
  const entry = row;
588
671
  if (entry.id !== rowId)
589
672
  continue;
673
+ // A row naming another module never reaches this id's entry (#1113).
674
+ if (!rowApplies(entry.name, expected))
675
+ continue;
590
676
  // An `!!js` expression arrives as a function (or a tag object): it decides
591
677
  // by itself, and flattening it here would freeze one host's answer.
592
678
  if (entry.disabled === true)
@@ -596,7 +682,7 @@ function composedRowFlag(text, rowId) {
596
682
  }
597
683
  return flag;
598
684
  }
599
- function lastRowFlag(text, rowId) {
685
+ function lastRowFlag(text, rowId, expected = null) {
600
686
  const id = escapeRegExp(rowId);
601
687
  const idLine = new RegExp(`^- id: (?:${id}|'${id}'|"${id}")\\s*$`, 'u');
602
688
  const lines = text.split(/\r?\n/u);
@@ -604,6 +690,10 @@ function lastRowFlag(text, rowId) {
604
690
  for (let index = 0; index < lines.length; index += 1) {
605
691
  if (!idLine.test(lines[index] ?? ''))
606
692
  continue;
693
+ const named = entryKeyValue(lines, index + 1, 'name');
694
+ const name = named === null ? null : named.replace(/^(['"])(.*)\1$/u, '$2');
695
+ if (!rowApplies(name, expected))
696
+ continue;
607
697
  const value = entryKeyValue(lines, index + 1, 'disabled');
608
698
  if (value === 'true' || value === 'false')
609
699
  flag = value;
@@ -699,7 +789,7 @@ function appendPatchEntry(patchPath, block) {
699
789
  * a later reinstall off. Duplicates an older version left are folded into
700
790
  * the one block at the same time.
701
791
  */
702
- export function disableRow(patchPath, rowId) {
792
+ export function disableRow(patchPath, rowId, options = {}) {
703
793
  return queuedWrite(async () => {
704
794
  if (!ROW_ID_RE.test(rowId)) {
705
795
  return { ok: false, reason: `行 id 含特殊字符,不支持写入补丁层 / row id ${rowId} cannot be written to the patch layer` };
@@ -718,13 +808,13 @@ export function disableRow(patchPath, rowId) {
718
808
  return '';
719
809
  kept = true;
720
810
  return block.replace(/^ {2}disabled: false(?=[ \t]*(?:\r?\n|$))/mu, ' disabled: true');
721
- });
811
+ }, options.expectedName ?? null);
722
812
  if (next !== text) {
723
813
  const flipped = writePatchFile(patchPath, next);
724
814
  if (!flipped.ok)
725
815
  return flipped;
726
816
  // A longer entry for the row further down still has the last word.
727
- if (lastRowFlag(next, rowId) !== 'true') {
817
+ if (lastRowFlag(next, rowId, options.expectedName ?? null) !== 'true') {
728
818
  const result = appendPatchEntry(patchPath, rowBlock(rowId, true));
729
819
  if (!result.ok)
730
820
  return result;
@@ -732,7 +822,10 @@ export function disableRow(patchPath, rowId) {
732
822
  logEvent('info', 'patch', `disabled row ${rowId} in ${patchPath}`);
733
823
  return { ok: true, reason: null };
734
824
  }
735
- const state = readUserPatchState(patchPath);
825
+ // A row whose `name` is not this entry's owns nothing here: counting it
826
+ // as already-disabled would answer "off" and change nothing, leaving the
827
+ // plugin running (#1113).
828
+ const state = withoutMismatchedRow(readUserPatchState(patchPath), rowId, options.expectedName ?? null);
736
829
  if (state.disables.includes(rowId))
737
830
  return { ok: true, reason: null };
738
831
  const result = appendPatchEntry(patchPath, rowBlock(rowId, true));
@@ -753,11 +846,12 @@ export function disableRow(patchPath, rowId) {
753
846
  * closed — the host composes later entries last, so the append wins. */
754
847
  export function enableRow(patchPath, rowId, options = {}) {
755
848
  const cleanOnly = options.cleanOnly === true;
849
+ const expected = options.expectedName ?? null;
756
850
  return queuedWrite(async () => {
757
851
  if (!ROW_ID_RE.test(rowId)) {
758
852
  return { ok: false, reason: `行 id 含特殊字符,不支持写入补丁层 / row id ${rowId} cannot be written to the patch layer` };
759
853
  }
760
- const state = readUserPatchState(patchPath);
854
+ const state = withoutMismatchedRow(readUserPatchState(patchPath), rowId, expected);
761
855
  const text = (() => {
762
856
  try {
763
857
  return readFileSync(patchPath, 'utf8');
@@ -766,7 +860,7 @@ export function enableRow(patchPath, rowId, options = {}) {
766
860
  return '';
767
861
  }
768
862
  })();
769
- const next = rewriteRowBlocks(text, rowId, 'true', () => '');
863
+ const next = rewriteRowBlocks(text, rowId, 'true', () => '', expected);
770
864
  if (next !== text) {
771
865
  const written = writePatchFile(patchPath, withPlaceholderRestored(next));
772
866
  if (!written.ok)
@@ -775,7 +869,7 @@ export function enableRow(patchPath, rowId, options = {}) {
775
869
  // spelling the line scanner cannot see (#1112). Ask the parser the host
776
870
  // uses; when the file is not readable as its dialect, fall back to the
777
871
  // scanner.
778
- const stillOff = composedRowFlag(next, rowId) ?? lastRowFlag(next, rowId);
872
+ const stillOff = composedRowFlag(next, rowId, expected) ?? lastRowFlag(next, rowId, expected);
779
873
  if (!cleanOnly && stillOff === 'true') {
780
874
  const result = appendPatchEntry(patchPath, rowBlock(rowId, false));
781
875
  if (!result.ok)
@@ -99,3 +99,17 @@ export function selectMatureUpdate(packument, installed, now, policy) {
99
99
  latestMaturityAt: latestPublished === null || latestExempt ? null : latestPublished + ageMs,
100
100
  };
101
101
  }
102
+ export function versionMaturity(packument, version, now, policy) {
103
+ const ageMs = policy.minimumReleaseAgeMs;
104
+ const policyKnown = Number.isSafeInteger(ageMs) && ageMs >= 0 && Number.isFinite(now);
105
+ const times = typeof packument?.time === 'object' && packument.time !== null ? packument.time : {};
106
+ const published = strictPublishTime(times[version]);
107
+ const exempt = policy.exemptPackage === true || policy.exemptVersions?.has(version) === true;
108
+ if (published === null)
109
+ return { publishedAt: null, matureAt: null, exempt, mature: false, policyKnown };
110
+ if (!policyKnown)
111
+ return { publishedAt: published, matureAt: null, exempt, mature: false, policyKnown };
112
+ const matureAt = exempt ? published : published + ageMs;
113
+ const mature = published <= now && (exempt || published <= now - ageMs);
114
+ return { publishedAt: published, matureAt: Number.isFinite(matureAt) ? matureAt : null, exempt, mature, policyKnown };
115
+ }
package/lib/routes.js CHANGED
@@ -45,14 +45,14 @@ import { asRegion, githubProxyManaged, normalizeGithubProxy, REGIONS, routesFor,
45
45
  import { resolveRegion } from './region-probe.js';
46
46
  import { acceleratedTarget, resolveHeadCommit } from './accelerate.js';
47
47
  import { sourceWebUrl, updateNotesFor } from './changelog.js';
48
- import { checkUpdates, isUpdatablePlugin, compareVersions, fetchNpmLatest, invalidateUpdates, resolveDesktopMatureUpdate, resolveGitRemoteHead, isUpgrade, latestPublishedRecently, setUpdateRegistry, versionOnChannel } from './updates.js';
48
+ import { checkUpdates, isUpdatablePlugin, compareVersions, fetchNpmLatest, invalidateUpdates, readVersionMaturity, resolveDesktopMatureUpdate, resolveGitRemoteHead, isUpgrade, latestPublishedRecently, setUpdateRegistry, versionOnChannel } from './updates.js';
49
49
  import { isStableReleaseVersion } from './release-candidates.js';
50
50
  import { createThemeManager } from './themes.js';
51
51
  import { readJsonBody, refuseUnadmitted, sameOrigin, sendJson } from './http.js';
52
52
  import { resolveDshHome } from './home-paths.js';
53
53
  import { detectedDebugger, detectedSupervisor, restartAllowed, scheduleRestart, servingPort, trustedRestartRequest, trustedDownloadRequest, trustedSelfUninstallRequest, selfUninstallReachableFrom, restartReachableFrom } from './restart.js';
54
54
  import { activationAfterReplace, brokenClientBundles, bundlePatchIsEmpty, checkClientBundle, defaultHostRuntimeFacts, findUnservedConfigNamespaces, hasHostHalf, hostPeerGate, isDeclaredLibraryDsh, newlyBrokenBundles, peerGateRemedy, verifyActivation } from './verify.js';
55
- import { carrierRowIds, disableRow, enableRow, findUserPatchPath, foreignRowIds, isProtectedModule, loaderEntryId, packagePatchFlags, readUserPatchState, removeRowBlocks, rowIdsForPackage, userPatchPackageReferences, } from './patch.js';
55
+ import { carrierRowIds, composedRowName, disableRow, enableRow, findUserPatchPath, foreignRowIds, isProtectedModule, loaderEntryId, packagePatchFlags, rowFlagApplies, readUserPatchState, removeRowBlocks, rowIdsForPackage, userPatchPackageReferences, } from './patch.js';
56
56
  import { createProfileBackup, downloadWebdav, MAX_BACKUP_BYTES, mergeRestoreManifest, pinRunningDeps, restoreProfileBackup, unportableDeps, uploadWebdav, WebdavUrlError, } from './backup.js';
57
57
  import { createGist, fitsGistLimit, GistError, gistErrorCode, parseGistId, readGist, resolveGistTokenSource, updateGist, verifyGistToken, } from './gist.js';
58
58
  import { MAX_UPDATE_OPERATIONS_V1, UpdateOperationStoreV1, UPDATE_API_V1_SCHEMA } from './update-api-v1.js';
@@ -1105,6 +1105,12 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
1105
1105
  // What the row layer said before this call, so a rollback can put
1106
1106
  // each row back the way it was rather than the other way round.
1107
1107
  const prePatch = patchGate ? readUserPatchState(userPatchPath) : null;
1108
+ // The name the loader composed for a row, for the rows whose user-layer
1109
+ // entry carries one of its own: the host skips an entry whose `name` is
1110
+ // not this one, so its flag is not a decision about the row (#1113).
1111
+ const expectedNameFor = (rowId) => composedRowName(host, rowId);
1112
+ /** A user-layer flag counts only when the row it names is this entry. */
1113
+ const rowIsOurs = (rowId) => prePatch !== null && rowFlagApplies(prePatch, rowId, expectedNameFor(rowId));
1108
1114
  if (patchRows.length > 0 && patchGate && prePatch !== null) {
1109
1115
  // Disable touches every row: one left behind leaves the package
1110
1116
  // half-on. Enable leaves the bundle's own opt-in rows alone — they are
@@ -1119,7 +1125,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
1119
1125
  // at activation — except, again, to clean a block an earlier disable
1120
1126
  // left, which restores the expression's authority, never a forced on.
1121
1127
  const targets = enabled
1122
- ? patchRows.filter(rowId => (!optOutRows.has(rowId) && !expressionRows.has(rowId)) || prePatch.disables.includes(rowId))
1128
+ ? patchRows.filter(rowId => (!optOutRows.has(rowId) && !expressionRows.has(rowId)) || (rowIsOurs(rowId) && prePatch.disables.includes(rowId)))
1123
1129
  : patchRows;
1124
1130
  const flipped = [];
1125
1131
  for (const rowId of targets) {
@@ -1129,9 +1135,10 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
1129
1135
  // composes later entries last — so the append is what switched a row
1130
1136
  // on that #876/#1043 say must never be forced on.
1131
1137
  const cleanOnly = optOutRows.has(rowId) || expressionRows.has(rowId);
1138
+ const expectedName = expectedNameFor(rowId);
1132
1139
  const result = enabled
1133
- ? await enableRow(userPatchPath, rowId, { cleanOnly })
1134
- : await disableRow(userPatchPath, rowId);
1140
+ ? await enableRow(userPatchPath, rowId, { cleanOnly, expectedName })
1141
+ : await disableRow(userPatchPath, rowId, { expectedName });
1135
1142
  if (result.ok) {
1136
1143
  flipped.push(rowId);
1137
1144
  continue;
@@ -1156,12 +1163,12 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
1156
1163
  // `disabled: false` behind would force-enable it in the
1157
1164
  // user's own patch layer — the same disagreement this route
1158
1165
  // exists to end, one row smaller.
1159
- if (prePatch !== null && prePatch.disables.includes(rowId)) {
1160
- const back = await disableRow(userPatchPath, rowId);
1166
+ if (prePatch !== null && rowIsOurs(rowId) && prePatch.disables.includes(rowId)) {
1167
+ const back = await disableRow(userPatchPath, rowId, { expectedName: expectedNameFor(rowId) });
1161
1168
  if (!back.ok)
1162
1169
  logEvent('warn', 'toggle', `${name}: patch row ${rowId} could not be put back — ${back.reason}`);
1163
1170
  }
1164
- else if (prePatch === null || !prePatch.forced.includes(rowId)) {
1171
+ else if (prePatch === null || !rowIsOurs(rowId) || !prePatch.forced.includes(rowId)) {
1165
1172
  // A row already forced on before this call got nothing from
1166
1173
  // the enable; that block is the user's to keep.
1167
1174
  const cleanedRow = removeRowBlocks(userPatchPath, [rowId]);
@@ -3154,8 +3161,16 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
3154
3161
  return;
3155
3162
  }
3156
3163
  const compatibleVersion = await findCompatibleVersion(npmName, host.version, corePackageNames(host.directory ?? null), routesFor(region).npmRegistry, undefined, currentVersion);
3157
- logEvent('info', 'find-compatible', `${npmName}: host=${host.version}, after=${currentVersion ?? 'none'} → ${compatibleVersion ?? 'none'}`);
3158
- sendJson(response, 200, { compatibleVersion, currentVersion, upgradeOnly });
3164
+ // A compatible version is only advice until the release-age gate
3165
+ // agrees: the dialog says "update to X", and clicking that used to
3166
+ // dead-end on a 409 the log never mentioned. Answer both questions
3167
+ // here, where the caller can say "in about N hours" up front.
3168
+ const maturity = compatibleVersion === null
3169
+ ? null
3170
+ : await readVersionMaturity(npmName, compatibleVersion, config.profile, activeProfileDir);
3171
+ logEvent('info', 'find-compatible', `${npmName}: host=${host.version}, after=${currentVersion ?? 'none'} → ${compatibleVersion ?? 'none'}`
3172
+ + ` (held=${maturity === null ? 'n/a' : String(maturity.held)}, maturity=${maturity?.reason ?? 'n/a'})`);
3173
+ sendJson(response, 200, { compatibleVersion, currentVersion, upgradeOnly, maturity });
3159
3174
  }
3160
3175
  catch (error) {
3161
3176
  sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) });
@@ -4758,10 +4773,11 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
4758
4773
  const patchForced = !patchDisabled && patchFlags.forced.includes(name);
4759
4774
  const patchWarnings = [];
4760
4775
  for (const rowId of rowIdsForPackage(host, activeProfileDir, targetName)) {
4776
+ const expectedName = composedRowName(host, rowId);
4761
4777
  const changed = patchDisabled
4762
- ? await disableRow(userPatchPath, rowId)
4778
+ ? await disableRow(userPatchPath, rowId, { expectedName })
4763
4779
  : patchForced
4764
- ? await enableRow(userPatchPath, rowId)
4780
+ ? await enableRow(userPatchPath, rowId, { expectedName })
4765
4781
  : { ok: true, reason: null };
4766
4782
  if (!changed.ok && changed.reason !== null)
4767
4783
  patchWarnings.push(changed.reason);
@@ -5103,9 +5119,35 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
5103
5119
  }
5104
5120
  // compatVersion is an existing host-compatibility escape hatch,
5105
5121
  // never an exemption from the profile's release-age policy.
5122
+ // The dialog that produced compatVersion promised this exact
5123
+ // version, so a bare "not verified mature" dead-ends the user
5124
+ // in a refusal with no cause and no next step. Answer in the
5125
+ // three parts AGENTS.md asks for: what happened (held), why
5126
+ // (wait window, still short by N hours), what now (keep the
5127
+ // current version, try again after).
5106
5128
  if (compatVersion !== null && eligible.candidate !== compatVersion) {
5107
5129
  invalidateUpdates();
5108
- sendJson(response, 409, { staleTarget: true, error: 'The requested compatible version is not verified mature under the current profile policy.' });
5130
+ const maturity = await readVersionMaturity(name, compatVersion, config.profile, activeProfileDir);
5131
+ const heldHours = maturity.nextMaturityAt === null
5132
+ ? null
5133
+ : Math.max(1, Math.ceil((Date.parse(maturity.nextMaturityAt) - Date.now()) / 3_600_000));
5134
+ const windowHours = maturity.releaseAgeMs === null ? 24 : Math.round(maturity.releaseAgeMs / 3_600_000);
5135
+ const gapZh = heldHours === null ? '一天左右' : `约 ${heldHours} 小时`;
5136
+ const waitZh = `${gapZh}后`;
5137
+ const waitEn = heldHours === null ? 'in about a day' : `in about ${heldHours} ${heldHours === 1 ? 'hour' : 'hours'}`;
5138
+ const keptZh = installedVersion === null ? '插件没有改动' : `插件仍是 ${installedVersion}`;
5139
+ logEvent('warn', 'update-held', `${name}@${compatVersion}: compatible with this host but inside the release-age wait `
5140
+ + `(window=${windowHours}h, candidate=${eligible.candidate ?? 'none'}, maturity=${maturity.reason}, retry=${waitEn})`);
5141
+ sendJson(response, 409, {
5142
+ staleTarget: true,
5143
+ failureCode: maturity.reason === 'held' ? 'RELEASE_AGE_HELD' : 'RELEASE_AGE_UNVERIFIED',
5144
+ requestedVersion: compatVersion,
5145
+ candidate: eligible.candidate,
5146
+ nextMaturityAt: maturity.nextMaturityAt,
5147
+ releaseAgeMs: maturity.releaseAgeMs,
5148
+ error: `没法更新到 ${compatVersion}:它能兼容当前 DSH,但还在发布等待期——新版本发布后要等 ${windowHours} 小时才算稳定,它还差${gapZh}。${keptZh},可以${waitZh}再更新一次。 / `
5149
+ + `Cannot update to ${compatVersion} yet: it does support this DSH, but it is still inside the release-age wait (a new release has to settle for ${windowHours} hours; ${gapZh === '一天左右' ? 'about a day' : `about ${heldHours} hours`} to go). Nothing was changed${installedVersion === null ? '' : ` — the plugin is still on ${installedVersion}`}; update again ${waitEn}.`,
5150
+ });
5109
5151
  return;
5110
5152
  }
5111
5153
  expectedNpmVersion = eligible.candidate;
@@ -55,7 +55,28 @@ export interface PatchState {
55
55
  forced: string[];
56
56
  /** Row ids the user patch inserts. */
57
57
  inserts: string[];
58
+ /** The `name` a flag row carries, when it carries one. A row whose name
59
+ * does not match the composed entry is skipped by the host, so its flag is
60
+ * not a decision about anything (#1113). */
61
+ names?: Record<string, string>;
58
62
  }
63
+ /**
64
+ * The name the loader composed for a row, or null when the id is not there.
65
+ *
66
+ * This is the comparison the host makes, against the composed entry's own
67
+ * `name` — NOT `nameMatchesPackage()`, which judges package ownership and
68
+ * treats a subpath name and a foreign package name the same way (#1113).
69
+ */
70
+ export declare function composedRowName(host: PatchHost, rowId: string): string | null;
71
+ /**
72
+ * Whether the user layer's flag for this row is a decision the host applies.
73
+ *
74
+ * @param state - the user patch state.
75
+ * @param rowId - the row being asked about.
76
+ * @param expected - the composed entry's name, or null when the id is not in
77
+ * the loader.
78
+ */
79
+ export declare function rowFlagApplies(state: PatchState, rowId: string, expected: string | null): boolean;
59
80
  export declare function readUserPatchState(patchPath: string): PatchState;
60
81
  /**
61
82
  * User-authored insert rows that still load `packageName` (or one of its
@@ -166,7 +187,9 @@ export declare function packagePatchFlags(host: PatchHost, profileDirectory: str
166
187
  * a later reinstall off. Duplicates an older version left are folded into
167
188
  * the one block at the same time.
168
189
  */
169
- export declare function disableRow(patchPath: string, rowId: string): Promise<{
190
+ export declare function disableRow(patchPath: string, rowId: string, options?: {
191
+ expectedName?: string | null;
192
+ }): Promise<{
170
193
  ok: boolean;
171
194
  reason: string | null;
172
195
  }>;
@@ -182,6 +205,7 @@ export declare function disableRow(patchPath: string, rowId: string): Promise<{
182
205
  * closed — the host composes later entries last, so the append wins. */
183
206
  export declare function enableRow(patchPath: string, rowId: string, options?: {
184
207
  cleanOnly?: boolean;
208
+ expectedName?: string | null;
185
209
  }): Promise<{
186
210
  ok: boolean;
187
211
  reason: string | null;
@@ -24,3 +24,19 @@ export interface MatureUpdateSelection {
24
24
  export declare function isStableReleaseVersion(value: unknown): value is string;
25
25
  export declare function strictPublishTime(value: unknown): number | null;
26
26
  export declare function selectMatureUpdate(packument: NpmPackument, installed: string | null, now: number, policy: MatureUpdatePolicy): MatureUpdateSelection;
27
+ /**
28
+ * Judge ONE requested version against the same wait policy selectMatureUpdate
29
+ * enforces, without selecting anything. The compatibility dialog names a
30
+ * precise version ("update to 1.7.11: it declares support for this DSH") that
31
+ * the age gate may still hold; the caller needs that fact in prose, not a 409.
32
+ * Fail-closed like its sibling: an exempt package does not make a fabricated
33
+ * or missing timestamp installable, and an unknown policy is not a pass.
34
+ */
35
+ export interface VersionMaturity {
36
+ publishedAt: number | null;
37
+ matureAt: number | null;
38
+ exempt: boolean;
39
+ mature: boolean;
40
+ policyKnown: boolean;
41
+ }
42
+ export declare function versionMaturity(packument: NpmPackument, version: string, now: number, policy: MatureUpdatePolicy): VersionMaturity;
@@ -174,6 +174,25 @@ export interface DesktopMatureResult {
174
174
  }
175
175
  /** Shared fresh registry/policy verification for listing and locked execution. */
176
176
  export declare function resolveDesktopMatureUpdate(name: string, installed: string | null, profile: string, activeProfileDir: string, endpointLatest: string | null, maxVersion?: string): Promise<DesktopMatureResult>;
177
+ /**
178
+ * The maturity of ONE precisely named version, for the compatibility dialog.
179
+ * "You can update to 1.7.11" is only advice; this answers whether that exact
180
+ * version may be installed right now, and if not, when. Never throws: an
181
+ * unreadable policy or an unreachable registry is reported as unknown so the
182
+ * UI can stay quiet instead of promising something the install would refuse.
183
+ */
184
+ export interface RequestedVersionMaturity {
185
+ version: string;
186
+ /** true = installable now, false = held, null = not verifiable here. */
187
+ installable: boolean | null;
188
+ held: boolean;
189
+ exempt: boolean;
190
+ publishedAt: string | null;
191
+ nextMaturityAt: string | null;
192
+ releaseAgeMs: number | null;
193
+ reason: 'eligible' | 'held' | 'unknown-age' | 'policy-unknown' | 'registry-unavailable' | 'unknown-version';
194
+ }
195
+ export declare function readVersionMaturity(name: string, version: string, profile: string, activeProfileDir: string, now?: number): Promise<RequestedVersionMaturity>;
177
196
  /**
178
197
  * Evidence check behind the "wait a day" stale diagnosis (#45): whether the
179
198
  * package's CURRENT latest release was published recently enough to sit
package/lib/updates.js CHANGED
@@ -14,7 +14,7 @@ import { marketFetch } from './net.js';
14
14
  import { publishedReleaseUpdate } from './release-updates.js';
15
15
  import { activeRegion, githubRoutesFor, rememberGithubRoute, throughProxy } from './regions.js';
16
16
  import { isNumericReleaseAgeWindow, readMinimumReleaseAgeMs } from './install.js';
17
- import { isStableReleaseVersion, selectMatureUpdate } from './release-candidates.js';
17
+ import { isStableReleaseVersion, selectMatureUpdate, versionMaturity } from './release-candidates.js';
18
18
  import { hasDshManifest, profileDir, readGitResolutionCommit, readInstalled, readInstalledVersion, readLockCommits, readProfileBundles } from './profile.js';
19
19
  import { userPatchPackageReferences } from './patch.js';
20
20
  import { catalogRepoKey, gitCommitOfTarget, gitRefOfTarget, gitUploadPackUrl, hasSemverSelector, hostedRepoKey, githubCommitOfTarget, githubRefOfTarget, isGenerationLink, isGitHostedSpec, lookupRepoFromUrl, parseGitHubRemote, repoOfTarget } from './sources.js';
@@ -373,6 +373,42 @@ export async function resolveDesktopMatureUpdate(name, installed, profile, activ
373
373
  } }),
374
374
  };
375
375
  }
376
+ export async function readVersionMaturity(name, version, profile, activeProfileDir, now = Date.now()) {
377
+ const unknown = (reason) => ({
378
+ version, installable: null, held: false, exempt: false, publishedAt: null, nextMaturityAt: null, releaseAgeMs: null, reason,
379
+ });
380
+ const windowMs = readMinimumReleaseAgeMs(profile, activeProfileDir);
381
+ const policy = readReleaseAgeExclusions(activeProfileDir, name);
382
+ if (windowMs === null || policy.kind === 'unknown')
383
+ return unknown('policy-unknown');
384
+ // Same two-attempt, cache-busting read as resolveDesktopMatureUpdate: a stale
385
+ // mirror must not be able to make a held version look installable.
386
+ let packument = null;
387
+ for (let attempt = 0; attempt < 2; attempt++) {
388
+ try {
389
+ const suffix = attempt === 0 ? '' : `?t=${String(Date.now())}`;
390
+ packument = (await fetchJson(npmUrl(`${encodeURIComponent(name)}${suffix}`)));
391
+ break;
392
+ }
393
+ catch { /* Retry once against a potentially stale mirror. */ }
394
+ }
395
+ if (packument === null)
396
+ return unknown('registry-unavailable');
397
+ const versions = packument.versions;
398
+ if (typeof versions !== 'object' || versions === null || !Object.hasOwn(versions, version))
399
+ return unknown('unknown-version');
400
+ const maturity = versionMaturity(packument, version, now, { minimumReleaseAgeMs: windowMs, ...policy.exclusions });
401
+ return {
402
+ version,
403
+ installable: maturity.mature,
404
+ held: !maturity.mature,
405
+ exempt: maturity.exempt,
406
+ publishedAt: maturity.publishedAt === null ? null : new Date(maturity.publishedAt).toISOString(),
407
+ nextMaturityAt: maturity.matureAt === null ? null : new Date(maturity.matureAt).toISOString(),
408
+ releaseAgeMs: windowMs,
409
+ reason: maturity.mature ? 'eligible' : maturity.publishedAt === null ? 'unknown-age' : 'held',
410
+ };
411
+ }
376
412
  async function fetchJson(url) {
377
413
  // Through the proxy when one is configured: Node's global fetch ignores
378
414
  // HTTP_PROXY, so on a machine whose route out is a local proxy every
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dshmarket",
3
3
  "description": "Visual plugin market inside DeepSeek Harness — browse, search, and one-click install community plugins. · DSH 可视化插件市场:逛一逛,点一下,装好。",
4
- "version": "1.73.13",
4
+ "version": "1.73.14",
5
5
  "icon": "assets/logo.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",