@sparkelf/dsh-plus 0.2.9-alpha.55 → 0.2.9-alpha.57

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.
@@ -2,9 +2,128 @@ 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
4
  import { dirname, isAbsolute, relative, resolve } from "node:path";
5
- import { tmpdir } from "node:os";
6
5
  import { satisfies, valid, validRange } from "semver";
6
+ import { tmpdir } from "node:os";
7
7
  import { parseDocument } from "yaml";
8
+ //#region lib/types/patch-set.js
9
+ /**
10
+ * Read the Plus distribution's embedded patch set.
11
+ *
12
+ * The distribution owns one patch set for official DSH and, separately, the patches it
13
+ * carries for third-party packages. Both live inside the distribution package: the
14
+ * manifest declares entries, and each entry's payload is a file under `patches/`. A
15
+ * consumer resolves no independently published patch package.
16
+ *
17
+ * The two lists are governed differently. A Plus entry must target an official package
18
+ * that the profile republishes and overrides; a third-party entry must name its upstream
19
+ * and a retirement condition, and never becomes part of the official patch set.
20
+ */
21
+ function object(value, label) {
22
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(label + " must be an object");
23
+ return value;
24
+ }
25
+ function string(value, label) {
26
+ if (typeof value !== "string" || value === "") throw new Error(label + " must be a non-empty string");
27
+ return value;
28
+ }
29
+ function range(value, label) {
30
+ const text = string(value, label);
31
+ if (validRange(text) === null) throw new Error(label + " is not a semantic-version range: " + text);
32
+ return text;
33
+ }
34
+ /** A payload stays inside the distribution package it is declared by. */
35
+ function patchFile(distributionDirectory, declared, label) {
36
+ const absolute = resolve(distributionDirectory, declared);
37
+ const local = relative(distributionDirectory, absolute);
38
+ if (local === "" || isAbsolute(local) || local === ".." || local.startsWith("../")) throw new Error(label + " must stay inside the distribution package: " + declared);
39
+ if (!existsSync(absolute)) throw new Error(label + " does not exist: " + absolute);
40
+ return local.replaceAll("\\", "/");
41
+ }
42
+ function sourceTarget(value, sourceBaseRevision, label) {
43
+ const target = object(value, label);
44
+ if (target.kind !== "dsh-source") throw new Error(label + ".kind must be dsh-source");
45
+ if (!Array.isArray(target.paths) || target.paths.length === 0) throw new Error(label + ".paths must be a non-empty array");
46
+ const paths = target.paths.map((entry, index) => {
47
+ const path = string(entry, label + ".paths[" + String(index) + "]");
48
+ if (!path.endsWith("/")) throw new Error(label + ".paths entries must be repository directory prefixes");
49
+ return path;
50
+ });
51
+ if (!Array.isArray(target.packages) || target.packages.length === 0) throw new Error(label + ".packages must be a non-empty array");
52
+ return {
53
+ kind: "dsh-source",
54
+ baseRevision: sourceBaseRevision,
55
+ packages: target.packages.map((entry, index) => {
56
+ const name = string(entry, label + ".packages[" + String(index) + "]");
57
+ if (!name.startsWith("@deepseek-ai/")) throw new Error(label + ".packages entries must be official package names");
58
+ return name;
59
+ }),
60
+ paths
61
+ };
62
+ }
63
+ function npmTarget(value, label) {
64
+ const target = object(value, label);
65
+ if (target.kind !== "npm") throw new Error(label + ".kind must be npm");
66
+ return {
67
+ kind: "npm",
68
+ name: string(target.name, label + ".name"),
69
+ range: range(target.range, label + ".range")
70
+ };
71
+ }
72
+ function entry(value, scope, sourceBaseRevision, distributionDirectory, label) {
73
+ const record = object(value, label);
74
+ const id = string(record.id, label + ".id");
75
+ const dsh = range(record.dsh, label + ".dsh");
76
+ const file = patchFile(distributionDirectory, string(record.file, label + ".file"), label + ".file");
77
+ const retireWhen = string(record.retireWhen, label + ".retireWhen");
78
+ const targetLabel = label + ".target";
79
+ const target = scope === "plus" ? object(record.target, targetLabel).kind === "dsh-source" ? sourceTarget(record.target, sourceBaseRevision, targetLabel) : npmTarget(record.target, targetLabel) : npmTarget(record.target, targetLabel);
80
+ if (scope === "third-party") return {
81
+ id,
82
+ scope,
83
+ dsh,
84
+ file,
85
+ retireWhen,
86
+ upstreamUrl: string(record.upstreamUrl, label + ".upstreamUrl"),
87
+ target
88
+ };
89
+ return {
90
+ id,
91
+ scope,
92
+ dsh,
93
+ file,
94
+ retireWhen,
95
+ target
96
+ };
97
+ }
98
+ /**
99
+ * Read and validate the embedded patch set from an installed distribution.
100
+ * @param distributionDirectory - installed `@sparkelf/dsh-plus` directory.
101
+ * @param manifest - its parsed package manifest.
102
+ * @returns the ordered Plus entries, third-party entries, and the exact source base.
103
+ */
104
+ function readPatchSet(distributionDirectory, manifest) {
105
+ const plus = object(manifest.dshPlus, "dshPlus");
106
+ const sourceBaseRevision = string(object(plus.sourceBase, "dshPlus.sourceBase").revision, "dshPlus.sourceBase.revision");
107
+ const declaration = object(plus.patchSet, "dshPlus.patchSet");
108
+ if (declaration.formatVersion !== 1) throw new Error("dshPlus.patchSet.formatVersion must be 1");
109
+ if (!Array.isArray(declaration.entries) || declaration.entries.length === 0) throw new Error("dshPlus.patchSet.entries must be a non-empty array");
110
+ const entries = declaration.entries.map((value, index) => entry(value, "plus", sourceBaseRevision, distributionDirectory, "dshPlus.patchSet.entries[" + String(index) + "]"));
111
+ const thirdPartyRaw = plus.thirdPartyPatches;
112
+ const thirdParty = thirdPartyRaw === void 0 ? [] : Array.isArray(thirdPartyRaw) ? thirdPartyRaw.map((value, index) => entry(value, "third-party", sourceBaseRevision, distributionDirectory, "dshPlus.thirdPartyPatches[" + String(index) + "]")) : (() => {
113
+ throw new Error("dshPlus.thirdPartyPatches must be an array");
114
+ })();
115
+ const ids = /* @__PURE__ */ new Set();
116
+ for (const item of [...entries, ...thirdParty]) {
117
+ if (ids.has(item.id)) throw new Error("duplicate patch entry id: " + item.id);
118
+ ids.add(item.id);
119
+ }
120
+ return {
121
+ entries,
122
+ thirdPartyPatches: thirdParty,
123
+ sourceBaseRevision
124
+ };
125
+ }
126
+ //#endregion
8
127
  //#region lib/types/apply.js
9
128
  /** Materialize the Plus distribution's independent patch packages without Desktop. */
10
129
  const FORMAT_VERSION = 1;
@@ -157,13 +276,16 @@ function requireSourceBase(root, baseRevision) {
157
276
  return checkoutRevision;
158
277
  }
159
278
  /**
160
- * Names of the packages that carry `dshPatch` variants.
279
+ * Names of distribution dependencies that carry `dshPatch` variants.
161
280
  *
162
- * The distribution moved from a flat `dshPlus.patchPackages` list to `dshPlus.patchSet`, whose
163
- * entries name their target packages per patch. Older tarballs still carry the flat list, so it
164
- * wins when present; otherwise the union of every entry's `target.packages` is used.
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.
165
286
  *
166
287
  * @param plus - Parsed `dshPlus` block of the distribution manifest.
288
+ * @returns Patch-carrier package names; empty when the distribution ships only source patches.
167
289
  */
168
290
  function resolvePatchPackageNames(plus) {
169
291
  const declared = plus.patchPackages;
@@ -172,14 +294,13 @@ function resolvePatchPackageNames(plus) {
172
294
  if (names.length > 0) return names;
173
295
  }
174
296
  const entries = requireObject(plus.patchSet, "dshPlus.patchSet").entries;
175
- if (!Array.isArray(entries) || entries.length === 0) throw new Error("dshPlus.patchSet.entries must be a non-empty array");
297
+ if (!Array.isArray(entries)) throw new Error("dshPlus.patchSet.entries must be an array");
176
298
  const names = /* @__PURE__ */ new Set();
177
299
  for (const [index, value] of entries.entries()) {
178
300
  const target = requireObject(requireObject(value, "dshPlus.patchSet.entries[" + String(index) + "]").target, "dshPlus.patchSet.entries[" + String(index) + "].target");
179
- if (!Array.isArray(target.packages)) continue;
180
- for (const name of requireStringArray(target.packages, "dshPlus.patchSet.entries[" + String(index) + "].target.packages")) names.add(name);
301
+ if (target.kind !== "npm") continue;
302
+ names.add(requireString(target.name, "dshPlus.patchSet.entries[" + String(index) + "].target.name"));
181
303
  }
182
- if (names.size === 0) throw new Error("dshPlus.patchSet must name at least one patch package");
183
304
  return [...names].sort();
184
305
  }
185
306
  function patchPackageVariants(distributionDirectory, names) {
@@ -193,6 +314,34 @@ function patchPackageVariants(distributionDirectory, names) {
193
314
  }
194
315
  return variants;
195
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
+ }
196
345
  function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
197
346
  const distributionManifest = readJsonObject(resolve(distributionDirectory, "package.json"), "Plus distribution manifest");
198
347
  const distributionName = requireString(distributionManifest.name, "Plus distribution name");
@@ -217,8 +366,14 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
217
366
  const dshVersion = requireVersion(readJsonObject(resolve(dshRoot, "package.json"), "DSH source manifest").version, "DSH source version");
218
367
  if (!satisfies(dshVersion, dshRange, { includePrerelease: true })) throw new Error(distributionName + "@" + distributionVersion + " requires DSH " + dshRange + ", found " + dshVersion);
219
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);
220
375
  const groups = /* @__PURE__ */ new Map();
221
- for (const variant of patchPackageVariants(distributionDirectory, patchPackageNames)) {
376
+ for (const variant of variants) {
222
377
  const entries = groups.get(variant.id) ?? [];
223
378
  entries.push(variant);
224
379
  groups.set(variant.id, entries);
@@ -665,4 +820,4 @@ function runApply(argv) {
665
820
  process.stdout.write("[dsh-plus] applied " + String(selection.patches.length) + " patches; lock " + lock + "\n");
666
821
  }
667
822
  //#endregion
668
- export { runApply as i, parseOfficialWorkspacePackages as n, resolvePatchPackageNames as r, materializeOfficialPackageScope as t };
823
+ export { readPatchSet as a, runApply as i, parseOfficialWorkspacePackages as n, resolvePatchPackageNames as r, materializeOfficialPackageScope as t };
package/lib/apply.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as runApply, n as parseOfficialWorkspacePackages, r as resolvePatchPackageNames, t as materializeOfficialPackageScope } from "./apply-DpmD0ljp.js";
1
+ import { i as runApply, n as parseOfficialWorkspacePackages, r as resolvePatchPackageNames, t as materializeOfficialPackageScope } from "./apply-CvePS57c.js";
2
2
  export { materializeOfficialPackageScope, parseOfficialWorkspacePackages, resolvePatchPackageNames, runApply };
package/lib/bin.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { i as runApply } from "./apply-DpmD0ljp.js";
2
+ import { a as readPatchSet, i as runApply } from "./apply-CvePS57c.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
6
- import { dirname, isAbsolute, join, posix, relative, resolve, win32 } from "node:path";
7
- import { homedir } from "node:os";
6
+ import { dirname, join, posix, resolve, win32 } from "node:path";
8
7
  import semver, { valid, validRange } from "semver";
8
+ import { homedir } from "node:os";
9
9
  import { parseDocument } from "yaml";
10
10
  import { fileURLToPath } from "node:url";
11
11
  import { createServer } from "node:net";
@@ -1084,125 +1084,6 @@ async function waitForAuthenticatedUrl(logPath, timeoutMilliseconds) {
1084
1084
  }
1085
1085
  }
1086
1086
  //#endregion
1087
- //#region lib/types/patch-set.js
1088
- /**
1089
- * Read the Plus distribution's embedded patch set.
1090
- *
1091
- * The distribution owns one patch set for official DSH and, separately, the patches it
1092
- * carries for third-party packages. Both live inside the distribution package: the
1093
- * manifest declares entries, and each entry's payload is a file under `patches/`. A
1094
- * consumer resolves no independently published patch package.
1095
- *
1096
- * The two lists are governed differently. A Plus entry must target an official package
1097
- * that the profile republishes and overrides; a third-party entry must name its upstream
1098
- * and a retirement condition, and never becomes part of the official patch set.
1099
- */
1100
- function object(value, label) {
1101
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(label + " must be an object");
1102
- return value;
1103
- }
1104
- function string(value, label) {
1105
- if (typeof value !== "string" || value === "") throw new Error(label + " must be a non-empty string");
1106
- return value;
1107
- }
1108
- function range(value, label) {
1109
- const text = string(value, label);
1110
- if (validRange(text) === null) throw new Error(label + " is not a semantic-version range: " + text);
1111
- return text;
1112
- }
1113
- /** A payload stays inside the distribution package it is declared by. */
1114
- function patchFile(distributionDirectory, declared, label) {
1115
- const absolute = resolve(distributionDirectory, declared);
1116
- const local = relative(distributionDirectory, absolute);
1117
- if (local === "" || isAbsolute(local) || local === ".." || local.startsWith("../")) throw new Error(label + " must stay inside the distribution package: " + declared);
1118
- if (!existsSync(absolute)) throw new Error(label + " does not exist: " + absolute);
1119
- return local.replaceAll("\\", "/");
1120
- }
1121
- function sourceTarget(value, sourceBaseRevision, label) {
1122
- const target = object(value, label);
1123
- if (target.kind !== "dsh-source") throw new Error(label + ".kind must be dsh-source");
1124
- if (!Array.isArray(target.paths) || target.paths.length === 0) throw new Error(label + ".paths must be a non-empty array");
1125
- const paths = target.paths.map((entry, index) => {
1126
- const path = string(entry, label + ".paths[" + String(index) + "]");
1127
- if (!path.endsWith("/")) throw new Error(label + ".paths entries must be repository directory prefixes");
1128
- return path;
1129
- });
1130
- if (!Array.isArray(target.packages) || target.packages.length === 0) throw new Error(label + ".packages must be a non-empty array");
1131
- return {
1132
- kind: "dsh-source",
1133
- baseRevision: sourceBaseRevision,
1134
- packages: target.packages.map((entry, index) => {
1135
- const name = string(entry, label + ".packages[" + String(index) + "]");
1136
- if (!name.startsWith("@deepseek-ai/")) throw new Error(label + ".packages entries must be official package names");
1137
- return name;
1138
- }),
1139
- paths
1140
- };
1141
- }
1142
- function npmTarget(value, label) {
1143
- const target = object(value, label);
1144
- if (target.kind !== "npm") throw new Error(label + ".kind must be npm");
1145
- return {
1146
- kind: "npm",
1147
- name: string(target.name, label + ".name"),
1148
- range: range(target.range, label + ".range")
1149
- };
1150
- }
1151
- function entry(value, scope, sourceBaseRevision, distributionDirectory, label) {
1152
- const record = object(value, label);
1153
- const id = string(record.id, label + ".id");
1154
- const dsh = range(record.dsh, label + ".dsh");
1155
- const file = patchFile(distributionDirectory, string(record.file, label + ".file"), label + ".file");
1156
- const retireWhen = string(record.retireWhen, label + ".retireWhen");
1157
- const targetLabel = label + ".target";
1158
- const target = scope === "plus" ? object(record.target, targetLabel).kind === "dsh-source" ? sourceTarget(record.target, sourceBaseRevision, targetLabel) : npmTarget(record.target, targetLabel) : npmTarget(record.target, targetLabel);
1159
- if (scope === "third-party") return {
1160
- id,
1161
- scope,
1162
- dsh,
1163
- file,
1164
- retireWhen,
1165
- upstreamUrl: string(record.upstreamUrl, label + ".upstreamUrl"),
1166
- target
1167
- };
1168
- return {
1169
- id,
1170
- scope,
1171
- dsh,
1172
- file,
1173
- retireWhen,
1174
- target
1175
- };
1176
- }
1177
- /**
1178
- * Read and validate the embedded patch set from an installed distribution.
1179
- * @param distributionDirectory - installed `@sparkelf/dsh-plus` directory.
1180
- * @param manifest - its parsed package manifest.
1181
- * @returns the ordered Plus entries, third-party entries, and the exact source base.
1182
- */
1183
- function readPatchSet(distributionDirectory, manifest) {
1184
- const plus = object(manifest.dshPlus, "dshPlus");
1185
- const sourceBaseRevision = string(object(plus.sourceBase, "dshPlus.sourceBase").revision, "dshPlus.sourceBase.revision");
1186
- const declaration = object(plus.patchSet, "dshPlus.patchSet");
1187
- if (declaration.formatVersion !== 1) throw new Error("dshPlus.patchSet.formatVersion must be 1");
1188
- if (!Array.isArray(declaration.entries) || declaration.entries.length === 0) throw new Error("dshPlus.patchSet.entries must be a non-empty array");
1189
- const entries = declaration.entries.map((value, index) => entry(value, "plus", sourceBaseRevision, distributionDirectory, "dshPlus.patchSet.entries[" + String(index) + "]"));
1190
- const thirdPartyRaw = plus.thirdPartyPatches;
1191
- const thirdParty = thirdPartyRaw === void 0 ? [] : Array.isArray(thirdPartyRaw) ? thirdPartyRaw.map((value, index) => entry(value, "third-party", sourceBaseRevision, distributionDirectory, "dshPlus.thirdPartyPatches[" + String(index) + "]")) : (() => {
1192
- throw new Error("dshPlus.thirdPartyPatches must be an array");
1193
- })();
1194
- const ids = /* @__PURE__ */ new Set();
1195
- for (const item of [...entries, ...thirdParty]) {
1196
- if (ids.has(item.id)) throw new Error("duplicate patch entry id: " + item.id);
1197
- ids.add(item.id);
1198
- }
1199
- return {
1200
- entries,
1201
- thirdPartyPatches: thirdParty,
1202
- sourceBaseRevision
1203
- };
1204
- }
1205
- //#endregion
1206
1087
  //#region lib/types/profile.js
1207
1088
  /**
1208
1089
  * Runtime paths and profile composition for a standalone Plus installation.
@@ -5,13 +5,16 @@ export interface OfficialWorkspacePackage {
5
5
  directory: string;
6
6
  }
7
7
  /**
8
- * Names of the packages that carry `dshPatch` variants.
8
+ * Names of distribution dependencies that carry `dshPatch` variants.
9
9
  *
10
- * The distribution moved from a flat `dshPlus.patchPackages` list to `dshPlus.patchSet`, whose
11
- * entries name their target packages per patch. Older tarballs still carry the flat list, so it
12
- * wins when present; otherwise the union of every entry's `target.packages` is used.
10
+ * `patchPackageVariants()` resolves these names from the Plus install tree, so they must be
11
+ * packages this distribution actually depends on. The current manifest declares `dshPlus.patchSet`
12
+ * instead of a flat list: only entries whose target is an npm package name a `dshPatch` carrier
13
+ * (`dsh-source` entries name the source packages being patched, which are never Plus dependencies).
14
+ * An older tarball may still carry the flat `dshPlus.patchPackages` list, which wins when present.
13
15
  *
14
16
  * @param plus - Parsed `dshPlus` block of the distribution manifest.
17
+ * @returns Patch-carrier package names; empty when the distribution ships only source patches.
15
18
  */
16
19
  export declare function resolvePatchPackageNames(plus: Record<string, unknown>): string[];
17
20
  /**
@@ -2,6 +2,7 @@
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync, } from 'node:fs';
4
4
  import { createRequire } from 'node:module';
5
+ import { readPatchSet } from "./patch-set.js";
5
6
  import { dirname, isAbsolute, relative, resolve } from 'node:path';
6
7
  import { tmpdir } from 'node:os';
7
8
  import { satisfies, valid, validRange } from 'semver';
@@ -149,13 +150,16 @@ function requireSourceBase(root, baseRevision) {
149
150
  return checkoutRevision;
150
151
  }
151
152
  /**
152
- * Names of the packages that carry `dshPatch` variants.
153
+ * Names of distribution dependencies that carry `dshPatch` variants.
153
154
  *
154
- * The distribution moved from a flat `dshPlus.patchPackages` list to `dshPlus.patchSet`, whose
155
- * entries name their target packages per patch. Older tarballs still carry the flat list, so it
156
- * wins when present; otherwise the union of every entry's `target.packages` is used.
155
+ * `patchPackageVariants()` resolves these names from the Plus install tree, so they must be
156
+ * packages this distribution actually depends on. The current manifest declares `dshPlus.patchSet`
157
+ * instead of a flat list: only entries whose target is an npm package name a `dshPatch` carrier
158
+ * (`dsh-source` entries name the source packages being patched, which are never Plus dependencies).
159
+ * An older tarball may still carry the flat `dshPlus.patchPackages` list, which wins when present.
157
160
  *
158
161
  * @param plus - Parsed `dshPlus` block of the distribution manifest.
162
+ * @returns Patch-carrier package names; empty when the distribution ships only source patches.
159
163
  */
160
164
  export function resolvePatchPackageNames(plus) {
161
165
  const declared = plus.patchPackages;
@@ -166,21 +170,16 @@ export function resolvePatchPackageNames(plus) {
166
170
  }
167
171
  const patchSet = requireObject(plus.patchSet, 'dshPlus.patchSet');
168
172
  const entries = patchSet.entries;
169
- if (!Array.isArray(entries) || entries.length === 0) {
170
- throw new Error('dshPlus.patchSet.entries must be a non-empty array');
171
- }
173
+ if (!Array.isArray(entries))
174
+ throw new Error('dshPlus.patchSet.entries must be an array');
172
175
  const names = new Set();
173
176
  for (const [index, value] of entries.entries()) {
174
177
  const entry = requireObject(value, 'dshPlus.patchSet.entries[' + String(index) + ']');
175
178
  const target = requireObject(entry.target, 'dshPlus.patchSet.entries[' + String(index) + '].target');
176
- if (!Array.isArray(target.packages))
179
+ if (target.kind !== 'npm')
177
180
  continue;
178
- for (const name of requireStringArray(target.packages, 'dshPlus.patchSet.entries[' + String(index) + '].target.packages')) {
179
- names.add(name);
180
- }
181
+ names.add(requireString(target.name, 'dshPlus.patchSet.entries[' + String(index) + '].target.name'));
181
182
  }
182
- if (names.size === 0)
183
- throw new Error('dshPlus.patchSet must name at least one patch package');
184
183
  return [...names].sort();
185
184
  }
186
185
  function patchPackageVariants(distributionDirectory, names) {
@@ -200,6 +199,29 @@ function patchPackageVariants(distributionDirectory, names) {
200
199
  }
201
200
  return variants;
202
201
  }
202
+ /**
203
+ * Build patch variants from the distribution's `dshPlus.patchSet`.
204
+ *
205
+ * The patch files live inside the Plus package (`./patches/*.patch`), so every variant points at
206
+ * the distribution itself as its patch package: `resolvePatchFile()` then resolves the declared
207
+ * path inside the tarball, and `materializePatchFiles()` copies it into the profile's stable
208
+ * patch directory. Unlike the retired `dshPatch` carrier packages, the source packages named in
209
+ * `target.packages` are never resolved from the Plus tree -- they are the packages being patched.
210
+ *
211
+ * @param distribution - Installed Plus distribution package.
212
+ */
213
+ function patchSetVariants(distribution) {
214
+ const patchSet = readPatchSet(distribution.directory, distribution.manifest);
215
+ return [...patchSet.entries, ...patchSet.thirdPartyPatches].map((entry) => ({
216
+ id: entry.id,
217
+ dsh: entry.dsh,
218
+ file: entry.file,
219
+ patchPackage: distribution,
220
+ target: entry.target.kind === 'npm'
221
+ ? { kind: 'npm', name: entry.target.name, range: entry.target.range }
222
+ : { kind: 'dsh-source', baseRevision: entry.target.baseRevision },
223
+ }));
224
+ }
203
225
  // 先验证official source,再物化Plus声明的profile依赖,避免source不匹配时改动用户profile。
204
226
  function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
205
227
  const distributionManifest = readJsonObject(resolve(distributionDirectory, 'package.json'), 'Plus distribution manifest');
@@ -235,8 +257,18 @@ function prepareSelection(distributionDirectory, profileDirectory, dshRoot) {
235
257
  throw new Error(distributionName + '@' + distributionVersion + ' requires DSH ' + dshRange + ', found ' + dshVersion);
236
258
  }
237
259
  const checkoutRevision = requireSourceBase(dshRoot, baseRevision);
260
+ // Legacy tarballs declare `dshPlus.patchPackages` (dshPatch carrier packages); the current
261
+ // distribution declares `dshPlus.patchSet` with the patch files inside the Plus package.
262
+ const variants = plus.patchPackages === undefined
263
+ ? patchSetVariants({
264
+ name: distributionName,
265
+ version: distributionVersion,
266
+ directory: distributionDirectory,
267
+ manifest: distributionManifest,
268
+ })
269
+ : patchPackageVariants(distributionDirectory, patchPackageNames);
238
270
  const groups = new Map();
239
- for (const variant of patchPackageVariants(distributionDirectory, patchPackageNames)) {
271
+ for (const variant of variants) {
240
272
  const entries = groups.get(variant.id) ?? [];
241
273
  entries.push(variant);
242
274
  groups.set(variant.id, entries);
package/package.json CHANGED
@@ -331,6 +331,21 @@
331
331
  ]
332
332
  }
333
333
  },
334
+ {
335
+ "dsh": ">=0.2.2-alpha.2",
336
+ "file": "./patches/input-trigger-source-label.patch",
337
+ "id": "input-trigger-source-label",
338
+ "retireWhen": "官方 composer 的 @ 菜单显示来源分组名后退役",
339
+ "target": {
340
+ "kind": "dsh-source",
341
+ "packages": [
342
+ "@deepseek-ai/dsh-client-ui-conversation"
343
+ ],
344
+ "paths": [
345
+ "packages/client/ui-conversation/"
346
+ ]
347
+ }
348
+ },
334
349
  {
335
350
  "dsh": ">=0.2.2-alpha.2",
336
351
  "file": "./patches/legacy-code-preset.patch",
@@ -719,7 +734,7 @@
719
734
  "@sparkelf/dsh-dataops-account": "0.2.0",
720
735
  "@sparkelf/dsh-dataops-managed": "0.3.39",
721
736
  "@sparkelf/dsh-genui": "0.15.0-sparkelf.3",
722
- "@sparkelf/dsh-group-chat": "0.5.4",
737
+ "@sparkelf/dsh-group-chat": "0.5.5",
723
738
  "@sparkelf/dsh-kb-citation": "0.1.3",
724
739
  "@sparkelf/dsh-knowledge-base": "0.1.32",
725
740
  "@sparkelf/dsh-mineru": "0.1.4",
@@ -790,5 +805,5 @@
790
805
  },
791
806
  "type": "module",
792
807
  "types": "lib/types/index.d.ts",
793
- "version": "0.2.9-alpha.55"
808
+ "version": "0.2.9-alpha.57"
794
809
  }
@@ -0,0 +1,63 @@
1
+ diff --git a/packages/client/ui-input-trigger/src/client/MenuView.tsx b/packages/client/ui-input-trigger/src/client/MenuView.tsx
2
+ index da6dccdbad..42a7726014 100644
3
+ --- a/packages/client/ui-input-trigger/src/client/MenuView.tsx
4
+ +++ b/packages/client/ui-input-trigger/src/client/MenuView.tsx
5
+ @@ -143,7 +143,7 @@ export function MenuView({ menu, headers, onPick, onCrumb, onHover, onDismiss, t
6
+ shows its raw name — hence the cast past the typed key union. */}
7
+ {group.showGroupTitle === false || group.items.some(item => item.section !== undefined)
8
+ ? null
9
+ - : <div className={css.groupTitle} role="presentation" data-source={group.source}>{t(group.source as MenuKey)}</div>}
10
+ + : <div className={css.groupTitle} role="presentation" data-source={group.source}>{group.label ?? t(group.source as MenuKey)}</div>}
11
+ {group.status === 'pending' && group.items.length === 0
12
+ ? (
13
+ <div role="status" aria-label={t('loading')} data-source={group.source}>
14
+ diff --git a/packages/client/ui-input-trigger/src/core/contract.ts b/packages/client/ui-input-trigger/src/core/contract.ts
15
+ index eab79f1066..856555ca0d 100644
16
+ --- a/packages/client/ui-input-trigger/src/core/contract.ts
17
+ +++ b/packages/client/ui-input-trigger/src/core/contract.ts
18
+ @@ -37,6 +37,8 @@ export interface MenuState {
19
+ readonly generation: number
20
+ readonly groups: readonly {
21
+ readonly source: string
22
+ + /** Display title for the group row; absent renders the source id, as it always has. */
23
+ + readonly label?: string
24
+ /** False when candidate section rows own all visible group labeling. */
25
+ readonly showGroupTitle?: boolean
26
+ readonly status: 'pending' | 'ready'
27
+ diff --git a/packages/client/ui-input-trigger/src/core/menu.ts b/packages/client/ui-input-trigger/src/core/menu.ts
28
+ index 85787266a5..b3e8476132 100644
29
+ --- a/packages/client/ui-input-trigger/src/core/menu.ts
30
+ +++ b/packages/client/ui-input-trigger/src/core/menu.ts
31
+ @@ -29,12 +29,13 @@ export const MENU_CLOSED: MenuState = { open: false, hit: null, generation: 0, g
32
+ */
33
+ export function seedGroups(
34
+ state: MenuState,
35
+ - sources: readonly Pick<InputTriggerSource, 'name' | 'showGroupTitle'>[],
36
+ + sources: readonly Pick<InputTriggerSource, 'name' | 'label' | 'showGroupTitle'>[],
37
+ ): MenuState {
38
+ return {
39
+ ...state,
40
+ groups: sources.map(source => ({
41
+ source: source.name,
42
+ + ...(source.label === undefined ? {} : { label: source.label }),
43
+ ...(source.showGroupTitle === false ? { showGroupTitle: false } : {}),
44
+ status: 'pending',
45
+ items: [],
46
+ diff --git a/packages/client/ui-input-trigger/src/types.ts b/packages/client/ui-input-trigger/src/types.ts
47
+ index cd3f6bc54c..4b370b5127 100644
48
+ --- a/packages/client/ui-input-trigger/src/types.ts
49
+ +++ b/packages/client/ui-input-trigger/src/types.ts
50
+ @@ -161,6 +161,13 @@ export interface InputTriggerSource {
51
+ readonly trigger: TriggerChar
52
+ /** Menu group label; unique per trigger — duplicate registration throws. */
53
+ readonly name: string
54
+ + /**
55
+ + * Menu group display title. The raw `name` is shown when absent, which is why an unregistered
56
+ + * source renders its own id; a plugin whose name is a package path sets this to the words a
57
+ + * reader expects. It never appears in a pick, a reference, or a stored mention -- identity stays
58
+ + * `name`.
59
+ + */
60
+ + readonly label?: string
61
+ /** Menu group display order (lower = higher in the list; default 0). */
62
+ readonly order?: number
63
+ /** Whether the menu renders the source-title row; defaults to true. */