@linxin666/dsh-client-ui-plugin-manager 0.4.22 → 0.4.23

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.
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, realpathSync } from "node:fs";
3
3
  import { copyFile, readFile, rename, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, isAbsolute, join, normalize, posix, sep, win32 } from "node:path";
5
- import { isMap, isScalar, isSeq, parseDocument } from "yaml";
5
+ import { isMap, isScalar, isSeq, parseAllDocuments, parseDocument } from "yaml";
6
6
  import { homedir } from "node:os";
7
7
  import { isAbsolute as isAbsolute$1, join as join$1 } from "node:path/posix";
8
8
  import semver from "semver";
@@ -319,11 +319,51 @@ function claimedIdsOf(patchText) {
319
319
  for (const row of insertRowsOf(patchText)) if (row.id !== void 0) ids.push(row.id);
320
320
  return ids;
321
321
  }
322
+ /** The string id of a patch entry node (a map carrying a string `id`). */
323
+ function entryIdOf(node) {
324
+ if (!isMap(node)) return void 0;
325
+ const id = node.get("id", true);
326
+ return isScalar(id) && typeof id.value === "string" ? id.value : void 0;
327
+ }
328
+ /**
329
+ * Whether a patch node is a `group: true` container, whose `config:` list
330
+ * holds real child entries rather than composition data. The loader mounts
331
+ * those children as entries, so their ids count as live.
332
+ * @param node - one patch node.
333
+ * @returns whether the node is a group entry.
334
+ */
335
+ function isGroupEntry(node) {
336
+ if (!isMap(node)) return false;
337
+ const group = node.get("group", true);
338
+ return isScalar(group) && typeof group.value === "boolean" && group.value;
339
+ }
340
+ /**
341
+ * The ids of the entries nested (recursively) under one `group: true` entry's
342
+ * `config:` list. These are composition children: the loader mounts each as a
343
+ * real entry, so an override their id carries is live even though no top-level
344
+ * row names them. Only a group's `config:` list is descended — a plain config
345
+ * value that happens to carry an `id` key (a nested `{ id, x }` item, say) is
346
+ * data, not an entry, and is left alone. A child that is itself a group
347
+ * recurses through its own `config:`.
348
+ * @param config - a group entry's `config` node.
349
+ * @param ids - the accumulator to add into.
350
+ */
351
+ function collectGroupEntryIds(config, ids) {
352
+ if (!isSeq(config)) return;
353
+ for (const child of config.items) {
354
+ const id = entryIdOf(child);
355
+ if (id !== void 0) ids.add(id);
356
+ if (isMap(child) && isGroupEntry(child)) collectGroupEntryIds(child.get("config", true), ids);
357
+ }
358
+ }
322
359
  /**
323
360
  * Every entry id a layer declares: its top-level `- id:` rows (bare override
324
- * rows and config rows alike) plus the entries of its `- insert:` lists. Ids
325
- * nested inside a row's own `config:` are composition children of that entry,
326
- * not layer entries, and are not declared here.
361
+ * rows and config rows alike) plus the entries of its `- insert:` lists, plus —
362
+ * recursively — the entries nested under any `group: true` entry's `config:`
363
+ * list (the loader mounts those as entries too, so an override for one is not
364
+ * an orphan; issue #2091). Ids nested inside a non-group row's own `config:`
365
+ * are composition data of that entry, not layer entries, and are not declared
366
+ * here.
327
367
  *
328
368
  * This answers "does this layer still declare that row?" without composing, so
329
369
  * it stays true in the states where a composition probe is not: a host that
@@ -342,18 +382,25 @@ function declaredRowIds(patchText, filename) {
342
382
  if (value === void 0 || ids.includes(value)) return;
343
383
  ids.push(value);
344
384
  };
345
- const idOf = (node) => {
346
- const id = node.get("id", true);
347
- return isScalar(id) && typeof id.value === "string" ? id.value : void 0;
385
+ const pushGroupChildren = (node) => {
386
+ if (!isGroupEntry(node)) return;
387
+ const children = /* @__PURE__ */ new Set();
388
+ collectGroupEntryIds(node.get("config", true), children);
389
+ for (const child of children) push(child);
348
390
  };
349
391
  for (const item of root.items) {
350
392
  if (!isMap(item)) continue;
351
393
  const insert = item.get("insert", true);
352
394
  if (isSeq(insert)) {
353
- for (const entry of insert.items) if (isMap(entry)) push(idOf(entry));
395
+ for (const entry of insert.items) {
396
+ if (!isMap(entry)) continue;
397
+ push(entryIdOf(entry));
398
+ pushGroupChildren(entry);
399
+ }
354
400
  continue;
355
401
  }
356
- push(idOf(item));
402
+ push(entryIdOf(item));
403
+ pushGroupChildren(item);
357
404
  }
358
405
  return ids;
359
406
  }
@@ -597,9 +644,9 @@ function repairStaleRowNames(text, filename, liveNames) {
597
644
  //#endregion
598
645
  //#region src/host/dsh-home.ts
599
646
  /**
600
- * DSH_HOME resolution shared by the plugin family's Host halves: the
601
- * environment override wins, the platform home fallback follows. Mirrors
602
- * what dsh-pet and dsh-liangshen each used to implement locally.
647
+ * DSH_HOME and DSH_AGENTS_HOME resolution shared by the plugin family's Host
648
+ * halves: environment overrides win (blank values treated as unset), then the
649
+ * platform home fallbacks follow — mirroring `@deepseek-ai/dsh-home-paths`.
603
650
  */
604
651
  /** Expand a leading ~ (or ~user) in a path, platform-style. */
605
652
  function expandHome(path, home = homedir()) {
@@ -608,6 +655,16 @@ function expandHome(path, home = homedir()) {
608
655
  if (path.startsWith("~/") || path.startsWith("~\\")) return j(home, path.slice(2));
609
656
  return path;
610
657
  }
658
+ function resolveUserRoot(envValue, defaultDirName, home) {
659
+ const isPosix = home.startsWith("/");
660
+ const j = isPosix ? join$1 : join;
661
+ const isAbs = isPosix ? isAbsolute$1 : isAbsolute;
662
+ if (envValue !== void 0 && envValue.trim() !== "") {
663
+ const expanded = expandHome(envValue.trim(), home);
664
+ return isAbs(expanded) ? expanded : j(process.cwd(), expanded);
665
+ }
666
+ return j(home, defaultDirName);
667
+ }
611
668
  /**
612
669
  * Resolve the DSH home directory.
613
670
  * @param env - process environment to read DSH_HOME from.
@@ -615,15 +672,7 @@ function expandHome(path, home = homedir()) {
615
672
  * @returns the absolute DSH home path.
616
673
  */
617
674
  function resolveDshHome(env = process.env, home = homedir()) {
618
- const isPosix = home.startsWith("/");
619
- const j = isPosix ? join$1 : join;
620
- const isAbs = isPosix ? isAbsolute$1 : isAbsolute;
621
- const raw = env.DSH_HOME;
622
- if (raw !== void 0 && raw.trim() !== "") {
623
- const expanded = expandHome(raw.trim(), home);
624
- return isAbs(expanded) ? expanded : j(process.cwd(), expanded);
625
- }
626
- return j(home, ".dsh");
675
+ return resolveUserRoot(env.DSH_HOME, ".dsh", home);
627
676
  }
628
677
  /** Resolve the DSH home directory from the live environment. */
629
678
  function dshHome() {
@@ -1790,7 +1839,10 @@ const OFFICIAL_INSTALLER_PATTERN = /^\s*-?\s*id:\s*['"]?plugin-(?:installer|cont
1790
1839
  * `# ==` header, with the composed entries as column-0 `- id:` items — an
1791
1840
  * entry a profile patch overrides appears once, carrying the override's keys,
1792
1841
  * so those lines are exactly the loader's own entry set. Nested config keeps
1793
- * its own `id` keys indented and is never mistaken for an entry.
1842
+ * its own `id` keys indented and is never mistaken for an entry, with one
1843
+ * exception: a `group: true` entry's `config:` list holds real child entries
1844
+ * (recursively), whose ids the loader composes just like top-level ones and
1845
+ * which are collected here too (issue #2091).
1794
1846
  * @param dump - the dump's captured text.
1795
1847
  * @returns the composed entry ids, or undefined when the dump carried none.
1796
1848
  */
@@ -1804,9 +1856,37 @@ function composedEntryIdsOf(dump) {
1804
1856
  const unquoted = /^'(.*)'$/.exec(value)?.[1] ?? /^"(.*)"$/.exec(value)?.[1] ?? value;
1805
1857
  if (unquoted !== "") ids.add(unquoted);
1806
1858
  }
1859
+ collectDumpGroupChildIds(dump, ids);
1807
1860
  return ids.size === 0 ? void 0 : ids;
1808
1861
  }
1809
1862
  /**
1863
+ * Add the ids of entries nested under any `group: true` entry's `config:` list
1864
+ * in a composed dump. The flat `- id:` scan above only sees top-level entries;
1865
+ * a group's children are indented beneath it, so they are read structurally.
1866
+ * The dump prints one YAML document per layer, so every document is parsed and
1867
+ * a document that does not parse is skipped, leaving the flat scan's ids — the
1868
+ * same entry set it reported before groups were understood — as the result.
1869
+ * @param dump - the dump's captured text.
1870
+ * @param ids - the accumulator to add into.
1871
+ */
1872
+ function collectDumpGroupChildIds(dump, ids) {
1873
+ let documents;
1874
+ try {
1875
+ documents = parseAllDocuments(dump, { prettyErrors: false });
1876
+ } catch {
1877
+ return;
1878
+ }
1879
+ for (const document of documents) {
1880
+ if (document.errors.length > 0) continue;
1881
+ const root = document.contents;
1882
+ if (!isSeq(root)) continue;
1883
+ for (const entry of root.items) {
1884
+ if (!isMap(entry) || !isGroupEntry(entry)) continue;
1885
+ collectGroupEntryIds(entry.get("config", true), ids);
1886
+ }
1887
+ }
1888
+ }
1889
+ /**
1810
1890
  * Detect whether the official installer channels exist on this runtime by
1811
1891
  * dumping the boot composition once: the npm-published web never contains
1812
1892
  * `plugin-installer` entries, DSHCode and the checkout web do. The browser
@@ -18,7 +18,7 @@
18
18
  * manager returned, and a locked row says which lock it is.
19
19
  * @module @linxin666/dsh-client-ui-plugin-manager/client
20
20
  */
21
- import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
21
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client';
22
22
  import { type DisplayText } from '../core/builtin.ts';
23
23
  import type { RemoteSnapshot } from './native-faces.ts';
24
24
  /** The operations the group drives, all of them the official manager's own. */
@@ -15,7 +15,7 @@
15
15
  * own subtree.
16
16
  * @module @linxin666/dsh-client-ui-plugin-manager/client
17
17
  */
18
- import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
18
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client';
19
19
  import type { PluginBatchUpdateResult, PluginUpdateItem, RestartMode, RestartPlanWire } from '../core/protocol.ts';
20
20
  /** The operations the toolbar drives (the package's dual-channel face). */
21
21
  export interface PluginListToolbarInjected {
@@ -1,5 +1,7 @@
1
- import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
1
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client';
2
2
  import type { InstallProgressItem, PluginUpdateItem, PluginUpdateResult } from '../core/protocol.ts';
3
+ /** Official `ui-plugin-manager` 0.2.3-alpha.2+ native Versions section selector. */
4
+ export declare const NATIVE_VERSIONS_SELECTOR = "[data-plugin-versions]";
3
5
  /** One loader row of a bundle, as the official page's subject carries it. */
4
6
  export interface PluginPageRowRef {
5
7
  rowId: string;
@@ -30,7 +32,7 @@ export type PluginPageSubject = {
30
32
  kind: 'item';
31
33
  id: string;
32
34
  };
33
- declare module '@deepseek-ai/dsh-client-ui-slots' {
35
+ declare module '@deepseek-ai/dsh-client-ui-slots/client' {
34
36
  interface SlotMap {
35
37
  /**
36
38
  * One section contributed under a Plugins page's own content. Declared at
@@ -27,7 +27,7 @@ import { type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx';
27
27
  import { type PluginManagerKey } from './locales.ts';
28
28
  import { type PluginBatchUpdateResult, type RestartMode, type RestartPlanWire } from '../core/protocol.ts';
29
29
  import { type PluginManagerService } from '../core/service.ts';
30
- declare module '@deepseek-ai/dsh-client-ui-slots' {
30
+ declare module '@deepseek-ai/dsh-client-ui-slots/client' {
31
31
  interface LocaleNamespaceMap {
32
32
  /** Copy for the check-for-updates patch. */
33
33
  'settings.pluginManager': PluginManagerKey;
@@ -87,6 +87,7 @@ declare const STATIC_ZH: {
87
87
  presetGroup: string;
88
88
  presetDefault: string;
89
89
  presetBroken: string;
90
+ presetSummary: string;
90
91
  presetRowOn: string;
91
92
  presetRowOff: string;
92
93
  presetRowConditional: string;
@@ -171,6 +172,7 @@ export declare const zh: {
171
172
  presetGroup: string;
172
173
  presetDefault: string;
173
174
  presetBroken: string;
175
+ presetSummary: string;
174
176
  presetRowOn: string;
175
177
  presetRowOff: string;
176
178
  presetRowConditional: string;
@@ -255,6 +257,7 @@ export declare const en: {
255
257
  presetGroup: string;
256
258
  presetDefault: string;
257
259
  presetBroken: string;
260
+ presetSummary: string;
258
261
  presetRowOn: string;
259
262
  presetRowOff: string;
260
263
  presetRowConditional: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * DSH_HOME resolution shared by the plugin family's Host halves: the
3
- * environment override wins, the platform home fallback follows. Mirrors
4
- * what dsh-pet and dsh-liangshen each used to implement locally.
2
+ * DSH_HOME and DSH_AGENTS_HOME resolution shared by the plugin family's Host
3
+ * halves: environment overrides win (blank values treated as unset), then the
4
+ * platform home fallbacks follow — mirroring `@deepseek-ai/dsh-home-paths`.
5
5
  */
6
6
  /** Expand a leading ~ (or ~user) in a path, platform-style. */
7
7
  export declare function expandHome(path: string, home?: string): string;
@@ -14,3 +14,13 @@ export declare function expandHome(path: string, home?: string): string;
14
14
  export declare function resolveDshHome(env?: NodeJS.ProcessEnv, home?: string): string;
15
15
  /** Resolve the DSH home directory from the live environment. */
16
16
  export declare function dshHome(): string;
17
+ /**
18
+ * Resolve the shared agent configuration root (`$DSH_AGENTS_HOME`, defaulting
19
+ * to `<home>/.agents`), matching `@deepseek-ai/dsh-home-paths`'s `resolveAgentsHome`.
20
+ * @param env - process environment to read DSH_AGENTS_HOME from.
21
+ * @param home - platform home directory fallback (test seam).
22
+ * @returns the absolute shared agents home path.
23
+ */
24
+ export declare function resolveAgentsHome(env?: NodeJS.ProcessEnv, home?: string): string;
25
+ /** Resolve the shared agent configuration root from the live environment. */
26
+ export declare function agentsHome(): string;
@@ -312,7 +312,10 @@ export declare function spawnDsh(binary: string, args: string[], env: NodeJS.Pro
312
312
  * `# ==` header, with the composed entries as column-0 `- id:` items — an
313
313
  * entry a profile patch overrides appears once, carrying the override's keys,
314
314
  * so those lines are exactly the loader's own entry set. Nested config keeps
315
- * its own `id` keys indented and is never mistaken for an entry.
315
+ * its own `id` keys indented and is never mistaken for an entry, with one
316
+ * exception: a `group: true` entry's `config:` list holds real child entries
317
+ * (recursively), whose ids the loader composes just like top-level ones and
318
+ * which are collected here too (issue #2091).
316
319
  * @param dump - the dump's captured text.
317
320
  * @returns the composed entry ids, or undefined when the dump carried none.
318
321
  */
@@ -72,11 +72,34 @@ export declare function findBareRow(root: YAMLSeq, id: string): {
72
72
  * @returns the claimed insert ids, in order.
73
73
  */
74
74
  export declare function claimedIdsOf(patchText: string): string[];
75
+ /**
76
+ * Whether a patch node is a `group: true` container, whose `config:` list
77
+ * holds real child entries rather than composition data. The loader mounts
78
+ * those children as entries, so their ids count as live.
79
+ * @param node - one patch node.
80
+ * @returns whether the node is a group entry.
81
+ */
82
+ export declare function isGroupEntry(node: unknown): boolean;
83
+ /**
84
+ * The ids of the entries nested (recursively) under one `group: true` entry's
85
+ * `config:` list. These are composition children: the loader mounts each as a
86
+ * real entry, so an override their id carries is live even though no top-level
87
+ * row names them. Only a group's `config:` list is descended — a plain config
88
+ * value that happens to carry an `id` key (a nested `{ id, x }` item, say) is
89
+ * data, not an entry, and is left alone. A child that is itself a group
90
+ * recurses through its own `config:`.
91
+ * @param config - a group entry's `config` node.
92
+ * @param ids - the accumulator to add into.
93
+ */
94
+ export declare function collectGroupEntryIds(config: unknown, ids: Set<string>): void;
75
95
  /**
76
96
  * Every entry id a layer declares: its top-level `- id:` rows (bare override
77
- * rows and config rows alike) plus the entries of its `- insert:` lists. Ids
78
- * nested inside a row's own `config:` are composition children of that entry,
79
- * not layer entries, and are not declared here.
97
+ * rows and config rows alike) plus the entries of its `- insert:` lists, plus —
98
+ * recursively — the entries nested under any `group: true` entry's `config:`
99
+ * list (the loader mounts those as entries too, so an override for one is not
100
+ * an orphan; issue #2091). Ids nested inside a non-group row's own `config:`
101
+ * are composition data of that entry, not layer entries, and are not declared
102
+ * here.
80
103
  *
81
104
  * This answers "does this layer still declare that row?" without composing, so
82
105
  * it stays true in the states where a composition probe is not: a host that
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-plugin-manager",
3
3
  "description": "Update checking for the dsh web GUI's official Plugins page: compares installed plugins against the version their registry source serves, gates the update on the DSH runtime minimum the release declares, and drives the update through the official installer channel or this package's loopback CLI gateway.",
4
- "version": "0.4.22",
4
+ "version": "0.4.23",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dsh": {
24
24
  "engines": {
25
- "dsh": ">=0.2.3-alpha.2"
25
+ "dsh": ">=0.2.3-alpha.4"
26
26
  },
27
27
  "bundle": {
28
28
  "patch": "./cordis.patch.yml"
@@ -36,29 +36,29 @@
36
36
  }
37
37
  },
38
38
  "peerDependencies": {
39
- "@deepseek-ai/dsh": ">=0.2.3-alpha.2",
40
- "react": "^18.2.0"
39
+ "@deepseek-ai/dsh": ">=0.2.3-alpha.4",
40
+ "react": "^19.3.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@deepseek-ai/cordis": "~4.2.0-alpha.1",
44
- "@deepseek-ai/dsh-api-session-controller": "^0.2.3-alpha.2",
45
- "@deepseek-ai/dsh-api-workspace-controller": "^0.2.3-alpha.2",
46
- "@deepseek-ai/dsh-client-connection": "^0.2.3-alpha.2",
47
- "@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.2",
48
- "@deepseek-ai/dsh-client-ui-primitives": "^0.2.3-alpha.2",
49
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.3-alpha.2",
50
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.3-alpha.2",
51
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.2",
52
- "@deepseek-ai/dsh-client-ui-workspace": "^0.2.3-alpha.2",
53
- "@deepseek-ai/dsh-host-webserver": "^0.2.3-alpha.2",
54
- "@testing-library/react": "^16.1.0",
43
+ "@deepseek-ai/cordis": "~4.2.0-alpha.3",
44
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.3-alpha.4",
45
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.2.3-alpha.4",
46
+ "@deepseek-ai/dsh-client-connection": "^0.2.3-alpha.4",
47
+ "@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.4",
48
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.3-alpha.4",
49
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.3-alpha.4",
50
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.3-alpha.4",
51
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.4",
52
+ "@deepseek-ai/dsh-client-ui-workspace": "^0.2.3-alpha.4",
53
+ "@deepseek-ai/dsh-host-webserver": "^0.2.3-alpha.4",
54
+ "@testing-library/react": "^16.3.3",
55
55
  "@types/node": "^22.20.0",
56
- "@types/react": "~18.3.1",
57
- "@types/react-dom": "^18.3.5",
56
+ "@types/react": "~19.3.2",
57
+ "@types/react-dom": "~19.3.0",
58
58
  "@types/semver": "^7.8.0",
59
59
  "jsdom": "^26.0.0",
60
- "react": "^18.3.1",
61
- "react-dom": "^18.3.1",
60
+ "react": "^19.3.1",
61
+ "react-dom": "^19.3.1",
62
62
  "tsdown": "0.22.2",
63
63
  "typescript": "~5.7.2",
64
64
  "vitest": "^4.1.1"