@oxecli/oxe 1.0.57 → 1.0.59

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/engine.js CHANGED
@@ -149,7 +149,7 @@ export class InferenceEngine {
149
149
  process.stdout.write("\x1b[1A\x1b[2K");
150
150
  }
151
151
  process.stdout.write(mutedMarkdown(text) + "\n\n");
152
- this.workRows = displayRows(text) + 1;
152
+ this.workRows = displayRows(mutedMarkdown(text)) + 1;
153
153
  }
154
154
  clearWorkLine() {
155
155
  if (!this.workActive || this.workRows < 1)
@@ -196,7 +196,7 @@ export class InferenceEngine {
196
196
  else {
197
197
  process.stdout.write(mutedMarkdown(`Worked for ${t}`) + "\n\n");
198
198
  this.workActive = true;
199
- this.workRows = displayRows(`Worked for ${t}`) + 1;
199
+ this.workRows = displayRows(mutedMarkdown(`Worked for ${t}`)) + 1;
200
200
  }
201
201
  };
202
202
  const finishThinking = (report) => {
package/dist/ui.js CHANGED
@@ -64,6 +64,38 @@ export function stripAnsi(s) {
64
64
  export function plainLen(s) {
65
65
  return stripAnsi(s).length;
66
66
  }
67
+ // Truncate styled text to a max number of visible characters while keeping
68
+ // ANSI escape sequences intact (never cut mid-sequence).
69
+ export function truncateStyled(text, maxVisible) {
70
+ if (maxVisible <= 0)
71
+ return "";
72
+ if (plainLen(text) <= maxVisible)
73
+ return text;
74
+ const re = ANSI_RE;
75
+ re.lastIndex = 0;
76
+ let out = "";
77
+ let visible = 0;
78
+ let last = 0;
79
+ let m;
80
+ while ((m = re.exec(text)) !== null) {
81
+ if (m.index > last) {
82
+ const seg = text.slice(last, m.index);
83
+ const room = maxVisible - visible;
84
+ if (room <= 0)
85
+ return out;
86
+ out += seg.slice(0, room);
87
+ visible += Math.min(seg.length, room);
88
+ if (visible >= maxVisible)
89
+ return out;
90
+ }
91
+ out += m[0];
92
+ last = m.index + m[0].length;
93
+ }
94
+ if (visible < maxVisible) {
95
+ out += text.slice(last, last + (maxVisible - visible));
96
+ }
97
+ return out;
98
+ }
67
99
  // ---------------------------------------------------------------------------
68
100
  // Markup tag -> ANSI
69
101
  // ---------------------------------------------------------------------------
@@ -377,7 +409,8 @@ function panelString(content, title = "", subtitle = "", expand = true, borderSt
377
409
  const line = styledLines[i];
378
410
  const plain = plainLines[i] ?? "";
379
411
  const pad = Math.max(innerW - plain.length, 0);
380
- out.push(`\x1b[${borderStyle}m│\x1b[0m ${line}${" ".repeat(pad)} \x1b[${borderStyle}m│\x1b[0m`);
412
+ const display = plain.length > innerW ? truncateStyled(line, innerW) : line;
413
+ out.push(`\x1b[${borderStyle}m│\x1b[0m ${display}${" ".repeat(pad)} \x1b[${borderStyle}m│\x1b[0m`);
381
414
  }
382
415
  const bottom = `╰${embed(subtitle, "center")}╯`;
383
416
  out.push(`\x1b[${borderStyle}m${bottom}\x1b[0m`);
@@ -841,9 +874,6 @@ export function isShiftEnterKey(str, key) {
841
874
  seq === "\x1bOM") {
842
875
  return true;
843
876
  }
844
- if (!key.ctrl && (str === "\n" || seq === "\n" || key.name === "linefeed")) {
845
- return true;
846
- }
847
877
  return false;
848
878
  }
849
879
  export const isNewlineKey = isShiftEnterKey;
@@ -854,7 +884,6 @@ export function isSubmitEnterKey(str, key) {
854
884
  return false;
855
885
  const seq = key.sequence || str || "";
856
886
  if ((key.name === "return" ||
857
- key.name === "enter" ||
858
887
  seq === "\r" ||
859
888
  seq === "\x1b[13u" ||
860
889
  seq === "\x1b[13;1u") &&
@@ -1341,6 +1370,13 @@ export function askBottomPrompt(label = "You", prefix = "❯", history = []) {
1341
1370
  repaint();
1342
1371
  return;
1343
1372
  }
1373
+ // Ctrl+J sends a bare LF (0x0a). Node reports it as name "enter" or
1374
+ // "linefeed" with no shift modifier. Only Shift+Enter should create a
1375
+ // new row, so ignore a lone LF (it is not a real Enter — a real Enter
1376
+ // arrives as CR / name "return").
1377
+ if (key && !key.shift && (key.name === "enter" || key.name === "linefeed")) {
1378
+ return;
1379
+ }
1344
1380
  if (str) {
1345
1381
  const isPaste = str.length > 1;
1346
1382
  insert(str.replace(/\r\n/g, "\n").replace(/\r/g, "\n"), isPaste);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },