@yukino.js/yukino 0.0.12 → 0.0.13-dev

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/dist/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  providers_exports,
4
4
  version,
5
5
  version_exports
6
- } from "./chunk-WL3ML2TB.js";
6
+ } from "./chunk-EGJKLA2W.js";
7
7
  import {
8
8
  bwrap_exports
9
9
  } from "./chunk-XLRV26YW.js";
@@ -1987,7 +1987,7 @@ async function initializeTelemetry() {
1987
1987
  if (!shouldInitialize()) {
1988
1988
  return;
1989
1989
  }
1990
- initialization = import("./providers-DPVHJZAX.js").then(async ({ createTelemetryRuntime }) => {
1990
+ initialization = import("./providers-MOCB6Y5L.js").then(async ({ createTelemetryRuntime }) => {
1991
1991
  runtime = await createTelemetryRuntime();
1992
1992
  runtime.setMode(mode);
1993
1993
  process.once("beforeExit", () => {
@@ -2002,8 +2002,8 @@ function setTelemetryMode(nextMode) {
2002
2002
  mode = nextMode;
2003
2003
  runtime.setMode(nextMode);
2004
2004
  }
2005
- function captureTelemetryError(error, context) {
2006
- runtime.captureError(error, context);
2005
+ function captureTelemetryError(error, context2) {
2006
+ runtime.captureError(error, context2);
2007
2007
  }
2008
2008
  async function flushTelemetry() {
2009
2009
  await initialization;
@@ -5229,13 +5229,13 @@ var BASH_DESCRIPTION = `Execute command in Bash; return stdout and stderr. Prefe
5229
5229
  - Quote paths with spaces. To change directory, use cd "path" && command in the same call. Separate independent commands; chain dependent commands with &&, not ;.
5230
5230
  - Prefer dedicated file/search tools over cat, head, tail, sed, awk, echo, or find. Scope searches to a directory, never the filesystem root. Diagnose failures rather than retrying in sleep loops.
5231
5231
  ${GIT_GUIDANCE}`;
5232
- var BASH_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed, unless it is a bare sleep.`;
5232
+ var BASH_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed.`;
5233
5233
  var POWERSHELL_DESCRIPTION = `Execute command in PowerShell; return stdout and stderr. Recommended on Windows (powershell.exe); uses pwsh elsewhere.
5234
5234
  - timeout is in seconds: default 120, maximum 600. Each call starts a fresh, independent shell in the Agent's working directory; location, variables, and options do not persist.
5235
5235
  - Quote paths with spaces; use Set-Location -LiteralPath "path" in the same call. Separate independent commands. For dependencies, check $LASTEXITCODE for native commands and use -ErrorAction Stop for cmdlets; ; does not stop on failure. Do not assume PowerShell 7 syntax.
5236
5236
  - Prefer dedicated file/search tools over Get-Content, Select-String, or Write-Output. Scope recursion to a directory, not a drive root. Diagnose failures rather than retrying in Start-Sleep loops.
5237
5237
  ${GIT_GUIDANCE}`;
5238
- var POWERSHELL_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or Start-Sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed, unless it is a bare Start-Sleep.`;
5238
+ var POWERSHELL_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or Start-Sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed.`;
5239
5239
  var READ_FILE_DESCRIPTION = `Read text with 1-based display line numbers, or images (png, jpg, jpeg, gif, webp) as visual content; not directories.
5240
5240
  - file_path is absolute or relative to the Agent's working directory. offset skips lines (0-based, default 0); limit defaults to 2000 lines, with a 50KB text output cap. Displayed line 101 starts at offset=100. Follow continuation/readback instructions for partial output.
5241
5241
  - Images ignore offset/limit. A successful read refreshes the file-state cache used by EditFile/WriteFile; re-read after an external-change error.`;
@@ -5277,7 +5277,6 @@ __export(shell_background_exports, {
5277
5277
  discardFd: () => discardFd,
5278
5278
  formatFinalResult: () => formatFinalResult,
5279
5279
  hasAnyForegroundTasks: () => hasAnyForegroundTasks,
5280
- isAutobackgroundingAllowed: () => isAutobackgroundingAllowed,
5281
5280
  openOutputFd: () => openOutputFd,
5282
5281
  readOutputFile: () => readOutputFile,
5283
5282
  sliceUtf8Safe: () => sliceUtf8Safe,
@@ -5564,12 +5563,12 @@ function takeUtf8Prefix(value, maxBytes) {
5564
5563
  }
5565
5564
  let used = 0;
5566
5565
  const parts = [];
5567
- for (const character of value) {
5568
- const bytes = utf8ByteLength(character);
5566
+ for (const character2 of value) {
5567
+ const bytes = utf8ByteLength(character2);
5569
5568
  if (used + bytes > maxBytes) {
5570
5569
  break;
5571
5570
  }
5572
- parts.push(character);
5571
+ parts.push(character2);
5573
5572
  used += bytes;
5574
5573
  }
5575
5574
  return parts.join("");
@@ -5675,11 +5674,6 @@ var BACKGROUND_NOTIFICATION_BYTES = 3e4;
5675
5674
  var BACKGROUND_PREVIEW_BYTES = TOOL_RESULT_PREVIEW_CHARS;
5676
5675
  var BACKGROUND_MAX_OUTPUT_BYTES = 5 * 1024 * 1024 * 1024;
5677
5676
  var SIZE_WATCHDOG_INTERVAL_MS = 500;
5678
- function isAutobackgroundingAllowed(command, disallowed) {
5679
- const first = /^\S+/.exec(command.trimStart())?.[0] ?? "";
5680
- const base = first.replace(/^.*\//, "").replace(/^["']|["']$/g, "").toLowerCase();
5681
- return !disallowed.has(base);
5682
- }
5683
5677
  function backgroundTaskName(command) {
5684
5678
  const flat = command.replace(/\s+/g, " ").trim();
5685
5679
  return flat.length > 80 ? `${flat.slice(0, 77)}...` : flat;
@@ -5904,7 +5898,6 @@ function backgroundAllForegroundTasks(registry) {
5904
5898
  var MAX_TIMEOUT = 600;
5905
5899
  var log9 = createChildLogger({ module: "bash" });
5906
5900
  var KILL_GRACE_MS = 3e3;
5907
- var DISALLOWED_AUTO_BACKGROUND_COMMANDS = /* @__PURE__ */ new Set(["sleep"]);
5908
5901
  var BashTool = class {
5909
5902
  async dispose() {
5910
5903
  await this.sandbox?.dispose?.();
@@ -6214,19 +6207,15 @@ ${BASH_BACKGROUND_DESCRIPTION}`;
6214
6207
  terminate();
6215
6208
  };
6216
6209
  const backgroundAvailableHere = manager !== null && process.env.YUKINO_DISABLE_BACKGROUND_TASKS !== "1";
6217
- const autoBackgroundAllowed = backgroundAvailableHere && isAutobackgroundingAllowed(
6218
- command,
6219
- DISALLOWED_AUTO_BACKGROUND_COMMANDS
6220
- );
6221
6210
  let timedOut = false;
6222
- const timeoutTimer = setTimeout(() => {
6223
- if (autoBackgroundAllowed && backgroundExecution("timeout") !== null) {
6211
+ const timeoutTimer = ctx.shellTimeoutDisabled ? void 0 : setTimeout(() => {
6212
+ if (backgroundExecution("timeout") !== null) {
6224
6213
  return;
6225
6214
  }
6226
6215
  timedOut = true;
6227
6216
  terminate();
6228
6217
  }, timeout * 1e3);
6229
- timeoutTimer.unref();
6218
+ timeoutTimer?.unref();
6230
6219
  ctx.abortSignal?.addEventListener("abort", onAbort, { once: true });
6231
6220
  if (ctx.abortSignal?.aborted) {
6232
6221
  onAbort();
@@ -8087,6 +8076,112 @@ function buildDiff(oldContent, newContent) {
8087
8076
  };
8088
8077
  }
8089
8078
 
8079
+ // src/tools/edit-file-diagnostics.ts
8080
+ var edit_file_diagnostics_exports = {};
8081
+ __export(edit_file_diagnostics_exports, {
8082
+ describeEditMismatch: () => describeEditMismatch
8083
+ });
8084
+ function position(text, offset) {
8085
+ const prefix = text.slice(0, offset);
8086
+ const line = (prefix.match(/\n/gu)?.length ?? 0) + 1;
8087
+ const column = Array.from(prefix.slice(prefix.lastIndexOf("\n") + 1)).length + 1;
8088
+ return `line ${String(line)}, column ${String(column)}`;
8089
+ }
8090
+ function character(text, offset) {
8091
+ const codePoint = text.codePointAt(offset);
8092
+ if (codePoint === void 0) {
8093
+ return "end of text";
8094
+ }
8095
+ const value = JSON.stringify(String.fromCodePoint(codePoint)).replace(
8096
+ / /gu,
8097
+ "\\u0020"
8098
+ );
8099
+ return `${value} (U+${codePoint.toString(16).toUpperCase().padStart(4, "0")})`;
8100
+ }
8101
+ function context(text, offset) {
8102
+ return JSON.stringify(
8103
+ text.slice(Math.max(0, offset - 30), offset + 30)
8104
+ ).replace(/ /gu, "\\u0020");
8105
+ }
8106
+ function mismatch(file, snippet, start, length) {
8107
+ return [
8108
+ `First difference: old_string ${position(snippet, length)} has ${character(snippet, length)}; file ${position(file, start + length)} has ${character(file, start + length)}.`,
8109
+ `old_string context: ${context(snippet, length)}`,
8110
+ `file context: ${context(file, start + length)}`
8111
+ ].join("\n");
8112
+ }
8113
+ function commonPrefix(file, snippet, start) {
8114
+ let length = 0;
8115
+ while (length < snippet.length && file.codePointAt(start + length) === snippet.codePointAt(length)) {
8116
+ length += (snippet.codePointAt(length) ?? 0) > 65535 ? 2 : 1;
8117
+ }
8118
+ return length;
8119
+ }
8120
+ function sourceOffset(text, normalizedOffset) {
8121
+ let removed = 0;
8122
+ for (const whitespace of text.matchAll(/[^\S\r\n]+/gu)) {
8123
+ if (whitespace.index - removed >= normalizedOffset) {
8124
+ break;
8125
+ }
8126
+ removed += whitespace[0].length - 1;
8127
+ }
8128
+ return normalizedOffset + removed;
8129
+ }
8130
+ function describeEditMismatch(content, oldString) {
8131
+ const file = content.replace(/\r\n/gu, "\n");
8132
+ const snippet = oldString.replace(/\r\n/gu, "\n");
8133
+ const normalizedFile = file.replace(/[^\S\r\n]+/gu, " ");
8134
+ const normalizedSnippet = snippet.replace(/[^\S\r\n]+/gu, " ");
8135
+ const candidates = [];
8136
+ if (normalizedSnippet) {
8137
+ let cursor = 0;
8138
+ while (candidates.length < 3) {
8139
+ const index = normalizedFile.indexOf(normalizedSnippet, cursor);
8140
+ if (index < 0) {
8141
+ break;
8142
+ }
8143
+ candidates.push(sourceOffset(file, index));
8144
+ cursor = index + normalizedSnippet.length;
8145
+ }
8146
+ }
8147
+ const details = [];
8148
+ if (candidates.length > 0) {
8149
+ details.push(
8150
+ `Candidates matching after horizontal whitespace normalization (up to 3): ${candidates.map((start2) => `file ${position(file, start2)}`).join("; ")}. These are suggestions only; whitespace must match exactly.`
8151
+ );
8152
+ const start = candidates[0];
8153
+ details.push(
8154
+ mismatch(file, snippet, start, commonPrefix(file, snippet, start))
8155
+ );
8156
+ } else {
8157
+ let low = 0;
8158
+ let high = snippet.length;
8159
+ while (low < high) {
8160
+ const middle = Math.ceil((low + high) / 2);
8161
+ if (file.includes(snippet.slice(0, middle))) {
8162
+ low = middle;
8163
+ } else {
8164
+ high = middle - 1;
8165
+ }
8166
+ }
8167
+ if (low > 0) {
8168
+ const start = file.indexOf(snippet.slice(0, low));
8169
+ details.push(
8170
+ `Longest matching prefix starts at file ${position(file, start)}.`
8171
+ );
8172
+ details.push(
8173
+ mismatch(file, snippet, start, commonPrefix(file, snippet, start))
8174
+ );
8175
+ } else {
8176
+ details.push(
8177
+ "No matching prefix or horizontal-whitespace candidate found."
8178
+ );
8179
+ }
8180
+ }
8181
+ details.push("No edits were written.");
8182
+ return details.join("\n");
8183
+ }
8184
+
8090
8185
  // src/tools/file-mutation-queue.ts
8091
8186
  var file_mutation_queue_exports = {};
8092
8187
  __export(file_mutation_queue_exports, {
@@ -8155,12 +8250,14 @@ function applyEdits(content, edits) {
8155
8250
  const ending = /\r?\n/u.exec(content)?.[0] ?? "\n";
8156
8251
  const replacements = [];
8157
8252
  for (const [editIndex, edit] of edits.entries()) {
8158
- let pattern = editPattern(edit.oldString);
8253
+ let oldString = edit.oldString;
8254
+ let pattern = editPattern(oldString);
8159
8255
  let match = pattern.exec(content);
8160
8256
  let newString = edit.newString;
8161
8257
  if (!match) {
8162
8258
  const cleanedOldString = withoutStrayCarriageReturns(edit.oldString);
8163
8259
  if (cleanedOldString && cleanedOldString !== edit.oldString) {
8260
+ oldString = cleanedOldString;
8164
8261
  pattern = editPattern(cleanedOldString);
8165
8262
  match = pattern.exec(content);
8166
8263
  newString = withoutStrayCarriageReturns(newString);
@@ -8191,7 +8288,8 @@ function applyEdits(content, edits) {
8191
8288
  }
8192
8289
  if (count === 0) {
8193
8290
  throw new Error(
8194
- `edits[${String(editIndex)}].old_string not found in file`
8291
+ `edits[${String(editIndex)}].old_string not found in file
8292
+ ${describeEditMismatch(content, oldString)}`
8195
8293
  );
8196
8294
  }
8197
8295
  }
@@ -9544,13 +9642,13 @@ var LspTool = class {
9544
9642
  }
9545
9643
  }
9546
9644
  const textDocument = { uri };
9547
- const position = {
9645
+ const position2 = {
9548
9646
  line: (args.line ?? 1) - 1,
9549
9647
  character: (args.character ?? 1) - 1
9550
9648
  };
9551
9649
  if (args.line !== void 0) {
9552
9650
  const lines = text.split(/\r?\n/u);
9553
- if (position.line >= lines.length || position.character > (lines[position.line]?.length ?? 0)) {
9651
+ if (position2.line >= lines.length || position2.character > (lines[position2.line]?.length ?? 0)) {
9554
9652
  throw new Error("LSP position is outside the document");
9555
9653
  }
9556
9654
  }
@@ -9618,7 +9716,7 @@ var LspTool = class {
9618
9716
  if (args.operation === "incomingCalls" || args.operation === "outgoingCalls") {
9619
9717
  const prepared = await session.client.request(
9620
9718
  "textDocument/prepareCallHierarchy",
9621
- { textDocument, position },
9719
+ { textDocument, position: position2 },
9622
9720
  signal
9623
9721
  );
9624
9722
  if (!Array.isArray(prepared)) {
@@ -9641,7 +9739,7 @@ var LspTool = class {
9641
9739
  `textDocument/${args.operation}`,
9642
9740
  {
9643
9741
  textDocument,
9644
- position,
9742
+ position: position2,
9645
9743
  ...args.operation === "references" ? { context: { includeDeclaration: true } } : {}
9646
9744
  },
9647
9745
  signal
@@ -9717,7 +9815,6 @@ import { execFile as execFile2, spawn as spawn5 } from "child_process";
9717
9815
  import { statSync as statSync7 } from "fs";
9718
9816
  var MAX_TIMEOUT2 = 600;
9719
9817
  var KILL_GRACE_MS2 = 3e3;
9720
- var DISALLOWED_AUTO_BACKGROUND_COMMANDS2 = /* @__PURE__ */ new Set(["start-sleep", "sleep"]);
9721
9818
  var PowerShellTool = class {
9722
9819
  // Use a hardcoded string instead of PowerShellTool.name.replace("Tool", "")
9723
9820
  // because class names are not stable after minification — bundlers like
@@ -9952,19 +10049,15 @@ ${POWERSHELL_BACKGROUND_DESCRIPTION}`;
9952
10049
  terminate();
9953
10050
  };
9954
10051
  const backgroundAvailableHere = manager !== null && process.env.YUKINO_DISABLE_BACKGROUND_TASKS !== "1";
9955
- const autoBackgroundAllowed = backgroundAvailableHere && isAutobackgroundingAllowed(
9956
- command,
9957
- DISALLOWED_AUTO_BACKGROUND_COMMANDS2
9958
- );
9959
10052
  let timedOut = false;
9960
- const timeoutTimer = setTimeout(() => {
9961
- if (autoBackgroundAllowed && backgroundExecution("timeout") !== null) {
10053
+ const timeoutTimer = ctx.shellTimeoutDisabled ? void 0 : setTimeout(() => {
10054
+ if (backgroundExecution("timeout") !== null) {
9962
10055
  return;
9963
10056
  }
9964
10057
  timedOut = true;
9965
10058
  terminate();
9966
10059
  }, timeout * 1e3);
9967
- timeoutTimer.unref();
10060
+ timeoutTimer?.unref();
9968
10061
  ctx.abortSignal?.addEventListener("abort", onAbort, { once: true });
9969
10062
  if (ctx.abortSignal?.aborted) {
9970
10063
  onAbort();
@@ -10909,7 +11002,7 @@ function wireSkillsToRegistry(catalog, commandRegistry, skillHost) {
10909
11002
  type: skill.meta.mode === "fork" ? "skill_fork" : "prompt",
10910
11003
  description: `${meta.description} [skill]`,
10911
11004
  isSkill: true,
10912
- handler: skill.meta.mode === "fork" ? () => "" : (context) => runInline(skill, context.args, skillHost)
11005
+ handler: skill.meta.mode === "fork" ? () => "" : (context2) => runInline(skill, context2.args, skillHost)
10913
11006
  };
10914
11007
  try {
10915
11008
  commandRegistry.register(command);
@@ -13427,7 +13520,7 @@ function parseCommandFile(base, full) {
13427
13520
  return {
13428
13521
  name,
13429
13522
  type: "prompt",
13430
- description: description || (argumentHint ? `custom command (args: ${argumentHint})` : "custom command"),
13523
+ description: `${description || (argumentHint ? `custom command (args: ${argumentHint})` : "custom command")} [custom]`,
13431
13524
  handler: (ctx) => renderBody(body, ctx.args)
13432
13525
  };
13433
13526
  }
@@ -13550,7 +13643,7 @@ var HookEngine = class {
13550
13643
  this.notifications = [];
13551
13644
  return out;
13552
13645
  }
13553
- async fire(event, context, options = {}) {
13646
+ async fire(event, context2, options = {}) {
13554
13647
  const results = [];
13555
13648
  for (const [index, hook] of this.hooks.entries()) {
13556
13649
  if (options.abortSignal?.aborted) {
@@ -13559,7 +13652,7 @@ var HookEngine = class {
13559
13652
  if (hook.event !== event) {
13560
13653
  continue;
13561
13654
  }
13562
- if (hook.condition && !evaluateCondition(hook.condition, context)) {
13655
+ if (hook.condition && !evaluateCondition(hook.condition, context2)) {
13563
13656
  continue;
13564
13657
  }
13565
13658
  const onceKey = hook.once ? hook.id === void 0 ? `index:${String(index)}` : `id:${hook.id}` : null;
@@ -13570,7 +13663,7 @@ var HookEngine = class {
13570
13663
  this.firedOnce.add(onceKey);
13571
13664
  }
13572
13665
  if (hook.async) {
13573
- this.executeAction(hook, context, options).then((r) => {
13666
+ this.executeAction(hook, context2, options).then((r) => {
13574
13667
  this.recordNotification(r.output);
13575
13668
  }).catch((err) => {
13576
13669
  log18.error({ err }, "hooks operation failed");
@@ -13586,7 +13679,7 @@ var HookEngine = class {
13586
13679
  continue;
13587
13680
  }
13588
13681
  try {
13589
- const result = await this.executeAction(hook, context, options);
13682
+ const result = await this.executeAction(hook, context2, options);
13590
13683
  results.push(result);
13591
13684
  if (result.reject && event === "pre_tool_use") {
13592
13685
  break;
@@ -13612,13 +13705,13 @@ var HookEngine = class {
13612
13705
  return results;
13613
13706
  }
13614
13707
  async firePreToolHooks(toolName, args, options = {}) {
13615
- const context = {
13708
+ const context2 = {
13616
13709
  event: "pre_tool_use",
13617
13710
  toolName,
13618
13711
  args,
13619
13712
  filePath: strArg(args, "file_path", strArg(args, "path", ""))
13620
13713
  };
13621
- const results = await this.fire("pre_tool_use", context, options);
13714
+ const results = await this.fire("pre_tool_use", context2, options);
13622
13715
  for (const r of results) {
13623
13716
  if (r.reject) {
13624
13717
  return { rejected: true, reason: r.output };
@@ -13627,7 +13720,7 @@ var HookEngine = class {
13627
13720
  }
13628
13721
  return { rejected: false, reason: "" };
13629
13722
  }
13630
- async executeAction(hook, context, options) {
13723
+ async executeAction(hook, context2, options) {
13631
13724
  switch (hook.action.type) {
13632
13725
  case "command": {
13633
13726
  const command = hook.action.command ?? "";
@@ -13637,9 +13730,9 @@ var HookEngine = class {
13637
13730
  signal: options.abortSignal,
13638
13731
  env: {
13639
13732
  ...process.env,
13640
- YUKINO_EVENT: context.event,
13641
- YUKINO_TOOL: context.toolName ?? "",
13642
- YUKINO_FILE_PATH: context.filePath ?? ""
13733
+ YUKINO_EVENT: context2.event,
13734
+ YUKINO_TOOL: context2.toolName ?? "",
13735
+ YUKINO_FILE_PATH: context2.filePath ?? ""
13643
13736
  }
13644
13737
  });
13645
13738
  return {
@@ -13666,7 +13759,7 @@ var HookEngine = class {
13666
13759
  const resp = await fetch(url, {
13667
13760
  method,
13668
13761
  headers: { "Content-Type": "application/json" },
13669
- ...method === "GET" || method === "HEAD" ? {} : { body: JSON.stringify(context) },
13762
+ ...method === "GET" || method === "HEAD" ? {} : { body: JSON.stringify(context2) },
13670
13763
  signal: options.abortSignal ? AbortSignal.any([
13671
13764
  options.abortSignal,
13672
13765
  AbortSignal.timeout(3e4)
@@ -13697,7 +13790,7 @@ var HookEngine = class {
13697
13790
  }
13698
13791
  const prompt = hook.action.prompt ?? hook.action.command ?? "";
13699
13792
  try {
13700
- const output = await this.agentRunner(prompt, context);
13793
+ const output = await this.agentRunner(prompt, context2);
13701
13794
  return { output, success: true, reject: hook.reject ?? false };
13702
13795
  } catch (err) {
13703
13796
  log18.error({ err }, "hooks operation failed");
@@ -18042,7 +18135,7 @@ async function createRemoteAgent(opts) {
18042
18135
  const msgs = conv.getMessages();
18043
18136
  return msgs.slice(-count).map((m) => `${m.role}: ${contentToText(m.content)}`).join("\n");
18044
18137
  },
18045
- runSubagent: (prompt, abortSignal, context) => spawnSubagent(
18138
+ runSubagent: (prompt, abortSignal, context2) => spawnSubagent(
18046
18139
  BUILTIN_AGENTS[0],
18047
18140
  prompt,
18048
18141
  client,
@@ -18052,11 +18145,11 @@ async function createRemoteAgent(opts) {
18052
18145
  void 0,
18053
18146
  void 0,
18054
18147
  void 0,
18055
- context?.permissionChecker?.forCwd(cwd2) ?? handle.checker.forCwd(cwd2),
18148
+ context2?.permissionChecker?.forCwd(cwd2) ?? handle.checker.forCwd(cwd2),
18056
18149
  {
18057
18150
  abortSignal,
18058
18151
  background: false,
18059
- onPermissionRequest: context?.onPermissionRequest
18152
+ onPermissionRequest: context2?.onPermissionRequest
18060
18153
  }
18061
18154
  )
18062
18155
  };
@@ -18099,7 +18192,7 @@ async function createRemoteAgent(opts) {
18099
18192
  const agentTool = new AgentTool(
18100
18193
  cwd2,
18101
18194
  registry,
18102
- async (def, prompt, background, modelOverride, cwdOverride, context) => {
18195
+ async (def, prompt, background, modelOverride, cwdOverride, context2) => {
18103
18196
  return spawnSubagent(
18104
18197
  def,
18105
18198
  prompt,
@@ -18110,18 +18203,18 @@ async function createRemoteAgent(opts) {
18110
18203
  void 0,
18111
18204
  void 0,
18112
18205
  modelOverride,
18113
- cwdOverride ? context?.permissionChecker?.forCwd(cwdOverride) : context?.permissionChecker,
18206
+ cwdOverride ? context2?.permissionChecker?.forCwd(cwdOverride) : context2?.permissionChecker,
18114
18207
  {
18115
- abortSignal: context?.abortSignal,
18208
+ abortSignal: context2?.abortSignal,
18116
18209
  background,
18117
- onPermissionRequest: context?.onPermissionRequest,
18118
- permissionMode: context?.permissionChecker?.mode
18210
+ onPermissionRequest: context2?.onPermissionRequest,
18211
+ permissionMode: context2?.permissionChecker?.mode
18119
18212
  }
18120
18213
  );
18121
18214
  },
18122
18215
  conv,
18123
- async (prompt, forkConv, forkRegistry, modelOverride, context) => {
18124
- const forkCwd = context?.cwd ?? cwd2;
18216
+ async (prompt, forkConv, forkRegistry, modelOverride, context2) => {
18217
+ const forkCwd = context2?.cwd ?? cwd2;
18125
18218
  const resolvedModel = modelOverride ?? provider.model;
18126
18219
  const forkEnv = detectEnvironment(forkCwd);
18127
18220
  forkEnv.model = resolvedModel;
@@ -18130,7 +18223,7 @@ async function createRemoteAgent(opts) {
18130
18223
  { ...provider, model: resolvedModel },
18131
18224
  forkSystemPrompt
18132
18225
  ) : client;
18133
- const checker = (context?.permissionChecker ?? handle.checker).forSubagent(forkCwd);
18226
+ const checker = (context2?.permissionChecker ?? handle.checker).forSubagent(forkCwd);
18134
18227
  forkConv.addUserMessage(prompt);
18135
18228
  const forkTaskManager = new TaskManager();
18136
18229
  const agent2 = new Agent({
@@ -18140,8 +18233,8 @@ async function createRemoteAgent(opts) {
18140
18233
  conversation: forkConv,
18141
18234
  cwd: forkCwd,
18142
18235
  maxIterations: 200,
18143
- abortSignal: context?.abortSignal,
18144
- onPermissionRequest: context?.onPermissionRequest,
18236
+ abortSignal: context2?.abortSignal,
18237
+ onPermissionRequest: context2?.onPermissionRequest,
18145
18238
  fileStateCache: new FileStateCache(),
18146
18239
  instructions: loadInstructions(forkCwd),
18147
18240
  contextWindow: getContextWindow(provider),
@@ -20791,17 +20884,17 @@ var YukinoAcpAgent = class {
20791
20884
  }))
20792
20885
  };
20793
20886
  }
20794
- prompt(params, context) {
20887
+ prompt(params, context2) {
20795
20888
  const session = this.requireSession(params.sessionId);
20796
20889
  const text = promptToText(params.prompt);
20797
20890
  const generation = session.generation;
20798
20891
  const run2 = session.tail.catch(() => void 0).then(async () => {
20799
- if (session.closed || generation !== session.generation || context.signal.aborted) {
20892
+ if (session.closed || generation !== session.generation || context2.signal.aborted) {
20800
20893
  return { stopReason: "cancelled" };
20801
20894
  }
20802
20895
  const turnAbort = new AbortController();
20803
20896
  session.turnAbort = turnAbort;
20804
- const signal = AbortSignal.any([context.signal, turnAbort.signal]);
20897
+ const signal = AbortSignal.any([context2.signal, turnAbort.signal]);
20805
20898
  const abort = () => {
20806
20899
  session.runtime.abort();
20807
20900
  };
@@ -20815,7 +20908,7 @@ var YukinoAcpAgent = class {
20815
20908
  session,
20816
20909
  params.sessionId,
20817
20910
  text,
20818
- context,
20911
+ context2,
20819
20912
  signal
20820
20913
  );
20821
20914
  } finally {
@@ -20879,7 +20972,7 @@ var YukinoAcpAgent = class {
20879
20972
  }
20880
20973
  return session;
20881
20974
  }
20882
- async runPrompt(session, sessionId, text, context, signal) {
20975
+ async runPrompt(session, sessionId, text, context2, signal) {
20883
20976
  saveMessage(session.runtime.cwd, sessionId, {
20884
20977
  role: "user",
20885
20978
  content: text,
@@ -20891,7 +20984,7 @@ var YukinoAcpAgent = class {
20891
20984
  for await (const event of session.runtime.run(text, {
20892
20985
  onPermissionRequest: async (toolName, args, decision, toolCallId, requestSignal) => {
20893
20986
  const permissionSignal = requestSignal ?? signal;
20894
- const permission = context.client.request(
20987
+ const permission = context2.client.request(
20895
20988
  acp.methods.client.session.requestPermission,
20896
20989
  {
20897
20990
  sessionId,
@@ -20958,7 +21051,7 @@ var YukinoAcpAgent = class {
20958
21051
  );
20959
21052
  if (update) {
20960
21053
  const notification = { sessionId, update };
20961
- await context.client.notify(
21054
+ await context2.client.notify(
20962
21055
  acp.methods.client.session.update,
20963
21056
  notification
20964
21057
  );
@@ -20974,30 +21067,30 @@ function createYukinoAcpApp(runtimeFactory) {
20974
21067
  const implementation = new YukinoAcpAgent(runtimeFactory);
20975
21068
  const app = acp.agent({ name: "yukino" }).onRequest(
20976
21069
  acp.methods.agent.initialize,
20977
- (context) => implementation.initialize(context.params)
21070
+ (context2) => implementation.initialize(context2.params)
20978
21071
  ).onRequest(
20979
21072
  acp.methods.agent.authenticate,
20980
21073
  () => implementation.authenticate()
20981
21074
  ).onRequest(
20982
21075
  acp.methods.agent.session.new,
20983
- (context) => implementation.newSession(context.params)
21076
+ (context2) => implementation.newSession(context2.params)
20984
21077
  ).onRequest(
20985
21078
  acp.methods.agent.session.prompt,
20986
- (context) => implementation.prompt(context.params, context)
21079
+ (context2) => implementation.prompt(context2.params, context2)
20987
21080
  ).onRequest(
20988
21081
  acp.methods.agent.session.list,
20989
- (context) => implementation.listSessions(context.params)
21082
+ (context2) => implementation.listSessions(context2.params)
20990
21083
  ).onRequest(
20991
21084
  acp.methods.agent.session.load,
20992
- (context) => implementation.loadSession(context.params, context.client, true)
21085
+ (context2) => implementation.loadSession(context2.params, context2.client, true)
20993
21086
  ).onRequest(
20994
21087
  acp.methods.agent.session.resume,
20995
- (context) => implementation.loadSession(context.params, context.client, false)
21088
+ (context2) => implementation.loadSession(context2.params, context2.client, false)
20996
21089
  ).onRequest(
20997
21090
  acp.methods.agent.session.close,
20998
- (context) => implementation.closeSession(context.params)
20999
- ).onNotification(acp.methods.agent.session.cancel, (context) => {
21000
- implementation.cancel(context.params);
21091
+ (context2) => implementation.closeSession(context2.params)
21092
+ ).onNotification(acp.methods.agent.session.cancel, (context2) => {
21093
+ implementation.cancel(context2.params);
21001
21094
  }).onConnect((connection) => {
21002
21095
  connection.signal.addEventListener(
21003
21096
  "abort",
@@ -21256,24 +21349,16 @@ function formatInteractionSummary(summary, endedAt = Date.now()) {
21256
21349
  const promptTokens = summary.inputTokens + summary.cacheReadTokens + summary.cacheCreationTokens;
21257
21350
  const cacheHitRate = percentage(summary.cacheReadTokens, promptTokens);
21258
21351
  return [
21259
- "### Interaction summary",
21260
- "",
21261
- `Session \`${summary.sessionId}\``,
21262
- "",
21352
+ `### Session \`${summary.sessionId}\``,
21263
21353
  [
21264
21354
  `**Tools** ${String(totalToolCalls)} calls \xB7 \u2713 ${String(summary.successfulToolCalls)} \xB7 \u2717 ${String(summary.failedToolCalls)} \xB7 ${successRate.toFixed(1)}% success`,
21265
21355
  `**Time** ${formatDuration(endedAt - summary.startedAt)} wall \xB7 ${formatDuration(summary.agentActiveMs)} active`,
21266
- `**Breakdown** API ${formatDuration(apiTimeMs)} (${percentage(apiTimeMs, summary.agentActiveMs)}) \xB7 Tools ${formatDuration(summary.toolTimeMs)} (${percentage(summary.toolTimeMs, summary.agentActiveMs)})`
21267
- ].join(" \n"),
21268
- "",
21269
- [
21356
+ `**Breakdown** API ${formatDuration(apiTimeMs)} (${percentage(apiTimeMs, summary.agentActiveMs)}) \xB7 Tools ${formatDuration(summary.toolTimeMs)} (${percentage(summary.toolTimeMs, summary.agentActiveMs)})`,
21270
21357
  `**Tokens** \u2191 ${formatTokens2(summary.inputTokens)} input \xB7 \u2193 ${formatTokens2(summary.outputTokens)} output`,
21271
21358
  `**Cache** ${formatTokens2(summary.cacheReadTokens)} read \xB7 ${formatTokens2(summary.cacheCreationTokens)} write`,
21272
- `**Cache hit** ${cacheHitRate} (${formatTokens2(summary.cacheReadTokens)} of ${formatTokens2(promptTokens)} prompt)`
21273
- ].join(" \n"),
21274
- "",
21275
- "**Resume session** ",
21276
- `\`yukino --resume ${summary.sessionId}\``
21359
+ `**Cache hit** ${cacheHitRate} (${formatTokens2(summary.cacheReadTokens)} of ${formatTokens2(promptTokens)} prompt)`,
21360
+ `\`yukino --resume ${summary.sessionId}\``
21361
+ ].join(" \n")
21277
21362
  ].join("\n");
21278
21363
  }
21279
21364
 
@@ -21310,26 +21395,26 @@ var CodeReviewFormSchema = z20.object({
21310
21395
  to: z20.string(),
21311
21396
  commit: z20.string(),
21312
21397
  exclude: z20.string()
21313
- }).superRefine((values, context) => {
21398
+ }).superRefine((values, context2) => {
21314
21399
  const from = values.from.trim();
21315
21400
  const to = values.to.trim();
21316
21401
  const commit = values.commit.trim();
21317
21402
  if (from && !to) {
21318
- context.addIssue({
21403
+ context2.addIssue({
21319
21404
  code: "custom",
21320
21405
  path: ["to"],
21321
21406
  message: "To is required when From is set"
21322
21407
  });
21323
21408
  }
21324
21409
  if (to && !from) {
21325
- context.addIssue({
21410
+ context2.addIssue({
21326
21411
  code: "custom",
21327
21412
  path: ["from"],
21328
21413
  message: "From is required when To is set"
21329
21414
  });
21330
21415
  }
21331
21416
  if (commit && (from || to)) {
21332
- context.addIssue({
21417
+ context2.addIssue({
21333
21418
  code: "custom",
21334
21419
  path: ["commit"],
21335
21420
  message: "Commit cannot be combined with From/To"
@@ -21337,13 +21422,13 @@ var CodeReviewFormSchema = z20.object({
21337
21422
  }
21338
21423
  const validateRef = (field, value) => {
21339
21424
  if (/\r|\n/u.test(value)) {
21340
- context.addIssue({
21425
+ context2.addIssue({
21341
21426
  code: "custom",
21342
21427
  path: [field],
21343
21428
  message: "Git refs must be a single line"
21344
21429
  });
21345
21430
  } else if (value.startsWith("-")) {
21346
- context.addIssue({
21431
+ context2.addIssue({
21347
21432
  code: "custom",
21348
21433
  path: [field],
21349
21434
  message: "Git refs must not start with '-'"
@@ -21947,6 +22032,7 @@ __export(tools_exports3, {
21947
22032
  Descriptions: () => descriptions_exports,
21948
22033
  Diff: () => diff_exports,
21949
22034
  EditFile: () => edit_file_exports,
22035
+ EditFileDiagnostics: () => edit_file_diagnostics_exports,
21950
22036
  EnterWorktree: () => enter_worktree_exports,
21951
22037
  ExitCodeHints: () => exit_code_hints_exports,
21952
22038
  ExitPlanMode: () => exit_plan_mode_exports,
@@ -22640,7 +22726,7 @@ async function runPrintMode(args) {
22640
22726
  const agentTool = new AgentTool(
22641
22727
  cwd2,
22642
22728
  registry,
22643
- (def, prompt2, background, modelOverride, cwdOverride, context) => spawnSubagent(
22729
+ (def, prompt2, background, modelOverride, cwdOverride, context2) => spawnSubagent(
22644
22730
  def,
22645
22731
  prompt2,
22646
22732
  client,
@@ -22650,30 +22736,30 @@ async function runPrintMode(args) {
22650
22736
  void 0,
22651
22737
  void 0,
22652
22738
  modelOverride,
22653
- cwdOverride ? context?.permissionChecker?.forCwd(cwdOverride) : context?.permissionChecker,
22739
+ cwdOverride ? context2?.permissionChecker?.forCwd(cwdOverride) : context2?.permissionChecker,
22654
22740
  {
22655
- abortSignal: context?.abortSignal,
22741
+ abortSignal: context2?.abortSignal,
22656
22742
  background,
22657
- onPermissionRequest: context?.onPermissionRequest,
22658
- permissionMode: context?.permissionChecker?.mode
22743
+ onPermissionRequest: context2?.onPermissionRequest,
22744
+ permissionMode: context2?.permissionChecker?.mode
22659
22745
  }
22660
22746
  ),
22661
22747
  conv,
22662
- (prompt2, conversation, forkRegistry, modelOverride, context) => spawnSubagent(
22748
+ (prompt2, conversation, forkRegistry, modelOverride, context2) => spawnSubagent(
22663
22749
  BUILTIN_AGENTS[0],
22664
22750
  prompt2,
22665
22751
  client,
22666
22752
  forkRegistry,
22667
22753
  provider,
22668
- context?.cwd ?? cwd2,
22754
+ context2?.cwd ?? cwd2,
22669
22755
  void 0,
22670
22756
  void 0,
22671
22757
  modelOverride,
22672
- context?.permissionChecker,
22758
+ context2?.permissionChecker,
22673
22759
  {
22674
22760
  conversation,
22675
- abortSignal: context?.abortSignal,
22676
- onPermissionRequest: context?.onPermissionRequest
22761
+ abortSignal: context2?.abortSignal,
22762
+ onPermissionRequest: context2?.onPermissionRequest
22677
22763
  }
22678
22764
  ),
22679
22765
  backgroundTaskManager
@@ -22940,9 +23026,9 @@ function record(text) {
22940
23026
  } catch {
22941
23027
  }
22942
23028
  }
22943
- function recordError(context, error) {
23029
+ function recordError(context2, error) {
22944
23030
  const stack = error instanceof Error ? error.stack ?? error.message : String(error);
22945
- record(`crash [${context}] ${stack}`);
23031
+ record(`crash [${context2}] ${stack}`);
22946
23032
  }
22947
23033
  var TERMINAL_GONE_CODES = /* @__PURE__ */ new Set(["EIO", "EPIPE", "ERR_STREAM_DESTROYED"]);
22948
23034
  function isTerminalGone(err) {
@@ -22953,11 +23039,11 @@ function isTerminalGone(err) {
22953
23039
  return typeof code === "string" && TERMINAL_GONE_CODES.has(code);
22954
23040
  }
22955
23041
  var terminalGoneRecorded = false;
22956
- function exitForTerminalGone(context, error) {
23042
+ function exitForTerminalGone(context2, error) {
22957
23043
  if (!terminalGoneRecorded) {
22958
23044
  terminalGoneRecorded = true;
22959
23045
  const detail = error instanceof Error ? error.message : String(error);
22960
- record(`terminal closed [${context}] ${detail}`);
23046
+ record(`terminal closed [${context2}] ${detail}`);
22961
23047
  }
22962
23048
  runExitCleanups();
22963
23049
  process.exit(0);