@thegitai/cli 1.0.0-preview.55 → 1.0.0-preview.56
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { displayWidth, line, padToWidth, plainLine, sliceToWidth, span, wrapText, wrapToWidth, } from './text.js';
|
|
1
|
+
import { displayWidth, expandTabs, line, padToWidth, plainLine, sliceToWidth, span, wrapText, wrapToWidth, } from './text.js';
|
|
2
2
|
const MIN_TABLE_COLUMN_WIDTH = 3;
|
|
3
3
|
function tableRowOverhead(columnCount) {
|
|
4
4
|
return 3 * columnCount + 1;
|
|
@@ -178,10 +178,10 @@ function parseMarkdownTableBlock(lines, startIndex) {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
function splitFormattedLines(body) {
|
|
181
|
-
const
|
|
181
|
+
const normalizedBody = String(body ?? '')
|
|
182
182
|
.replace(/\r\n/g, '\n')
|
|
183
|
-
.replace(/\r/g, '\n')
|
|
184
|
-
|
|
183
|
+
.replace(/\r/g, '\n');
|
|
184
|
+
const lines = expandTabs(normalizedBody).split('\n');
|
|
185
185
|
const formatted = [];
|
|
186
186
|
let inCodeBlock = false;
|
|
187
187
|
for (let index = 0; index < lines.length; index++) {
|
|
@@ -410,7 +410,7 @@ export function renderFormattedBodyLines(body, width, kind) {
|
|
|
410
410
|
if (prev && prev.kind !== 'code' && prev.kind !== 'blank') {
|
|
411
411
|
output.push(plainLine(''));
|
|
412
412
|
}
|
|
413
|
-
for (const wrapped of wrapText(formattedLine.text || ' ',
|
|
413
|
+
for (const wrapped of wrapText(formattedLine.text || ' ', Math.max(1, width - 4))) {
|
|
414
414
|
output.push(plainLine(` ${wrapped}`, { color: 'cyan' }));
|
|
415
415
|
}
|
|
416
416
|
const next = formatted[index + 1];
|
|
@@ -446,16 +446,17 @@ export function renderPreformattedBodyLines(body, width, kind) {
|
|
|
446
446
|
const bodyColor = kind === 'error' ? 'red' : undefined;
|
|
447
447
|
const bodyWidth = Math.max(1, width - 8);
|
|
448
448
|
const output = [];
|
|
449
|
-
const normalizedBody = String(body ?? '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
449
|
+
const normalizedBody = expandTabs(String(body ?? '').replace(/\r\n/g, '\n').replace(/\r/g, '\n'));
|
|
450
450
|
for (const rawLine of normalizedBody.split('\n')) {
|
|
451
451
|
if (rawLine === '') {
|
|
452
452
|
output.push(plainLine(''));
|
|
453
453
|
continue;
|
|
454
454
|
}
|
|
455
455
|
let remaining = rawLine;
|
|
456
|
-
while (remaining
|
|
457
|
-
|
|
458
|
-
|
|
456
|
+
while (displayWidth(remaining) > bodyWidth) {
|
|
457
|
+
const head = sliceToWidth(remaining, bodyWidth);
|
|
458
|
+
output.push(plainLine(` ${head}`, { color: bodyColor }));
|
|
459
|
+
remaining = remaining.slice(head.length);
|
|
459
460
|
}
|
|
460
461
|
output.push(plainLine(` ${remaining}`, { color: bodyColor }));
|
|
461
462
|
}
|
package/dist/src/ui/tui/text.js
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
const CSI_PATTERN =
|
|
2
|
-
const OSC_PATTERN =
|
|
3
|
-
const
|
|
1
|
+
const CSI_PATTERN = /(?:\u001B\[|\u009B)[0-?]*[ -\/]*[@-~]/g;
|
|
2
|
+
const OSC_PATTERN = /(?:\u001B\]|\u009D)[^\u0007\u001B\u009C]*(?:\u0007|\u001B\\|\u009C)?/g;
|
|
3
|
+
const STRING_CONTROL_PATTERN = /(?:\u001B[PX^_]|[\u0090\u0098\u009E\u009F])[^\u001B\u009C]*(?:\u001B\\|\u009C)?/g;
|
|
4
|
+
const ESC_PATTERN = /\u001B[ -\/]*[0-~]/g;
|
|
5
|
+
const CONTROL_CHAR_PATTERN = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F]/g;
|
|
4
6
|
export function stripControlCharacters(text) {
|
|
5
7
|
return String(text ?? '')
|
|
6
8
|
.replace(OSC_PATTERN, '')
|
|
9
|
+
.replace(STRING_CONTROL_PATTERN, '')
|
|
7
10
|
.replace(CSI_PATTERN, '')
|
|
11
|
+
.replace(ESC_PATTERN, '')
|
|
8
12
|
.replace(CONTROL_CHAR_PATTERN, '');
|
|
9
13
|
}
|
|
14
|
+
export function expandTabs(text, initialColumn = 0) {
|
|
15
|
+
let column = initialColumn;
|
|
16
|
+
return stripControlCharacters(text).split(/(\t|\n)/).map((part) => {
|
|
17
|
+
if (part === '\n') {
|
|
18
|
+
column = 0;
|
|
19
|
+
return part;
|
|
20
|
+
}
|
|
21
|
+
if (part === '\t') {
|
|
22
|
+
const spaces = 8 - column % 8;
|
|
23
|
+
column += spaces;
|
|
24
|
+
return ' '.repeat(spaces);
|
|
25
|
+
}
|
|
26
|
+
column += displayWidth(part);
|
|
27
|
+
return part;
|
|
28
|
+
}).join('');
|
|
29
|
+
}
|
|
10
30
|
export function span(text, style = {}) {
|
|
11
31
|
return { text: stripControlCharacters(text), ...style };
|
|
12
32
|
}
|
|
13
33
|
export function line(...spans) {
|
|
14
|
-
|
|
34
|
+
let column = 0;
|
|
35
|
+
return { spans: spans.map((part) => {
|
|
36
|
+
const text = expandTabs(part.text.replace(/\n/g, ' '), column);
|
|
37
|
+
column += displayWidth(text);
|
|
38
|
+
return { ...part, text };
|
|
39
|
+
}) };
|
|
15
40
|
}
|
|
16
41
|
export function plainLine(text, style = {}) {
|
|
17
42
|
return line(span(text, style));
|
|
@@ -21,7 +46,7 @@ export function wrapText(text, width) {
|
|
|
21
46
|
if (!text)
|
|
22
47
|
return [''];
|
|
23
48
|
const lines = [];
|
|
24
|
-
for (const rawLine of text.split('\n')) {
|
|
49
|
+
for (const rawLine of expandTabs(text).split('\n')) {
|
|
25
50
|
let remaining = rawLine;
|
|
26
51
|
while (displayWidth(remaining) > safeWidth) {
|
|
27
52
|
const head = sliceToWidth(remaining, safeWidth);
|
|
@@ -152,7 +177,7 @@ export function padToWidth(text, width) {
|
|
|
152
177
|
export function wrapToWidth(text, width) {
|
|
153
178
|
const limit = Math.max(1, Math.floor(width));
|
|
154
179
|
const out = [];
|
|
155
|
-
for (const rawLine of
|
|
180
|
+
for (const rawLine of expandTabs(text).split('\n')) {
|
|
156
181
|
let current = '';
|
|
157
182
|
const flush = () => {
|
|
158
183
|
out.push(current);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.56",
|
|
4
4
|
"description": "TheGitAI is an agentic AI coding tool for your terminal. It reads and searches your repository, writes and edits files, runs your tests, and verifies the change before handing it back.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-ai",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@lydell/node-pty-linux-x64": "1.1.0",
|
|
46
46
|
"@lydell/node-pty-win32-arm64": "1.1.0",
|
|
47
47
|
"@lydell/node-pty-win32-x64": "1.1.0",
|
|
48
|
-
"@thegitai/tui-darwin-arm64": "1.0.0-preview.
|
|
49
|
-
"@thegitai/tui-darwin-x64": "1.0.0-preview.
|
|
50
|
-
"@thegitai/tui-linux-arm64": "1.0.0-preview.
|
|
51
|
-
"@thegitai/tui-linux-x64": "1.0.0-preview.
|
|
52
|
-
"@thegitai/tui-win32-x64": "1.0.0-preview.
|
|
48
|
+
"@thegitai/tui-darwin-arm64": "1.0.0-preview.56",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.0.0-preview.56",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.0.0-preview.56",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.0.0-preview.56",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.0.0-preview.56",
|
|
53
53
|
"@vscode/ripgrep": "1.18.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|