@sparkelf/dsh-plus 0.2.7-alpha.50 → 0.2.9-alpha.100

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 (56) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +1 -1
  3. package/README.zh.md +1 -1
  4. package/cordis.patch.yml +29 -7
  5. package/lib/{apply-DmICvIGh.js → apply-CvePS57c.js} +213 -43
  6. package/lib/{apply-08huHfLG.js → apply-DycMqLJO.js} +240 -53
  7. package/lib/apply-c_7SZFSh.js +1193 -0
  8. package/lib/apply.js +2 -2
  9. package/lib/bin.js +20 -319
  10. package/lib/types/apply.d.ts +14 -1
  11. package/lib/types/apply.js +275 -53
  12. package/lib/types/capabilities.js +25 -36
  13. package/lib/types/manifest.d.ts +24 -0
  14. package/lib/types/manifest.js +51 -0
  15. package/lib/types/profile.d.ts +1 -0
  16. package/lib/types/profile.js +14 -3
  17. package/package.json +529 -577
  18. package/patches/approval-allow-policy.patch +3 -3
  19. package/patches/atomic-write-zombie-lock-holder.patch +1 -1
  20. package/patches/bootstrap-exempt-names.patch +6 -6
  21. package/patches/composer-popover-boundaries.patch +41 -283
  22. package/patches/image-offload-hoist-replay.patch +34 -31
  23. package/patches/input-trigger-source-label.patch +63 -0
  24. package/patches/legacy-code-preset.patch +5 -5
  25. package/patches/llm-pi-ai-transport-truncation.patch +4 -4
  26. package/patches/mobile-journal-generation.patch +2 -2
  27. package/patches/office-preview-stable-load.patch +1 -1
  28. package/patches/officecli-deliverables.patch +2 -2
  29. package/patches/ptc-mcp-schema-types.patch +3 -3
  30. package/patches/responses-reasoning-status.patch +197 -48
  31. package/patches/session-controller-image-downgrade-and-tool-visibility.patch +16 -14
  32. package/patches/session-export-chinese.patch +11 -11
  33. package/patches/session-format-legacy-restart.patch +1 -1
  34. package/patches/sidebar-right-tab-menu.patch +119 -0
  35. package/patches/state-dot-brand-blue.patch +2 -2
  36. package/patches/ui-settings-compact-phone.patch +2 -9
  37. package/patches/ui-sidebar-right-global-panel.patch +3 -3
  38. package/patches/workspace-hide-group-rooms.patch +38 -0
  39. package/patches/workspace-storage-restore.patch +21 -5
  40. package/patches/wsl-native-open.patch +8 -8
  41. package/lib/apply-e0aMC4B4.js +0 -601
  42. package/lib/types/standalone-capabilities.d.ts +0 -139
  43. package/lib/types/standalone-capabilities.js +0 -688
  44. package/lib/types/standalone-cli.d.ts +0 -17
  45. package/lib/types/standalone-cli.js +0 -913
  46. package/lib/types/standalone-profile.d.ts +0 -258
  47. package/lib/types/standalone-profile.js +0 -747
  48. package/lib/types/standalone-server.d.ts +0 -70
  49. package/lib/types/standalone-server.js +0 -158
  50. package/patches/browser-auth-mode.patch +0 -127
  51. package/patches/diagram-preview.patch +0 -562
  52. package/patches/dsh-resource-ref-chip.patch +0 -40
  53. package/patches/session-envelope-ignorable.patch +0 -63
  54. package/patches/session-log-trajectory-toolbar.patch +0 -352
  55. package/patches/ui-schedule-plaza-tab.patch +0 -217
  56. package/patches/web-runtime-compat.patch +0 -83
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/bundle/plus/README.md
5
- README.md: 6bba650085777934ec620db2c4595f1f86902fd0
6
- README.zh.md: f4326b76dc011c2f41693105937e6532a5a277b0
5
+ README.md: 176fb28972e0f84c33b60913ff87d0d134ec7267
6
+ README.zh.md: 140360e17c3cd8f9322a9bb050c06bc1dd884298
package/README.md CHANGED
@@ -33,7 +33,7 @@ dsh --profile plus
33
33
 
34
34
  The explicit rc24 apply step requires official revision `fb2c4b9e698e30edb738bca4cf0618587db7d203`, applies every pending source payload, configures exact npm patches, removes retired Plus-owned entries, and writes `.dsh-plus/patchset.lock.json` with mode `0600`. Patched official source workspaces always replace clean CLI packages in the profile scope. The profile resolves SQL Workbench 0.5.0, Workbench Vault 0.1.1, SSH Manager 0.7.0, API Client 0.5.0, Supervisor 0.1.4, GenUI 0.9.9, dshmarket 1.45.1, OfficeCLI 0.1.1, MinerU 0.1.1, and Mobile Bridge 0.2.11 from npm. Version conflicts, source mismatches, missing bundles, and runtime closure drift stop promotion.
35
35
 
36
- Official DSH supplies Sidebar navigation, file and text preview, Session search, generic file upload, durable attachment cards, read-only model paths, onboarding, Workspace selection, Session export, and Turn folding. Plus configures the official SQLite Session query provider to open on first search with a durable derived index at `$DSH_HOME/storages/session-query.sqlite`; canonical compressed JSONL remains the history source. Plus adds an OfficeCLI tool for original DOCX/XLSX/PPTX production and a MinerU PDF tool that consumes the official uploaded-file path without a prompt hook. It replaces mixed English `Session` wording in the Simplified-Chinese export UI, places the desktop Session-log action immediately before Trajectory search while retaining its Header position on phones, and keeps composer permission and model popovers inside the center column with 12px horizontal clearance. `@changfenhuang/dsh-genui@0.9.9` now contains the previously patched streaming EChart behavior. The registry-pinned Supervisor manages the materialized runtime and restores Sessions interrupted by its own restart. DataOps and MinerU mount only when their endpoint environment variables exist. Agent Teams remains excluded because official shipped profiles disable those private experimental packages.
36
+ Official DSH supplies Sidebar navigation, file and text preview, Session search, generic file upload, durable attachment cards, read-only model paths, onboarding, Workspace selection, Session export, and Turn folding. Plus configures the official SQLite Session query provider to open on first search with a durable derived index at `$DSH_HOME/storages/session-query.sqlite`; canonical compressed JSONL remains the history source. Plus adds an OfficeCLI tool for original DOCX/XLSX/PPTX production and a MinerU PDF tool that consumes the official uploaded-file path without a prompt hook. It replaces mixed English `Session` wording in the Simplified-Chinese export UI, places the desktop Session-log action immediately before Trajectory search while retaining its Header position on phones, and keeps composer permission and model popovers inside the center column with 12px horizontal clearance. `@changfenhuang/dsh-genui@0.9.9` now contains the previously patched streaming EChart behavior. The registry-pinned Supervisor manages the materialized runtime and restores Sessions interrupted by its own restart. DataOps and MinerU mount only when their endpoint environment variables exist. The profile mounts the official Exa search provider; `web_search` routes through `exa` when `EXA_API_KEY` is present in the launch environment and otherwise keeps the official `deepseek-search-api` provider. Agent Teams remains excluded because official shipped profiles disable those private experimental packages.
37
37
 
38
38
  Plus explicitly selects `browserAuthentication: disabled`: its Web URL is clean and opens without a process-token exchange or browser cookie, while Connection still applies the official Host/Origin trust fence. Every process that can reach an accepted authority can therefore use the complete Host API, including Shell, files, and Sessions. The official `web` profile keeps the upstream `required` default; only the Plus composition opts out.
39
39
 
package/README.zh.md CHANGED
@@ -33,7 +33,7 @@ dsh --profile plus
33
33
 
34
34
  rc24 explicit apply步骤固定official revision `fb2c4b9e698e30edb738bca4cf0618587db7d203`,一次应用全部pending source payloads,配置exact npm patches,删除retired Plus-owned entries,并以`0600` mode写入`.dsh-plus/patchset.lock.json`。profile中的patched official source workspaces始终覆盖clean CLI packages。profile从npm解析SQL Workbench 0.5.0、Workbench Vault 0.1.1、SSH Manager 0.7.0、API Client 0.5.0、Supervisor 0.1.4、GenUI 0.9.9、dshmarket 1.45.1、OfficeCLI 0.1.1、MinerU 0.1.1及Mobile Bridge 0.2.11。version conflict、source mismatch、bundle缺失和runtime closure drift都会阻止promotion。
35
35
 
36
- Official DSH提供Sidebar navigation、file与text preview、Session search、generic file upload、durable attachment cards、model-visible readonly paths、onboarding、Workspace selection、Session export及Turn folding。Plus把official SQLite Session query provider配置为首次搜索时打开,持久派生索引位于`$DSH_HOME/storages/session-query.sqlite`,canonical compressed JSONL仍为history source。Plus增加用于生成原始DOCX/XLSX/PPTX的OfficeCLI工具,以及无需prompt hook、直接消费official uploaded-file path的MinerU PDF工具;同时把简体中文导出界面中混用的英文`Session`替换为中文,在桌面端把会话日志操作放到Trajectory搜索框紧邻左侧,在手机上保留其Header位置,并让composer permission与model popover保持在center column内且水平边缘各留12px间距。`@changfenhuang/dsh-genui@0.9.9`已内含此前patch的streaming EChart behavior。registry-pinned Supervisor管理materialized runtime并恢复被自身restart中断的Sessions。DataOps和MinerU仅在对应endpoint environment variables存在时mount。Agent Teams仍被排除,因为official shipped profiles禁用这些private experimental packages。
36
+ Official DSH提供Sidebar navigation、file与text preview、Session search、generic file upload、durable attachment cards、model-visible readonly paths、onboarding、Workspace selection、Session export及Turn folding。Plus把official SQLite Session query provider配置为首次搜索时打开,持久派生索引位于`$DSH_HOME/storages/session-query.sqlite`,canonical compressed JSONL仍为history source。Plus增加用于生成原始DOCX/XLSX/PPTX的OfficeCLI工具,以及无需prompt hook、直接消费official uploaded-file path的MinerU PDF工具;同时把简体中文导出界面中混用的英文`Session`替换为中文,在桌面端把会话日志操作放到Trajectory搜索框紧邻左侧,在手机上保留其Header位置,并让composer permission与model popover保持在center column内且水平边缘各留12px间距。`@changfenhuang/dsh-genui@0.9.9`已内含此前patch的streaming EChart behavior。registry-pinned Supervisor管理materialized runtime并恢复被自身restart中断的Sessions。DataOps和MinerU仅在对应endpoint environment variables存在时mount。profile挂载official Exa search provider:launch environment中存在`EXA_API_KEY`时`web_search`路由到`exa`,否则继续使用official `deepseek-search-api` provider。Agent Teams仍被排除,因为official shipped profiles禁用这些private experimental packages。
37
37
 
38
38
  Plus显式选择`browserAuthentication: disabled`:其Web URL保持clean,无需process-token exchange或browser cookie即可打开,同时Connection仍执行official Host/Origin trust fence。因此所有能访问accepted authority的进程都能使用包含Shell、files与Sessions在内的完整Host API。official `web` profile保留upstream `required` default;只有Plus composition选择关闭。
39
39
 
package/cordis.patch.yml CHANGED
@@ -1,13 +1,17 @@
1
1
  # A patch row inherits the `inject` of the row it names rather than declaring its own,
2
- # so this row states both services. `webStartup` is the current provider; `webRuntime` is
3
- # the pre-alpha.2 name the dsh-web-app patch republishes for the third-party bundles that
4
- # still inject it (dsh-better-sidebar, dsh-video-preview). Reading the old service keeps
5
- # this layer working whichever of the two a deployment's web-app patch provides.
2
+ # so this row states the service it reads. 0.2.3 renamed the bind-dependent provider from
3
+ # `webRuntime` to `webStartup`; the old name is gone from this distribution, and the
4
+ # third-party bundles that once injected it are released against the new name.
6
5
  - id: connection
7
- inject: [webStartup, webRuntime]
6
+ inject: [webStartup]
8
7
  config:
9
- trustedHosts: !!js ctx.webRuntime.trustedHosts
10
- browserAuthentication: disabled
8
+ trustedHosts: !!js ctx.webStartup.trustedHosts
9
+
10
+ # Third-party bundles released before 0.2.3 inject `webRuntime`, which the base
11
+ # renamed to `webStartup`. Re-publish the old service so those bundles activate.
12
+ - insert:
13
+ - id: web-runtime-compat
14
+ name: '@sparkelf/dsh-web-runtime-compat'
11
15
 
12
16
  # The derived index behind session history search. `first-search` builds it when a
13
17
  # search first asks for it rather than delaying every start.
@@ -95,3 +99,21 @@
95
99
  name: '@sparkelf/dsh-image-hoist'
96
100
  config:
97
101
  providers: []
102
+
103
+ # Web search: the distribution ships Exa as its second search provider. The plugin
104
+ # reports itself unavailable until `EXA_API_KEY` resolves, so mounting the row is inert
105
+ # for a deployment without a key; the selector below then keeps the official DeepSeek
106
+ # Search API. With a key, Exa serves `web_search` and the selector replaces the base
107
+ # layer's `deepseek-search-api` default. A patch replaces the row's whole config object,
108
+ # so `fetchProvider` is restated rather than inherited.
109
+ - insert:
110
+ - id: web-search-exa
111
+ name: '@deepseek-ai/dsh-web-search-exa'
112
+ config:
113
+ searchType: auto
114
+ numResults: 8
115
+
116
+ - id: web
117
+ config:
118
+ searchProvider: !!js "process.env.EXA_API_KEY ? 'exa' : 'deepseek-search-api'"
119
+ fetchProvider: http
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { spawnSync } from "node:child_process";
3
3
  import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
- import { basename, dirname, isAbsolute, relative, resolve } from "node:path";
5
- import { tmpdir } from "node:os";
4
+ import { dirname, isAbsolute, relative, resolve } from "node:path";
6
5
  import { satisfies, valid, validRange } from "semver";
6
+ import { tmpdir } from "node:os";
7
7
  import { parseDocument } from "yaml";
8
8
  //#region lib/types/patch-set.js
9
9
  /**
@@ -125,7 +125,7 @@ function readPatchSet(distributionDirectory, manifest) {
125
125
  }
126
126
  //#endregion
127
127
  //#region lib/types/apply.js
128
- /** Materialize the Plus distribution's embedded patch set without Desktop. */
128
+ /** Materialize the Plus distribution's independent patch packages without Desktop. */
129
129
  const FORMAT_VERSION = 1;
130
130
  function isSelectedNpmPatch(patch) {
131
131
  return patch.target.kind === "npm";
@@ -169,6 +169,44 @@ function resolveInstalledPackage(distributionDirectory, packageName) {
169
169
  manifest
170
170
  };
171
171
  }
172
+ function resolvePatchFile(packageDirectory, declared) {
173
+ const absoluteFile = resolve(packageDirectory, declared);
174
+ const local = relative(packageDirectory, absoluteFile);
175
+ if (isAbsolute(local) || local === ".." || local.startsWith("../")) throw new Error("patch file must stay inside its patch package: " + declared);
176
+ if (!existsSync(absoluteFile)) throw new Error("patch file does not exist: " + absoluteFile);
177
+ return {
178
+ relativeFile: local.replaceAll("\\", "/"),
179
+ absoluteFile
180
+ };
181
+ }
182
+ function parseVariant(value, index, patchPackage) {
183
+ const label = patchPackage.name + " dshPatch.variants[" + String(index) + "]";
184
+ const variant = requireObject(value, label);
185
+ const target = requireObject(variant.target, label + ".target");
186
+ const kind = requireString(target.kind, label + ".target.kind");
187
+ const common = {
188
+ id: requireString(variant.id, label + ".id"),
189
+ dsh: requireRange(variant.dsh, label + ".dsh"),
190
+ file: requireString(variant.file, label + ".file"),
191
+ patchPackage
192
+ };
193
+ if (kind === "npm") return {
194
+ ...common,
195
+ target: {
196
+ kind,
197
+ name: requireString(target.name, label + ".target.name"),
198
+ range: requireRange(target.range, label + ".target.range")
199
+ }
200
+ };
201
+ if (kind === "dsh-source") return {
202
+ ...common,
203
+ target: {
204
+ kind,
205
+ baseRevision: requireString(target.baseRevision, label + ".target.baseRevision")
206
+ }
207
+ };
208
+ throw new Error("unsupported patch target kind: " + kind);
209
+ }
172
210
  function git(root, args, acceptFailure = false) {
173
211
  const result = spawnSync("git", args, {
174
212
  cwd: root,
@@ -237,6 +275,73 @@ function requireSourceBase(root, baseRevision) {
237
275
  if (checkoutRevision !== baseRevision) throw new Error("DSH checkout must be exact official base " + baseRevision + ", found " + checkoutRevision);
238
276
  return checkoutRevision;
239
277
  }
278
+ /**
279
+ * Names of distribution dependencies that carry `dshPatch` variants.
280
+ *
281
+ * `patchPackageVariants()` resolves these names from the Plus install tree, so they must be
282
+ * packages this distribution actually depends on. The current manifest declares `dshPlus.patchSet`
283
+ * instead of a flat list: only entries whose target is an npm package name a `dshPatch` carrier
284
+ * (`dsh-source` entries name the source packages being patched, which are never Plus dependencies).
285
+ * An older tarball may still carry the flat `dshPlus.patchPackages` list, which wins when present.
286
+ *
287
+ * @param plus - Parsed `dshPlus` block of the distribution manifest.
288
+ * @returns Patch-carrier package names; empty when the distribution ships only source patches.
289
+ */
290
+ function resolvePatchPackageNames(plus) {
291
+ const declared = plus.patchPackages;
292
+ if (declared !== void 0) {
293
+ const names = requireStringArray(declared, "dshPlus.patchPackages");
294
+ if (names.length > 0) return names;
295
+ }
296
+ const entries = requireObject(plus.patchSet, "dshPlus.patchSet").entries;
297
+ if (!Array.isArray(entries)) throw new Error("dshPlus.patchSet.entries must be an array");
298
+ const names = /* @__PURE__ */ new Set();
299
+ for (const [index, value] of entries.entries()) {
300
+ const target = requireObject(requireObject(value, "dshPlus.patchSet.entries[" + String(index) + "]").target, "dshPlus.patchSet.entries[" + String(index) + "].target");
301
+ if (target.kind !== "npm") continue;
302
+ names.add(requireString(target.name, "dshPlus.patchSet.entries[" + String(index) + "].target.name"));
303
+ }
304
+ return [...names].sort();
305
+ }
306
+ function patchPackageVariants(distributionDirectory, names) {
307
+ const variants = [];
308
+ for (const name of names) {
309
+ const patchPackage = resolveInstalledPackage(distributionDirectory, name);
310
+ const declaration = requireObject(patchPackage.manifest.dshPatch, name + " dshPatch");
311
+ if (declaration.formatVersion !== FORMAT_VERSION) throw new Error("unsupported dshPatch formatVersion in " + name + ": " + String(declaration.formatVersion));
312
+ if (!Array.isArray(declaration.variants) || declaration.variants.length === 0) throw new Error(name + " dshPatch.variants must be a non-empty array");
313
+ for (const [index, value] of declaration.variants.entries()) variants.push(parseVariant(value, index, patchPackage));
314
+ }
315
+ return variants;
316
+ }
317
+ /**
318
+ * Build patch variants from the distribution's `dshPlus.patchSet`.
319
+ *
320
+ * The patch files live inside the Plus package (`./patches/*.patch`), so every variant points at
321
+ * the distribution itself as its patch package: `resolvePatchFile()` then resolves the declared
322
+ * path inside the tarball, and `materializePatchFiles()` copies it into the profile's stable
323
+ * patch directory. Unlike the retired `dshPatch` carrier packages, the source packages named in
324
+ * `target.packages` are never resolved from the Plus tree -- they are the packages being patched.
325
+ *
326
+ * @param distribution - Installed Plus distribution package.
327
+ */
328
+ function patchSetVariants(distribution) {
329
+ const patchSet = readPatchSet(distribution.directory, distribution.manifest);
330
+ return [...patchSet.entries, ...patchSet.thirdPartyPatches].map((entry) => ({
331
+ id: entry.id,
332
+ dsh: entry.dsh,
333
+ file: entry.file,
334
+ patchPackage: distribution,
335
+ target: entry.target.kind === "npm" ? {
336
+ kind: "npm",
337
+ name: entry.target.name,
338
+ range: entry.target.range
339
+ } : {
340
+ kind: "dsh-source",
341
+ baseRevision: entry.target.baseRevision
342
+ }
343
+ }));
344
+ }
240
345
  function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
241
346
  const distributionManifest = readJsonObject(resolve(distributionDirectory, "package.json"), "Plus distribution manifest");
242
347
  const distributionName = requireString(distributionManifest.name, "Plus distribution name");
@@ -256,18 +361,29 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
256
361
  if (typeof allowed !== "boolean") throw new Error("dshPlus.profile.allowBuilds." + name + " must be a boolean");
257
362
  allowBuilds[name] = allowed;
258
363
  }
259
- const patchSet = readPatchSet(distributionDirectory, distributionManifest);
364
+ const patchPackageNames = resolvePatchPackageNames(plus);
260
365
  const dependencies = requireObject(distributionManifest.dependencies, "Plus distribution dependencies");
261
366
  const dshVersion = requireVersion(readJsonObject(resolve(dshRoot, "package.json"), "DSH source manifest").version, "DSH source version");
262
367
  if (!satisfies(dshVersion, dshRange, { includePrerelease: true })) throw new Error(distributionName + "@" + distributionVersion + " requires DSH " + dshRange + ", found " + dshVersion);
263
- const checkoutRevision = requireSourceBase(dshRoot, patchSet.sourceBaseRevision);
264
- const patchEntries = [...patchSet.entries, ...patchSet.thirdPartyPatches];
368
+ const checkoutRevision = requireSourceBase(dshRoot, baseRevision);
369
+ const variants = plus.patchPackages === void 0 ? patchSetVariants({
370
+ name: distributionName,
371
+ version: distributionVersion,
372
+ directory: distributionDirectory,
373
+ manifest: distributionManifest
374
+ }) : patchPackageVariants(distributionDirectory, patchPackageNames);
375
+ const groups = /* @__PURE__ */ new Map();
376
+ for (const variant of variants) {
377
+ const entries = groups.get(variant.id) ?? [];
378
+ entries.push(variant);
379
+ groups.set(variant.id, entries);
380
+ }
265
381
  const sourceStates = /* @__PURE__ */ new Map();
266
- for (const item of patchEntries) {
267
- if (!satisfies(dshVersion, item.dsh, { includePrerelease: true })) throw new Error("patch " + item.id + " declares DSH " + item.dsh + ", found " + dshVersion);
268
- if (item.target.kind !== "dsh-source") continue;
269
- const absoluteFile = resolve(distributionDirectory, item.file);
270
- sourceStates.set(absoluteFile, sourcePatchState(dshRoot, absoluteFile));
382
+ const orderedGroups = [...groups].sort(([left], [right]) => left.localeCompare(right));
383
+ for (const [, variants] of orderedGroups) for (const variant of variants) {
384
+ if (variant.target.kind !== "dsh-source" || variant.target.baseRevision !== baseRevision || !satisfies(dshVersion, variant.dsh, { includePrerelease: true })) continue;
385
+ const file = resolvePatchFile(variant.patchPackage.directory, variant.file);
386
+ sourceStates.set(file.absoluteFile, sourcePatchState(dshRoot, file.absoluteFile));
271
387
  }
272
388
  preflightSourcePatches(dshRoot, [...sourceStates].flatMap(([file, state]) => state === "pending" ? [file] : []));
273
389
  writeProfileRequirements(profileDirectory, profileDependencySpecs, allowBuilds);
@@ -278,42 +394,55 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
278
394
  version: resolveInstalledPackage(profileDirectory, name).version
279
395
  };
280
396
  });
281
- const runtimePackages = [...Object.keys(dependencies).sort().map((name) => {
397
+ const runtimePackages = [...Object.keys(dependencies).filter((name) => !patchPackageNames.includes(name)).sort().map((name) => {
282
398
  return {
283
399
  name,
284
400
  version: resolveInstalledPackage(distributionDirectory, name).version
285
401
  };
286
402
  }), ...profileDependencies].sort((left, right) => left.name.localeCompare(right.name));
287
403
  const selected = [];
288
- for (const item of patchEntries) {
289
- const absoluteFile = resolve(distributionDirectory, item.file);
290
- if (item.target.kind === "dsh-source") {
291
- selected.push({
292
- id: item.id,
293
- scope: item.scope,
294
- file: item.file,
295
- absoluteFile,
296
- target: {
297
- kind: "dsh-source",
298
- baseRevision: patchSet.sourceBaseRevision
299
- },
300
- alreadyApplied: sourceStates.get(absoluteFile) === "applied"
301
- });
302
- continue;
303
- }
304
- const targetVersion = resolveInstalledPackage(item.target.name in profileDependencySpecs ? profileDirectory : distributionDirectory, item.target.name).version;
305
- if (!satisfies(targetVersion, item.target.range, { includePrerelease: true })) throw new Error("patch " + item.id + " targets " + item.target.name + " " + item.target.range + ", found " + targetVersion);
306
- selected.push({
307
- id: item.id,
308
- scope: item.scope,
309
- file: item.file,
310
- absoluteFile,
311
- target: {
312
- kind: "npm",
313
- name: item.target.name,
314
- version: targetVersion
404
+ for (const [id, variants] of orderedGroups) {
405
+ const candidates = variants.flatMap((variant) => {
406
+ if (!satisfies(dshVersion, variant.dsh, { includePrerelease: true })) return [];
407
+ const file = resolvePatchFile(variant.patchPackage.directory, variant.file);
408
+ if (variant.target.kind === "dsh-source") {
409
+ if (variant.target.baseRevision !== baseRevision) return [];
410
+ return [{
411
+ id,
412
+ patchPackage: {
413
+ name: variant.patchPackage.name,
414
+ version: variant.patchPackage.version
415
+ },
416
+ file: file.relativeFile,
417
+ absoluteFile: file.absoluteFile,
418
+ target: {
419
+ kind: "dsh-source",
420
+ baseRevision
421
+ },
422
+ alreadyApplied: sourceStates.get(file.absoluteFile) === "applied"
423
+ }];
315
424
  }
425
+ const targetVersion = resolveInstalledPackage(variant.target.name in profileDependencySpecs ? profileDirectory : distributionDirectory, variant.target.name).version;
426
+ if (!satisfies(targetVersion, variant.target.range, { includePrerelease: true })) return [];
427
+ return [{
428
+ id,
429
+ patchPackage: {
430
+ name: variant.patchPackage.name,
431
+ version: variant.patchPackage.version
432
+ },
433
+ file: file.relativeFile,
434
+ absoluteFile: file.absoluteFile,
435
+ target: {
436
+ kind: "npm",
437
+ name: variant.target.name,
438
+ version: targetVersion
439
+ }
440
+ }];
316
441
  });
442
+ const [candidate] = candidates;
443
+ if (candidate === void 0) throw new Error("no compatible patch variant for " + id + " on DSH " + dshVersion);
444
+ if (candidates.length > 1) throw new Error("multiple compatible patch variants for " + id + " on DSH " + dshVersion);
445
+ selected.push(candidate);
317
446
  }
318
447
  const lockPatches = selected.map((patch) => {
319
448
  if ("alreadyApplied" in patch) {
@@ -353,7 +482,7 @@ function materializePatchFiles(profileDirectory, patches) {
353
482
  force: true
354
483
  });
355
484
  const stablePatches = patches.map((patch) => {
356
- const destination = resolve(root, patch.scope, patch.id, basename(patch.file));
485
+ const destination = resolve(root, patch.patchPackage.name, patch.patchPackage.version, patch.file);
357
486
  mkdirSync(dirname(destination), { recursive: true });
358
487
  copyFileSync(patch.absoluteFile, destination);
359
488
  return {
@@ -376,7 +505,7 @@ function materializePatchFiles(profileDirectory, patches) {
376
505
  npmPatchFiles.set(key, first.absoluteFile);
377
506
  continue;
378
507
  }
379
- const members = group.map((patch) => encodeURIComponent(patch.id)).join("+");
508
+ const members = group.map((patch) => encodeURIComponent(patch.id + "@" + patch.patchPackage.version)).join("+");
380
509
  const destination = resolve(root, "combined", encodeURIComponent(key), members + ".patch");
381
510
  mkdirSync(dirname(destination), { recursive: true });
382
511
  writeFileSync(destination, group.map((patch) => {
@@ -415,6 +544,46 @@ function profilePatchConfiguration(profileDirectory, npmPatchFiles) {
415
544
  changed
416
545
  };
417
546
  }
547
+ /**
548
+ * Profile-local pnpm hook that keeps the CDN-only xlsx dependency installable.
549
+ *
550
+ * `@deepseek-ai/dsh-client-ui-sidebar-documentpreview` declares `xlsx` as
551
+ * `https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz`. SheetJS stopped publishing to npm
552
+ * after 0.18.5, so no registry mirror carries 0.20.3, and the build network cannot reach that
553
+ * CDN (measured 2026-11-06: every request times out). The image vendors the tarball at
554
+ * /opt/dsh-vendor; this hook rewrites the spec wherever it appears so a cold profile install
555
+ * never requests the CDN.
556
+ *
557
+ * Written into the profile root rather than a template: the Plus bundle has no profile
558
+ * template directory, the profile manifest and pnpm-workspace.yaml are generated here.
559
+ */
560
+ const PROFILE_PNPMFILE = `// Generated by @sparkelf/dsh-plus -- do not edit; rewritten on every apply.
561
+ const VENDORED_XLSX = '/opt/dsh-vendor/xlsx-0.20.3.tgz'
562
+ const CDN_XLSX = /^https?:\\/\\/cdn\\.sheetjs\\.com\\//
563
+ const FIELDS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']
564
+
565
+ module.exports = {
566
+ hooks: {
567
+ readPackage(pkg) {
568
+ for (const field of FIELDS) {
569
+ const deps = pkg && pkg[field]
570
+ if (deps && typeof deps.xlsx === 'string' && CDN_XLSX.test(deps.xlsx)) {
571
+ deps.xlsx = 'file:' + VENDORED_XLSX
572
+ }
573
+ }
574
+ return pkg
575
+ },
576
+ },
577
+ }
578
+ `;
579
+ /** Write the profile pnpmfile when its content changed; returns whether it wrote. */
580
+ function writeProfilePnpmfile(profileDirectory) {
581
+ const path = resolve(profileDirectory, ".pnpmfile.cjs");
582
+ if ((existsSync(path) ? readFileSync(path, "utf8") : void 0) === PROFILE_PNPMFILE) return false;
583
+ writeFileSync(path, PROFILE_PNPMFILE);
584
+ console.log("profile pnpmfile: xlsx -> /opt/dsh-vendor/xlsx-0.20.3.tgz");
585
+ return true;
586
+ }
418
587
  function writeProfileRequirements(profileDirectory, dependencySpecs, allowBuilds) {
419
588
  const manifestPath = resolve(profileDirectory, "package.json");
420
589
  const manifest = readJsonObject(manifestPath, "DSH profile manifest");
@@ -465,7 +634,8 @@ function writeProfileRequirements(profileDirectory, dependencySpecs, allowBuilds
465
634
  writeFileSync(manifestPath, JSON.stringify(manifest, void 0, 2) + "\n");
466
635
  }
467
636
  if (workspaceChanged) writeFileSync(workspacePath, String(document));
468
- return manifestChanged || workspaceChanged;
637
+ const pnpmfileChanged = writeProfilePnpmfile(profileDirectory);
638
+ return manifestChanged || workspaceChanged || pnpmfileChanged;
469
639
  }
470
640
  function writeProfileComposition(profileDirectory, bundles, runtimePackages) {
471
641
  const path = resolve(profileDirectory, "package.json");
@@ -650,4 +820,4 @@ function runApply(argv) {
650
820
  process.stdout.write("[dsh-plus] applied " + String(selection.patches.length) + " patches; lock " + lock + "\n");
651
821
  }
652
822
  //#endregion
653
- export { readPatchSet as i, parseOfficialWorkspacePackages as n, runApply as r, materializeOfficialPackageScope as t };
823
+ export { readPatchSet as a, runApply as i, parseOfficialWorkspacePackages as n, resolvePatchPackageNames as r, materializeOfficialPackageScope as t };