@ariacode/cli 0.2.2 → 0.2.3
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/README.md +60 -7
- package/dist/actions/db-ask.d.ts +2 -0
- package/dist/actions/db-ask.js +23 -6
- package/dist/actions/db-ask.js.map +1 -1
- package/dist/actions/db-explain.d.ts +2 -0
- package/dist/actions/db-explain.js +23 -5
- package/dist/actions/db-explain.js.map +1 -1
- package/dist/actions/db-schema.d.ts +2 -0
- package/dist/actions/db-schema.js +15 -2
- package/dist/actions/db-schema.js.map +1 -1
- package/dist/actions/upgrade-deps.d.ts +2 -0
- package/dist/actions/upgrade-deps.js +18 -0
- package/dist/actions/upgrade-deps.js.map +1 -1
- package/dist/actions.d.ts +86 -71
- package/dist/actions.js +382 -182
- package/dist/actions.js.map +1 -1
- package/dist/agent.d.ts +0 -1
- package/dist/agent.js +1 -2
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts +3 -3
- package/dist/app.js +3 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +15 -3
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/output/schemas.d.ts +92 -0
- package/dist/output/schemas.js +142 -0
- package/dist/output/schemas.js.map +1 -0
- package/dist/parser.d.ts +8 -3
- package/dist/parser.js +51 -5
- package/dist/parser.js.map +1 -1
- package/dist/repo.d.ts +0 -1
- package/dist/repo.js +6 -9
- package/dist/repo.js.map +1 -1
- package/dist/safety.d.ts +0 -4
- package/dist/safety.js +0 -4
- package/dist/safety.js.map +1 -1
- package/dist/storage/queries.d.ts +39 -0
- package/dist/storage/queries.js +211 -0
- package/dist/storage/queries.js.map +1 -0
- package/dist/tools.d.ts +6 -7
- package/dist/tools.js +20 -7
- package/dist/tools.js.map +1 -1
- package/dist/ui/diff-renderer.d.ts +28 -0
- package/dist/ui/diff-renderer.js +388 -0
- package/dist/ui/diff-renderer.js.map +1 -0
- package/dist/ui/highlight.d.ts +25 -0
- package/dist/ui/highlight.js +239 -0
- package/dist/ui/highlight.js.map +1 -0
- package/dist/ui.d.ts +3 -16
- package/dist/ui.js +7 -28
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced diff renderer for terminal output.
|
|
3
|
+
*
|
|
4
|
+
* Parses unified diffs and renders them with syntax highlighting, line numbers,
|
|
5
|
+
* collapsed unchanged sections, and optional side-by-side layout.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import pc from 'picocolors';
|
|
9
|
+
import { highlight, inferLanguageFromPath } from './highlight.js';
|
|
10
|
+
import { stripAnsi } from '../ui.js';
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Internal helpers
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/**
|
|
15
|
+
* Extract language from a diff header line like `--- a/src/foo.ts`.
|
|
16
|
+
* Returns undefined if the path cannot be extracted or language is unsupported.
|
|
17
|
+
*/
|
|
18
|
+
function inferLanguage(diffHeader) {
|
|
19
|
+
// Match "--- a/path/to/file.ext" or "--- path/to/file.ext"
|
|
20
|
+
const match = diffHeader.match(/^---\s+(?:a\/)?(.+?)(?:\s|$)/);
|
|
21
|
+
if (!match)
|
|
22
|
+
return undefined;
|
|
23
|
+
const filePath = match[1];
|
|
24
|
+
const lang = inferLanguageFromPath(filePath);
|
|
25
|
+
return lang ?? undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wrap highlight(), returning input unchanged on any failure.
|
|
29
|
+
*/
|
|
30
|
+
function highlightSafe(code, language) {
|
|
31
|
+
try {
|
|
32
|
+
return highlight(code, { language });
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return code;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Collapse runs of unchanged context lines that appear BETWEEN two changed lines
|
|
40
|
+
* (not at the start or end). Runs exceeding `threshold` are replaced with a summary.
|
|
41
|
+
*/
|
|
42
|
+
function collapseUnchanged(lines, threshold) {
|
|
43
|
+
if (threshold <= 0)
|
|
44
|
+
return lines;
|
|
45
|
+
// Find the index of the first and last changed line
|
|
46
|
+
let firstChanged = -1;
|
|
47
|
+
let lastChanged = -1;
|
|
48
|
+
for (let i = 0; i < lines.length; i++) {
|
|
49
|
+
const line = lines[i];
|
|
50
|
+
// Changed lines start with + or - (but not +++ or ---)
|
|
51
|
+
if ((line.startsWith('+') && !line.startsWith('+++')) ||
|
|
52
|
+
(line.startsWith('-') && !line.startsWith('---'))) {
|
|
53
|
+
if (firstChanged === -1)
|
|
54
|
+
firstChanged = i;
|
|
55
|
+
lastChanged = i;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// No changed lines — nothing to collapse
|
|
59
|
+
if (firstChanged === -1)
|
|
60
|
+
return lines;
|
|
61
|
+
const result = [];
|
|
62
|
+
let i = 0;
|
|
63
|
+
while (i < lines.length) {
|
|
64
|
+
const line = lines[i];
|
|
65
|
+
const isChanged = (line.startsWith('+') && !line.startsWith('+++')) ||
|
|
66
|
+
(line.startsWith('-') && !line.startsWith('---'));
|
|
67
|
+
if (!isChanged) {
|
|
68
|
+
// Collect the run of unchanged lines
|
|
69
|
+
const runStart = i;
|
|
70
|
+
while (i < lines.length &&
|
|
71
|
+
!((lines[i].startsWith('+') && !lines[i].startsWith('+++')) ||
|
|
72
|
+
(lines[i].startsWith('-') && !lines[i].startsWith('---')))) {
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
const runEnd = i; // exclusive
|
|
76
|
+
const runLength = runEnd - runStart;
|
|
77
|
+
const runLines = lines.slice(runStart, runEnd);
|
|
78
|
+
// Only collapse if this run is strictly between two changed lines
|
|
79
|
+
const isMiddle = runStart > firstChanged && runEnd <= lastChanged + 1;
|
|
80
|
+
if (isMiddle && runLength > threshold) {
|
|
81
|
+
result.push(`... ${runLength} unchanged lines ...`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
result.push(...runLines);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
result.push(line);
|
|
89
|
+
i++;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Render two columns side-by-side given a terminal width.
|
|
96
|
+
* Left column gets original lines, right column gets modified lines.
|
|
97
|
+
*/
|
|
98
|
+
function renderSideBySide(leftLines, rightLines, width) {
|
|
99
|
+
const colWidth = Math.floor(width / 2) - 1;
|
|
100
|
+
const maxRows = Math.max(leftLines.length, rightLines.length);
|
|
101
|
+
const rows = [];
|
|
102
|
+
for (let i = 0; i < maxRows; i++) {
|
|
103
|
+
const left = leftLines[i] ?? '';
|
|
104
|
+
const right = rightLines[i] ?? '';
|
|
105
|
+
// Truncate or pad to column width (strip ANSI for length calculation)
|
|
106
|
+
const leftPadded = padToWidth(left, colWidth);
|
|
107
|
+
const rightPadded = padToWidth(right, colWidth);
|
|
108
|
+
rows.push(`${leftPadded} ${rightPadded}`);
|
|
109
|
+
}
|
|
110
|
+
return rows.join('\n');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Pad a string (which may contain ANSI codes) to a visible width.
|
|
114
|
+
* Truncates if the visible content exceeds the target width.
|
|
115
|
+
* Note: truncation strips ANSI codes for simplicity — long lines lose color in split view.
|
|
116
|
+
*/
|
|
117
|
+
function padToWidth(str, width) {
|
|
118
|
+
const visible = stripAnsi(str);
|
|
119
|
+
if (visible.length >= width) {
|
|
120
|
+
// Truncate visible content — rebuild with ANSI stripped for simplicity
|
|
121
|
+
return visible.slice(0, width);
|
|
122
|
+
}
|
|
123
|
+
return str + ' '.repeat(width - visible.length);
|
|
124
|
+
}
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
// Diff parser
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
function parseHunkHeader(line) {
|
|
129
|
+
const match = line.match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@(.*)/);
|
|
130
|
+
if (!match)
|
|
131
|
+
return null;
|
|
132
|
+
return {
|
|
133
|
+
oldStart: parseInt(match[1], 10),
|
|
134
|
+
oldCount: match[2] !== undefined ? parseInt(match[2], 10) : 1,
|
|
135
|
+
newStart: parseInt(match[3], 10),
|
|
136
|
+
newCount: match[4] !== undefined ? parseInt(match[4], 10) : 1,
|
|
137
|
+
context: match[5] ?? '',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function parseUnifiedDiff(diffText) {
|
|
141
|
+
const lines = diffText.split('\n');
|
|
142
|
+
const files = [];
|
|
143
|
+
let currentFile = null;
|
|
144
|
+
let currentHunk = null;
|
|
145
|
+
for (let i = 0; i < lines.length; i++) {
|
|
146
|
+
const line = lines[i];
|
|
147
|
+
if (line.startsWith('--- ')) {
|
|
148
|
+
// Start of a new file diff
|
|
149
|
+
if (currentFile && currentHunk) {
|
|
150
|
+
currentFile.hunks.push(currentHunk);
|
|
151
|
+
currentHunk = null;
|
|
152
|
+
}
|
|
153
|
+
if (currentFile) {
|
|
154
|
+
files.push(currentFile);
|
|
155
|
+
}
|
|
156
|
+
const oldPath = line.slice(4).trim().replace(/^a\//, '');
|
|
157
|
+
// Peek at next line for +++
|
|
158
|
+
const nextLine = lines[i + 1] ?? '';
|
|
159
|
+
const newPath = nextLine.startsWith('+++ ')
|
|
160
|
+
? nextLine.slice(4).trim().replace(/^b\//, '')
|
|
161
|
+
: oldPath;
|
|
162
|
+
currentFile = { oldPath, newPath, hunks: [] };
|
|
163
|
+
if (nextLine.startsWith('+++ ')) {
|
|
164
|
+
i++; // skip the +++ line
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else if (line.startsWith('@@ ')) {
|
|
168
|
+
if (currentFile) {
|
|
169
|
+
if (currentHunk) {
|
|
170
|
+
currentFile.hunks.push(currentHunk);
|
|
171
|
+
}
|
|
172
|
+
const header = parseHunkHeader(line);
|
|
173
|
+
if (header) {
|
|
174
|
+
currentHunk = { header, lines: [] };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else if (currentHunk !== null) {
|
|
179
|
+
// Content line: +, -, or space (context)
|
|
180
|
+
if (line.startsWith('+') || line.startsWith('-') || line.startsWith(' ') || line === '') {
|
|
181
|
+
currentHunk.lines.push(line);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Flush remaining
|
|
186
|
+
if (currentFile) {
|
|
187
|
+
if (currentHunk) {
|
|
188
|
+
currentFile.hunks.push(currentHunk);
|
|
189
|
+
}
|
|
190
|
+
files.push(currentFile);
|
|
191
|
+
}
|
|
192
|
+
return files;
|
|
193
|
+
}
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
// Rendering helpers
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
197
|
+
/**
|
|
198
|
+
* Count added and removed lines in a list of parsed files.
|
|
199
|
+
*/
|
|
200
|
+
function countMutations(hunks) {
|
|
201
|
+
let added = 0;
|
|
202
|
+
let removed = 0;
|
|
203
|
+
for (const hunk of hunks) {
|
|
204
|
+
for (const line of hunk.lines) {
|
|
205
|
+
if (line.startsWith('+'))
|
|
206
|
+
added++;
|
|
207
|
+
else if (line.startsWith('-'))
|
|
208
|
+
removed++;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { added, removed };
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Render a single hunk in unified format with optional line numbers and highlighting.
|
|
215
|
+
*/
|
|
216
|
+
function renderHunkUnified(hunk, language, lineNumbers) {
|
|
217
|
+
const { lines, header } = hunk;
|
|
218
|
+
// Apply collapse to the raw lines
|
|
219
|
+
// (collapse operates on the raw diff lines before colorization)
|
|
220
|
+
// We'll apply collapse after colorization to preserve the line content
|
|
221
|
+
// Calculate line number width for padding
|
|
222
|
+
const maxOldLine = header.oldStart + header.oldCount;
|
|
223
|
+
const maxNewLine = header.newStart + header.newCount;
|
|
224
|
+
const maxLine = Math.max(maxOldLine, maxNewLine);
|
|
225
|
+
const lineNumWidth = String(maxLine).length;
|
|
226
|
+
let oldLineNum = header.oldStart;
|
|
227
|
+
let newLineNum = header.newStart;
|
|
228
|
+
const rendered = [];
|
|
229
|
+
for (const line of lines) {
|
|
230
|
+
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
231
|
+
const content = line.slice(1);
|
|
232
|
+
const highlighted = language ? highlightSafe(content, language) : content;
|
|
233
|
+
const colorized = pc.green('+') + highlighted;
|
|
234
|
+
if (lineNumbers) {
|
|
235
|
+
const lineNum = String(newLineNum).padStart(lineNumWidth, ' ');
|
|
236
|
+
rendered.push(`${lineNum} ${colorized}`);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
rendered.push(colorized);
|
|
240
|
+
}
|
|
241
|
+
newLineNum++;
|
|
242
|
+
}
|
|
243
|
+
else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
244
|
+
const content = line.slice(1);
|
|
245
|
+
const highlighted = language ? highlightSafe(content, language) : content;
|
|
246
|
+
const colorized = pc.red('-') + highlighted;
|
|
247
|
+
if (lineNumbers) {
|
|
248
|
+
const lineNum = String(oldLineNum).padStart(lineNumWidth, ' ');
|
|
249
|
+
rendered.push(`${lineNum} ${colorized}`);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
rendered.push(colorized);
|
|
253
|
+
}
|
|
254
|
+
oldLineNum++;
|
|
255
|
+
}
|
|
256
|
+
else if (line.startsWith('... ') && line.endsWith(' unchanged lines ...')) {
|
|
257
|
+
// Collapse marker — pass through as-is (styled by caller)
|
|
258
|
+
rendered.push(line);
|
|
259
|
+
// Parse the count to advance line numbers
|
|
260
|
+
const countMatch = line.match(/^\.\.\. (\d+) unchanged lines \.\.\./);
|
|
261
|
+
if (countMatch) {
|
|
262
|
+
const n = parseInt(countMatch[1], 10);
|
|
263
|
+
oldLineNum += n;
|
|
264
|
+
newLineNum += n;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
// Context line (starts with space or is empty)
|
|
269
|
+
const content = line.startsWith(' ') ? line.slice(1) : line;
|
|
270
|
+
if (lineNumbers) {
|
|
271
|
+
const lineNum = String(oldLineNum).padStart(lineNumWidth, ' ');
|
|
272
|
+
rendered.push(`${lineNum} ${content}`);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
rendered.push(` ${content}`);
|
|
276
|
+
}
|
|
277
|
+
oldLineNum++;
|
|
278
|
+
newLineNum++;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return rendered;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Render a hunk header line.
|
|
285
|
+
*/
|
|
286
|
+
function renderHunkHeaderLine(header) {
|
|
287
|
+
const base = `@@ -${header.oldStart},${header.oldCount} +${header.newStart},${header.newCount} @@`;
|
|
288
|
+
return pc.cyan(header.context ? `${base}${header.context}` : base);
|
|
289
|
+
}
|
|
290
|
+
// ---------------------------------------------------------------------------
|
|
291
|
+
// Main export
|
|
292
|
+
// ---------------------------------------------------------------------------
|
|
293
|
+
/** Maximum diff input size (2 MB). Larger diffs are returned as-is to prevent OOM/CPU spikes. */
|
|
294
|
+
const MAX_DIFF_SIZE = 2 * 1024 * 1024;
|
|
295
|
+
/**
|
|
296
|
+
* Render a unified diff string with syntax highlighting, line numbers,
|
|
297
|
+
* collapsed unchanged sections, and optional side-by-side layout.
|
|
298
|
+
*
|
|
299
|
+
*/
|
|
300
|
+
export function renderDiff(diffText, options) {
|
|
301
|
+
// Guard: skip rendering for oversized diffs (binary files, monorepo bulk diffs)
|
|
302
|
+
if (diffText.length > MAX_DIFF_SIZE)
|
|
303
|
+
return diffText;
|
|
304
|
+
const width = options.terminalWidth ?? process.stdout.columns ?? 80;
|
|
305
|
+
const useSideBySide = options.split && width > 120;
|
|
306
|
+
const files = parseUnifiedDiff(diffText);
|
|
307
|
+
if (files.length === 0)
|
|
308
|
+
return diffText;
|
|
309
|
+
const outputParts = [];
|
|
310
|
+
for (const file of files) {
|
|
311
|
+
// Determine language
|
|
312
|
+
const language = options.language ??
|
|
313
|
+
inferLanguage(`--- a/${file.oldPath}`) ??
|
|
314
|
+
inferLanguage(`--- a/${file.newPath}`);
|
|
315
|
+
// File header: filepath +M -N lines
|
|
316
|
+
const { added, removed } = countMutations(file.hunks);
|
|
317
|
+
const filePath = file.newPath !== '/dev/null' ? file.newPath : file.oldPath;
|
|
318
|
+
const fileHeader = `${filePath} ${pc.green(`+${added}`)} ${pc.red(`-${removed}`)} lines`;
|
|
319
|
+
outputParts.push(fileHeader);
|
|
320
|
+
for (const hunk of file.hunks) {
|
|
321
|
+
// Hunk header
|
|
322
|
+
outputParts.push(renderHunkHeaderLine(hunk.header));
|
|
323
|
+
if (useSideBySide) {
|
|
324
|
+
// Build left (original) and right (modified) lines
|
|
325
|
+
const leftLines = [];
|
|
326
|
+
const rightLines = [];
|
|
327
|
+
let oldLineNum = hunk.header.oldStart;
|
|
328
|
+
let newLineNum = hunk.header.newStart;
|
|
329
|
+
const maxOldLine = hunk.header.oldStart + hunk.header.oldCount;
|
|
330
|
+
const maxNewLine = hunk.header.newStart + hunk.header.newCount;
|
|
331
|
+
const maxLine = Math.max(maxOldLine, maxNewLine);
|
|
332
|
+
const lineNumWidth = String(maxLine).length;
|
|
333
|
+
for (const line of hunk.lines) {
|
|
334
|
+
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
335
|
+
const content = line.slice(1);
|
|
336
|
+
const highlighted = language ? highlightSafe(content, language) : content;
|
|
337
|
+
const colorized = pc.green('+') + highlighted;
|
|
338
|
+
const lineNum = options.lineNumbers
|
|
339
|
+
? `${String(newLineNum).padStart(lineNumWidth, ' ')} `
|
|
340
|
+
: '';
|
|
341
|
+
leftLines.push('');
|
|
342
|
+
rightLines.push(`${lineNum}${colorized}`);
|
|
343
|
+
newLineNum++;
|
|
344
|
+
}
|
|
345
|
+
else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
346
|
+
const content = line.slice(1);
|
|
347
|
+
const highlighted = language ? highlightSafe(content, language) : content;
|
|
348
|
+
const colorized = pc.red('-') + highlighted;
|
|
349
|
+
const lineNum = options.lineNumbers
|
|
350
|
+
? `${String(oldLineNum).padStart(lineNumWidth, ' ')} `
|
|
351
|
+
: '';
|
|
352
|
+
leftLines.push(`${lineNum}${colorized}`);
|
|
353
|
+
rightLines.push('');
|
|
354
|
+
oldLineNum++;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
// Context line
|
|
358
|
+
const content = line.startsWith(' ') ? line.slice(1) : line;
|
|
359
|
+
const leftLineNum = options.lineNumbers
|
|
360
|
+
? `${String(oldLineNum).padStart(lineNumWidth, ' ')} `
|
|
361
|
+
: '';
|
|
362
|
+
leftLines.push(`${leftLineNum} ${content}`);
|
|
363
|
+
rightLines.push(`${leftLineNum} ${content}`);
|
|
364
|
+
oldLineNum++;
|
|
365
|
+
newLineNum++;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
outputParts.push(renderSideBySide(leftLines, rightLines, width));
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
// Unified rendering: collapse first, then render
|
|
372
|
+
const collapsedLines = collapseUnchanged(hunk.lines, options.collapseThreshold);
|
|
373
|
+
const collapsedHunk = { header: hunk.header, lines: collapsedLines };
|
|
374
|
+
const renderedLines = renderHunkUnified(collapsedHunk, language, options.lineNumbers);
|
|
375
|
+
for (const rLine of renderedLines) {
|
|
376
|
+
if (rLine.startsWith('... ') && rLine.endsWith(' unchanged lines ...')) {
|
|
377
|
+
outputParts.push(pc.dim(rLine));
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
outputParts.push(rLine);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return outputParts.join('\n');
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=diff-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-renderer.js","sourceRoot":"","sources":["../../src/ui/diff-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAsBrC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;GAGG;AACH,SAAS,aAAa,CAAC,UAAkB;IACvC,2DAA2D;IAC3D,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC/D,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC7C,OAAO,IAAI,IAAI,SAAS,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,IAAY,EAAE,QAAgB;IACnD,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,KAAe,EAAE,SAAiB;IAC3D,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAEjC,oDAAoD;IACpD,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC;IACtB,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,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AAC,IAAI,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;wBACvE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;oBAClC,CAAC;yBAAM,CAAC;wBACN,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC1B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-house syntax highlighter for terminal output.
|
|
3
|
+
*
|
|
4
|
+
* Applies ANSI color codes via picocolors to TypeScript, JavaScript, Prisma,
|
|
5
|
+
* JSON, and Markdown code snippets. Zero external dependencies beyond picocolors.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export type SupportedLanguage = 'typescript' | 'javascript' | 'prisma' | 'json' | 'markdown';
|
|
9
|
+
export interface HighlightOptions {
|
|
10
|
+
/** Language identifier; if unknown/unsupported, returns input unchanged */
|
|
11
|
+
language: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Apply minimal syntax highlighting using ANSI color codes via picocolors.
|
|
15
|
+
* Returns the input code unchanged if the language is unsupported or if any
|
|
16
|
+
* error occurs — never throws.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare function highlight(code: string, options: HighlightOptions): string;
|
|
20
|
+
/**
|
|
21
|
+
* Infer a SupportedLanguage from a file path/extension.
|
|
22
|
+
* Returns null if the extension is not in the supported set.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare function inferLanguageFromPath(filePath: string): SupportedLanguage | null;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-house syntax highlighter for terminal output.
|
|
3
|
+
*
|
|
4
|
+
* Applies ANSI color codes via picocolors to TypeScript, JavaScript, Prisma,
|
|
5
|
+
* JSON, and Markdown code snippets. Zero external dependencies beyond picocolors.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import pc from 'picocolors';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// TypeScript / JavaScript
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
const TS_KEYWORDS = new Set([
|
|
13
|
+
'const', 'let', 'var', 'function', 'class', 'interface', 'type',
|
|
14
|
+
'return', 'if', 'else', 'for', 'while', 'async', 'await', 'export',
|
|
15
|
+
'import', 'from', 'default', 'extends', 'implements', 'new', 'this',
|
|
16
|
+
'typeof', 'instanceof', 'in', 'of', 'do', 'switch', 'case', 'break',
|
|
17
|
+
'continue', 'throw', 'try', 'catch', 'finally', 'void', 'null',
|
|
18
|
+
'undefined', 'true', 'false', 'static', 'readonly', 'private',
|
|
19
|
+
'protected', 'public', 'abstract', 'enum', 'namespace', 'declare',
|
|
20
|
+
'as', 'is', 'keyof', 'never', 'any', 'unknown', 'object', 'string',
|
|
21
|
+
'number', 'boolean', 'symbol', 'bigint', 'delete', 'yield', 'super',
|
|
22
|
+
'with', 'debugger',
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Highlight TypeScript or JavaScript code.
|
|
26
|
+
*/
|
|
27
|
+
function highlightTS(code) {
|
|
28
|
+
const placeholders = [];
|
|
29
|
+
// Step 1: extract comments and strings into placeholders
|
|
30
|
+
// Template literals (backtick) may span lines and contain ${...} — match them separately.
|
|
31
|
+
let result = code.replace(/(\/\/.*$|\/\*[\s\S]*?\*\/|`(?:[^`\\]|\\.|\$\{[^}]*\})*`|(['"])(?:[^'"\\n]|\\.)*\2)/gm, (match) => {
|
|
32
|
+
const idx = placeholders.length;
|
|
33
|
+
if (match.startsWith('//') || match.startsWith('/*')) {
|
|
34
|
+
placeholders.push(pc.gray(match));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
placeholders.push(pc.green(match));
|
|
38
|
+
}
|
|
39
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
40
|
+
});
|
|
41
|
+
// Step 2: numbers
|
|
42
|
+
result = result.replace(/\b\d+(\.\d+)?\b/g, (match) => {
|
|
43
|
+
const idx = placeholders.length;
|
|
44
|
+
placeholders.push(pc.yellow(match));
|
|
45
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
46
|
+
});
|
|
47
|
+
// Step 3: keywords
|
|
48
|
+
result = result.replace(/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g, (match) => {
|
|
49
|
+
if (TS_KEYWORDS.has(match)) {
|
|
50
|
+
const idx = placeholders.length;
|
|
51
|
+
placeholders.push(pc.cyan(match));
|
|
52
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
53
|
+
}
|
|
54
|
+
return match;
|
|
55
|
+
});
|
|
56
|
+
// Step 4: restore placeholders
|
|
57
|
+
return result.replace(/\x00TOKEN_(\d+)\x00/g, (_, i) => placeholders[Number(i)]);
|
|
58
|
+
}
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Prisma
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
const PRISMA_KEYWORDS = new Set([
|
|
63
|
+
'model', 'enum', 'datasource', 'generator', 'provider', 'url',
|
|
64
|
+
'output', 'previewFeatures', 'relationMode',
|
|
65
|
+
]);
|
|
66
|
+
const PRISMA_FIELD_TYPES = new Set([
|
|
67
|
+
'String', 'Int', 'Float', 'Boolean', 'DateTime', 'Json',
|
|
68
|
+
'Bytes', 'Decimal', 'BigInt',
|
|
69
|
+
]);
|
|
70
|
+
/**
|
|
71
|
+
* Highlight Prisma schema code.
|
|
72
|
+
*/
|
|
73
|
+
function highlightPrisma(code) {
|
|
74
|
+
const placeholders = [];
|
|
75
|
+
// Step 1: line comments and strings
|
|
76
|
+
let result = code.replace(/(\/\/.*$|(['"])(?:(?!\2)[^\\]|\\.)*\2)/gm, (match) => {
|
|
77
|
+
const idx = placeholders.length;
|
|
78
|
+
if (match.startsWith('//')) {
|
|
79
|
+
placeholders.push(pc.gray(match));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
placeholders.push(pc.green(match));
|
|
83
|
+
}
|
|
84
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
85
|
+
});
|
|
86
|
+
// Step 2: directives (@id, @@unique, etc.)
|
|
87
|
+
result = result.replace(/@@?[a-zA-Z]+/g, (match) => {
|
|
88
|
+
const idx = placeholders.length;
|
|
89
|
+
placeholders.push(pc.magenta(match));
|
|
90
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
91
|
+
});
|
|
92
|
+
// Step 3: field types (capitalized identifiers in the type set)
|
|
93
|
+
result = result.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g, (match) => {
|
|
94
|
+
if (PRISMA_FIELD_TYPES.has(match)) {
|
|
95
|
+
const idx = placeholders.length;
|
|
96
|
+
placeholders.push(pc.blue(match));
|
|
97
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
98
|
+
}
|
|
99
|
+
return match;
|
|
100
|
+
});
|
|
101
|
+
// Step 4: keywords
|
|
102
|
+
result = result.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g, (match) => {
|
|
103
|
+
if (PRISMA_KEYWORDS.has(match)) {
|
|
104
|
+
const idx = placeholders.length;
|
|
105
|
+
placeholders.push(pc.cyan(match));
|
|
106
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
107
|
+
}
|
|
108
|
+
return match;
|
|
109
|
+
});
|
|
110
|
+
// Step 5: restore
|
|
111
|
+
return result.replace(/\x00TOKEN_(\d+)\x00/g, (_, i) => placeholders[Number(i)]);
|
|
112
|
+
}
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// JSON
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
/**
|
|
117
|
+
* Highlight JSON code.
|
|
118
|
+
*/
|
|
119
|
+
function highlightJSON(code) {
|
|
120
|
+
const placeholders = [];
|
|
121
|
+
// Step 1: string keys (before colon) and string values
|
|
122
|
+
// Keys: "key":
|
|
123
|
+
let result = code.replace(/"([^"\\]|\\.)*"\s*:/g, (match) => {
|
|
124
|
+
const idx = placeholders.length;
|
|
125
|
+
// color just the key string, keep the colon plain
|
|
126
|
+
const colonIdx = match.lastIndexOf(':');
|
|
127
|
+
const key = match.slice(0, colonIdx);
|
|
128
|
+
const colon = match.slice(colonIdx);
|
|
129
|
+
placeholders.push(pc.cyan(key) + colon);
|
|
130
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
131
|
+
});
|
|
132
|
+
// Values: remaining strings
|
|
133
|
+
result = result.replace(/"([^"\\]|\\.)*"/g, (match) => {
|
|
134
|
+
const idx = placeholders.length;
|
|
135
|
+
placeholders.push(pc.green(match));
|
|
136
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
137
|
+
});
|
|
138
|
+
// Step 2: numbers
|
|
139
|
+
result = result.replace(/\b\d+(\.\d+)?\b/g, (match) => {
|
|
140
|
+
const idx = placeholders.length;
|
|
141
|
+
placeholders.push(pc.yellow(match));
|
|
142
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
143
|
+
});
|
|
144
|
+
// Step 3: booleans and null
|
|
145
|
+
result = result.replace(/\b(true|false|null)\b/g, (match) => {
|
|
146
|
+
const idx = placeholders.length;
|
|
147
|
+
placeholders.push(pc.cyan(match));
|
|
148
|
+
return `\x00TOKEN_${idx}\x00`;
|
|
149
|
+
});
|
|
150
|
+
// Step 4: restore
|
|
151
|
+
return result.replace(/\x00TOKEN_(\d+)\x00/g, (_, i) => placeholders[Number(i)]);
|
|
152
|
+
}
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
// Markdown
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
/**
|
|
157
|
+
* Highlight Markdown code (line-by-line for headings, inline for others).
|
|
158
|
+
*/
|
|
159
|
+
function highlightMarkdown(code) {
|
|
160
|
+
const lines = code.split('\n');
|
|
161
|
+
const processed = lines.map((line) => {
|
|
162
|
+
// Fenced code block lines (``` or ~~~)
|
|
163
|
+
if (/^```/.test(line) || /^~~~/.test(line)) {
|
|
164
|
+
return pc.green(line);
|
|
165
|
+
}
|
|
166
|
+
// Headings: lines starting with #
|
|
167
|
+
if (/^#{1,6}\s/.test(line)) {
|
|
168
|
+
return pc.bold(pc.blue(line));
|
|
169
|
+
}
|
|
170
|
+
// Process inline patterns
|
|
171
|
+
// Inline code: `code`
|
|
172
|
+
line = line.replace(/`([^`]+)`/g, (match) => pc.green(match));
|
|
173
|
+
// Bold: **text**
|
|
174
|
+
line = line.replace(/\*\*([^*]+)\*\*/g, (match) => pc.bold(match));
|
|
175
|
+
return line;
|
|
176
|
+
});
|
|
177
|
+
return processed.join('\n');
|
|
178
|
+
}
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
// Public API
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
/** Maximum input size for highlighting (100 KB). Larger inputs returned as-is. */
|
|
183
|
+
const MAX_HIGHLIGHT_SIZE = 100_000;
|
|
184
|
+
/**
|
|
185
|
+
* Apply minimal syntax highlighting using ANSI color codes via picocolors.
|
|
186
|
+
* Returns the input code unchanged if the language is unsupported or if any
|
|
187
|
+
* error occurs — never throws.
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
export function highlight(code, options) {
|
|
191
|
+
if (code.length > MAX_HIGHLIGHT_SIZE)
|
|
192
|
+
return code;
|
|
193
|
+
try {
|
|
194
|
+
const lang = options.language;
|
|
195
|
+
switch (lang) {
|
|
196
|
+
case 'typescript':
|
|
197
|
+
case 'javascript':
|
|
198
|
+
return highlightTS(code);
|
|
199
|
+
case 'prisma':
|
|
200
|
+
return highlightPrisma(code);
|
|
201
|
+
case 'json':
|
|
202
|
+
return highlightJSON(code);
|
|
203
|
+
case 'markdown':
|
|
204
|
+
return highlightMarkdown(code);
|
|
205
|
+
default:
|
|
206
|
+
return code;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return code;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Infer a SupportedLanguage from a file path/extension.
|
|
215
|
+
* Returns null if the extension is not in the supported set.
|
|
216
|
+
*
|
|
217
|
+
*/
|
|
218
|
+
export function inferLanguageFromPath(filePath) {
|
|
219
|
+
const ext = filePath.slice(filePath.lastIndexOf('.')).toLowerCase();
|
|
220
|
+
switch (ext) {
|
|
221
|
+
case '.ts':
|
|
222
|
+
case '.tsx':
|
|
223
|
+
return 'typescript';
|
|
224
|
+
case '.js':
|
|
225
|
+
case '.jsx':
|
|
226
|
+
case '.mjs':
|
|
227
|
+
case '.cjs':
|
|
228
|
+
return 'javascript';
|
|
229
|
+
case '.prisma':
|
|
230
|
+
return 'prisma';
|
|
231
|
+
case '.json':
|
|
232
|
+
return 'json';
|
|
233
|
+
case '.md':
|
|
234
|
+
return 'markdown';
|
|
235
|
+
default:
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=highlight.js.map
|