dsh-update-status 0.4.8 → 0.5.1

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/lib/index.d.ts CHANGED
@@ -26,17 +26,16 @@ interface UpdateStatusConfig {
26
26
  export declare const Config: z<UpdateStatusConfig, Record<string, unknown>>;
27
27
  //#endregion
28
28
  //#region src/shared/types.d.ts
29
- type ReleaseCompatibility = 'verified' | 'unverified' | 'incompatible';
30
29
  /**
31
30
  * Severity of `warning`, so a surface can tell "the plugin could not determine
32
31
  * the update state" from "here is something worth knowing".
33
32
  *
34
33
  * - `failure`: no usable answer — a failed registry read, or a version SemVer
35
34
  * cannot compare. This is what justifies repainting the sidebar chip.
36
- * - `notice`: the answer is complete and usable; the text is advisory, e.g. a
37
- * newer release this bundle has not been verified against. The chip must NOT
38
- * repaint for this — an operator upgrading DSH ahead of the plugin would
39
- * otherwise see the chip turn red for a plugin-side bookkeeping fact.
35
+ * - `notice`: the answer is complete and usable; the text is advisory, e.g. the
36
+ * Host resolved a stale copy of a shared library. The chip must NOT repaint for
37
+ * this — an operator upgrading DSH ahead of the plugin would otherwise see the
38
+ * chip turn red for a plugin-side bookkeeping fact.
40
39
  *
41
40
  * Optional on purpose: a Host older than this field leaves it `undefined`, and
42
41
  * the client then falls back to treating any warning as a failure.
@@ -52,11 +51,6 @@ type UpdateWarning = {
52
51
  currentVersion: string;
53
52
  latestVersion: string;
54
53
  } |
55
- /** A newer release exists, but this bundle has not been tested against it. */
56
- {
57
- code: 'version-unverified';
58
- version: string;
59
- } |
60
54
  /**
61
55
  * The Host resolved a `@deepseek-ai/schemastery` that DSH does not ship, so the
62
56
  * Loader's volatile projection is unavailable and the preference fields cannot
@@ -69,6 +63,24 @@ type UpdateWarning = {
69
63
  path: string;
70
64
  nodeModulesDir: string | null;
71
65
  };
66
+ /**
67
+ * One published version that is newer than the running one.
68
+ *
69
+ * The plugin's only job is to say "a newer version exists, here is how to get
70
+ * it", so a candidate carries the version, the npm dist-tag that publishes it,
71
+ * when it was published, its release line, and a copy-only command when the
72
+ * detected installation kind actually accepts one.
73
+ */
74
+ interface ReleaseCandidate {
75
+ version: string;
76
+ /** The npm dist-tag carrying this version; null when the Host could not tell. */
77
+ tag: string | null;
78
+ publishedAt: string | null;
79
+ /** Numeric release line, e.g. `0.2.1` for `0.2.1-rc.4`. */
80
+ line: string;
81
+ /** Copy-only upgrade command, or null when this installation cannot be upgraded that way. */
82
+ command: string | null;
83
+ }
72
84
  /**
73
85
  * A lossless, JSON-serializable snapshot used by both browser surfaces.
74
86
  * Nulls are intentional: a failed first check must still render a truthful
@@ -76,11 +88,12 @@ type UpdateWarning = {
76
88
  */
77
89
  interface UpdateStatus {
78
90
  currentVersion: string;
79
- /** Newest version the registry publishes under any dist-tag; null when unknown. */
80
- latestVersion: string | null;
91
+ /**
92
+ * Every published version strictly newer than `currentVersion`, highest first.
93
+ * Empty means "you are on the newest published version" — never a placeholder.
94
+ */
95
+ releases: ReleaseCandidate[];
81
96
  hasUpdate: boolean;
82
- /** Whether this bundle was verified against `latestVersion`. */
83
- compatibility: ReleaseCompatibility;
84
97
  cached: boolean;
85
98
  checkedAt: string | null;
86
99
  /** English fallback for older clients; current clients localize `warnings`. */
@@ -90,10 +103,8 @@ interface UpdateStatus {
90
103
  /** Structured warning facts; absent from a Host older than this field. */
91
104
  warnings?: UpdateWarning[];
92
105
  installKind: InstallKind;
93
- upgradeCommand: string;
94
106
  releaseUrl: string;
95
107
  changelogUrl: string;
96
- publishedAt: string | null;
97
108
  packageName: string;
98
109
  /** Phase 1 is informational only; the GUI must never apply an update. */
99
110
  canApplyInPlace: false;
@@ -108,16 +119,17 @@ interface InstallationInfo {
108
119
  }
109
120
  //#endregion
110
121
  //#region src/host/update-status.d.ts
111
- /** The newest release the registry publishes, with everything the UI shows. */
112
- interface RegistryLatest {
122
+ /** One tagged version from the registry, before it is compared with the running version. */
123
+ interface RegistryCandidate {
113
124
  version: string;
125
+ tag: string | null;
114
126
  publishedAt: string | null;
115
- compatibility: ReleaseCompatibility;
116
127
  }
117
- interface RegistryRelease {
118
- latest: RegistryLatest | null;
128
+ /** Every version the registry publishes under a dist-tag, newest first. */
129
+ interface RegistrySnapshot {
130
+ releases: RegistryCandidate[];
119
131
  }
120
- type RegistryFetcher = () => Promise<RegistryRelease>;
132
+ type RegistryFetcher = () => Promise<RegistrySnapshot>;
121
133
  interface UpdateStatusServiceOptions {
122
134
  installation: InstallationInfo;
123
135
  fetchLatest?: RegistryFetcher;
@@ -143,7 +155,7 @@ export declare class UpdateStatusService {
143
155
  getStatus(cacheTtlMinutes?: number): Promise<UpdateStatus>;
144
156
  /** `force` bypasses TTL but still joins any registry check already in flight. */
145
157
  check(force?: boolean, cacheTtlMinutes?: number): Promise<UpdateStatus>;
146
- private refreshRelease;
158
+ private refreshReleases;
147
159
  private statusAfterFailure;
148
160
  private statusFromCache;
149
161
  private statusWithoutRemoteRelease;
package/lib/index.js CHANGED
@@ -9,26 +9,6 @@ import { execFile } from "node:child_process";
9
9
  const PACKAGE_NAME = "@deepseek-ai/dsh";
10
10
  /** Shared Connection RPC channel. Custom prefixes 405 on the SPA fallback. */
11
11
  const UPDATE_STATUS_CHANNEL = "/api";
12
- /**
13
- * DSH releases this bundle has actually been verified against. The same list is
14
- * declared in package.json's `dsh.compatibility.dshReleases`, and every other
15
- * release the registry reports stays `unverified` — the plugin never claims a
16
- * compatibility nobody checked.
17
- */
18
- const VERIFIED_DSH_VERSIONS = [
19
- "0.1.7-alpha.2",
20
- "0.1.7-rc.1",
21
- "0.1.7-rc.2",
22
- "0.2.0-rc.1",
23
- "0.2.0-rc.2",
24
- "0.2.1-alpha.1",
25
- "0.2.1-alpha.3",
26
- "0.2.1-alpha.4",
27
- "0.2.1-alpha.5",
28
- "0.2.1-rc.2",
29
- "0.2.1-rc.3",
30
- "0.2.1-rc.4"
31
- ];
32
12
  function isCacheTtlMinutes(value) {
33
13
  return typeof value === "number" && Number.isInteger(value) && value >= 30 && value <= 1440;
34
14
  }
@@ -1227,21 +1207,6 @@ function compareSemver(leftValue, rightValue) {
1227
1207
  }
1228
1208
  return 0;
1229
1209
  }
1230
- /**
1231
- * Highest version in a list, preserving the spelling of the winner.
1232
- *
1233
- * Unparsable entries are skipped rather than failing the whole list: a registry
1234
- * that adds one odd tag must not hide the release line behind it. Returns
1235
- * undefined when nothing in the list is valid SemVer.
1236
- */
1237
- function newestSemver(versions) {
1238
- let winner;
1239
- for (const candidate of versions) {
1240
- if (parseSemver(candidate) === void 0) continue;
1241
- if (winner === void 0 || compareSemver(candidate, winner) > 0) winner = candidate;
1242
- }
1243
- return winner;
1244
- }
1245
1210
  //#endregion
1246
1211
  //#region src/host/update-status.ts
1247
1212
  const REGISTRY_URL = "https://registry.npmjs.org/@deepseek-ai%2Fdsh";
@@ -1256,7 +1221,6 @@ function describeWarning(warning) {
1256
1221
  switch (warning.code) {
1257
1222
  case "registry-unavailable": return `Unable to check the npm registry: ${warning.detail}`;
1258
1223
  case "version-incomparable": return `Unable to compare the current version ${warning.currentVersion} with the published version ${warning.latestVersion} using SemVer.`;
1259
- case "version-unverified": return `Version ${warning.version} is newer than this plugin has been verified against.`;
1260
1224
  case "stale-schemastery": {
1261
1225
  const version = warning.version === null ? "" : ` ${warning.version}`;
1262
1226
  const remedy = warning.nodeModulesDir === null ? `Remove the stale ${SCHEMASTERY_NAME} directory there and restart DSH.` : `Remove the stale copy and restart DSH: rm -rf ${warning.nodeModulesDir}`;
@@ -1274,7 +1238,7 @@ function warningFallback(warnings) {
1274
1238
  * and only the settings form is degraded, so repainting the brand row would
1275
1239
  * misreport a plugin-runtime fact as a failed update check.
1276
1240
  */
1277
- const ADVISORY_CODES = ["version-unverified", "stale-schemastery"];
1241
+ const ADVISORY_CODES = ["stale-schemastery"];
1278
1242
  function warningKindOf(warnings) {
1279
1243
  if (warnings.length === 0) return null;
1280
1244
  return warnings.every((warning) => ADVISORY_CODES.includes(warning.code)) ? "notice" : "failure";
@@ -1284,29 +1248,62 @@ function dateOrNull(value) {
1284
1248
  const time = Date.parse(value);
1285
1249
  return Number.isFinite(time) ? new Date(time).toISOString() : null;
1286
1250
  }
1287
- function compatibilityOf(version) {
1288
- return VERIFIED_DSH_VERSIONS.includes(version) ? "verified" : "unverified";
1251
+ /** The numeric release line of a version: `0.2.1-rc.4` belongs to line `0.2.1`. */
1252
+ function releaseLineOf(version) {
1253
+ return version.split("-", 1)[0] ?? version;
1254
+ }
1255
+ /** Tag preference when two tags point at the same version; npm's own vocabulary leads. */
1256
+ const TAG_PRIORITY = [
1257
+ "latest",
1258
+ "next",
1259
+ "alpha",
1260
+ "beta",
1261
+ "rc"
1262
+ ];
1263
+ function preferredTag(left, right) {
1264
+ const rank = (tag) => {
1265
+ const index = TAG_PRIORITY.indexOf(tag);
1266
+ return index === -1 ? TAG_PRIORITY.length : index;
1267
+ };
1268
+ return rank(left) <= rank(right) ? left : right;
1289
1269
  }
1290
1270
  /**
1291
- * Reduce one registry document to the single newest release.
1271
+ * Reduce one registry document to every tagged version, newest first.
1292
1272
  *
1293
1273
  * Every dist-tag contributes, not a fixed `latest`/`next`/`alpha` triple: npm
1294
1274
  * tags are the registry's own vocabulary, and a version published under a tag
1295
- * this plugin has never heard of is still a version users can install.
1275
+ * this plugin has never heard of is still a version users can install. A version
1276
+ * carried by several tags keeps the most specific tag name (latest > next >
1277
+ * alpha > …), and an unparsable version is dropped rather than rendered as a
1278
+ * card nobody can compare.
1296
1279
  */
1297
- function registryReleaseOf(value) {
1280
+ function registryReleasesOf(value) {
1298
1281
  if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("npm registry returned an invalid document");
1299
1282
  const record = value;
1300
1283
  const tags = record["dist-tags"];
1301
1284
  if (tags === null || typeof tags !== "object" || Array.isArray(tags)) throw new Error("npm registry response has no dist-tags");
1302
- const version = newestSemver(Object.values(tags).filter((version) => typeof version === "string" && version.trim() !== "").map((version) => version.trim()));
1303
- if (version === void 0) throw new Error("npm registry response has no comparable dist-tags");
1304
1285
  const time = record.time;
1305
- return { latest: {
1306
- version,
1307
- publishedAt: dateOrNull((time !== null && typeof time === "object" && !Array.isArray(time) ? time : {})[version]),
1308
- compatibility: compatibilityOf(version)
1309
- } };
1286
+ const timeRecord = time !== null && typeof time === "object" && !Array.isArray(time) ? time : {};
1287
+ /** version -> tag, keeping one deterministic tag per version. */
1288
+ const byVersion = /* @__PURE__ */ new Map();
1289
+ for (const [tag, raw] of Object.entries(tags)) {
1290
+ if (typeof raw !== "string" || raw.trim() === "") continue;
1291
+ const version = raw.trim();
1292
+ const existing = byVersion.get(version);
1293
+ byVersion.set(version, existing === void 0 ? tag : preferredTag(existing, tag));
1294
+ }
1295
+ const releases = [];
1296
+ for (const [version, tag] of byVersion) {
1297
+ if (parseSemver(version) === void 0) continue;
1298
+ releases.push({
1299
+ version,
1300
+ tag,
1301
+ publishedAt: dateOrNull(timeRecord[version])
1302
+ });
1303
+ }
1304
+ releases.sort((left, right) => compareSemver(right.version, left.version) ?? 0);
1305
+ if (releases.length === 0) throw new Error("npm registry response has no comparable dist-tags");
1306
+ return { releases };
1310
1307
  }
1311
1308
  /** Only the explicitly approved HTTPS npm Registry authority may be contacted. */
1312
1309
  function assertApprovedRegistryUrl(raw) {
@@ -1331,7 +1328,7 @@ function createRegistryFetcher(timeoutMs = DEFAULT_TIMEOUT_MS) {
1331
1328
  headers: { accept: "application/json" }
1332
1329
  });
1333
1330
  if (!response.ok) throw new Error(`npm registry returned HTTP ${response.status}`);
1334
- return registryReleaseOf(await response.json());
1331
+ return registryReleasesOf(await response.json());
1335
1332
  } catch (error) {
1336
1333
  if (controller.signal.aborted) throw new Error(`npm registry timed out after ${boundedTimeout}ms`);
1337
1334
  throw error;
@@ -1340,6 +1337,15 @@ function createRegistryFetcher(timeoutMs = DEFAULT_TIMEOUT_MS) {
1340
1337
  }
1341
1338
  };
1342
1339
  }
1340
+ /**
1341
+ * A copyable command is only honest for a package-manager installation; a source
1342
+ * checkout and an unknown installation get guidance text instead of a command
1343
+ * that would not work.
1344
+ */
1345
+ function copyableCommand(installation, version) {
1346
+ if (installation.installKind !== "npm-global" && installation.installKind !== "pnpm-global") return null;
1347
+ return upgradeCommandFor(installation.installKind, installation.packageName || "@deepseek-ai/dsh", version);
1348
+ }
1343
1349
  var UpdateStatusService = class {
1344
1350
  installation;
1345
1351
  fetchLatest;
@@ -1370,7 +1376,7 @@ var UpdateStatusService = class {
1370
1376
  } catch (error) {
1371
1377
  return this.statusAfterFailure(error);
1372
1378
  }
1373
- const run = this.refreshRelease();
1379
+ const run = this.refreshReleases();
1374
1380
  this.inFlight = run;
1375
1381
  try {
1376
1382
  return this.statusFromCache(await run, false, []);
@@ -1380,9 +1386,9 @@ var UpdateStatusService = class {
1380
1386
  if (this.inFlight === run) this.inFlight = void 0;
1381
1387
  }
1382
1388
  }
1383
- async refreshRelease() {
1389
+ async refreshReleases() {
1384
1390
  const cache = {
1385
- release: await this.fetchLatest(),
1391
+ releases: (await this.fetchLatest()).releases,
1386
1392
  checkedAtMs: this.now()
1387
1393
  };
1388
1394
  this.cache = cache;
@@ -1396,35 +1402,43 @@ var UpdateStatusService = class {
1396
1402
  return this.cache === void 0 ? this.statusWithoutRemoteRelease(warnings) : this.statusFromCache(this.cache, true, warnings);
1397
1403
  }
1398
1404
  statusFromCache(cache, cached, initialWarnings) {
1399
- const selected = cache.release.latest;
1400
- const comparison = selected === null ? void 0 : compareSemver(this.installation.currentVersion, selected.version);
1401
- const hasUpdate = comparison !== void 0 && comparison < 0;
1405
+ const current = this.installation.currentVersion;
1402
1406
  const warnings = [...initialWarnings];
1403
- if (selected !== null && comparison === void 0) warnings.push({
1404
- code: "version-incomparable",
1405
- currentVersion: this.installation.currentVersion,
1406
- latestVersion: selected.version
1407
- });
1408
- if (hasUpdate && selected !== null && selected.compatibility !== "verified") warnings.push({
1409
- code: "version-unverified",
1410
- version: selected.version
1411
- });
1407
+ const releases = [];
1408
+ if (parseSemver(current) === void 0) {
1409
+ const newest = cache.releases[0];
1410
+ if (newest !== void 0) warnings.push({
1411
+ code: "version-incomparable",
1412
+ currentVersion: current,
1413
+ latestVersion: newest.version
1414
+ });
1415
+ } else {
1416
+ for (const candidate of cache.releases) {
1417
+ const comparison = compareSemver(current, candidate.version);
1418
+ if (comparison === void 0 || comparison >= 0) continue;
1419
+ releases.push({
1420
+ version: candidate.version,
1421
+ tag: candidate.tag,
1422
+ publishedAt: candidate.publishedAt,
1423
+ line: releaseLineOf(candidate.version),
1424
+ command: copyableCommand(this.installation, candidate.version)
1425
+ });
1426
+ }
1427
+ releases.sort((left, right) => compareSemver(right.version, left.version) ?? 0);
1428
+ }
1412
1429
  warnings.push(...this.runtimeWarnings);
1413
1430
  return {
1414
- currentVersion: this.installation.currentVersion,
1415
- latestVersion: selected?.version ?? null,
1416
- hasUpdate,
1417
- compatibility: selected?.compatibility ?? "unverified",
1431
+ currentVersion: current,
1432
+ releases,
1433
+ hasUpdate: releases.length > 0,
1418
1434
  cached,
1419
1435
  checkedAt: new Date(cache.checkedAtMs).toISOString(),
1420
1436
  warning: warningFallback(warnings),
1421
1437
  warningKind: warningKindOf(warnings),
1422
1438
  warnings,
1423
1439
  installKind: this.installation.installKind,
1424
- upgradeCommand: upgradeCommandFor(this.installation.installKind, this.installation.packageName || "@deepseek-ai/dsh", selected?.version ?? null),
1425
1440
  releaseUrl: this.releaseUrl,
1426
1441
  changelogUrl: this.releaseUrl,
1427
- publishedAt: selected?.publishedAt ?? null,
1428
1442
  packageName: this.installation.packageName || "@deepseek-ai/dsh",
1429
1443
  canApplyInPlace: false
1430
1444
  };
@@ -1433,19 +1447,16 @@ var UpdateStatusService = class {
1433
1447
  const combined = [...warnings, ...this.runtimeWarnings];
1434
1448
  return {
1435
1449
  currentVersion: this.installation.currentVersion,
1436
- latestVersion: null,
1450
+ releases: [],
1437
1451
  hasUpdate: false,
1438
- compatibility: "unverified",
1439
1452
  cached: false,
1440
1453
  checkedAt: null,
1441
1454
  warning: warningFallback(combined),
1442
1455
  warningKind: warningKindOf(combined),
1443
1456
  warnings: combined,
1444
1457
  installKind: this.installation.installKind,
1445
- upgradeCommand: upgradeCommandFor(this.installation.installKind, this.installation.packageName || "@deepseek-ai/dsh", null),
1446
1458
  releaseUrl: this.releaseUrl,
1447
1459
  changelogUrl: this.releaseUrl,
1448
- publishedAt: null,
1449
1460
  packageName: this.installation.packageName || "@deepseek-ai/dsh",
1450
1461
  canApplyInPlace: false
1451
1462
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-update-status",
3
- "version": "0.4.8",
3
+ "version": "0.5.1",
4
4
  "description": "DeepSeek Harness Web plugin for version status, copy-only upgrade guidance, and safe restart when an explicit user-level supervisor is installed.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -63,22 +63,6 @@
63
63
  "@deepseek-ai/dsh-client-ui-settings",
64
64
  "@deepseek-ai/dsh-client-ui-settings-general"
65
65
  ]
66
- },
67
- "compatibility": {
68
- "dshReleases": {
69
- "0.1.7-alpha.2": "compatible",
70
- "0.1.7-rc.1": "compatible",
71
- "0.1.7-rc.2": "compatible",
72
- "0.2.0-rc.1": "compatible",
73
- "0.2.0-rc.2": "compatible",
74
- "0.2.1-alpha.1": "compatible",
75
- "0.2.1-alpha.3": "compatible",
76
- "0.2.1-alpha.4": "compatible",
77
- "0.2.1-alpha.5": "compatible",
78
- "0.2.1-rc.2": "compatible",
79
- "0.2.1-rc.3": "compatible",
80
- "0.2.1-rc.4": "compatible"
81
- }
82
66
  }
83
67
  },
84
68
  "keywords": [
@@ -96,9 +80,9 @@
96
80
  "@deepseek-ai/schemastery": "^3.18.4"
97
81
  },
98
82
  "devDependencies": {
99
- "@deepseek-ai/cordis": "^4.0.4",
100
- "@deepseek-ai/dsh-settings": "0.1.7-alpha.2",
101
- "@deepseek-ai/schemastery": "^3.18.4",
83
+ "@deepseek-ai/cordis": "^4.1.0",
84
+ "@deepseek-ai/dsh-settings": "0.2.2-rc.3",
85
+ "@deepseek-ai/schemastery": "^3.19.0",
102
86
  "@types/node": "^26.2.0",
103
87
  "@types/react": "^18.3.31",
104
88
  "react": "^18.3.1",