dsh-crate 0.0.0-stage → 0.5.0

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 (132) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +288 -2
  3. package/README.zh.md +263 -0
  4. package/UPDATE-API-V1.md +207 -0
  5. package/assets/logo.svg +37 -0
  6. package/client/client.js +18964 -0
  7. package/cordis.patch.yml +4 -0
  8. package/lib/accelerate.js +194 -0
  9. package/lib/agents.js +67 -0
  10. package/lib/backup.js +688 -0
  11. package/lib/body-progress.js +173 -0
  12. package/lib/catalog-local-match.js +160 -0
  13. package/lib/catalog-npm.js +180 -0
  14. package/lib/changelog.js +462 -0
  15. package/lib/channels.js +64 -0
  16. package/lib/check.js +1557 -0
  17. package/lib/compatibility.js +243 -0
  18. package/lib/crate-catalog.js +179 -0
  19. package/lib/diagnostics.js +49 -0
  20. package/lib/discovery-compatibility.js +447 -0
  21. package/lib/drain-journal.js +164 -0
  22. package/lib/drain.js +1043 -0
  23. package/lib/dsh-cli.js +1373 -0
  24. package/lib/dsh-install.js +259 -0
  25. package/lib/entry-identity.js +85 -0
  26. package/lib/gist.js +369 -0
  27. package/lib/groups.js +108 -0
  28. package/lib/home-paths.js +29 -0
  29. package/lib/host-recovery.js +187 -0
  30. package/lib/hot.js +871 -0
  31. package/lib/http.js +252 -0
  32. package/lib/index.js +394 -0
  33. package/lib/install.js +1147 -0
  34. package/lib/lifecycle.js +37 -0
  35. package/lib/log-redaction.js +24 -0
  36. package/lib/log.js +204 -0
  37. package/lib/ndjson.js +154 -0
  38. package/lib/net.js +174 -0
  39. package/lib/official-desktop.js +619 -0
  40. package/lib/order.js +284 -0
  41. package/lib/patch.js +943 -0
  42. package/lib/pending-rows.js +142 -0
  43. package/lib/pending-updates.js +346 -0
  44. package/lib/pnpm-compat.js +972 -0
  45. package/lib/presets.js +282 -0
  46. package/lib/probe-context.js +20 -0
  47. package/lib/proc-text.js +69 -0
  48. package/lib/profile.js +1978 -0
  49. package/lib/recovery.js +1059 -0
  50. package/lib/region-probe.js +93 -0
  51. package/lib/regions.js +283 -0
  52. package/lib/registry.js +308 -0
  53. package/lib/release-candidates.js +115 -0
  54. package/lib/release-updates.js +70 -0
  55. package/lib/restart.js +688 -0
  56. package/lib/routes.js +7960 -0
  57. package/lib/settings.js +164 -0
  58. package/lib/shelfry-catalog.js +179 -0
  59. package/lib/snapshot.js +506 -0
  60. package/lib/source-migration.js +164 -0
  61. package/lib/sources.js +1005 -0
  62. package/lib/state.js +38 -0
  63. package/lib/store.js +163 -0
  64. package/lib/themes.js +350 -0
  65. package/lib/trial.js +125 -0
  66. package/lib/types/accelerate.d.ts +85 -0
  67. package/lib/types/agents.d.ts +52 -0
  68. package/lib/types/backup.d.ts +171 -0
  69. package/lib/types/body-progress.d.ts +94 -0
  70. package/lib/types/catalog-local-match.d.ts +39 -0
  71. package/lib/types/catalog-npm.d.ts +77 -0
  72. package/lib/types/changelog.d.ts +131 -0
  73. package/lib/types/channels.d.ts +56 -0
  74. package/lib/types/check.d.ts +353 -0
  75. package/lib/types/compatibility.d.ts +83 -0
  76. package/lib/types/crate-catalog.d.ts +48 -0
  77. package/lib/types/diagnostics.d.ts +29 -0
  78. package/lib/types/discovery-compatibility.d.ts +145 -0
  79. package/lib/types/drain-journal.d.ts +25 -0
  80. package/lib/types/drain.d.ts +306 -0
  81. package/lib/types/dsh-cli.d.ts +481 -0
  82. package/lib/types/dsh-install.d.ts +106 -0
  83. package/lib/types/entry-identity.d.ts +68 -0
  84. package/lib/types/gist.d.ts +79 -0
  85. package/lib/types/groups.d.ts +34 -0
  86. package/lib/types/home-paths.d.ts +13 -0
  87. package/lib/types/host-recovery.d.ts +95 -0
  88. package/lib/types/hot.d.ts +405 -0
  89. package/lib/types/http.d.ts +114 -0
  90. package/lib/types/index.d.ts +52 -0
  91. package/lib/types/install.d.ts +463 -0
  92. package/lib/types/lifecycle.d.ts +14 -0
  93. package/lib/types/log-redaction.d.ts +2 -0
  94. package/lib/types/log.d.ts +43 -0
  95. package/lib/types/ndjson.d.ts +52 -0
  96. package/lib/types/net.d.ts +94 -0
  97. package/lib/types/official-desktop.d.ts +59 -0
  98. package/lib/types/order.d.ts +100 -0
  99. package/lib/types/patch.d.ts +218 -0
  100. package/lib/types/pending-rows.d.ts +81 -0
  101. package/lib/types/pending-updates.d.ts +161 -0
  102. package/lib/types/pnpm-compat.d.ts +102 -0
  103. package/lib/types/presets.d.ts +94 -0
  104. package/lib/types/probe-context.d.ts +14 -0
  105. package/lib/types/proc-text.d.ts +29 -0
  106. package/lib/types/profile.d.ts +551 -0
  107. package/lib/types/recovery.d.ts +342 -0
  108. package/lib/types/region-probe.d.ts +50 -0
  109. package/lib/types/regions.d.ts +134 -0
  110. package/lib/types/registry.d.ts +160 -0
  111. package/lib/types/release-candidates.d.ts +42 -0
  112. package/lib/types/release-updates.d.ts +15 -0
  113. package/lib/types/restart.d.ts +279 -0
  114. package/lib/types/routes.d.ts +130 -0
  115. package/lib/types/settings.d.ts +112 -0
  116. package/lib/types/shelfry-catalog.d.ts +48 -0
  117. package/lib/types/snapshot.d.ts +93 -0
  118. package/lib/types/source-migration.d.ts +100 -0
  119. package/lib/types/sources.d.ts +391 -0
  120. package/lib/types/state.d.ts +20 -0
  121. package/lib/types/store.d.ts +47 -0
  122. package/lib/types/themes.d.ts +46 -0
  123. package/lib/types/trial.d.ts +61 -0
  124. package/lib/types/update-api-v1.d.ts +83 -0
  125. package/lib/types/updates.d.ts +273 -0
  126. package/lib/types/verify.d.ts +277 -0
  127. package/lib/update-api-v1.js +273 -0
  128. package/lib/updates.js +981 -0
  129. package/lib/verify.js +904 -0
  130. package/locale/en.json +5 -0
  131. package/locale/zh.json +6 -0
  132. package/package.json +113 -4
@@ -0,0 +1,391 @@
1
+ /**
2
+ * Registry-source knowledge: how a curated registry entry's URL maps to an
3
+ * installable pnpm target. Pure string logic, no I/O.
4
+ */
5
+ /** Registry tarball names must be plain npm package names, nothing fancier. */
6
+ export declare const NPM_NAME_RE: RegExp;
7
+ /**
8
+ * Parse a registry source url: a github repo, optionally with a
9
+ * `/tree/<branch>/<subpath>` suffix (how the curated list links monorepo
10
+ * subpackages, e.g. dsh-plugins#theme-gallery).
11
+ */
12
+ export declare function parseSourceUrl(url: string): {
13
+ repo: string;
14
+ subpath: string | null;
15
+ } | null;
16
+ /** Parse repository forms accepted by package.json.repository. */
17
+ export declare function parseGitHubRepository(value: string): {
18
+ repo: string;
19
+ } | null;
20
+ /**
21
+ * Parse a Git remote. Unlike package metadata, a local origin may contain a
22
+ * proxy prefix (for example `https://proxy/https://github.com/o/r.git`). In
23
+ * that case only the last GitHub occurrence is considered.
24
+ */
25
+ export declare function parseGitHubRemote(url: string): {
26
+ repo: string;
27
+ } | null;
28
+ /** Normalized repo identity shared by server discovery and client matching. */
29
+ export declare function githubRepoIdentity(url: string, directory?: string | null): string | null;
30
+ /**
31
+ * Repository evidence used for installed-source matching. A monorepo package
32
+ * contributes both its collection root and exact subpath, mirroring the
33
+ * identities extracted from `github:owner/repo#path:/package` specs.
34
+ */
35
+ export declare function githubRepoIdentities(url: string, directory?: string | null): string[];
36
+ /** Weak identity hints from a local Git origin; never used to reject a unique match. */
37
+ export declare function githubRemoteIdentities(url: string, directory?: string | null): string[];
38
+ /** GitHub `owner/repo` for a registry URL, or null when it is not a GitHub repo URL. */
39
+ export declare function repoOf(url: string): string | null;
40
+ /**
41
+ * A commit-pinned codeload tarball URL, optionally behind a prefix proxy.
42
+ *
43
+ * Pinned to a SHA rather than `HEAD` on purpose. pnpm records whatever URL
44
+ * it was given, and the profile's version detection reads the installed
45
+ * commit back out of the lockfile by matching `codeload.github.com/owner/
46
+ * repo/tar.gz/<40 hex>` (src/profile.ts). A `HEAD` URL installs fine and
47
+ * then reports no version forever, which is a worse outcome than being slow.
48
+ *
49
+ * @param repo - `owner/repo`.
50
+ * @param sha - full 40-character commit SHA.
51
+ * @param proxy - prefix proxy, or null to address codeload directly.
52
+ */
53
+ export declare function codeloadTarball(repo: string, sha: string, proxy: string | null): string;
54
+ /**
55
+ * Extract a GitHub repo URL from a URL that may be a Release asset tarball
56
+ * (the format used by the catalog: releases/latest/download/ or
57
+ * releases/download/vX.Y.Z/).
58
+ *
59
+ * THIS IS FOR DISPLAY/LOOKUP PURPOSES ONLY — e.g., finding update notes for a
60
+ * plugin installed via npm. It MUST NOT be used for any decision that affects
61
+ * installation, rollback, duplicate detection, or build-script approval.
62
+ * Those paths use `repoFromTarget` / `repoOfTarget` which are stricter and
63
+ * intentionally do NOT recognize Release asset URLs (because the same asset
64
+ * URL can serve different bytes at different times).
65
+ */
66
+ export declare function lookupRepoFromUrl(url: string): string | null;
67
+ /**
68
+ * Repo identity (`owner/repo`, lowercased) of any GitHub URL, ignoring the
69
+ * path after the repo — the plain repo page, monorepo subpaths, and the
70
+ * Release asset URLs `lookupRepoFromUrl` returns all fold to one key.
71
+ * Non-GitHub URLs return null.
72
+ *
73
+ * Update authorization for archive-URL installs (#768): the catalog entry
74
+ * has to own both the repo the archive came from and the registry name the
75
+ * update would use, and this is the repo side of that comparison.
76
+ */
77
+ export declare function catalogRepoKey(url: string): string | null;
78
+ /**
79
+ * Normalized identity of an install target, for comparing two targets that
80
+ * may be spelled differently — lowercased, matching `githubRepoIdentity`.
81
+ *
82
+ * @returns the identity, or null when the spec is not a GitHub source (an
83
+ * npm package name, a `file:` link, anything else).
84
+ */
85
+ export declare function repoOfTarget(spec: string): string | null;
86
+ /**
87
+ * The branch or tag a GitHub spec selects, or null for the default branch.
88
+ *
89
+ * Update detection has to ask about the same ref the install used, or it
90
+ * compares the installed commit against a line the user never chose (#446).
91
+ * A commit pin yields null: the answer for a pinned install is the default
92
+ * branch, which is what "is there something newer" means there.
93
+ */
94
+ export declare function githubRefOfTarget(spec: string): string | null;
95
+ /**
96
+ * The same question for every OTHER git source — a host shorthand or a plain
97
+ * remote URL.
98
+ *
99
+ * Their update check asks the remote for `HEAD`, which is the default branch.
100
+ * For an install that selected a branch or tag, that compares the installed
101
+ * commit against a line the user never chose: the row then offers an update
102
+ * forever, and the update itself re-resolves inside the same selector and
103
+ * never moves. That is #446, reached from a different direction.
104
+ */
105
+ export declare function gitRefOfTarget(spec: string): string | null;
106
+ /**
107
+ * True when the spec's `#…` fragment carries a `semver:` range selector.
108
+ *
109
+ * A semver range is a line the user chose on purpose, like a branch: pnpm
110
+ * re-resolves inside that range, so a raw HEAD version ABOVE the range is not
111
+ * installable — asking it would advertise an update forever (#446 shape).
112
+ * `refOfFragment` deliberately answers null for those, so the update check
113
+ * needs this separate probe.
114
+ */
115
+ export declare function hasSemverSelector(spec: string): boolean;
116
+ /**
117
+ * An immutable GitHub commit already carried by an install target.
118
+ *
119
+ * Build-script approval on pnpm below 11.21 needs the exact commit-pinned
120
+ * codeload key. Re-resolving HEAD after an install can race a repository push
121
+ * and approve a different URL, so consume an existing pin whenever the spec
122
+ * has one (#285/#385).
123
+ */
124
+ export declare function githubCommitOfTarget(spec: string): string | null;
125
+ /**
126
+ * Pin a GitHub shortcut to one immutable commit without losing its subpath.
127
+ * Revision selectors are replaced; one valid `path:` selector is preserved.
128
+ */
129
+ export declare function githubTargetAtCommit(spec: string, sha: string): string | null;
130
+ /**
131
+ * The allowBuilds key that actually authorizes a git-hosted dependency's
132
+ * build scripts. Verified against pnpm 11.21 (#68 by @yzr278892): for a
133
+ * `github:owner/repo` install, a bare `name: true` entry does NOT match —
134
+ * pnpm's own hint names a commit-pinned codeload URL that changes on every
135
+ * push; the stable form that matches is `name@git+https://github.com/owner/repo.git`.
136
+ *
137
+ * A legacy China-region install may address the SAME repo through a proxied
138
+ * codeload URL, and must authorize under the same key: the plugin a user
139
+ * approved build scripts for does not become a different plugin because its
140
+ * stored source spelling differs.
141
+ *
142
+ * @param name - installed package name.
143
+ * @param spec - the dependency spec from package.json, or the install target.
144
+ * @returns the stable key, or null when the spec is not a git source pnpm
145
+ * installs as one (an npm name, a local path, the scp-like `git@host:` form).
146
+ */
147
+ export declare function gitAllowBuildsKey(name: string, spec: string): string | null;
148
+ /**
149
+ * The OTHER allowBuilds key form, for pnpm below 11.21 (#285 by @omdsh-dev,
150
+ * following #267).
151
+ *
152
+ * The stable `name@git+https://…` key above is what pnpm 11.21+ matches, and
153
+ * it is the better key precisely because it does not change when the
154
+ * repository is pushed to. Older pnpm does not match it at all: 11.8.0 — the
155
+ * version DSH Desktop still bundles — matches only the commit-pinned
156
+ * codeload URL it names in its own `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`
157
+ * message. On those versions the "allow build scripts and retry" button
158
+ * could never work, because the key it wrote was one pnpm would never read.
159
+ *
160
+ * Both are written. The pinned form goes stale the moment the repository
161
+ * moves, which is why it cannot REPLACE the stable one — but a stale entry
162
+ * costs a line in a YAML file, and a missing one costs the user the only
163
+ * button that could have unblocked them.
164
+ *
165
+ * @param sha - the commit the install will actually fetch.
166
+ * @returns the key, or null when the spec is not github-hosted.
167
+ */
168
+ export declare function codeloadAllowBuildsKey(name: string, spec: string, sha: string): string | null;
169
+ /**
170
+ * The pinned allowBuilds key for a NON-GitHub git source — the other half of
171
+ * the pair `codeloadAllowBuildsKey` gives GitHub, for the same reason (#285):
172
+ * the stable clone-URL key is what pnpm 12 matches, while pnpm 11.8.0 — the
173
+ * version DSH Desktop bundles — matches only the commit-pinned id it names in
174
+ * its own error.
175
+ *
176
+ * Measured on 11.8.0: the stable key leaves a bitbucket install's build
177
+ * ignored, and `name@https://bitbucket.org/owner/repo/get/<sha>.tar.gz`
178
+ * authorizes it; for a plain remote the working key is
179
+ * `name@git+<remote>#<sha>`. Like the codeload one this goes stale the moment
180
+ * the repository is pushed to, which is why it is written ALONGSIDE the
181
+ * stable key and never instead of it.
182
+ */
183
+ export declare function pinnedGitAllowBuildsKey(name: string, spec: string, sha: string): string | null;
184
+ /**
185
+ * The repo (`owner/repo`, original case) of a GitHub remote spelled as a URL
186
+ * (`git+https://github.com/owner/repo.git`), or null for anything else.
187
+ *
188
+ * pnpm itself writes this spelling into the manifest for a GitHub source —
189
+ * the market sends `github:owner/repo`, pnpm answers with
190
+ * `git+https://owner/repo.git` (#803) — so the market must recognize it to
191
+ * keep deriving the GitHub keys for deps that only ever appear this way.
192
+ */
193
+ export declare function githubRepoOfRemote(spec: string): string | null;
194
+ /**
195
+ * Every commit-pinned allowBuilds key for one git source at one known commit
196
+ * (#784 by @sanqi-normal follow-up).
197
+ *
198
+ * Which pinned key pnpm checks depends on HOW it fetches the dependency,
199
+ * not on how the spec is spelled (review-measured on 11.7.0, empty store:
200
+ * a codeload download passes the codeload key and refuses the git+https#sha
201
+ * one; the git+https#sha refusal seen on dsh-better-sidebar came from a git
202
+ * clone fetch):
203
+ * - pnpm 11.21+ matches the stable unpinned clone-URL key (`gitAllowBuildsKey`).
204
+ * - a codeload download matches the commit-pinned codeload tarball URL.
205
+ * - a git clone matches the commit-pinned `name@git+https://…#<sha>` form,
206
+ * and only when it matches the remote's own spelling (`.git` or not,
207
+ * #665/#695 — pnpm matches the key literally).
208
+ *
209
+ * Writing ONE pinned form was the structural gap: a GitHub source derived
210
+ * only its codeload key, so a git-clone fetch ran with no key pnpm would
211
+ * read and only pnpm's own printed key could save the retry (#784's
212
+ * evidence). When the commit is known, BOTH pinned forms are written — one
213
+ * extra line in a YAML file versus the only button that could have
214
+ * unblocked the user.
215
+ *
216
+ * Non-GitHub remotes keep `pinnedGitAllowBuildsKey`'s single form: one key
217
+ * covers their fetch mode.
218
+ *
219
+ * @param sha - the commit the install will actually fetch.
220
+ * @returns the pinned keys (empty for no known git shape); callers merge the
221
+ * stable key from `gitAllowBuildsKey` alongside.
222
+ */
223
+ export declare function pinnedAllowBuildsKeys(name: string, spec: string, sha: string): string[];
224
+ /**
225
+ * The pnpm install target for a registry entry. Repo-verified npm packages
226
+ * win, followed by author-supplied prebuilt GitHub Release tarballs; both avoid
227
+ * full-repo downloads and local build scripts.
228
+ * @returns the target spec, or null when the source url is unsupported.
229
+ */
230
+ export declare function installTargetFor(entry: {
231
+ url: string;
232
+ npm?: unknown;
233
+ tarball?: unknown;
234
+ }): string | null;
235
+ /**
236
+ * The target to retry with when a prebuilt release tarball could not be
237
+ * installed — the entry's own GitHub source, which is what it would have
238
+ * installed from had it carried no `tarball` (#797).
239
+ *
240
+ * pnpm 11.0 through 11.8 records NO `integrity` for a bare release-asset URL
241
+ * under `nodeLinker: hoisted` (measured: 11.7.0 and 11.8.0 fail with
242
+ * ERR_PNPM_MISSING_TARBALL_INTEGRITY; 11.9.0 onward writes it and installs),
243
+ * and every DSH profile is hoisted. The same entry installs from `github:` on
244
+ * the same pnpm, so the fast path is kept where it works and this is where it
245
+ * degrades to.
246
+ * @returns the `github:` target, or null when the install target is not this
247
+ * entry's own verified release tarball (an npm package, or already source).
248
+ */
249
+ export declare function sourceFallbackFor(entry: {
250
+ url: string;
251
+ npm?: unknown;
252
+ tarball?: unknown;
253
+ }, target: string): string | null;
254
+ /** True for profile specs that are a local checkout or tarball, not a registry pin. */
255
+ export declare function isLocalSpec(spec: string): boolean;
256
+ export interface HostShorthand {
257
+ /** Lowercased scheme, i.e. the manifest's own spelling of the host. */
258
+ scheme: string;
259
+ /** The host that scheme resolves to. */
260
+ host: string;
261
+ /** `owner/repo`, or a nested group path on GitLab. No `.git`, no fragment. */
262
+ path: string;
263
+ /** Everything after `#`, empty when the spec carries no selector. */
264
+ fragment: string;
265
+ }
266
+ /**
267
+ * Split `<scheme>:<path>[#<selector>]` into its parts, or null when the spec
268
+ * is not one of the shorthands above or its path does not fit that host's
269
+ * shape. Used where a URL or an identity has to be BUILT from the spec;
270
+ * classification asks `hostShorthandScheme`, which is deliberately looser
271
+ * because pnpm hands the whole scheme to git regardless of what follows.
272
+ */
273
+ export declare function parseHostShorthand(spec: string): HostShorthand | null;
274
+ /**
275
+ * `host/path`, lowercased: the identity a git-hosted install keeps across
276
+ * its spellings — the shorthand, the clone URL it was typed as, and the
277
+ * archive tarball pnpm resolved it to.
278
+ *
279
+ * Host-qualified on purpose. `owner/repo` alone is not an identity: the
280
+ * same pair exists on github.com, gitlab.com and bitbucket.org, and a bare
281
+ * key would let one host's commit answer for another host's plugin.
282
+ *
283
+ * This answers "which repository is this", not "is this a git source" — it
284
+ * will happily key a registry tarball URL by its host. Ask `isGitHostedSpec`
285
+ * first, the way every caller here does.
286
+ */
287
+ export declare function hostedRepoKey(spec: string): string | null;
288
+ /**
289
+ * True when the install came from a git remote — host shorthands, codeload
290
+ * tarballs, and any other host (Gitea, GitLab self-host, raw `git+https://…`).
291
+ *
292
+ * Update detection used to ask only `repoOfTarget` (GitHub spellings). A
293
+ * private-host URL then fell through to the npm branch and was looked up by
294
+ * package name; a colliding registry package read as an "update" and
295
+ * `name@latest` replaced the git install (#525).
296
+ */
297
+ export declare function isGitHostedSpec(spec: string): boolean;
298
+ /**
299
+ * Immutable commit already carried by a non-shortcut git URL (`…git#<sha>`).
300
+ * GitHub shortcuts keep using `githubCommitOfTarget`.
301
+ */
302
+ export declare function gitCommitOfTarget(spec: string): string | null;
303
+ /**
304
+ * Pin a non-shortcut git URL to one immutable commit: the remote as spelled,
305
+ * with any ref, pin or selector fragment replaced by the commit, which pnpm
306
+ * re-resolves to exactly that commit. GitHub shortcuts and codeload URLs keep
307
+ * `githubTargetAtCommit` (#632).
308
+ *
309
+ * Three spellings are refused rather than promised:
310
+ * - a `path:` selector, because the `&` that carries it alongside a commit is
311
+ * outside the host's target grammar;
312
+ * - the scp-like `git@host:owner/repo.git`, which pnpm does not read as a git
313
+ * source at all — measured on 9.15.4 and 12.4.1, `pnpm add git@host:o/r.git`
314
+ * exits 0 having written a `link:` dependency literally named `git`;
315
+ * - a bare `https://host/owner/repo.git`, which pnpm 12 clones but pnpm 11 —
316
+ * what DSH Desktop still bundles — downloads as a tarball; it is returned
317
+ * with the `git+` prefix that means the same thing to both.
318
+ */
319
+ export declare function gitTargetAtCommit(spec: string, sha: string): string | null;
320
+ /**
321
+ * pnpm add target for updating a non-shortcut git install: drop a full-SHA
322
+ * pin so the remote re-resolves to HEAD, keep any branch/tag fragment.
323
+ * GitHub-hosted `git+https://github.com/…` is rewritten to `github:` — the
324
+ * market's canonical spelling — so a successful update rematerializes the
325
+ * dependency that way and later check/update/rollback can use the first-class
326
+ * GitHub path. This turn still installs through the generic-git target slot
327
+ * (no region acceleration on the rewritten shortcut itself).
328
+ *
329
+ * A gitlab/bitbucket shorthand is sent BACK to pnpm as the same shorthand,
330
+ * and deliberately not rewritten to `git+https://host/owner/repo.git`. Both
331
+ * install (measured on 12.4.1), but pnpm writes the shorthand into the
332
+ * manifest either way — so rewriting would send one spelling and get the
333
+ * other one back, leaving the target we sent, the manifest we then read, the
334
+ * duplicate-install guard and the allowBuilds key disagreeing about what was
335
+ * installed. Passthrough keeps all four on the single spelling pnpm itself
336
+ * settles on.
337
+ */
338
+ export declare function gitUpdateTarget(spec: string): string | null;
339
+ /**
340
+ * Smart-HTTP info/refs URL for a git-hosted install target, or null when the
341
+ * transport cannot be probed with `fetch` (scp / git:// / ssh://).
342
+ * Userinfo is stripped so update checks do not resend embedded credentials.
343
+ */
344
+ export declare function gitUploadPackUrl(spec: string): string | null;
345
+ /**
346
+ * A `link:` that points into a generation the desktop host materialised
347
+ * (#497): `link:../.generations/live/<pkg>+<version>+<hash>/node_modules/<pkg>`.
348
+ * That is the host's production install, not a developer's checkout — it
349
+ * came from the registry and has releases to compare against. The host
350
+ * recognises its own installs by the `.generations/live/` segment, and no
351
+ * hand-written link ever lands under that directory, so the same test is
352
+ * enough here.
353
+ */
354
+ export declare function isGenerationLink(spec: string): boolean;
355
+ export { findCatalogEntryForLocal, resolveCatalogRestore } from './catalog-local-match.ts';
356
+ /**
357
+ * pnpm add target for restoring a local checkout onto a catalog entry.
358
+ * When the catalog only lists the collection root but the checkout declared
359
+ * `repository.directory`, keep that subdirectory — otherwise we install the
360
+ * repo tarball and get the wrong package name (and its build scripts).
361
+ */
362
+ export declare function restoreTargetForLocal(entry: {
363
+ url: string;
364
+ npm?: unknown;
365
+ }, identities?: readonly string[]): string | null;
366
+ /**
367
+ * Dependency names that use pnpm's `workspace:` protocol.
368
+ * Those specs only resolve inside the author's monorepo; a git `#path:`
369
+ * install into a profile cannot see the sibling packages. pnpm installs
370
+ * optional dependencies and auto-installs peers too, so all three maps are
371
+ * scanned; devDependencies are never installed and stay out.
372
+ */
373
+ export declare function workspaceProtocolDeps(manifest: unknown): string[];
374
+ /** Git subdirectory restores cannot satisfy `workspace:` dependencies. npm can. */
375
+ export declare function restoreBlockedByWorkspace(target: string, workspaceDeps: readonly string[]): boolean;
376
+ /**
377
+ * The name an entry is ALREADY installed under, or null — the server-side
378
+ * duplicate guard (#27): the same plugin listed under an alias entry must
379
+ * never install twice (two loader entries with one id brick the next boot).
380
+ *
381
+ * Identity is subpath-aware so monorepo siblings stay independent: an entry
382
+ * with a /tree/ subpath identifies as repo#path:/sub (never the bare repo),
383
+ * while an installed dependency contributes its bare repo AND its #path:
384
+ * form — so a collection root still matches the pieces it was retargeted
385
+ * into, but two different subpackages of one repo never cross-match.
386
+ */
387
+ export declare function findInstalledAlias(entry: {
388
+ name: string;
389
+ npm?: unknown;
390
+ url: string;
391
+ }, installed: Record<string, string>): string | null;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 每个 profile 的状态目录名。
3
+ * 0.5 起由 `.dsh-shelfry` 改为 `.dsh-crate`,旧目录在首次访问时就地改名。
4
+ */
5
+ export declare const STATE_DIR_NAME = ".dsh-crate";
6
+ /**
7
+ * 返回可用的状态目录。
8
+ *
9
+ * 入参:profileDir —— profile 根目录的绝对路径。
10
+ * 返回:新目录路径;旧目录存在且新目录不存在时,先把旧目录改名再返回。
11
+ * 改名失败时回退到旧目录,保证数据仍可读写,不影响启动。
12
+ */
13
+ export declare function stateDir(profileDir: string): string;
14
+ /**
15
+ * 拼出状态目录下的文件路径。
16
+ *
17
+ * 入参:profileDir —— profile 根目录;parts —— 目录内的相对路径片段。
18
+ * 返回:完成迁移后的绝对路径。
19
+ */
20
+ export declare function statePath(profileDir: string, ...parts: string[]): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * pnpm store hygiene: reclaim staging directories orphaned by aborted runs,
3
+ * and the profile-side quarantine pnpm never empties (`node_modules/.ignored`).
4
+ *
5
+ * pnpm extracts every fetched tarball under the store's `tmp/` directory as
6
+ * `tmp/_tmp_<pid>_<hex>/`. A run that is killed, cancelled, or timed out —
7
+ * or one that hard-fails mid-fetch — never finishes that staging step, so
8
+ * the directory survives. For `github:` sources the staged payload is the
9
+ * WHOLE repository tarball, so a single aborted install can leave hundreds
10
+ * of megabytes behind (e.g. an OpenViking monorepo install killed at ~88MB).
11
+ *
12
+ * The directory name carries the owning pnpm process id, which makes
13
+ * reclamation safe by construction: when that pid is gone, no live download
14
+ * can be using the directory. Live pnpm tmp dirs are never touched.
15
+ *
16
+ * Separately, under `nodeLinker: hoisted` pnpm moves alien / interrupted
17
+ * package directories into `node_modules/.ignored` and never reclaims them
18
+ * (#974; pnpm #13720). Those copies are already out of the tree — Node does
19
+ * not resolve through `.ignored` — so they are safe to delete once our pnpm
20
+ * process has exited. The pid in a `_tmp_<pid>_` name is historical there
21
+ * and is not consulted (Windows reuses pids; a live match would skip a
22
+ * dead quarantine). `.bak` leftovers stay: they are someone else's wreckage,
23
+ * not pnpm staging (#205, #974).
24
+ */
25
+ import type { PluginRunner } from './dsh-cli.ts';
26
+ /**
27
+ * Remove every orphaned staging directory under a pnpm store's `tmp/` whose
28
+ * owning pid is no longer alive. Directories that do not match the pnpm
29
+ * staging shape, and any that are locked or in use, are left alone.
30
+ * @param storePath - the pnpm store root (as printed by `pnpm store path`).
31
+ * @returns the removed directory names.
32
+ */
33
+ export declare function cleanOrphanedStoreTmp(storePath: string): string[];
34
+ /**
35
+ * Resolve the active profile's pnpm store root through the same runner the
36
+ * market uses for installs (so both the web and Desktop pnpm paths agree)
37
+ * and reclaim its orphaned staging directories.
38
+ * @returns the removed directory names, empty when the store cannot be resolved.
39
+ */
40
+ export declare function cleanOrphanedStore(run: PluginRunner, profile: string): Promise<string[]>;
41
+ /**
42
+ * Remove quarantined copies under the profile's `node_modules/.ignored`,
43
+ * except `.bak` leftovers. Scoped directories are walked one level so a
44
+ * leftover `@jimp/png` is reclaimed without deleting `@scope/foo.bak-*`.
45
+ * Locked entries are left for a later run.
46
+ */
47
+ export declare function cleanOrphanedIgnored(profileDirectory: string): string[];
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Theme lifecycle: classifying installed packages as themes (by the
3
+ * registry's theme category), live-toggling bundle-layer entries through
4
+ * the loader, and keeping exactly one theme active with the choice
5
+ * persisted across restarts.
6
+ */
7
+ /** The slice of a cordis loader entry the market needs for live enable/disable. */
8
+ export interface LoaderEntry {
9
+ options: {
10
+ id?: string;
11
+ name?: string;
12
+ disabled?: boolean | null;
13
+ };
14
+ /**
15
+ * Whether the row is switched off, after evaluating any `disabled`
16
+ * expression it carries — so reading it can throw, and callers that only
17
+ * want to know "is this row off" wrap the read (#1023).
18
+ */
19
+ disabled?: boolean;
20
+ fiber?: unknown;
21
+ update(options: {
22
+ disabled: boolean | null;
23
+ }, create?: boolean, force?: boolean): Promise<void>;
24
+ }
25
+ /** The host surface the theme manager needs (loader entries + hot-mount context). */
26
+ export interface ThemeHost {
27
+ loader: {
28
+ entries(): Iterable<LoaderEntry>;
29
+ };
30
+ plugin(plugin: unknown, config: unknown): {
31
+ await(): Promise<unknown>;
32
+ dispose(): Promise<unknown> | void;
33
+ };
34
+ }
35
+ /** Manages theme exclusivity for one profile. */
36
+ export interface ThemeManager {
37
+ installedThemeNames(): Promise<Set<string>>;
38
+ setEntryDisabled(name: string, disabledFlag: boolean, requireLive?: boolean, rejectPending?: boolean): Promise<boolean>;
39
+ activateTheme(name: string): Promise<boolean>;
40
+ }
41
+ /**
42
+ * Create the theme manager. `disabledThemes` is the live, shared set of
43
+ * themes the user switched off — the caller owns reading it at boot and
44
+ * replaying it; the manager mutates and persists it on switches.
45
+ */
46
+ export declare function createThemeManager(host: ThemeHost, profile: string, disabledThemes: Set<string>, explicitDir?: string): ThemeManager;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Trial validation for composition changes — issue #98 (phase 3), the
3
+ * "trial boot" half of #19 reduced to what is safe and offline: before any
4
+ * bundle-order or preset change is written to the profile, replay the
5
+ * composition with the CANDIDATE order using the same entry-list machinery
6
+ * the real boot uses (src/check.ts's buildBundleLayers + composeLayers), and
7
+ * refuse the change when the composed tree would fail to boot (duplicate
8
+ * loader entry ids, unresolvable bundle layers, unparseable patches).
9
+ *
10
+ * No process, no network, no writes to the profile: the real profile is only
11
+ * read; if the candidate is bad, the failure is reported and nothing is
12
+ * applied (the caller then skips the write-back entirely).
13
+ *
14
+ * Issue #125 review: the CURRENT composition is replayed alongside the
15
+ * candidate, so the response also carries a current-vs-candidate diff
16
+ * (overrides / orphans / duplicates the reorder introduces) — not just
17
+ * whether it boots.
18
+ *
19
+ * Bundle resolution is deliberately SHARED with the check report
20
+ * (check.ts's buildBundleLayers): the dsh installation anchor first, then
21
+ * Node's module search from the profile (workspace-root hoisting) — so the
22
+ * trial can never disagree with the diagnostics about what a bundle is or
23
+ * where it lives, and official bundles resolve even when they are only
24
+ * hoisted to the workspace root.
25
+ */
26
+ import { type DuplicateId, type OrphanRow, type OverrideRow } from './check.ts';
27
+ export interface TrialIssue {
28
+ layer: string;
29
+ message: string;
30
+ }
31
+ /** Current-vs-candidate composition diff (issue #125 review). */
32
+ export interface TrialDiff {
33
+ /** Override relationships introduced by the candidate (not present in the current composition). */
34
+ overrides: OverrideRow[];
35
+ /** Orphan rows introduced by the candidate. */
36
+ orphans: OrphanRow[];
37
+ /** Duplicate loader entry ids introduced by the candidate. */
38
+ duplicates: DuplicateId[];
39
+ }
40
+ export interface TrialResult {
41
+ ok: boolean;
42
+ errors: TrialIssue[];
43
+ warnings: TrialIssue[];
44
+ duplicates: DuplicateId[];
45
+ /** The composed loader rows under the candidate order. */
46
+ rows: {
47
+ id: string;
48
+ layer: string;
49
+ }[];
50
+ /** What the reorder would change vs the current composition (issue #125 review). */
51
+ diff: TrialDiff;
52
+ }
53
+ /**
54
+ * Replay the profile composition with `newCommunityOrder` (the candidate
55
+ * community-bundle order; official bundles keep their exact positions) and
56
+ * report anything that would break the boot. Pure read.
57
+ */
58
+ export declare function trialValidate(profileDir: string, newCommunityOrder: string[], options?: {
59
+ dshInstallDir?: string | null;
60
+ homeDir?: string;
61
+ }): TrialResult;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Stable, versioned contract for plugin-owned update surfaces.
3
+ *
4
+ * The market UI has richer internal response shapes that evolve with its UI.
5
+ * Third-party plugins must not depend on those shapes, so this module owns the
6
+ * small JSON envelope exposed under `/dsh-crate/api/v1`.
7
+ */
8
+ import type { InstallProgress } from './dsh-cli.ts';
9
+ export declare const UPDATE_API_V1_SCHEMA: 'dsh-crate/update-api/v1';
10
+ export declare const MAX_UPDATE_OPERATIONS_V1 = 50;
11
+ export type UpdateOperationState = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'rolled-back';
12
+ export interface UpdateFailureV1 {
13
+ code: string;
14
+ message: string;
15
+ retryable: boolean;
16
+ }
17
+ export interface UpdateOperationV1 {
18
+ schema: typeof UPDATE_API_V1_SCHEMA;
19
+ operationId: string;
20
+ kind: 'update';
21
+ packageName: string;
22
+ state: UpdateOperationState;
23
+ createdAt: number;
24
+ startedAt: number | null;
25
+ finishedAt: number | null;
26
+ beforeVersion: string | null;
27
+ installedVersion: string | null;
28
+ progress: {
29
+ phase: string | null;
30
+ done: number;
31
+ total: number | null;
32
+ percent: number | null;
33
+ currentPackage: string | null;
34
+ detail: string | null;
35
+ downloaded: number | null;
36
+ size: number | null;
37
+ };
38
+ outcome: {
39
+ refreshRequired: boolean;
40
+ restartRequired: boolean;
41
+ rollback: {
42
+ available: boolean;
43
+ state: 'unavailable' | 'available' | 'running' | 'succeeded' | 'failed';
44
+ detail: string | null;
45
+ };
46
+ };
47
+ failure: UpdateFailureV1 | null;
48
+ /**
49
+ * Present while a deferred operation is waiting for a safe boundary. The
50
+ * state remains `queued`; this explains why (#411).
51
+ */
52
+ wait: {
53
+ reason: 'agents';
54
+ activeCount: number;
55
+ activeAgentIds: string[];
56
+ since: number;
57
+ } | null;
58
+ }
59
+ /** Process-local operation registry. A boot id scopes ids across restarts. */
60
+ export declare class UpdateOperationStoreV1 {
61
+ private readonly bootId;
62
+ private readonly now;
63
+ private readonly maxOperations;
64
+ private sequence;
65
+ private readonly operations;
66
+ private activeId;
67
+ constructor(bootId: string, now?: () => number, maxOperations?: number);
68
+ hasActive(): boolean;
69
+ create(packageName: string, beforeVersion: string | null): UpdateOperationV1;
70
+ start(operationId: string): void;
71
+ /**
72
+ * Explain why a deferred operation is still queued. Additive: an operation
73
+ * that never waits keeps `wait: null`.
74
+ */
75
+ setWait(operationId: string, wait: UpdateOperationV1['wait']): UpdateOperationV1 | null;
76
+ /** Project the post-pnpm validation window as `running` + phase `verifying`. */
77
+ beginVerifying(operationId: string): void;
78
+ finish(operationId: string, status: number, payload: unknown, installedVersion: string | null): UpdateOperationV1 | null;
79
+ beginRollback(operationId: string): string | null;
80
+ finishRollback(operationId: string, status: number, payload: unknown, installedVersion?: string | null): UpdateOperationV1 | null;
81
+ get(operationId: string, progress?: InstallProgress): UpdateOperationV1 | null;
82
+ private snapshot;
83
+ }