zames_pro 2.90.7 → 2.90.9

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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.90.9] - 2026-10-28
11
+
12
+ ### Fixed
13
+
14
+ - **ui:** strip OSC escapes when measuring the banner and config-menu width
15
+
16
+ ## [2.90.8] - 2026-10-28
17
+
18
+ ### Fixed
19
+
20
+ - **tui:** copy an OSC escape whole and do not count its body as visible width
21
+
10
22
  ## [2.90.7] - 2026-10-28
11
23
 
12
24
  ### Fixed
package/dist/banner.js CHANGED
@@ -6,7 +6,18 @@ import { theme } from './theme.js';
6
6
  import { visLen } from './input/layout.js';
7
7
  /** Visible width of a string (ANSI stripped, wide chars counted as 2). */
8
8
  function width(s) {
9
- return visLen(s.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, ''));
9
+ return visLen(stripAnsi(s));
10
+ }
11
+ /**
12
+ * Remove CSI AND OSC escapes. An OSC body (an OSC-8 hyperlink, a terminal
13
+ * title) is NOT visible text: a CSI-only regex counted every URL character as
14
+ * a column, so the banner box was drawn too wide and the config menu's erase
15
+ * height disagreed with the real screen (duplicated rows).
16
+ */
17
+ function stripAnsi(s) {
18
+ return String(s ?? '')
19
+ .replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '')
20
+ .replace(/\x1b\][\s\S]*?(?:\x07|\x1b\\|$)/g, '');
10
21
  }
11
22
  /**
12
23
  * Draw a rounded box around the given content lines. The box width is the
@@ -34,6 +45,9 @@ function box(lines, maxWidth) {
34
45
  return [top, ...body, bottom].join('\n');
35
46
  }
36
47
  /** Truncate an (ANSI-carrying) string to `max` visible columns. */
48
+ export function clipToWidth(s, max) {
49
+ return clip(s, max);
50
+ }
37
51
  function clip(s, max) {
38
52
  if (width(s) <= max)
39
53
  return s;
@@ -43,7 +57,7 @@ function clip(s, max) {
43
57
  let out = '';
44
58
  let visible = 0;
45
59
  let i = 0;
46
- const esc = /\x1b\[[0-9;?]*[A-Za-z]/y;
60
+ const esc = /\x1b\[[0-9;?]*[A-Za-z]|\x1b\][\s\S]*?(?:\x07|\x1b\\|$)/y;
47
61
  while (i < s.length && visible < max - 1) {
48
62
  esc.lastIndex = i;
49
63
  const m = esc.exec(s);
@@ -14,7 +14,12 @@ const ESC = String.fromCharCode(27);
14
14
  // (input.ts keeps its own private helper): the regex must match a real CSI,
15
15
  // otherwise visCols over-counts and the erase moves to the wrong row.
16
16
  function stripAnsiLocal(s) {
17
- return s.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '');
17
+ // CSI AND OSC: a menu line never carries a hyperlink today, but a field
18
+ // value or a group label may, and an OSC body counted as visible columns
19
+ // made the erase height disagree with the real screen (duplicated rows).
20
+ return String(s ?? '')
21
+ .replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '')
22
+ .replace(/\x1b\][\s\S]*?(?:\x07|\x1b\\|$)/g, '');
18
23
  }
19
24
  // Visible COLUMNS of a line (ANSI removed, wide chars counted as 2). Using the
20
25
  // code-point count made the block height disagree with the real screen on lines
@@ -178,6 +178,25 @@ export function visLen(s) {
178
178
  i++;
179
179
  i++;
180
180
  }
181
+ else if (s[i] === ']') {
182
+ // OSC (`ESC ] … BEL` / `ESC ] … ESC \`) — e.g. an OSC-8 hyperlink
183
+ // emitted by renderMarkdown. Its body is NOT visible text: without
184
+ // this branch every URL character counted as a column, so a link line
185
+ // measured far wider than it renders (layout/cursor drift) and
186
+ // truncation cut into the middle of the sequence.
187
+ i++;
188
+ while (i < s.length) {
189
+ if (s.charCodeAt(i) === 7) {
190
+ i++;
191
+ break;
192
+ }
193
+ if (s.charCodeAt(i) === 27 && s[i + 1] === String.fromCharCode(92)) {
194
+ i += 2;
195
+ break;
196
+ }
197
+ i++;
198
+ }
199
+ }
181
200
  continue;
182
201
  }
183
202
  const cp = s.codePointAt(i);
@@ -348,6 +367,29 @@ export function truncateToWidth(s, maxCols) {
348
367
  i += seq.length;
349
368
  continue;
350
369
  }
370
+ // OSC (`ESC ] … BEL` or `ESC ] … ESC \`) is the OTHER escape family and is
371
+ // what renderMarkdown emits for OSC-8 hyperlinks. Without this branch the
372
+ // URL's characters counted as visible columns and the cut landed INSIDE
373
+ // the sequence (`\x1b]…`), destroying the link. Copy it whole too; one
374
+ // whose terminator was already lost is kept as-is rather than half-cut.
375
+ if (text.charCodeAt(i) === 27 && text[i + 1] === ']') {
376
+ let j = i + 2;
377
+ while (j < text.length) {
378
+ if (text[j] === String.fromCharCode(7)) {
379
+ j++;
380
+ break;
381
+ }
382
+ if (text.charCodeAt(j) === 27 && text[j + 1] === '\\') {
383
+ j += 2;
384
+ break;
385
+ }
386
+ j++;
387
+ }
388
+ const seq = text.slice(i, j);
389
+ out += seq;
390
+ i = j;
391
+ continue;
392
+ }
351
393
  const cp = text.codePointAt(i);
352
394
  const w = charWidth(cp);
353
395
  if (used + w > budget)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zames_pro",
3
- "version": "2.90.7",
3
+ "version": "2.90.9",
4
4
  "description": "Terminal coding agent that drives a real browser to chat with DeepSeek, Qwen or GLM — no API key required. Reads and edits files, runs commands, commits to git, like Claude Code / Codex CLI.",
5
5
  "type": "module",
6
6
  "bin": {