dsh-crate 0.5.2 → 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 (46) hide show
  1. package/assets/logo.svg +11 -33
  2. package/client/client.js +2271 -561
  3. package/lib/body-progress.js +4 -3
  4. package/lib/changelog.js +15 -2
  5. package/lib/discovery-cache.js +210 -0
  6. package/lib/discovery-compatibility.js +135 -90
  7. package/lib/drain.js +28 -9
  8. package/lib/dsh-cli.js +36 -6
  9. package/lib/github-install-target.js +53 -0
  10. package/lib/hot.js +400 -33
  11. package/lib/index.js +23 -9
  12. package/lib/install.js +37 -0
  13. package/lib/patch.js +123 -73
  14. package/lib/pending-rows.js +3 -4
  15. package/lib/pnpm-compat.js +234 -2
  16. package/lib/proc-text.js +16 -1
  17. package/lib/profile.js +17 -1
  18. package/lib/recovery.js +2 -1
  19. package/lib/registry.js +24 -16
  20. package/lib/release-candidates.js +4 -0
  21. package/lib/release-updates.js +9 -2
  22. package/lib/routes.js +459 -134
  23. package/lib/themes.js +42 -9
  24. package/lib/types/body-progress.d.ts +2 -1
  25. package/lib/types/changelog.d.ts +10 -1
  26. package/lib/types/discovery-cache.d.ts +38 -0
  27. package/lib/types/discovery-compatibility.d.ts +24 -14
  28. package/lib/types/dsh-cli.d.ts +19 -2
  29. package/lib/types/github-install-target.d.ts +11 -0
  30. package/lib/types/hot.d.ts +91 -7
  31. package/lib/types/index.d.ts +17 -0
  32. package/lib/types/install.d.ts +19 -0
  33. package/lib/types/patch.d.ts +6 -2
  34. package/lib/types/profile.d.ts +4 -1
  35. package/lib/types/registry.d.ts +9 -8
  36. package/lib/types/release-candidates.d.ts +2 -0
  37. package/lib/types/routes.d.ts +2 -2
  38. package/lib/types/themes.d.ts +7 -1
  39. package/lib/types/update-notification-settings.d.ts +5 -0
  40. package/lib/types/update-notifications.d.ts +51 -0
  41. package/lib/types/updates.d.ts +5 -1
  42. package/lib/update-notification-settings.js +6 -0
  43. package/lib/update-notifications.js +166 -0
  44. package/lib/updates.js +41 -11
  45. package/lib/verify.js +24 -2
  46. package/package.json +1 -1
package/lib/themes.js CHANGED
@@ -7,12 +7,12 @@
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';
14
14
  import { nameMatchesPackage } from './entry-identity.js';
15
- import { bundlePatchInsertedIds, profileDir, readInstalled } from './profile.js';
15
+ import { bundleExpressionRowIds, bundlePatchInsertedIds, profileDir, readInstalled } from './profile.js';
16
16
  import { parseSourceUrl, repoOfTarget } from './sources.js';
17
17
  /**
18
18
  * Whether an installed package declares itself a skin.
@@ -215,7 +215,24 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
215
215
  // looking for a naming bug (#619's shape) in a profile where the match
216
216
  // was fine and the runtime was simply still busy.
217
217
  let matched = false;
218
+ // Rows the package decides itself, by expression (`disabled: !!js …`),
219
+ // are not the market's to overrule (#1043). The durable layer already
220
+ // leaves them alone — `switchPluginLayers` filters them out through
221
+ // `bundleExpressionRowIds` — and the live layer has to agree: clearing a
222
+ // guard the host evaluated to `true` mounts the row anyway, which for a
223
+ // carrier means a second copy of a module the host already holds
224
+ // (`storage form 'domain' is already mounted`), and dsh answers a
225
+ // duplicate mount by exiting (#1175: dsh-tui on a web profile).
226
+ //
227
+ // Disabling still writes through: "off" cannot resurrect anything, and a
228
+ // guarded row the user wants off should stay off whichever way the
229
+ // condition falls.
230
+ const expressionIds = disabledFlag
231
+ ? null
232
+ : new Set(bundleExpressionRowIds(join(activeProfileDir, 'node_modules', name)));
218
233
  for (const entry of matchingEntries(name)) {
234
+ if (expressionIds !== null && expressionIds.has(entry.options.id ?? ''))
235
+ continue;
219
236
  matched = true;
220
237
  if (!disabledFlag && uncertainEntries.has(entry)) {
221
238
  throw new LifecycleWaitError('loader entry: runtime state is uncertain; retry disabling before enabling');
@@ -312,6 +329,7 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
312
329
  * set is what lets the next attempt try it again.
313
330
  */
314
331
  async function activateTheme(name) {
332
+ const stopFailedMount = async (theme) => !listHotMounts().includes(theme) || await hotUnmount(theme);
315
333
  const themes = await installedThemeNames();
316
334
  const stopped = [];
317
335
  for (const other of themes) {
@@ -329,22 +347,37 @@ export function createThemeManager(host, profile, disabledThemes, explicitDir) {
329
347
  }
330
348
  disabledThemes.delete(name);
331
349
  writeDisabled(activeProfileDir, disabledThemes);
332
- const live = listHotMounts().includes(name)
333
- || await setEntryDisabled(name, false)
334
- || (await hotMount(host, activeProfileDir, name)).ok;
335
- if (live)
336
- 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;
337
367
  for (const previous of stopped) {
338
368
  const back = previous.kind === 'hot'
339
369
  ? (await hotMount(host, activeProfileDir, previous.name)).ok
340
370
  : await setEntryDisabled(previous.name, false);
341
371
  if (back)
342
372
  disabledThemes.delete(previous.name);
343
- else
373
+ else {
344
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
+ }
345
378
  }
346
379
  writeDisabled(activeProfileDir, disabledThemes);
347
- return false;
380
+ return failure;
348
381
  }
349
382
  return { installedThemeNames, setEntryDisabled, activateTheme };
350
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 {};
@@ -11,8 +11,8 @@
11
11
  export type HostCompatibilityStatus = 'compatible' | 'incompatible' | 'unknown';
12
12
  export type HostCompatibilityBasis = 'manifest' | 'undeclared' | 'unavailable';
13
13
  export interface HostRequirementDeclaration {
14
- kind: 'engine' | 'peer';
15
- /** Present only for a peer-derived declaration. */
14
+ kind: 'engine' | 'peer' | 'dependency';
15
+ /** Present only for a peer- or dependency-derived declaration. */
16
16
  package?: string;
17
17
  range: string;
18
18
  }
@@ -27,6 +27,12 @@ export interface NpmManifestFacts {
27
27
  version: string | null;
28
28
  enginesDsh: string | null;
29
29
  peerDependencies: Record<string, string>;
30
+ /**
31
+ * Ordinary dependencies that name a host package. Optional only because a
32
+ * durable cache entry or a catalog release manifest written before this
33
+ * field existed carries no value; a missing field declares nothing.
34
+ */
35
+ dependencies?: Record<string, string>;
30
36
  }
31
37
  type FetchLike = (url: string, init?: {
32
38
  signal?: AbortSignal;
@@ -35,8 +41,11 @@ type FetchLike = (url: string, init?: {
35
41
  export interface GitHubManifestSource {
36
42
  url: string;
37
43
  tarball?: string | null;
44
+ version?: string | null;
38
45
  releaseManifest?: unknown;
39
46
  }
47
+ /** Only the selected artifact and its declarations determine a discovery verdict. */
48
+ export declare function githubCompatibilityRevision(source: GitHubManifestSource): string;
40
49
  /** Reuse catalog facts only for this repository's exact pinned install asset. */
41
50
  export declare function catalogReleaseManifest(source: GitHubManifestSource): NpmManifestFacts | null;
42
51
  /** Keep only the small public subset of an npm manifest needed by discovery. */
@@ -50,24 +59,22 @@ export declare function manifestFacts(value: unknown): NpmManifestFacts;
50
59
  */
51
60
  export declare function deriveHostCompatibility(facts: NpmManifestFacts | null, hostVersion: string | null, hostPackages: ReadonlySet<string>): HostCompatibility;
52
61
  /**
53
- * Durable, bounded lookup of npm `latest` and catalog GitHub manifests.
62
+ * Durable, bounded lookup of npm releases and catalog GitHub manifests.
54
63
  *
55
64
  * Failed requests are intentionally memory-only and short-lived: a mirror
56
65
  * outage must not become a day-long false "undeclared" result on disk.
57
66
  */
58
67
  export declare class DiscoveryManifestIndex {
59
- private readonly cacheFile;
60
- private readonly entries;
68
+ private readonly cache;
61
69
  private readonly failures;
62
70
  private readonly inflight;
63
71
  private readonly fetcher;
64
72
  private readonly now;
65
73
  private readonly ttlMs;
66
74
  private readonly concurrency;
67
- private loaded;
68
75
  private consecutiveFailures;
69
76
  private unavailableUntil;
70
- private dirty;
77
+ private disposed;
71
78
  private activeFetches;
72
79
  private readonly fetchWaiters;
73
80
  constructor(cacheFile: string, options?: {
@@ -76,11 +83,15 @@ export declare class DiscoveryManifestIndex {
76
83
  ttlMs?: number;
77
84
  concurrency?: number;
78
85
  });
79
- private load;
80
- private persist;
86
+ /** Unmount this index, retaining any writes already queued for this profile. */
87
+ dispose(): Promise<void>;
81
88
  /** One semaphore for the whole index, including overlapping HTTP batches. */
82
89
  private withFetchPermit;
90
+ private retryDelay;
91
+ npmRetryAfterMs(name: string, registry: string, version: string | undefined): number;
92
+ githubRetryAfterMs(source: GitHubManifestSource): number;
83
93
  private fetchOne;
94
+ private readNpmManifest;
84
95
  /**
85
96
  * Facts for ONE named release, rather than for `latest`.
86
97
  *
@@ -92,11 +103,9 @@ export declare class DiscoveryManifestIndex {
92
103
  * release declares a range this host misses), and it would equally pass a
93
104
  * pinned release that is itself incompatible.
94
105
  *
95
- * Deliberately outside the cache. The index is keyed by package name, and a
96
- * version-keyed one would grow with every release anyone ever pinned to
97
- * answer a question asked once per install. Nothing is recorded either: a
98
- * pre-flight verdict must not decide what the diagnostics panel sees next
99
- * (#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).
100
109
  *
101
110
  * A release whose manifest cannot be read is `null`, like every other
102
111
  * unreadable manifest: absence of a claim is not a verdict.
@@ -113,6 +122,7 @@ export declare class DiscoveryManifestIndex {
113
122
  */
114
123
  lookup(names: readonly string[], registry: string, options?: {
115
124
  record?: boolean;
125
+ versions?: ReadonlyMap<string, string>;
116
126
  }): Promise<Record<string, NpmManifestFacts | null>>;
117
127
  /** Catalog-approved GitHub sources, cached by both package path and selected archive. */
118
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
@@ -385,7 +467,9 @@ export declare function hotMount(ctx: HotContext, profileDir: string, packageNam
385
467
  * in every boot — this is what makes them behave like normal plugins.
386
468
  * @returns names that were mounted.
387
469
  */
388
- export declare function mountClientOnlyDeps(ctx: HotContext, profileDir: string): Promise<string[]>;
470
+ export declare function mountClientOnlyDeps(ctx: HotContext, profileDir: string,
471
+ /** The host's install directory; `undefined` finds it, `null` means "do not look". */
472
+ hostDirectory?: string | null): Promise<string[]>;
389
473
  /**
390
474
  * Package names the profile's OWN bundle layer already mounts.
391
475
  *
@@ -401,7 +485,7 @@ export declare function mountClientOnlyDeps(ctx: HotContext, profileDir: string)
401
485
  * today's behaviour (shim, possibly duplicated) rather than silently dropping
402
486
  * a client bundle that the bundle layer never mounts.
403
487
  */
404
- export declare function bundleLayerTargets(profileDir: string, bundles: Iterable<string>): Set<string>;
488
+ export declare function bundleLayerTargets(profileDir: string, bundles: Iterable<string>, hostDirectory?: string | null): Set<string>;
405
489
  /**
406
490
  * Row ids and package names the user's own patch layer (cordis.patch.yml)
407
491
  * already contains. Line-wise scan on purpose: the file may hold structures
@@ -3,10 +3,27 @@
3
3
  * composes the webServer and shell services.
4
4
  */
5
5
  import type { Context } from '@deepseek-ai/cordis';
6
+ import z from '@deepseek-ai/schemastery';
6
7
  import { type MarketConfig } from './routes.ts';
7
8
  export declare const name = "dsh-crate";
8
9
  /** Optional cordis.yml configuration; profile defaults to `web`. */
9
10
  export type Config = Partial<Pick<MarketConfig, 'profile' | 'allowRestart' | 'maxSnapshots' | 'buildEnv'>>;
11
+ /** dsh 0.1.7+ builds its form from `plugin.Config` and writes `simplify(config)` back, so every field the market reads is named here or the first form save deletes it. Each is loose: an older composition still boots, a mistyped value is dropped, and neither editable field takes a default, so "unconfigured" stays distinguishable (#1144, #229). */
12
+ export declare const Config: z<Schemastery.ObjectS<{
13
+ profile: z<string, string>;
14
+ channel: z<string, string>;
15
+ region: z<string, string>;
16
+ allowRestart: z<boolean, boolean>;
17
+ maxSnapshots: z<number, number>;
18
+ buildEnv: z<import("@deepseek-ai/cosmokit").Dict<any, string>, import("@deepseek-ai/cosmokit").Dict<any, string>>;
19
+ }>, Schemastery.ObjectT<{
20
+ profile: z<string, string>;
21
+ channel: z<string, string>;
22
+ region: z<string, string>;
23
+ allowRestart: z<boolean, boolean>;
24
+ maxSnapshots: z<number, number>;
25
+ buildEnv: z<import("@deepseek-ai/cosmokit").Dict<any, string>, import("@deepseek-ai/cosmokit").Dict<any, string>>;
26
+ }>>;
10
27
  /**
11
28
  * The launcher's `profileContext` in one line, for the exported log (#744).
12
29
  *
@@ -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
  };
@@ -543,9 +543,12 @@ export declare function dropUnparseableBuildKeys(profile: string, explicitDir?:
543
543
  * nothing in the file says which main package it belongs to — guessing would
544
544
  * delete policy that may still be in effect for something installed.
545
545
  *
546
+ * With `keepVersion` (the update path) the rows that name that version are
547
+ * kept and only the older ones go.
548
+ *
546
549
  * @returns the entries removed, for the caller to log; empty when there is no
547
550
  * such block, no such row, or the file cannot be read exactly (in which case
548
551
  * it is left byte-for-byte as it was).
549
552
  */
550
- export declare function dropReleaseAgeExcludes(profile: string, name: string, explicitDir?: string): string[];
553
+ export declare function dropReleaseAgeExcludes(profile: string, name: string, explicitDir?: string, keepVersion?: string): string[];
551
554
  export declare function mergeDuplicateReleaseAgeExcludes(profile: string, explicitDir?: string): string[];
@@ -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
  /**