@nomad-e/bluma-cli 0.6.9 → 0.7.0

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.
@@ -18,6 +18,13 @@ license: Proprietary. LICENSE.txt has complete terms
18
18
  > design agency, not a script. Typography, spacing, color, and hierarchy are
19
19
  > not optional — they are the foundation of a credible document.
20
20
 
21
+ ## Prerequisites
22
+
23
+ - **Python 3.10+** installed and available in PATH
24
+ - Install dependencies: `pip install reportlab pypdf`
25
+ - If any script fails with `command not found` or `ModuleNotFoundError`, Python or its
26
+ packages are missing — install them before proceeding
27
+
21
28
  ## MANDATORY workflow — new multi-page reports (read first)
22
29
 
23
30
  Ad-hoc 30-line ReportLab scripts are the #1 cause of “cheap PDF” output (no
@@ -46,8 +46,24 @@ from pathlib import Path
46
46
  from typing import Any
47
47
  from xml.sax.saxutils import escape
48
48
 
49
- from reportlab.lib.pagesizes import A4
50
- from reportlab.lib.units import cm
49
+ MIN_PYTHON = (3, 10)
50
+ if sys.version_info < MIN_PYTHON:
51
+ print(
52
+ f"Error: Python {'.'.join(map(str, MIN_PYTHON))}+ is required "
53
+ f"(found {'.'.join(map(str, sys.version_info[:3]))})",
54
+ file=sys.stderr,
55
+ )
56
+ sys.exit(1)
57
+
58
+ try:
59
+ from reportlab.lib.pagesizes import A4
60
+ from reportlab.lib.units import cm
61
+ except ImportError:
62
+ print(
63
+ "Error: reportlab is required. Install with: pip install reportlab",
64
+ file=sys.stderr,
65
+ )
66
+ sys.exit(1)
51
67
  from reportlab.lib.colors import HexColor
52
68
  from reportlab.lib.styles import ParagraphStyle
53
69
  from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY
@@ -8,6 +8,15 @@ Usage:
8
8
  import argparse
9
9
  import sys
10
10
 
11
+ MIN_PYTHON = (3, 10)
12
+ if sys.version_info < MIN_PYTHON:
13
+ print(
14
+ f"Error: Python {'.'.join(map(str, MIN_PYTHON))}+ is required "
15
+ f"(found {'.'.join(map(str, sys.version_info[:3]))})",
16
+ file=sys.stderr,
17
+ )
18
+ sys.exit(1)
19
+
11
20
  def merge_pdfs(input_files: list[str], output_path: str) -> None:
12
21
  try:
13
22
  from pypdf import PdfWriter, PdfReader
@@ -16,6 +16,14 @@ license: Proprietary. LICENSE.txt has complete terms
16
16
 
17
17
  # XLSX — Spreadsheet Creation, Editing & Analysis
18
18
 
19
+ ## Prerequisites
20
+
21
+ - **Python 3.10+** installed and available in PATH
22
+ - Install dependencies: `pip install openpyxl pandas`
23
+ - **LibreOffice** installed (required by `recalc.py` for formula recalculation)
24
+ - If any script fails with `command not found` or `ModuleNotFoundError`, Python or its
25
+ packages are missing — install them before proceeding
26
+
19
27
  ## Core Principle
20
28
 
21
29
  > **Formulas, not hardcodes.** Every calculated value MUST be an Excel
@@ -19,6 +19,15 @@ import os
19
19
  import sys
20
20
  import time
21
21
 
22
+ MIN_PYTHON = (3, 10)
23
+ if sys.version_info < MIN_PYTHON:
24
+ print(
25
+ f"Error: Python {'.'.join(map(str, MIN_PYTHON))}+ is required "
26
+ f"(found {'.'.join(map(str, sys.version_info[:3]))})",
27
+ file=sys.stderr,
28
+ )
29
+ sys.exit(1)
30
+
22
31
  SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
23
32
  sys.path.insert(0, SCRIPT_DIR)
24
33
 
package/dist/main.js CHANGED
@@ -15366,7 +15366,7 @@ function createDiff(filename, oldContent, newContent) {
15366
15366
  const prefix = part.added ? "+" : part.removed ? "-" : " ";
15367
15367
  const lines = part.value.split("\n").slice(0, -1);
15368
15368
  for (const line of lines) {
15369
- if (line === "\") continue;
15369
+ if (line === "") continue;
15370
15370
  diffString += `${prefix}${line}
15371
15371
  `;
15372
15372
  lineCount++;
@@ -29086,10 +29086,7 @@ var HighlightedCodeComponent = ({ code, filePath, maxLines }) => {
29086
29086
  visible.map((line, idx) => {
29087
29087
  const tokens = tokenizeLine(line, language);
29088
29088
  const lineNum = String(idx + 1).padStart(gutterWidth, " ");
29089
- return /* @__PURE__ */ jsxs5(Box_default, { width: "100%", flexDirection: "row", children: [
29090
- /* @__PURE__ */ jsx12(Box_default, { marginRight: 2, children: /* @__PURE__ */ jsx12(Text, { color: THEME.lineNumber, children: lineNum }) }),
29091
- /* @__PURE__ */ jsx12(Text, { children: tokens.map((t, ti) => /* @__PURE__ */ jsx12(Text, { color: t.color, children: t.text }, ti)) })
29092
- ] }, idx);
29089
+ return /* @__PURE__ */ jsx12(Box_default, { width: "100%", flexDirection: "row", children: /* @__PURE__ */ jsx12(Text, { children: tokens.map((t, ti) => /* @__PURE__ */ jsx12(Text, { color: t.color, children: t.text }, ti)) }) }, idx);
29093
29090
  }),
29094
29091
  hidden > 0 && /* @__PURE__ */ jsxs5(Text, { color: THEME.lineNumber, dimColor: true, children: [
29095
29092
  "\u2026 +",
@@ -32563,14 +32560,64 @@ function diffSummary(additions, removals, hidden) {
32563
32560
  if (hidden > 0) bits.push(`\u22EF ${hidden} hidden`);
32564
32561
  return bits.join(" \xB7 ");
32565
32562
  }
32563
+ var THEME2 = {
32564
+ keyword: "#569CD6",
32565
+ string: "#CE9178",
32566
+ number: "#B5CEA8",
32567
+ comment: "#6A9955",
32568
+ //#22c55e
32569
+ function: "#DCDCAA",
32570
+ variable: "#9CDCFE",
32571
+ operator: "#D4D4D4",
32572
+ punctuation: "#D4D4D4",
32573
+ default: "#D4D4D4",
32574
+ lineNumber: "#858585",
32575
+ gutter: "#404040"
32576
+ };
32577
+ var KEYWORDS2 = /* @__PURE__ */ new Set([
32578
+ "const",
32579
+ "let",
32580
+ "var",
32581
+ "function",
32582
+ "return",
32583
+ "if",
32584
+ "else",
32585
+ "for",
32586
+ "while",
32587
+ "switch",
32588
+ "case",
32589
+ "break",
32590
+ "continue",
32591
+ "class",
32592
+ "extends",
32593
+ "import",
32594
+ "from",
32595
+ "export",
32596
+ "default",
32597
+ "async",
32598
+ "await",
32599
+ "try",
32600
+ "catch",
32601
+ "finally",
32602
+ "new",
32603
+ "typeof",
32604
+ "instanceof",
32605
+ "null",
32606
+ "undefined",
32607
+ "true",
32608
+ "false",
32609
+ "type",
32610
+ "interface",
32611
+ "enum",
32612
+ "implements",
32613
+ "abstract",
32614
+ "readonly",
32615
+ "override"
32616
+ ]);
32566
32617
  function hunkToRows(hunk) {
32567
32618
  const rows = [];
32568
32619
  let oldLine = hunk.oldStart;
32569
32620
  let newLine = hunk.newStart;
32570
- rows.push({
32571
- kind: "meta",
32572
- text: `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`
32573
- });
32574
32621
  for (const raw of hunk.lines) {
32575
32622
  if (!raw.length) continue;
32576
32623
  const prefix = raw[0];
@@ -32611,22 +32658,22 @@ function pairWordDiffs(rows) {
32611
32658
  }
32612
32659
  return out;
32613
32660
  }
32614
- function maxLineNums(rows) {
32615
- let maxO = 0;
32661
+ function calcGutterW(rows) {
32616
32662
  let maxN = 0;
32617
32663
  for (const r of rows) {
32618
- if (r.kind === "ctx") {
32619
- maxO = Math.max(maxO, r.old);
32620
- maxN = Math.max(maxN, r.new);
32621
- } else if (r.kind === "rem") {
32622
- maxO = Math.max(maxO, r.old);
32623
- } else if (r.kind === "add") {
32624
- maxN = Math.max(maxN, r.new);
32625
- }
32664
+ if (r.kind === "ctx") maxN = Math.max(maxN, r.old, r.new);
32665
+ else if (r.kind === "rem") maxN = Math.max(maxN, r.old);
32666
+ else if (r.kind === "add") maxN = Math.max(maxN, r.new);
32626
32667
  }
32627
- const wOld = Math.max(2, String(maxO || 0).length);
32628
- const wNew = Math.max(2, String(maxN || 0).length);
32629
- return { wOld, wNew };
32668
+ return Math.max(2, String(maxN || 0).length);
32669
+ }
32670
+ function calcLegacyGutterW(segs) {
32671
+ let maxN = 0;
32672
+ for (const s of segs) {
32673
+ if (s.kind === "rem") maxN = Math.max(maxN, s.oldLine);
32674
+ if (s.kind === "add") maxN = Math.max(maxN, s.newLine);
32675
+ }
32676
+ return Math.max(2, String(maxN || 0).length);
32630
32677
  }
32631
32678
  function rowLineCounts(rows) {
32632
32679
  let additions = 0;
@@ -32637,21 +32684,11 @@ function rowLineCounts(rows) {
32637
32684
  }
32638
32685
  return { additions, removals };
32639
32686
  }
32640
- function gutterCtx(wOld, wNew, oldN, newN, showSeparator) {
32641
- return `${String(oldN).padStart(wOld)} ${String(newN).padStart(wNew)}${showSeparator ? " \u2502 " : " "}`;
32642
- }
32643
- function gutterRem(wOld, wNew, oldN, showSeparator) {
32644
- return `${String(oldN).padStart(wOld)} ${" ".repeat(wNew)}${showSeparator ? " \u2502 " : " "}`;
32645
- }
32646
- function gutterAdd(wOld, wNew, newN, showSeparator) {
32647
- return `${" ".repeat(wOld)} ${String(newN).padStart(wNew)}${showSeparator ? " \u2502 " : " "}`;
32687
+ function gutterLine(w, n) {
32688
+ return ` ${String(n).padEnd(w)} `;
32648
32689
  }
32649
- function gutterOmit(wOld, wNew, showSeparator) {
32650
- const cols = wOld + 1 + wNew;
32651
- const dot = "\u22EE";
32652
- const padL = Math.max(0, Math.floor((cols - dot.length) / 2));
32653
- const padR = Math.max(0, cols - dot.length - padL);
32654
- return `${" ".repeat(padL)}${dot}${" ".repeat(padR)}${showSeparator ? " \u2502 " : " "}`;
32690
+ function gutterOmit(w) {
32691
+ return ` ${"\u22EE".padEnd(w)} `;
32655
32692
  }
32656
32693
  function WordDiffChunks({
32657
32694
  parts,
@@ -32671,9 +32708,82 @@ function WordDiffChunks({
32671
32708
  }
32672
32709
  return /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", width: "100%", flexGrow: 1, children: chunks });
32673
32710
  }
32674
- function renderStructuredRows(rows, maxHeight, showGutterSeparator) {
32711
+ function collapseContextRows(rows) {
32712
+ const out = [];
32713
+ let ctx = [];
32714
+ const flush = () => {
32715
+ if (ctx.length <= 3) {
32716
+ out.push(...ctx);
32717
+ } else {
32718
+ out.push({ kind: "omit", count: ctx.length });
32719
+ }
32720
+ ctx = [];
32721
+ };
32722
+ for (const r of rows) {
32723
+ if (r.kind === "ctx") {
32724
+ ctx.push(r);
32725
+ continue;
32726
+ }
32727
+ flush();
32728
+ out.push(r);
32729
+ }
32730
+ flush();
32731
+ return out;
32732
+ }
32733
+ function tokenizeLine2(line, _language) {
32734
+ if (!line.trim()) return [{ text: line || " ", color: THEME2.default }];
32735
+ const tokens = [];
32736
+ let i = 0;
32737
+ while (i < line.length) {
32738
+ if (/\s/.test(line[i])) {
32739
+ let spaces = "";
32740
+ while (i < line.length && /\s/.test(line[i])) spaces += line[i++];
32741
+ tokens.push({ text: spaces, color: THEME2.default });
32742
+ continue;
32743
+ }
32744
+ if (line[i] === "/" && line[i + 1] === "/") {
32745
+ tokens.push({ text: line.slice(i), color: THEME2.comment });
32746
+ break;
32747
+ }
32748
+ if (line[i] === "#") {
32749
+ tokens.push({ text: line.slice(i), color: THEME2.comment });
32750
+ break;
32751
+ }
32752
+ if (line[i] === '"' || line[i] === "'" || line[i] === "`") {
32753
+ const quote = line[i];
32754
+ let j = i + 1;
32755
+ while (j < line.length && line[j] !== quote) {
32756
+ if (line[j] === "\\") j++;
32757
+ j++;
32758
+ }
32759
+ tokens.push({ text: line.slice(i, j + 1), color: THEME2.string });
32760
+ i = j + 1;
32761
+ continue;
32762
+ }
32763
+ if (/\d/.test(line[i])) {
32764
+ let num = "";
32765
+ while (i < line.length && /[\d.]/.test(line[i])) num += line[i++];
32766
+ tokens.push({ text: num, color: THEME2.number });
32767
+ continue;
32768
+ }
32769
+ if (/[a-zA-Z_$]/.test(line[i])) {
32770
+ let word = "";
32771
+ while (i < line.length && /[\w$]/.test(line[i])) word += line[i++];
32772
+ const isCall = line[i] === "(";
32773
+ let color = THEME2.variable;
32774
+ if (KEYWORDS2.has(word)) color = THEME2.keyword;
32775
+ else if (isCall) color = THEME2.function;
32776
+ tokens.push({ text: word, color });
32777
+ continue;
32778
+ }
32779
+ tokens.push({ text: line[i], color: THEME2.punctuation });
32780
+ i++;
32781
+ }
32782
+ return tokens;
32783
+ }
32784
+ function renderStructuredRows(rows, maxHeight) {
32675
32785
  const paired = collapseContextRows(pairWordDiffs(rows));
32676
- const { wOld, wNew } = maxLineNums(paired);
32786
+ const w = calcGutterW(paired);
32677
32787
  const { additions, removals } = rowLineCounts(paired);
32678
32788
  const nodes = [];
32679
32789
  let lineBudget = maxHeight > 0 ? maxHeight : Number.POSITIVE_INFINITY;
@@ -32690,11 +32800,13 @@ function renderStructuredRows(rows, maxHeight, showGutterSeparator) {
32690
32800
  for (const r of paired) {
32691
32801
  if (r.kind === "omit") {
32692
32802
  push(
32693
- /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, children: [
32694
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterOmit(wOld, wNew, showGutterSeparator) }),
32695
- r.count > 1 ? /* @__PURE__ */ jsxs26(Text, { dimColor: true, wrap: "wrap", children: [
32803
+ /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, paddingLeft: 5, children: [
32804
+ /* @__PURE__ */ jsxs26(Text, { dimColor: true, children: [
32696
32805
  " ",
32697
- "\xB7 ",
32806
+ gutterOmit(w)
32807
+ ] }),
32808
+ r.count > 1 ? /* @__PURE__ */ jsxs26(Text, { dimColor: true, wrap: "wrap", children: [
32809
+ " \xB7 ",
32698
32810
  r.count
32699
32811
  ] }) : null
32700
32812
  ] }, `o-${idx++}`)
@@ -32703,35 +32815,32 @@ function renderStructuredRows(rows, maxHeight, showGutterSeparator) {
32703
32815
  }
32704
32816
  if (r.kind === "meta") {
32705
32817
  push(
32706
- /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, children: /* @__PURE__ */ jsx41(Text, { dimColor: true, wrap: "wrap", children: r.text }) }, `m-${idx++}`)
32818
+ /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, children: tokenizeLine2(r.text || " ", "ts").map((t, i) => /* @__PURE__ */ jsx41(Text, { color: t.color, children: t.text }, i)) }, `m-${idx++}`)
32707
32819
  );
32708
32820
  continue;
32709
32821
  }
32710
32822
  if (r.kind === "ctx") {
32711
32823
  push(
32712
- /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", flexWrap: "wrap", width: "100%", flexGrow: 1, children: [
32713
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterCtx(wOld, wNew, r.old, r.new, showGutterSeparator) }),
32714
- /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.muted, wrap: "wrap", children: r.text || " " })
32715
- ] }, `c-${idx++}`)
32824
+ /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", width: "100%", flexGrow: 1, children: tokenizeLine2(r.text || " ", "ts").map((t, i) => /* @__PURE__ */ jsx41(Text, { color: t.color, children: t.text }, i)) }, `c-${idx++}`)
32716
32825
  );
32717
32826
  continue;
32718
32827
  }
32719
32828
  if (r.kind === "rem") {
32720
32829
  push(
32721
- /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, flexWrap: "wrap", backgroundColor: BLUMA_TERMINAL.diffRemoved, children: [
32722
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterRem(wOld, wNew, r.old, showGutterSeparator) }),
32830
+ /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, flexWrap: "wrap", backgroundColor: BLUMA_TERMINAL.diffRemoved, paddingLeft: 3, children: [
32831
+ /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.dim, children: gutterLine(w, r.old) }),
32723
32832
  /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.diffRemovedWord, children: "-" }),
32724
- r.wordParts && r.wordParts.length > 0 ? /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", flexGrow: 1, marginLeft: 1, children: /* @__PURE__ */ jsx41(WordDiffChunks, { parts: r.wordParts, mode: "rem" }) }) : /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", flexGrow: 1, marginLeft: 1, children: /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.m3OnSurface, wrap: "wrap", children: r.text || " " }) })
32833
+ r.wordParts && r.wordParts.length > 0 ? /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", flexGrow: 1, marginLeft: 1, children: /* @__PURE__ */ jsx41(WordDiffChunks, { parts: r.wordParts, mode: "rem" }) }) : /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", children: tokenizeLine2(r.text || " ", "ts").map((t, i) => /* @__PURE__ */ jsx41(Text, { color: t.color, children: t.text }, i)) })
32725
32834
  ] }, `r-${idx++}`)
32726
32835
  );
32727
32836
  continue;
32728
32837
  }
32729
32838
  if (r.kind === "add") {
32730
32839
  push(
32731
- /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, flexWrap: "wrap", backgroundColor: BLUMA_TERMINAL.diffAdded, children: [
32732
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterAdd(wOld, wNew, r.new, showGutterSeparator) }),
32840
+ /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, flexWrap: "wrap", backgroundColor: BLUMA_TERMINAL.diffAdded, paddingLeft: 3, children: [
32841
+ /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.dim, children: gutterLine(w, r.new) }),
32733
32842
  /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.diffAddedWord, children: "+" }),
32734
- r.wordParts && r.wordParts.length > 0 ? /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", flexGrow: 1, marginLeft: 1, children: /* @__PURE__ */ jsx41(WordDiffChunks, { parts: r.wordParts, mode: "add" }) }) : /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", flexGrow: 1, marginLeft: 1, children: /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.m3OnSurface, wrap: "wrap", children: r.text || " " }) })
32843
+ r.wordParts && r.wordParts.length > 0 ? /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", flexGrow: 1, children: /* @__PURE__ */ jsx41(WordDiffChunks, { parts: r.wordParts, mode: "add" }) }) : /* @__PURE__ */ jsx41(Box_default, { flexDirection: "row", flexWrap: "wrap", children: tokenizeLine2(r.text || " ", "ts").map((t, i) => /* @__PURE__ */ jsx41(Text, { color: t.color, children: t.text }, i)) })
32735
32844
  ] }, `a-${idx++}`)
32736
32845
  );
32737
32846
  }
@@ -32756,15 +32865,18 @@ function legacyDiffToSegs(lines) {
32756
32865
  const isNewHeader = line.startsWith("+++");
32757
32866
  if (isOldHeader || isNewHeader) {
32758
32867
  flushCtx();
32759
- out.push({ kind: "header", line });
32760
32868
  if (isNewHeader) {
32761
32869
  oldLine = 1;
32762
32870
  newLine = 1;
32763
32871
  }
32764
32872
  continue;
32765
32873
  }
32766
- const isRem = line.startsWith("-") && !isOldHeader;
32767
- const isAdd = line.startsWith("+") && !isNewHeader;
32874
+ if (line.startsWith("\\")) {
32875
+ flushCtx();
32876
+ continue;
32877
+ }
32878
+ const isRem = line.startsWith("-");
32879
+ const isAdd = line.startsWith("+");
32768
32880
  if (isRem) {
32769
32881
  flushCtx();
32770
32882
  out.push({ kind: "rem", body: line.slice(1), oldLine });
@@ -32782,11 +32894,6 @@ function legacyDiffToSegs(lines) {
32782
32894
  ctx += 1;
32783
32895
  continue;
32784
32896
  }
32785
- if (line.startsWith("\\")) {
32786
- flushCtx();
32787
- out.push({ kind: "raw", line });
32788
- continue;
32789
- }
32790
32897
  if (line.startsWith("[")) {
32791
32898
  flushCtx();
32792
32899
  out.push({ kind: "raw", line });
@@ -32802,18 +32909,6 @@ function legacyDiffToSegs(lines) {
32802
32909
  flushCtx();
32803
32910
  return out;
32804
32911
  }
32805
- function legacySegWidths(segs) {
32806
- let maxO = 0;
32807
- let maxN = 0;
32808
- for (const s of segs) {
32809
- if (s.kind === "rem") maxO = Math.max(maxO, s.oldLine);
32810
- if (s.kind === "add") maxN = Math.max(maxN, s.newLine);
32811
- }
32812
- return {
32813
- wOld: Math.max(2, String(maxO || 0).length),
32814
- wNew: Math.max(2, String(maxN || 0).length)
32815
- };
32816
- }
32817
32912
  function legacySegLineCounts(lines) {
32818
32913
  let additions = 0;
32819
32914
  let removals = 0;
@@ -32823,86 +32918,106 @@ function legacySegLineCounts(lines) {
32823
32918
  }
32824
32919
  return { additions, removals };
32825
32920
  }
32826
- function collapseContextRows(rows) {
32827
- const out = [];
32828
- let ctxCount = 0;
32829
- const flush = () => {
32830
- if (ctxCount > 0) {
32831
- out.push({ kind: "omit", count: ctxCount });
32832
- ctxCount = 0;
32833
- }
32834
- };
32835
- for (const r of rows) {
32836
- if (r.kind === "ctx") {
32837
- ctxCount += 1;
32838
- continue;
32839
- }
32840
- if (r.kind === "meta" && r.text.startsWith("@@")) {
32841
- ctxCount += 1;
32842
- continue;
32843
- }
32844
- flush();
32845
- out.push(r);
32846
- }
32847
- flush();
32848
- return out;
32849
- }
32850
32921
  function LegacyDiffBody({
32851
32922
  lines,
32852
- maxHeight,
32853
- showGutterSeparator
32923
+ maxHeight
32854
32924
  }) {
32855
32925
  const segs = legacyDiffToSegs(lines);
32856
- const { wOld, wNew } = legacySegWidths(segs);
32926
+ const w = calcLegacyGutterW(segs);
32857
32927
  const truncated = maxHeight > 0 && segs.length > maxHeight;
32858
32928
  const toRender = truncated ? segs.slice(0, maxHeight) : segs;
32859
32929
  const hiddenBelow = truncated ? segs.length - toRender.length : 0;
32860
32930
  const { additions, removals } = legacySegLineCounts(lines);
32861
- const summary = diffSummary(additions, removals, hiddenBelow);
32862
- return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "column", width: "100%", alignItems: "stretch", children: [
32863
- toRender.map((seg, index) => {
32864
- if (seg.kind === "header") {
32865
- return /* @__PURE__ */ jsx41(Text, { dimColor: true, wrap: "wrap", children: seg.line }, index);
32866
- }
32867
- if (seg.kind === "omit") {
32868
- return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, children: [
32869
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterOmit(wOld, wNew, showGutterSeparator) }),
32870
- seg.count > 1 ? /* @__PURE__ */ jsxs26(Text, { dimColor: true, wrap: "wrap", children: [
32871
- " ",
32872
- "\xB7 ",
32873
- seg.count
32874
- ] }) : null
32875
- ] }, index);
32876
- }
32877
- if (seg.kind === "raw") {
32878
- return /* @__PURE__ */ jsx41(Text, { dimColor: true, wrap: "wrap", children: seg.line }, index);
32879
- }
32880
- if (seg.kind === "rem") {
32881
- return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, flexWrap: "wrap", backgroundColor: BLUMA_TERMINAL.diffRemoved, children: [
32882
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterRem(wOld, wNew, seg.oldLine, showGutterSeparator) }),
32883
- /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.diffRemovedWord, children: "-" }),
32884
- /* @__PURE__ */ jsxs26(Text, { color: BLUMA_TERMINAL.m3OnSurface, wrap: "wrap", children: [
32885
- " ",
32886
- seg.body || " "
32887
- ] })
32888
- ] }, index);
32889
- }
32890
- if (seg.kind === "add") {
32891
- return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "row", width: "100%", flexGrow: 1, flexWrap: "wrap", backgroundColor: BLUMA_TERMINAL.diffAdded, children: [
32892
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: gutterAdd(wOld, wNew, seg.newLine, showGutterSeparator) }),
32893
- /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.diffAddedWord, children: "+" }),
32894
- /* @__PURE__ */ jsxs26(Text, { color: BLUMA_TERMINAL.m3OnSurface, wrap: "wrap", children: [
32895
- " ",
32896
- seg.body || " "
32897
- ] })
32898
- ] }, index);
32899
- }
32900
- return null;
32901
- }),
32902
- summary ? /* @__PURE__ */ jsx41(Text, { dimColor: true, children: summary }) : null
32903
- ] });
32931
+ const summary = diffSummary(
32932
+ additions,
32933
+ removals,
32934
+ hiddenBelow
32935
+ );
32936
+ const renderTokenizedLine = (text, backgroundColor) => tokenizeLine2(text || " ", "ts").map((t, i) => /* @__PURE__ */ jsx41(Text, { color: t.color, backgroundColor, children: t.text }, i));
32937
+ return /* @__PURE__ */ jsx41(Box_default, { flexDirection: "column", width: "100%", children: toRender.map((seg, index) => {
32938
+ if (seg.kind === "omit") {
32939
+ return /* @__PURE__ */ jsx41(
32940
+ Box_default,
32941
+ {
32942
+ flexDirection: "row",
32943
+ width: "100%",
32944
+ flexGrow: 1,
32945
+ paddingLeft: 6,
32946
+ children: /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.dim, children: gutterOmit(w) })
32947
+ },
32948
+ index
32949
+ );
32950
+ }
32951
+ if (seg.kind === "raw") {
32952
+ return /* @__PURE__ */ jsx41(
32953
+ Box_default,
32954
+ {
32955
+ flexDirection: "row",
32956
+ width: "100%",
32957
+ flexWrap: "wrap",
32958
+ children: renderTokenizedLine(seg.line)
32959
+ },
32960
+ index
32961
+ );
32962
+ }
32963
+ if (seg.kind === "rem") {
32964
+ return /* @__PURE__ */ jsxs26(
32965
+ Box_default,
32966
+ {
32967
+ flexDirection: "row",
32968
+ width: "100%",
32969
+ flexGrow: 1,
32970
+ flexWrap: "wrap",
32971
+ backgroundColor: BLUMA_TERMINAL.diffRemoved,
32972
+ paddingLeft: 3,
32973
+ children: [
32974
+ /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.dim, children: gutterLine(w, seg.oldLine) }),
32975
+ /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.diffRemovedWord, children: "-" }),
32976
+ /* @__PURE__ */ jsx41(
32977
+ Box_default,
32978
+ {
32979
+ flexDirection: "row",
32980
+ flexWrap: "wrap",
32981
+ backgroundColor: BLUMA_TERMINAL.diffRemoved,
32982
+ children: renderTokenizedLine(seg.body, BLUMA_TERMINAL.diffRemoved)
32983
+ }
32984
+ )
32985
+ ]
32986
+ },
32987
+ index
32988
+ );
32989
+ }
32990
+ if (seg.kind === "add") {
32991
+ return /* @__PURE__ */ jsxs26(
32992
+ Box_default,
32993
+ {
32994
+ flexDirection: "row",
32995
+ width: "100%",
32996
+ flexGrow: 1,
32997
+ flexWrap: "wrap",
32998
+ backgroundColor: BLUMA_TERMINAL.diffAdded,
32999
+ paddingLeft: 3,
33000
+ children: [
33001
+ /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.dim, children: gutterLine(w, seg.newLine) }),
33002
+ /* @__PURE__ */ jsx41(Text, { color: BLUMA_TERMINAL.diffAddedWord, children: "+" }),
33003
+ /* @__PURE__ */ jsx41(
33004
+ Box_default,
33005
+ {
33006
+ flexDirection: "row",
33007
+ flexWrap: "wrap",
33008
+ backgroundColor: BLUMA_TERMINAL.diffAdded,
33009
+ children: renderTokenizedLine(seg.body, BLUMA_TERMINAL.diffAdded)
33010
+ }
33011
+ )
33012
+ ]
33013
+ },
33014
+ index
33015
+ );
33016
+ }
33017
+ return null;
33018
+ }) });
32904
33019
  }
32905
- var SimpleDiff = ({ text, maxHeight, frame = false, showGutterSeparator = true }) => {
33020
+ var SimpleDiff = ({ text, maxHeight, frame = false }) => {
32906
33021
  const raw = stripOptionalMarkdownFence(String(text ?? ""));
32907
33022
  let patches = [];
32908
33023
  try {
@@ -32914,31 +33029,18 @@ var SimpleDiff = ({ text, maxHeight, frame = false, showGutterSeparator = true }
32914
33029
  const rule = "\u2500".repeat(diffRuleWidth());
32915
33030
  if (hunks.length === 0) {
32916
33031
  const allLines = raw.split("\n");
32917
- const body2 = /* @__PURE__ */ jsx41(LegacyDiffBody, { lines: allLines, maxHeight, showGutterSeparator });
33032
+ const body2 = /* @__PURE__ */ jsx41(LegacyDiffBody, { lines: allLines, maxHeight });
32918
33033
  if (!frame) return body2;
32919
- return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "column", children: [
32920
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: rule }),
32921
- /* @__PURE__ */ jsx41(Box_default, { flexDirection: "column", paddingX: 1, children: body2 }),
32922
- /* @__PURE__ */ jsx41(Text, { dimColor: true, children: rule })
32923
- ] });
33034
+ return /* @__PURE__ */ jsx41(Box_default, { flexDirection: "column", children: /* @__PURE__ */ jsx41(Box_default, { flexDirection: "column", paddingX: 1, children: body2 }) });
32924
33035
  }
32925
33036
  const rows = [];
32926
33037
  for (const h of hunks) {
32927
33038
  rows.push(...hunkToRows(h));
32928
33039
  }
32929
- const { nodes, hidden, additions, removals } = renderStructuredRows(
32930
- rows,
32931
- maxHeight,
32932
- showGutterSeparator
32933
- );
32934
- const body = /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "column", width: "100%", alignItems: "stretch", children: [
32935
- (hidden > 0 || additions > 0 || removals > 0) && /* @__PURE__ */ jsx41(Text, { dimColor: true, children: diffSummary(additions, removals, hidden) }),
32936
- nodes
32937
- ] });
32938
- if (!frame) {
32939
- return body;
32940
- }
32941
- return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "column", width: "100%", alignItems: "stretch", children: [
33040
+ const { nodes, hidden, additions, removals } = renderStructuredRows(rows, maxHeight);
33041
+ const body = /* @__PURE__ */ jsx41(Box_default, { flexDirection: "column", width: "100%", children: nodes });
33042
+ if (!frame) return body;
33043
+ return /* @__PURE__ */ jsxs26(Box_default, { flexDirection: "column", width: "100%", children: [
32942
33044
  /* @__PURE__ */ jsx41(Text, { dimColor: true, children: rule }),
32943
33045
  /* @__PURE__ */ jsx41(Box_default, { flexDirection: "column", paddingX: 1, children: body }),
32944
33046
  /* @__PURE__ */ jsx41(Text, { dimColor: true, children: rule })
@@ -33040,7 +33142,6 @@ function EditToolDiffPanel({
33040
33142
  description,
33041
33143
  diffText,
33042
33144
  maxHeight = EDIT_DIFF_PREVIEW_MAX_LINES,
33043
- showGutterSeparator = true,
33044
33145
  oldString,
33045
33146
  newString,
33046
33147
  replaceAll = false
@@ -33057,7 +33158,7 @@ function EditToolDiffPanel({
33057
33158
  replaceAll,
33058
33159
  maxHeight
33059
33160
  }
33060
- ) }) : hasDiffText ? /* @__PURE__ */ jsx43(Box_default, { marginTop: 0, children: /* @__PURE__ */ jsx43(SimpleDiff, { text: diffText, maxHeight, showGutterSeparator }) }) : /* @__PURE__ */ jsx43(Box_default, { marginTop: 0, children: /* @__PURE__ */ jsx43(Text, { dimColor: true, wrap: "wrap", children: "Diff preview unavailable" }) }) });
33161
+ ) }) : hasDiffText ? /* @__PURE__ */ jsx43(Box_default, { marginTop: 0, children: /* @__PURE__ */ jsx43(SimpleDiff, { text: diffText, maxHeight }) }) : /* @__PURE__ */ jsx43(Box_default, { marginTop: 0, children: /* @__PURE__ */ jsx43(Text, { dimColor: true, wrap: "wrap", children: "Diff preview unavailable" }) }) });
33061
33162
  }
33062
33163
 
33063
33164
  // src/app/agent/tools/EditTool/UI.tsx
@@ -33075,9 +33176,6 @@ function countLineDiff(oldText, newText) {
33075
33176
  }
33076
33177
  return { added, removed };
33077
33178
  }
33078
- function stripUnifiedDiffFileHeaders(diffText) {
33079
- return diffText.replace(/^--- .*\n/m, "").replace(/^\+\+\+ .*\n/m, "");
33080
- }
33081
33179
  function userFacingName11(args) {
33082
33180
  if (!args) return "Updated";
33083
33181
  if (args.edits && Array.isArray(args.edits) && args.edits.length > 0) {
@@ -33096,13 +33194,14 @@ function renderToolHeader12({ args }) {
33096
33194
  const oldText = typeof args?.old_string === "string" ? args.old_string : "";
33097
33195
  const newText = typeof args?.new_string === "string" ? args.new_string : "";
33098
33196
  const counts = countLineDiff(oldText, newText);
33099
- const fileName = String(path50).split("/").pop() || String(path50);
33100
33197
  const action = oldText === "" ? "Created" : "Update";
33101
33198
  return /* @__PURE__ */ jsxs27(Box_default, { flexDirection: "row", gap: 1, alignItems: "flex-end", children: [
33102
33199
  /* @__PURE__ */ jsxs27(Text, { bold: true, color: BLUMA_TERMINAL.m3OnSurface, children: [
33103
33200
  action,
33104
- " ",
33105
- /* @__PURE__ */ jsx44(FilePathLink, { filePath: path50, color: BLUMA_TERMINAL.dim })
33201
+ /* @__PURE__ */ jsxs27(Text, { dimColor: true, children: [
33202
+ " ",
33203
+ /* @__PURE__ */ jsx44(FilePathLink, { filePath: path50, color: BLUMA_TERMINAL.dim })
33204
+ ] })
33106
33205
  ] }),
33107
33206
  /* @__PURE__ */ jsxs27(Text, { dimColor: true, children: [
33108
33207
  "(",
@@ -33214,8 +33313,7 @@ function renderToolResultMessage12(result) {
33214
33313
  {
33215
33314
  filePath: edit.file_path,
33216
33315
  isNewFile: edit.is_new_file ?? false,
33217
- diffText: typeof edit.diff === "string" ? stripUnifiedDiffFileHeaders(edit.diff) : edit.diff,
33218
- showGutterSeparator: false
33316
+ diffText: typeof edit.diff === "string" ? edit.diff : null
33219
33317
  }
33220
33318
  ) }, `result-edit-${idx}`)) });
33221
33319
  }
@@ -33224,8 +33322,7 @@ function renderToolResultMessage12(result) {
33224
33322
  {
33225
33323
  filePath: result.file_path,
33226
33324
  isNewFile: result.is_new_file ?? false,
33227
- diffText: stripUnifiedDiffFileHeaders(result.diff),
33228
- showGutterSeparator: false
33325
+ diffText: result.diff
33229
33326
  }
33230
33327
  ) }) });
33231
33328
  }
@@ -34113,7 +34210,7 @@ function renderToolMessage20({
34113
34210
  /* @__PURE__ */ jsx54(ToolUseLoader, { state: state2 ?? "pending" }),
34114
34211
  renderToolHeader21({ args: p })
34115
34212
  ] }),
34116
- /* @__PURE__ */ jsx54(Box_default, { flexDirection: "column", paddingLeft: 1, children: payload != null ? renderToolResultMessage21(payload, { filePath, content }) : /* @__PURE__ */ jsx54(Box_default, { flexDirection: "column", children: /* @__PURE__ */ jsx54(Box_default, { marginTop: 0, width: "100%", children: content ? /* @__PURE__ */ jsx54(Box_default, { width: "100%", flexGrow: 1, flexDirection: "column", alignItems: "stretch", children: /* @__PURE__ */ jsx54(SimpleDiff, { text: diffText, maxHeight: 4 }) }) : /* @__PURE__ */ jsxs37(Text, { dimColor: true, children: [
34213
+ /* @__PURE__ */ jsx54(Box_default, { flexDirection: "column", paddingLeft: 1, children: payload != null ? renderToolResultMessage21(payload, { filePath, content }) : /* @__PURE__ */ jsx54(Box_default, { flexDirection: "column", children: /* @__PURE__ */ jsx54(Box_default, { marginTop: 0, width: "100%", children: content ? /* @__PURE__ */ jsx54(Box_default, { width: "100%", flexGrow: 1, flexDirection: "column", children: /* @__PURE__ */ jsx54(SimpleDiff, { text: diffText, maxHeight: 2e3 }) }) : /* @__PURE__ */ jsxs37(Text, { dimColor: true, children: [
34117
34214
  "Writing to ",
34118
34215
  filePath ?? "...",
34119
34216
  " (",
@@ -34138,18 +34235,17 @@ function renderToolResultMessage21(result, context) {
34138
34235
  const previousContent = typeof payload.previous_content === "string" ? payload.previous_content : void 0;
34139
34236
  const currentContent = typeof payload.content === "string" ? payload.content : typeof context?.args?.content === "string" ? (context?.args).content : typeof context?.content === "string" ? context.content : void 0;
34140
34237
  const canRenderDiff = typeof currentContent === "string" && currentContent.trim() && typeof previousContent === "string";
34141
- return /* @__PURE__ */ jsx54(Box_default, { flexDirection: "column", children: canRenderDiff ? /* @__PURE__ */ jsx54(Box_default, { marginTop: 0, width: "100%", flexDirection: "column", alignItems: "stretch", flexGrow: 1, children: /* @__PURE__ */ jsx54(
34238
+ return /* @__PURE__ */ jsx54(Box_default, { flexDirection: "column", children: canRenderDiff ? /* @__PURE__ */ jsx54(Box_default, { width: "100%", flexGrow: 1, children: /* @__PURE__ */ jsx54(
34142
34239
  SimpleDiff,
34143
34240
  {
34144
34241
  text: buildUnifiedDiffText(resultFilePath, previousContent ?? "", currentContent ?? ""),
34145
- maxHeight: 200
34242
+ maxHeight: 2e3
34146
34243
  }
34147
34244
  ) }) : typeof currentContent === "string" && currentContent.trim() ? /* @__PURE__ */ jsx54(
34148
34245
  Box_default,
34149
34246
  {
34150
34247
  width: "100%",
34151
34248
  backgroundColor: BLUMA_TERMINAL.diffAdded,
34152
- marginTop: 1,
34153
34249
  children: /* @__PURE__ */ jsx54(
34154
34250
  HighlightedCode,
34155
34251
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomad-e/bluma-cli",
3
- "version": "0.6.9",
3
+ "version": "0.7.0",
4
4
  "description": "BluMa independent agent for automation and advanced software engineering.",
5
5
  "author": "Alex Fonseca",
6
6
  "license": "Apache-2.0",