dsh-crate 0.5.3 → 0.5.4

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.
Files changed (40) hide show
  1. package/client/client.js +2060 -459
  2. package/lib/body-progress.js +4 -3
  3. package/lib/changelog.js +15 -2
  4. package/lib/discovery-cache.js +210 -0
  5. package/lib/discovery-compatibility.js +91 -93
  6. package/lib/dsh-cli.js +36 -6
  7. package/lib/github-install-target.js +53 -0
  8. package/lib/hot.js +361 -27
  9. package/lib/index.js +6 -5
  10. package/lib/install.js +37 -0
  11. package/lib/patch.js +116 -72
  12. package/lib/pending-rows.js +3 -4
  13. package/lib/pnpm-compat.js +79 -1
  14. package/lib/proc-text.js +16 -1
  15. package/lib/recovery.js +2 -1
  16. package/lib/registry.js +24 -16
  17. package/lib/release-candidates.js +4 -0
  18. package/lib/routes.js +390 -131
  19. package/lib/themes.js +24 -8
  20. package/lib/types/body-progress.d.ts +2 -1
  21. package/lib/types/changelog.d.ts +10 -1
  22. package/lib/types/discovery-cache.d.ts +38 -0
  23. package/lib/types/discovery-compatibility.d.ts +16 -12
  24. package/lib/types/dsh-cli.d.ts +19 -2
  25. package/lib/types/github-install-target.d.ts +11 -0
  26. package/lib/types/hot.d.ts +87 -5
  27. package/lib/types/install.d.ts +19 -0
  28. package/lib/types/patch.d.ts +6 -2
  29. package/lib/types/registry.d.ts +9 -8
  30. package/lib/types/release-candidates.d.ts +2 -0
  31. package/lib/types/routes.d.ts +2 -2
  32. package/lib/types/themes.d.ts +7 -1
  33. package/lib/types/update-notification-settings.d.ts +5 -0
  34. package/lib/types/update-notifications.d.ts +51 -0
  35. package/lib/types/updates.d.ts +5 -1
  36. package/lib/update-notification-settings.js +6 -0
  37. package/lib/update-notifications.js +166 -0
  38. package/lib/updates.js +41 -11
  39. package/lib/verify.js +5 -2
  40. package/package.json +1 -1
package/lib/themes.js CHANGED
@@ -7,7 +7,7 @@
7
7
  import { readFileSync } from 'node:fs';
8
8
  import { join } from 'node:path';
9
9
  import { loadRegistry, pluginCategories } from './registry.js';
10
- import { hotMount, hotUnmount, listHotMounts, writeDisabled } from './hot.js';
10
+ import { hotMount, hotMountFailure, hotUnmount, listHotMounts, writeDisabled } from './hot.js';
11
11
  import { logEvent } from './log.js';
12
12
  import { loaderEntryId } from './patch.js';
13
13
  import { LifecyclePendingError, LifecycleWaitError, waitForLifecycle } from './lifecycle.js';
@@ -329,6 +329,7 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
329
329
  * set is what lets the next attempt try it again.
330
330
  */
331
331
  async function activateTheme(name) {
332
+ const stopFailedMount = async (theme) => !listHotMounts().includes(theme) || await hotUnmount(theme);
332
333
  const themes = await installedThemeNames();
333
334
  const stopped = [];
334
335
  for (const other of themes) {
@@ -346,22 +347,37 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
346
347
  }
347
348
  disabledThemes.delete(name);
348
349
  writeDisabled(activeProfileDir, disabledThemes);
349
- const live = listHotMounts().includes(name)
350
- || await setEntryDisabled(name, false)
351
- || (await hotMount(host, activeProfileDir, name)).ok;
352
- if (live)
353
- return true;
350
+ let reason;
351
+ if (listHotMounts().includes(name)) {
352
+ reason = hotMountFailure(name, activeProfileDir);
353
+ if (reason === null)
354
+ return { ok: true };
355
+ }
356
+ else {
357
+ if (await setEntryDisabled(name, false))
358
+ return { ok: true };
359
+ const mount = await hotMount(host, activeProfileDir, name);
360
+ if (mount.ok)
361
+ return { ok: true };
362
+ reason = mount.retained === true ? mount.reason : null;
363
+ }
364
+ const failure = reason === null ? { ok: false } : { ok: false, reason };
365
+ if (!await stopFailedMount(name))
366
+ return failure;
354
367
  for (const previous of stopped) {
355
368
  const back = previous.kind === 'hot'
356
369
  ? (await hotMount(host, activeProfileDir, previous.name)).ok
357
370
  : await setEntryDisabled(previous.name, false);
358
371
  if (back)
359
372
  disabledThemes.delete(previous.name);
360
- else
373
+ else {
361
374
  logEvent('warn', 'theme', `${previous.name}: could not be restored after ${name} failed to start`);
375
+ if (previous.kind === 'hot' && !await stopFailedMount(previous.name))
376
+ break;
377
+ }
362
378
  }
363
379
  writeDisabled(activeProfileDir, disabledThemes);
364
- return false;
380
+ return failure;
365
381
  }
366
382
  return { installedThemeNames, setEntryDisabled, activateTheme };
367
383
  }
@@ -70,8 +70,9 @@ export declare const MAX_BODY_BYTES: number;
70
70
  * @param res - the response whose body to read.
71
71
  * @param stallMs - silence that ends the read, in milliseconds.
72
72
  * @param what - the download, for the rejection message ("the catalog").
73
+ * @param maxBytes - maximum decoded response size.
73
74
  */
74
- export declare function readBodyWhileProgressing(res: Response, stallMs: number, what?: string): Promise<Uint8Array>;
75
+ export declare function readBodyWhileProgressing(res: Response, stallMs: number, what?: string, maxBytes?: number): Promise<Uint8Array>;
75
76
  /**
76
77
  * Fetch with a headers-only deadline, then hand the body to the watchdog.
77
78
  *
@@ -112,6 +112,13 @@ export interface UpdateNotes {
112
112
  }[];
113
113
  /** Present for `source`: the repository page to read changes on, or null. */
114
114
  sourceUrl?: string | null;
115
+ /**
116
+ * Present for `release` when the notes describe a version NEWER than the
117
+ * one the Update button installs (#1193): the snapshot is the repository's
118
+ * latest release, while the target may be an older, already installable
119
+ * one. Carries that target so the dialog can say whose notes these are.
120
+ */
121
+ beyondTarget?: string;
115
122
  /**
116
123
  * Present for `source`: `missing` when the notes loaded without this
117
124
  * plugin, `unavailable` when they could not be loaded at all — a passing
@@ -127,5 +134,7 @@ export interface UpdateNotes {
127
134
  * same contract the issue promised — a dialog that cannot load its data shows
128
135
  * a neutral statement, not an error.
129
136
  */
130
- export declare function updateNotesFor(profile: string, explicitDir: string | undefined, name: string): Promise<UpdateNotes>;
137
+ export declare function updateNotesFor(profile: string, explicitDir: string | undefined, name: string,
138
+ /** The version the Update button installs, when it is not simply "latest". */
139
+ target?: string): Promise<UpdateNotes>;
131
140
  export {};
@@ -0,0 +1,38 @@
1
+ import type { NpmManifestFacts } from './discovery-compatibility.ts';
2
+ export interface CacheEntry {
3
+ checkedAt: number;
4
+ facts: NpmManifestFacts;
5
+ }
6
+ type DecodeEntry = (raw: unknown) => CacheEntry | null;
7
+ /**
8
+ * A single writer and shared view per cache path. The old JSON remains readable
9
+ * until a complete journal has been published. Later writes append only the
10
+ * changed rows, with occasional atomic snapshots to bound the log.
11
+ */
12
+ declare class DiscoveryCache {
13
+ private readonly file;
14
+ private readonly decode;
15
+ private readonly journal;
16
+ private readonly entries;
17
+ private readonly pending;
18
+ private loaded;
19
+ private timer;
20
+ private writing;
21
+ private journalRows;
22
+ private canAppend;
23
+ private retryMs;
24
+ private owners;
25
+ constructor(file: string, decode: DecodeEntry);
26
+ acquire(): void;
27
+ release(): Promise<void>;
28
+ private restore;
29
+ private ready;
30
+ get(key: string): Promise<CacheEntry | undefined>;
31
+ set(key: string, entry: CacheEntry): void;
32
+ private trim;
33
+ private schedule;
34
+ private flushOnce;
35
+ private write;
36
+ }
37
+ export declare function openDiscoveryCache(file: string, decode: DecodeEntry): DiscoveryCache;
38
+ export {};
@@ -41,8 +41,11 @@ type FetchLike = (url: string, init?: {
41
41
  export interface GitHubManifestSource {
42
42
  url: string;
43
43
  tarball?: string | null;
44
+ version?: string | null;
44
45
  releaseManifest?: unknown;
45
46
  }
47
+ /** Only the selected artifact and its declarations determine a discovery verdict. */
48
+ export declare function githubCompatibilityRevision(source: GitHubManifestSource): string;
46
49
  /** Reuse catalog facts only for this repository's exact pinned install asset. */
47
50
  export declare function catalogReleaseManifest(source: GitHubManifestSource): NpmManifestFacts | null;
48
51
  /** Keep only the small public subset of an npm manifest needed by discovery. */
@@ -56,24 +59,22 @@ export declare function manifestFacts(value: unknown): NpmManifestFacts;
56
59
  */
57
60
  export declare function deriveHostCompatibility(facts: NpmManifestFacts | null, hostVersion: string | null, hostPackages: ReadonlySet<string>): HostCompatibility;
58
61
  /**
59
- * Durable, bounded lookup of npm `latest` and catalog GitHub manifests.
62
+ * Durable, bounded lookup of npm releases and catalog GitHub manifests.
60
63
  *
61
64
  * Failed requests are intentionally memory-only and short-lived: a mirror
62
65
  * outage must not become a day-long false "undeclared" result on disk.
63
66
  */
64
67
  export declare class DiscoveryManifestIndex {
65
- private readonly cacheFile;
66
- private readonly entries;
68
+ private readonly cache;
67
69
  private readonly failures;
68
70
  private readonly inflight;
69
71
  private readonly fetcher;
70
72
  private readonly now;
71
73
  private readonly ttlMs;
72
74
  private readonly concurrency;
73
- private loaded;
74
75
  private consecutiveFailures;
75
76
  private unavailableUntil;
76
- private dirty;
77
+ private disposed;
77
78
  private activeFetches;
78
79
  private readonly fetchWaiters;
79
80
  constructor(cacheFile: string, options?: {
@@ -82,11 +83,15 @@ export declare class DiscoveryManifestIndex {
82
83
  ttlMs?: number;
83
84
  concurrency?: number;
84
85
  });
85
- private load;
86
- private persist;
86
+ /** Unmount this index, retaining any writes already queued for this profile. */
87
+ dispose(): Promise<void>;
87
88
  /** One semaphore for the whole index, including overlapping HTTP batches. */
88
89
  private withFetchPermit;
90
+ private retryDelay;
91
+ npmRetryAfterMs(name: string, registry: string, version: string | undefined): number;
92
+ githubRetryAfterMs(source: GitHubManifestSource): number;
89
93
  private fetchOne;
94
+ private readNpmManifest;
90
95
  /**
91
96
  * Facts for ONE named release, rather than for `latest`.
92
97
  *
@@ -98,11 +103,9 @@ export declare class DiscoveryManifestIndex {
98
103
  * release declares a range this host misses), and it would equally pass a
99
104
  * pinned release that is itself incompatible.
100
105
  *
101
- * Deliberately outside the cache. The index is keyed by package name, and a
102
- * version-keyed one would grow with every release anyone ever pinned to
103
- * answer a question asked once per install. Nothing is recorded either: a
104
- * pre-flight verdict must not decide what the diagnostics panel sees next
105
- * (#619).
106
+ * Deliberately outside the cache. An install can target any old release,
107
+ * whereas a discovery query is for the version shown in the catalog. A
108
+ * pre-flight verdict must not decide what the diagnostics panel sees next (#619).
106
109
  *
107
110
  * A release whose manifest cannot be read is `null`, like every other
108
111
  * unreadable manifest: absence of a claim is not a verdict.
@@ -119,6 +122,7 @@ export declare class DiscoveryManifestIndex {
119
122
  */
120
123
  lookup(names: readonly string[], registry: string, options?: {
121
124
  record?: boolean;
125
+ versions?: ReadonlyMap<string, string>;
122
126
  }): Promise<Record<string, NpmManifestFacts | null>>;
123
127
  /** Catalog-approved GitHub sources, cached by both package path and selected archive. */
124
128
  lookupGitHub(sources: readonly GitHubManifestSource[]): Promise<Record<string, NpmManifestFacts | null>>;
@@ -452,13 +452,30 @@ export declare const BOOT_ID: string;
452
452
  * it (defense in depth on top of per-route validation — the win32 bare-dsh
453
453
  * fallback runs through a shell). Suggested in #16 by @anupamme.
454
454
  *
455
- * `^`, `~` and `=` are intentionally allowed: restore/install flows turn
456
- * manifest specs such as "dsh-better-sidebar": "^0.14.0" into targets like
455
+ * `^`, `~` and `=`: restore/install flows turn manifest specs such as
456
+ * "dsh-better-sidebar": "^0.14.0" into targets like
457
457
  * `dsh-better-sidebar@^0.14.0`, and regex-valid semver ranges must not be
458
458
  * mistaken for shell injection (whitespace and shell metacharacters remain
459
459
  * rejected — the win32 bare-dsh fallback is the reason to keep them out).
460
+ *
461
+ * `&` is deliberately absent: a bare `&` backgrounds the child and must stay
462
+ * rejected. The one shape that needs it — pnpm's monorepo selector,
463
+ * `#<ref>&path:/packages/x` — is admitted by `isSafePluginTarget` instead.
460
464
  */
461
465
  export declare const TARGET_RE: RegExp;
466
+ /**
467
+ * Whether one plugin target is safe to hand to a spawned pnpm.
468
+ *
469
+ * A target is safe when `TARGET_RE` accepts it whole, or when it is that same
470
+ * allowlisted head followed only by `&path:` selectors. pnpm spells a
471
+ * monorepo subdirectory as `github:owner/repo#<ref>&path:/packages/x`, which
472
+ * `TARGET_RE` alone rejects — every GitHub subpath install then failed as
473
+ * "unsafe plugin target".
474
+ *
475
+ * @param target - the last argv element the caller built.
476
+ * @returns true when no segment could be read as a shell separator.
477
+ */
478
+ export declare function isSafePluginTarget(target: string): boolean;
462
479
  /**
463
480
  * Run the host-supplied package manager in a profile directory.
464
481
  *
@@ -0,0 +1,11 @@
1
+ import { type Region } from './regions.ts';
2
+ /**
3
+ * A package-like catalog name can point to the workspace root by mistake
4
+ * (#1208). Check a commit's manifest before handing that root to the host:
5
+ * Desktop can unpack it before refusing a package with no bundle.
6
+ *
7
+ * The curated catalog also lists entire collections (#18) and uses display
8
+ * names for ordinary Git plugins. Only a declared workspace with no DSH
9
+ * surface and a different root name gives enough evidence to refuse the add.
10
+ */
11
+ export declare function mismatchedWorkspaceRoot(target: string, name: string, region: Region): Promise<string | null>;
@@ -15,6 +15,7 @@
15
15
  * tree changes back to the file it read (see dsh's agent-presets PresetTree
16
16
  * for the in-tree precedent).
17
17
  */
18
+ import { type UpdateCheckIntervalHours } from './update-notification-settings.ts';
18
19
  import { type Channel } from './channels.ts';
19
20
  import { type Region } from './regions.ts';
20
21
  interface HotRow {
@@ -25,15 +26,40 @@ interface PluginHandle {
25
26
  await(): Promise<unknown>;
26
27
  dispose(): Promise<unknown> | void;
27
28
  }
29
+ /** One structured record delivered to a host logger exporter (cordis `Message`). */
30
+ interface HostLogMessage {
31
+ name?: unknown;
32
+ type?: unknown;
33
+ args?: unknown;
34
+ }
35
+ /**
36
+ * Sink shape accepted by cordis' `LoggerService.exporter`.
37
+ *
38
+ * `levels` is not optional decoration: the service skips a record before it
39
+ * ever reaches `export` when
40
+ * `(levels[name] ?? levels.default ?? logger.level ?? 1) < record.level`.
41
+ * The default threshold is `1`, and `warn` is level `2` — a sink that leaves
42
+ * `levels` out never sees a single warning.
43
+ */
44
+ interface HostLogSink {
45
+ levels?: Record<string, number>;
46
+ export(message: HostLogMessage): void;
47
+ }
28
48
  interface HotContext {
29
49
  plugin(plugin: unknown, config: unknown): PluginHandle;
30
50
  logger?: {
31
51
  info?(message: string): void;
32
52
  warn(message: string): void;
53
+ /**
54
+ * Optional structured sink: cordis' `LoggerService.exporter` hands over
55
+ * every record the process logs and returns a disposer. Absent on hosts
56
+ * whose logger is a bare object, and on test doubles.
57
+ */
58
+ exporter?(sink: HostLogSink): unknown;
33
59
  };
34
60
  }
35
61
  /**
36
- * Profile-scoped resolution for hot-mount rows: turn a bare package name into
62
+ * Profile-scoped resolution for hot-mount imports: turn a bare package name into
37
63
  * the absolute `file://` entry URL of the package just installed into
38
64
  * `profileDir`.
39
65
  *
@@ -47,7 +73,7 @@ interface HotContext {
47
73
  * back to "restart required", blaming the plugin for what is a resolution
48
74
  * anchor problem.
49
75
  *
50
- * Resolving the row name HERE, against the profile the package was actually
76
+ * Resolving the module at import time, against the profile it was actually
51
77
  * installed into, is anchor-independent: `require.resolve` walks
52
78
  * `profileDir/node_modules` natively, so the tree hands the loader a
53
79
  * `file://` URL needing no further resolution. Non-bare specifiers (relative
@@ -59,8 +85,8 @@ interface HotContext {
59
85
  * whose entry cannot be located via `require.resolve` (no `main`/exports —
60
86
  * the market's own `entryArtifactExists` heuristic covers those shapes before
61
87
  * an install is accepted) is not something this resolver should guess about.
62
- * Client-only shims never reach this function (their rows are replaced by a
63
- * no-op host module before the file is written).
88
+ * Client-only shims never reach this function: their import returns a no-op
89
+ * host module before attempting package resolution.
64
90
  */
65
91
  export declare function resolveProfileEntry(profileDir: string, name: string): string;
66
92
  /**
@@ -192,6 +218,10 @@ export interface MarketState {
192
218
  * An empty array is how the last name is removed.
193
219
  */
194
220
  updateExempt?: string[];
221
+ /** Background update checks run only after an explicit opt-in. */
222
+ backgroundUpdateChecks?: boolean;
223
+ /** Polling cadence; absent or invalid legacy values use the six-hour default. */
224
+ backgroundUpdateIntervalHours?: UpdateCheckIntervalHours;
195
225
  /** User-supplied HTTPS prefix used when the built-in GitHub routes fail. */
196
226
  githubProxy?: string;
197
227
  /**
@@ -257,6 +287,30 @@ export interface MarketState {
257
287
  * src/dsh-cli.ts spawnEnv for the precedence once it reaches a child.
258
288
  */
259
289
  buildEnv?: Record<string, string>;
290
+ /**
291
+ * When this market installed or last updated each package (#1142/#1121).
292
+ *
293
+ * A row in the installed list has no time of its own. `node_modules/<pkg>`
294
+ * mtime is not one (pnpm rewrites it on every install, so a batch all
295
+ * shares one instant) and `.plugin-manager/logs/operation-*` is a log with
296
+ * a retention policy, not a field. So the market writes its own stamps at
297
+ * the two moments it knows: an install it ran, and an update that landed.
298
+ *
299
+ * Two consequences worth stating in the shape itself:
300
+ * - A package installed anywhere else (the CLI, the host's plugins page) has
301
+ * no entry, and displaying a guessed one would be worse than displaying
302
+ * nothing: "按安装时间排" would then be an ordering of guesses.
303
+ * - Keys carry no profile: the file is per profile already, and a copied
304
+ * profile inheriting another's timestamps would be inventing history.
305
+ */
306
+ installTimes?: Record<string, InstallTimes>;
307
+ }
308
+ /** One package's market-recorded timestamps, both ISO 8601. */
309
+ export interface InstallTimes {
310
+ /** When this market installed the package. Absent when it did not. */
311
+ installedAt?: string;
312
+ /** When an update of it last landed. Absent when it never updated here. */
313
+ updatedAt?: string;
260
314
  }
261
315
  /** Why a package is no longer declared, and what to put back. */
262
316
  export interface BrokenPlugin {
@@ -281,6 +335,13 @@ export declare const MAX_BLOCKED = 500;
281
335
  export declare const MAX_UPDATE_EXEMPT = 500;
282
336
  /** npm package names are at most 214 characters. Longer values are not names. */
283
337
  export declare const MAX_BLOCKED_NAME = 214;
338
+ /**
339
+ * Upper bound on the install-time map (#1142). One entry per package the
340
+ * market itself installed, and a profile with 500 of those is already an
341
+ * outlier; the cap keeps state.json from growing with every plugin the user
342
+ * ever tried and removed.
343
+ */
344
+ export declare const MAX_INSTALL_TIMES = 500;
284
345
  /**
285
346
  * Sanitize an untrusted build-env map (state.json, or the card route's body)
286
347
  * into the shape spawnEnv can merge.
@@ -345,13 +406,34 @@ export declare function writeDisabled(profileDir: string, disabled: Set<string>)
345
406
  export declare function readDisabledThemes(profileDir: string): Set<string>;
346
407
  /** @deprecated theme-specific alias — kept for pre-#60 callers. */
347
408
  export declare function writeDisabledThemes(profileDir: string, disabled: Set<string>): void;
348
- /** Package names currently live through a market hot mount (patch or shim). */
409
+ /**
410
+ * The market installed these packages just now (#1142): both stamps are this
411
+ * moment, because the first install is also the last change so far.
412
+ */
413
+ export declare function recordInstalled(profileDir: string, names: readonly string[], at?: Date): void;
414
+ /**
415
+ * An update of these packages landed: only the update stamp moves.
416
+ *
417
+ * A package with no entry keeps `installedAt` absent — the market never saw
418
+ * it installed, and "when I first noticed it" is a different fact. Writing it
419
+ * here would make the sort report a guessed install order as history.
420
+ */
421
+ export declare function recordUpdated(profileDir: string, names: readonly string[], at?: Date): void;
422
+ /** The package is gone: its stamps must not outlive it. */
423
+ export declare function forgetInstalled(profileDir: string, name: string): void;
424
+ /** Package names whose hot-mount trees are still attached and can be removed. */
349
425
  export declare function listHotMounts(): string[];
426
+ /** Report a failed child only when it belongs to this package's hot-mount tree. */
427
+ export declare function hotMountFailure(packageName: string, profileDir?: string): string | null;
428
+ /** Hot mounts the market can report as live. */
429
+ export declare function listLiveHotMounts(): string[];
350
430
  /** Outcome of one hot-mount attempt; `reason` explains non-`ok` results. */
351
431
  export interface HotMountResult {
352
432
  ok: boolean;
353
433
  /** Bilingual reason shown to the user instead of a bare restart banner. */
354
434
  reason: string | null;
435
+ /** The tree is still attached so its running components can continue. */
436
+ retained?: true;
355
437
  /**
356
438
  * Set when nothing was attempted because this package can only come up on a
357
439
  * start — its patch holds more than plain inserts. That is a verdict about
@@ -365,6 +365,25 @@ export declare function normalizedLinkTarget(target: string): string;
365
365
  * fail the uninstall that triggered it.
366
366
  */
367
367
  export declare function removeDanglingHostBridge(name: string, profileDirectory: string, hostDirectory: string | null): boolean;
368
+ /**
369
+ * Remove the link a confirmed uninstall left at `node_modules/<name>` (#1191).
370
+ *
371
+ * A plugin installed from a local checkout (`link:`) is a junction or
372
+ * directory symlink into that checkout. The uninstall has removed the
373
+ * dependency from package.json and the lockfile, but on Windows the link was
374
+ * reported still there, and the next install of the same name (the online
375
+ * release) makes pnpm rename `<name>_tmp_*` over it, which Windows refuses
376
+ * with EPERM.
377
+ *
378
+ * Only a link is ever touched, and only when the manifest no longer lists
379
+ * `name` — a link the profile still owns must survive. `rmSync` without
380
+ * `recursive` unlinks the link itself and never reaches the checkout it points
381
+ * at (the same measurement the host-bridge cleanup above relies on).
382
+ *
383
+ * @returns the checkout path the removed link pointed at, or null when there
384
+ * was nothing to remove. Never throws: the uninstall already succeeded.
385
+ */
386
+ export declare function removeLeftoverProfileLink(profile: string, name: string, profileDirectory: string): string | null;
368
387
  /**
369
388
  * Group flat `{id, owner}` conflict hits by the installed plugin that owns
370
389
  * them. What the user has to decide is which PLUGINS to uninstall, not which
@@ -77,7 +77,7 @@ export declare function composedRowName(host: PatchHost, rowId: string): string
77
77
  * the loader.
78
78
  */
79
79
  export declare function rowFlagApplies(state: PatchState, rowId: string, expected: string | null): boolean;
80
- export declare function readUserPatchState(patchPath: string): PatchState;
80
+ export declare function readUserPatchState(patchPath: string, expectedNameFor?: (id: string) => string | null): PatchState;
81
81
  /**
82
82
  * User-authored insert rows that still load `packageName` (or one of its
83
83
  * exported subpaths). This evidence deliberately stays separate from the
@@ -189,6 +189,8 @@ export declare function packagePatchFlags(host: PatchHost, profileDirectory: str
189
189
  */
190
190
  export declare function disableRow(patchPath: string, rowId: string, options?: {
191
191
  expectedName?: string | null;
192
+ recordModuleName?: boolean;
193
+ packageName?: string;
192
194
  }): Promise<{
193
195
  ok: boolean;
194
196
  reason: string | null;
@@ -206,13 +208,15 @@ export declare function disableRow(patchPath: string, rowId: string, options?: {
206
208
  export declare function enableRow(patchPath: string, rowId: string, options?: {
207
209
  cleanOnly?: boolean;
208
210
  expectedName?: string | null;
211
+ packageName?: string;
209
212
  }): Promise<{
210
213
  ok: boolean;
211
214
  reason: string | null;
215
+ removedMarketName?: string;
212
216
  }>;
213
217
  /** Remove every disable/force block the market (or the user) wrote for a
214
218
  * row — the uninstall cleanup, so a removed plugin leaves no orphan rows. */
215
- export declare function removeRowBlocks(patchPath: string, rowIds: readonly string[]): {
219
+ export declare function removeRowBlocks(patchPath: string, rowIds: readonly string[], packageName?: string | null): {
216
220
  ok: boolean;
217
221
  reason: string | null;
218
222
  };
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Registry access: crate 的目录(dsh-crate.json)每次请求都重新拉取。
3
- * 这里只负责抓取、重试、校验与 304 复用;字段映射见 src/crate-catalog.ts。
2
+ * Registry access: the curated list from awesome-dsh-plugin.com, fetched
3
+ * fresh on every request. See `loadRegistry` for why there is nothing
4
+ * behind it any more.
4
5
  */
5
6
  import { type Region } from './regions.ts';
6
7
  export interface RegistryPlugin {
@@ -37,9 +38,9 @@ export interface RegistryPlugin {
37
38
  /** When the source checked this statistic; never the client's fetch time. */
38
39
  downloadsCheckedAt?: string | null;
39
40
  /**
40
- * npm `latest` reported by the catalog (#348). A string when known;
41
- * `null`/absent when github-only or not yet backfilled — the UI omits the
42
- * byline segment rather than showing a placeholder.
41
+ * Registry `dist-tags.latest` from awesome-dsh-plugin (#348). A string when
42
+ * known; `null`/absent when github-only or not yet backfilled — the UI
43
+ * omits the byline segment rather than showing a placeholder.
43
44
  */
44
45
  version?: string | null;
45
46
  /**
@@ -51,9 +52,9 @@ export interface RegistryPlugin {
51
52
  install: string;
52
53
  added: string;
53
54
  /**
54
- * Catalog-side deprecation flags (#60): an optional extra on top of the
55
- * core contract, absent for every normal entry — the market only consumes
56
- * them, so a catalog without the fields behaves exactly as before.
55
+ * Catalog-side deprecation flags (#60): supplied by awesome-dsh-plugin,
56
+ * absent for every normal entry — the market only consumes them, so a
57
+ * catalog without the fields behaves exactly as before.
57
58
  */
58
59
  deprecated?: boolean;
59
60
  /** Catalog name of the suggested replacement plugin, when deprecated. */
@@ -22,6 +22,8 @@ export interface MatureUpdateSelection {
22
22
  }
23
23
  /** Accept stable SemVer, including build metadata, at both API boundaries. */
24
24
  export declare function isStableReleaseVersion(value: unknown): value is string;
25
+ /** Accept a bounded exact npm release version, including prereleases. */
26
+ export declare function isExactReleaseVersion(value: unknown): value is string;
25
27
  export declare function strictPublishTime(value: unknown): number | null;
26
28
  export declare function selectMatureUpdate(packument: NpmPackument, installed: string | null, now: number, policy: MatureUpdatePolicy): MatureUpdateSelection;
27
29
  /**
@@ -125,6 +125,6 @@ export declare function marketVersion(): string;
125
125
  * Register the market's HTTP routes.
126
126
  * @param host - Acquired webServer + shell services.
127
127
  * @param config - Validated market configuration.
128
- * @returns Disposer removing every registered route.
128
+ * @returns Disposer removing every registered route and draining queued cache writes.
129
129
  */
130
- export declare function mountMarketRoutes(host: MarketHost, config: MarketConfig, commandRuntime?: PluginCommandRuntime, agentsLookup?: AgentsLookup, hostActivation?: HostPluginActivation): () => void;
130
+ export declare function mountMarketRoutes(host: MarketHost, config: MarketConfig, commandRuntime?: PluginCommandRuntime, agentsLookup?: AgentsLookup, hostActivation?: HostPluginActivation): () => Promise<void>;
@@ -36,7 +36,12 @@ export interface ThemeHost {
36
36
  export interface ThemeManager {
37
37
  installedThemeNames(): Promise<Set<string>>;
38
38
  setEntryDisabled(name: string, disabledFlag: boolean, requireLive?: boolean, rejectPending?: boolean): Promise<boolean>;
39
- activateTheme(name: string): Promise<boolean>;
39
+ activateTheme(name: string): Promise<ThemeActivationResult>;
40
+ }
41
+ interface ThemeActivationResult {
42
+ ok: boolean;
43
+ /** Verified component failure before rolling back the attempted switch. */
44
+ reason?: string;
40
45
  }
41
46
  /**
42
47
  * Create the theme manager. `disabledThemes` is the live, shared set of
@@ -44,3 +49,4 @@ export interface ThemeManager {
44
49
  * replaying it; the manager mutates and persists it on switches.
45
50
  */
46
51
  export declare function createThemeManager(host: ThemeHost, profile: string, disabledThemes: Set<string>, explicitDir?: string): ThemeManager;
52
+ export {};
@@ -0,0 +1,5 @@
1
+ /** Persisted choices shared by the profile monitor and its settings UI. */
2
+ export declare const UPDATE_CHECK_INTERVAL_HOURS: readonly [6, 12, 72, 168];
3
+ export type UpdateCheckIntervalHours = typeof UPDATE_CHECK_INTERVAL_HOURS[number];
4
+ export declare const DEFAULT_UPDATE_CHECK_INTERVAL_HOURS: UpdateCheckIntervalHours;
5
+ export declare function isUpdateCheckIntervalHours(value: unknown): value is UpdateCheckIntervalHours;
@@ -0,0 +1,51 @@
1
+ /** Shared, read-only update checks for every market surface in one profile. */
2
+ import type { UpdateStatus } from './updates.ts';
3
+ import { type UpdateCheckIntervalHours } from './update-notification-settings.ts';
4
+ export declare const UPDATE_CHECK_START_DELAY_MS = 30000;
5
+ export declare const UPDATE_CHECK_INTERVAL_MS: number;
6
+ /** Notification data; reading a snapshot never contacts an update source. */
7
+ export interface UpdateNotificationSnapshot {
8
+ enabled: boolean;
9
+ intervalHours: UpdateCheckIntervalHours;
10
+ checking: boolean;
11
+ checkedAt: number | null;
12
+ lastSuccessAt: number | null;
13
+ nextCheckAt: number | null;
14
+ stale: boolean;
15
+ error: string | null;
16
+ updates: Record<string, UpdateStatus>;
17
+ boot: string;
18
+ /** Stable opaque profile identity for client-side read receipts. */
19
+ profileKey?: string;
20
+ updateExempt: string[];
21
+ disabled: string[];
22
+ blocked: string[];
23
+ }
24
+ export interface UpdateNotificationInventory {
25
+ /** Includes the profile and release channel; a change invalidates all results. */
26
+ context: string;
27
+ /** Per-package source, installed version and locked commit identity. */
28
+ packages: Record<string, string>;
29
+ }
30
+ interface MonitorDependencies {
31
+ boot: string;
32
+ profileKey?: string;
33
+ enabled: boolean;
34
+ intervalHours?: UpdateCheckIntervalHours;
35
+ inventory(): UpdateNotificationInventory;
36
+ preferences(): Pick<UpdateNotificationSnapshot, 'updateExempt' | 'disabled' | 'blocked'>;
37
+ check(force: boolean): Promise<{
38
+ updates: Record<string, UpdateStatus>;
39
+ error?: string;
40
+ }>;
41
+ }
42
+ export interface UpdateNotificationMonitor {
43
+ snapshot(): UpdateNotificationSnapshot;
44
+ check(force?: boolean): Promise<Record<string, UpdateStatus>>;
45
+ setEnabled(enabled: boolean): void;
46
+ setIntervalHours(intervalHours: UpdateCheckIntervalHours): void;
47
+ dispose(): void;
48
+ }
49
+ /** Start one profile-scoped timer; callers own persistence of the preferences. */
50
+ export declare function createUpdateNotificationMonitor(deps: MonitorDependencies): UpdateNotificationMonitor;
51
+ export {};
@@ -23,6 +23,10 @@ export interface UpdateStatus {
23
23
  * as "there is an upgrade" and labels a button accordingly.
24
24
  */
25
25
  updateAvailable: boolean;
26
+ /** Source lookup failed; notification surfaces may retain a previous confirmed result. */
27
+ checkError?: 'unavailable';
28
+ /** The upstream check failed, so this row does not establish that the plugin is current. */
29
+ checkFailed?: true;
26
30
  /** Exact mature npm stable target for Desktop; `latest` remains the registry tag. */
27
31
  eligibleVersion?: string;
28
32
  /**
@@ -237,7 +241,7 @@ export declare function fetchNpmLatest(name: string): Promise<string | null>;
237
241
  * without the market volunteering anyone's prerelease as an update.
238
242
  */
239
243
  export declare function newerPrereleaseFor(name: string, installed: string | null): Promise<string | null>;
240
- /** Per-plugin update checks; a failed check reports no update rather than failing the listing. */
244
+ /** Check each plugin independently so a failed lookup leaves the other results usable. */
241
245
  export declare function checkUpdates(profile: string, force?: boolean, explicitDir?: string,
242
246
  /**
243
247
  * Packages that follow a release channel instead of plain `latest`. Only
@@ -0,0 +1,6 @@
1
+ /** Persisted choices shared by the profile monitor and its settings UI. */
2
+ export const UPDATE_CHECK_INTERVAL_HOURS = [6, 12, 72, 168];
3
+ export const DEFAULT_UPDATE_CHECK_INTERVAL_HOURS = 6;
4
+ export function isUpdateCheckIntervalHours(value) {
5
+ return typeof value === 'number' && UPDATE_CHECK_INTERVAL_HOURS.includes(value);
6
+ }