@oxecli/oxe 1.0.109 → 1.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -4,7 +4,7 @@ import { execFile, spawn } from "node:child_process";
4
4
  import { structuredPatch } from "diff";
5
5
  import { max_diff_source_chars, max_diff_lines, max_diff_context_lines, max_diff_line_chars, max_read_line_chars, max_read_file_bytes, max_read_lines, max_output_chars, max_bash_timeout_seconds, max_grep_file_bytes, strict_max_properties, ignoredDirs, } from "./config.js";
6
6
  import { toolLoadSkill } from "./skills.js";
7
- import { truncateStyled, plainLen, terminalWidth, highlightCodeLine } from "./ui.js";
7
+ import { truncateStyled, plainLen, terminalWidth, highlightCodeLine, fitBoxWidth } from "./ui.js";
8
8
  export { toolLoadSkill };
9
9
  // ---------------------------------------------------------------------------
10
10
  // Path sanitization helper
@@ -148,6 +148,10 @@ function displayDiff(pathName, oldContent, newContent) {
148
148
  return { kind: k, body: line.slice(1), oldNum, newNum };
149
149
  });
150
150
  const termW = terminalWidth();
151
+ // The diff rows render outside a panel, so clamp their width to the scaled
152
+ // box width (minus margin) so they never overflow on narrow terminals.
153
+ const boxW = fitBoxWidth(termW - 4, termW);
154
+ const innerW = Math.max(boxW - 4, 1);
151
155
  let maxNum = 1;
152
156
  for (const v of visible) {
153
157
  if (v.oldNum)
@@ -156,7 +160,7 @@ function displayDiff(pathName, oldContent, newContent) {
156
160
  maxNum = Math.max(maxNum, v.newNum);
157
161
  }
158
162
  const numW = String(maxNum).length;
159
- const bodyMax = Math.max(termW - ind.length - numW - 4, 20);
163
+ const bodyMax = Math.max(innerW - ind.length - numW - 4, 1);
160
164
  const gap = " ".repeat(numW);
161
165
  for (const v of visible) {
162
166
  if (v.kind === "~") {
@@ -184,7 +188,7 @@ function displayDiff(pathName, oldContent, newContent) {
184
188
  const shown = isAdd
185
189
  ? body
186
190
  : recolorBrackets(body, fg, "\x1b[97m");
187
- const fill = Math.max(0, termW - ind.length - numW - 4 - plainLen(body));
191
+ const fill = Math.max(0, innerW - ind.length - numW - 4 - plainLen(body));
188
192
  pendingDiffOutput.push(`${ind}${bg}${fg}${numStr} ${sign} \x1b[0m${bg}\x1b[97m${shown}${bg}\x1b[97m${" ".repeat(fill)}\x1b[0m`);
189
193
  }
190
194
  else {
package/dist/ui.js CHANGED
@@ -117,7 +117,7 @@ export function terminalWidth() {
117
117
  return process.stdout.columns || 80;
118
118
  }
119
119
  /** Minimum width for boxes/cards so they don't collapse to nothing. */
120
- const MIN_BOX_WIDTH = 40;
120
+ const MIN_BOX_WIDTH = 52;
121
121
  /** Horizontal margin reserved on each side of a box/card from the terminal edge. */
122
122
  const BOX_MARGIN = 4;
123
123
  /**
@@ -127,7 +127,7 @@ const BOX_MARGIN = 4;
127
127
  * terminal is narrower than min+margin, so cards size down smoothly instead of
128
128
  * overflowing.
129
129
  */
130
- function fitBoxWidth(pref, termW) {
130
+ export function fitBoxWidth(pref, termW) {
131
131
  const maxW = Math.max(termW - BOX_MARGIN, 1);
132
132
  return Math.min(Math.max(Math.min(pref, maxW), MIN_BOX_WIDTH), maxW);
133
133
  }
@@ -363,13 +363,36 @@ function formatMarkdownTable(tableLines) {
363
363
  }
364
364
  colWidths.push(Math.max(mw, 3));
365
365
  }
366
+ // Scale the table to fit the terminal: shrink columns (each toward a minimum
367
+ // of 3) so the whole table stays inside the box width instead of overflowing
368
+ // or wrapping its borders on a narrow/scaled terminal. Cell content that no
369
+ // longer fits is truncated to the column width when rendered.
370
+ {
371
+ const termW = terminalWidth();
372
+ const boxW = fitBoxWidth(termW - 4, termW);
373
+ const availW = Math.max(boxW - 4, 1);
374
+ // total = Σ(colWidth+2) + (ncols-1) separators + 2 outer borders.
375
+ const totalW = colWidths.reduce((a, w) => a + w + 2, 0) + (colWidths.length - 1) + 2;
376
+ let extra = totalW - availW;
377
+ if (extra > 0) {
378
+ for (let c = 0; c < colWidths.length && extra > 0; c++) {
379
+ const room = colWidths[c] - 3;
380
+ if (room > 0) {
381
+ const cut = Math.min(room, extra);
382
+ colWidths[c] -= cut;
383
+ extra -= cut;
384
+ }
385
+ }
386
+ }
387
+ }
366
388
  const out = [];
367
389
  const topBorder = `\x1b[90m╭${colWidths.map((w) => "─".repeat(w + 2)).join("┬")}╮\x1b[0m`;
368
390
  const midBorder = `\x1b[90m├${colWidths.map((w) => "─".repeat(w + 2)).join("┼")}┤\x1b[0m`;
369
391
  const botBorder = `\x1b[90m╰${colWidths.map((w) => "─".repeat(w + 2)).join("┴")}╯\x1b[0m`;
370
392
  out.push(topBorder);
371
393
  const headCells = header.map((h, i) => {
372
- const formatted = `\x1b[1;37m${formatInlineMarkdown(h)}\x1b[0m`;
394
+ const raw = `\x1b[1;37m${formatInlineMarkdown(h)}\x1b[0m`;
395
+ const formatted = truncateStyled(raw, colWidths[i]);
373
396
  const pad = colWidths[i] - plainLen(formatted);
374
397
  return ` ${formatted}${" ".repeat(Math.max(pad, 0))} `;
375
398
  });
@@ -377,7 +400,7 @@ function formatMarkdownTable(tableLines) {
377
400
  out.push(midBorder);
378
401
  for (const r of rows) {
379
402
  const rowCells = header.map((_, i) => {
380
- const cell = r[i] ? formatInlineMarkdown(r[i]) : "";
403
+ const cell = r[i] ? truncateStyled(formatInlineMarkdown(r[i]), colWidths[i]) : "";
381
404
  const pad = colWidths[i] - plainLen(cell);
382
405
  return ` ${cell}${" ".repeat(Math.max(pad, 0))} `;
383
406
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.109",
3
+ "version": "1.0.110",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },