@oxecli/oxe 1.0.75 → 1.0.76

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
@@ -44,7 +44,7 @@ function displayDiff(pathName, oldContent, newContent) {
44
44
  if (oldContent.length + newContent.length > max_diff_source_chars) {
45
45
  pendingDiffOutput.push(`\x1b[90m${pathName}: ${oldContent.length.toLocaleString()} chars -> ${newContent.length.toLocaleString()} chars ` +
46
46
  `(diff hidden: exceeds ${max_diff_source_chars.toLocaleString()} char limit)\x1b[0m`);
47
- return;
47
+ return null;
48
48
  }
49
49
  const patch = structuredPatch(pathName, pathName, oldContent, newContent, "", "", { context: max_diff_context_lines });
50
50
  const contentLines = [];
@@ -74,7 +74,7 @@ function displayDiff(pathName, oldContent, newContent) {
74
74
  const added = contentLines.filter((c) => c.kind === "+").length;
75
75
  const removed = contentLines.filter((c) => c.kind === "-").length;
76
76
  if (!added && !removed)
77
- return;
77
+ return null;
78
78
  const shown = [];
79
79
  let run = [];
80
80
  let lastKind = null;
@@ -121,51 +121,30 @@ function displayDiff(pathName, oldContent, newContent) {
121
121
  if (v.newNum)
122
122
  maxNum = Math.max(maxNum, v.newNum);
123
123
  }
124
- const numW = Math.max(String(maxNum).length, 2);
125
- let contentW = 0;
126
- for (const v of visible) {
127
- const len = v.kind === "~" ? plainLen(v.body) : numW + 1 + 2 + plainLen(v.body);
128
- contentW = Math.max(contentW, len);
129
- }
130
- const headerPlain = `${pathName} +${added} -${removed}`;
131
- const boxW = Math.min(Math.max(contentW + 6, plainLen(headerPlain) + 6), Math.max(termW - 2, 20));
132
- const innerW = Math.max(boxW - 4, 1);
133
- const maxPath = Math.max(10, boxW - 2 - plainLen(` +${added} -${removed}`) - 3);
134
- let pathDisp = pathName;
135
- if (plainLen(pathDisp) > maxPath)
136
- pathDisp = truncateStyled(pathDisp, Math.max(maxPath - 1, 1)) + "…";
137
- const header = `\x1b[1m${pathDisp}\x1b[0m \x1b[32m+${added}\x1b[0m \x1b[31m-${removed}\x1b[0m`;
138
- const headerStr = `─ ${header} `;
139
- const top = `╭${headerStr}${"─".repeat(Math.max(0, boxW - 2 - plainLen(headerStr)))}╮`;
140
- pendingDiffOutput.push(`\x1b[90m${top}\x1b[0m`);
141
- const bodyMax = Math.max(innerW - numW - 3, 1);
124
+ const numW = String(maxNum).length;
125
+ const indent = " ";
126
+ const bodyMax = Math.max(termW - plainLen(indent) - numW - 4, 20);
142
127
  const gap = " ".repeat(numW);
143
128
  for (const v of visible) {
144
129
  if (v.kind === "~") {
145
- const body = truncateStyled(v.body, innerW - 2);
146
- const text = `\x1b[90m${gap} ${body}\x1b[0m`;
147
- const fill = Math.max(0, innerW - plainLen(text));
148
- pendingDiffOutput.push(`\x1b[90m│\x1b[0m ${text}${" ".repeat(fill)} \x1b[90m│\x1b[0m`);
130
+ const body = truncateStyled(v.body, bodyMax);
131
+ pendingDiffOutput.push(`\x1b[90m${indent}${gap} ${body}\x1b[0m`);
149
132
  continue;
150
133
  }
151
134
  const num = v.kind === "+" ? v.newNum : v.oldNum;
152
135
  const numStr = num ? String(num).padStart(numW, " ") : gap;
153
136
  if (v.kind === "+" || v.kind === "-") {
154
137
  const color = v.kind === "+" ? "\x1b[32m" : "\x1b[31m";
138
+ const sign = v.kind === "+" ? "+" : "-";
155
139
  const body = truncateStyled(v.body, bodyMax);
156
- const text = `${numStr} ${v.kind === "+" ? "+ " : "- "}${body}`;
157
- const fill = Math.max(0, innerW - plainLen(text));
158
- // Whole line is painted green/red, filling to the right edge.
159
- pendingDiffOutput.push(`\x1b[90m│\x1b[0m ${color}${text}${" ".repeat(fill)}\x1b[0m \x1b[90m│\x1b[0m`);
140
+ pendingDiffOutput.push(`${indent}${color}${numStr} ${sign} ${body}\x1b[0m`);
160
141
  }
161
142
  else {
162
143
  const body = truncateStyled(v.kind === "\\" ? v.body : highlightCodeLine(v.body), bodyMax);
163
- const text = `\x1b[90m${numStr} ${body}\x1b[0m`;
164
- const fill = Math.max(0, innerW - plainLen(text));
165
- pendingDiffOutput.push(`\x1b[90m│\x1b[0m ${text}${" ".repeat(fill)} \x1b[90m│\x1b[0m`);
144
+ pendingDiffOutput.push(`\x1b[90m${indent}${numStr} ${body}\x1b[0m`);
166
145
  }
167
146
  }
168
- pendingDiffOutput.push(`\x1b[90m╰${"─".repeat(boxW - 2)}╯\x1b[0m`);
147
+ return { added, removed };
169
148
  }
170
149
  export function truncateToolOutput(output, maxChars = max_output_chars) {
171
150
  if (output.length > maxChars) {
@@ -491,7 +470,6 @@ export function toolEditFile(pathName, oldString, newString, replaceAll = false)
491
470
  const text = data.toString("utf-8");
492
471
  const newline = detectNewline(text);
493
472
  let match;
494
- let normalized = false;
495
473
  if (text.includes(oldString)) {
496
474
  match = oldString;
497
475
  }
@@ -499,7 +477,6 @@ export function toolEditFile(pathName, oldString, newString, replaceAll = false)
499
477
  const norm = withNewlines(oldString, newline);
500
478
  if (text.includes(norm)) {
501
479
  match = norm;
502
- normalized = true;
503
480
  }
504
481
  else {
505
482
  const blocks = findWsBlocks(text, oldString);
@@ -508,7 +485,6 @@ export function toolEditFile(pathName, oldString, newString, replaceAll = false)
508
485
  "(line endings and per-line leading/trailing whitespace are normalized for matching)");
509
486
  }
510
487
  match = blocks[0];
511
- normalized = true;
512
488
  }
513
489
  }
514
490
  const count = text.split(match).length - 1;
@@ -519,15 +495,17 @@ export function toolEditFile(pathName, oldString, newString, replaceAll = false)
519
495
  const newContent = replaceAll
520
496
  ? text.split(match).join(insert)
521
497
  : text.replace(match, insert);
522
- displayDiff(pathName, text, newContent);
498
+ const summary = displayDiff(pathName, text, newContent);
523
499
  try {
524
500
  fs.writeFileSync(p, newContent, "utf-8");
525
501
  }
526
502
  catch (err) {
527
503
  return `Error: ${err}`;
528
504
  }
529
- return (`Edited ${pathName} (${count} occurrence${count !== 1 ? "s" : ""} replaced` +
530
- `${normalized ? "; line endings and per-line whitespace normalized" : ""})`);
505
+ if (!summary)
506
+ return `Edited ${pathName}`;
507
+ return (`Added ${summary.added} line${summary.added !== 1 ? "s" : ""}, ` +
508
+ `removed ${summary.removed} line${summary.removed !== 1 ? "s" : ""}`);
531
509
  }
532
510
  // ---------------------------------------------------------------------------
533
511
  // bash
package/dist/ui.js CHANGED
@@ -556,7 +556,7 @@ export class Spinner {
556
556
  draw() {
557
557
  const text = this.render ? this.render() : "";
558
558
  const icon = SPINNER_FRAMES[this.frame % SPINNER_FRAMES.length];
559
- const rendered = `\x1b[36m${icon}\x1b[0m \x1b[90m${text}\x1b[0m`;
559
+ const rendered = `\x1b[1;36m${icon}\x1b[0m \x1b[90m${text}\x1b[0m`;
560
560
  // Nothing changed on this tick -> do not rewrite the line (avoids flicker).
561
561
  if (rendered === this.lastRendered)
562
562
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },