@tiens.nguyen/gonext-cli 1.0.359 → 1.0.360

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.
Files changed (2) hide show
  1. package/gonext-repl.mjs +39 -8
  2. package/package.json +1 -1
package/gonext-repl.mjs CHANGED
@@ -71,13 +71,8 @@ const gutterLines = (s) =>
71
71
  // one left edge: the bullet's TEXT column (GUTTER + "● " = GUTTER + 2). Without this the answer
72
72
  // sat at the bare GUTTER, 2 cols left of the bullet text above it — the ragged jog between the
73
73
  // actions and "Done!" (padding fix). Plain replies have no bullets, so they keep the GUTTER
74
- // margin (aligned with the >> prompt). `outputLines` insets a block to that shared edge.
74
+ // margin (aligned with the >> prompt).
75
75
  const OUTPUT_INDENT = GUTTER + " ";
76
- const outputLines = (s) =>
77
- String(s)
78
- .split("\n")
79
- .map((l) => (l.length ? OUTPUT_INDENT + l : l))
80
- .join("\n");
81
76
  // Render the model's inline **bold** as ANSI bold (markdown polish). The terminal has no
82
77
  // markdown renderer, so a heading like `**What I did:**` was printing its literal asterisks.
83
78
  // Only paired ** with non-space content between them is consumed (so a stray `**` or `a ** b`
@@ -87,6 +82,40 @@ const outputLines = (s) =>
87
82
  // reply stream isn't marked up because ** can straddle a chunk boundary there.
88
83
  const renderMdBold = (s) =>
89
84
  String(s).replace(/\*\*(?=\S)(.*?\S)\*\*/g, "\x1b[1m$1\x1b[22m");
85
+ // Word-wrap a block to the terminal width so a long line does NOT soft-wrap back to column 0
86
+ // and lose its left margin — instead we hard-break at word boundaries and re-apply `indent` to
87
+ // EVERY continuation row (user-reported: wrapped answer lines had no padding on line 2+). A
88
+ // single token longer than the line (e.g. a URL) is hard-split so it can't overflow. Existing
89
+ // newlines (paragraph breaks / list items) are preserved; blank lines stay bare. The -1 guards
90
+ // against a wide (emoji) char nudging the visible row one past the edge into a real soft-wrap.
91
+ const wrapBlock = (text, indent, width) => {
92
+ const avail = Math.max(8, (width || 80) - indent.length - 1);
93
+ const rows = [];
94
+ for (const para of String(text).split("\n")) {
95
+ if (para === "") { rows.push(""); continue; }
96
+ let cur = "";
97
+ for (let w of para.split(/\s+/).filter(Boolean)) {
98
+ if (w.length > avail) {
99
+ if (cur) { rows.push(cur); cur = ""; }
100
+ while (w.length > avail) { rows.push(w.slice(0, avail)); w = w.slice(avail); }
101
+ cur = w;
102
+ continue;
103
+ }
104
+ const next = cur ? cur + " " + w : w;
105
+ if (next.length <= avail) cur = next;
106
+ else { rows.push(cur); cur = w; }
107
+ }
108
+ if (cur) rows.push(cur);
109
+ }
110
+ return rows;
111
+ };
112
+ // The completed agent answer, ready to print: wrapped to the current terminal width, every row
113
+ // re-indented to the bullet-text column (OUTPUT_INDENT) so line 2+ keeps the same margin, with
114
+ // inline **bold** rendered per row (after wrapping, so the width math is on visible text).
115
+ const renderAnswer = (answer) =>
116
+ wrapBlock(answer, OUTPUT_INDENT, process.stdout.columns || 80)
117
+ .map((l) => (l.length ? OUTPUT_INDENT + renderMdBold(l) : l))
118
+ .join("\n");
90
119
  // Vertical rhythm between ● action/answer bullets (task #129). One blank line so the list
91
120
  // breathes instead of being cramped. A knob: "" = the old tight list, "\n" = one blank.
92
121
  // Applied as a LEADING blank before a bullet when the previous line wasn't already blank —
@@ -2671,10 +2700,12 @@ async function main() {
2671
2700
  // A plain-reply answer already streamed live in the loop above (shown=true) — printing
2672
2701
  // it again here would just duplicate it, so only a spacer blank line. The AGENT answer
2673
2702
  // (shown=false) is printed here from resultText, indented to the bullet-text column
2674
- // (outputLines) so it shares the ● bullets' left edge, and with ONE leading blank
2703
+ // (renderAnswer) so it shares the ● bullets' left edge, and with ONE leading blank
2675
2704
  // (LINE_SPACING) matching the between-bullets rhythm — was a hard "\n\n" double gap at
2676
2705
  // the seam, bigger than the gaps between bullets above it (the seam padding fix).
2677
- console.log(shown ? "" : `${LINE_SPACING}${outputLines(renderMdBold(answer))}\n`);
2706
+ // renderAnswer also WRAPS long lines and re-indents each continuation row, so a wrapped
2707
+ // paragraph keeps the same left margin instead of soft-wrapping back to column 0.
2708
+ console.log(shown ? "" : `${LINE_SPACING}${renderAnswer(answer)}\n`);
2678
2709
  // Task #104: persistent token footer at the bottom of the screen — this turn's
2679
2710
  // code-model INPUT + this turn's OUTPUT (↓ out), then the model's GLOBAL lifetime
2680
2711
  // output total (all turns for this user + coding server), labelled with the model
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-cli",
3
- "version": "1.0.359",
3
+ "version": "1.0.360",
4
4
  "description": "GoNext CLI — the gonext terminal plus the local worker that runs agent / OCR / PDF / embedding jobs on your Mac (Ollama / MLX / OpenAI-compatible).",
5
5
  "type": "module",
6
6
  "license": "MIT",