@letta-ai/letta-code 0.9.0-next.1 → 0.10.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 (2) hide show
  1. package/letta.js +2287 -720
  2. package/package.json +1 -1
package/letta.js CHANGED
@@ -3233,7 +3233,7 @@ var package_default;
3233
3233
  var init_package = __esm(() => {
3234
3234
  package_default = {
3235
3235
  name: "@letta-ai/letta-code",
3236
- version: "0.9.0-next.1",
3236
+ version: "0.10.0",
3237
3237
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
3238
3238
  type: "module",
3239
3239
  bin: {
@@ -27886,11 +27886,11 @@ var init_colors = __esm(() => {
27886
27886
  },
27887
27887
  link: {
27888
27888
  text: "cyan",
27889
- url: "blue"
27889
+ url: brandColors.primaryAccent
27890
27890
  },
27891
27891
  heading: {
27892
27892
  primary: "cyan",
27893
- secondary: "blue"
27893
+ secondary: brandColors.primaryAccent
27894
27894
  },
27895
27895
  status: {
27896
27896
  error: brandColors.statusError,
@@ -27930,7 +27930,7 @@ var init_colors = __esm(() => {
27930
27930
  },
27931
27931
  info: {
27932
27932
  border: brandColors.primaryAccent,
27933
- prompt: "blue"
27933
+ prompt: brandColors.primaryAccent
27934
27934
  },
27935
27935
  diff: {
27936
27936
  addedLineBg: "#1a4d1a",
@@ -27939,7 +27939,7 @@ var init_colors = __esm(() => {
27939
27939
  removedWordBg: "#7a2d2d",
27940
27940
  contextLineBg: undefined,
27941
27941
  textOnDark: "white",
27942
- textOnHighlight: "black",
27942
+ textOnHighlight: "white",
27943
27943
  symbolAdd: "green",
27944
27944
  symbolRemove: "red",
27945
27945
  symbolContext: undefined
@@ -33347,16 +33347,26 @@ class PermissionModeManager2 {
33347
33347
  "Write",
33348
33348
  "Edit",
33349
33349
  "MultiEdit",
33350
- "NotebookEdit",
33351
33350
  "apply_patch",
33352
- "ApplyPatch"
33351
+ "ApplyPatch",
33352
+ "write_file_gemini",
33353
+ "WriteFileGemini",
33354
+ "replace",
33355
+ "Replace"
33353
33356
  ];
33354
33357
  if (allowedInPlan.includes(toolName)) {
33355
33358
  return "allow";
33356
33359
  }
33357
33360
  if (writeTools.includes(toolName)) {
33358
33361
  const planFilePath = this.getPlanFilePath();
33359
- const targetPath = toolArgs?.file_path || toolArgs?.path;
33362
+ let targetPath = toolArgs?.file_path || toolArgs?.path;
33363
+ if ((toolName === "ApplyPatch" || toolName === "apply_patch") && toolArgs?.input) {
33364
+ const input = toolArgs.input;
33365
+ const match = input.match(/\*\*\* (?:Add|Update|Delete) File:\s*(.+)/);
33366
+ if (match?.[1]) {
33367
+ targetPath = match[1].trim();
33368
+ }
33369
+ }
33360
33370
  if (planFilePath && targetPath && targetPath === planFilePath) {
33361
33371
  return "allow";
33362
33372
  }
@@ -48385,13 +48395,9 @@ function SetupUI({ onComplete }) {
48385
48395
  setDeviceCode(deviceData.device_code);
48386
48396
  setUserCode(deviceData.user_code);
48387
48397
  setVerificationUri(deviceData.verification_uri_complete);
48388
- try {
48389
- const { default: open2 } = await Promise.resolve().then(() => (init_open(), exports_open));
48390
- const subprocess = await open2(deviceData.verification_uri_complete, {
48391
- wait: false
48392
- });
48398
+ Promise.resolve().then(() => (init_open(), exports_open)).then(({ default: open2 }) => open2(deviceData.verification_uri_complete, { wait: false })).then((subprocess) => {
48393
48399
  subprocess.on("error", () => {});
48394
- } catch (_openErr) {}
48400
+ }).catch(() => {});
48395
48401
  const deviceId = settingsManager.getOrCreateDeviceId();
48396
48402
  const deviceName = hostname3();
48397
48403
  pollForToken(deviceData.device_code, deviceData.interval, deviceData.expires_in, deviceId, deviceName).then((tokens) => {
@@ -48485,7 +48491,7 @@ function SetupUI({ onComplete }) {
48485
48491
  /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
48486
48492
  dimColor: true,
48487
48493
  children: [
48488
- "URL: ",
48494
+ "If browser didn't open, visit: ",
48489
48495
  verificationUri
48490
48496
  ]
48491
48497
  }, undefined, true, undefined, this),
@@ -52358,9 +52364,6 @@ class Diff {
52358
52364
  }
52359
52365
 
52360
52366
  // node_modules/diff/libesm/diff/character.js
52361
- function diffChars(oldStr, newStr, options) {
52362
- return characterDiff.diff(oldStr, newStr, options);
52363
- }
52364
52367
  var CharacterDiff, characterDiff;
52365
52368
  var init_character = __esm(() => {
52366
52369
  CharacterDiff = class CharacterDiff extends Diff {
@@ -53027,11 +53030,429 @@ function computeAdvancedDiff(input, opts) {
53027
53030
  }));
53028
53031
  return { mode: "advanced", fileName, oldStr, newStr, hunks };
53029
53032
  }
53033
+ function parsePatchToAdvancedDiff(patchLines, filePath) {
53034
+ const fileName = basename2(filePath);
53035
+ const hunks = [];
53036
+ let currentHunk = null;
53037
+ let oldLine = 1;
53038
+ let newLine = 1;
53039
+ for (const line of patchLines) {
53040
+ if (line.startsWith("@@")) {
53041
+ if (currentHunk && currentHunk.lines.length > 0) {
53042
+ hunks.push(currentHunk);
53043
+ }
53044
+ const match3 = line.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
53045
+ currentHunk = {
53046
+ oldStart: match3?.[1] ? parseInt(match3[1], 10) : oldLine,
53047
+ newStart: match3?.[2] ? parseInt(match3[2], 10) : newLine,
53048
+ lines: []
53049
+ };
53050
+ continue;
53051
+ }
53052
+ if (!currentHunk) {
53053
+ currentHunk = { oldStart: 1, newStart: 1, lines: [] };
53054
+ }
53055
+ if (line.length === 0) {
53056
+ currentHunk.lines.push({ raw: " " });
53057
+ oldLine++;
53058
+ newLine++;
53059
+ } else {
53060
+ const prefix = line[0];
53061
+ if (prefix === " " || prefix === "-" || prefix === "+") {
53062
+ currentHunk.lines.push({ raw: line });
53063
+ if (prefix === " " || prefix === "-")
53064
+ oldLine++;
53065
+ if (prefix === " " || prefix === "+")
53066
+ newLine++;
53067
+ }
53068
+ }
53069
+ }
53070
+ if (currentHunk && currentHunk.lines.length > 0) {
53071
+ hunks.push(currentHunk);
53072
+ }
53073
+ if (hunks.length === 0)
53074
+ return null;
53075
+ return {
53076
+ mode: "advanced",
53077
+ fileName,
53078
+ oldStr: "",
53079
+ newStr: "",
53080
+ hunks
53081
+ };
53082
+ }
53030
53083
  var ADV_DIFF_CONTEXT_LINES = 1, ADV_DIFF_IGNORE_WHITESPACE = true;
53031
53084
  var init_diff2 = __esm(() => {
53032
53085
  init_libesm();
53033
53086
  });
53034
53087
 
53088
+ // src/cli/helpers/toolNameMapping.ts
53089
+ function getDisplayToolName(rawName) {
53090
+ if (rawName === "write")
53091
+ return "Write";
53092
+ if (rawName === "edit" || rawName === "multi_edit")
53093
+ return "Update";
53094
+ if (rawName === "read")
53095
+ return "Read";
53096
+ if (rawName === "bash")
53097
+ return "Bash";
53098
+ if (rawName === "grep")
53099
+ return "Grep";
53100
+ if (rawName === "glob")
53101
+ return "Glob";
53102
+ if (rawName === "ls")
53103
+ return "LS";
53104
+ if (rawName === "todo_write" || rawName === "TodoWrite")
53105
+ return "TODO";
53106
+ if (rawName === "EnterPlanMode" || rawName === "ExitPlanMode")
53107
+ return "Planning";
53108
+ if (rawName === "AskUserQuestion")
53109
+ return "Question";
53110
+ if (rawName === "update_plan")
53111
+ return "Planning";
53112
+ if (rawName === "shell_command" || rawName === "shell")
53113
+ return "Bash";
53114
+ if (rawName === "read_file")
53115
+ return "Read";
53116
+ if (rawName === "list_dir")
53117
+ return "LS";
53118
+ if (rawName === "grep_files")
53119
+ return "Grep";
53120
+ if (rawName === "apply_patch")
53121
+ return "Patch";
53122
+ if (rawName === "UpdatePlan")
53123
+ return "Planning";
53124
+ if (rawName === "ShellCommand" || rawName === "Shell")
53125
+ return "Bash";
53126
+ if (rawName === "ReadFile")
53127
+ return "Read";
53128
+ if (rawName === "ListDir")
53129
+ return "LS";
53130
+ if (rawName === "GrepFiles")
53131
+ return "Grep";
53132
+ if (rawName === "ApplyPatch")
53133
+ return "Patch";
53134
+ if (rawName === "run_shell_command")
53135
+ return "Bash";
53136
+ if (rawName === "read_file_gemini")
53137
+ return "Read";
53138
+ if (rawName === "list_directory")
53139
+ return "LS";
53140
+ if (rawName === "glob_gemini")
53141
+ return "Glob";
53142
+ if (rawName === "search_file_content")
53143
+ return "Grep";
53144
+ if (rawName === "write_file_gemini")
53145
+ return "Write";
53146
+ if (rawName === "write_todos")
53147
+ return "TODO";
53148
+ if (rawName === "read_many_files")
53149
+ return "Read Multiple";
53150
+ if (rawName === "RunShellCommand")
53151
+ return "Bash";
53152
+ if (rawName === "ReadFileGemini")
53153
+ return "Read";
53154
+ if (rawName === "ListDirectory")
53155
+ return "LS";
53156
+ if (rawName === "GlobGemini")
53157
+ return "Glob";
53158
+ if (rawName === "SearchFileContent")
53159
+ return "Grep";
53160
+ if (rawName === "WriteFileGemini")
53161
+ return "Write";
53162
+ if (rawName === "WriteTodos")
53163
+ return "TODO";
53164
+ if (rawName === "ReadManyFiles")
53165
+ return "Read Multiple";
53166
+ if (rawName === "Replace" || rawName === "replace")
53167
+ return "Update";
53168
+ if (rawName === "WriteFile" || rawName === "write_file")
53169
+ return "Write";
53170
+ if (rawName === "KillBash")
53171
+ return "Kill Bash";
53172
+ if (rawName === "BashOutput")
53173
+ return "Shell Output";
53174
+ if (rawName === "MultiEdit")
53175
+ return "Update";
53176
+ return rawName;
53177
+ }
53178
+ function isTaskTool(name) {
53179
+ return name === "Task" || name === "task";
53180
+ }
53181
+ function isTodoTool(rawName, displayName) {
53182
+ return rawName === "todo_write" || rawName === "TodoWrite" || rawName === "write_todos" || rawName === "WriteTodos" || displayName === "TODO";
53183
+ }
53184
+ function isPlanTool(rawName, displayName) {
53185
+ return rawName === "update_plan" || rawName === "UpdatePlan" || displayName === "Planning";
53186
+ }
53187
+ function isFancyUITool(name) {
53188
+ return name === "AskUserQuestion" || name === "EnterPlanMode" || name === "ExitPlanMode";
53189
+ }
53190
+ function isMemoryTool(name) {
53191
+ return name === "memory" || name === "memory_apply_patch";
53192
+ }
53193
+ function isFileEditTool(name) {
53194
+ return name === "edit" || name === "Edit" || name === "multi_edit" || name === "MultiEdit" || name === "Replace" || name === "replace";
53195
+ }
53196
+ function isFileWriteTool(name) {
53197
+ return name === "write" || name === "Write" || name === "WriteFile" || name === "write_file" || name === "write_file_gemini" || name === "WriteFileGemini";
53198
+ }
53199
+ function isFileReadTool(name) {
53200
+ return name === "read" || name === "Read" || name === "ReadFile" || name === "read_file" || name === "read_file_gemini" || name === "ReadFileGemini" || name === "read_many_files" || name === "ReadManyFiles";
53201
+ }
53202
+ function isPatchTool(name) {
53203
+ return name === "apply_patch" || name === "ApplyPatch";
53204
+ }
53205
+ function isShellTool(name) {
53206
+ return name === "bash" || name === "Bash" || name === "shell" || name === "Shell" || name === "shell_command" || name === "ShellCommand" || name === "run_shell_command" || name === "RunShellCommand";
53207
+ }
53208
+
53209
+ // src/cli/helpers/formatArgsDisplay.ts
53210
+ import { relative as relative2 } from "node:path";
53211
+ function formatDisplayPath(filePath) {
53212
+ const cwd2 = process.cwd();
53213
+ const relativePath = relative2(cwd2, filePath);
53214
+ if (relativePath.startsWith("..")) {
53215
+ return filePath;
53216
+ }
53217
+ return relativePath;
53218
+ }
53219
+ function parsePatchInput(input) {
53220
+ if (!input)
53221
+ return null;
53222
+ const addMatch = /\*\*\* Add File:\s*(.+)/.exec(input);
53223
+ if (addMatch?.[1]) {
53224
+ return { kind: "add", path: addMatch[1].trim() };
53225
+ }
53226
+ const updateMatch = /\*\*\* Update File:\s*(.+)/.exec(input);
53227
+ if (updateMatch?.[1]) {
53228
+ return { kind: "update", path: updateMatch[1].trim() };
53229
+ }
53230
+ const deleteMatch = /\*\*\* Delete File:\s*(.+)/.exec(input);
53231
+ if (deleteMatch?.[1]) {
53232
+ return { kind: "delete", path: deleteMatch[1].trim() };
53233
+ }
53234
+ return null;
53235
+ }
53236
+ function parsePatchOperations(input) {
53237
+ if (!input)
53238
+ return [];
53239
+ const lines = input.split(/\r?\n/);
53240
+ const beginIdx = lines.findIndex((l) => l.trim() === "*** Begin Patch");
53241
+ const endIdx = lines.findIndex((l) => l.trim() === "*** End Patch");
53242
+ const startIdx = beginIdx === -1 ? 0 : beginIdx + 1;
53243
+ const stopIdx = endIdx === -1 ? lines.length : endIdx;
53244
+ const operations = [];
53245
+ let i = startIdx;
53246
+ while (i < stopIdx) {
53247
+ const line = lines[i]?.trim();
53248
+ if (!line) {
53249
+ i++;
53250
+ continue;
53251
+ }
53252
+ if (line.startsWith("*** Add File:")) {
53253
+ const path17 = line.replace("*** Add File:", "").trim();
53254
+ i++;
53255
+ const contentLines = [];
53256
+ const patchLines = [];
53257
+ while (i < stopIdx) {
53258
+ const raw = lines[i];
53259
+ if (raw === undefined || raw.startsWith("*** "))
53260
+ break;
53261
+ patchLines.push(raw);
53262
+ if (raw.startsWith("+")) {
53263
+ contentLines.push(raw.slice(1));
53264
+ }
53265
+ i++;
53266
+ }
53267
+ operations.push({
53268
+ kind: "add",
53269
+ path: path17,
53270
+ content: contentLines.join(`
53271
+ `),
53272
+ patchLines
53273
+ });
53274
+ continue;
53275
+ }
53276
+ if (line.startsWith("*** Update File:")) {
53277
+ const path17 = line.replace("*** Update File:", "").trim();
53278
+ i++;
53279
+ if (i < stopIdx && lines[i]?.startsWith("*** Move to:")) {
53280
+ i++;
53281
+ }
53282
+ const oldParts = [];
53283
+ const newParts = [];
53284
+ const patchLines = [];
53285
+ while (i < stopIdx) {
53286
+ const hLine = lines[i];
53287
+ if (hLine === undefined || hLine.startsWith("*** "))
53288
+ break;
53289
+ patchLines.push(hLine);
53290
+ if (hLine.startsWith("@@")) {
53291
+ i++;
53292
+ continue;
53293
+ }
53294
+ if (hLine === "") {
53295
+ oldParts.push("");
53296
+ newParts.push("");
53297
+ } else {
53298
+ const prefix = hLine[0];
53299
+ const text = hLine.slice(1);
53300
+ if (prefix === " ") {
53301
+ oldParts.push(text);
53302
+ newParts.push(text);
53303
+ } else if (prefix === "-") {
53304
+ oldParts.push(text);
53305
+ } else if (prefix === "+") {
53306
+ newParts.push(text);
53307
+ }
53308
+ }
53309
+ i++;
53310
+ }
53311
+ operations.push({
53312
+ kind: "update",
53313
+ path: path17,
53314
+ oldString: oldParts.join(`
53315
+ `),
53316
+ newString: newParts.join(`
53317
+ `),
53318
+ patchLines
53319
+ });
53320
+ continue;
53321
+ }
53322
+ if (line.startsWith("*** Delete File:")) {
53323
+ const path17 = line.replace("*** Delete File:", "").trim();
53324
+ operations.push({ kind: "delete", path: path17 });
53325
+ i++;
53326
+ continue;
53327
+ }
53328
+ i++;
53329
+ }
53330
+ return operations;
53331
+ }
53332
+ function formatArgsDisplay(argsJson, toolName) {
53333
+ let parsed = {};
53334
+ let display = "…";
53335
+ try {
53336
+ if (argsJson?.trim()) {
53337
+ const p = JSON.parse(argsJson);
53338
+ if (isRecord4(p)) {
53339
+ const clone = { ...p };
53340
+ if ("request_heartbeat" in clone)
53341
+ delete clone.request_heartbeat;
53342
+ parsed = clone;
53343
+ if (toolName) {
53344
+ if (isPatchTool(toolName) && typeof parsed.input === "string") {
53345
+ const patchInfo = parsePatchInput(parsed.input);
53346
+ if (patchInfo) {
53347
+ display = formatDisplayPath(patchInfo.path);
53348
+ return { display, parsed };
53349
+ }
53350
+ display = "…";
53351
+ return { display, parsed };
53352
+ }
53353
+ if (isFileEditTool(toolName) && parsed.file_path) {
53354
+ const filePath = String(parsed.file_path);
53355
+ display = formatDisplayPath(filePath);
53356
+ return { display, parsed };
53357
+ }
53358
+ if (isFileWriteTool(toolName) && parsed.file_path) {
53359
+ const filePath = String(parsed.file_path);
53360
+ display = formatDisplayPath(filePath);
53361
+ return { display, parsed };
53362
+ }
53363
+ if (isFileReadTool(toolName) && parsed.file_path) {
53364
+ const filePath = String(parsed.file_path);
53365
+ const relativePath = formatDisplayPath(filePath);
53366
+ const otherArgs = [];
53367
+ for (const [k, v] of Object.entries(parsed)) {
53368
+ if (k === "file_path")
53369
+ continue;
53370
+ if (v === undefined || v === null)
53371
+ continue;
53372
+ if (typeof v === "boolean" || typeof v === "number") {
53373
+ otherArgs.push(`${k}=${v}`);
53374
+ } else if (typeof v === "string" && v.length <= 30) {
53375
+ otherArgs.push(`${k}="${v}"`);
53376
+ }
53377
+ }
53378
+ if (otherArgs.length > 0) {
53379
+ display = `${relativePath}, ${otherArgs.join(", ")}`;
53380
+ } else {
53381
+ display = relativePath;
53382
+ }
53383
+ return { display, parsed };
53384
+ }
53385
+ if (isShellTool(toolName) && parsed.command) {
53386
+ if (Array.isArray(parsed.command)) {
53387
+ const cmd = parsed.command;
53388
+ if (cmd.length >= 3 && (cmd[0] === "bash" || cmd[0] === "sh") && (cmd[1] === "-c" || cmd[1] === "-lc")) {
53389
+ display = cmd.slice(2).join(" ");
53390
+ } else {
53391
+ display = cmd.join(" ");
53392
+ }
53393
+ } else {
53394
+ display = String(parsed.command);
53395
+ }
53396
+ return { display, parsed };
53397
+ }
53398
+ }
53399
+ const keys = Object.keys(parsed);
53400
+ const firstKey = keys[0];
53401
+ if (keys.length === 1 && firstKey && [
53402
+ "query",
53403
+ "path",
53404
+ "file_path",
53405
+ "target_file",
53406
+ "target_directory",
53407
+ "command",
53408
+ "label",
53409
+ "pattern"
53410
+ ].includes(firstKey)) {
53411
+ const v = parsed[firstKey];
53412
+ display = typeof v === "string" ? v : String(v);
53413
+ } else {
53414
+ display = Object.entries(parsed).map(([k, v]) => {
53415
+ if (v === undefined || v === null)
53416
+ return `${k}=${v}`;
53417
+ if (typeof v === "boolean" || typeof v === "number")
53418
+ return `${k}=${v}`;
53419
+ if (typeof v === "string")
53420
+ return v.length > 50 ? `${k}=…` : `${k}="${v}"`;
53421
+ if (Array.isArray(v))
53422
+ return `${k}=[${v.length} items]`;
53423
+ if (typeof v === "object")
53424
+ return `${k}={${Object.keys(v).length} props}`;
53425
+ const str = JSON.stringify(v);
53426
+ return str.length > 50 ? `${k}=…` : `${k}=${str}`;
53427
+ }).join(", ");
53428
+ }
53429
+ }
53430
+ }
53431
+ } catch {
53432
+ try {
53433
+ const s = argsJson || "";
53434
+ const fp = /"file_path"\s*:\s*"([^"]+)"/.exec(s);
53435
+ const old = /"old_string"\s*:\s*"([\s\S]*?)"\s*(,|\})/.exec(s);
53436
+ const neu = /"new_string"\s*:\s*"([\s\S]*?)"\s*(,|\})/.exec(s);
53437
+ const cont = /"content"\s*:\s*"([\s\S]*?)"\s*(,|\})/.exec(s);
53438
+ const parts = [];
53439
+ if (fp)
53440
+ parts.push(`file_path="${fp[1]}"`);
53441
+ if (old)
53442
+ parts.push(`old_string=…`);
53443
+ if (neu)
53444
+ parts.push(`new_string=…`);
53445
+ if (cont)
53446
+ parts.push(`content=…`);
53447
+ if (parts.length)
53448
+ display = parts.join(", ");
53449
+ } catch {}
53450
+ }
53451
+ return { display, parsed };
53452
+ }
53453
+ var isRecord4 = (v) => typeof v === "object" && v !== null;
53454
+ var init_formatArgsDisplay = () => {};
53455
+
53035
53456
  // src/cli/helpers/pasteRegistry.ts
53036
53457
  function allocatePaste(content) {
53037
53458
  const id = nextId++;
@@ -53151,12 +53572,12 @@ var init_pasteRegistry = __esm(() => {
53151
53572
  });
53152
53573
 
53153
53574
  // src/cli/components/DiffRenderer.tsx
53154
- import { relative as relative2 } from "node:path";
53155
- function formatRelativePath(filePath) {
53575
+ import { relative as relative3 } from "node:path";
53576
+ function formatDisplayPath2(filePath) {
53156
53577
  const cwd2 = process.cwd();
53157
- const relativePath = relative2(cwd2, filePath);
53158
- if (!relativePath.startsWith("..")) {
53159
- return `./${relativePath}`;
53578
+ const relativePath = relative3(cwd2, filePath);
53579
+ if (relativePath.startsWith("..")) {
53580
+ return filePath;
53160
53581
  }
53161
53582
  return relativePath;
53162
53583
  }
@@ -53170,84 +53591,158 @@ function DiffLine({
53170
53591
  lineNumber,
53171
53592
  type,
53172
53593
  content,
53173
- compareContent
53594
+ compareContent,
53595
+ columns,
53596
+ showLineNumbers = true
53174
53597
  }) {
53175
53598
  const prefix = type === "add" ? "+" : "-";
53176
53599
  const lineBg = type === "add" ? colors.diff.addedLineBg : colors.diff.removedLineBg;
53177
53600
  const wordBg = type === "add" ? colors.diff.addedWordBg : colors.diff.removedWordBg;
53601
+ const gutterWidth = 4;
53602
+ const contentWidth = Math.max(0, columns - gutterWidth);
53603
+ const linePrefix = showLineNumbers ? `${lineNumber} ${prefix} ` : `${prefix} `;
53178
53604
  if (compareContent !== undefined && content.trim() && compareContent.trim()) {
53179
53605
  const wordDiffs = type === "add" ? diffWords(compareContent, content) : diffWords(content, compareContent);
53180
53606
  return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53607
+ flexDirection: "row",
53181
53608
  children: [
53182
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53183
- children: " "
53184
- }, undefined, false, undefined, this),
53185
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53186
- backgroundColor: lineBg,
53187
- color: colors.diff.textOnDark,
53188
- children: `${lineNumber} ${prefix} `
53609
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53610
+ width: gutterWidth,
53611
+ flexShrink: 0,
53612
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53613
+ children: " "
53614
+ }, undefined, false, undefined, this)
53189
53615
  }, undefined, false, undefined, this),
53190
- wordDiffs.map((part, i) => {
53191
- if (part.added && type === "add") {
53192
- return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53193
- backgroundColor: wordBg,
53194
- color: colors.diff.textOnHighlight,
53195
- children: part.value
53196
- }, `word-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
53197
- } else if (part.removed && type === "remove") {
53198
- return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53199
- backgroundColor: wordBg,
53200
- color: colors.diff.textOnHighlight,
53201
- children: part.value
53202
- }, `word-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
53203
- } else if (!part.added && !part.removed) {
53204
- return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53205
- backgroundColor: lineBg,
53206
- color: colors.diff.textOnDark,
53207
- children: part.value
53208
- }, `word-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
53209
- }
53210
- return null;
53211
- })
53616
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53617
+ flexGrow: 1,
53618
+ width: contentWidth,
53619
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53620
+ wrap: "wrap",
53621
+ children: [
53622
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53623
+ backgroundColor: lineBg,
53624
+ color: colors.diff.textOnDark,
53625
+ children: linePrefix
53626
+ }, undefined, false, undefined, this),
53627
+ wordDiffs.map((part, i) => {
53628
+ if (part.added && type === "add") {
53629
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53630
+ backgroundColor: wordBg,
53631
+ color: colors.diff.textOnHighlight,
53632
+ children: part.value
53633
+ }, `word-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
53634
+ } else if (part.removed && type === "remove") {
53635
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53636
+ backgroundColor: wordBg,
53637
+ color: colors.diff.textOnHighlight,
53638
+ children: part.value
53639
+ }, `word-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
53640
+ } else if (!part.added && !part.removed) {
53641
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53642
+ backgroundColor: lineBg,
53643
+ color: colors.diff.textOnDark,
53644
+ children: part.value
53645
+ }, `word-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
53646
+ }
53647
+ return null;
53648
+ })
53649
+ ]
53650
+ }, undefined, true, undefined, this)
53651
+ }, undefined, false, undefined, this)
53212
53652
  ]
53213
53653
  }, undefined, true, undefined, this);
53214
53654
  }
53215
53655
  return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53656
+ flexDirection: "row",
53216
53657
  children: [
53217
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53218
- children: " "
53658
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53659
+ width: gutterWidth,
53660
+ flexShrink: 0,
53661
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53662
+ children: " "
53663
+ }, undefined, false, undefined, this)
53219
53664
  }, undefined, false, undefined, this),
53220
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53221
- backgroundColor: lineBg,
53222
- color: colors.diff.textOnDark,
53223
- children: `${lineNumber} ${prefix} ${content}`
53665
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53666
+ flexGrow: 1,
53667
+ width: contentWidth,
53668
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53669
+ backgroundColor: lineBg,
53670
+ color: colors.diff.textOnDark,
53671
+ wrap: "wrap",
53672
+ children: `${linePrefix}${content}`
53673
+ }, undefined, false, undefined, this)
53224
53674
  }, undefined, false, undefined, this)
53225
53675
  ]
53226
53676
  }, undefined, true, undefined, this);
53227
53677
  }
53228
53678
  function WriteRenderer({ filePath, content }) {
53229
- const relativePath = formatRelativePath(filePath);
53679
+ const columns = useTerminalWidth();
53680
+ const relativePath = formatDisplayPath2(filePath);
53230
53681
  const lines = content.split(`
53231
53682
  `);
53232
53683
  const lineCount = lines.length;
53684
+ const gutterWidth = 4;
53685
+ const contentWidth = Math.max(0, columns - gutterWidth);
53233
53686
  return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53234
53687
  flexDirection: "column",
53235
53688
  children: [
53236
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53689
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53690
+ flexDirection: "row",
53237
53691
  children: [
53238
- " ",
53239
- "⎿ Wrote ",
53240
- lineCount,
53241
- " line",
53242
- lineCount !== 1 ? "s" : "",
53243
- " to ",
53244
- relativePath
53692
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53693
+ width: gutterWidth,
53694
+ flexShrink: 0,
53695
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53696
+ children: [
53697
+ " ",
53698
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53699
+ dimColor: true,
53700
+ children: "⎿"
53701
+ }, undefined, false, undefined, this)
53702
+ ]
53703
+ }, undefined, true, undefined, this)
53704
+ }, undefined, false, undefined, this),
53705
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53706
+ flexGrow: 1,
53707
+ width: contentWidth,
53708
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53709
+ wrap: "wrap",
53710
+ children: [
53711
+ "Wrote ",
53712
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53713
+ bold: true,
53714
+ children: lineCount
53715
+ }, undefined, false, undefined, this),
53716
+ " line",
53717
+ lineCount !== 1 ? "s" : "",
53718
+ " to ",
53719
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53720
+ bold: true,
53721
+ children: relativePath
53722
+ }, undefined, false, undefined, this)
53723
+ ]
53724
+ }, undefined, true, undefined, this)
53725
+ }, undefined, false, undefined, this)
53245
53726
  ]
53246
53727
  }, undefined, true, undefined, this),
53247
- lines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53728
+ lines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53729
+ flexDirection: "row",
53248
53730
  children: [
53249
- " ",
53250
- line
53731
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53732
+ width: gutterWidth,
53733
+ flexShrink: 0,
53734
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53735
+ children: " "
53736
+ }, undefined, false, undefined, this)
53737
+ }, undefined, false, undefined, this),
53738
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53739
+ flexGrow: 1,
53740
+ width: contentWidth,
53741
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53742
+ wrap: "wrap",
53743
+ children: line
53744
+ }, undefined, false, undefined, this)
53745
+ }, undefined, false, undefined, this)
53251
53746
  ]
53252
53747
  }, `line-${i}-${line.substring(0, 20)}`, true, undefined, this))
53253
53748
  ]
@@ -53256,9 +53751,11 @@ function WriteRenderer({ filePath, content }) {
53256
53751
  function EditRenderer({
53257
53752
  filePath,
53258
53753
  oldString,
53259
- newString
53754
+ newString,
53755
+ showLineNumbers = true
53260
53756
  }) {
53261
- const relativePath = formatRelativePath(filePath);
53757
+ const columns = useTerminalWidth();
53758
+ const relativePath = formatDisplayPath2(filePath);
53262
53759
  const oldLines = oldString.split(`
53263
53760
  `);
53264
53761
  const newLines = newString.split(`
@@ -53266,63 +53763,142 @@ function EditRenderer({
53266
53763
  const additions = newLines.length;
53267
53764
  const removals = oldLines.length;
53268
53765
  const singleLineEdit = oldLines.length === 1 && newLines.length === 1;
53766
+ const gutterWidth = 4;
53767
+ const contentWidth = Math.max(0, columns - gutterWidth);
53269
53768
  return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53270
53769
  flexDirection: "column",
53271
53770
  children: [
53272
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53771
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53772
+ flexDirection: "row",
53273
53773
  children: [
53274
- " ",
53275
- "⎿ Updated ",
53276
- relativePath,
53277
- " with ",
53278
- additions,
53279
- " addition",
53280
- additions !== 1 ? "s" : "",
53281
- " and ",
53282
- removals,
53283
- " removal",
53284
- removals !== 1 ? "s" : ""
53774
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53775
+ width: gutterWidth,
53776
+ flexShrink: 0,
53777
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53778
+ children: [
53779
+ " ",
53780
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53781
+ dimColor: true,
53782
+ children: "⎿"
53783
+ }, undefined, false, undefined, this)
53784
+ ]
53785
+ }, undefined, true, undefined, this)
53786
+ }, undefined, false, undefined, this),
53787
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53788
+ flexGrow: 1,
53789
+ width: contentWidth,
53790
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53791
+ wrap: "wrap",
53792
+ children: [
53793
+ "Updated ",
53794
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53795
+ bold: true,
53796
+ children: relativePath
53797
+ }, undefined, false, undefined, this),
53798
+ " with",
53799
+ " ",
53800
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53801
+ bold: true,
53802
+ children: additions
53803
+ }, undefined, false, undefined, this),
53804
+ " addition",
53805
+ additions !== 1 ? "s" : "",
53806
+ " and ",
53807
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53808
+ bold: true,
53809
+ children: removals
53810
+ }, undefined, false, undefined, this),
53811
+ " ",
53812
+ "removal",
53813
+ removals !== 1 ? "s" : ""
53814
+ ]
53815
+ }, undefined, true, undefined, this)
53816
+ }, undefined, false, undefined, this)
53285
53817
  ]
53286
53818
  }, undefined, true, undefined, this),
53287
53819
  oldLines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(DiffLine, {
53288
53820
  lineNumber: i + 1,
53289
53821
  type: "remove",
53290
53822
  content: line,
53291
- compareContent: singleLineEdit ? newLines[0] : undefined
53823
+ compareContent: singleLineEdit ? newLines[0] : undefined,
53824
+ columns,
53825
+ showLineNumbers
53292
53826
  }, `old-${i}-${line.substring(0, 20)}`, false, undefined, this)),
53293
53827
  newLines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(DiffLine, {
53294
53828
  lineNumber: i + 1,
53295
53829
  type: "add",
53296
53830
  content: line,
53297
- compareContent: singleLineEdit ? oldLines[0] : undefined
53831
+ compareContent: singleLineEdit ? oldLines[0] : undefined,
53832
+ columns,
53833
+ showLineNumbers
53298
53834
  }, `new-${i}-${line.substring(0, 20)}`, false, undefined, this))
53299
53835
  ]
53300
53836
  }, undefined, true, undefined, this);
53301
53837
  }
53302
- function MultiEditRenderer({ filePath, edits }) {
53303
- const relativePath = formatRelativePath(filePath);
53838
+ function MultiEditRenderer({
53839
+ filePath,
53840
+ edits,
53841
+ showLineNumbers = true
53842
+ }) {
53843
+ const columns = useTerminalWidth();
53844
+ const relativePath = formatDisplayPath2(filePath);
53304
53845
  let totalAdditions = 0;
53305
53846
  let totalRemovals = 0;
53306
53847
  edits.forEach((edit2) => {
53307
53848
  totalAdditions += countLines(edit2.new_string);
53308
53849
  totalRemovals += countLines(edit2.old_string);
53309
53850
  });
53851
+ const gutterWidth = 4;
53852
+ const contentWidth = Math.max(0, columns - gutterWidth);
53310
53853
  return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53311
53854
  flexDirection: "column",
53312
53855
  children: [
53313
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53856
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53857
+ flexDirection: "row",
53314
53858
  children: [
53315
- " ",
53316
- "⎿ Updated ",
53317
- relativePath,
53318
- " with ",
53319
- totalAdditions,
53320
- " addition",
53321
- totalAdditions !== 1 ? "s" : "",
53322
- " and ",
53323
- totalRemovals,
53324
- " removal",
53325
- totalRemovals !== 1 ? "s" : ""
53859
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53860
+ width: gutterWidth,
53861
+ flexShrink: 0,
53862
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53863
+ children: [
53864
+ " ",
53865
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53866
+ dimColor: true,
53867
+ children: "⎿"
53868
+ }, undefined, false, undefined, this)
53869
+ ]
53870
+ }, undefined, true, undefined, this)
53871
+ }, undefined, false, undefined, this),
53872
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
53873
+ flexGrow: 1,
53874
+ width: contentWidth,
53875
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53876
+ wrap: "wrap",
53877
+ children: [
53878
+ "Updated ",
53879
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53880
+ bold: true,
53881
+ children: relativePath
53882
+ }, undefined, false, undefined, this),
53883
+ " with",
53884
+ " ",
53885
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53886
+ bold: true,
53887
+ children: totalAdditions
53888
+ }, undefined, false, undefined, this),
53889
+ " addition",
53890
+ totalAdditions !== 1 ? "s" : "",
53891
+ " and",
53892
+ " ",
53893
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
53894
+ bold: true,
53895
+ children: totalRemovals
53896
+ }, undefined, false, undefined, this),
53897
+ " removal",
53898
+ totalRemovals !== 1 ? "s" : ""
53899
+ ]
53900
+ }, undefined, true, undefined, this)
53901
+ }, undefined, false, undefined, this)
53326
53902
  ]
53327
53903
  }, undefined, true, undefined, this),
53328
53904
  edits.map((edit2, index) => {
@@ -53338,13 +53914,17 @@ function MultiEditRenderer({ filePath, edits }) {
53338
53914
  lineNumber: i + 1,
53339
53915
  type: "remove",
53340
53916
  content: line,
53341
- compareContent: singleLineEdit && i === 0 ? newLines[0] : undefined
53917
+ compareContent: singleLineEdit && i === 0 ? newLines[0] : undefined,
53918
+ columns,
53919
+ showLineNumbers
53342
53920
  }, `old-${index}-${i}-${line.substring(0, 20)}`, false, undefined, this)),
53343
53921
  newLines.map((line, i) => /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(DiffLine, {
53344
53922
  lineNumber: i + 1,
53345
53923
  type: "add",
53346
53924
  content: line,
53347
- compareContent: singleLineEdit && i === 0 ? oldLines[0] : undefined
53925
+ compareContent: singleLineEdit && i === 0 ? oldLines[0] : undefined,
53926
+ columns,
53927
+ showLineNumbers
53348
53928
  }, `new-${index}-${i}-${line.substring(0, 20)}`, false, undefined, this))
53349
53929
  ]
53350
53930
  }, `edit-${index}-${edit2.old_string.substring(0, 20)}-${edit2.new_string.substring(0, 20)}`, true, undefined, this);
@@ -53355,62 +53935,77 @@ function MultiEditRenderer({ filePath, edits }) {
53355
53935
  var jsx_dev_runtime5;
53356
53936
  var init_DiffRenderer = __esm(async () => {
53357
53937
  init_libesm();
53938
+ init_useTerminalWidth();
53358
53939
  init_colors();
53359
53940
  await init_build2();
53360
53941
  jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
53361
53942
  });
53362
53943
 
53363
53944
  // src/cli/components/AdvancedDiffRenderer.tsx
53364
- import { relative as relative3 } from "node:path";
53365
- function formatRelativePath2(filePath) {
53945
+ import { relative as relative4 } from "node:path";
53946
+ function formatRelativePath(filePath) {
53366
53947
  const cwd2 = process.cwd();
53367
- const relativePath = relative3(cwd2, filePath);
53948
+ const relativePath = relative4(cwd2, filePath);
53368
53949
  return relativePath.startsWith("..") ? relativePath : `./${relativePath}`;
53369
53950
  }
53370
53951
  function padLeft(n, width) {
53371
53952
  const s = String(n);
53372
53953
  return s.length >= width ? s : " ".repeat(width - s.length) + s;
53373
53954
  }
53955
+ function wordSimilarity(a, b) {
53956
+ const wordsA = new Set(a.toLowerCase().split(/\s+/).filter(Boolean));
53957
+ const wordsB = new Set(b.toLowerCase().split(/\s+/).filter(Boolean));
53958
+ if (wordsA.size === 0 && wordsB.size === 0)
53959
+ return 1;
53960
+ if (wordsA.size === 0 || wordsB.size === 0)
53961
+ return 0;
53962
+ const intersection = [...wordsA].filter((w) => wordsB.has(w)).length;
53963
+ const union = new Set([...wordsA, ...wordsB]).size;
53964
+ return intersection / union;
53965
+ }
53374
53966
  function Line({
53375
53967
  kind,
53376
53968
  displayNo,
53377
53969
  text,
53378
53970
  pairText,
53379
53971
  gutterWidth,
53380
- contentWidth,
53972
+ columns,
53381
53973
  enableWord
53382
53974
  }) {
53383
53975
  const symbol = kind === "add" ? "+" : kind === "remove" ? "-" : " ";
53384
53976
  const symbolColor = kind === "add" ? colors.diff.symbolAdd : kind === "remove" ? colors.diff.symbolRemove : colors.diff.symbolContext;
53385
53977
  const bgLine = kind === "add" ? colors.diff.addedLineBg : kind === "remove" ? colors.diff.removedLineBg : colors.diff.contextLineBg;
53386
53978
  const bgWord = kind === "add" ? colors.diff.addedWordBg : kind === "remove" ? colors.diff.removedWordBg : undefined;
53387
- const charParts = enableWord && pairText && (kind === "add" || kind === "remove") && pairText !== text ? kind === "add" ? diffChars(pairText, text) : diffChars(text, pairText) : null;
53388
- const textWidth = Math.max(0, contentWidth - gutterWidth - 2);
53979
+ const similarity = enableWord && pairText ? wordSimilarity(text, pairText) : 0;
53980
+ const charParts = enableWord && pairText && (kind === "add" || kind === "remove") && pairText !== text && similarity >= WORD_SIMILARITY_THRESHOLD ? kind === "add" ? diffWordsWithSpace(pairText, text) : diffWordsWithSpace(text, pairText) : null;
53981
+ const linePrefix = `${padLeft(displayNo, gutterWidth)} ${symbol} `;
53982
+ const prefixWidth = linePrefix.length;
53983
+ const contentWidth = Math.max(0, columns - prefixWidth);
53389
53984
  return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53390
- width: contentWidth,
53985
+ flexDirection: "row",
53391
53986
  children: [
53392
53987
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53393
- width: gutterWidth,
53988
+ width: prefixWidth,
53989
+ flexShrink: 0,
53394
53990
  children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53395
- dimColor: true,
53396
- children: padLeft(displayNo, gutterWidth)
53397
- }, undefined, false, undefined, this)
53991
+ dimColor: kind === "context",
53992
+ children: [
53993
+ padLeft(displayNo, gutterWidth),
53994
+ " ",
53995
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53996
+ color: symbolColor,
53997
+ children: symbol
53998
+ }, undefined, false, undefined, this),
53999
+ " "
54000
+ ]
54001
+ }, undefined, true, undefined, this)
53398
54002
  }, undefined, false, undefined, this),
53399
54003
  /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53400
- width: 2,
53401
- children: [
53402
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53403
- color: symbolColor,
53404
- children: symbol
53405
- }, undefined, false, undefined, this),
53406
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53407
- children: " "
53408
- }, undefined, false, undefined, this)
53409
- ]
53410
- }, undefined, true, undefined, this),
53411
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53412
- width: textWidth,
54004
+ flexGrow: 1,
54005
+ width: contentWidth,
53413
54006
  children: charParts ? /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54007
+ wrap: "wrap",
54008
+ backgroundColor: bgLine,
53414
54009
  children: charParts.map((p, i) => {
53415
54010
  if (kind === "remove") {
53416
54011
  if (p.removed)
@@ -53443,11 +54038,11 @@ function Line({
53443
54038
  return null;
53444
54039
  }
53445
54040
  return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53446
- backgroundColor: bgLine,
53447
54041
  children: p.value
53448
54042
  }, `context-${i}-${p.value.substring(0, 10)}`, false, undefined, this);
53449
54043
  })
53450
54044
  }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54045
+ wrap: "wrap",
53451
54046
  backgroundColor: bgLine,
53452
54047
  color: kind === "context" ? undefined : colors.diff.textOnDark,
53453
54048
  children: text
@@ -53507,19 +54102,39 @@ function AdvancedDiffRenderer(props) {
53507
54102
  }, undefined, false, undefined, this);
53508
54103
  }
53509
54104
  if (result.mode === "unpreviewable") {
54105
+ const gutterWidth2 = 4;
53510
54106
  return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53511
- flexDirection: "column",
53512
- children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53513
- dimColor: true,
53514
- children: [
53515
- " ⎿ Cannot preview changes: ",
53516
- result.reason
53517
- ]
53518
- }, undefined, true, undefined, this)
53519
- }, undefined, false, undefined, this);
54107
+ flexDirection: "row",
54108
+ children: [
54109
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54110
+ width: gutterWidth2,
54111
+ flexShrink: 0,
54112
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54113
+ children: [
54114
+ " ",
54115
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54116
+ dimColor: true,
54117
+ children: "⎿"
54118
+ }, undefined, false, undefined, this)
54119
+ ]
54120
+ }, undefined, true, undefined, this)
54121
+ }, undefined, false, undefined, this),
54122
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54123
+ flexGrow: 1,
54124
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54125
+ wrap: "wrap",
54126
+ dimColor: true,
54127
+ children: [
54128
+ "Cannot preview changes: ",
54129
+ result.reason
54130
+ ]
54131
+ }, undefined, true, undefined, this)
54132
+ }, undefined, false, undefined, this)
54133
+ ]
54134
+ }, undefined, true, undefined, this);
53520
54135
  }
53521
54136
  const { hunks } = result;
53522
- const relative4 = formatRelativePath2(props.filePath);
54137
+ const relative5 = formatRelativePath(props.filePath);
53523
54138
  const enableWord = props.kind !== "multi_edit";
53524
54139
  const rows = [];
53525
54140
  for (const h of hunks) {
@@ -53597,36 +54212,151 @@ function AdvancedDiffRenderer(props) {
53597
54212
  }
53598
54213
  const maxDisplayNo = rows.reduce((m, r) => Math.max(m, r.displayNo), 1);
53599
54214
  const gutterWidth = String(maxDisplayNo).length;
53600
- const header = props.kind === "write" ? `Wrote changes to ${relative4}` : `Updated ${relative4}`;
53601
- const panelInnerWidth = Math.max(20, columns - 8);
54215
+ const header = props.kind === "write" ? `Wrote changes to ${relative5}` : `Updated ${relative5}`;
54216
+ if (rows.length === 0) {
54217
+ const noChangesGutter = 4;
54218
+ return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54219
+ flexDirection: "column",
54220
+ children: [
54221
+ showHeader ? /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54222
+ flexDirection: "row",
54223
+ children: [
54224
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54225
+ width: noChangesGutter,
54226
+ flexShrink: 0,
54227
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54228
+ children: [
54229
+ " ",
54230
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54231
+ dimColor: true,
54232
+ children: "⎿"
54233
+ }, undefined, false, undefined, this)
54234
+ ]
54235
+ }, undefined, true, undefined, this)
54236
+ }, undefined, false, undefined, this),
54237
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54238
+ flexGrow: 1,
54239
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54240
+ wrap: "wrap",
54241
+ children: header
54242
+ }, undefined, false, undefined, this)
54243
+ }, undefined, false, undefined, this)
54244
+ ]
54245
+ }, undefined, true, undefined, this) : null,
54246
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54247
+ flexDirection: "row",
54248
+ children: [
54249
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54250
+ width: noChangesGutter,
54251
+ flexShrink: 0,
54252
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54253
+ children: " "
54254
+ }, undefined, false, undefined, this)
54255
+ }, undefined, false, undefined, this),
54256
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54257
+ flexGrow: 1,
54258
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54259
+ dimColor: true,
54260
+ children: [
54261
+ "No changes to ",
54262
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54263
+ bold: true,
54264
+ children: relative5
54265
+ }, undefined, false, undefined, this),
54266
+ " (file content identical)"
54267
+ ]
54268
+ }, undefined, true, undefined, this)
54269
+ }, undefined, false, undefined, this)
54270
+ ]
54271
+ }, undefined, true, undefined, this)
54272
+ ]
54273
+ }, undefined, true, undefined, this);
54274
+ }
54275
+ const toolResultGutter = 4;
53602
54276
  return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
53603
54277
  flexDirection: "column",
53604
- width: panelInnerWidth,
53605
54278
  children: [
53606
54279
  showHeader ? /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(jsx_dev_runtime6.Fragment, {
53607
54280
  children: [
53608
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53609
- children: header
54281
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54282
+ flexDirection: "row",
54283
+ children: [
54284
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54285
+ width: toolResultGutter,
54286
+ flexShrink: 0,
54287
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54288
+ children: [
54289
+ " ",
54290
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54291
+ dimColor: true,
54292
+ children: "⎿"
54293
+ }, undefined, false, undefined, this)
54294
+ ]
54295
+ }, undefined, true, undefined, this)
54296
+ }, undefined, false, undefined, this),
54297
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54298
+ flexGrow: 1,
54299
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54300
+ wrap: "wrap",
54301
+ children: header
54302
+ }, undefined, false, undefined, this)
54303
+ }, undefined, false, undefined, this)
54304
+ ]
54305
+ }, undefined, true, undefined, this),
54306
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54307
+ flexDirection: "row",
54308
+ children: [
54309
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54310
+ width: toolResultGutter,
54311
+ flexShrink: 0,
54312
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54313
+ children: " "
54314
+ }, undefined, false, undefined, this)
54315
+ }, undefined, false, undefined, this),
54316
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54317
+ flexGrow: 1,
54318
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54319
+ dimColor: true,
54320
+ children: `Showing ~${ADV_DIFF_CONTEXT_LINES} context line${ADV_DIFF_CONTEXT_LINES === 1 ? "" : "s"}`
54321
+ }, undefined, false, undefined, this)
54322
+ }, undefined, false, undefined, this)
54323
+ ]
54324
+ }, undefined, true, undefined, this)
54325
+ ]
54326
+ }, undefined, true, undefined, this) : null,
54327
+ rows.map((r, idx) => showHeader ? /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54328
+ flexDirection: "row",
54329
+ children: [
54330
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
54331
+ width: toolResultGutter,
54332
+ flexShrink: 0,
54333
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
54334
+ children: " "
54335
+ }, undefined, false, undefined, this)
53610
54336
  }, undefined, false, undefined, this),
53611
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
53612
- dimColor: true,
53613
- children: `Showing ~${ADV_DIFF_CONTEXT_LINES} context line${ADV_DIFF_CONTEXT_LINES === 1 ? "" : "s"}`
54337
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Line, {
54338
+ kind: r.kind,
54339
+ displayNo: r.displayNo,
54340
+ text: r.text,
54341
+ pairText: r.pairText,
54342
+ gutterWidth,
54343
+ columns: columns - toolResultGutter,
54344
+ enableWord
53614
54345
  }, undefined, false, undefined, this)
53615
54346
  ]
53616
- }, undefined, true, undefined, this) : null,
53617
- rows.map((r, idx) => /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Line, {
54347
+ }, `row-${idx}-${r.kind}-${r.displayNo || idx}`, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Line, {
53618
54348
  kind: r.kind,
53619
54349
  displayNo: r.displayNo,
53620
54350
  text: r.text,
53621
54351
  pairText: r.pairText,
53622
54352
  gutterWidth,
53623
- contentWidth: panelInnerWidth,
54353
+ columns,
53624
54354
  enableWord
53625
54355
  }, `row-${idx}-${r.kind}-${r.displayNo || idx}`, false, undefined, this))
53626
54356
  ]
53627
54357
  }, undefined, true, undefined, this);
53628
54358
  }
53629
- var import_react27, jsx_dev_runtime6;
54359
+ var import_react27, jsx_dev_runtime6, WORD_SIMILARITY_THRESHOLD = 0.3;
53630
54360
  var init_AdvancedDiffRenderer = __esm(async () => {
53631
54361
  init_libesm();
53632
54362
  init_diff2();
@@ -54327,7 +55057,9 @@ var import_react30, jsx_dev_runtime8, OptionsRenderer, DynamicPreview = ({
54327
55057
  toolName,
54328
55058
  toolArgs,
54329
55059
  parsedArgs,
54330
- precomputedDiff
55060
+ precomputedDiff,
55061
+ allDiffs,
55062
+ toolCallId
54331
55063
  }) => {
54332
55064
  const t = toolName.toLowerCase();
54333
55065
  if (t === "bash" || t === "shell_command" || t === "shellcommand" || t === "run_shell_command" || t === "runshellcommand") {
@@ -54430,13 +55162,91 @@ var import_react30, jsx_dev_runtime8, OptionsRenderer, DynamicPreview = ({
54430
55162
  }
54431
55163
  if (t === "apply_patch" || t === "applypatch") {
54432
55164
  const inputVal = parsedArgs?.input;
54433
- const patchPreview = typeof inputVal === "string" && inputVal.length > 100 ? `${inputVal.slice(0, 100)}...` : typeof inputVal === "string" ? inputVal : "(no patch content)";
55165
+ if (typeof inputVal === "string") {
55166
+ const operations = parsePatchOperations(inputVal);
55167
+ if (operations.length > 0) {
55168
+ const { relative: relative5 } = __require("node:path");
55169
+ const cwd2 = process.cwd();
55170
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55171
+ flexDirection: "column",
55172
+ paddingLeft: 2,
55173
+ children: operations.map((op, idx) => {
55174
+ const relPath = relative5(cwd2, op.path);
55175
+ const displayPath = relPath.startsWith("..") ? op.path : relPath;
55176
+ const diffKey = toolCallId ? `${toolCallId}:${op.path}` : undefined;
55177
+ const opDiff = diffKey ? allDiffs.get(diffKey) : undefined;
55178
+ if (op.kind === "add") {
55179
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55180
+ flexDirection: "column",
55181
+ children: [
55182
+ idx > 0 && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55183
+ height: 1
55184
+ }, undefined, false, undefined, this),
55185
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
55186
+ dimColor: true,
55187
+ children: displayPath
55188
+ }, undefined, false, undefined, this),
55189
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(AdvancedDiffRenderer, {
55190
+ precomputed: opDiff,
55191
+ kind: "write",
55192
+ filePath: op.path,
55193
+ content: op.content,
55194
+ showHeader: false
55195
+ }, undefined, false, undefined, this)
55196
+ ]
55197
+ }, `patch-add-${op.path}`, true, undefined, this);
55198
+ }
55199
+ if (op.kind === "update") {
55200
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55201
+ flexDirection: "column",
55202
+ children: [
55203
+ idx > 0 && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55204
+ height: 1
55205
+ }, undefined, false, undefined, this),
55206
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
55207
+ dimColor: true,
55208
+ children: displayPath
55209
+ }, undefined, false, undefined, this),
55210
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(AdvancedDiffRenderer, {
55211
+ precomputed: opDiff,
55212
+ kind: "edit",
55213
+ filePath: op.path,
55214
+ oldString: op.oldString,
55215
+ newString: op.newString,
55216
+ showHeader: false
55217
+ }, undefined, false, undefined, this)
55218
+ ]
55219
+ }, `patch-update-${op.path}`, true, undefined, this);
55220
+ }
55221
+ if (op.kind === "delete") {
55222
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55223
+ flexDirection: "column",
55224
+ children: [
55225
+ idx > 0 && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
55226
+ height: 1
55227
+ }, undefined, false, undefined, this),
55228
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
55229
+ dimColor: true,
55230
+ children: displayPath
55231
+ }, undefined, false, undefined, this),
55232
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
55233
+ color: "red",
55234
+ children: "File will be deleted"
55235
+ }, undefined, false, undefined, this)
55236
+ ]
55237
+ }, `patch-delete-${op.path}`, true, undefined, this);
55238
+ }
55239
+ return null;
55240
+ })
55241
+ }, undefined, false, undefined, this);
55242
+ }
55243
+ }
54434
55244
  return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
54435
55245
  flexDirection: "column",
54436
55246
  paddingLeft: 2,
54437
55247
  children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
54438
55248
  dimColor: true,
54439
- children: patchPreview
55249
+ children: typeof inputVal === "string" && inputVal.length > 100 ? `${inputVal.slice(0, 100)}...` : typeof inputVal === "string" ? inputVal : "(no patch content)"
54440
55250
  }, undefined, false, undefined, this)
54441
55251
  }, undefined, false, undefined, this);
54442
55252
  }
@@ -54637,6 +55447,7 @@ var import_react30, jsx_dev_runtime8, OptionsRenderer, DynamicPreview = ({
54637
55447
  }, ApprovalDialog;
54638
55448
  var init_ApprovalDialogRich = __esm(async () => {
54639
55449
  init_diff2();
55450
+ init_formatArgsDisplay();
54640
55451
  init_pasteRegistry();
54641
55452
  init_colors();
54642
55453
  await __promiseAll([
@@ -54704,22 +55515,6 @@ var init_ApprovalDialogRich = __esm(async () => {
54704
55515
  setIsEnteringReason(false);
54705
55516
  setDenyReason("");
54706
55517
  }, [progress?.current]);
54707
- const options = import_react30.useMemo(() => {
54708
- const approvalLabel = progress && progress.total > 1 ? "Yes, approve this tool" : "Yes, just this once";
54709
- const opts = [{ label: approvalLabel, action: onApproveAll }];
54710
- if (approvalContext?.allowPersistence) {
54711
- opts.push({
54712
- label: approvalContext.approveAlwaysText,
54713
- action: () => onApproveAlways(approvalContext.defaultScope === "user" ? "session" : approvalContext.defaultScope)
54714
- });
54715
- }
54716
- const denyLabel = progress && progress.total > 1 ? "No, deny this tool (esc)" : "No, and tell Letta what to do differently (esc)";
54717
- opts.push({
54718
- label: denyLabel,
54719
- action: () => {}
54720
- });
54721
- return opts;
54722
- }, [progress, approvalContext, onApproveAll, onApproveAlways]);
54723
55518
  use_input_default((_input, key) => {
54724
55519
  if (isExecuting)
54725
55520
  return;
@@ -54804,10 +55599,134 @@ var init_ApprovalDialogRich = __esm(async () => {
54804
55599
  }
54805
55600
  return null;
54806
55601
  }, [approvalRequest, parsedArgs]);
55602
+ const allDiffs = import_react30.useMemo(() => {
55603
+ const diffs = new Map;
55604
+ const toolCallId = approvalRequest?.toolCallId;
55605
+ if (!toolCallId)
55606
+ return diffs;
55607
+ if (precomputedDiff) {
55608
+ diffs.set(toolCallId, precomputedDiff);
55609
+ return diffs;
55610
+ }
55611
+ const t = approvalRequest.toolName.toLowerCase();
55612
+ if ((t === "apply_patch" || t === "applypatch") && parsedArgs?.input) {
55613
+ const operations = parsePatchOperations(parsedArgs.input);
55614
+ for (const op of operations) {
55615
+ const key = `${toolCallId}:${op.path}`;
55616
+ if (op.kind === "add" || op.kind === "update") {
55617
+ const result = parsePatchToAdvancedDiff(op.patchLines, op.path);
55618
+ if (result) {
55619
+ diffs.set(key, result);
55620
+ }
55621
+ }
55622
+ }
55623
+ }
55624
+ return diffs;
55625
+ }, [approvalRequest, parsedArgs, precomputedDiff]);
55626
+ const options = import_react30.useMemo(() => {
55627
+ const approvalLabel = progress && progress.total > 1 ? "Yes, approve this tool" : "Yes, just this once";
55628
+ const opts = [
55629
+ {
55630
+ label: approvalLabel,
55631
+ action: () => onApproveAll(allDiffs.size > 0 ? allDiffs : undefined)
55632
+ }
55633
+ ];
55634
+ if (approvalContext?.allowPersistence) {
55635
+ opts.push({
55636
+ label: approvalContext.approveAlwaysText,
55637
+ action: () => onApproveAlways(approvalContext.defaultScope === "user" ? "session" : approvalContext.defaultScope, allDiffs.size > 0 ? allDiffs : undefined)
55638
+ });
55639
+ }
55640
+ const denyLabel = progress && progress.total > 1 ? "No, deny this tool (esc)" : "No, and tell Letta Code what to do differently (esc)";
55641
+ opts.push({
55642
+ label: denyLabel,
55643
+ action: () => {}
55644
+ });
55645
+ return opts;
55646
+ }, [progress, approvalContext, onApproveAll, onApproveAlways, allDiffs]);
55647
+ const headerLabel = import_react30.useMemo(() => {
55648
+ if (!approvalRequest)
55649
+ return "";
55650
+ const t = approvalRequest.toolName.toLowerCase();
55651
+ if (t === "apply_patch" || t === "applypatch") {
55652
+ if (parsedArgs?.input && typeof parsedArgs.input === "string") {
55653
+ const operations = parsePatchOperations(parsedArgs.input);
55654
+ if (operations.length > 0) {
55655
+ const isMulti = operations.length > 1;
55656
+ const firstOp = operations[0];
55657
+ if (firstOp?.kind === "add")
55658
+ return isMulti ? "Write Files" : "Write File";
55659
+ if (firstOp?.kind === "update")
55660
+ return isMulti ? "Edit Files" : "Edit File";
55661
+ if (firstOp?.kind === "delete")
55662
+ return isMulti ? "Delete Files" : "Delete File";
55663
+ }
55664
+ }
55665
+ return "Apply Patch";
55666
+ }
55667
+ if (t === "write" || t === "write_file" || t === "writefile" || t === "write_file_gemini" || t === "writefilegemini") {
55668
+ const filePath = parsedArgs?.file_path;
55669
+ if (filePath) {
55670
+ try {
55671
+ const { existsSync: existsSync10 } = __require("node:fs");
55672
+ if (existsSync10(filePath)) {
55673
+ return "Overwrite File";
55674
+ }
55675
+ } catch {}
55676
+ }
55677
+ return "Write File";
55678
+ }
55679
+ return getHeaderLabel(approvalRequest.toolName);
55680
+ }, [approvalRequest, parsedArgs]);
55681
+ const questionText = import_react30.useMemo(() => {
55682
+ if (!approvalRequest || !parsedArgs) {
55683
+ return { text: "Do you want to proceed?" };
55684
+ }
55685
+ const t = approvalRequest.toolName.toLowerCase();
55686
+ if (t === "write" || t === "write_file" || t === "writefile" || t === "write_file_gemini" || t === "writefilegemini") {
55687
+ const filePath = parsedArgs.file_path;
55688
+ if (filePath) {
55689
+ const { existsSync: existsSync10 } = __require("node:fs");
55690
+ const { relative: relative5 } = __require("node:path");
55691
+ const cwd2 = process.cwd();
55692
+ const relPath = relative5(cwd2, filePath);
55693
+ const displayPath = relPath.startsWith("..") ? filePath : relPath;
55694
+ try {
55695
+ if (existsSync10(filePath)) {
55696
+ return { text: "Overwrite", boldPath: `${displayPath}?` };
55697
+ }
55698
+ } catch {}
55699
+ return { text: "Write to", boldPath: `${displayPath}?` };
55700
+ }
55701
+ }
55702
+ if ((t === "apply_patch" || t === "applypatch") && parsedArgs.input) {
55703
+ const operations = parsePatchOperations(parsedArgs.input);
55704
+ if (operations.length > 0) {
55705
+ const { relative: relative5 } = __require("node:path");
55706
+ const cwd2 = process.cwd();
55707
+ const paths = operations.map((op) => {
55708
+ const relPath = relative5(cwd2, op.path);
55709
+ return relPath.startsWith("..") ? op.path : relPath;
55710
+ });
55711
+ if (paths.length === 1) {
55712
+ const op = operations[0];
55713
+ if (op?.kind === "add") {
55714
+ return { text: "Write to", boldPath: `${paths[0]}?` };
55715
+ } else if (op?.kind === "update") {
55716
+ return { text: "Update", boldPath: `${paths[0]}?` };
55717
+ } else if (op?.kind === "delete") {
55718
+ return { text: "Delete", boldPath: `${paths[0]}?` };
55719
+ }
55720
+ } else {
55721
+ return { text: "Apply patch to", boldPath: `${paths.length} files?` };
55722
+ }
55723
+ }
55724
+ }
55725
+ return { text: "Do you want to proceed?" };
55726
+ }, [approvalRequest, parsedArgs]);
54807
55727
  if (!approvalRequest) {
54808
55728
  return null;
54809
55729
  }
54810
- const headerLabel = getHeaderLabel(approvalRequest.toolName);
54811
55730
  if (isEnteringReason) {
54812
55731
  return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
54813
55732
  flexDirection: "column",
@@ -54821,7 +55740,7 @@ var init_ApprovalDialogRich = __esm(async () => {
54821
55740
  children: [
54822
55741
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
54823
55742
  bold: true,
54824
- children: "What should Letta do differently? (esc to cancel):"
55743
+ children: "What should I do differently? (esc to cancel):"
54825
55744
  }, undefined, false, undefined, this),
54826
55745
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
54827
55746
  height: 1
@@ -54883,15 +55802,28 @@ var init_ApprovalDialogRich = __esm(async () => {
54883
55802
  toolName: approvalRequest.toolName,
54884
55803
  toolArgs: approvalRequest.toolArgs,
54885
55804
  parsedArgs,
54886
- precomputedDiff
55805
+ precomputedDiff,
55806
+ allDiffs,
55807
+ toolCallId: approvalRequest.toolCallId
54887
55808
  }, undefined, false, undefined, this),
54888
55809
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
54889
55810
  height: 1
54890
55811
  }, undefined, false, undefined, this),
54891
55812
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
54892
55813
  bold: true,
54893
- children: "Do you want to proceed?"
54894
- }, undefined, false, undefined, this),
55814
+ children: [
55815
+ questionText.text,
55816
+ questionText.boldPath ? /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(jsx_dev_runtime8.Fragment, {
55817
+ children: [
55818
+ " ",
55819
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
55820
+ bold: true,
55821
+ children: questionText.boldPath
55822
+ }, undefined, false, undefined, this)
55823
+ ]
55824
+ }, undefined, true, undefined, this) : null
55825
+ ]
55826
+ }, undefined, true, undefined, this),
54895
55827
  /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
54896
55828
  height: 1
54897
55829
  }, undefined, false, undefined, this),
@@ -55716,7 +56648,7 @@ function FeedbackDialog({
55716
56648
  children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Text, {
55717
56649
  color: colors.approval.header,
55718
56650
  bold: true,
55719
- children: "Send Feedback to Letta Team"
56651
+ children: "Send Feedback to the Letta Team"
55720
56652
  }, undefined, false, undefined, this)
55721
56653
  }, undefined, false, undefined, this),
55722
56654
  /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
@@ -59347,10 +60279,6 @@ function AgentInfoBar({
59347
60279
  children: [
59348
60280
  /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
59349
60281
  children: [
59350
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
59351
- color: "gray",
59352
- children: "Current agent: "
59353
- }, undefined, false, undefined, this),
59354
60282
  /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
59355
60283
  bold: true,
59356
60284
  children: agentName || "Unnamed"
@@ -59358,6 +60286,9 @@ function AgentInfoBar({
59358
60286
  isPinned ? /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
59359
60287
  color: "green",
59360
60288
  children: " (pinned ✓)"
60289
+ }, undefined, false, undefined, this) : agentName === DEFAULT_AGENT_NAME || !agentName ? /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
60290
+ color: "gray",
60291
+ children: " (type /pin to give your agent a real name!)"
59361
60292
  }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
59362
60293
  color: "gray",
59363
60294
  children: " (type /pin to pin agent)"
@@ -59410,6 +60341,7 @@ function AgentInfoBar({
59410
60341
  }
59411
60342
  var import_react40, jsx_dev_runtime19;
59412
60343
  var init_AgentInfoBar = __esm(async () => {
60344
+ init_constants();
59413
60345
  init_settings_manager();
59414
60346
  init_colors();
59415
60347
  await __promiseAll([
@@ -59573,7 +60505,6 @@ function AutocompleteBox({ header, children }) {
59573
60505
  borderStyle: "round",
59574
60506
  borderColor: colors.command.border,
59575
60507
  paddingX: 1,
59576
- marginBottom: 1,
59577
60508
  children: [
59578
60509
  /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
59579
60510
  dimColor: true,
@@ -59891,7 +60822,7 @@ function SlashCommandAutocomplete({
59891
60822
  const showScrollUp = startIndex > 0;
59892
60823
  const showScrollDown = startIndex + VISIBLE_COMMANDS < totalMatches;
59893
60824
  return /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(AutocompleteBox, {
59894
- header: "↑↓ navigate, Tab autocomplete, Enter execute",
60825
+ header: "↑↓ navigate, Tab to autocomplete, Enter to execute",
59895
60826
  children: [
59896
60827
  showScrollUp && /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
59897
60828
  dimColor: true,
@@ -59923,6 +60854,23 @@ function SlashCommandAutocomplete({
59923
60854
  totalMatches - startIndex - VISIBLE_COMMANDS,
59924
60855
  " more below"
59925
60856
  ]
60857
+ }, undefined, true, undefined, this),
60858
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
60859
+ children: " "
60860
+ }, undefined, false, undefined, this),
60861
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
60862
+ dimColor: true,
60863
+ children: [
60864
+ "Having issues? Report bugs with /feedback or",
60865
+ " ",
60866
+ /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(dist_default4, {
60867
+ url: "https://discord.gg/letta",
60868
+ children: /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
60869
+ color: colors.link.text,
60870
+ children: "join our Discord ↗"
60871
+ }, undefined, false, undefined, this)
60872
+ }, undefined, false, undefined, this)
60873
+ ]
59926
60874
  }, undefined, true, undefined, this)
59927
60875
  ]
59928
60876
  }, undefined, true, undefined, this);
@@ -59931,8 +60879,10 @@ var import_react43, jsx_dev_runtime22, VISIBLE_COMMANDS = 8, _allCommands;
59931
60879
  var init_SlashCommandAutocomplete = __esm(async () => {
59932
60880
  init_settings_manager();
59933
60881
  init_registry();
60882
+ init_colors();
59934
60883
  await __promiseAll([
59935
60884
  init_build2(),
60885
+ init_dist4(),
59936
60886
  init_useAutocompleteNavigation(),
59937
60887
  init_Autocomplete()
59938
60888
  ]);
@@ -64251,6 +65201,7 @@ function formatToolArgs(argsStr) {
64251
65201
  var import_react60, jsx_dev_runtime40, AgentRow, GroupHeader, SubagentGroupDisplay;
64252
65202
  var init_SubagentGroupDisplay = __esm(async () => {
64253
65203
  init_subagentState();
65204
+ init_useTerminalWidth();
64254
65205
  init_colors();
64255
65206
  await __promiseAll([
64256
65207
  init_build2(),
@@ -64260,6 +65211,9 @@ var init_SubagentGroupDisplay = __esm(async () => {
64260
65211
  jsx_dev_runtime40 = __toESM(require_jsx_dev_runtime(), 1);
64261
65212
  AgentRow = import_react60.memo(({ agent, isLast, expanded }) => {
64262
65213
  const { treeChar, continueChar } = getTreeChars(isLast);
65214
+ const columns = useTerminalWidth();
65215
+ const gutterWidth = 6;
65216
+ const contentWidth = Math.max(0, columns - gutterWidth);
64263
65217
  const getDotElement = () => {
64264
65218
  switch (agent.status) {
64265
65219
  case "pending":
@@ -64335,17 +65289,34 @@ var init_SubagentGroupDisplay = __esm(async () => {
64335
65289
  agent.agentURL && /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Box_default, {
64336
65290
  flexDirection: "row",
64337
65291
  children: [
64338
- /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64339
- color: colors.subagent.treeChar,
64340
- children: continueChar
65292
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Box_default, {
65293
+ width: gutterWidth,
65294
+ flexShrink: 0,
65295
+ children: /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65296
+ children: [
65297
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65298
+ color: colors.subagent.treeChar,
65299
+ children: continueChar
65300
+ }, undefined, false, undefined, this),
65301
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65302
+ dimColor: true,
65303
+ children: " ⎿ "
65304
+ }, undefined, false, undefined, this)
65305
+ ]
65306
+ }, undefined, true, undefined, this)
64341
65307
  }, undefined, false, undefined, this),
64342
- /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64343
- dimColor: true,
64344
- children: [
64345
- " ⎿ Subagent: ",
64346
- agent.agentURL
64347
- ]
64348
- }, undefined, true, undefined, this)
65308
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Box_default, {
65309
+ flexGrow: 1,
65310
+ width: contentWidth,
65311
+ children: /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65312
+ wrap: "wrap",
65313
+ dimColor: true,
65314
+ children: [
65315
+ "Subagent: ",
65316
+ agent.agentURL
65317
+ ]
65318
+ }, undefined, true, undefined, this)
65319
+ }, undefined, false, undefined, this)
64349
65320
  ]
64350
65321
  }, undefined, true, undefined, this),
64351
65322
  expanded && agent.toolCalls.map((tc) => {
@@ -64372,32 +65343,72 @@ var init_SubagentGroupDisplay = __esm(async () => {
64372
65343
  }),
64373
65344
  /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Box_default, {
64374
65345
  flexDirection: "row",
64375
- children: [
64376
- /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64377
- color: colors.subagent.treeChar,
64378
- children: continueChar
64379
- }, undefined, false, undefined, this),
64380
- agent.status === "completed" ? /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64381
- dimColor: true,
64382
- children: " ⎿ Done"
64383
- }, undefined, false, undefined, this) : agent.status === "error" ? /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64384
- color: colors.subagent.error,
64385
- children: [
64386
- " ⎿ ",
64387
- agent.error
64388
- ]
64389
- }, undefined, true, undefined, this) : lastTool ? /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64390
- dimColor: true,
64391
- children: [
64392
- " ⎿ ",
64393
- lastTool.name
64394
- ]
64395
- }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
64396
- dimColor: true,
64397
- children: " ⎿ Starting..."
64398
- }, undefined, false, undefined, this)
64399
- ]
64400
- }, undefined, true, undefined, this)
65346
+ children: agent.status === "completed" ? /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(jsx_dev_runtime40.Fragment, {
65347
+ children: [
65348
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65349
+ color: colors.subagent.treeChar,
65350
+ children: continueChar
65351
+ }, undefined, false, undefined, this),
65352
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65353
+ dimColor: true,
65354
+ children: " ⎿ Done"
65355
+ }, undefined, false, undefined, this)
65356
+ ]
65357
+ }, undefined, true, undefined, this) : agent.status === "error" ? /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(jsx_dev_runtime40.Fragment, {
65358
+ children: [
65359
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Box_default, {
65360
+ width: gutterWidth,
65361
+ flexShrink: 0,
65362
+ children: /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65363
+ children: [
65364
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65365
+ color: colors.subagent.treeChar,
65366
+ children: continueChar
65367
+ }, undefined, false, undefined, this),
65368
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65369
+ dimColor: true,
65370
+ children: " ⎿ "
65371
+ }, undefined, false, undefined, this)
65372
+ ]
65373
+ }, undefined, true, undefined, this)
65374
+ }, undefined, false, undefined, this),
65375
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Box_default, {
65376
+ flexGrow: 1,
65377
+ width: contentWidth,
65378
+ children: /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65379
+ wrap: "wrap",
65380
+ color: colors.subagent.error,
65381
+ children: agent.error
65382
+ }, undefined, false, undefined, this)
65383
+ }, undefined, false, undefined, this)
65384
+ ]
65385
+ }, undefined, true, undefined, this) : lastTool ? /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(jsx_dev_runtime40.Fragment, {
65386
+ children: [
65387
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65388
+ color: colors.subagent.treeChar,
65389
+ children: continueChar
65390
+ }, undefined, false, undefined, this),
65391
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65392
+ dimColor: true,
65393
+ children: [
65394
+ " ⎿ ",
65395
+ lastTool.name
65396
+ ]
65397
+ }, undefined, true, undefined, this)
65398
+ ]
65399
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(jsx_dev_runtime40.Fragment, {
65400
+ children: [
65401
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65402
+ color: colors.subagent.treeChar,
65403
+ children: continueChar
65404
+ }, undefined, false, undefined, this),
65405
+ /* @__PURE__ */ jsx_dev_runtime40.jsxDEV(Text, {
65406
+ dimColor: true,
65407
+ children: " ⎿ Starting..."
65408
+ }, undefined, false, undefined, this)
65409
+ ]
65410
+ }, undefined, true, undefined, this)
65411
+ }, undefined, false, undefined, this)
64401
65412
  ]
64402
65413
  }, undefined, true, undefined, this);
64403
65414
  });
@@ -64467,12 +65478,16 @@ var init_SubagentGroupDisplay = __esm(async () => {
64467
65478
  // src/cli/components/SubagentGroupStatic.tsx
64468
65479
  var import_react61, jsx_dev_runtime41, AgentRow2, SubagentGroupStatic;
64469
65480
  var init_SubagentGroupStatic = __esm(async () => {
65481
+ init_useTerminalWidth();
64470
65482
  init_colors();
64471
65483
  await init_build2();
64472
65484
  import_react61 = __toESM(require_react(), 1);
64473
65485
  jsx_dev_runtime41 = __toESM(require_jsx_dev_runtime(), 1);
64474
65486
  AgentRow2 = import_react61.memo(({ agent, isLast }) => {
64475
65487
  const { treeChar, continueChar } = getTreeChars(isLast);
65488
+ const columns = useTerminalWidth();
65489
+ const gutterWidth = 6;
65490
+ const contentWidth = Math.max(0, columns - gutterWidth);
64476
65491
  const dotColor = agent.status === "completed" ? colors.subagent.completed : colors.subagent.error;
64477
65492
  const stats = formatStats(agent.toolCount, agent.totalTokens);
64478
65493
  return /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
@@ -64524,38 +65539,79 @@ var init_SubagentGroupStatic = __esm(async () => {
64524
65539
  agent.agentURL && /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
64525
65540
  flexDirection: "row",
64526
65541
  children: [
64527
- /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
64528
- color: colors.subagent.treeChar,
64529
- children: continueChar
65542
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
65543
+ width: gutterWidth,
65544
+ flexShrink: 0,
65545
+ children: /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65546
+ children: [
65547
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65548
+ color: colors.subagent.treeChar,
65549
+ children: continueChar
65550
+ }, undefined, false, undefined, this),
65551
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65552
+ dimColor: true,
65553
+ children: " ⎿ "
65554
+ }, undefined, false, undefined, this)
65555
+ ]
65556
+ }, undefined, true, undefined, this)
64530
65557
  }, undefined, false, undefined, this),
64531
- /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
64532
- dimColor: true,
64533
- children: [
64534
- " ⎿ Subagent: ",
64535
- agent.agentURL
64536
- ]
64537
- }, undefined, true, undefined, this)
65558
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
65559
+ flexGrow: 1,
65560
+ width: contentWidth,
65561
+ children: /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65562
+ wrap: "wrap",
65563
+ dimColor: true,
65564
+ children: [
65565
+ "Subagent: ",
65566
+ agent.agentURL
65567
+ ]
65568
+ }, undefined, true, undefined, this)
65569
+ }, undefined, false, undefined, this)
64538
65570
  ]
64539
65571
  }, undefined, true, undefined, this),
64540
65572
  /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
64541
65573
  flexDirection: "row",
64542
- children: [
64543
- /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
64544
- color: colors.subagent.treeChar,
64545
- children: continueChar
64546
- }, undefined, false, undefined, this),
64547
- agent.status === "completed" ? /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
64548
- dimColor: true,
64549
- children: " ⎿ Done"
64550
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
64551
- color: colors.subagent.error,
64552
- children: [
64553
- " ⎿ ",
64554
- agent.error
64555
- ]
64556
- }, undefined, true, undefined, this)
64557
- ]
64558
- }, undefined, true, undefined, this)
65574
+ children: agent.status === "completed" ? /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(jsx_dev_runtime41.Fragment, {
65575
+ children: [
65576
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65577
+ color: colors.subagent.treeChar,
65578
+ children: continueChar
65579
+ }, undefined, false, undefined, this),
65580
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65581
+ dimColor: true,
65582
+ children: " ⎿ Done"
65583
+ }, undefined, false, undefined, this)
65584
+ ]
65585
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(jsx_dev_runtime41.Fragment, {
65586
+ children: [
65587
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
65588
+ width: gutterWidth,
65589
+ flexShrink: 0,
65590
+ children: /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65591
+ children: [
65592
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65593
+ color: colors.subagent.treeChar,
65594
+ children: continueChar
65595
+ }, undefined, false, undefined, this),
65596
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65597
+ dimColor: true,
65598
+ children: " ⎿ "
65599
+ }, undefined, false, undefined, this)
65600
+ ]
65601
+ }, undefined, true, undefined, this)
65602
+ }, undefined, false, undefined, this),
65603
+ /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
65604
+ flexGrow: 1,
65605
+ width: contentWidth,
65606
+ children: /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text, {
65607
+ wrap: "wrap",
65608
+ color: colors.subagent.error,
65609
+ children: agent.error
65610
+ }, undefined, false, undefined, this)
65611
+ }, undefined, false, undefined, this)
65612
+ ]
65613
+ }, undefined, true, undefined, this)
65614
+ }, undefined, false, undefined, this)
64559
65615
  ]
64560
65616
  }, undefined, true, undefined, this);
64561
65617
  });
@@ -64865,185 +65921,12 @@ var init_SystemPromptSelector = __esm(async () => {
64865
65921
  jsx_dev_runtime43 = __toESM(require_jsx_dev_runtime(), 1);
64866
65922
  });
64867
65923
 
64868
- // src/cli/helpers/formatArgsDisplay.ts
64869
- function formatArgsDisplay(argsJson) {
64870
- let parsed = {};
64871
- let display = "…";
64872
- try {
64873
- if (argsJson?.trim()) {
64874
- const p = JSON.parse(argsJson);
64875
- if (isRecord4(p)) {
64876
- const clone = { ...p };
64877
- if ("request_heartbeat" in clone)
64878
- delete clone.request_heartbeat;
64879
- parsed = clone;
64880
- const keys = Object.keys(parsed);
64881
- const firstKey = keys[0];
64882
- if (keys.length === 1 && firstKey && [
64883
- "query",
64884
- "path",
64885
- "file_path",
64886
- "target_file",
64887
- "target_directory",
64888
- "command",
64889
- "label",
64890
- "pattern"
64891
- ].includes(firstKey)) {
64892
- const v = parsed[firstKey];
64893
- display = typeof v === "string" ? v : String(v);
64894
- } else {
64895
- display = Object.entries(parsed).map(([k, v]) => {
64896
- if (v === undefined || v === null)
64897
- return `${k}=${v}`;
64898
- if (typeof v === "boolean" || typeof v === "number")
64899
- return `${k}=${v}`;
64900
- if (typeof v === "string")
64901
- return v.length > 50 ? `${k}=…` : `${k}="${v}"`;
64902
- if (Array.isArray(v))
64903
- return `${k}=[${v.length} items]`;
64904
- if (typeof v === "object")
64905
- return `${k}={${Object.keys(v).length} props}`;
64906
- const str = JSON.stringify(v);
64907
- return str.length > 50 ? `${k}=…` : `${k}=${str}`;
64908
- }).join(", ");
64909
- }
64910
- }
64911
- }
64912
- } catch {
64913
- try {
64914
- const s = argsJson || "";
64915
- const fp = /"file_path"\s*:\s*"([^"]+)"/.exec(s);
64916
- const old = /"old_string"\s*:\s*"([\s\S]*?)"\s*(,|\})/.exec(s);
64917
- const neu = /"new_string"\s*:\s*"([\s\S]*?)"\s*(,|\})/.exec(s);
64918
- const cont = /"content"\s*:\s*"([\s\S]*?)"\s*(,|\})/.exec(s);
64919
- const parts = [];
64920
- if (fp)
64921
- parts.push(`file_path="${fp[1]}"`);
64922
- if (old)
64923
- parts.push(`old_string=…`);
64924
- if (neu)
64925
- parts.push(`new_string=…`);
64926
- if (cont)
64927
- parts.push(`content=…`);
64928
- if (parts.length)
64929
- display = parts.join(", ");
64930
- } catch {}
64931
- }
64932
- return { display, parsed };
64933
- }
64934
- var isRecord4 = (v) => typeof v === "object" && v !== null;
64935
-
64936
- // src/cli/helpers/toolNameMapping.ts
64937
- function getDisplayToolName(rawName) {
64938
- if (rawName === "write")
64939
- return "Write";
64940
- if (rawName === "edit" || rawName === "multi_edit")
64941
- return "Edit";
64942
- if (rawName === "read")
64943
- return "Read";
64944
- if (rawName === "bash")
64945
- return "Bash";
64946
- if (rawName === "grep")
64947
- return "Grep";
64948
- if (rawName === "glob")
64949
- return "Glob";
64950
- if (rawName === "ls")
64951
- return "LS";
64952
- if (rawName === "todo_write" || rawName === "TodoWrite")
64953
- return "TODO";
64954
- if (rawName === "EnterPlanMode" || rawName === "ExitPlanMode")
64955
- return "Planning";
64956
- if (rawName === "AskUserQuestion")
64957
- return "Question";
64958
- if (rawName === "update_plan")
64959
- return "Planning";
64960
- if (rawName === "shell_command" || rawName === "shell")
64961
- return "Shell";
64962
- if (rawName === "read_file")
64963
- return "Read";
64964
- if (rawName === "list_dir")
64965
- return "LS";
64966
- if (rawName === "grep_files")
64967
- return "Grep";
64968
- if (rawName === "apply_patch")
64969
- return "Patch";
64970
- if (rawName === "UpdatePlan")
64971
- return "Planning";
64972
- if (rawName === "ShellCommand" || rawName === "Shell")
64973
- return "Shell";
64974
- if (rawName === "ReadFile")
64975
- return "Read";
64976
- if (rawName === "ListDir")
64977
- return "LS";
64978
- if (rawName === "GrepFiles")
64979
- return "Grep";
64980
- if (rawName === "ApplyPatch")
64981
- return "Patch";
64982
- if (rawName === "run_shell_command")
64983
- return "Shell";
64984
- if (rawName === "read_file_gemini")
64985
- return "Read";
64986
- if (rawName === "list_directory")
64987
- return "LS";
64988
- if (rawName === "glob_gemini")
64989
- return "Glob";
64990
- if (rawName === "search_file_content")
64991
- return "Grep";
64992
- if (rawName === "write_file_gemini")
64993
- return "Write";
64994
- if (rawName === "write_todos")
64995
- return "TODO";
64996
- if (rawName === "read_many_files")
64997
- return "Read Multiple";
64998
- if (rawName === "RunShellCommand")
64999
- return "Shell";
65000
- if (rawName === "ReadFileGemini")
65001
- return "Read";
65002
- if (rawName === "ListDirectory")
65003
- return "LS";
65004
- if (rawName === "GlobGemini")
65005
- return "Glob";
65006
- if (rawName === "SearchFileContent")
65007
- return "Grep";
65008
- if (rawName === "WriteFileGemini")
65009
- return "Write";
65010
- if (rawName === "WriteTodos")
65011
- return "TODO";
65012
- if (rawName === "ReadManyFiles")
65013
- return "Read Multiple";
65014
- if (rawName === "Replace" || rawName === "replace")
65015
- return "Edit";
65016
- if (rawName === "WriteFile" || rawName === "write_file")
65017
- return "Write";
65018
- if (rawName === "KillBash")
65019
- return "Kill Shell";
65020
- if (rawName === "BashOutput")
65021
- return "Shell Output";
65022
- if (rawName === "MultiEdit")
65023
- return "Edit";
65024
- return rawName;
65025
- }
65026
- function isTaskTool(name) {
65027
- return name === "Task" || name === "task";
65028
- }
65029
- function isTodoTool(rawName, displayName) {
65030
- return rawName === "todo_write" || rawName === "TodoWrite" || rawName === "write_todos" || rawName === "WriteTodos" || displayName === "TODO";
65031
- }
65032
- function isPlanTool(rawName, displayName) {
65033
- return rawName === "update_plan" || rawName === "UpdatePlan" || displayName === "Planning";
65034
- }
65035
- function isFancyUITool(name) {
65036
- return name === "AskUserQuestion" || name === "EnterPlanMode" || name === "ExitPlanMode";
65037
- }
65038
- function isMemoryTool(name) {
65039
- return name === "memory" || name === "memory_apply_patch";
65040
- }
65041
-
65042
65924
  // src/cli/components/MemoryDiffRenderer.tsx
65043
65925
  function MemoryDiffRenderer({
65044
65926
  argsText,
65045
65927
  toolName
65046
65928
  }) {
65929
+ const columns = useTerminalWidth();
65047
65930
  try {
65048
65931
  const args = JSON.parse(argsText);
65049
65932
  if (toolName === "memory_apply_patch") {
@@ -65051,7 +65934,8 @@ function MemoryDiffRenderer({
65051
65934
  const patch = args.patch || "";
65052
65935
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(PatchDiffRenderer, {
65053
65936
  label,
65054
- patch
65937
+ patch,
65938
+ columns
65055
65939
  }, undefined, false, undefined, this);
65056
65940
  }
65057
65941
  const command = args.command;
@@ -65064,41 +65948,73 @@ function MemoryDiffRenderer({
65064
65948
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(MemoryStrReplaceDiff, {
65065
65949
  blockName,
65066
65950
  oldStr,
65067
- newStr
65951
+ newStr,
65952
+ columns
65068
65953
  }, undefined, false, undefined, this);
65069
65954
  }
65070
65955
  case "insert": {
65071
65956
  const insertText = args.insert_text || "";
65072
65957
  const insertLine = args.insert_line;
65958
+ const prefixWidth = 4;
65959
+ const contentWidth = Math.max(0, columns - prefixWidth);
65073
65960
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65074
65961
  flexDirection: "column",
65075
65962
  children: [
65076
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65963
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65964
+ flexDirection: "row",
65077
65965
  children: [
65078
- " ",
65079
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65080
- dimColor: true,
65081
- children: "⎿"
65082
- }, undefined, false, undefined, this),
65083
- " Inserted into memory block",
65084
- " ",
65085
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65086
- color: colors.tool.memoryName,
65087
- children: blockName
65966
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65967
+ width: prefixWidth,
65968
+ flexShrink: 0,
65969
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65970
+ children: [
65971
+ " ",
65972
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65973
+ dimColor: true,
65974
+ children: "⎿"
65975
+ }, undefined, false, undefined, this)
65976
+ ]
65977
+ }, undefined, true, undefined, this)
65088
65978
  }, undefined, false, undefined, this),
65089
- insertLine !== undefined && ` at line ${insertLine}`
65979
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65980
+ flexGrow: 1,
65981
+ width: contentWidth,
65982
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65983
+ wrap: "wrap",
65984
+ children: [
65985
+ "Inserted into memory block",
65986
+ " ",
65987
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65988
+ bold: true,
65989
+ color: colors.tool.memoryName,
65990
+ children: blockName
65991
+ }, undefined, false, undefined, this),
65992
+ insertLine !== undefined && ` at line ${insertLine}`
65993
+ ]
65994
+ }, undefined, true, undefined, this)
65995
+ }, undefined, false, undefined, this)
65090
65996
  ]
65091
65997
  }, undefined, true, undefined, this),
65092
65998
  insertText.split(`
65093
65999
  `).map((line, i) => /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66000
+ flexDirection: "row",
65094
66001
  children: [
65095
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65096
- children: " "
66002
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66003
+ width: prefixWidth,
66004
+ flexShrink: 0,
66005
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66006
+ children: " "
66007
+ }, undefined, false, undefined, this)
65097
66008
  }, undefined, false, undefined, this),
65098
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65099
- backgroundColor: colors.diff.addedLineBg,
65100
- color: colors.diff.textOnDark,
65101
- children: `+ ${line}`
66009
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66010
+ flexGrow: 1,
66011
+ width: contentWidth,
66012
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66013
+ backgroundColor: colors.diff.addedLineBg,
66014
+ color: colors.diff.textOnDark,
66015
+ wrap: "wrap",
66016
+ children: `+ ${line}`
66017
+ }, undefined, false, undefined, this)
65102
66018
  }, undefined, false, undefined, this)
65103
66019
  ]
65104
66020
  }, `insert-${i}-${line.substring(0, 20)}`, true, undefined, this))
@@ -65108,41 +66024,72 @@ function MemoryDiffRenderer({
65108
66024
  case "create": {
65109
66025
  const description = args.description || "";
65110
66026
  const fileText = args.file_text || "";
66027
+ const prefixWidth = 4;
66028
+ const contentWidth = Math.max(0, columns - prefixWidth);
65111
66029
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65112
66030
  flexDirection: "column",
65113
66031
  children: [
65114
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66032
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66033
+ flexDirection: "row",
65115
66034
  children: [
65116
- " ",
65117
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65118
- dimColor: true,
65119
- children: "⎿"
65120
- }, undefined, false, undefined, this),
65121
- " Created memory block",
65122
- " ",
65123
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65124
- color: colors.tool.memoryName,
65125
- children: blockName
66035
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66036
+ width: prefixWidth,
66037
+ flexShrink: 0,
66038
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66039
+ children: [
66040
+ " ",
66041
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66042
+ dimColor: true,
66043
+ children: "⎿"
66044
+ }, undefined, false, undefined, this)
66045
+ ]
66046
+ }, undefined, true, undefined, this)
65126
66047
  }, undefined, false, undefined, this),
65127
- description && /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65128
- dimColor: true,
65129
- children: [
65130
- " - ",
65131
- truncate(description, 40)
65132
- ]
65133
- }, undefined, true, undefined, this)
66048
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66049
+ flexGrow: 1,
66050
+ width: contentWidth,
66051
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66052
+ wrap: "wrap",
66053
+ children: [
66054
+ "Created memory block",
66055
+ " ",
66056
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66057
+ bold: true,
66058
+ color: colors.tool.memoryName,
66059
+ children: blockName
66060
+ }, undefined, false, undefined, this),
66061
+ description && /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66062
+ dimColor: true,
66063
+ children: [
66064
+ " - ",
66065
+ truncate(description, 40)
66066
+ ]
66067
+ }, undefined, true, undefined, this)
66068
+ ]
66069
+ }, undefined, true, undefined, this)
66070
+ }, undefined, false, undefined, this)
65134
66071
  ]
65135
66072
  }, undefined, true, undefined, this),
65136
66073
  fileText?.split(`
65137
66074
  `).slice(0, 3).map((line, i) => /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66075
+ flexDirection: "row",
65138
66076
  children: [
65139
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65140
- children: " "
66077
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66078
+ width: prefixWidth,
66079
+ flexShrink: 0,
66080
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66081
+ children: " "
66082
+ }, undefined, false, undefined, this)
65141
66083
  }, undefined, false, undefined, this),
65142
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65143
- backgroundColor: colors.diff.addedLineBg,
65144
- color: colors.diff.textOnDark,
65145
- children: `+ ${truncate(line, 60)}`
66084
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66085
+ flexGrow: 1,
66086
+ width: contentWidth,
66087
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66088
+ backgroundColor: colors.diff.addedLineBg,
66089
+ color: colors.diff.textOnDark,
66090
+ wrap: "wrap",
66091
+ children: `+ ${truncate(line, 60)}`
66092
+ }, undefined, false, undefined, this)
65146
66093
  }, undefined, false, undefined, this)
65147
66094
  ]
65148
66095
  }, `create-${i}-${line.substring(0, 20)}`, true, undefined, this)),
@@ -65161,18 +66108,39 @@ function MemoryDiffRenderer({
65161
66108
  }, undefined, true, undefined, this);
65162
66109
  }
65163
66110
  case "delete": {
65164
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66111
+ const prefixWidth = 4;
66112
+ const contentWidth = Math.max(0, columns - prefixWidth);
66113
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66114
+ flexDirection: "row",
65165
66115
  children: [
65166
- " ",
65167
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65168
- dimColor: true,
65169
- children: "⎿"
66116
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66117
+ width: prefixWidth,
66118
+ flexShrink: 0,
66119
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66120
+ children: [
66121
+ " ",
66122
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66123
+ dimColor: true,
66124
+ children: "⎿"
66125
+ }, undefined, false, undefined, this)
66126
+ ]
66127
+ }, undefined, true, undefined, this)
65170
66128
  }, undefined, false, undefined, this),
65171
- " Deleted memory block",
65172
- " ",
65173
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65174
- color: colors.tool.memoryName,
65175
- children: blockName
66129
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66130
+ flexGrow: 1,
66131
+ width: contentWidth,
66132
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66133
+ wrap: "wrap",
66134
+ children: [
66135
+ "Deleted memory block",
66136
+ " ",
66137
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66138
+ bold: true,
66139
+ color: colors.tool.memoryName,
66140
+ children: blockName
66141
+ }, undefined, false, undefined, this)
66142
+ ]
66143
+ }, undefined, true, undefined, this)
65176
66144
  }, undefined, false, undefined, this)
65177
66145
  ]
65178
66146
  }, undefined, true, undefined, this);
@@ -65181,63 +66149,127 @@ function MemoryDiffRenderer({
65181
66149
  const newPath = args.new_path || "";
65182
66150
  const newBlockName = newPath.split("/").pop() || newPath;
65183
66151
  const description = args.description;
66152
+ const prefixWidth = 4;
66153
+ const contentWidth = Math.max(0, columns - prefixWidth);
65184
66154
  if (description) {
65185
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66155
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66156
+ flexDirection: "row",
65186
66157
  children: [
65187
- " ",
65188
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65189
- dimColor: true,
65190
- children: "⎿"
66158
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66159
+ width: prefixWidth,
66160
+ flexShrink: 0,
66161
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66162
+ children: [
66163
+ " ",
66164
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66165
+ dimColor: true,
66166
+ children: "⎿"
66167
+ }, undefined, false, undefined, this)
66168
+ ]
66169
+ }, undefined, true, undefined, this)
65191
66170
  }, undefined, false, undefined, this),
65192
- " Updated description of",
65193
- " ",
65194
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65195
- color: colors.tool.memoryName,
65196
- children: blockName
66171
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66172
+ flexGrow: 1,
66173
+ width: contentWidth,
66174
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66175
+ wrap: "wrap",
66176
+ children: [
66177
+ "Updated description of",
66178
+ " ",
66179
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66180
+ bold: true,
66181
+ color: colors.tool.memoryName,
66182
+ children: blockName
66183
+ }, undefined, false, undefined, this)
66184
+ ]
66185
+ }, undefined, true, undefined, this)
65197
66186
  }, undefined, false, undefined, this)
65198
66187
  ]
65199
66188
  }, undefined, true, undefined, this);
65200
66189
  }
65201
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66190
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66191
+ flexDirection: "row",
65202
66192
  children: [
65203
- " ",
65204
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65205
- dimColor: true,
65206
- children: "⎿"
65207
- }, undefined, false, undefined, this),
65208
- " Renamed",
65209
- " ",
65210
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65211
- color: colors.tool.memoryName,
65212
- children: blockName
66193
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66194
+ width: prefixWidth,
66195
+ flexShrink: 0,
66196
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66197
+ children: [
66198
+ " ",
66199
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66200
+ dimColor: true,
66201
+ children: "⎿"
66202
+ }, undefined, false, undefined, this)
66203
+ ]
66204
+ }, undefined, true, undefined, this)
65213
66205
  }, undefined, false, undefined, this),
65214
- " to",
65215
- " ",
65216
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65217
- color: colors.tool.memoryName,
65218
- children: newBlockName
66206
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66207
+ flexGrow: 1,
66208
+ width: contentWidth,
66209
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66210
+ wrap: "wrap",
66211
+ children: [
66212
+ "Renamed",
66213
+ " ",
66214
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66215
+ bold: true,
66216
+ color: colors.tool.memoryName,
66217
+ children: blockName
66218
+ }, undefined, false, undefined, this),
66219
+ " ",
66220
+ "to",
66221
+ " ",
66222
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66223
+ bold: true,
66224
+ color: colors.tool.memoryName,
66225
+ children: newBlockName
66226
+ }, undefined, false, undefined, this)
66227
+ ]
66228
+ }, undefined, true, undefined, this)
65219
66229
  }, undefined, false, undefined, this)
65220
66230
  ]
65221
66231
  }, undefined, true, undefined, this);
65222
66232
  }
65223
- default:
65224
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66233
+ default: {
66234
+ const defaultPrefixWidth = 4;
66235
+ const defaultContentWidth = Math.max(0, columns - defaultPrefixWidth);
66236
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66237
+ flexDirection: "row",
65225
66238
  children: [
65226
- " ",
65227
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65228
- dimColor: true,
65229
- children: "⎿"
66239
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66240
+ width: defaultPrefixWidth,
66241
+ flexShrink: 0,
66242
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66243
+ children: [
66244
+ " ",
66245
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66246
+ dimColor: true,
66247
+ children: "⎿"
66248
+ }, undefined, false, undefined, this)
66249
+ ]
66250
+ }, undefined, true, undefined, this)
65230
66251
  }, undefined, false, undefined, this),
65231
- " Memory operation: ",
65232
- command,
65233
- " on",
65234
- " ",
65235
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65236
- color: colors.tool.memoryName,
65237
- children: blockName
66252
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66253
+ flexGrow: 1,
66254
+ width: defaultContentWidth,
66255
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66256
+ wrap: "wrap",
66257
+ children: [
66258
+ "Memory operation: ",
66259
+ command,
66260
+ " on",
66261
+ " ",
66262
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66263
+ bold: true,
66264
+ color: colors.tool.memoryName,
66265
+ children: blockName
66266
+ }, undefined, false, undefined, this)
66267
+ ]
66268
+ }, undefined, true, undefined, this)
65238
66269
  }, undefined, false, undefined, this)
65239
66270
  ]
65240
66271
  }, undefined, true, undefined, this);
66272
+ }
65241
66273
  }
65242
66274
  } catch {
65243
66275
  return null;
@@ -65246,50 +66278,100 @@ function MemoryDiffRenderer({
65246
66278
  function MemoryStrReplaceDiff({
65247
66279
  blockName,
65248
66280
  oldStr,
65249
- newStr
66281
+ newStr,
66282
+ columns
65250
66283
  }) {
65251
- const oldLines = oldStr.split(`
65252
- `);
65253
- const newLines = newStr.split(`
66284
+ const lineDiffs = diffLines(oldStr, newStr);
66285
+ const rows = [];
66286
+ for (let i = 0;i < lineDiffs.length; i++) {
66287
+ const part = lineDiffs[i];
66288
+ if (!part)
66289
+ continue;
66290
+ if (!part.added && !part.removed)
66291
+ continue;
66292
+ const lines = part.value.replace(/\n$/, "").split(`
65254
66293
  `);
65255
- const singleLine = oldLines.length === 1 && newLines.length === 1;
65256
- const maxLines = 5;
65257
- const oldTruncated = oldLines.slice(0, maxLines);
65258
- const newTruncated = newLines.slice(0, maxLines);
65259
- const hasMore = oldLines.length > maxLines || newLines.length > maxLines;
66294
+ if (part.removed) {
66295
+ const nextPart = lineDiffs[i + 1];
66296
+ const nextIsAdd = nextPart?.added;
66297
+ const nextLines = nextIsAdd ? nextPart.value.replace(/\n$/, "").split(`
66298
+ `) : [];
66299
+ lines.forEach((line, lineIdx) => {
66300
+ rows.push({
66301
+ type: "remove",
66302
+ content: line,
66303
+ pairContent: nextIsAdd && lines.length === nextLines.length ? nextLines[lineIdx] : undefined
66304
+ });
66305
+ });
66306
+ } else if (part.added) {
66307
+ const prevPart = lineDiffs[i - 1];
66308
+ const prevIsRemove = prevPart?.removed;
66309
+ const prevLines = prevIsRemove ? prevPart.value.replace(/\n$/, "").split(`
66310
+ `) : [];
66311
+ lines.forEach((line, lineIdx) => {
66312
+ rows.push({
66313
+ type: "add",
66314
+ content: line,
66315
+ pairContent: prevIsRemove && lines.length === prevLines.length ? prevLines[lineIdx] : undefined
66316
+ });
66317
+ });
66318
+ }
66319
+ }
66320
+ const maxRows = 10;
66321
+ const displayRows = rows.slice(0, maxRows);
66322
+ const hasMore = rows.length > maxRows;
66323
+ const prefixWidth = 4;
66324
+ const contentWidth = Math.max(0, columns - prefixWidth);
65260
66325
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65261
66326
  flexDirection: "column",
65262
66327
  children: [
65263
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66328
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66329
+ flexDirection: "row",
65264
66330
  children: [
65265
- " ",
65266
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65267
- dimColor: true,
65268
- children: "⎿"
66331
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66332
+ width: prefixWidth,
66333
+ flexShrink: 0,
66334
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66335
+ children: [
66336
+ " ",
66337
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66338
+ dimColor: true,
66339
+ children: "⎿"
66340
+ }, undefined, false, undefined, this)
66341
+ ]
66342
+ }, undefined, true, undefined, this)
65269
66343
  }, undefined, false, undefined, this),
65270
- " Updated memory block",
65271
- " ",
65272
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65273
- color: colors.tool.memoryName,
65274
- children: blockName
66344
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66345
+ flexGrow: 1,
66346
+ width: contentWidth,
66347
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66348
+ wrap: "wrap",
66349
+ children: [
66350
+ "Updated memory block",
66351
+ " ",
66352
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66353
+ bold: true,
66354
+ color: colors.tool.memoryName,
66355
+ children: blockName
66356
+ }, undefined, false, undefined, this)
66357
+ ]
66358
+ }, undefined, true, undefined, this)
65275
66359
  }, undefined, false, undefined, this)
65276
66360
  ]
65277
66361
  }, undefined, true, undefined, this),
65278
- oldTruncated.map((line, i) => /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(DiffLine2, {
65279
- type: "remove",
65280
- content: line,
65281
- compareContent: singleLine ? newLines[0] : undefined
65282
- }, `old-${i}-${line.substring(0, 20)}`, false, undefined, this)),
65283
- newTruncated.map((line, i) => /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(DiffLine2, {
65284
- type: "add",
65285
- content: line,
65286
- compareContent: singleLine ? oldLines[0] : undefined
65287
- }, `new-${i}-${line.substring(0, 20)}`, false, undefined, this)),
66362
+ displayRows.map((row, i) => /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(DiffLine2, {
66363
+ type: row.type,
66364
+ content: row.content,
66365
+ compareContent: row.pairContent,
66366
+ columns
66367
+ }, `diff-${i}-${row.type}-${row.content.substring(0, 20)}`, false, undefined, this)),
65288
66368
  hasMore && /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65289
66369
  dimColor: true,
65290
66370
  children: [
65291
66371
  " ",
65292
- "... diff truncated"
66372
+ "... ",
66373
+ rows.length - maxRows,
66374
+ " more lines"
65293
66375
  ]
65294
66376
  }, undefined, true, undefined, this)
65295
66377
  ]
@@ -65298,57 +66380,84 @@ function MemoryStrReplaceDiff({
65298
66380
  function DiffLine2({
65299
66381
  type,
65300
66382
  content,
65301
- compareContent
66383
+ compareContent,
66384
+ columns
65302
66385
  }) {
65303
66386
  const prefix = type === "add" ? "+" : "-";
65304
66387
  const lineBg = type === "add" ? colors.diff.addedLineBg : colors.diff.removedLineBg;
65305
66388
  const wordBg = type === "add" ? colors.diff.addedWordBg : colors.diff.removedWordBg;
66389
+ const prefixWidth = 4;
66390
+ const contentWidth = Math.max(0, columns - prefixWidth);
65306
66391
  if (compareContent !== undefined && content.trim() && compareContent.trim()) {
65307
66392
  const wordDiffs = type === "add" ? diffWords(compareContent, content) : diffWords(content, compareContent);
65308
66393
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66394
+ flexDirection: "row",
65309
66395
  children: [
65310
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65311
- children: " "
65312
- }, undefined, false, undefined, this),
65313
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65314
- backgroundColor: lineBg,
65315
- color: colors.diff.textOnDark,
65316
- children: `${prefix} `
66396
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66397
+ width: prefixWidth,
66398
+ flexShrink: 0,
66399
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66400
+ children: " "
66401
+ }, undefined, false, undefined, this)
65317
66402
  }, undefined, false, undefined, this),
65318
- wordDiffs.map((part, i) => {
65319
- if (part.added && type === "add") {
65320
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65321
- backgroundColor: wordBg,
65322
- color: colors.diff.textOnHighlight,
65323
- children: part.value
65324
- }, `w-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
65325
- } else if (part.removed && type === "remove") {
65326
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65327
- backgroundColor: wordBg,
65328
- color: colors.diff.textOnHighlight,
65329
- children: part.value
65330
- }, `w-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
65331
- } else if (!part.added && !part.removed) {
65332
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65333
- backgroundColor: lineBg,
65334
- color: colors.diff.textOnDark,
65335
- children: part.value
65336
- }, `w-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
65337
- }
65338
- return null;
65339
- })
66403
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66404
+ flexGrow: 1,
66405
+ width: contentWidth,
66406
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66407
+ wrap: "wrap",
66408
+ children: [
66409
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66410
+ backgroundColor: lineBg,
66411
+ color: colors.diff.textOnDark,
66412
+ children: `${prefix} `
66413
+ }, undefined, false, undefined, this),
66414
+ wordDiffs.map((part, i) => {
66415
+ if (part.added && type === "add") {
66416
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66417
+ backgroundColor: wordBg,
66418
+ color: colors.diff.textOnHighlight,
66419
+ children: part.value
66420
+ }, `w-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
66421
+ } else if (part.removed && type === "remove") {
66422
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66423
+ backgroundColor: wordBg,
66424
+ color: colors.diff.textOnHighlight,
66425
+ children: part.value
66426
+ }, `w-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
66427
+ } else if (!part.added && !part.removed) {
66428
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66429
+ backgroundColor: lineBg,
66430
+ color: colors.diff.textOnDark,
66431
+ children: part.value
66432
+ }, `w-${i}-${part.value.substring(0, 10)}`, false, undefined, this);
66433
+ }
66434
+ return null;
66435
+ })
66436
+ ]
66437
+ }, undefined, true, undefined, this)
66438
+ }, undefined, false, undefined, this)
65340
66439
  ]
65341
66440
  }, undefined, true, undefined, this);
65342
66441
  }
65343
66442
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66443
+ flexDirection: "row",
65344
66444
  children: [
65345
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65346
- children: " "
66445
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66446
+ width: prefixWidth,
66447
+ flexShrink: 0,
66448
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66449
+ children: " "
66450
+ }, undefined, false, undefined, this)
65347
66451
  }, undefined, false, undefined, this),
65348
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65349
- backgroundColor: lineBg,
65350
- color: colors.diff.textOnDark,
65351
- children: `${prefix} ${content}`
66452
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66453
+ flexGrow: 1,
66454
+ width: contentWidth,
66455
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66456
+ backgroundColor: lineBg,
66457
+ color: colors.diff.textOnDark,
66458
+ wrap: "wrap",
66459
+ children: `${prefix} ${content}`
66460
+ }, undefined, false, undefined, this)
65352
66461
  }, undefined, false, undefined, this)
65353
66462
  ]
65354
66463
  }, undefined, true, undefined, this);
@@ -65358,27 +66467,52 @@ function truncate(str, maxLen) {
65358
66467
  return str;
65359
66468
  return `${str.slice(0, maxLen - 1)}…`;
65360
66469
  }
65361
- function PatchDiffRenderer({ label, patch }) {
66470
+ function PatchDiffRenderer({
66471
+ label,
66472
+ patch,
66473
+ columns
66474
+ }) {
65362
66475
  const lines = patch.split(`
65363
66476
  `);
65364
66477
  const maxLines = 8;
65365
66478
  const displayLines = lines.slice(0, maxLines);
65366
66479
  const hasMore = lines.length > maxLines;
66480
+ const prefixWidth = 4;
66481
+ const contentWidth = Math.max(0, columns - prefixWidth);
65367
66482
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65368
66483
  flexDirection: "column",
65369
66484
  children: [
65370
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66485
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66486
+ flexDirection: "row",
65371
66487
  children: [
65372
- " ",
65373
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65374
- dimColor: true,
65375
- children: "⎿"
66488
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66489
+ width: prefixWidth,
66490
+ flexShrink: 0,
66491
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66492
+ children: [
66493
+ " ",
66494
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66495
+ dimColor: true,
66496
+ children: "⎿"
66497
+ }, undefined, false, undefined, this)
66498
+ ]
66499
+ }, undefined, true, undefined, this)
65376
66500
  }, undefined, false, undefined, this),
65377
- " Patched memory block",
65378
- " ",
65379
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65380
- color: colors.tool.memoryName,
65381
- children: label
66501
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66502
+ flexGrow: 1,
66503
+ width: contentWidth,
66504
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66505
+ wrap: "wrap",
66506
+ children: [
66507
+ "Patched memory block",
66508
+ " ",
66509
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66510
+ bold: true,
66511
+ color: colors.tool.memoryName,
66512
+ children: label
66513
+ }, undefined, false, undefined, this)
66514
+ ]
66515
+ }, undefined, true, undefined, this)
65382
66516
  }, undefined, false, undefined, this)
65383
66517
  ]
65384
66518
  }, undefined, true, undefined, this),
@@ -65390,46 +66524,94 @@ function PatchDiffRenderer({ label, patch }) {
65390
66524
  const content = line.slice(1);
65391
66525
  if (firstChar === "+") {
65392
66526
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66527
+ flexDirection: "row",
65393
66528
  children: [
65394
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65395
- children: " "
66529
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66530
+ width: prefixWidth,
66531
+ flexShrink: 0,
66532
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66533
+ children: " "
66534
+ }, undefined, false, undefined, this)
65396
66535
  }, undefined, false, undefined, this),
65397
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65398
- backgroundColor: colors.diff.addedLineBg,
65399
- color: colors.diff.textOnDark,
65400
- children: `+ ${content}`
66536
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66537
+ flexGrow: 1,
66538
+ width: contentWidth,
66539
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66540
+ backgroundColor: colors.diff.addedLineBg,
66541
+ color: colors.diff.textOnDark,
66542
+ wrap: "wrap",
66543
+ children: `+ ${content}`
66544
+ }, undefined, false, undefined, this)
65401
66545
  }, undefined, false, undefined, this)
65402
66546
  ]
65403
66547
  }, `patch-${i}-${line.substring(0, 20)}`, true, undefined, this);
65404
66548
  } else if (firstChar === "-") {
65405
66549
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66550
+ flexDirection: "row",
65406
66551
  children: [
65407
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65408
- children: " "
66552
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66553
+ width: prefixWidth,
66554
+ flexShrink: 0,
66555
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66556
+ children: " "
66557
+ }, undefined, false, undefined, this)
65409
66558
  }, undefined, false, undefined, this),
65410
- /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65411
- backgroundColor: colors.diff.removedLineBg,
65412
- color: colors.diff.textOnDark,
65413
- children: `- ${content}`
66559
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66560
+ flexGrow: 1,
66561
+ width: contentWidth,
66562
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66563
+ backgroundColor: colors.diff.removedLineBg,
66564
+ color: colors.diff.textOnDark,
66565
+ wrap: "wrap",
66566
+ children: `- ${content}`
66567
+ }, undefined, false, undefined, this)
65414
66568
  }, undefined, false, undefined, this)
65415
66569
  ]
65416
66570
  }, `patch-${i}-${line.substring(0, 20)}`, true, undefined, this);
65417
66571
  } else if (firstChar === " ") {
65418
66572
  return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
65419
- children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65420
- dimColor: true,
65421
- children: [
65422
- " ",
65423
- content
65424
- ]
65425
- }, undefined, true, undefined, this)
65426
- }, `patch-${i}-${line.substring(0, 20)}`, false, undefined, this);
66573
+ flexDirection: "row",
66574
+ children: [
66575
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66576
+ width: prefixWidth + 2,
66577
+ flexShrink: 0,
66578
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66579
+ dimColor: true,
66580
+ children: " "
66581
+ }, undefined, false, undefined, this)
66582
+ }, undefined, false, undefined, this),
66583
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66584
+ flexGrow: 1,
66585
+ width: Math.max(0, columns - prefixWidth - 2),
66586
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66587
+ dimColor: true,
66588
+ wrap: "wrap",
66589
+ children: content
66590
+ }, undefined, false, undefined, this)
66591
+ }, undefined, false, undefined, this)
66592
+ ]
66593
+ }, `patch-${i}-${line.substring(0, 20)}`, true, undefined, this);
65427
66594
  }
65428
- return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
65429
- dimColor: true,
66595
+ return /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66596
+ flexDirection: "row",
65430
66597
  children: [
65431
- " ",
65432
- line
66598
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66599
+ width: prefixWidth,
66600
+ flexShrink: 0,
66601
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66602
+ dimColor: true,
66603
+ children: " "
66604
+ }, undefined, false, undefined, this)
66605
+ }, undefined, false, undefined, this),
66606
+ /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Box_default, {
66607
+ flexGrow: 1,
66608
+ width: contentWidth,
66609
+ children: /* @__PURE__ */ jsx_dev_runtime44.jsxDEV(Text, {
66610
+ dimColor: true,
66611
+ wrap: "wrap",
66612
+ children: line
66613
+ }, undefined, false, undefined, this)
66614
+ }, undefined, false, undefined, this)
65433
66615
  ]
65434
66616
  }, `patch-${i}-${line.substring(0, 20)}`, true, undefined, this);
65435
66617
  }),
@@ -65448,6 +66630,7 @@ function PatchDiffRenderer({ label, patch }) {
65448
66630
  var jsx_dev_runtime44;
65449
66631
  var init_MemoryDiffRenderer = __esm(async () => {
65450
66632
  init_libesm();
66633
+ init_useTerminalWidth();
65451
66634
  init_colors();
65452
66635
  await init_build2();
65453
66636
  jsx_dev_runtime44 = __toESM(require_jsx_dev_runtime(), 1);
@@ -65458,18 +66641,31 @@ var jsx_dev_runtime45, PlanRenderer = ({
65458
66641
  plan,
65459
66642
  explanation
65460
66643
  }) => {
66644
+ const columns = useTerminalWidth();
66645
+ const prefixWidth = 5;
66646
+ const contentWidth = Math.max(0, columns - prefixWidth);
65461
66647
  return /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
65462
66648
  flexDirection: "column",
65463
66649
  children: [
65464
66650
  explanation && /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
66651
+ flexDirection: "row",
65465
66652
  children: [
65466
- /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
65467
- children: " ⎿ "
66653
+ /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
66654
+ width: prefixWidth,
66655
+ flexShrink: 0,
66656
+ children: /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
66657
+ children: " ⎿ "
66658
+ }, undefined, false, undefined, this)
65468
66659
  }, undefined, false, undefined, this),
65469
- /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
65470
- italic: true,
65471
- dimColor: true,
65472
- children: explanation
66660
+ /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
66661
+ flexGrow: 1,
66662
+ width: contentWidth,
66663
+ children: /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
66664
+ italic: true,
66665
+ dimColor: true,
66666
+ wrap: "wrap",
66667
+ children: explanation
66668
+ }, undefined, false, undefined, this)
65473
66669
  }, undefined, false, undefined, this)
65474
66670
  ]
65475
66671
  }, undefined, true, undefined, this),
@@ -65480,6 +66676,7 @@ var jsx_dev_runtime45, PlanRenderer = ({
65480
66676
  textElement = /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
65481
66677
  color: colors.todo.completed,
65482
66678
  strikethrough: true,
66679
+ wrap: "wrap",
65483
66680
  children: [
65484
66681
  checkbox,
65485
66682
  " ",
@@ -65490,6 +66687,7 @@ var jsx_dev_runtime45, PlanRenderer = ({
65490
66687
  textElement = /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
65491
66688
  color: colors.todo.inProgress,
65492
66689
  bold: true,
66690
+ wrap: "wrap",
65493
66691
  children: [
65494
66692
  checkbox,
65495
66693
  " ",
@@ -65498,6 +66696,7 @@ var jsx_dev_runtime45, PlanRenderer = ({
65498
66696
  }, undefined, true, undefined, this);
65499
66697
  } else {
65500
66698
  textElement = /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
66699
+ wrap: "wrap",
65501
66700
  children: [
65502
66701
  checkbox,
65503
66702
  " ",
@@ -65507,11 +66706,20 @@ var jsx_dev_runtime45, PlanRenderer = ({
65507
66706
  }
65508
66707
  const prefix = index === 0 && !explanation ? " ⎿ " : " ";
65509
66708
  return /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
66709
+ flexDirection: "row",
65510
66710
  children: [
65511
- /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
65512
- children: prefix
66711
+ /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
66712
+ width: prefixWidth,
66713
+ flexShrink: 0,
66714
+ children: /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Text, {
66715
+ children: prefix
66716
+ }, undefined, false, undefined, this)
65513
66717
  }, undefined, false, undefined, this),
65514
- textElement
66718
+ /* @__PURE__ */ jsx_dev_runtime45.jsxDEV(Box_default, {
66719
+ flexGrow: 1,
66720
+ width: contentWidth,
66721
+ children: textElement
66722
+ }, undefined, false, undefined, this)
65515
66723
  ]
65516
66724
  }, `${index}-${item.step.slice(0, 20)}`, true, undefined, this);
65517
66725
  })
@@ -65519,6 +66727,7 @@ var jsx_dev_runtime45, PlanRenderer = ({
65519
66727
  }, undefined, true, undefined, this);
65520
66728
  };
65521
66729
  var init_PlanRenderer = __esm(async () => {
66730
+ init_useTerminalWidth();
65522
66731
  init_colors();
65523
66732
  await init_build2();
65524
66733
  jsx_dev_runtime45 = __toESM(require_jsx_dev_runtime(), 1);
@@ -65526,6 +66735,9 @@ var init_PlanRenderer = __esm(async () => {
65526
66735
 
65527
66736
  // src/cli/components/TodoRenderer.tsx
65528
66737
  var jsx_dev_runtime46, TodoRenderer = ({ todos }) => {
66738
+ const columns = useTerminalWidth();
66739
+ const prefixWidth = 5;
66740
+ const contentWidth = Math.max(0, columns - prefixWidth);
65529
66741
  return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
65530
66742
  flexDirection: "column",
65531
66743
  children: todos.map((todo, index) => {
@@ -65535,6 +66747,7 @@ var jsx_dev_runtime46, TodoRenderer = ({ todos }) => {
65535
66747
  textElement = /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
65536
66748
  color: colors.todo.completed,
65537
66749
  strikethrough: true,
66750
+ wrap: "wrap",
65538
66751
  children: [
65539
66752
  checkbox,
65540
66753
  " ",
@@ -65545,6 +66758,7 @@ var jsx_dev_runtime46, TodoRenderer = ({ todos }) => {
65545
66758
  textElement = /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
65546
66759
  color: colors.todo.inProgress,
65547
66760
  bold: true,
66761
+ wrap: "wrap",
65548
66762
  children: [
65549
66763
  checkbox,
65550
66764
  " ",
@@ -65553,6 +66767,7 @@ var jsx_dev_runtime46, TodoRenderer = ({ todos }) => {
65553
66767
  }, undefined, true, undefined, this);
65554
66768
  } else {
65555
66769
  textElement = /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
66770
+ wrap: "wrap",
65556
66771
  children: [
65557
66772
  checkbox,
65558
66773
  " ",
@@ -65562,17 +66777,27 @@ var jsx_dev_runtime46, TodoRenderer = ({ todos }) => {
65562
66777
  }
65563
66778
  const prefix = index === 0 ? " ⎿ " : " ";
65564
66779
  return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
66780
+ flexDirection: "row",
65565
66781
  children: [
65566
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
65567
- children: prefix
66782
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
66783
+ width: prefixWidth,
66784
+ flexShrink: 0,
66785
+ children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
66786
+ children: prefix
66787
+ }, undefined, false, undefined, this)
65568
66788
  }, undefined, false, undefined, this),
65569
- textElement
66789
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
66790
+ flexGrow: 1,
66791
+ width: contentWidth,
66792
+ children: textElement
66793
+ }, undefined, false, undefined, this)
65570
66794
  ]
65571
66795
  }, todo.id || index, true, undefined, this);
65572
66796
  })
65573
66797
  }, undefined, false, undefined, this);
65574
66798
  };
65575
66799
  var init_TodoRenderer = __esm(async () => {
66800
+ init_useTerminalWidth();
65576
66801
  init_colors();
65577
66802
  await init_build2();
65578
66803
  jsx_dev_runtime46 = __toESM(require_jsx_dev_runtime(), 1);
@@ -65583,11 +66808,14 @@ var import_react64, jsx_dev_runtime47, ToolCallMessage;
65583
66808
  var init_ToolCallMessageRich = __esm(async () => {
65584
66809
  init_constants();
65585
66810
  init_manager3();
66811
+ init_formatArgsDisplay();
65586
66812
  init_useTerminalWidth();
65587
66813
  init_colors();
65588
66814
  await __promiseAll([
65589
66815
  init_build2(),
66816
+ init_AdvancedDiffRenderer(),
65590
66817
  init_BlinkDot(),
66818
+ init_DiffRenderer(),
65591
66819
  init_MarkdownDisplay(),
65592
66820
  init_MemoryDiffRenderer(),
65593
66821
  init_PlanRenderer(),
@@ -65595,7 +66823,10 @@ var init_ToolCallMessageRich = __esm(async () => {
65595
66823
  ]);
65596
66824
  import_react64 = __toESM(require_react(), 1);
65597
66825
  jsx_dev_runtime47 = __toESM(require_jsx_dev_runtime(), 1);
65598
- ToolCallMessage = import_react64.memo(({ line }) => {
66826
+ ToolCallMessage = import_react64.memo(({
66827
+ line,
66828
+ precomputedDiffs
66829
+ }) => {
65599
66830
  const columns = useTerminalWidth();
65600
66831
  const rawName = line.name ?? "?";
65601
66832
  const argsText = line.argsText ?? "...";
@@ -65605,8 +66836,24 @@ var init_ToolCallMessageRich = __esm(async () => {
65605
66836
  return null;
65606
66837
  }
65607
66838
  }
65608
- const displayName = getDisplayToolName(rawName);
65609
- const formatted = formatArgsDisplay(argsText);
66839
+ let displayName = getDisplayToolName(rawName);
66840
+ if (isPatchTool(rawName)) {
66841
+ try {
66842
+ const parsedArgs = JSON.parse(argsText);
66843
+ if (parsedArgs.input) {
66844
+ const patchInfo = parsePatchInput(parsedArgs.input);
66845
+ if (patchInfo) {
66846
+ if (patchInfo.kind === "add")
66847
+ displayName = "Write";
66848
+ else if (patchInfo.kind === "update")
66849
+ displayName = "Update";
66850
+ else if (patchInfo.kind === "delete")
66851
+ displayName = "Delete";
66852
+ }
66853
+ }
66854
+ } catch {}
66855
+ }
66856
+ const formatted = formatArgsDisplay(argsText, rawName);
65610
66857
  const args = `(${formatted.display})`;
65611
66858
  const rightWidth = Math.max(0, columns - 2);
65612
66859
  const fallback = displayName.length >= rightWidth;
@@ -65739,6 +66986,154 @@ var init_ToolCallMessageRich = __esm(async () => {
65739
66986
  return memoryDiff;
65740
66987
  }
65741
66988
  }
66989
+ if (isFileEditTool(rawName) && line.resultOk !== false && line.argsText) {
66990
+ const diff2 = line.toolCallId ? precomputedDiffs?.get(line.toolCallId) : undefined;
66991
+ try {
66992
+ const parsedArgs = JSON.parse(line.argsText);
66993
+ const filePath = parsedArgs.file_path || "";
66994
+ if (diff2) {
66995
+ if (parsedArgs.edits && Array.isArray(parsedArgs.edits)) {
66996
+ const edits = parsedArgs.edits.map((e) => ({
66997
+ old_string: e.old_string || "",
66998
+ new_string: e.new_string || "",
66999
+ replace_all: e.replace_all
67000
+ }));
67001
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(AdvancedDiffRenderer, {
67002
+ precomputed: diff2,
67003
+ kind: "multi_edit",
67004
+ filePath,
67005
+ edits
67006
+ }, undefined, false, undefined, this);
67007
+ }
67008
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(AdvancedDiffRenderer, {
67009
+ precomputed: diff2,
67010
+ kind: "edit",
67011
+ filePath,
67012
+ oldString: parsedArgs.old_string || "",
67013
+ newString: parsedArgs.new_string || "",
67014
+ replaceAll: parsedArgs.replace_all
67015
+ }, undefined, false, undefined, this);
67016
+ }
67017
+ if (parsedArgs.edits && Array.isArray(parsedArgs.edits)) {
67018
+ const edits = parsedArgs.edits.map((e) => ({
67019
+ old_string: e.old_string || "",
67020
+ new_string: e.new_string || ""
67021
+ }));
67022
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(MultiEditRenderer, {
67023
+ filePath,
67024
+ edits,
67025
+ showLineNumbers: false
67026
+ }, undefined, false, undefined, this);
67027
+ }
67028
+ if (parsedArgs.old_string !== undefined) {
67029
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(EditRenderer, {
67030
+ filePath,
67031
+ oldString: parsedArgs.old_string || "",
67032
+ newString: parsedArgs.new_string || "",
67033
+ showLineNumbers: false
67034
+ }, undefined, false, undefined, this);
67035
+ }
67036
+ } catch {}
67037
+ }
67038
+ if (isFileWriteTool(rawName) && line.resultOk !== false && line.argsText) {
67039
+ const diff2 = line.toolCallId ? precomputedDiffs?.get(line.toolCallId) : undefined;
67040
+ try {
67041
+ const parsedArgs = JSON.parse(line.argsText);
67042
+ const filePath = parsedArgs.file_path || "";
67043
+ const content = parsedArgs.content || "";
67044
+ if (filePath && content) {
67045
+ if (diff2) {
67046
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(AdvancedDiffRenderer, {
67047
+ precomputed: diff2,
67048
+ kind: "write",
67049
+ filePath,
67050
+ content
67051
+ }, undefined, false, undefined, this);
67052
+ }
67053
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(WriteRenderer, {
67054
+ filePath,
67055
+ content
67056
+ }, undefined, false, undefined, this);
67057
+ }
67058
+ } catch {}
67059
+ }
67060
+ if (isPatchTool(rawName) && line.resultOk !== false && line.argsText) {
67061
+ try {
67062
+ const parsedArgs = JSON.parse(line.argsText);
67063
+ if (parsedArgs.input) {
67064
+ const operations = parsePatchOperations(parsedArgs.input);
67065
+ if (operations.length > 0) {
67066
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Box_default, {
67067
+ flexDirection: "column",
67068
+ children: operations.map((op) => {
67069
+ const key = `${line.toolCallId}:${op.path}`;
67070
+ const diff2 = precomputedDiffs?.get(key);
67071
+ if (op.kind === "add") {
67072
+ return diff2 ? /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(AdvancedDiffRenderer, {
67073
+ precomputed: diff2,
67074
+ kind: "write",
67075
+ filePath: op.path,
67076
+ content: op.content
67077
+ }, `patch-add-${op.path}`, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(WriteRenderer, {
67078
+ filePath: op.path,
67079
+ content: op.content
67080
+ }, `patch-add-${op.path}`, false, undefined, this);
67081
+ }
67082
+ if (op.kind === "update") {
67083
+ return diff2 ? /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(AdvancedDiffRenderer, {
67084
+ precomputed: diff2,
67085
+ kind: "edit",
67086
+ filePath: op.path,
67087
+ oldString: op.oldString,
67088
+ newString: op.newString
67089
+ }, `patch-update-${op.path}`, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(EditRenderer, {
67090
+ filePath: op.path,
67091
+ oldString: op.oldString,
67092
+ newString: op.newString,
67093
+ showLineNumbers: false
67094
+ }, `patch-update-${op.path}`, false, undefined, this);
67095
+ }
67096
+ if (op.kind === "delete") {
67097
+ const gutterWidth = 4;
67098
+ return /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Box_default, {
67099
+ flexDirection: "row",
67100
+ children: [
67101
+ /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Box_default, {
67102
+ width: gutterWidth,
67103
+ flexShrink: 0,
67104
+ children: /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67105
+ children: [
67106
+ " ",
67107
+ /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67108
+ dimColor: true,
67109
+ children: "⎿"
67110
+ }, undefined, false, undefined, this)
67111
+ ]
67112
+ }, undefined, true, undefined, this)
67113
+ }, undefined, false, undefined, this),
67114
+ /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Box_default, {
67115
+ flexGrow: 1,
67116
+ children: /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67117
+ wrap: "wrap",
67118
+ children: [
67119
+ "Deleted ",
67120
+ /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67121
+ bold: true,
67122
+ children: op.path
67123
+ }, undefined, false, undefined, this)
67124
+ ]
67125
+ }, undefined, true, undefined, this)
67126
+ }, undefined, false, undefined, this)
67127
+ ]
67128
+ }, `patch-delete-${op.path}`, true, undefined, this);
67129
+ }
67130
+ return null;
67131
+ })
67132
+ }, undefined, false, undefined, this);
67133
+ }
67134
+ }
67135
+ } catch {}
67136
+ }
65742
67137
  const isError = line.resultOk === false;
65743
67138
  let displayText = displayResultText;
65744
67139
  try {
@@ -65797,16 +67192,26 @@ var init_ToolCallMessageRich = __esm(async () => {
65797
67192
  children: isMemoryTool(rawName) ? /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(jsx_dev_runtime47.Fragment, {
65798
67193
  children: [
65799
67194
  /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67195
+ bold: true,
65800
67196
  color: colors.tool.memoryName,
65801
67197
  children: displayName
65802
67198
  }, undefined, false, undefined, this),
65803
67199
  args
65804
67200
  ]
65805
- }, undefined, true, undefined, this) : `${displayName}${args}`
67201
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(jsx_dev_runtime47.Fragment, {
67202
+ children: [
67203
+ /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67204
+ bold: true,
67205
+ children: displayName
67206
+ }, undefined, false, undefined, this),
67207
+ args
67208
+ ]
67209
+ }, undefined, true, undefined, this)
65806
67210
  }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Box_default, {
65807
67211
  flexDirection: "row",
65808
67212
  children: [
65809
67213
  /* @__PURE__ */ jsx_dev_runtime47.jsxDEV(Text, {
67214
+ bold: true,
65810
67215
  color: isMemoryTool(rawName) ? colors.tool.memoryName : undefined,
65811
67216
  children: displayName
65812
67217
  }, undefined, false, undefined, this),
@@ -67083,7 +68488,7 @@ function getPlanModeReminder() {
67083
68488
  Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
67084
68489
 
67085
68490
  ## Plan File Info:
67086
- ${planFilePath ? `No plan file exists yet. You should create your plan at ${planFilePath} using the Write tool.` : "No plan file path assigned."}
68491
+ ${planFilePath ? `No plan file exists yet. You should create your plan at ${planFilePath} using a write tool (e.g. Write, ApplyPatch, etc. depending on your toolset).` : "No plan file path assigned."}
67087
68492
 
67088
68493
  You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
67089
68494
 
@@ -67337,6 +68742,7 @@ function App2({
67337
68742
  const [lines, setLines] = import_react69.useState([]);
67338
68743
  const buffersRef = import_react69.useRef(createBuffers());
67339
68744
  const hasBackfilledRef = import_react69.useRef(false);
68745
+ const precomputedDiffsRef = import_react69.useRef(new Map);
67340
68746
  const refreshDerived = import_react69.useCallback(() => {
67341
68747
  const b = buffersRef.current;
67342
68748
  setTokenCount(b.tokenCount);
@@ -67655,6 +69061,62 @@ function App2({
67655
69061
  autoAllowed.push(ac);
67656
69062
  }
67657
69063
  }
69064
+ for (const ac of autoAllowed) {
69065
+ const toolName = ac.approval.toolName;
69066
+ const toolCallId = ac.approval.toolCallId;
69067
+ try {
69068
+ const args = JSON.parse(ac.approval.toolArgs || "{}");
69069
+ if (isFileWriteTool(toolName)) {
69070
+ const filePath = args.file_path;
69071
+ if (filePath) {
69072
+ const result = computeAdvancedDiff({
69073
+ kind: "write",
69074
+ filePath,
69075
+ content: args.content || ""
69076
+ });
69077
+ if (result.mode === "advanced") {
69078
+ precomputedDiffsRef.current.set(toolCallId, result);
69079
+ }
69080
+ }
69081
+ } else if (isFileEditTool(toolName)) {
69082
+ const filePath = args.file_path;
69083
+ if (filePath) {
69084
+ if (args.edits && Array.isArray(args.edits)) {
69085
+ const result = computeAdvancedDiff({
69086
+ kind: "multi_edit",
69087
+ filePath,
69088
+ edits: args.edits
69089
+ });
69090
+ if (result.mode === "advanced") {
69091
+ precomputedDiffsRef.current.set(toolCallId, result);
69092
+ }
69093
+ } else {
69094
+ const result = computeAdvancedDiff({
69095
+ kind: "edit",
69096
+ filePath,
69097
+ oldString: args.old_string || "",
69098
+ newString: args.new_string || "",
69099
+ replaceAll: args.replace_all
69100
+ });
69101
+ if (result.mode === "advanced") {
69102
+ precomputedDiffsRef.current.set(toolCallId, result);
69103
+ }
69104
+ }
69105
+ }
69106
+ } else if (isPatchTool(toolName) && args.input) {
69107
+ const operations = parsePatchOperations(args.input);
69108
+ for (const op of operations) {
69109
+ const key = `${toolCallId}:${op.path}`;
69110
+ if (op.kind === "add" || op.kind === "update") {
69111
+ const result = parsePatchToAdvancedDiff(op.patchLines, op.path);
69112
+ if (result) {
69113
+ precomputedDiffsRef.current.set(key, result);
69114
+ }
69115
+ }
69116
+ }
69117
+ }
69118
+ } catch {}
69119
+ }
67658
69120
  const autoAllowedResults = await executeAutoAllowedTools(autoAllowed, (chunk) => onChunk(buffersRef.current, chunk));
67659
69121
  const autoDeniedResults = autoDenied.map((ac) => {
67660
69122
  const reason = ac.permission.reason ? `Permission denied: ${ac.permission.reason}` : ("matchedRule" in ac.permission) && ac.permission.matchedRule ? `Permission denied by rule: ${ac.permission.matchedRule}` : "Permission denied: Unknown reason";
@@ -69397,6 +70859,62 @@ DO NOT respond to these messages or otherwise consider them in your response unl
69397
70859
  }
69398
70860
  }
69399
70861
  if (needsUserInput.length === 0) {
70862
+ for (const ac of autoAllowed) {
70863
+ const toolName = ac.approval.toolName;
70864
+ const toolCallId = ac.approval.toolCallId;
70865
+ try {
70866
+ const args = JSON.parse(ac.approval.toolArgs || "{}");
70867
+ if (isFileWriteTool(toolName)) {
70868
+ const filePath = args.file_path;
70869
+ if (filePath) {
70870
+ const result = computeAdvancedDiff({
70871
+ kind: "write",
70872
+ filePath,
70873
+ content: args.content || ""
70874
+ });
70875
+ if (result.mode === "advanced") {
70876
+ precomputedDiffsRef.current.set(toolCallId, result);
70877
+ }
70878
+ }
70879
+ } else if (isFileEditTool(toolName)) {
70880
+ const filePath = args.file_path;
70881
+ if (filePath) {
70882
+ if (args.edits && Array.isArray(args.edits)) {
70883
+ const result = computeAdvancedDiff({
70884
+ kind: "multi_edit",
70885
+ filePath,
70886
+ edits: args.edits
70887
+ });
70888
+ if (result.mode === "advanced") {
70889
+ precomputedDiffsRef.current.set(toolCallId, result);
70890
+ }
70891
+ } else {
70892
+ const result = computeAdvancedDiff({
70893
+ kind: "edit",
70894
+ filePath,
70895
+ oldString: args.old_string || "",
70896
+ newString: args.new_string || "",
70897
+ replaceAll: args.replace_all
70898
+ });
70899
+ if (result.mode === "advanced") {
70900
+ precomputedDiffsRef.current.set(toolCallId, result);
70901
+ }
70902
+ }
70903
+ }
70904
+ } else if (isPatchTool(toolName) && args.input) {
70905
+ const operations = parsePatchOperations(args.input);
70906
+ for (const op of operations) {
70907
+ const key = `${toolCallId}:${op.path}`;
70908
+ if (op.kind === "add" || op.kind === "update") {
70909
+ const result = parsePatchToAdvancedDiff(op.patchLines, op.path);
70910
+ if (result) {
70911
+ precomputedDiffsRef.current.set(key, result);
70912
+ }
70913
+ }
70914
+ }
70915
+ }
70916
+ } catch {}
70917
+ }
69400
70918
  const autoAllowedResults = await executeAutoAllowedTools(autoAllowed, (chunk) => onChunk(buffersRef.current, chunk));
69401
70919
  const autoDeniedResults = autoDenied.map((ac) => {
69402
70920
  const reason = ac.permission.reason ? `Permission denied: ${ac.permission.reason}` : ("matchedRule" in ac.permission) && ac.permission.matchedRule ? `Permission denied by rule: ${ac.permission.matchedRule}` : "Permission denied: Unknown";
@@ -69450,6 +70968,62 @@ DO NOT respond to these messages or otherwise consider them in your response unl
69450
70968
  setStreaming(false);
69451
70969
  setPendingApprovals(needsUserInput.map((ac) => ac.approval));
69452
70970
  setApprovalContexts(needsUserInput.map((ac) => ac.context).filter(Boolean));
70971
+ for (const ac of autoAllowed) {
70972
+ const toolName = ac.approval.toolName;
70973
+ const toolCallId = ac.approval.toolCallId;
70974
+ try {
70975
+ const args = JSON.parse(ac.approval.toolArgs || "{}");
70976
+ if (isFileWriteTool(toolName)) {
70977
+ const filePath = args.file_path;
70978
+ if (filePath) {
70979
+ const result = computeAdvancedDiff({
70980
+ kind: "write",
70981
+ filePath,
70982
+ content: args.content || ""
70983
+ });
70984
+ if (result.mode === "advanced") {
70985
+ precomputedDiffsRef.current.set(toolCallId, result);
70986
+ }
70987
+ }
70988
+ } else if (isFileEditTool(toolName)) {
70989
+ const filePath = args.file_path;
70990
+ if (filePath) {
70991
+ if (args.edits && Array.isArray(args.edits)) {
70992
+ const result = computeAdvancedDiff({
70993
+ kind: "multi_edit",
70994
+ filePath,
70995
+ edits: args.edits
70996
+ });
70997
+ if (result.mode === "advanced") {
70998
+ precomputedDiffsRef.current.set(toolCallId, result);
70999
+ }
71000
+ } else {
71001
+ const result = computeAdvancedDiff({
71002
+ kind: "edit",
71003
+ filePath,
71004
+ oldString: args.old_string || "",
71005
+ newString: args.new_string || "",
71006
+ replaceAll: args.replace_all
71007
+ });
71008
+ if (result.mode === "advanced") {
71009
+ precomputedDiffsRef.current.set(toolCallId, result);
71010
+ }
71011
+ }
71012
+ }
71013
+ } else if (isPatchTool(toolName) && args.input) {
71014
+ const operations = parsePatchOperations(args.input);
71015
+ for (const op of operations) {
71016
+ const key = `${toolCallId}:${op.path}`;
71017
+ if (op.kind === "add" || op.kind === "update") {
71018
+ const result = parsePatchToAdvancedDiff(op.patchLines, op.path);
71019
+ if (result) {
71020
+ precomputedDiffsRef.current.set(key, result);
71021
+ }
71022
+ }
71023
+ }
71024
+ }
71025
+ } catch {}
71026
+ }
69453
71027
  const autoAllowedWithResults = await executeAutoAllowedTools(autoAllowed, (chunk) => onChunk(buffersRef.current, chunk));
69454
71028
  const autoDeniedWithReasons = autoDenied.map((ac) => {
69455
71029
  const reason = ac.permission.reason ? `Permission denied: ${ac.permission.reason}` : ("matchedRule" in ac.permission) && ac.permission.matchedRule ? `Permission denied by rule: ${ac.permission.matchedRule}` : "Permission denied: Unknown";
@@ -69633,13 +71207,18 @@ DO NOT respond to these messages or otherwise consider them in your response unl
69633
71207
  appendError,
69634
71208
  setStreaming
69635
71209
  ]);
69636
- const handleApproveCurrent = import_react69.useCallback(async () => {
71210
+ const handleApproveCurrent = import_react69.useCallback(async (diffs) => {
69637
71211
  if (isExecutingTool)
69638
71212
  return;
69639
71213
  const currentIndex = approvalResults.length;
69640
71214
  const currentApproval2 = pendingApprovals[currentIndex];
69641
71215
  if (!currentApproval2)
69642
71216
  return;
71217
+ if (diffs) {
71218
+ for (const [key, diff2] of diffs) {
71219
+ precomputedDiffsRef.current.set(key, diff2);
71220
+ }
71221
+ }
69643
71222
  setIsExecutingTool(true);
69644
71223
  try {
69645
71224
  const decision = {
@@ -69667,7 +71246,7 @@ DO NOT respond to these messages or otherwise consider them in your response unl
69667
71246
  isExecutingTool,
69668
71247
  setStreaming
69669
71248
  ]);
69670
- const handleApproveAlways = import_react69.useCallback(async (scope) => {
71249
+ const handleApproveAlways = import_react69.useCallback(async (scope, diffs) => {
69671
71250
  if (isExecutingTool)
69672
71251
  return;
69673
71252
  if (pendingApprovals.length === 0 || approvalContexts.length === 0)
@@ -69689,7 +71268,7 @@ DO NOT respond to these messages or otherwise consider them in your response unl
69689
71268
  });
69690
71269
  buffersRef.current.order.push(cmdId);
69691
71270
  refreshDerived();
69692
- await handleApproveCurrent();
71271
+ await handleApproveCurrent(diffs);
69693
71272
  }, [
69694
71273
  approvalResults,
69695
71274
  approvalContexts,
@@ -70107,7 +71686,7 @@ Consider switching to a different system prompt using /system to match.` : null;
70107
71686
  const planFilePath = permissionMode2.getPlanFilePath();
70108
71687
  handlePlanKeepPlanning(`You must write your plan to the plan file before exiting plan mode.
70109
71688
  ` + `Plan file path: ${planFilePath || "not set"}
70110
- ` + `Use the Write tool to create your plan, then call ExitPlanMode again.`);
71689
+ ` + `Use a write tool (e.g. Write, ApplyPatch, etc.) to create your plan, then call ExitPlanMode again.`);
70111
71690
  }
70112
71691
  }, [pendingApprovals, approvalResults.length, handlePlanKeepPlanning]);
70113
71692
  const handleQuestionSubmit = import_react69.useCallback(async (answers) => {
@@ -70303,7 +71882,8 @@ Plan file path: ${planFilePath}`;
70303
71882
  }, undefined, false, undefined, this) : item.kind === "assistant" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(AssistantMessage, {
70304
71883
  line: item
70305
71884
  }, undefined, false, undefined, this) : item.kind === "tool_call" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ToolCallMessage, {
70306
- line: item
71885
+ line: item,
71886
+ precomputedDiffs: precomputedDiffsRef.current
70307
71887
  }, undefined, false, undefined, this) : item.kind === "subagent_group" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(SubagentGroupStatic, {
70308
71888
  agents: item.agents
70309
71889
  }, undefined, false, undefined, this) : item.kind === "error" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ErrorMessage, {
@@ -70342,7 +71922,8 @@ Plan file path: ${planFilePath}`;
70342
71922
  }, undefined, false, undefined, this) : ln.kind === "assistant" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(AssistantMessage, {
70343
71923
  line: ln
70344
71924
  }, undefined, false, undefined, this) : ln.kind === "tool_call" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ToolCallMessage, {
70345
- line: ln
71925
+ line: ln,
71926
+ precomputedDiffs: precomputedDiffsRef.current
70346
71927
  }, undefined, false, undefined, this) : ln.kind === "error" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ErrorMessage, {
70347
71928
  line: ln
70348
71929
  }, undefined, false, undefined, this) : ln.kind === "status" ? /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(StatusMessage, {
@@ -70355,11 +71936,9 @@ Plan file path: ${planFilePath}`;
70355
71936
  }, ln.id, false, undefined, this))
70356
71937
  }, undefined, false, undefined, this),
70357
71938
  /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(SubagentGroupDisplay, {}, undefined, false, undefined, this),
70358
- liveItems.length === 0 && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
70359
- height: 1
70360
- }, undefined, false, undefined, this),
70361
71939
  showExitStats && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
70362
71940
  flexDirection: "column",
71941
+ marginTop: 1,
70363
71942
  children: [
70364
71943
  /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Text, {
70365
71944
  dimColor: true,
@@ -70372,7 +71951,7 @@ Plan file path: ${planFilePath}`;
70372
71951
  children: "Resume this agent with:"
70373
71952
  }, undefined, false, undefined, this),
70374
71953
  /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Text, {
70375
- color: "blue",
71954
+ color: colors.link.url,
70376
71955
  children: [
70377
71956
  "letta --agent ",
70378
71957
  agentId
@@ -70380,25 +71959,28 @@ Plan file path: ${planFilePath}`;
70380
71959
  }, undefined, true, undefined, this)
70381
71960
  ]
70382
71961
  }, undefined, true, undefined, this),
70383
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Input, {
70384
- visible: !showExitStats && pendingApprovals.length === 0 && !anySelectorOpen,
70385
- streaming: streaming && !abortControllerRef.current?.signal.aborted,
70386
- tokenCount,
70387
- thinkingMessage,
70388
- onSubmit,
70389
- onBashSubmit: handleBashSubmit,
70390
- permissionMode: uiPermissionMode,
70391
- onPermissionModeChange: handlePermissionModeChange,
70392
- onExit: handleExit,
70393
- onInterrupt: handleInterrupt,
70394
- interruptRequested,
70395
- agentId,
70396
- agentName,
70397
- currentModel: currentModelDisplay,
70398
- currentModelProvider,
70399
- messageQueue,
70400
- onEnterQueueEditMode: handleEnterQueueEditMode,
70401
- onEscapeCancel: profileConfirmPending ? handleProfileEscapeCancel : undefined
71962
+ /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
71963
+ marginTop: liveItems.length > 0 ? 0 : 1,
71964
+ children: /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Input, {
71965
+ visible: !showExitStats && pendingApprovals.length === 0 && !anySelectorOpen,
71966
+ streaming: streaming && !abortControllerRef.current?.signal.aborted,
71967
+ tokenCount,
71968
+ thinkingMessage,
71969
+ onSubmit,
71970
+ onBashSubmit: handleBashSubmit,
71971
+ permissionMode: uiPermissionMode,
71972
+ onPermissionModeChange: handlePermissionModeChange,
71973
+ onExit: handleExit,
71974
+ onInterrupt: handleInterrupt,
71975
+ interruptRequested,
71976
+ agentId,
71977
+ agentName,
71978
+ currentModel: currentModelDisplay,
71979
+ currentModelProvider,
71980
+ messageQueue,
71981
+ onEnterQueueEditMode: handleEnterQueueEditMode,
71982
+ onEscapeCancel: profileConfirmPending ? handleProfileEscapeCancel : undefined
71983
+ }, undefined, false, undefined, this)
70402
71984
  }, undefined, false, undefined, this),
70403
71985
  activeOverlay === "model" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ModelSelector, {
70404
71986
  currentModelId: currentModelId ?? undefined,
@@ -70571,64 +72153,36 @@ Plan file path: ${planFilePath}`;
70571
72153
  },
70572
72154
  onCancel: closeOverlay
70573
72155
  }, undefined, false, undefined, this),
70574
- currentApproval?.toolName === "ExitPlanMode" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(jsx_dev_runtime50.Fragment, {
70575
- children: [
70576
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
70577
- height: 1
70578
- }, undefined, false, undefined, this),
70579
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(PlanModeDialog, {
70580
- plan: readPlanFile(),
70581
- onApprove: () => handlePlanApprove(false),
70582
- onApproveAndAcceptEdits: () => handlePlanApprove(true),
70583
- onKeepPlanning: handlePlanKeepPlanning
70584
- }, undefined, false, undefined, this)
70585
- ]
70586
- }, undefined, true, undefined, this),
70587
- currentApproval?.toolName === "AskUserQuestion" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(jsx_dev_runtime50.Fragment, {
70588
- children: [
70589
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
70590
- height: 1
70591
- }, undefined, false, undefined, this),
70592
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(QuestionDialog, {
70593
- questions: getQuestionsFromApproval(currentApproval),
70594
- onSubmit: handleQuestionSubmit
70595
- }, undefined, false, undefined, this)
70596
- ]
70597
- }, undefined, true, undefined, this),
70598
- currentApproval?.toolName === "EnterPlanMode" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(jsx_dev_runtime50.Fragment, {
70599
- children: [
70600
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
70601
- height: 1
70602
- }, undefined, false, undefined, this),
70603
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(EnterPlanModeDialog, {
70604
- onApprove: handleEnterPlanModeApprove,
70605
- onReject: handleEnterPlanModeReject
70606
- }, undefined, false, undefined, this)
70607
- ]
70608
- }, undefined, true, undefined, this),
70609
- currentApproval && !isFancyUITool(currentApproval.toolName) && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(jsx_dev_runtime50.Fragment, {
70610
- children: [
70611
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(Box_default, {
70612
- height: 1
70613
- }, undefined, false, undefined, this),
70614
- /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ApprovalDialog, {
70615
- approvals: [currentApproval],
70616
- approvalContexts: approvalContexts[approvalResults.length] ? [
70617
- approvalContexts[approvalResults.length]
70618
- ] : [],
70619
- progress: {
70620
- current: approvalResults.length + 1,
70621
- total: pendingApprovals.length
70622
- },
70623
- totalTools: autoHandledResults.length + pendingApprovals.length,
70624
- isExecuting: isExecutingTool,
70625
- onApproveAll: handleApproveCurrent,
70626
- onApproveAlways: handleApproveAlways,
70627
- onDenyAll: handleDenyCurrent,
70628
- onCancel: handleCancelApprovals
70629
- }, undefined, false, undefined, this)
70630
- ]
70631
- }, undefined, true, undefined, this)
72156
+ currentApproval?.toolName === "ExitPlanMode" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(PlanModeDialog, {
72157
+ plan: readPlanFile(),
72158
+ onApprove: () => handlePlanApprove(false),
72159
+ onApproveAndAcceptEdits: () => handlePlanApprove(true),
72160
+ onKeepPlanning: handlePlanKeepPlanning
72161
+ }, undefined, false, undefined, this),
72162
+ currentApproval?.toolName === "AskUserQuestion" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(QuestionDialog, {
72163
+ questions: getQuestionsFromApproval(currentApproval),
72164
+ onSubmit: handleQuestionSubmit
72165
+ }, undefined, false, undefined, this),
72166
+ currentApproval?.toolName === "EnterPlanMode" && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(EnterPlanModeDialog, {
72167
+ onApprove: handleEnterPlanModeApprove,
72168
+ onReject: handleEnterPlanModeReject
72169
+ }, undefined, false, undefined, this),
72170
+ currentApproval && !isFancyUITool(currentApproval.toolName) && /* @__PURE__ */ jsx_dev_runtime50.jsxDEV(ApprovalDialog, {
72171
+ approvals: [currentApproval],
72172
+ approvalContexts: approvalContexts[approvalResults.length] ? [
72173
+ approvalContexts[approvalResults.length]
72174
+ ] : [],
72175
+ progress: {
72176
+ current: approvalResults.length + 1,
72177
+ total: pendingApprovals.length
72178
+ },
72179
+ totalTools: autoHandledResults.length + pendingApprovals.length,
72180
+ isExecuting: isExecutingTool,
72181
+ onApproveAll: handleApproveCurrent,
72182
+ onApproveAlways: handleApproveAlways,
72183
+ onDenyAll: handleDenyCurrent,
72184
+ onCancel: handleCancelApprovals
72185
+ }, undefined, false, undefined, this)
70632
72186
  ]
70633
72187
  }, undefined, true, undefined, this)
70634
72188
  ]
@@ -70653,9 +72207,12 @@ var init_App2 = __esm(async () => {
70653
72207
  init_manager3();
70654
72208
  init_mcp();
70655
72209
  init_profile();
72210
+ init_colors();
70656
72211
  init_SessionStats();
70657
72212
  init_accumulator();
72213
+ init_diff2();
70658
72214
  init_errorFormatter();
72215
+ init_formatArgsDisplay();
70659
72216
  init_memoryReminder();
70660
72217
  init_pasteRegistry();
70661
72218
  init_planName();
@@ -71909,16 +73466,26 @@ class PermissionModeManager {
71909
73466
  "Write",
71910
73467
  "Edit",
71911
73468
  "MultiEdit",
71912
- "NotebookEdit",
71913
73469
  "apply_patch",
71914
- "ApplyPatch"
73470
+ "ApplyPatch",
73471
+ "write_file_gemini",
73472
+ "WriteFileGemini",
73473
+ "replace",
73474
+ "Replace"
71915
73475
  ];
71916
73476
  if (allowedInPlan.includes(toolName)) {
71917
73477
  return "allow";
71918
73478
  }
71919
73479
  if (writeTools.includes(toolName)) {
71920
73480
  const planFilePath = this.getPlanFilePath();
71921
- const targetPath = toolArgs?.file_path || toolArgs?.path;
73481
+ let targetPath = toolArgs?.file_path || toolArgs?.path;
73482
+ if ((toolName === "ApplyPatch" || toolName === "apply_patch") && toolArgs?.input) {
73483
+ const input = toolArgs.input;
73484
+ const match = input.match(/\*\*\* (?:Add|Update|Delete) File:\s*(.+)/);
73485
+ if (match?.[1]) {
73486
+ targetPath = match[1].trim();
73487
+ }
73488
+ }
71922
73489
  if (planFilePath && targetPath && targetPath === planFilePath) {
71923
73490
  return "allow";
71924
73491
  }
@@ -73304,4 +74871,4 @@ Error during initialization: ${message}`);
73304
74871
  }
73305
74872
  main();
73306
74873
 
73307
- //# debugId=36BBA221BCCDEE8B64756E2164756E21
74874
+ //# debugId=87E9178478E6BF4964756E2164756E21