@dsh-electron/dsh-plugin-multi-root-workspace 0.1.9 → 0.1.11

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 (62) hide show
  1. package/CHANGELOG.en.md +26 -1
  2. package/CHANGELOG.md +26 -1
  3. package/README.en.md +24 -8
  4. package/README.md +24 -8
  5. package/cordis.patch.yml +4 -0
  6. package/lib/auto-review.js +1 -1
  7. package/lib/client.js +727 -209
  8. package/lib/client.js.map +1 -1
  9. package/lib/{command-Bwd6EGNV.js → command-BGdz7VBH.js} +65 -5
  10. package/lib/command.js +1 -1
  11. package/lib/{compat-CagUNzRB.js → compat-BiW-m_q0.js} +14 -1
  12. package/lib/compat.js +1 -1
  13. package/lib/{contract-DZ4zczDT.js → contract-CStSEOcK.js} +44 -1
  14. package/lib/index.js +6 -5
  15. package/lib/{instructions-CGNS3H0H.js → instructions-MePoRigy.js} +2 -206
  16. package/lib/instructions.js +1 -1
  17. package/lib/llm-message-fYORacvh.js +206 -0
  18. package/lib/metadata-DgqSdVX_.js +35 -0
  19. package/lib/{registry-BClm6wfh.js → registry-KSsmU393.js} +60 -7
  20. package/lib/registry.js +1 -1
  21. package/lib/{review-context-D-ohSVmA.js → review-context-AH-SXHmj.js} +1 -1
  22. package/lib/review-context.js +1 -1
  23. package/lib/scope.js +6 -2
  24. package/lib/skills.js +790 -0
  25. package/lib/types/client/WorkspaceFoldersAction.d.ts +1 -1
  26. package/lib/types/client/locales.d.ts +26 -16
  27. package/lib/types/client/open-in-app/OpenInAppAction.d.ts +5 -3
  28. package/lib/types/client/open-in-app/OpenTargetButton.d.ts +16 -10
  29. package/lib/types/client/open-in-app/adapter.d.ts +5 -1
  30. package/lib/types/client/open-in-app/controller.d.ts +5 -2
  31. package/lib/types/client/open-in-app/device.d.ts +11 -0
  32. package/lib/types/client/open-in-app/locales.d.ts +1 -1
  33. package/lib/types/client/open-in-app/open-path.d.ts +6 -5
  34. package/lib/types/client/open-in-app/open-toast.d.ts +39 -0
  35. package/lib/types/client/open-in-app/outcome.d.ts +23 -0
  36. package/lib/types/client/skills-client.d.ts +23 -0
  37. package/lib/types/client/skills-settings.d.ts +10 -0
  38. package/lib/types/client/skills.d.ts +36 -0
  39. package/lib/types/client/styles.d.ts +1 -1
  40. package/lib/types/command.d.ts +1 -1
  41. package/lib/types/compat/client-session.d.ts +2 -0
  42. package/lib/types/compat/dsh-version.d.ts +5 -5
  43. package/lib/types/compat/open-in-app-device.d.ts +23 -0
  44. package/lib/types/compat/skill-content.d.ts +3 -0
  45. package/lib/types/compat/skills-client.d.ts +33 -0
  46. package/lib/types/compat/skills-settings.d.ts +8 -0
  47. package/lib/types/compat/skills.d.ts +13 -0
  48. package/lib/types/compat/storage-zod.d.ts +1 -0
  49. package/lib/types/contract.d.ts +12 -1
  50. package/lib/types/registry.d.ts +7 -0
  51. package/lib/types/roots.d.ts +4 -1
  52. package/lib/types/scope.d.ts +2 -0
  53. package/lib/types/skills/catalog.d.ts +34 -0
  54. package/lib/types/skills/invocation.d.ts +7 -0
  55. package/lib/types/skills/metadata.d.ts +13 -0
  56. package/lib/types/skills/pool.d.ts +19 -0
  57. package/lib/types/skills/reader.d.ts +3 -0
  58. package/lib/types/skills/routing.d.ts +2 -0
  59. package/lib/types/skills-contract.d.ts +39 -0
  60. package/lib/types/skills.d.ts +43 -0
  61. package/package.json +98 -85
  62. package/lib/types/client/open-in-app/open-failure-toast.d.ts +0 -11
@@ -1,7 +1,7 @@
1
1
  import { t as effectiveDirectory } from "./session-directory-BLOstut1.js";
2
2
  import { r as canonicalPath$1 } from "./windows-runner-contract-B5R2K3mM.js";
3
3
  import { i as canonicalRoot, o as entryRootRef, p as resolveRootRef, r as availableRoots, t as RootValidationError } from "./roots-Ca_W1S9n.js";
4
- import { i as parsePanelCall, r as effectiveRootAccess, t as PANEL_CHANNEL } from "./contract-DZ4zczDT.js";
4
+ import { c as skillsRequestSchema, i as parsePanelCall, r as effectiveRootAccess, s as SKILLS_ENDPOINTS, t as PANEL_CHANNEL } from "./contract-CStSEOcK.js";
5
5
  import { closeSync, lstatSync, openSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { isAbsolute, join } from "node:path";
7
7
  import "@deepseek-ai/cordis";
@@ -682,6 +682,8 @@ function parseFoldersCommand(rawInput) {
682
682
  case "add":
683
683
  case "remove":
684
684
  case "alias":
685
+ case "alias-id":
686
+ case "skills":
685
687
  case "access":
686
688
  case "reveal":
687
689
  case "isolate-profiles":
@@ -723,7 +725,7 @@ function renderRootsReport(primaryRoot, statuses, unavailable, limit, mode) {
723
725
  for (const [index, status] of statuses.entries()) {
724
726
  const alias = status.alias === void 0 ? "" : ` [${status.alias}]`;
725
727
  const state = status.state === "available" ? "" : ` (${status.state}: ${status.detail ?? "unavailable"})`;
726
- lines.push(` ${index + 1} ${status.path}${alias} (${status.access})${state}`);
728
+ lines.push(` ${index + 1} ${status.path}${alias} (${status.access})${state}${typeof status.aliasId === "string" ? ` Skills: ${status.skillsEnabled === true ? "on" : "off"} /${status.aliasId}:` : ""}`);
727
729
  }
728
730
  const withheld = statuses.length - availableRoots(statuses).length;
729
731
  if (withheld > 0) lines.push(`${withheld} root(s) are registered but not writable right now; restore the directory and run /${COMMAND_NAME} list, or remove the entry.`);
@@ -744,7 +746,7 @@ function apply(ctx, config = {}) {
744
746
  ctx.commands.register({
745
747
  name: COMMAND_NAME,
746
748
  description: "List, add, remove, alias, or reveal the additional workspace roots of this session, or isolate DSH profile imports",
747
- input: { hint: "[list|add [path] [--inherit|--read-only|--read-write]|remove <n|path>|alias <n|path> [name]|access <n|path> <level>|reveal <n|path>|isolate-profiles [--apply]|help]" },
749
+ input: { hint: "[list|add [path] [--inherit|--read-only|--read-write]|remove <n|path>|alias <n|path> [name]|alias-id <n|path> <id>|skills <n|path> on|off|access <n|path> <level>|reveal <n|path>|isolate-profiles [--apply]|help]" },
748
750
  handler: async (invocation) => await runCommand(ctx, invocation, config)
749
751
  });
750
752
  ctx.inject(["connection", "webServer"], (connectionCtx) => {
@@ -753,7 +755,7 @@ function apply(ctx, config = {}) {
753
755
  ctx.logger.warn("multi-root: connection resolved without the service; the panel channel is not mounted");
754
756
  return;
755
757
  }
756
- const dispose = connection.rpc.handle(PANEL_CHANNEL, async (endpoint, payload) => await dispatchPanelRequest(ctx, endpoint, payload));
758
+ const dispose = connection.rpc.handle(PANEL_CHANNEL, async (endpoint, payload, signal) => await dispatchPanelRequest(ctx, endpoint, payload, signal));
757
759
  return () => {
758
760
  dispose();
759
761
  };
@@ -817,6 +819,20 @@ async function runCommand(ctx, invocation, config) {
817
819
  text: await report(registry, primaryRoot, policy.mode)
818
820
  };
819
821
  }
822
+ case "alias-id":
823
+ case "skills": {
824
+ const { text: reference, rest: value } = splitReference(parsed.rest);
825
+ const { ref } = await targetOf(registry, primaryRoot, reference);
826
+ if (parsed.verb === "alias-id") await registry.setAliasId(primaryRoot, ref, unquote(value));
827
+ else {
828
+ if (value !== "on" && value !== "off") throw new RootValidationError("invalid-ref", "skills requires on or off");
829
+ await registry.setSkillsEnabled(primaryRoot, ref, value === "on");
830
+ }
831
+ return {
832
+ kind: "success",
833
+ text: await report(registry, primaryRoot, policy.mode)
834
+ };
835
+ }
820
836
  case "access": {
821
837
  const { text: reference, rest: level } = splitReference(parsed.rest);
822
838
  const access = parseAccessLevel(level);
@@ -921,6 +937,8 @@ function helpText() {
921
937
  ` /${COMMAND_NAME} remove <n|path>`,
922
938
  ` /${COMMAND_NAME} alias <n|path> [name] (no name clears the alias)`,
923
939
  ` /${COMMAND_NAME} access <n|path> inherit|read-only|read-write`,
940
+ ` /${COMMAND_NAME} skills <n|path> on|off`,
941
+ ` /${COMMAND_NAME} alias-id <n|path> <kebab-case>`,
924
942
  ` /${COMMAND_NAME} reveal <n|path>`,
925
943
  ` /${COMMAND_NAME} isolate-profiles [--apply] (report or set packageImportMethod: copy for every profile under $DSH_HOME)`,
926
944
  "Roots are canonicalized before they are stored: `~` expands, and a duplicate, a nested directory,",
@@ -1067,6 +1085,8 @@ function toRootView(status, index) {
1067
1085
  ordinal: index + 1,
1068
1086
  id: status.id,
1069
1087
  path: status.path,
1088
+ ...typeof status.aliasId === "string" ? { aliasId: status.aliasId } : {},
1089
+ skillsEnabled: status.skillsEnabled === true,
1070
1090
  ...status.alias === void 0 ? {} : { alias: status.alias },
1071
1091
  addedAt: status.addedAt,
1072
1092
  state: status.state,
@@ -1139,8 +1159,34 @@ async function rootsViewOf(ctx, registry, primaryRoot, request) {
1139
1159
  * A malformed request is reported as `panel/bad-request` rather than throwing
1140
1160
  * through the channel.
1141
1161
  */
1142
- async function dispatchPanelRequest(ctx, endpoint, payload) {
1162
+ async function dispatchPanelRequest(ctx, endpoint, payload, signal) {
1143
1163
  try {
1164
+ if (SKILLS_ENDPOINTS.includes(endpoint)) {
1165
+ const parsedSkills = skillsRequestSchema.safeParse(payload);
1166
+ if (!parsedSkills.success) return {
1167
+ ok: false,
1168
+ error: {
1169
+ code: "panel/bad-request",
1170
+ message: "invalid Skills request",
1171
+ details: {}
1172
+ }
1173
+ };
1174
+ const request = parsedSkills.data;
1175
+ if (endpoint === "skillsPreview" && request.name === void 0 || endpoint === "skillsChanges" && request.generation === void 0) return {
1176
+ ok: false,
1177
+ error: {
1178
+ code: "panel/bad-request",
1179
+ message: "missing Skills request field",
1180
+ details: {}
1181
+ }
1182
+ };
1183
+ const skills = ctx.get("multiRootSkills");
1184
+ if (skills === void 0) throw new Error("multi-root skills: service is unavailable");
1185
+ return {
1186
+ ok: true,
1187
+ value: endpoint === "skillsList" ? await skills.listSession(request.sessionId, signal) : endpoint === "skillsPreview" ? await skills.previewSession(request.sessionId, request.name ?? "", signal) : await skills.changes(request.sessionId, request.generation ?? -1, signal)
1188
+ };
1189
+ }
1144
1190
  const parsed = parsePanelCall(endpoint, payload);
1145
1191
  if (!parsed.ok) return {
1146
1192
  ok: false,
@@ -1169,6 +1215,20 @@ async function dispatchPanelRequest(ctx, endpoint, payload) {
1169
1215
  ok: true,
1170
1216
  value: await rootsViewOf(ctx, registry, primaryRoot, request)
1171
1217
  };
1218
+ case "setSkillsEnabled":
1219
+ if (request.skillsEnabled === void 0) throw new RootValidationError("invalid-ref", "skillsEnabled is required");
1220
+ await registry.setSkillsEnabled(primaryRoot, requireEntry(request), request.skillsEnabled);
1221
+ return {
1222
+ ok: true,
1223
+ value: await rootsViewOf(ctx, registry, primaryRoot, request)
1224
+ };
1225
+ case "setAliasId":
1226
+ if (request.aliasId === void 0) throw new RootValidationError("invalid-alias-id", "aliasId is required");
1227
+ await registry.setAliasId(primaryRoot, requireEntry(request), request.aliasId);
1228
+ return {
1229
+ ok: true,
1230
+ value: await rootsViewOf(ctx, registry, primaryRoot, request)
1231
+ };
1172
1232
  case "setAccess":
1173
1233
  if (request.access === void 0) throw new RootValidationError("invalid-ref", "an access level is required");
1174
1234
  await registry.setAccess(primaryRoot, requireEntry(request), request.access);
package/lib/command.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as renderRootsReport, c as revealArgv, i as parseFoldersCommand, n as apply, o as resolvePanelPrimaryRoot, r as inject, s as revealAccepted, t as COMMAND_NAME } from "./command-Bwd6EGNV.js";
1
+ import { a as renderRootsReport, c as revealArgv, i as parseFoldersCommand, n as apply, o as resolvePanelPrimaryRoot, r as inject, s as revealAccepted, t as COMMAND_NAME } from "./command-BGdz7VBH.js";
2
2
  export { COMMAND_NAME, apply, inject, parseFoldersCommand, renderRootsReport, resolvePanelPrimaryRoot, revealAccepted, revealArgv };
@@ -50,7 +50,10 @@ const SUPPORTED_DSH_RELEASES = [
50
50
  "0.2.1-alpha.4",
51
51
  "0.2.1-alpha.5",
52
52
  "0.2.1-rc.1",
53
- "0.2.1-rc.2"
53
+ "0.2.1-rc.2",
54
+ "0.2.1-rc.3",
55
+ "0.2.1-rc.4",
56
+ "0.2.2-alpha.2"
54
57
  ];
55
58
  /**
56
59
  * Packages whose absence means this plugin cannot function at all: every one of
@@ -71,6 +74,11 @@ const REQUIRED_CORE_PACKAGES = [
71
74
  * that is the mixed-installation failure this contract exists to catch.
72
75
  */
73
76
  const OPTIONAL_CORE_PACKAGES = [
77
+ "@deepseek-ai/dsh-skill",
78
+ "@deepseek-ai/dsh-skill-filesystem",
79
+ "@deepseek-ai/dsh-settings",
80
+ "@deepseek-ai/dsh-api-session-controller",
81
+ "@deepseek-ai/dsh-session-query",
74
82
  "@deepseek-ai/dsh-tools",
75
83
  "@deepseek-ai/dsh-working-directory",
76
84
  "@deepseek-ai/dsh-lsp",
@@ -95,6 +103,8 @@ const OPTIONAL_CORE_PACKAGES = [
95
103
  * that disagrees with the host is a real mixed installation, not a phantom.
96
104
  */
97
105
  const RUNTIME_OPTIONAL_PACKAGES = [
106
+ "@deepseek-ai/dsh-skill",
107
+ "@deepseek-ai/dsh-skill-filesystem",
98
108
  "@deepseek-ai/dsh-agent-instructions",
99
109
  "@deepseek-ai/dsh-llm",
100
110
  "@deepseek-ai/dsh-session",
@@ -114,6 +124,9 @@ const RUNTIME_OPTIONAL_PACKAGES = [
114
124
  * uniformly `0.2.0-rc.2` installation).
115
125
  */
116
126
  const HOST_SERVICE_PACKAGES = [
127
+ "@deepseek-ai/dsh-settings",
128
+ "@deepseek-ai/dsh-api-session-controller",
129
+ "@deepseek-ai/dsh-session-query",
117
130
  "@deepseek-ai/dsh-agent",
118
131
  "@deepseek-ai/dsh-api-workspace-files",
119
132
  "@deepseek-ai/dsh-client-connection",
package/lib/compat.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as inject, i as assertSupportedInstallation, n as MultiRootCompatService, r as apply, t as DshCompatUnsupportedError } from "./compat-CagUNzRB.js";
1
+ import { a as inject, i as assertSupportedInstallation, n as MultiRootCompatService, r as apply, t as DshCompatUnsupportedError } from "./compat-BiW-m_q0.js";
2
2
  export { DshCompatUnsupportedError, MultiRootCompatService, apply, assertSupportedInstallation, inject };
@@ -1,4 +1,37 @@
1
1
  import { z } from "zod";
2
+ //#region src/skills-contract.ts
3
+ /** Browser-safe Skills wire shapes. Session IDs select authority; clients never send paths. */
4
+ const SKILLS_ENDPOINTS = [
5
+ "skillsList",
6
+ "skillsPreview",
7
+ "skillsChanges"
8
+ ];
9
+ const nameSchema = z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/);
10
+ const skillsRequestSchema = z.object({
11
+ sessionId: z.string().min(1),
12
+ name: nameSchema.optional(),
13
+ generation: z.number().int().nonnegative().optional()
14
+ }).strict();
15
+ const status = {
16
+ sessionId: z.string(),
17
+ generation: z.number().int().nonnegative(),
18
+ enabled: z.boolean()
19
+ };
20
+ z.object(status);
21
+ z.object({
22
+ ...status,
23
+ skills: z.array(z.object({
24
+ name: nameSchema,
25
+ description: z.string(),
26
+ modelInvocable: z.boolean()
27
+ }))
28
+ });
29
+ z.object({
30
+ ...status,
31
+ name: nameSchema,
32
+ content: z.string()
33
+ });
34
+ //#endregion
2
35
  //#region src/contract.ts
3
36
  /**
4
37
  * The wire contract between the browser panel and this plugin's host half.
@@ -40,6 +73,8 @@ const PANEL_ENDPOINTS = [
40
73
  "alias",
41
74
  "move",
42
75
  "setAccess",
76
+ "setSkillsEnabled",
77
+ "setAliasId",
43
78
  "reveal"
44
79
  ];
45
80
  /** The shared nine-cell rule; tool dispatch may subsequently narrow writes. */
@@ -65,6 +100,8 @@ const panelRequestSchema = z.object({
65
100
  }).strict().optional(),
66
101
  id: z.string().optional(),
67
102
  path: z.string().optional(),
103
+ aliasId: z.string().optional(),
104
+ skillsEnabled: z.boolean().optional(),
68
105
  alias: z.string().optional(),
69
106
  access: z.enum([
70
107
  "inherit",
@@ -88,6 +125,8 @@ const rootViewSchema = z.object({
88
125
  ordinal: z.number().int().positive(),
89
126
  id: z.string(),
90
127
  path: z.string(),
128
+ aliasId: z.string().optional(),
129
+ skillsEnabled: z.boolean().optional(),
91
130
  alias: z.string().optional(),
92
131
  addedAt: z.string(),
93
132
  state: z.enum([
@@ -208,6 +247,8 @@ function narrowCall(endpoint, value) {
208
247
  ...value.entry === void 0 ? {} : { entry: value.entry },
209
248
  ...value.id === void 0 ? {} : { id: value.id },
210
249
  ...value.path === void 0 ? {} : { path: value.path },
250
+ ...value.aliasId === void 0 ? {} : { aliasId: value.aliasId },
251
+ ...value.skillsEnabled === void 0 ? {} : { skillsEnabled: value.skillsEnabled },
211
252
  ...value.alias === void 0 ? {} : { alias: value.alias },
212
253
  ...value.access === void 0 ? {} : { access: value.access },
213
254
  ...value.beforeEntry === void 0 ? {} : { beforeEntry: value.beforeEntry },
@@ -224,6 +265,8 @@ function narrowRootView(value) {
224
265
  state: value.state,
225
266
  access: value.access ?? "inherit",
226
267
  ...value.effectiveAccess === void 0 ? {} : { effectiveAccess: value.effectiveAccess },
268
+ ...value.aliasId === void 0 ? {} : { aliasId: value.aliasId },
269
+ ...value.skillsEnabled === void 0 ? {} : { skillsEnabled: value.skillsEnabled },
227
270
  ...value.alias === void 0 ? {} : { alias: value.alias },
228
271
  ...value.detail === void 0 ? {} : { detail: value.detail }
229
272
  };
@@ -235,4 +278,4 @@ function firstIssue(error) {
235
278
  return `${issue.path.length === 0 ? "" : `${issue.path.join(".")}: `}${issue.message}`;
236
279
  }
237
280
  //#endregion
238
- export { parseRevealedView as a, parsePanelCall as i, PANEL_ENDPOINTS as n, parseRootsView as o, effectiveRootAccess as r, PANEL_CHANNEL as t };
281
+ export { parseRevealedView as a, skillsRequestSchema as c, parsePanelCall as i, PANEL_ENDPOINTS as n, parseRootsView as o, effectiveRootAccess as r, SKILLS_ENDPOINTS as s, PANEL_CHANNEL as t };
package/lib/index.js CHANGED
@@ -1,13 +1,14 @@
1
- import { a as composeInstructionMessage, c as createInstructionMessage, l as instructionsApi, r as PLUGIN_SOURCE, t as DEFAULT_MAX_BYTES, u as renderInstructions } from "./instructions-CGNS3H0H.js";
1
+ import { i as renderInstructions, n as instructionsApi, t as createInstructionMessage } from "./llm-message-fYORacvh.js";
2
+ import { a as composeInstructionMessage, r as PLUGIN_SOURCE, t as DEFAULT_MAX_BYTES } from "./instructions-MePoRigy.js";
2
3
  import { a as classifyStoredRoots, c as indexedStatuses, i as canonicalRoot, l as isCanonicallyUnder, m as validateRootCandidate, n as additionalRootId, p as resolveRootRef, r as availableRoots, s as expandRootInput, t as RootValidationError, u as removeStatusAt } from "./roots-Ca_W1S9n.js";
3
- import { _ as classifyInstallation, c as agentPtyMarkerVerdict, d as HOST_SERVICE_PACKAGES, f as OPTIONAL_CORE_PACKAGES, g as SUPPORTED_DSH_RELEASES, h as RUNTIME_OPTIONAL_PACKAGES, i as assertSupportedInstallation, l as assertAgentPtyMarker, m as RUNNER_ANCHORED_PACKAGES, n as MultiRootCompatService, o as AGENT_PTY_MARKER, p as REQUIRED_CORE_PACKAGES, s as PtyMarkerContractError, t as DshCompatUnsupportedError, u as CORE_PACKAGES, v as compatEnforcement, y as readInstalledVersion } from "./compat-CagUNzRB.js";
4
+ import { _ as classifyInstallation, c as agentPtyMarkerVerdict, d as HOST_SERVICE_PACKAGES, f as OPTIONAL_CORE_PACKAGES, g as SUPPORTED_DSH_RELEASES, h as RUNTIME_OPTIONAL_PACKAGES, i as assertSupportedInstallation, l as assertAgentPtyMarker, m as RUNNER_ANCHORED_PACKAGES, n as MultiRootCompatService, o as AGENT_PTY_MARKER, p as REQUIRED_CORE_PACKAGES, s as PtyMarkerContractError, t as DshCompatUnsupportedError, u as CORE_PACKAGES, v as compatEnforcement, y as readInstalledVersion } from "./compat-BiW-m_q0.js";
4
5
  import { n as widenConfined, t as MultiRootSandboxProvider } from "./sandbox-CXk5h-ct.js";
5
6
  import { MULTI_ROOT_PROVIDER_BRAND, MultiRootProviders, brandMultiRootProvider, isMultiRootProvider } from "./providers.js";
6
7
  import { t as MultiRootFileSystem } from "./fs-BTXySwSG.js";
7
- import { a as parseRevealedView, i as parsePanelCall, n as PANEL_ENDPOINTS, o as parseRootsView, t as PANEL_CHANNEL } from "./contract-DZ4zczDT.js";
8
+ import { a as parseRevealedView, i as parsePanelCall, n as PANEL_ENDPOINTS, o as parseRootsView, t as PANEL_CHANNEL } from "./contract-CStSEOcK.js";
8
9
  import { MultiRootScopeService, renderWorkspaceRootsContext, sanitizeAdditionalRoots } from "./scope.js";
9
- import { a as MultiRootRegistry, c as multiRootDomainSpec, i as MAX_ALIAS_LENGTH, l as RegistryAuthorityLease, n as DOMAIN_NAME, o as REGISTRY_CONTENDED_MESSAGE, r as MAX_ADDITIONAL_ROOTS_CEILING, t as DEFAULT_MAX_ADDITIONAL_ROOTS, u as RegistryLeaseContendedError } from "./registry-BClm6wfh.js";
10
- import { a as renderRootsReport, c as revealArgv, i as parseFoldersCommand, o as resolvePanelPrimaryRoot, t as COMMAND_NAME } from "./command-Bwd6EGNV.js";
10
+ import { a as MultiRootRegistry, c as multiRootDomainSpec, i as MAX_ALIAS_LENGTH, l as RegistryAuthorityLease, n as DOMAIN_NAME, o as REGISTRY_CONTENDED_MESSAGE, r as MAX_ADDITIONAL_ROOTS_CEILING, t as DEFAULT_MAX_ADDITIONAL_ROOTS, u as RegistryLeaseContendedError } from "./registry-KSsmU393.js";
11
+ import { a as renderRootsReport, c as revealArgv, i as parseFoldersCommand, o as resolvePanelPrimaryRoot, t as COMMAND_NAME } from "./command-BGdz7VBH.js";
11
12
  //#region src/index.ts
12
13
  /**
13
14
  * Carrier plugin face for the bare-package-name loader row (see the module
@@ -1,217 +1,13 @@
1
1
  import { t as effectiveDirectory } from "./session-directory-BLOstut1.js";
2
+ import { n as instructionsApi, t as createInstructionMessage } from "./llm-message-fYORacvh.js";
2
3
  import { t as aroundTool } from "./tool-context-CpgIFcCB.js";
3
4
  import { l as isCanonicallyUnder } from "./roots-Ca_W1S9n.js";
4
- import { createRequire } from "node:module";
5
5
  import { createHash } from "node:crypto";
6
6
  import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
7
7
  import "@deepseek-ai/cordis";
8
8
  import { canonicalPath } from "@deepseek-ai/dsh-sandbox";
9
9
  import { stat } from "node:fs/promises";
10
10
  import { AsyncLocalStorage } from "node:async_hooks";
11
- //#region src/compat/agent-instructions.ts
12
- /**
13
- * Compatibility adapter for upstream's instruction discovery and rendering.
14
- *
15
- * `@deepseek-ai/dsh-agent-instructions` renamed its renderer between two
16
- * releases this plugin supports, without changing its signature:
17
- *
18
- * ```text
19
- * 0.1.5-rc.2 renderWorkspaceContext(files, options) RenderedWorkspaceContext
20
- * 0.1.6-alpha.1 renderAgentInstructions(files, options) RenderedAgentInstructions
21
- * ```
22
- *
23
- * `discoverBaselineInstructionFiles` kept both its name and its signature.
24
- *
25
- * All coupling to that package is concentrated here so the business layer
26
- * (`src/instructions.ts`) only ever calls {@link renderInstructions} and
27
- * {@link InstructionsApi.discover}. A future rename is one edit in this file,
28
- * not a version check sprinkled through the provider.
29
- *
30
- * The export is picked by NAME rather than by comparing the release string:
31
- * a structural probe also copes with upstream keeping both names for a release,
32
- * or reshaping within one, which a version comparison does not.
33
- *
34
- * The package is loaded LAZILY, and its genuine ABSENCE is reported as absence
35
- * rather than thrown. It is an optional peer: the default DSH bundle mounts it,
36
- * but a minimal composition legitimately has neither it nor an agent, and in
37
- * that case this plugin's instruction row must simply contribute nothing. A
38
- * package that is present but cannot be evaluated is a different answer, and
39
- * one this adapter reports instead of caching as absence.
40
- *
41
- * @module @dsh-electron/dsh-plugin-multi-root-workspace/compat/agent-instructions
42
- */
43
- /** Raised when the package is present but carries neither renderer name. */
44
- var DshInstructionApiError = class extends Error {
45
- constructor(message) {
46
- super(message);
47
- this.name = "DshInstructionApiError";
48
- }
49
- };
50
- /** Resolution is attempted once per process; `null` records a confirmed absence. */
51
- let resolution;
52
- /**
53
- * Pick the renderer this release exports.
54
- * @param module - the loaded upstream module.
55
- * @returns the renderer.
56
- * @throws {DshInstructionApiError} when neither name is present.
57
- */
58
- function selectRenderer(module) {
59
- const render = module.renderAgentInstructions ?? module.renderWorkspaceContext;
60
- if (render === void 0) throw new DshInstructionApiError("multi-root workspace: @deepseek-ai/dsh-agent-instructions exports neither renderAgentInstructions (0.1.6 and later) nor renderWorkspaceContext (0.1.5); the additional roots' instruction files cannot be rendered. Adapt src/compat/agent-instructions.ts to the installed release.");
61
- return render;
62
- }
63
- /**
64
- * Adapt one loaded upstream module to {@link InstructionsApi}.
65
- * @param module - the loaded upstream module.
66
- * @returns the adapted surface.
67
- * @throws {DshInstructionApiError} when a function this plugin needs is absent.
68
- */
69
- function adaptInstructionsModule(module) {
70
- const discover = module.discoverBaselineInstructionFiles;
71
- if (discover === void 0) throw new DshInstructionApiError("multi-root workspace: @deepseek-ai/dsh-agent-instructions does not export discoverBaselineInstructionFiles; adapt src/compat/agent-instructions.ts to the installed release.");
72
- return {
73
- discover: (options) => discover(options),
74
- render: selectRenderer(module)
75
- };
76
- }
77
- /**
78
- * Whether one package is installed at all, judged WITHOUT evaluating it.
79
- *
80
- * This is what separates "the optional peer is absent" from "the optional peer
81
- * is installed but its evaluation fails" (a missing transitive dependency, a
82
- * broken build). Only a genuine resolvability failure counts as absence: a
83
- * resolution that fails for another reason (an `exports` map with no `require`
84
- * condition, say) leaves the verdict to the `import()` below, which is the
85
- * authority on whether the module can actually be loaded.
86
- * @param specifier - the bare package specifier to probe.
87
- * @returns whether the package resolves from this module.
88
- */
89
- function isPackageInstalled(specifier) {
90
- try {
91
- createRequire(import.meta.url).resolve(specifier);
92
- return true;
93
- } catch (error) {
94
- const code = error?.code;
95
- return code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND";
96
- }
97
- }
98
- /**
99
- * Load and adapt the upstream instruction surface, once.
100
- *
101
- * @returns the adapted surface, or `undefined` when the package is not
102
- * installed. A package that IS installed but exports neither renderer throws
103
- * instead: that is a compatibility break to fix, not an optional seam. So
104
- * does one that is installed but cannot be evaluated at all — a missing
105
- * transitive dependency, a broken build — because reporting that as absence
106
- * would drop every additional root's instructions for the rest of the
107
- * process. See {@link isPackageInstalled} for how the two are told apart.
108
- */
109
- async function instructionsApi() {
110
- resolution ??= (async () => {
111
- if (!isPackageInstalled("@deepseek-ai/dsh-agent-instructions")) return null;
112
- return adaptInstructionsModule(await import("@deepseek-ai/dsh-agent-instructions"));
113
- })();
114
- return await resolution ?? void 0;
115
- }
116
- /**
117
- * Render loaded instruction files within a byte budget, through whichever
118
- * renderer the installed release exports.
119
- *
120
- * This is the only rendering entry point the business layer uses.
121
- * @param files - loaded files, ordered broadest to most specific.
122
- * @param options - the byte budget.
123
- * @returns the rendered text and its budget diagnostics.
124
- * @throws {DshInstructionApiError} when no usable renderer is installed.
125
- */
126
- async function renderInstructions(files, options) {
127
- const api = await instructionsApi();
128
- if (api === void 0) throw new DshInstructionApiError("multi-root workspace: @deepseek-ai/dsh-agent-instructions is not installed, so instruction files cannot be rendered. Check for its presence with instructionsApi() before calling renderInstructions().");
129
- return api.render(files, options);
130
- }
131
- //#endregion
132
- //#region src/compat/llm-message.ts
133
- /**
134
- * This plugin's own producer kind.
135
- *
136
- * Session format 4 rejects the shared `kind: 'plugin'` (`format v4 message
137
- * requires a producer-owned source kind`). The kind is ours, not
138
- * `agent-instructions`: upstream treats that kind's `changes` array as its
139
- * own reconciliation authority.
140
- */
141
- const PRODUCER_SOURCE_KIND = "multi-root-workspace";
142
- /**
143
- * The first session format whose encoder refuses `kind: 'plugin'`.
144
- * Earlier formats declare that kind on `MessageSourceMap` and require it.
145
- */
146
- const PRODUCER_OWNED_FORMAT = 4;
147
- /**
148
- * Which source kind the installed session format will persist.
149
- * @param formatVersion - `SESSION_FORMAT_VERSION`, when the session package is installed.
150
- * @returns `plugin` through format 3, and this plugin's own kind from format 4 on.
151
- */
152
- function instructionSourceKind(formatVersion) {
153
- return formatVersion !== void 0 && formatVersion >= PRODUCER_OWNED_FORMAT ? PRODUCER_SOURCE_KIND : "plugin";
154
- }
155
- /**
156
- * The installed session format, when that package is present.
157
- *
158
- * A composition that never persists a session can omit the package; format 3
159
- * is then the spelling that still declares `kind: 'plugin'`. Any other failure
160
- * is a broken install and must surface.
161
- * @returns the format version, or `undefined` when the package is not installed.
162
- */
163
- async function installedFormatVersion() {
164
- try {
165
- const session = await import("@deepseek-ai/dsh-session");
166
- return typeof session.SESSION_FORMAT_VERSION === "number" ? session.SESSION_FORMAT_VERSION : void 0;
167
- } catch (error) {
168
- const code = error.code;
169
- if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") return void 0;
170
- throw error;
171
- }
172
- }
173
- /**
174
- * Build one user-role instruction message.
175
- *
176
- * Format 3 and earlier: `{ kind: 'plugin', plugin, form: 'instructions' }`.
177
- * Format 4 and later: `{ kind: 'multi-root-workspace', plugin, form: 'instructions' }`.
178
- * @param input - the body and the plugin attribution.
179
- * @returns the frozen message upstream's helper produced.
180
- * @throws {Error} when the optional peer is absent: a step that has instruction
181
- * text to deliver cannot be served without it, and staying silent would drop
182
- * user-visible context instead of reporting a misconfigured composition.
183
- */
184
- async function createInstructionMessage(input) {
185
- let module;
186
- try {
187
- module = await import("@deepseek-ai/dsh-llm");
188
- } catch (error) {
189
- throw new Error(`multi-root workspace: @deepseek-ai/dsh-llm is not installed, so additional roots' instruction files cannot be delivered as messages (${error instanceof Error ? error.message : String(error)}).`);
190
- }
191
- const create = module.createUserMessage;
192
- return create({
193
- content: [{
194
- type: "text",
195
- text: input.text
196
- }],
197
- source: instructionSource(input.plugin, await installedFormatVersion())
198
- });
199
- }
200
- /** The source object the installed format will persist. */
201
- function instructionSource(plugin, formatVersion) {
202
- const kind = instructionSourceKind(formatVersion);
203
- if (kind === "plugin") return {
204
- kind,
205
- plugin,
206
- form: "instructions"
207
- };
208
- return {
209
- kind,
210
- plugin,
211
- form: "instructions"
212
- };
213
- }
214
- //#endregion
215
11
  //#region src/compat/tool-result.ts
216
12
  /**
217
13
  * Whether a tool-result message reports failure, on every supported release.
@@ -935,4 +731,4 @@ async function loadDirectory(fs, api, root, config, signal, cwd, strict = false)
935
731
  };
936
732
  }
937
733
  //#endregion
938
- export { composeInstructionMessage as a, createInstructionMessage as c, apply as i, instructionsApi as l, DEFAULT_MAX_SOURCE_BYTES as n, inject as o, PLUGIN_SOURCE as r, touchedPathOfToolCall as s, DEFAULT_MAX_BYTES as t, renderInstructions as u };
734
+ export { composeInstructionMessage as a, apply as i, DEFAULT_MAX_SOURCE_BYTES as n, inject as o, PLUGIN_SOURCE as r, touchedPathOfToolCall as s, DEFAULT_MAX_BYTES as t };
@@ -1,2 +1,2 @@
1
- import { a as composeInstructionMessage, i as apply, n as DEFAULT_MAX_SOURCE_BYTES, o as inject, r as PLUGIN_SOURCE, s as touchedPathOfToolCall, t as DEFAULT_MAX_BYTES } from "./instructions-CGNS3H0H.js";
1
+ import { a as composeInstructionMessage, i as apply, n as DEFAULT_MAX_SOURCE_BYTES, o as inject, r as PLUGIN_SOURCE, s as touchedPathOfToolCall, t as DEFAULT_MAX_BYTES } from "./instructions-MePoRigy.js";
2
2
  export { DEFAULT_MAX_BYTES, DEFAULT_MAX_SOURCE_BYTES, PLUGIN_SOURCE, apply, composeInstructionMessage, inject, touchedPathOfToolCall };