@oxecli/oxe 1.0.116 → 1.0.117
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/ui.js +21 -8
- package/package.json +1 -1
package/dist/ui.js
CHANGED
|
@@ -513,10 +513,20 @@ export function markdownToAnsi(text) {
|
|
|
513
513
|
const badge = codeLang ? ` \x1b[1;36m${codeLang}\x1b[0m ` : "";
|
|
514
514
|
const barLen = Math.max(10, Math.min(width - plainLen(badge) - (codeLang ? 4 : 2), 60));
|
|
515
515
|
const topPrefix = codeLang ? "─" : "";
|
|
516
|
+
// Full width of the framed box = the top border's column span, used to
|
|
517
|
+
// truncate body lines so they never run off the right edge past the border.
|
|
518
|
+
const borderW = 1 + (codeLang ? 1 : 0) + plainLen(badge) + barLen + 1;
|
|
519
|
+
// Body prefix is "│ " (3 columns). Content (incl. a trailing ellipsis)
|
|
520
|
+
// must fit in borderW - 3 so a truncated line ends flush with the border.
|
|
521
|
+
const contentMax = Math.max(borderW - 3, 1);
|
|
516
522
|
out.push(`\x1b[90m╭${topPrefix}${badge}${"─".repeat(barLen)}╮\x1b[0m`);
|
|
517
523
|
for (const cline of codeBuffer) {
|
|
518
524
|
const highlighted = highlightCodeLine(cline, codeLang);
|
|
519
|
-
|
|
525
|
+
// Truncate so a long code line never overflows the box's right edge
|
|
526
|
+
// (borders are only drawn at top/bottom, so a longer line would stick
|
|
527
|
+
// out past the closing ╯).
|
|
528
|
+
const body = plainLen(highlighted) > contentMax ? truncateStyled(highlighted, Math.max(contentMax - 1, 1)) + "…" : highlighted;
|
|
529
|
+
out.push(`\x1b[90m│\x1b[0m ${body}`);
|
|
520
530
|
}
|
|
521
531
|
out.push(`\x1b[90m╰${"─".repeat(barLen + plainLen(badge) + (codeLang ? 1 : 0))}╯\x1b[0m`);
|
|
522
532
|
codeBuffer = [];
|
|
@@ -570,26 +580,29 @@ export function markdownToAnsi(text) {
|
|
|
570
580
|
continue;
|
|
571
581
|
}
|
|
572
582
|
let line = raw;
|
|
573
|
-
// Headers (render as styled headings with the '#' markers stripped)
|
|
583
|
+
// Headers (render as styled headings with the '#' markers stripped). Wrapped
|
|
584
|
+
// so a long heading never runs off the right edge.
|
|
574
585
|
const h1 = line.match(/^#\s+(.+)$/);
|
|
575
586
|
if (h1) {
|
|
576
|
-
out.push(`\x1b[1;36m${formatInlineMarkdown(h1[1])}\x1b[0m
|
|
587
|
+
out.push(...wrapStyledToWidth(`\x1b[1;36m${formatInlineMarkdown(h1[1])}\x1b[0m`, width));
|
|
577
588
|
continue;
|
|
578
589
|
}
|
|
579
590
|
const h2 = line.match(/^##\s+(.+)$/);
|
|
580
591
|
if (h2) {
|
|
581
|
-
out.push(`\x1b[1;36m${formatInlineMarkdown(h2[1])}\x1b[0m
|
|
592
|
+
out.push(...wrapStyledToWidth(`\x1b[1;36m${formatInlineMarkdown(h2[1])}\x1b[0m`, width));
|
|
582
593
|
continue;
|
|
583
594
|
}
|
|
584
595
|
const h3 = line.match(/^###\s+(.+)$/);
|
|
585
596
|
if (h3) {
|
|
586
|
-
out.push(`\x1b[1;37m${formatInlineMarkdown(h3[1])}\x1b[0m
|
|
597
|
+
out.push(...wrapStyledToWidth(`\x1b[1;37m${formatInlineMarkdown(h3[1])}\x1b[0m`, width));
|
|
587
598
|
continue;
|
|
588
599
|
}
|
|
589
|
-
// Blockquote
|
|
600
|
+
// Blockquote. Wrapped inside the "│ " gutter so a long quote never runs off
|
|
601
|
+
// the right edge.
|
|
590
602
|
const bq = line.match(/^>\s*(.+)$/);
|
|
591
603
|
if (bq) {
|
|
592
|
-
|
|
604
|
+
const wrapped = wrapStyledToWidth(`\x1b[3m${formatInlineMarkdown(bq[1])}\x1b[0m`, Math.max(width - 2, 1));
|
|
605
|
+
out.push(...wrapped.map((l) => `\x1b[90m│\x1b[0m ${l}`));
|
|
593
606
|
continue;
|
|
594
607
|
}
|
|
595
608
|
// Unordered List item
|
|
@@ -1307,7 +1320,7 @@ export function formatToolResult(rawResult, failed) {
|
|
|
1307
1320
|
const allLines = clean.split("\n");
|
|
1308
1321
|
const lines = allLines
|
|
1309
1322
|
.slice(0, TOOL_RESULT_MAX_LINES)
|
|
1310
|
-
.map((ln) => (ln
|
|
1323
|
+
.map((ln) => (plainLen(ln) > lineMax ? truncateStyled(ln, lineMax) + "…" : ln));
|
|
1311
1324
|
if (allLines.length > TOOL_RESULT_MAX_LINES)
|
|
1312
1325
|
lines.push("…");
|
|
1313
1326
|
const styleOpen = failed ? "\x1b[31m" : "\x1b[90m";
|