@toddzheng024/dscode-bundle 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/THIRD_PARTY_NOTICES.md +15 -0
  2. package/cordis.patch.yml +3 -3
  3. package/package.json +7 -1
  4. package/plugins/clipboard-image/clipboard-image.swift +56 -0
  5. package/plugins/clipboard-image/index.mjs +70 -0
  6. package/plugins/code-review/git.mjs +95 -0
  7. package/plugins/code-review/index.mjs +88 -0
  8. package/plugins/dscode/index.mjs +57 -5
  9. package/plugins/email-tools/index.mjs +2 -2
  10. package/plugins/exec/index.mjs +107 -0
  11. package/plugins/session-metrics/index.mjs +6 -2
  12. package/plugins/session-metrics/rate.mjs +62 -0
  13. package/plugins/session-metrics/view.mjs +15 -9
  14. package/plugins/tui-tools/doctor-cli.mjs +22 -0
  15. package/plugins/tui-tools/doctor.mjs +141 -0
  16. package/plugins/tui-tools/index.mjs +14 -6
  17. package/plugins/ultra/policy.mjs +13 -2
  18. package/plugins/worktree-subagent/worktree.mjs +50 -0
  19. package/presets/dscode/agent.cordis.yml +14 -3
  20. package/vendor/deepseek/index.js +12 -2
  21. package/vendor/subagent/index.js +39 -12
  22. package/vendor/subagent-core/LICENSE +21 -0
  23. package/vendor/subagent-core/index.js +3232 -0
  24. package/vendor/subagent-core/invariant.js +76 -0
  25. package/vendor/subagent-core/typert.host.d.ts +3 -0
  26. package/vendor/subagent-core/typert.host.js +964 -0
  27. package/vendor/subagent-core/typert.remote-client.d.ts +27 -0
  28. package/vendor/subagent-core/typert.remote-client.js +160 -0
  29. package/vendor/subagent-core/types/assistant-output.d.ts +48 -0
  30. package/vendor/subagent-core/types/assistant-output.js +73 -0
  31. package/vendor/subagent-core/types/catalog.d.ts +77 -0
  32. package/vendor/subagent-core/types/catalog.js +103 -0
  33. package/vendor/subagent-core/types/child-agent.d.ts +150 -0
  34. package/vendor/subagent-core/types/child-agent.js +207 -0
  35. package/vendor/subagent-core/types/client.d.ts +8 -0
  36. package/vendor/subagent-core/types/client.js +7 -0
  37. package/vendor/subagent-core/types/continuation-activation.d.ts +251 -0
  38. package/vendor/subagent-core/types/continuation-activation.js +663 -0
  39. package/vendor/subagent-core/types/continuation-messages.d.ts +62 -0
  40. package/vendor/subagent-core/types/continuation-messages.js +102 -0
  41. package/vendor/subagent-core/types/continuation.d.ts +124 -0
  42. package/vendor/subagent-core/types/continuation.js +455 -0
  43. package/vendor/subagent-core/types/control-types.d.ts +146 -0
  44. package/vendor/subagent-core/types/control-types.js +9 -0
  45. package/vendor/subagent-core/types/control.d.ts +71 -0
  46. package/vendor/subagent-core/types/control.js +116 -0
  47. package/vendor/subagent-core/types/depth.d.ts +31 -0
  48. package/vendor/subagent-core/types/depth.js +39 -0
  49. package/vendor/subagent-core/types/descriptor.d.ts +144 -0
  50. package/vendor/subagent-core/types/descriptor.js +193 -0
  51. package/vendor/subagent-core/types/error.d.ts +11 -0
  52. package/vendor/subagent-core/types/error.js +14 -0
  53. package/vendor/subagent-core/types/inbox.d.ts +43 -0
  54. package/vendor/subagent-core/types/inbox.js +61 -0
  55. package/vendor/subagent-core/types/index.d.ts +316 -0
  56. package/vendor/subagent-core/types/index.js +511 -0
  57. package/vendor/subagent-core/types/internal.d.ts +58 -0
  58. package/vendor/subagent-core/types/internal.js +58 -0
  59. package/vendor/subagent-core/types/invariant.d.ts +13 -0
  60. package/vendor/subagent-core/types/invariant.js +91 -0
  61. package/vendor/subagent-core/types/lifecycle.d.ts +113 -0
  62. package/vendor/subagent-core/types/lifecycle.js +178 -0
  63. package/vendor/subagent-core/types/list-children.d.ts +65 -0
  64. package/vendor/subagent-core/types/list-children.js +381 -0
  65. package/vendor/subagent-core/types/out-of-process.d.ts +118 -0
  66. package/vendor/subagent-core/types/out-of-process.js +219 -0
  67. package/vendor/subagent-core/types/projection-types.d.ts +74 -0
  68. package/vendor/subagent-core/types/projection-types.js +7 -0
  69. package/vendor/subagent-core/types/projection.d.ts +95 -0
  70. package/vendor/subagent-core/types/projection.js +151 -0
  71. package/vendor/subagent-core/types/run-settlement.d.ts +17 -0
  72. package/vendor/subagent-core/types/run-settlement.js +70 -0
  73. package/vendor/subagent-core/types/types.d.ts +377 -0
  74. package/vendor/subagent-core/types/types.js +19 -0
  75. package/vendor/subagent-driver/LICENSE +21 -0
  76. package/vendor/subagent-driver/index.js +255 -0
  77. package/vendor/subagent-driver/types/index.d.ts +33 -0
  78. package/vendor/subagent-driver/types/structured.d.ts +42 -0
  79. package/vendor/subagent-fork/LICENSE +21 -0
  80. package/vendor/subagent-fork/index.js +61 -0
  81. package/vendor/subagent-fork/types/index.d.ts +20 -0
  82. package/vendor/subagent-spawn/LICENSE +21 -0
  83. package/vendor/subagent-spawn/index.js +45 -0
  84. package/vendor/subagent-spawn/types/index.d.ts +19 -0
  85. package/vendor/terminal/LICENSE +21 -0
  86. package/vendor/terminal/index.js +1013 -0
  87. package/vendor/terminal/types/config.d.ts +71 -0
  88. package/vendor/terminal/types/index.d.ts +36 -0
  89. package/vendor/terminal/types/sanitize.d.ts +47 -0
  90. package/vendor/terminal/types/session.d.ts +87 -0
  91. package/vendor/tui/dscode-clipboard-image/clipboard-image.swift +56 -0
  92. package/vendor/tui/dscode-clipboard-image/index.mjs +70 -0
  93. package/vendor/tui/index.mjs +341 -93
@@ -1,9 +1,12 @@
1
+ // dscode-child-name-v1
2
+ // dscode-child-worktree-v3
1
3
  // dscode-child-effort-v1
4
+ import { createChildWorktree, discardCleanChildWorktree } from "../../plugins/worktree-subagent/worktree.mjs";
2
5
  import z from "@deepseek-ai/schemastery";
3
6
  import { scopeChainOf, scopeOf } from "@deepseek-ai/dsh-scope";
4
7
  import { defineTool } from "@deepseek-ai/dsh-tools";
5
8
  import { SessionSeq } from "@deepseek-ai/dsh-session";
6
- import { assertSubagentMaxDepth, parentAgentOptionsForDelegation, settleRun } from "@deepseek-ai/dsh-subagent";
9
+ import { assertSubagentMaxDepth, parentAgentOptionsForDelegation, settleRun } from "../subagent-core/index.js";
7
10
  import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
8
11
  import { z as z$1 } from "zod";
9
12
  z.object({
@@ -398,8 +401,13 @@ function apply(ctx, config, session) {
398
401
  subagentProvider,
399
402
  disposeTool: runtimeCtx.tools.register(defineTool({
400
403
  name: toolName,
401
- description: wording.description + (backgroundEnabled ? continuable ? " This tool runs in the background by default, immediately returns a durable subagent id, and keeps the child conversation available for later turns. When that run settles, the runtime sends the parent a notice containing its outcome and any final assistant message; `send_message` steers the child's nearest step while it is running and starts a turn while it is idle. Set `run_in_background: false` only when your next action depends on receiving the result." : " This call waits for the result by default. Set `run_in_background: true` to return a job id; collect with `job_output` and stop with `job_kill`." : " This call waits for the subagent and returns its result.") + choiceDescription,
404
+ description: wording.description + (backgroundEnabled ? continuable ? " This tool runs in the background by default, immediately returns a durable subagent id, and keeps the child conversation available for later turns. When that run settles, the runtime sends the parent a notice containing its outcome and any final assistant message; `send_message` steers the child's nearest step while it is running and starts a turn while it is idle. Set `run_in_background: false` only when your next action depends on receiving the result." : " This call waits for the result by default. Set `run_in_background: true` to return a job id; collect with `job_output` and stop with `job_kill`." : " This call waits for the subagent and returns its result.") + choiceDescription + (continuable && (config.provider === "spawn" || config.provider === "fork") ? " Set worktree: true for an isolated Git checkout when agents edit in parallel. It starts at HEAD and refuses a dirty parent workspace; omit for read-only tasks or when the child needs uncommitted parent edits. You must inspect and integrate its changes; the worktree remains after completion." : ""),
402
405
  parameters: {
406
+ name: {
407
+ type: "string",
408
+ required: true,
409
+ description: "Unique name you give this child: 1-10 characters, letters, digits and underscores only, starting and ending with a letter (for example read_code). Address the child as /name in send_message and interrupt_agent."
410
+ },
403
411
  description: {
404
412
  type: "string",
405
413
  required: true,
@@ -428,6 +436,10 @@ function apply(ctx, config, session) {
428
436
  type: "string",
429
437
  description: "Reasoning effort for this child only, validated against its model. Omit to inherit. Prefer low for bounded tasks, high for difficult work, max for exceptional uncertainty. Provider/model remain unchanged."
430
438
  } } : {},
439
+ ...continuable && (config.provider === "spawn" || config.provider === "fork") ? { worktree: {
440
+ type: "boolean",
441
+ description: "Create an isolated Git worktree for this child at clean HEAD. Choose for parallel editing; omit or set false for read-only work or tasks requiring uncommitted parent changes. Parent must integrate the result."
442
+ } } : {},
431
443
  ...backgroundEnabled ? { run_in_background: {
432
444
  type: "boolean",
433
445
  description: continuable ? "Whether to run in the background and return a durable subagent id immediately. Defaults to true. Set false to wait for the result when your next action depends on it." : "Whether to run as a background job and return its id. Defaults to false; collect with job_output or stop with job_kill."
@@ -444,7 +456,8 @@ function apply(ctx, config, session) {
444
456
  required: true,
445
457
  const: "background"
446
458
  },
447
- jobId: {
459
+ worktree: { type: "string" },
460
+ jobId: {
448
461
  type: "string",
449
462
  required: true
450
463
  }
@@ -459,7 +472,8 @@ function apply(ctx, config, session) {
459
472
  required: true,
460
473
  const: "continuable"
461
474
  },
462
- subagentId: {
475
+ worktree: { type: "string" },
476
+ subagentId: {
463
477
  type: "string",
464
478
  required: true
465
479
  }
@@ -474,7 +488,8 @@ function apply(ctx, config, session) {
474
488
  required: true,
475
489
  const: "foreground"
476
490
  },
477
- runId: {
491
+ worktree: { type: "string" },
492
+ runId: {
478
493
  type: "string",
479
494
  required: true
480
495
  },
@@ -488,13 +503,16 @@ function apply(ctx, config, session) {
488
503
  ] },
489
504
  render: (_args, value) => [{
490
505
  type: "text",
491
- text: value.kind === "background" ? `started background subagent job ${value.jobId}` : value.kind === "continuable" ? `started subagent ${value.subagentId}` : outputValueText(value.output)
506
+ text: (value.kind === "background" ? `started background subagent job ${value.jobId}` : value.kind === "continuable" ? `started subagent /${_args.name} (${value.subagentId})` : outputValueText(value.output)) + (value.worktree ? `
507
+ Worktree: ${value.worktree}
508
+ Inspect and integrate its changes before removing it.` : "")
492
509
  }]
493
510
  },
494
511
  isConcurrencySafe: () => true,
495
512
  async execute(args, exec) {
496
513
  const parent = exec.agent;
497
514
  if (!parent) throw new Error("subagent tool requires a calling agent (exec.agent was undefined)");
515
+ if (typeof args.name !== "string" || !/^[A-Za-z](?:[A-Za-z0-9_]{0,8}[A-Za-z])?$/.test(args.name)) throw new Error("name must be 1-10 characters of letters, digits or underscores, starting and ending with a letter");
498
516
  const modelRequest = args;
499
517
  const parentOptions = parentAgentOptionsForDelegation(parent);
500
518
  const requiresRoutePreflight = hasDelegationModelRequest(modelRequest) || hasConfiguredLlmSelection(config.agentOptions);
@@ -510,9 +528,12 @@ function apply(ctx, config, session) {
510
528
  if (runtimeCtx.subagents.getProvider(config.provider) !== subagentProvider) throw new Error(`subagent provider "${config.provider}" changed while resolving the child LLM route; retry the delegation`);
511
529
  }
512
530
  exec.signal.throwIfAborted();
531
+ if (args.worktree === true && !(continuable && (config.provider === "spawn" || config.provider === "fork"))) throw new Error("worktree is unavailable for this subagent provider");
532
+ const childWorktree = args.worktree === true ? await createChildWorktree(parent.session.header.cwd, exec.signal) : void 0;
513
533
  const maxDepth = typeof config.maxDepth === "number" ? config.maxDepth : void 0;
514
534
  const request = {
515
- label: args.description,
535
+ label: "/" + args.name + " · " + args.description,
536
+ ...childWorktree ? { workspaceCwd: childWorktree.cwd } : {},
516
537
  prompt: [{
517
538
  type: "text",
518
539
  text: args.prompt
@@ -523,6 +544,7 @@ function apply(ctx, config, session) {
523
544
  ...config.toolFilter !== void 0 ? { toolFilter: config.toolFilter } : {},
524
545
  ...maxDepth !== void 0 ? { maxDepth } : {}
525
546
  };
547
+ try {
526
548
  if (resolveDelegationRun(args, {
527
549
  backgroundEnabled,
528
550
  continuable
@@ -531,10 +553,11 @@ function apply(ctx, config, session) {
531
553
  kind: "continuable",
532
554
  subagentId: (await runtimeCtx.subagents.startContinuable({
533
555
  provider: config.provider,
534
- label: args.description,
556
+ label: "/" + args.name + " · " + args.description,
535
557
  request,
536
558
  signal: exec.signal
537
- })).childId
559
+ })).childId,
560
+ ...childWorktree ? { worktree: childWorktree.cwd } : {}
538
561
  };
539
562
  const jobs = runtimeCtx.get("jobs");
540
563
  if (jobs === void 0) throw new Error("background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs");
@@ -542,7 +565,7 @@ function apply(ctx, config, session) {
542
565
  kind: "background",
543
566
  jobId: jobs.start({
544
567
  kind: "subagent",
545
- label: args.description,
568
+ label: "/" + args.name + " · " + args.description,
546
569
  owner: parent,
547
570
  run: () => {
548
571
  const controller = new AbortController();
@@ -559,10 +582,14 @@ function apply(ctx, config, session) {
559
582
  })
560
583
  };
561
584
  }
562
- return settleForegroundRun(await runtimeCtx.subagents.start(config.provider, {
585
+ return { ...await settleForegroundRun(await runtimeCtx.subagents.start(config.provider, {
563
586
  ...request,
564
587
  signal: exec.signal
565
- }));
588
+ })), ...childWorktree ? { worktree: childWorktree.cwd } : {} };
589
+ } catch (error) {
590
+ if (childWorktree && !await discardCleanChildWorktree(childWorktree)) throw new Error(`${String(error)}; child worktree retained at ${childWorktree.cwd}`, { cause: error });
591
+ throw error;
592
+ }
566
593
  }
567
594
  }))
568
595
  };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.