@bastani/atomic 0.9.20-alpha.7 → 0.9.20-alpha.8

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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  7. package/dist/builtin/workflows/package.json +1 -1
  8. package/dist/builtin/workflows/src/extension/index.bundle.mjs +142 -116
  9. package/dist/core/fast-model-variants.d.ts +10 -0
  10. package/dist/core/fast-model-variants.d.ts.map +1 -1
  11. package/dist/core/fast-model-variants.js +13 -1
  12. package/dist/core/fast-model-variants.js.map +1 -1
  13. package/dist/core/skill-catalog.d.ts.map +1 -1
  14. package/dist/core/skill-catalog.js +18 -6
  15. package/dist/core/skill-catalog.js.map +1 -1
  16. package/dist/core/tools/bash.d.ts.map +1 -1
  17. package/dist/core/tools/bash.js +15 -13
  18. package/dist/core/tools/bash.js.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  24. package/dist/modes/interactive/components/atomic-banner.js +3 -2
  25. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  26. package/dist/modes/interactive/components/startup-identity.d.ts +3 -0
  27. package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
  28. package/dist/modes/interactive/components/startup-identity.js +11 -2
  29. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  30. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  31. package/dist/modes/interactive/interactive-tui.js +2 -0
  32. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  33. package/dist/modes/interactive/overlay-line-composite.d.ts +7 -0
  34. package/dist/modes/interactive/overlay-line-composite.d.ts.map +1 -0
  35. package/dist/modes/interactive/overlay-line-composite.js +24 -0
  36. package/dist/modes/interactive/overlay-line-composite.js.map +1 -0
  37. package/dist/utils/child-process.d.ts +1 -0
  38. package/dist/utils/child-process.d.ts.map +1 -1
  39. package/dist/utils/child-process.js +7 -8
  40. package/dist/utils/child-process.js.map +1 -1
  41. package/dist/utils/shell.d.ts.map +1 -1
  42. package/dist/utils/shell.js +18 -1
  43. package/dist/utils/shell.js.map +1 -1
  44. package/docs/providers.md +4 -1
  45. package/npm-shrinkwrap.json +32 -32
  46. package/package.json +3 -3
@@ -70884,45 +70884,7 @@ function currentWorkflowStore() {
70884
70884
  }
70885
70885
 
70886
70886
  // dist/builtin/workflows/src/tui/color-utils.ts
70887
- import { Text, truncateToWidth } from "@earendil-works/pi-tui";
70888
- function parseHex(hex) {
70889
- const h = hex.replace(/^#/, "");
70890
- const r = parseInt(h.slice(0, 2), 16);
70891
- const g = parseInt(h.slice(2, 4), 16);
70892
- const b = parseInt(h.slice(4, 6), 16);
70893
- return [r, g, b];
70894
- }
70895
- function toHex(r, g, b) {
70896
- const clamp = (v) => Math.max(0, Math.min(255, Math.round(v)));
70897
- return `#${[clamp(r), clamp(g), clamp(b)].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
70898
- }
70899
- function lerpColor(a, b, t) {
70900
- const [ar, ag, ab] = parseHex(a);
70901
- const [br, bg, bb] = parseHex(b);
70902
- const r = ar + (br - ar) * t;
70903
- const g = ag + (bg - ag) * t;
70904
- const bl = ab + (bb - ab) * t;
70905
- return toHex(r, g, bl);
70906
- }
70907
- function hexToAnsi(hex) {
70908
- const [r, g, b] = parseHex(hex);
70909
- return `\x1B[38;2;${r};${g};${b}m`;
70910
- }
70911
- function hexBg(hex) {
70912
- const [r, g, b] = parseHex(hex);
70913
- return `\x1B[48;2;${r};${g};${b}m`;
70914
- }
70915
- var DEFAULT_BG = "\x1B[49m";
70916
- var RESET = "\x1B[0m";
70917
- var BOLD = "\x1B[1m";
70918
- function fillBackground(text, width, background) {
70919
- return new Text(truncateToWidth(text, width, "…"), 0, 0, (line) => `${background}${line.replace(/\x1b\[(?:0|49)?m/g, (reset) => reset + background)}${RESET}`).render(width)[0] ?? "";
70920
- }
70921
- function paint(text, fg, opts = {}) {
70922
- const bgSeq = opts.bg ? hexBg(opts.bg) : "";
70923
- const boldSeq = opts.bold ? BOLD : "";
70924
- return `${bgSeq}${hexToAnsi(fg)}${boldSeq}${text}${RESET}`;
70925
- }
70887
+ import { Text, truncateToWidth as truncateToWidth2 } from "@earendil-works/pi-tui";
70926
70888
 
70927
70889
  // dist/builtin/workflows/src/tui/text-helpers.ts
70928
70890
  import {
@@ -70947,9 +70909,29 @@ function readAnsiCode(text, offset) {
70947
70909
  const match = ANSI_ESCAPE_RE.exec(text.slice(offset));
70948
70910
  return match?.[0] ?? null;
70949
70911
  }
70950
- function truncateToWidth2(text, width, suffix = "", _preserveAnsi = false) {
70912
+ function truncateToWidth(text, width, suffix = "", _preserveAnsi = false) {
70913
+ if (width > 0 && visibleWidth(text) <= width)
70914
+ return text;
70951
70915
  return piTruncateToWidth(text, width, suffix, false);
70952
70916
  }
70917
+
70918
+ class BoundedTextCache {
70919
+ entries = new Map;
70920
+ limit;
70921
+ constructor(limit) {
70922
+ this.limit = limit;
70923
+ }
70924
+ get(key, compute) {
70925
+ const cached = this.entries.get(key);
70926
+ if (cached !== undefined)
70927
+ return cached;
70928
+ const value2 = compute();
70929
+ if (this.entries.size >= this.limit)
70930
+ this.entries.clear();
70931
+ this.entries.set(key, value2);
70932
+ return value2;
70933
+ }
70934
+ }
70953
70935
  function matchesKey(data, key) {
70954
70936
  return data === key || piMatchesKey(data, key);
70955
70937
  }
@@ -71019,7 +71001,7 @@ function renderWrappedPrefixedLines(opts) {
71019
71001
  return wrapPlainText(opts.text, textBudget).map((line, index) => {
71020
71002
  const prefix = index === 0 ? opts.firstPrefix : continuationPrefix;
71021
71003
  const styled = opts.styleLine ? opts.styleLine(line, index) : line;
71022
- return truncateToWidth2(prefix + styled, opts.width, opts.suffix ?? "…", opts.preserveAnsi ?? true);
71004
+ return truncateToWidth(prefix + styled, opts.width, opts.suffix ?? "…", opts.preserveAnsi ?? true);
71023
71005
  });
71024
71006
  }
71025
71007
  function sliceColumns(line, startCol, length, strict = false) {
@@ -71067,6 +71049,49 @@ function sliceColumns(line, startCol, length, strict = false) {
71067
71049
  return result;
71068
71050
  }
71069
71051
 
71052
+ // dist/builtin/workflows/src/tui/color-utils.ts
71053
+ var filledBackgroundLines = new BoundedTextCache(1024);
71054
+ function parseHex(hex) {
71055
+ const h = hex.replace(/^#/, "");
71056
+ const r = parseInt(h.slice(0, 2), 16);
71057
+ const g = parseInt(h.slice(2, 4), 16);
71058
+ const b = parseInt(h.slice(4, 6), 16);
71059
+ return [r, g, b];
71060
+ }
71061
+ function toHex(r, g, b) {
71062
+ const clamp = (v) => Math.max(0, Math.min(255, Math.round(v)));
71063
+ return `#${[clamp(r), clamp(g), clamp(b)].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
71064
+ }
71065
+ function lerpColor(a, b, t) {
71066
+ const [ar, ag, ab] = parseHex(a);
71067
+ const [br, bg, bb] = parseHex(b);
71068
+ const r = ar + (br - ar) * t;
71069
+ const g = ag + (bg - ag) * t;
71070
+ const bl = ab + (bb - ab) * t;
71071
+ return toHex(r, g, bl);
71072
+ }
71073
+ function hexToAnsi(hex) {
71074
+ const [r, g, b] = parseHex(hex);
71075
+ return `\x1B[38;2;${r};${g};${b}m`;
71076
+ }
71077
+ function hexBg(hex) {
71078
+ const [r, g, b] = parseHex(hex);
71079
+ return `\x1B[48;2;${r};${g};${b}m`;
71080
+ }
71081
+ var DEFAULT_BG = "\x1B[49m";
71082
+ var RESET = "\x1B[0m";
71083
+ var BOLD = "\x1B[1m";
71084
+ function fillBackground(text, width, background) {
71085
+ return filledBackgroundLines.get(`${width}\x00${background}\x00${text}`, () => {
71086
+ return new Text(truncateToWidth2(text, width, "…"), 0, 0, (line) => `${background}${line.replace(/\x1b\[(?:0|49)?m/g, (reset) => reset + background)}${RESET}`).render(width)[0] ?? "";
71087
+ });
71088
+ }
71089
+ function paint(text, fg, opts = {}) {
71090
+ const bgSeq = opts.bg ? hexBg(opts.bg) : "";
71091
+ const boldSeq = opts.bold ? BOLD : "";
71092
+ return `${bgSeq}${hexToAnsi(fg)}${boldSeq}${text}${RESET}`;
71093
+ }
71094
+
71070
71095
  // dist/builtin/workflows/src/tui/chat-surface.ts
71071
71096
  var ELLIPSIS = "…";
71072
71097
  var DEFAULT_WIDTH = 80;
@@ -71093,12 +71118,12 @@ function renderRoundedBoxLines(opts) {
71093
71118
  const border = theme ? hexToAnsi(opts.accent ?? theme.border) : "";
71094
71119
  const reset = theme ? RESET : "";
71095
71120
  const titleBudget = Math.max(0, inner - 2);
71096
- const titleText = opts.title && opts.title.length > 0 ? ` ${truncateToWidth2(opts.title, titleBudget, ELLIPSIS)} ` : "";
71121
+ const titleText = opts.title && opts.title.length > 0 ? ` ${truncateToWidth(opts.title, titleBudget, ELLIPSIS)} ` : "";
71097
71122
  const topFill = Math.max(0, inner - visibleWidth(titleText));
71098
71123
  const top = `${border}╭${titleText}${border}${"─".repeat(topFill)}╮${reset}`;
71099
71124
  const body = opts.bodyLines.length > 0 ? opts.bodyLines : [""];
71100
71125
  const rows = body.map((line) => {
71101
- const clipped = truncateToWidth2(line, inner, ELLIPSIS, theme !== undefined);
71126
+ const clipped = truncateToWidth(line, inner, ELLIPSIS, theme !== undefined);
71102
71127
  const pad = Math.max(0, inner - visibleWidth(clipped));
71103
71128
  return `${border}│${reset}${clipped}${" ".repeat(pad)}${border}│${reset}`;
71104
71129
  });
@@ -71299,7 +71324,7 @@ function renderDispatchHintRows(id, width, theme) {
71299
71324
  } else {
71300
71325
  rows.push({
71301
71326
  prefix: continuation,
71302
- chunk: truncateToWidth2(suffix.trimStart(), Math.max(1, budget - visibleWidth(continuation)), ELLIPSIS)
71327
+ chunk: truncateToWidth(suffix.trimStart(), Math.max(1, budget - visibleWidth(continuation)), ELLIPSIS)
71303
71328
  });
71304
71329
  }
71305
71330
  if (!theme)
@@ -71347,7 +71372,7 @@ function renderInputsSegment(inputs, budget, theme) {
71347
71372
  return { rendered, visibleWidth: totalW, fitted: true };
71348
71373
  }
71349
71374
  const flat = entries.map(([k, v]) => `${k}=${renderInputValue(v, valueBudget)}`).join(", ");
71350
- const cut = truncateToWidth2(flat, Math.max(8, budget), ELLIPSIS);
71375
+ const cut = truncateToWidth(flat, Math.max(8, budget), ELLIPSIS);
71351
71376
  if (!theme)
71352
71377
  return { rendered: cut, visibleWidth: visibleWidth(cut), fitted: false };
71353
71378
  return {
@@ -71363,7 +71388,7 @@ function toSingleLine(value2) {
71363
71388
  function renderInputValue(value2, budget) {
71364
71389
  if (typeof value2 === "string") {
71365
71390
  const interior = Math.max(0, budget - 2);
71366
- const trimmed = truncateToWidth2(toSingleLine(value2), interior, ELLIPSIS);
71391
+ const trimmed = truncateToWidth(toSingleLine(value2), interior, ELLIPSIS);
71367
71392
  return `"${trimmed}"`;
71368
71393
  }
71369
71394
  if (typeof value2 === "number" || typeof value2 === "boolean") {
@@ -71372,7 +71397,7 @@ function renderInputValue(value2, budget) {
71372
71397
  if (value2 === null)
71373
71398
  return "null";
71374
71399
  const json = JSON.stringify(value2);
71375
- return truncateToWidth2(toSingleLine(json ?? ""), budget, ELLIPSIS);
71400
+ return truncateToWidth(toSingleLine(json ?? ""), budget, ELLIPSIS);
71376
71401
  }
71377
71402
  function effectiveWidth(width) {
71378
71403
  return chatWidth(width);
@@ -71664,7 +71689,7 @@ function renderPlain(detail, now, width, resolveOwningRunStatus, resolveBoundary
71664
71689
  for (const [k, v] of summaryRows(detail, now)) {
71665
71690
  if (v === undefined)
71666
71691
  continue;
71667
- const value2 = truncateToWidth2(v, Math.max(1, width - 4 - KEY_COL), "…");
71692
+ const value2 = truncateToWidth(v, Math.max(1, width - 4 - KEY_COL), "…");
71668
71693
  out.push(` ${pad(k, KEY_COL)}${value2} `);
71669
71694
  }
71670
71695
  out.push("");
@@ -71688,7 +71713,7 @@ function renderPlain(detail, now, width, resolveOwningRunStatus, resolveBoundary
71688
71713
  if (artifactRows.length > 0) {
71689
71714
  out.push(" ARTIFACTS ");
71690
71715
  for (const [k, v] of artifactRows) {
71691
- out.push(` ${pad(k, KEY_COL)}${truncateToWidth2(v, Math.max(1, width - 4 - KEY_COL), "…")} `);
71716
+ out.push(` ${pad(k, KEY_COL)}${truncateToWidth(v, Math.max(1, width - 4 - KEY_COL), "…")} `);
71692
71717
  }
71693
71718
  out.push("");
71694
71719
  }
@@ -71710,7 +71735,7 @@ function renderThemed(detail, now, theme, width, resolveOwningRunStatus, resolve
71710
71735
  for (const [k, v] of summaryRows(detail, now)) {
71711
71736
  if (v === undefined)
71712
71737
  continue;
71713
- const value2 = truncateToWidth2(v, Math.max(1, width - 4 - KEY_COL), "…");
71738
+ const value2 = truncateToWidth(v, Math.max(1, width - 4 - KEY_COL), "…");
71714
71739
  out.push(` ${muted}${pad(k, KEY_COL)}${RESET}${text}${value2}${RESET} `);
71715
71740
  }
71716
71741
  out.push("");
@@ -71734,7 +71759,7 @@ function renderThemed(detail, now, theme, width, resolveOwningRunStatus, resolve
71734
71759
  if (artifactRows.length > 0) {
71735
71760
  out.push(` ${muted}${BOLD}ARTIFACTS${RESET} `);
71736
71761
  for (const [k, v] of artifactRows) {
71737
- out.push(` ${muted}${pad(k, KEY_COL)}${RESET}${dim}${truncateToWidth2(v, Math.max(1, width - 4 - KEY_COL), "…")}${RESET} `);
71762
+ out.push(` ${muted}${pad(k, KEY_COL)}${RESET}${dim}${truncateToWidth(v, Math.max(1, width - 4 - KEY_COL), "…")}${RESET} `);
71738
71763
  }
71739
71764
  out.push("");
71740
71765
  }
@@ -71797,14 +71822,14 @@ function stageLinePlain(stage, now, width) {
71797
71822
  const icon = statusIcon(stage.status);
71798
71823
  const dur = stageDurationString(stage, now);
71799
71824
  const activity = stageActivityString(stage, now);
71800
- const name = truncateToWidth2(`${icon} ${stage.name}`, STAGE_NAME_COL + 2, "…");
71801
- const activityText = activity ? truncateToWidth2(activity, 16, "…") : undefined;
71825
+ const name = truncateToWidth(`${icon} ${stage.name}`, STAGE_NAME_COL + 2, "…");
71826
+ const activityText = activity ? truncateToWidth(activity, 16, "…") : undefined;
71802
71827
  const parts = [pad(name, STAGE_NAME_COL + 2), pad(stage.status, 10)];
71803
71828
  if (activityText)
71804
71829
  parts.push(pad(activityText, 16));
71805
71830
  if (dur)
71806
71831
  parts.push(dur);
71807
- return truncateToWidth2(parts.join(""), width, "…");
71832
+ return truncateToWidth(parts.join(""), width, "…");
71808
71833
  }
71809
71834
  function stageLineThemed(stage, now, theme, width) {
71810
71835
  const icon = statusIcon(stage.status);
@@ -71815,13 +71840,13 @@ function stageLineThemed(stage, now, theme, width) {
71815
71840
  const stateFg = hexToAnsi(statusColor(stage.status, theme));
71816
71841
  const activity = stageActivityString(stage, now);
71817
71842
  const dur = stageDurationString(stage, now);
71818
- const nameText = truncateToWidth2(stage.name, STAGE_NAME_COL, "…");
71843
+ const nameText = truncateToWidth(stage.name, STAGE_NAME_COL, "…");
71819
71844
  const namePad = pad(nameText, STAGE_NAME_COL);
71820
71845
  const statePad = pad(stage.status, 10);
71821
- const activityText = activity ? truncateToWidth2(activity, 16, "…") : undefined;
71846
+ const activityText = activity ? truncateToWidth(activity, 16, "…") : undefined;
71822
71847
  const activitySeg = activityText ? `${muted}${pad(activityText, 16)}${RESET}` : " ".repeat(16);
71823
71848
  const durSeg = dur ? `${dim}${dur}${RESET}` : "";
71824
- return truncateToWidth2(`${iconFg}${icon}${RESET} ${text}${namePad}${RESET} ${stateFg}${statePad}${RESET}${activitySeg}${durSeg}`, width, "…");
71849
+ return truncateToWidth(`${iconFg}${icon}${RESET} ${text}${namePad}${RESET} ${stateFg}${statePad}${RESET}${activitySeg}${durSeg}`, width, "…");
71825
71850
  }
71826
71851
  function pendingStageRows(runId, rootRunId, runStatus, stage, width, theme, resolveOwningRunStatus, resolveBoundarySegments) {
71827
71852
  const pending = pendingWorkflowStageStatus({ id: runId, ...rootRunId === undefined ? {} : { rootRunId }, status: runStatus }, stage, resolveOwningRunStatus, resolveBoundarySegments);
@@ -71844,7 +71869,7 @@ function renderStageRowsPlain(runId, rootRunId, runStatus, stage, now, width, re
71844
71869
  ...pendingStageRows(runId, rootRunId, runStatus, stage, width, undefined, resolveOwningRunStatus, resolveBoundarySegments)
71845
71870
  ];
71846
71871
  if (stage.error) {
71847
- rows.push(` error ${truncateToWidth2(stage.error.split(`
71872
+ rows.push(` error ${truncateToWidth(stage.error.split(`
71848
71873
  `)[0] ?? "", Math.max(1, width - 10), "…")} `);
71849
71874
  }
71850
71875
  return rows;
@@ -71856,7 +71881,7 @@ function renderStageRowsThemed(runId, rootRunId, runStatus, stage, now, theme, w
71856
71881
  ];
71857
71882
  if (stage.error) {
71858
71883
  const errFg = hexToAnsi(theme.error);
71859
- rows.push(` ${hexToAnsi(theme.textMuted)}error${RESET} ${errFg}${truncateToWidth2(stage.error.split(`
71884
+ rows.push(` ${hexToAnsi(theme.textMuted)}error${RESET} ${errFg}${truncateToWidth(stage.error.split(`
71860
71885
  `)[0] ?? "", Math.max(1, width - 12), "…")}${RESET} `);
71861
71886
  }
71862
71887
  return rows;
@@ -71873,9 +71898,9 @@ function renderToolRowsPlain(tool, now, width) {
71873
71898
  const icon = statusIcon(toolDisplayStatus(tool.status));
71874
71899
  const duration = toolDurationString(tool, now);
71875
71900
  const line = ` ${pad(`${icon} ${tool.name}`, STAGE_NAME_COL + 2)}${pad(tool.status, 10)}${duration ?? ""} `;
71876
- const rows = [truncateToWidth2(line, width, "…")];
71901
+ const rows = [truncateToWidth(line, width, "…")];
71877
71902
  if (tool.error)
71878
- rows.push(` error ${truncateToWidth2(tool.error.split(`
71903
+ rows.push(` error ${truncateToWidth(tool.error.split(`
71879
71904
  `)[0] ?? "", Math.max(1, width - 10), "…")} `);
71880
71905
  return rows;
71881
71906
  }
@@ -71886,9 +71911,9 @@ function renderToolRowsThemed(tool, now, theme, width) {
71886
71911
  const dim = hexToAnsi(theme.dim);
71887
71912
  const duration = toolDurationString(tool, now);
71888
71913
  const line = ` ${stateFg}${statusIcon(displayStatus)}${RESET} ${text}${pad(tool.name, STAGE_NAME_COL)}${RESET} ${stateFg}${pad(tool.status, 10)}${RESET}${duration ? `${dim}${duration}${RESET}` : ""} `;
71889
- const rows = [truncateToWidth2(line, width, "…")];
71914
+ const rows = [truncateToWidth(line, width, "…")];
71890
71915
  if (tool.error)
71891
- rows.push(` ${hexToAnsi(theme.textMuted)}error${RESET} ${hexToAnsi(theme.error)}${truncateToWidth2(tool.error.split(`
71916
+ rows.push(` ${hexToAnsi(theme.textMuted)}error${RESET} ${hexToAnsi(theme.error)}${truncateToWidth(tool.error.split(`
71892
71917
  `)[0] ?? "", Math.max(1, width - 12), "…")}${RESET} `);
71893
71918
  return rows;
71894
71919
  }
@@ -71991,7 +72016,7 @@ function renderDetailHintRows(detail, width, theme) {
71991
72016
  } else {
71992
72017
  rows.push({
71993
72018
  prefix: continuation,
71994
- chunk: truncateToWidth2(suffix.trimStart(), Math.max(1, width - visibleWidth(continuation)), "…")
72019
+ chunk: truncateToWidth(suffix.trimStart(), Math.max(1, width - visibleWidth(continuation)), "…")
71995
72020
  });
71996
72021
  }
71997
72022
  if (!theme)
@@ -72209,9 +72234,9 @@ function renderRunEntry(run, now, width, theme, allRuns, indicatorStatuses, reso
72209
72234
  return ` ${accent}${chunk}${RESET}`;
72210
72235
  });
72211
72236
  const trailing = runTrailing(run, theme);
72212
- const trailingText = truncateToWidth2(trailing?.text ?? "", Math.max(0, interior - 1), ELLIPSIS);
72237
+ const trailingText = truncateToWidth(trailing?.text ?? "", Math.max(0, interior - 1), ELLIPSIS);
72213
72238
  const nameBudget = Math.max(1, interior - 3 - visibleWidth(trailingText) - (trailingText ? 2 : 0));
72214
- const name = truncateToWidth2(run.name, nameBudget, ELLIPSIS);
72239
+ const name = truncateToWidth(run.name, nameBudget, ELLIPSIS);
72215
72240
  const nameSeg = theme ? `${text}${BOLD}${name}${RESET}` : name;
72216
72241
  const trailingSeg = theme && trailingText ? `${hexToAnsi(trailing?.fg ?? theme.dim)}${trailingText}${RESET}` : trailingText;
72217
72242
  const identity = ` ${nameSeg}${trailingSeg ? ` ${trailingSeg}` : ""}`;
@@ -72219,7 +72244,7 @@ function renderRunEntry(run, now, width, theme, allRuns, indicatorStatuses, reso
72219
72244
  const rawMeta = runCardMeta(run, now);
72220
72245
  const modeW = mode.length + 4;
72221
72246
  const maxMetaW = Math.max(0, interior - modeW - 3);
72222
- const meta = truncateToWidth2(rawMeta, maxMetaW, ELLIPSIS);
72247
+ const meta = truncateToWidth(rawMeta, maxMetaW, ELLIPSIS);
72223
72248
  const metaW = visibleWidth(meta);
72224
72249
  const stripBudget = Math.max(0, interior - modeW - metaW - 2);
72225
72250
  const strip = progressStrip(stageCells(run), stripBudget, theme);
@@ -72275,13 +72300,13 @@ function pendingStageLines(run, width, theme, resolveOwningRunStatus, resolveBou
72275
72300
  });
72276
72301
  if (stages.length > MAX_PENDING_STAGE_ROWS) {
72277
72302
  const omitted = stages.length - MAX_PENDING_STAGE_ROWS;
72278
- const line = truncateToWidth2(` … ${omitted} more pending stage${omitted === 1 ? "" : "s"}`, width, ELLIPSIS);
72303
+ const line = truncateToWidth(` … ${omitted} more pending stage${omitted === 1 ? "" : "s"}`, width, ELLIPSIS);
72279
72304
  visible.push(theme === undefined ? line : `${hexToAnsi(theme.dim)}${line}${RESET}`);
72280
72305
  }
72281
72306
  return visible;
72282
72307
  }
72283
72308
  function pendingStageLine(line, width, theme) {
72284
- const visible = truncateToWidth2(line, width, ELLIPSIS);
72309
+ const visible = truncateToWidth(line, width, ELLIPSIS);
72285
72310
  return theme === undefined ? visible : `${hexToAnsi(theme.textMuted)}${visible}${RESET}`;
72286
72311
  }
72287
72312
  function runAccent(run, theme, indicatorStatus) {
@@ -72381,14 +72406,14 @@ function runningStageLabels(run) {
72381
72406
  if (running.length === 0)
72382
72407
  return;
72383
72408
  const joined = running.join(", ");
72384
- return truncateToWidth2(joined, STAGE_LABEL_BUDGET, ELLIPSIS);
72409
+ return truncateToWidth(joined, STAGE_LABEL_BUDGET, ELLIPSIS);
72385
72410
  }
72386
72411
  function pausedStageLabels(run) {
72387
72412
  const paused = run.stages.filter((s) => s.status === "paused").map((s) => s.name);
72388
72413
  if (paused.length === 0)
72389
72414
  return;
72390
72415
  const joined = paused.join(", ");
72391
- return truncateToWidth2(joined, STAGE_LABEL_BUDGET, ELLIPSIS);
72416
+ return truncateToWidth(joined, STAGE_LABEL_BUDGET, ELLIPSIS);
72392
72417
  }
72393
72418
  function lastStageDuration(run, now) {
72394
72419
  const candidate = [...run.stages].reverse().find((s) => s.status === "completed" || s.status === "failed" || s.status === "skipped") ?? run.stages.find((s) => s.status === "running");
@@ -72516,7 +72541,7 @@ function renderStatusHintRows(id, theme, width) {
72516
72541
  } else {
72517
72542
  rows.push({
72518
72543
  prefix: continuation,
72519
- chunk: truncateToWidth2(suffix.trimStart(), Math.max(1, budget - visibleWidth(continuation)), ELLIPSIS)
72544
+ chunk: truncateToWidth(suffix.trimStart(), Math.max(1, budget - visibleWidth(continuation)), ELLIPSIS)
72520
72545
  });
72521
72546
  }
72522
72547
  if (!theme)
@@ -72587,10 +72612,10 @@ function renderWorkflowEntry(entry, opts) {
72587
72612
  const width = effectiveWidth3(opts.width);
72588
72613
  const interior = Math.max(8, width - 2);
72589
72614
  const titleBudget = Math.max(8, Math.min(TAG_NAME_BUDGET, interior - 2));
72590
- const title = truncateToWidth2(entry.name, titleBudget, ELLIPSIS);
72615
+ const title = truncateToWidth(entry.name, titleBudget, ELLIPSIS);
72591
72616
  const titleLine = theme ? ` ${hexToAnsi(theme.text)}${BOLD}${title}${RESET} ` : ` ${title} `;
72592
72617
  const descBudget = Math.max(8, interior - 4);
72593
- const description = truncateToWidth2(entry.description, descBudget, ELLIPSIS);
72618
+ const description = truncateToWidth(entry.description, descBudget, ELLIPSIS);
72594
72619
  const row1 = ` ${paintMuted(description, theme)} `;
72595
72620
  const row2 = ` ${inputsSignatureRow(entry.inputs, interior - 4, theme)} `;
72596
72621
  return [titleLine, row1, row2];
@@ -72630,7 +72655,7 @@ function inputsSignatureRow(inputs, interior, theme) {
72630
72655
  const inlineWidth = labelW + 4 + visible.reduce((a, b) => a + visibleWidth(b.name) + (b.required ? 0 : 1), 0) + Math.max(0, visible.length - 1) * visibleWidth(sepPlain) + (overflow > 0 ? visibleWidth(sepPlain) + visibleWidth(`+${overflow} more`) : 0);
72631
72656
  if (inlineWidth > interior) {
72632
72657
  const flat = inputs.map((i) => i.required ? i.name : `${i.name}?`).join(", ");
72633
- const cut = truncateToWidth2(flat, Math.max(8, interior - labelW - 4), ELLIPSIS);
72658
+ const cut = truncateToWidth(flat, Math.max(8, interior - labelW - 4), ELLIPSIS);
72634
72659
  row = theme ? `${label} ${text}${cut}${reset}` : `inputs ${cut}`;
72635
72660
  }
72636
72661
  return row;
@@ -72966,14 +72991,14 @@ function renderCompactBandHeader(opts) {
72966
72991
  const labelW = visibleWidth(labelVisible);
72967
72992
  const rightEdgePad = 2;
72968
72993
  const subtitleBudget = Math.max(0, width - labelW - rightW - rightEdgePad - 2);
72969
- const subtitleText = subtitle.length > 0 && subtitleBudget > 0 ? truncateToWidth2(subtitle, subtitleBudget, "…") : "";
72994
+ const subtitleText = subtitle.length > 0 && subtitleBudget > 0 ? truncateToWidth(subtitle, subtitleBudget, "…") : "";
72970
72995
  const subtitleVisible = subtitleText.length > 0 ? ` ${subtitleText}` : "";
72971
72996
  const subtitleW = visibleWidth(subtitleVisible);
72972
72997
  const filler = Math.max(0, width - labelW - subtitleW - rightW - rightEdgePad);
72973
72998
  const labelStyled = `${chromeBg}${accent}${BOLD}${labelVisible}${RESET}${chromeBg}`;
72974
72999
  const subtitleStyled = subtitleText.length > 0 ? `${chromeBg} ${muted}${subtitleText}${RESET}${chromeBg}` : `${chromeBg}`;
72975
73000
  const line = `${labelStyled}${subtitleStyled}${" ".repeat(filler)}${rightStyled}${chromeBg}${" ".repeat(rightEdgePad)}${RESET}`;
72976
- const fitted = truncateToWidth2(line, width, "", true);
73001
+ const fitted = truncateToWidth(line, width, "", true);
72977
73002
  const pad = Math.max(0, width - visibleWidth(fitted));
72978
73003
  return [fillBackground(`${fitted}${chromeBg}${" ".repeat(pad)}${RESET}`, width, chromeBg)];
72979
73004
  }
@@ -72996,14 +73021,14 @@ function renderBandHeader(opts) {
72996
73021
  const rightEdgePad = 2;
72997
73022
  const subtitleBudget = Math.max(0, width - leftEdgePad - pillW - rightW - rightEdgePad);
72998
73023
  const subtitleTextBudget = Math.max(0, subtitleBudget - 2);
72999
- const subtitleText = subtitle.length > 0 && subtitleTextBudget > 0 ? truncateToWidth2(subtitle, subtitleTextBudget, "…") : "";
73024
+ const subtitleText = subtitle.length > 0 && subtitleTextBudget > 0 ? truncateToWidth(subtitle, subtitleTextBudget, "…") : "";
73000
73025
  const subtitleVisible = subtitleText.length > 0 ? ` ${subtitleText}` : "";
73001
73026
  const subtitleW = visibleWidth(subtitleVisible);
73002
73027
  const subtitleStyled = subtitleText.length > 0 ? `${chromeBg} ${muted}${subtitleText}${RESET}${chromeBg}` : `${chromeBg}`;
73003
73028
  const fillerTop = Math.max(0, width - leftEdgePad - pillW - subtitleW - rightEdgePad);
73004
73029
  const fillerMid = Math.max(0, width - leftEdgePad - pillW - subtitleW - rightW - rightEdgePad);
73005
73030
  const fitChromeLine = (line) => {
73006
- const fitted = truncateToWidth2(line, width, "");
73031
+ const fitted = truncateToWidth(line, width, "");
73007
73032
  const pad = Math.max(0, width - visibleWidth(fitted));
73008
73033
  return fillBackground(`${fitted}${chromeBg}${" ".repeat(pad)}${RESET}`, width, chromeBg);
73009
73034
  };
@@ -73638,11 +73663,11 @@ function renderSubmitToolbar(label, focused, theme, width) {
73638
73663
  const gap = 2;
73639
73664
  const rightPad = 1;
73640
73665
  const hintBudget = Math.max(0, width - leftPad - button.visibleWidth - gap - rightPad);
73641
- const fittedHints = truncateToWidth2(hints, hintBudget, "…", true);
73666
+ const fittedHints = truncateToWidth(hints, hintBudget, "…", true);
73642
73667
  const hintWidth = visibleWidth(fittedHints);
73643
73668
  const filler = Math.max(0, width - leftPad - button.visibleWidth - gap - hintWidth - rightPad);
73644
73669
  const line = `${chromeBg} ${button.text}${chromeBg}${" ".repeat(gap)}${fittedHints}${chromeBg}${" ".repeat(filler)} ${RESET}`;
73645
- const clipped = truncateToWidth2(line, width, "", true);
73670
+ const clipped = truncateToWidth(line, width, "", true);
73646
73671
  return [`${clipped}${chromeBg}${" ".repeat(Math.max(0, width - visibleWidth(clipped)))}${RESET}`];
73647
73672
  }
73648
73673
  function renderCompactSubmitButton(label, focused, theme, chromeBg) {
@@ -73697,10 +73722,10 @@ function padLine(s, usable) {
73697
73722
  return s;
73698
73723
  if (len < usable)
73699
73724
  return s + " ".repeat(usable - len);
73700
- return truncateToWidth2(s, usable, "…", true);
73725
+ return truncateToWidth(s, usable, "…", true);
73701
73726
  }
73702
73727
  function fitLine(line, width) {
73703
- return truncateToWidth2(line, Math.max(0, width), "…", true);
73728
+ return truncateToWidth(line, Math.max(0, width), "…", true);
73704
73729
  }
73705
73730
  function renderWorkflowHeader(workflowName, fieldCount, focusedIdx, theme, width) {
73706
73731
  const current = Math.min(fieldCount, Math.max(1, focusedIdx + 1));
@@ -73804,7 +73829,7 @@ function renderFieldTop(title, width, borderColor, focused, theme) {
73804
73829
  return paint("╭", borderColor) + labelText + paint(`${"─".repeat(fill)}╮`, borderColor);
73805
73830
  }
73806
73831
  function renderFieldRow(row, contentWidth, borderColor, _theme) {
73807
- const clipped = truncateToWidth2(row, contentWidth, "", true);
73832
+ const clipped = truncateToWidth(row, contentWidth, "", true);
73808
73833
  const padded = clipped + " ".repeat(Math.max(0, contentWidth - visibleWidth(clipped)));
73809
73834
  return paint("│", borderColor) + padded + paint("│", borderColor);
73810
73835
  }
@@ -73965,7 +73990,7 @@ function renderFieldTop2(title, width, borderColor, focused, theme) {
73965
73990
  return paint("╭", borderColor) + labelText + paint(`${"─".repeat(fill)}╮`, borderColor);
73966
73991
  }
73967
73992
  function renderFieldRow2(row, contentWidth, borderColor) {
73968
- const clipped = truncateToWidth2(row, contentWidth, "", true);
73993
+ const clipped = truncateToWidth(row, contentWidth, "", true);
73969
73994
  const padded = clipped + " ".repeat(Math.max(0, contentWidth - visibleWidth(clipped)));
73970
73995
  return paint("│", borderColor) + padded + paint("│", borderColor);
73971
73996
  }
@@ -73986,10 +74011,10 @@ function renderAskInputRows2(raw, caret, focused, placeholder, theme, width) {
73986
74011
  const usable = Math.max(1, width);
73987
74012
  if (raw === "") {
73988
74013
  const value2 = placeholder && placeholder.length > 0 ? paint(placeholder, theme.dim) + (focused ? cursorBlock() : "") : focused ? cursorBlock() : "";
73989
- return [truncateToWidth2(value2, usable, "…", true)];
74014
+ return [truncateToWidth(value2, usable, "…", true)];
73990
74015
  }
73991
74016
  const layout = layoutTextField(raw, usable, caret);
73992
- return layout.lines.map((line, row) => focused && row === layout.cursorRow ? renderCaretLine(line, layout.cursorOffset ?? line.length, usable, theme, theme.text) : truncateToWidth2(paint(line, theme.text), usable, "…", true));
74017
+ return layout.lines.map((line, row) => focused && row === layout.cursorRow ? renderCaretLine(line, layout.cursorOffset ?? line.length, usable, theme, theme.text) : truncateToWidth(paint(line, theme.text), usable, "…", true));
73993
74018
  }
73994
74019
  function renderCaretLine(raw, caret, usable, _theme, color) {
73995
74020
  const safe = clampGraphemeOffset2(raw, caret);
@@ -74022,10 +74047,10 @@ function composeCommand(state) {
74022
74047
  return parts.join(" ");
74023
74048
  }
74024
74049
  function fitLine2(ansi, width) {
74025
- return truncateToWidth2(ansi, Math.max(0, width), "…", true);
74050
+ return truncateToWidth(ansi, Math.max(0, width), "…", true);
74026
74051
  }
74027
74052
  function clip(ansi, budget) {
74028
- return truncateToWidth2(ansi, Math.max(0, budget), "…", true);
74053
+ return truncateToWidth(ansi, Math.max(0, budget), "…", true);
74029
74054
  }
74030
74055
  function cursorBlock(text = " ") {
74031
74056
  return `\x1B[7m${text}\x1B[0m`;
@@ -75806,7 +75831,7 @@ function modelText(stage, innerWidth) {
75806
75831
  const modelSuffix = short.endsWith("-fast") ? "-fast" : "";
75807
75832
  const name = modelSuffix ? short.slice(0, -modelSuffix.length) : short;
75808
75833
  const room = Math.max(1, innerWidth - visibleWidth(modelSuffix + suffix));
75809
- return `${truncateToWidth2(name, room, "…")}${modelSuffix}${suffix}`;
75834
+ return `${truncateToWidth(name, room, "…")}${modelSuffix}${suffix}`;
75810
75835
  }
75811
75836
  function workflowChildRunRows(stage, width) {
75812
75837
  const child = stage.workflowChild ?? stage.workflowChildRun;
@@ -75857,7 +75882,7 @@ function truncate(s, maxWidth) {
75857
75882
  return "";
75858
75883
  if (visibleWidth(s) <= maxWidth)
75859
75884
  return s;
75860
- return truncateToWidth2(s, maxWidth, "…");
75885
+ return truncateToWidth(s, maxWidth, "…");
75861
75886
  }
75862
75887
  function centreColored(content, width, fg, bg, opts = {}) {
75863
75888
  const safe = truncate(content, width);
@@ -76437,7 +76462,7 @@ function leadingAnsi(line) {
76437
76462
  function buildStageInputLabel(theme, stageName, maxNameWidth, prefix, suffix) {
76438
76463
  if (maxNameWidth < 1)
76439
76464
  return;
76440
- const truncatedName = truncateToWidth2(stageName, maxNameWidth, "…");
76465
+ const truncatedName = truncateToWidth(stageName, maxNameWidth, "…");
76441
76466
  if (truncatedName.length === 0)
76442
76467
  return;
76443
76468
  const plain = prefix + truncatedName + suffix;
@@ -77457,6 +77482,7 @@ var WORKFLOW_STATUS_KEY = "pi-workflows";
77457
77482
  var OVERLAY_HIDDEN_STATUS_KEYS = new Set(["mcp", "i-have-adhd"]);
77458
77483
 
77459
77484
  // dist/builtin/workflows/src/tui/graph-view-render-helpers.ts
77485
+ var slicedColumnSegments = new BoundedTextCache(1024);
77460
77486
  function toolExpandKey(piKeybindings) {
77461
77487
  const keybindings = isKeybindingsLike(piKeybindings) ? piKeybindings : undefined;
77462
77488
  const keys = keybindings?.getKeys?.(APP_ACTION.toolsExpand);
@@ -77500,7 +77526,7 @@ class GraphViewRenderHelpers extends GraphViewState {
77500
77526
  const statusSegment = statusText ? [`${accent}${statusText}${RESET}${chromeBg}`] : [];
77501
77527
  const hintSegments = hintKeys.map(({ key, label }) => `${text}${BOLD}${key}${RESET}${chromeBg} ${muted}${label}${RESET}${chromeBg}`);
77502
77528
  const hintsStyledRaw = [hintSegments[0], ...statusSegment, ...hintSegments.slice(1)].filter((segment) => segment !== undefined).join(sep);
77503
- const hintsStyled = truncateToWidth2(hintsStyledRaw, hintsBudget, "");
77529
+ const hintsStyled = truncateToWidth(hintsStyledRaw, hintsBudget, "");
77504
77530
  const hintsVisibleLen = visibleWidth(hintsStyled);
77505
77531
  const fillerVisible = Math.max(0, hintsBudget - hintsVisibleLen);
77506
77532
  const filler = " ".repeat(fillerVisible);
@@ -77515,13 +77541,13 @@ class GraphViewRenderHelpers extends GraphViewState {
77515
77541
  return `${DEFAULT_BG}${" ".repeat(width)}${RESET}`;
77516
77542
  }
77517
77543
  _centerCanvasContent(content, width) {
77518
- const truncated = truncateToWidth2(content, width, "…", true);
77544
+ const truncated = truncateToWidth(content, width, "…", true);
77519
77545
  const leftPad = Math.max(0, Math.floor((width - visibleWidth(truncated)) / 2));
77520
77546
  return `${" ".repeat(leftPad)}${truncated}`;
77521
77547
  }
77522
77548
  _canvasRow(content, width) {
77523
77549
  const bg = DEFAULT_BG;
77524
- const truncated = truncateToWidth2(content, width, "…", true);
77550
+ const truncated = truncateToWidth(content, width, "…", true);
77525
77551
  const padLen = Math.max(0, width - visibleWidth(truncated));
77526
77552
  return `${bg}${truncated}${bg}${" ".repeat(padLen)}${RESET}`;
77527
77553
  }
@@ -77611,7 +77637,7 @@ class GraphViewRenderHelpers extends GraphViewState {
77611
77637
  _sliceColumns(line, fromCol, toCol) {
77612
77638
  if (fromCol >= toCol)
77613
77639
  return "";
77614
- return sliceColumns(line, fromCol, toCol - fromCol, true);
77640
+ return slicedColumnSegments.get(`${fromCol}\x00${toCol}\x00${line}`, () => sliceColumns(line, fromCol, toCol - fromCol, true));
77615
77641
  }
77616
77642
  }
77617
77643
 
@@ -78032,7 +78058,7 @@ var TOOL_COMPACT_HINT = "↵ tool detail · esc close";
78032
78058
  var NO_CHAT_HINT = "↑↓ select · esc close";
78033
78059
  var NO_CHAT_COMPACT_HINT = "esc close";
78034
78060
  function padVisible(s, width) {
78035
- const clipped = visibleWidth(s) > width ? truncateToWidth2(s, width, "…", true) : s;
78061
+ const clipped = visibleWidth(s) > width ? truncateToWidth(s, width, "…", true) : s;
78036
78062
  return clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
78037
78063
  }
78038
78064
  function truncateToWidthWithoutReset(text, width, suffix = "") {
@@ -78069,7 +78095,7 @@ function renderSwitcher(stages, state, opts) {
78069
78095
  const leftLabelText = " STAGES";
78070
78096
  const hint = innerWidth >= 44 ? canOpenStageChat ? STAGE_HINT : selectedIsTool ? TOOL_HINT : NO_CHAT_HINT : canOpenStageChat ? STAGE_COMPACT_HINT : selectedIsTool ? TOOL_COMPACT_HINT : NO_CHAT_COMPACT_HINT;
78071
78097
  const queryBudget = Math.max(0, innerWidth - visibleWidth(leftLabelText) - visibleWidth(hint) - 3);
78072
- const queryDisplay = state.query ? ` ${truncateToWidth2(state.query, queryBudget, "…")}` : "";
78098
+ const queryDisplay = state.query ? ` ${truncateToWidth(state.query, queryBudget, "…")}` : "";
78073
78099
  const leftSegmentWidth = visibleWidth(`${leftLabelText}${queryDisplay}`);
78074
78100
  const gap = Math.max(1, innerWidth - leftSegmentWidth - visibleWidth(hint) - 1);
78075
78101
  const header = `${panelBg}${muted}${BOLD}${leftLabelText}${RESET}${panelBg}` + (queryDisplay ? `${text}${queryDisplay}${RESET}${panelBg}` : "") + " ".repeat(gap) + `${dim}${hint}${RESET}${panelBg}`;
@@ -78090,7 +78116,7 @@ function renderSwitcher(stages, state, opts) {
78090
78116
  const icon = statusIcon(stage.status);
78091
78117
  const label = statusText(stage.status);
78092
78118
  const rowTextBudget = Math.max(8, innerWidth - 14);
78093
- const name = truncateToWidth2(stage.name, rowTextBudget, "…");
78119
+ const name = truncateToWidth(stage.name, rowTextBudget, "…");
78094
78120
  if (isSelected) {
78095
78121
  const metaWidth = visibleWidth(label);
78096
78122
  const nameBudget = Math.max(4, innerWidth - visibleWidth(` ${icon} `) - metaWidth - 2);
@@ -78298,7 +78324,7 @@ function wrapFieldValue(text, width, continuationWidth = width) {
78298
78324
  function fitLine3(text, width, suffix, theme) {
78299
78325
  const safeWidth = Math.max(1, Math.floor(width));
78300
78326
  if (theme !== undefined)
78301
- return truncateToWidth2(text, safeWidth, suffix, true);
78327
+ return truncateToWidth(text, safeWidth, suffix, true);
78302
78328
  if (visibleWidth(text) <= safeWidth)
78303
78329
  return text;
78304
78330
  const suffixWidth = visibleWidth(suffix);
@@ -78614,7 +78640,7 @@ class GraphViewRenderer extends GraphViewGraphRenderer {
78614
78640
  if (visibleWidth(clean) === 0)
78615
78641
  return this._blankRow(width);
78616
78642
  if (visibleWidth(clean) > width)
78617
- return truncateToWidth2(clean, width, "…", true);
78643
+ return truncateToWidth(clean, width, "…", true);
78618
78644
  return `${clean}${" ".repeat(width - visibleWidth(clean))}`;
78619
78645
  });
78620
78646
  }
@@ -79167,8 +79193,8 @@ function fitHeaderNames(workflowName, stageName, budget) {
79167
79193
  remaining -= workflowExtra;
79168
79194
  stageBudget += Math.min(remaining, Math.max(0, stageWidth - stageBudget));
79169
79195
  return {
79170
- workflow: truncateToWidth2(workflowName, workflowBudget, "…"),
79171
- stage: truncateToWidth2(stageName, stageBudget, "…")
79196
+ workflow: truncateToWidth(workflowName, workflowBudget, "…"),
79197
+ stage: truncateToWidth(stageName, stageBudget, "…")
79172
79198
  };
79173
79199
  }
79174
79200
  function sepRule(ctx, width) {
@@ -79232,7 +79258,7 @@ function mergeOrchestratorReturnHintIntoLine(ctx, line, width, options = {}) {
79232
79258
  const rightMargin = Math.min(requestedRightMargin, Math.max(0, width - suffixWidth - hintWidth));
79233
79259
  const hintStart = Math.max(0, width - suffixWidth - rightMargin - hintWidth);
79234
79260
  const prefixWidth = Math.max(0, hintStart - 1);
79235
- const prefix = truncateToWidth2(line, prefixWidth, "", true);
79261
+ const prefix = truncateToWidth(line, prefixWidth, "", true);
79236
79262
  const gap = Math.max(0, hintStart - visibleWidth(prefix));
79237
79263
  return prefix + " ".repeat(gap) + hint.styled + " ".repeat(rightMargin) + trailingBorder;
79238
79264
  }
@@ -79856,7 +79882,7 @@ function appendHeadline(rows, opts, innerWidth) {
79856
79882
  }
79857
79883
  }
79858
79884
  function appendField(rows, field, innerWidth, theme) {
79859
- const label = truncateToWidth2(field.label, FIELD_LABEL_WIDTH, "…").padEnd(FIELD_LABEL_WIDTH, " ");
79885
+ const label = truncateToWidth(field.label, FIELD_LABEL_WIDTH, "…").padEnd(FIELD_LABEL_WIDTH, " ");
79860
79886
  const firstPrefixWidth = 1 + FIELD_LABEL_WIDTH + 1;
79861
79887
  const firstBudget = Math.max(1, innerWidth - firstPrefixWidth);
79862
79888
  const value2 = field.value ?? "";
@@ -79924,7 +79950,7 @@ function style(text, theme, color, bold = false) {
79924
79950
  return `${hexToAnsi(color)}${bold ? BOLD : ""}${text}${RESET}`;
79925
79951
  }
79926
79952
  function fit(line, width) {
79927
- return truncateToWidth2(line, width, "…", true);
79953
+ return truncateToWidth(line, width, "…", true);
79928
79954
  }
79929
79955
 
79930
79956
  // dist/builtin/workflows/src/tui/stage-chat-view-transcript.ts
@@ -82553,7 +82579,7 @@ function plainRunLines(run, now, allRuns, width, expandGraph) {
82553
82579
  function renderAwaitingPromptLine(message, bodyWidth, theme) {
82554
82580
  const indent = " ".repeat(5);
82555
82581
  const messageBudget = Math.max(1, bodyWidth - visibleWidth(indent) - 2);
82556
- const clipped = truncateToWidth2(sanitizePromptDisplay(message), messageBudget, ELLIPSIS);
82582
+ const clipped = truncateToWidth(sanitizePromptDisplay(message), messageBudget, ELLIPSIS);
82557
82583
  const preview = theme === undefined ? clipped.replace(/\x1b\[[0-9;]*m/g, "") : clipped;
82558
82584
  const row = `${indent}"${preview}"`;
82559
82585
  return theme === undefined ? row : `${hexToAnsi(theme.info)}${row}${RESET}`;
@@ -82627,7 +82653,7 @@ function buildThemedWidgetLines(snap, piTheme, width = 120, now = Date.now(), la
82627
82653
  const activeTools = display.filter(isActive).reduce((total, run) => total + activeToolNodes(run).length, 0);
82628
82654
  if (width < COLLAPSED_BREAKPOINT_COLS) {
82629
82655
  return [
82630
- truncateToWidth2(themed ? themedCollapsed(visibleCounts, activeTools, graphTheme) : plainCollapsed(visibleCounts, activeTools), width, "…")
82656
+ truncateToWidth(themed ? themedCollapsed(visibleCounts, activeTools, graphTheme) : plainCollapsed(visibleCounts, activeTools), width, "…")
82631
82657
  ];
82632
82658
  }
82633
82659
  const total = display.length;
@@ -82723,7 +82749,7 @@ class WorkflowWidgetViewport {
82723
82749
  render(width) {
82724
82750
  const content = this.content.render(width);
82725
82751
  const hint = content.length > 1 ? this.getHint() : "";
82726
- const nextLines = hint ? [...content, truncateToWidth2(hint, width, "…")] : content;
82752
+ const nextLines = hint ? [...content, truncateToWidth(hint, width, "…")] : content;
82727
82753
  const nextRunRows = (this.getRunRows?.() ?? []).map((run, index, rows) => hint && index === rows.length - 1 ? { ...run, end: run.end + 1 } : run);
82728
82754
  const collapsed = Boolean(this.getRunRows && nextLines.length === 1 && nextRunRows.length === 0);
82729
82755
  if (collapsed) {
@@ -117615,7 +117641,7 @@ function renderHeader3(width, theme) {
117615
117641
  const inner = Math.max(4, width - 2);
117616
117642
  const border = hexToAnsi(theme.border);
117617
117643
  const accent = hexToAnsi(theme.accent);
117618
- const title = truncateToWidth2(TITLE, Math.max(1, inner - 2), "…");
117644
+ const title = truncateToWidth(TITLE, Math.max(1, inner - 2), "…");
117619
117645
  const padded = ` ${title} `;
117620
117646
  const padLen = Math.max(0, inner - visibleWidth(padded));
117621
117647
  const left = Math.min(2, padLen);
@@ -117641,7 +117667,7 @@ function renderHintsRow(width, theme, state) {
117641
117667
  hint(keyText3("tui.select.cancel"), "Close")
117642
117668
  ];
117643
117669
  const line = ` ${parts.join(sep)}`;
117644
- const clipped = truncateToWidth2(line, width, "…");
117670
+ const clipped = truncateToWidth(line, width, "…");
117645
117671
  const lineWidth = visibleWidth(clipped);
117646
117672
  if (lineWidth >= width)
117647
117673
  return clipped;
@@ -117672,7 +117698,7 @@ function renderFilterRow(inner, theme, state) {
117672
117698
  const prefixPlain = " filter ";
117673
117699
  const valueBudget = Math.max(1, inner - visibleWidth(prefixPlain) - (state.filterFocused ? 1 : 0));
117674
117700
  const rawValue = state.query || "(type to filter by name or id)";
117675
- const shownValue = truncateToWidth2(rawValue, valueBudget, "…");
117701
+ const shownValue = truncateToWidth(rawValue, valueBudget, "…");
117676
117702
  const value2 = state.query ? `${text}${shownValue}${RESET}${panelBg}` : `${muted}${shownValue}${RESET}${panelBg}`;
117677
117703
  const content = ` ${mauve} ${RESET}${panelBg} ${label}${RESET}${panelBg} ${value2}${cursor}`;
117678
117704
  return `${border}│${RESET}${fillBackground(content, inner, panelBg)}${border}│${RESET}`;
@@ -117709,10 +117735,10 @@ function renderRunRow(row, isSelected, inner, theme, now, allRuns) {
117709
117735
  const progressCol = progress.padStart(10, " ");
117710
117736
  const rightPlain = `${elapsedCol} ${progressCol} `;
117711
117737
  const rightBudget = Math.max(1, inner - 5);
117712
- const rightVisible = truncateToWidth2(rightPlain, rightBudget, "…");
117738
+ const rightVisible = truncateToWidth(rightPlain, rightBudget, "…");
117713
117739
  const right = visibleWidth(rightVisible) < visibleWidth(rightPlain) ? `${dim}${rightVisible}${RESET}${panelBg}` : `${muted}${elapsedCol}${RESET}${panelBg} ${dim}${progressCol}${RESET}${panelBg} `;
117714
117740
  const nameBudget = Math.max(1, inner - 3 - visibleWidth(rightVisible) - 1);
117715
- const name = truncateToWidth2(run.name, nameBudget, "…");
117741
+ const name = truncateToWidth(run.name, nameBudget, "…");
117716
117742
  const nameRow = isSelected ? `${border}│${RESET}${fillBackground(`${hexToAnsi(theme.backgroundElement)}${BOLD} ${name}${" ".repeat(Math.max(1, inner - 3 - visibleWidth(name) - visibleWidth(rightVisible)))}${rightVisible}`, inner, hexBg(theme.accent))}${border}│${RESET}` : `${border}│${RESET}${fillBackground(` ${text}${name}${RESET}${panelBg}${" ".repeat(Math.max(1, inner - 3 - visibleWidth(name) - visibleWidth(right)))}${right}`, inner, panelBg)}${border}│${RESET}`;
117717
117743
  return [...idRows.map(renderIdRow), nameRow];
117718
117744
  }
@@ -120939,7 +120965,7 @@ function quoted(name) {
120939
120965
  function fitLine4(line, width) {
120940
120966
  if (width === undefined || width <= 0)
120941
120967
  return line;
120942
- return truncateToWidth2(line, width, "…");
120968
+ return truncateToWidth(line, width, "…");
120943
120969
  }
120944
120970
  function renderCall(args, opts = {}) {
120945
120971
  const action = args.action ?? "run";
@@ -121003,7 +121029,7 @@ import { wrapTextWithAnsi as wrapTextWithAnsi2 } from "@earendil-works/pi-tui";
121003
121029
  function fitLine5(line, width) {
121004
121030
  if (width === undefined || width <= 0)
121005
121031
  return line;
121006
- return truncateToWidth2(line, width, "…");
121032
+ return truncateToWidth(line, width, "…");
121007
121033
  }
121008
121034
  function noticeBodyLines(message, width) {
121009
121035
  return message.split(/\r?\n/).flatMap((line) => {