@kernlang/agon 0.1.3 → 0.1.5
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/dist/{chunk-52VTWOLH.js → chunk-46WNYE4R.js} +118 -162
- package/dist/chunk-46WNYE4R.js.map +1 -0
- package/dist/{chunk-XOJPAFCJ.js → chunk-4NTH3EAR.js} +286 -541
- package/dist/chunk-4NTH3EAR.js.map +1 -0
- package/dist/{chunk-H7KZ34VX.js → chunk-73ETZFDH.js} +8 -27
- package/dist/chunk-73ETZFDH.js.map +1 -0
- package/dist/chunk-DGTU4UWQ.js +489 -0
- package/dist/chunk-DGTU4UWQ.js.map +1 -0
- package/dist/chunk-GPYWJO2Q.js +2924 -0
- package/dist/chunk-GPYWJO2Q.js.map +1 -0
- package/dist/{chunk-PFHGKBQT.js → chunk-HAJIKZGU.js} +912 -228
- package/dist/chunk-HAJIKZGU.js.map +1 -0
- package/dist/chunk-HSPQEDHX.js +102 -0
- package/dist/chunk-HSPQEDHX.js.map +1 -0
- package/dist/{chunk-5QMVQPHY.js → chunk-SOUF7XTW.js} +1 -1
- package/dist/{chunk-5QMVQPHY.js.map → chunk-SOUF7XTW.js.map} +1 -1
- package/dist/{dispatch-6LQSMMGI.js → dispatch-XHLJ44TF.js} +2 -2
- package/dist/{forge-6NV4WCMB.js → forge-ZI7NE73F.js} +6 -5
- package/dist/index.js +2070 -3551
- package/dist/index.js.map +1 -1
- package/dist/plan-mode-KIXDKD63.js +17 -0
- package/dist/{src-4VOZ6GIN.js → src-4A5FVACG.js} +53 -3
- package/dist/update-DLPMYTF3.js +30 -0
- package/dist/update-DLPMYTF3.js.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-52VTWOLH.js.map +0 -1
- package/dist/chunk-H7KZ34VX.js.map +0 -1
- package/dist/chunk-PFHGKBQT.js.map +0 -1
- package/dist/chunk-XOJPAFCJ.js.map +0 -1
- package/dist/plan-mode-OSU42TOI.js +0 -15
- /package/dist/{dispatch-6LQSMMGI.js.map → dispatch-XHLJ44TF.js.map} +0 -0
- /package/dist/{forge-6NV4WCMB.js.map → forge-ZI7NE73F.js.map} +0 -0
- /package/dist/{plan-mode-OSU42TOI.js.map → plan-mode-KIXDKD63.js.map} +0 -0
- /package/dist/{src-4VOZ6GIN.js.map → src-4A5FVACG.js.map} +0 -0
|
@@ -0,0 +1,2924 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
extractSummary,
|
|
4
|
+
parsePatchPreview,
|
|
5
|
+
parseToolInputPayload
|
|
6
|
+
} from "./chunk-HSPQEDHX.js";
|
|
7
|
+
import {
|
|
8
|
+
ENGINE_COLORS,
|
|
9
|
+
bold,
|
|
10
|
+
cleanEngineOutput,
|
|
11
|
+
dim,
|
|
12
|
+
fail,
|
|
13
|
+
formatConfidenceToolLabel,
|
|
14
|
+
header,
|
|
15
|
+
icons,
|
|
16
|
+
info,
|
|
17
|
+
isCesarTelemetryLine,
|
|
18
|
+
parseMarkdownBlocks,
|
|
19
|
+
shortToolPath,
|
|
20
|
+
success,
|
|
21
|
+
truncateCodeLine,
|
|
22
|
+
yellow
|
|
23
|
+
} from "./chunk-DGTU4UWQ.js";
|
|
24
|
+
import {
|
|
25
|
+
getAgonHome
|
|
26
|
+
} from "./chunk-HAJIKZGU.js";
|
|
27
|
+
|
|
28
|
+
// src/generated/commands/update.ts
|
|
29
|
+
import { defineCommand } from "citty";
|
|
30
|
+
import { spawn } from "child_process";
|
|
31
|
+
import "os";
|
|
32
|
+
|
|
33
|
+
// src/generated/blocks/engine.tsx
|
|
34
|
+
import React4 from "react";
|
|
35
|
+
import { Box as Box4, Text as Text4 } from "ink";
|
|
36
|
+
|
|
37
|
+
// src/generated/blocks/rich-text.ts
|
|
38
|
+
var DEFAULT_STYLE = { bold: false, italic: false, code: false, dimColor: false, linkUrl: void 0 };
|
|
39
|
+
function classifyLine(line) {
|
|
40
|
+
const trimmed = line.trimStart();
|
|
41
|
+
const leadingSpaces = line.length - trimmed.length;
|
|
42
|
+
if (!trimmed) {
|
|
43
|
+
return { kind: "blank", content: "", indent: 0, marker: void 0 };
|
|
44
|
+
}
|
|
45
|
+
if (/^[-*_]\s*[-*_]\s*[-*_][\s*_-]*$/.test(trimmed)) {
|
|
46
|
+
return { kind: "hr", content: "", indent: 0, marker: void 0 };
|
|
47
|
+
}
|
|
48
|
+
const h3 = trimmed.match(/^###\s+(.*)/);
|
|
49
|
+
if (h3) {
|
|
50
|
+
return { kind: "h3", content: h3[1], indent: 0, marker: "### " };
|
|
51
|
+
}
|
|
52
|
+
const h2 = trimmed.match(/^##\s+(.*)/);
|
|
53
|
+
if (h2) {
|
|
54
|
+
return { kind: "h2", content: h2[1], indent: 0, marker: "## " };
|
|
55
|
+
}
|
|
56
|
+
const h1 = trimmed.match(/^#\s+(.*)/);
|
|
57
|
+
if (h1) {
|
|
58
|
+
return { kind: "h1", content: h1[1], indent: 0, marker: "# " };
|
|
59
|
+
}
|
|
60
|
+
const bq = trimmed.match(/^>\s?(.*)/);
|
|
61
|
+
if (bq) {
|
|
62
|
+
return { kind: "blockquote", content: bq[1], indent: 0, marker: "> " };
|
|
63
|
+
}
|
|
64
|
+
const bullet = trimmed.match(/^[-*+]\s+(.*)/);
|
|
65
|
+
if (bullet) {
|
|
66
|
+
return { kind: "bullet", content: bullet[1], indent: Math.floor(leadingSpaces / 2), marker: "\u2022 " };
|
|
67
|
+
}
|
|
68
|
+
const ordered = trimmed.match(/^(\d+)[.)]\s+(.*)/);
|
|
69
|
+
if (ordered) {
|
|
70
|
+
return { kind: "ordered", content: ordered[2], indent: Math.floor(leadingSpaces / 2), marker: `${ordered[1]}. ` };
|
|
71
|
+
}
|
|
72
|
+
return { kind: "plain", content: line, indent: 0, marker: void 0 };
|
|
73
|
+
}
|
|
74
|
+
function parseInlineSpans(text) {
|
|
75
|
+
if (!text) return [{ text: "", style: DEFAULT_STYLE }];
|
|
76
|
+
const spans = [];
|
|
77
|
+
const TOKEN = /(\*\*\*|__\_|\*\*|__|\*|_|`|\[([^\]]*)\]\(([^)]*)\))/g;
|
|
78
|
+
let pos = 0;
|
|
79
|
+
let bold2 = false;
|
|
80
|
+
let italic = false;
|
|
81
|
+
function pushText(t) {
|
|
82
|
+
if (!t) return;
|
|
83
|
+
spans.push({ text: t, style: { bold: bold2, italic, code: false, dimColor: false, linkUrl: void 0 } });
|
|
84
|
+
}
|
|
85
|
+
let match;
|
|
86
|
+
while ((match = TOKEN.exec(text)) !== null) {
|
|
87
|
+
const before = text.slice(pos, match.index);
|
|
88
|
+
const token = match[0];
|
|
89
|
+
if (match[2] !== void 0) {
|
|
90
|
+
pushText(before);
|
|
91
|
+
spans.push({
|
|
92
|
+
text: match[2],
|
|
93
|
+
style: { bold: bold2, italic, code: false, dimColor: false, linkUrl: match[3] }
|
|
94
|
+
});
|
|
95
|
+
pos = match.index + token.length;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (token === "`") {
|
|
99
|
+
const closeIdx = text.indexOf("`", match.index + 1);
|
|
100
|
+
if (closeIdx === -1) {
|
|
101
|
+
pushText(before + "`");
|
|
102
|
+
pos = match.index + 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
pushText(before);
|
|
106
|
+
const codeText = text.slice(match.index + 1, closeIdx);
|
|
107
|
+
spans.push({
|
|
108
|
+
text: codeText,
|
|
109
|
+
style: { bold: false, italic: false, code: true, dimColor: false, linkUrl: void 0 }
|
|
110
|
+
});
|
|
111
|
+
pos = closeIdx + 1;
|
|
112
|
+
TOKEN.lastIndex = pos;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (token === "***" || token === "___") {
|
|
116
|
+
pushText(before);
|
|
117
|
+
if (bold2 && italic) {
|
|
118
|
+
bold2 = false;
|
|
119
|
+
italic = false;
|
|
120
|
+
} else {
|
|
121
|
+
bold2 = true;
|
|
122
|
+
italic = true;
|
|
123
|
+
}
|
|
124
|
+
pos = match.index + token.length;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (token === "**" || token === "__") {
|
|
128
|
+
pushText(before);
|
|
129
|
+
bold2 = !bold2;
|
|
130
|
+
pos = match.index + token.length;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (token === "*" || token === "_") {
|
|
134
|
+
if (token === "_") {
|
|
135
|
+
const charBefore = match.index > 0 ? text[match.index - 1] : " ";
|
|
136
|
+
const charAfter = match.index + 1 < text.length ? text[match.index + 1] : " ";
|
|
137
|
+
if (/\w/.test(charBefore) && /\w/.test(charAfter)) {
|
|
138
|
+
pushText(before + "_");
|
|
139
|
+
pos = match.index + 1;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
pushText(before);
|
|
144
|
+
italic = !italic;
|
|
145
|
+
pos = match.index + token.length;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
pushText(before + token);
|
|
149
|
+
pos = match.index + token.length;
|
|
150
|
+
}
|
|
151
|
+
const tail = text.slice(pos);
|
|
152
|
+
if (tail) pushText(tail);
|
|
153
|
+
const merged = [];
|
|
154
|
+
for (const span of spans) {
|
|
155
|
+
const last = merged[merged.length - 1];
|
|
156
|
+
if (last && last.style.bold === span.style.bold && last.style.italic === span.style.italic && last.style.code === span.style.code && last.style.dimColor === span.style.dimColor && last.style.linkUrl === span.style.linkUrl) {
|
|
157
|
+
last.text += span.text;
|
|
158
|
+
} else {
|
|
159
|
+
merged.push({ ...span, style: { ...span.style } });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return merged.length > 0 ? merged : [{ text, style: DEFAULT_STYLE }];
|
|
163
|
+
}
|
|
164
|
+
function spansVisibleLength(spans) {
|
|
165
|
+
return spans.reduce((sum, s) => sum + s.text.length, 0);
|
|
166
|
+
}
|
|
167
|
+
function richWrap(spans, width) {
|
|
168
|
+
if (width <= 0) return [spans];
|
|
169
|
+
if (spansVisibleLength(spans) <= width) return [spans];
|
|
170
|
+
const fullText = spans.map((s) => s.text).join("");
|
|
171
|
+
if (!fullText) return [spans];
|
|
172
|
+
const lineRanges = [];
|
|
173
|
+
let lineStart = 0;
|
|
174
|
+
while (lineStart < fullText.length) {
|
|
175
|
+
if (lineStart + width >= fullText.length) {
|
|
176
|
+
lineRanges.push([lineStart, fullText.length]);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
let breakAt = fullText.lastIndexOf(" ", lineStart + width);
|
|
180
|
+
if (breakAt <= lineStart) breakAt = lineStart + width;
|
|
181
|
+
lineRanges.push([lineStart, breakAt]);
|
|
182
|
+
lineStart = breakAt;
|
|
183
|
+
while (lineStart < fullText.length && fullText[lineStart] === " ") lineStart++;
|
|
184
|
+
}
|
|
185
|
+
const spanRanges = [];
|
|
186
|
+
let offset = 0;
|
|
187
|
+
for (const span of spans) {
|
|
188
|
+
spanRanges.push({ start: offset, end: offset + span.text.length, style: span.style });
|
|
189
|
+
offset += span.text.length;
|
|
190
|
+
}
|
|
191
|
+
const lines = [];
|
|
192
|
+
for (const [rangeStart, rangeEnd] of lineRanges) {
|
|
193
|
+
const lineSpans = [];
|
|
194
|
+
for (const sr of spanRanges) {
|
|
195
|
+
if (sr.end <= rangeStart || sr.start >= rangeEnd) continue;
|
|
196
|
+
const sliceStart = Math.max(sr.start, rangeStart) - sr.start;
|
|
197
|
+
const sliceEnd = Math.min(sr.end, rangeEnd) - sr.start;
|
|
198
|
+
const sliceText = fullText.slice(sr.start + sliceStart, sr.start + sliceEnd);
|
|
199
|
+
const trimmed = lineSpans.length === 0 ? sliceText.trimStart() : sliceText;
|
|
200
|
+
if (trimmed) lineSpans.push({ text: trimmed, style: { ...sr.style } });
|
|
201
|
+
}
|
|
202
|
+
if (lineSpans.length > 0) {
|
|
203
|
+
const last = lineSpans[lineSpans.length - 1];
|
|
204
|
+
last.text = last.text.trimEnd();
|
|
205
|
+
if (!last.text) lineSpans.pop();
|
|
206
|
+
}
|
|
207
|
+
if (lineSpans.length > 0) lines.push(lineSpans);
|
|
208
|
+
}
|
|
209
|
+
return lines.length > 0 ? lines : [spans];
|
|
210
|
+
}
|
|
211
|
+
function parseProseToRichLines(text, width) {
|
|
212
|
+
if (!text.trim()) return [];
|
|
213
|
+
const inputLines = text.split("\n");
|
|
214
|
+
const result = [];
|
|
215
|
+
for (const rawLine of inputLines) {
|
|
216
|
+
const classified = classifyLine(rawLine);
|
|
217
|
+
if (classified.kind === "blank") {
|
|
218
|
+
result.push({ kind: "blank", spans: [], indent: 0, marker: void 0 });
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (classified.kind === "hr") {
|
|
222
|
+
result.push({ kind: "hr", spans: [{ text: "\u2500".repeat(Math.max(width - 2, 10)), style: { ...DEFAULT_STYLE, dimColor: true } }], indent: 0, marker: void 0 });
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const spans = parseInlineSpans(classified.content);
|
|
226
|
+
if (classified.kind === "blockquote") {
|
|
227
|
+
for (const span of spans) {
|
|
228
|
+
if (!span.style.code) span.style.dimColor = true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const indentWidth = classified.indent * 2;
|
|
232
|
+
const markerWidth = classified.marker ? classified.marker.length : 0;
|
|
233
|
+
const contentWidth2 = Math.max(width - indentWidth - markerWidth, 20);
|
|
234
|
+
const wrappedLines = richWrap(spans, contentWidth2);
|
|
235
|
+
for (let i = 0; i < wrappedLines.length; i++) {
|
|
236
|
+
result.push({
|
|
237
|
+
kind: i === 0 ? classified.kind : "plain",
|
|
238
|
+
spans: wrappedLines[i],
|
|
239
|
+
indent: classified.indent,
|
|
240
|
+
// Only first wrapped line gets the marker; continuations get indent
|
|
241
|
+
marker: i === 0 ? classified.marker : void 0
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/generated/blocks/rendering.tsx
|
|
249
|
+
import React from "react";
|
|
250
|
+
import { Box, Text } from "ink";
|
|
251
|
+
|
|
252
|
+
// src/generated/signals/ansi-parse.ts
|
|
253
|
+
var ANSI_COLORS = { 30: "#000000", 31: "#ef4444", 32: "#4ade80", 33: "#fbbf24", 34: "#60a5fa", 35: "#c084fc", 36: "#22d3ee", 37: "#e2e8f0", 90: "#6b7280", 91: "#f87171", 92: "#86efac", 93: "#fde047", 94: "#93c5fd", 95: "#d8b4fe", 96: "#67e8f9", 97: "#ffffff" };
|
|
254
|
+
var ANSI_BG_COLORS = { 40: "#000000", 41: "#991b1b", 42: "#166534", 43: "#854d0e", 44: "#1e3a5f", 45: "#581c87", 46: "#155e75", 47: "#374151", 100: "#4b5563", 101: "#b91c1c", 102: "#15803d", 103: "#a16207", 104: "#1d4ed8", 105: "#7e22ce", 106: "#0e7490", 107: "#9ca3af" };
|
|
255
|
+
function parseAnsiText(text) {
|
|
256
|
+
const segments = [];
|
|
257
|
+
const ansiRe = /\x1b\[([0-9;]*)m/g;
|
|
258
|
+
let lastIndex = 0;
|
|
259
|
+
let currentColor;
|
|
260
|
+
let currentBg;
|
|
261
|
+
let bold2 = false;
|
|
262
|
+
let dim2 = false;
|
|
263
|
+
let italic = false;
|
|
264
|
+
let match;
|
|
265
|
+
while ((match = ansiRe.exec(text)) !== null) {
|
|
266
|
+
if (match.index > lastIndex) {
|
|
267
|
+
const chunk = text.slice(lastIndex, match.index);
|
|
268
|
+
if (chunk) {
|
|
269
|
+
segments.push({ text: chunk, color: currentColor, bgColor: currentBg, bold: bold2 || void 0, dim: dim2 || void 0, italic: italic || void 0 });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
lastIndex = match.index + match[0].length;
|
|
273
|
+
const codes = match[1].split(";").map(Number);
|
|
274
|
+
for (let i = 0; i < codes.length; i++) {
|
|
275
|
+
const code = codes[i];
|
|
276
|
+
if (code === 0) {
|
|
277
|
+
currentColor = void 0;
|
|
278
|
+
currentBg = void 0;
|
|
279
|
+
bold2 = false;
|
|
280
|
+
dim2 = false;
|
|
281
|
+
italic = false;
|
|
282
|
+
} else if (code === 1) {
|
|
283
|
+
bold2 = true;
|
|
284
|
+
} else if (code === 2) {
|
|
285
|
+
dim2 = true;
|
|
286
|
+
} else if (code === 3) {
|
|
287
|
+
italic = true;
|
|
288
|
+
} else if (code === 22) {
|
|
289
|
+
bold2 = false;
|
|
290
|
+
dim2 = false;
|
|
291
|
+
} else if (code === 23) {
|
|
292
|
+
italic = false;
|
|
293
|
+
} else if (code >= 30 && code <= 37) {
|
|
294
|
+
currentColor = ANSI_COLORS[code];
|
|
295
|
+
} else if (code >= 90 && code <= 97) {
|
|
296
|
+
currentColor = ANSI_COLORS[code];
|
|
297
|
+
} else if (code === 39) {
|
|
298
|
+
currentColor = void 0;
|
|
299
|
+
} else if (code >= 40 && code <= 47) {
|
|
300
|
+
currentBg = ANSI_BG_COLORS[code];
|
|
301
|
+
} else if (code >= 100 && code <= 107) {
|
|
302
|
+
currentBg = ANSI_BG_COLORS[code];
|
|
303
|
+
} else if (code === 49) {
|
|
304
|
+
currentBg = void 0;
|
|
305
|
+
} else if (code === 38 && codes[i + 1] === 5 && codes[i + 2] !== void 0) {
|
|
306
|
+
const n = codes[i + 2];
|
|
307
|
+
if (n < 16) {
|
|
308
|
+
const basic = {
|
|
309
|
+
0: "#000000",
|
|
310
|
+
1: "#aa0000",
|
|
311
|
+
2: "#00aa00",
|
|
312
|
+
3: "#aa5500",
|
|
313
|
+
4: "#0000aa",
|
|
314
|
+
5: "#aa00aa",
|
|
315
|
+
6: "#00aaaa",
|
|
316
|
+
7: "#aaaaaa",
|
|
317
|
+
8: "#555555",
|
|
318
|
+
9: "#ff5555",
|
|
319
|
+
10: "#55ff55",
|
|
320
|
+
11: "#ffff55",
|
|
321
|
+
12: "#5555ff",
|
|
322
|
+
13: "#ff55ff",
|
|
323
|
+
14: "#55ffff",
|
|
324
|
+
15: "#ffffff"
|
|
325
|
+
};
|
|
326
|
+
currentColor = basic[n] ?? "#ffffff";
|
|
327
|
+
} else if (n >= 232) {
|
|
328
|
+
const gray = 8 + (n - 232) * 10;
|
|
329
|
+
const h = Math.min(255, gray).toString(16).padStart(2, "0");
|
|
330
|
+
currentColor = `#${h}${h}${h}`;
|
|
331
|
+
} else {
|
|
332
|
+
const idx = n - 16;
|
|
333
|
+
const r = Math.floor(idx / 36);
|
|
334
|
+
const g = Math.floor(idx % 36 / 6);
|
|
335
|
+
const b = idx % 6;
|
|
336
|
+
const toHex = (v) => (v === 0 ? 0 : 55 + v * 40).toString(16).padStart(2, "0");
|
|
337
|
+
currentColor = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
338
|
+
}
|
|
339
|
+
i += 2;
|
|
340
|
+
} else if (code === 38 && codes[i + 1] === 2 && codes[i + 4] !== void 0) {
|
|
341
|
+
const r = (codes[i + 2] ?? 0).toString(16).padStart(2, "0");
|
|
342
|
+
const g = (codes[i + 3] ?? 0).toString(16).padStart(2, "0");
|
|
343
|
+
const b = (codes[i + 4] ?? 0).toString(16).padStart(2, "0");
|
|
344
|
+
currentColor = `#${r}${g}${b}`;
|
|
345
|
+
i += 4;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (lastIndex < text.length) {
|
|
350
|
+
const chunk = text.slice(lastIndex);
|
|
351
|
+
if (chunk) {
|
|
352
|
+
segments.push({ text: chunk, color: currentColor, bgColor: currentBg, bold: bold2 || void 0, dim: dim2 || void 0, italic: italic || void 0 });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (segments.length === 0 && text) {
|
|
356
|
+
segments.push({ text });
|
|
357
|
+
}
|
|
358
|
+
return segments;
|
|
359
|
+
}
|
|
360
|
+
function hasAnsiCodes(text) {
|
|
361
|
+
return /\x1b\[/.test(text);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/generated/blocks/rendering.tsx
|
|
365
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
366
|
+
function DiffLine({ line, maxWidth }) {
|
|
367
|
+
const truncated = truncateCodeLine(line, maxWidth);
|
|
368
|
+
if (line.startsWith("+")) {
|
|
369
|
+
return /* @__PURE__ */ jsx(Text, { color: "#22c55e", children: truncated });
|
|
370
|
+
}
|
|
371
|
+
if (line.startsWith("-")) {
|
|
372
|
+
return /* @__PURE__ */ jsx(Text, { color: "#ef4444", children: truncated });
|
|
373
|
+
}
|
|
374
|
+
if (line.startsWith("@@")) {
|
|
375
|
+
return /* @__PURE__ */ jsx(Text, { color: "#22d3ee", children: truncated });
|
|
376
|
+
}
|
|
377
|
+
return /* @__PURE__ */ jsx(Text, { children: truncated });
|
|
378
|
+
}
|
|
379
|
+
function SyntaxLine({ line, maxWidth }) {
|
|
380
|
+
if (line.length > maxWidth) {
|
|
381
|
+
const visible = line.slice(0, maxWidth - 4);
|
|
382
|
+
const overflow = line.length - maxWidth + 4;
|
|
383
|
+
const tokens2 = tokenizeLine(visible);
|
|
384
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
385
|
+
tokens2.map((t, i) => t.color ? /* @__PURE__ */ jsx(Text, { color: t.color, children: t.text }, i) : /* @__PURE__ */ jsx(Text, { children: t.text }, i)),
|
|
386
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: `\u2026+${overflow}` })
|
|
387
|
+
] });
|
|
388
|
+
}
|
|
389
|
+
const tokens = tokenizeLine(line);
|
|
390
|
+
return /* @__PURE__ */ jsx(Text, { children: tokens.map((t, i) => t.color ? /* @__PURE__ */ jsx(Text, { color: t.color, children: t.text }, i) : /* @__PURE__ */ jsx(Text, { children: t.text }, i)) });
|
|
391
|
+
}
|
|
392
|
+
function CodeBlockView({ segment, borderColor }) {
|
|
393
|
+
const codeWidth = contentWidth(8);
|
|
394
|
+
const lines = (segment.code ?? "").split("\n");
|
|
395
|
+
const isDiff = segment.language === "diff" || lines.some((l) => /^[+-@]/.test(l));
|
|
396
|
+
const capped = lines.slice(0, MAX_CODE_LINES);
|
|
397
|
+
const overflow = lines.length - MAX_CODE_LINES;
|
|
398
|
+
const bc = borderColor || "#585858";
|
|
399
|
+
const maxLineLen = capped.reduce((m, l) => Math.max(m, l.length), 0);
|
|
400
|
+
const headerLen = (segment.language || "code").length + (segment.index !== void 0 ? ` [${segment.index}]`.length : 0);
|
|
401
|
+
const innerWidth = Math.max(maxLineLen, headerLen);
|
|
402
|
+
const boxWidth = innerWidth + 4;
|
|
403
|
+
const rule = "\u2500".repeat(boxWidth);
|
|
404
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", width: boxWidth + 2, flexShrink: 0, children: [
|
|
405
|
+
/* @__PURE__ */ jsxs(Text, { color: bc, children: [
|
|
406
|
+
"\u2502 ",
|
|
407
|
+
rule,
|
|
408
|
+
" \u2502"
|
|
409
|
+
] }),
|
|
410
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
411
|
+
/* @__PURE__ */ jsx(Text, { color: bc, children: "\u2502 " }),
|
|
412
|
+
/* @__PURE__ */ jsx(Text, { color: CODE_RAIL_COLOR, children: CODE_RAIL }),
|
|
413
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
414
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: segment.language || "code" }),
|
|
415
|
+
segment.index !== void 0 && /* @__PURE__ */ jsx(Text, { color: "#585858", children: ` [${segment.index}]` }),
|
|
416
|
+
/* @__PURE__ */ jsx(Text, { children: " ".repeat(Math.max(0, boxWidth - headerLen - 1)) }),
|
|
417
|
+
/* @__PURE__ */ jsx(Text, { color: bc, children: " \u2502" })
|
|
418
|
+
] }),
|
|
419
|
+
capped.map((line, i) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
420
|
+
/* @__PURE__ */ jsx(Text, { color: bc, children: "\u2502 " }),
|
|
421
|
+
/* @__PURE__ */ jsx(Text, { color: CODE_RAIL_COLOR, children: CODE_RAIL }),
|
|
422
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
423
|
+
isDiff ? /* @__PURE__ */ jsx(DiffLine, { line, maxWidth: codeWidth }) : /* @__PURE__ */ jsx(SyntaxLine, { line, maxWidth: codeWidth }),
|
|
424
|
+
/* @__PURE__ */ jsx(Text, { children: " ".repeat(Math.max(0, codeWidth - line.length - 4)) }),
|
|
425
|
+
/* @__PURE__ */ jsx(Text, { color: bc, children: " \u2502" })
|
|
426
|
+
] }, `code-${i}`)),
|
|
427
|
+
overflow > 0 && /* @__PURE__ */ jsxs(Text, { children: [
|
|
428
|
+
/* @__PURE__ */ jsx(Text, { color: bc, children: "\u2502 " }),
|
|
429
|
+
/* @__PURE__ */ jsx(Text, { color: CODE_RAIL_COLOR, children: CODE_RAIL }),
|
|
430
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
431
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
432
|
+
"\u2026 ",
|
|
433
|
+
overflow,
|
|
434
|
+
" more lines"
|
|
435
|
+
] }),
|
|
436
|
+
/* @__PURE__ */ jsx(Text, { color: bc, children: " \u2502" })
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ jsxs(Text, { color: bc, children: [
|
|
439
|
+
"\u2502 ",
|
|
440
|
+
rule,
|
|
441
|
+
" \u2502"
|
|
442
|
+
] })
|
|
443
|
+
] });
|
|
444
|
+
}
|
|
445
|
+
function RichSpanView({ span }) {
|
|
446
|
+
if (span.style.code) {
|
|
447
|
+
return /* @__PURE__ */ jsx(Text, { color: "#a78bfa", backgroundColor: "#1e1033", children: span.text });
|
|
448
|
+
}
|
|
449
|
+
if (span.style.linkUrl) {
|
|
450
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
451
|
+
/* @__PURE__ */ jsx(Text, { bold: true, color: "#60a5fa", children: span.text }),
|
|
452
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` (${span.style.linkUrl})` })
|
|
453
|
+
] });
|
|
454
|
+
}
|
|
455
|
+
let el = /* @__PURE__ */ jsx(Text, { children: span.text });
|
|
456
|
+
if (span.style.bold && span.style.italic) el = /* @__PURE__ */ jsx(Text, { bold: true, italic: true, children: span.text });
|
|
457
|
+
else if (span.style.bold) el = /* @__PURE__ */ jsx(Text, { bold: true, children: span.text });
|
|
458
|
+
else if (span.style.italic) el = /* @__PURE__ */ jsx(Text, { italic: true, children: span.text });
|
|
459
|
+
if (span.style.dimColor) el = /* @__PURE__ */ jsx(Text, { dimColor: true, children: span.text });
|
|
460
|
+
return el;
|
|
461
|
+
}
|
|
462
|
+
function RichLineView({ line, borderColor }) {
|
|
463
|
+
const border = borderColor ? /* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502 " }) : null;
|
|
464
|
+
const indent = line.indent > 0 ? " ".repeat(line.indent) : "";
|
|
465
|
+
if (line.kind === "blank") return /* @__PURE__ */ jsxs(Text, { children: [
|
|
466
|
+
border,
|
|
467
|
+
" "
|
|
468
|
+
] });
|
|
469
|
+
if (line.kind === "hr") return /* @__PURE__ */ jsxs(Text, { children: [
|
|
470
|
+
border,
|
|
471
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2500".repeat(40) })
|
|
472
|
+
] });
|
|
473
|
+
if (line.kind === "h1") return /* @__PURE__ */ jsxs(Text, { children: [
|
|
474
|
+
border,
|
|
475
|
+
indent,
|
|
476
|
+
/* @__PURE__ */ jsxs(Text, { bold: true, color: "cyan", children: [
|
|
477
|
+
"# ",
|
|
478
|
+
line.spans.map((s, i) => /* @__PURE__ */ jsx(RichSpanView, { span: s }, i))
|
|
479
|
+
] })
|
|
480
|
+
] });
|
|
481
|
+
if (line.kind === "h2") return /* @__PURE__ */ jsxs(Text, { children: [
|
|
482
|
+
border,
|
|
483
|
+
indent,
|
|
484
|
+
/* @__PURE__ */ jsxs(Text, { bold: true, color: "white", children: [
|
|
485
|
+
"## ",
|
|
486
|
+
line.spans.map((s, i) => /* @__PURE__ */ jsx(RichSpanView, { span: s }, i))
|
|
487
|
+
] })
|
|
488
|
+
] });
|
|
489
|
+
if (line.kind === "h3") return /* @__PURE__ */ jsxs(Text, { children: [
|
|
490
|
+
border,
|
|
491
|
+
indent,
|
|
492
|
+
/* @__PURE__ */ jsxs(Text, { bold: true, color: "#a0a0a0", children: [
|
|
493
|
+
"### ",
|
|
494
|
+
line.spans.map((s, i) => /* @__PURE__ */ jsx(RichSpanView, { span: s }, i))
|
|
495
|
+
] })
|
|
496
|
+
] });
|
|
497
|
+
if (line.kind === "blockquote") {
|
|
498
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
499
|
+
border,
|
|
500
|
+
indent,
|
|
501
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2502 " }),
|
|
502
|
+
line.spans.map((s, i) => /* @__PURE__ */ jsx(RichSpanView, { span: s }, i))
|
|
503
|
+
] });
|
|
504
|
+
}
|
|
505
|
+
const marker = line.marker ?? "";
|
|
506
|
+
const listIndent = (line.kind === "bullet" || line.kind === "ordered") && !indent ? " " : "";
|
|
507
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
508
|
+
border,
|
|
509
|
+
indent,
|
|
510
|
+
listIndent,
|
|
511
|
+
marker,
|
|
512
|
+
line.spans.map((s, i) => /* @__PURE__ */ jsx(RichSpanView, { span: s }, i))
|
|
513
|
+
] });
|
|
514
|
+
}
|
|
515
|
+
function MarkdownTableView({ headers, rows, alignments, borderColor }) {
|
|
516
|
+
const colWidths = headers.map((h, i) => {
|
|
517
|
+
let max = h.length;
|
|
518
|
+
for (const row of rows) {
|
|
519
|
+
if (row[i] && row[i].length > max) max = row[i].length;
|
|
520
|
+
}
|
|
521
|
+
return max;
|
|
522
|
+
});
|
|
523
|
+
function padCell(text, colIdx) {
|
|
524
|
+
const w = colWidths[colIdx] ?? text.length;
|
|
525
|
+
const align = alignments[colIdx] ?? "left";
|
|
526
|
+
if (align === "right") return text.padStart(w);
|
|
527
|
+
if (align === "center") {
|
|
528
|
+
const pad = w - text.length;
|
|
529
|
+
const left = Math.floor(pad / 2);
|
|
530
|
+
return " ".repeat(left) + text + " ".repeat(pad - left);
|
|
531
|
+
}
|
|
532
|
+
return text.padEnd(w);
|
|
533
|
+
}
|
|
534
|
+
const headerLine = headers.map((h, i) => padCell(h, i)).join(" ");
|
|
535
|
+
const sepLine = colWidths.map((w) => "\u2500".repeat(w)).join("\u2500\u2500");
|
|
536
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
537
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
538
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502 " }),
|
|
539
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: headerLine })
|
|
540
|
+
] }),
|
|
541
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
542
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502 " }),
|
|
543
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: sepLine })
|
|
544
|
+
] }),
|
|
545
|
+
rows.map((row, ri) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
546
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502 " }),
|
|
547
|
+
row.map((cell, ci) => padCell(cell, ci)).join(" ")
|
|
548
|
+
] }, `tr-${ri}`))
|
|
549
|
+
] });
|
|
550
|
+
}
|
|
551
|
+
function RenderedSegments({ segments, borderColor, wrapWidth }) {
|
|
552
|
+
return /* @__PURE__ */ jsx(Fragment, { children: segments.map((seg, i) => {
|
|
553
|
+
const spacer = i > 0 && borderColor ? /* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502" }, `sp-${i}`) : i > 0 ? /* @__PURE__ */ jsx(Text, { children: " " }, `sp-${i}`) : null;
|
|
554
|
+
if (seg.type === "prose") {
|
|
555
|
+
const richLines = parseProseToRichLines(seg.text ?? "", wrapWidth);
|
|
556
|
+
if (richLines.length === 0) return null;
|
|
557
|
+
const spaced = [];
|
|
558
|
+
for (let j = 0; j < richLines.length; j++) {
|
|
559
|
+
const line = richLines[j];
|
|
560
|
+
const prev = j > 0 ? richLines[j - 1] : null;
|
|
561
|
+
if ((line.kind === "h1" || line.kind === "h2" || line.kind === "h3") && prev && prev.kind !== "blank") {
|
|
562
|
+
spaced.push({ kind: "blank", spans: [], indent: 0, marker: void 0 });
|
|
563
|
+
}
|
|
564
|
+
spaced.push(line);
|
|
565
|
+
if (line.kind === "h1" || line.kind === "h2" || line.kind === "h3") {
|
|
566
|
+
const next = j + 1 < richLines.length ? richLines[j + 1] : null;
|
|
567
|
+
if (next && next.kind !== "blank") {
|
|
568
|
+
spaced.push({ kind: "blank", spans: [], indent: 0, marker: void 0 });
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
573
|
+
spacer,
|
|
574
|
+
/* @__PURE__ */ jsx(Box, { flexDirection: "column", children: spaced.map((line, j) => /* @__PURE__ */ jsx(RichLineView, { line, borderColor }, `rl-${i}-${j}`)) })
|
|
575
|
+
] }, `seg-${i}`);
|
|
576
|
+
}
|
|
577
|
+
if (seg.type === "table") {
|
|
578
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
579
|
+
spacer,
|
|
580
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
581
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502" }),
|
|
582
|
+
/* @__PURE__ */ jsx(MarkdownTableView, { headers: seg.headers ?? [], rows: seg.rows ?? [], alignments: seg.alignments ?? [], borderColor }),
|
|
583
|
+
/* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502" })
|
|
584
|
+
] })
|
|
585
|
+
] }, `seg-${i}`);
|
|
586
|
+
}
|
|
587
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
588
|
+
spacer,
|
|
589
|
+
/* @__PURE__ */ jsx(CodeBlockView, { segment: seg, borderColor })
|
|
590
|
+
] }, `seg-${i}`);
|
|
591
|
+
}) });
|
|
592
|
+
}
|
|
593
|
+
function GradientLine({ text, colors }) {
|
|
594
|
+
const step = Math.max(1, Math.ceil(text.length / colors.length));
|
|
595
|
+
return /* @__PURE__ */ jsx(Text, { children: text.split("").map((ch, i) => {
|
|
596
|
+
const ci = Math.min(Math.floor(i / step), colors.length - 1);
|
|
597
|
+
return /* @__PURE__ */ jsx(Text, { color: colors[ci], children: ch }, i);
|
|
598
|
+
}) });
|
|
599
|
+
}
|
|
600
|
+
function AnsiLine({ text, maxWidth, fallbackDim }) {
|
|
601
|
+
if (!hasAnsiCodes(text)) {
|
|
602
|
+
const display = text.length > maxWidth ? text.slice(0, maxWidth - 4) + "\u2026" : text;
|
|
603
|
+
return fallbackDim ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: display }) : /* @__PURE__ */ jsx(Text, { children: display });
|
|
604
|
+
}
|
|
605
|
+
const segments = parseAnsiText(text);
|
|
606
|
+
return /* @__PURE__ */ jsx(Text, { children: segments.map((seg, i) => /* @__PURE__ */ jsx(
|
|
607
|
+
Text,
|
|
608
|
+
{
|
|
609
|
+
color: seg.color,
|
|
610
|
+
backgroundColor: seg.bgColor,
|
|
611
|
+
bold: seg.bold,
|
|
612
|
+
dimColor: seg.dim,
|
|
613
|
+
italic: seg.italic,
|
|
614
|
+
children: seg.text
|
|
615
|
+
},
|
|
616
|
+
i
|
|
617
|
+
)) });
|
|
618
|
+
}
|
|
619
|
+
var CONTENT_WIDTH_OVERRIDE = { value: null };
|
|
620
|
+
function contentWidth(padding) {
|
|
621
|
+
const termWidth = CONTENT_WIDTH_OVERRIDE.value ?? (process.stdout.columns || 100);
|
|
622
|
+
return Math.max(termWidth - padding, 40);
|
|
623
|
+
}
|
|
624
|
+
function color256toHex(code) {
|
|
625
|
+
const basic16 = {
|
|
626
|
+
0: "#000000",
|
|
627
|
+
1: "#aa0000",
|
|
628
|
+
2: "#00aa00",
|
|
629
|
+
3: "#aa5500",
|
|
630
|
+
4: "#0000aa",
|
|
631
|
+
5: "#aa00aa",
|
|
632
|
+
6: "#00aaaa",
|
|
633
|
+
7: "#aaaaaa",
|
|
634
|
+
8: "#555555",
|
|
635
|
+
9: "#ff5555",
|
|
636
|
+
10: "#55ff55",
|
|
637
|
+
11: "#ffff55",
|
|
638
|
+
12: "#5555ff",
|
|
639
|
+
13: "#ff55ff",
|
|
640
|
+
14: "#55ffff",
|
|
641
|
+
15: "#ffffff"
|
|
642
|
+
};
|
|
643
|
+
if (code < 16) return basic16[code] ?? "#ffffff";
|
|
644
|
+
if (code >= 232) {
|
|
645
|
+
const gray = 8 + (code - 232) * 10;
|
|
646
|
+
const h = Math.min(255, gray).toString(16).padStart(2, "0");
|
|
647
|
+
return `#${h}${h}${h}`;
|
|
648
|
+
}
|
|
649
|
+
const idx = code - 16;
|
|
650
|
+
const r = Math.floor(idx / 36);
|
|
651
|
+
const g = Math.floor(idx % 36 / 6);
|
|
652
|
+
const b = idx % 6;
|
|
653
|
+
const toHex = (v) => (v === 0 ? 0 : 55 + v * 40).toString(16).padStart(2, "0");
|
|
654
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
655
|
+
}
|
|
656
|
+
function engineColor(id) {
|
|
657
|
+
const prefix = id.split("-")[0];
|
|
658
|
+
return color256toHex(ENGINE_COLORS[id] ?? ENGINE_COLORS[prefix] ?? 124);
|
|
659
|
+
}
|
|
660
|
+
var CODE_RAIL = "\u258C";
|
|
661
|
+
var CODE_RAIL_COLOR = "#585858";
|
|
662
|
+
var MAX_CODE_LINES = 60;
|
|
663
|
+
var SYN_KEYWORD = "#c084fc";
|
|
664
|
+
var SYN_STRING = "#4ade80";
|
|
665
|
+
var SYN_COMMENT = "#6b7280";
|
|
666
|
+
var SYN_NUMBER = "#fb923c";
|
|
667
|
+
var SYN_TYPE = "#38bdf8";
|
|
668
|
+
var SYN_PUNCT = "#94a3b8";
|
|
669
|
+
var SYN_FN = "#fbbf24";
|
|
670
|
+
var KEYWORDS = /* @__PURE__ */ new Set(["const", "let", "var", "function", "return", "if", "else", "for", "while", "do", "switch", "case", "break", "continue", "class", "extends", "implements", "new", "this", "super", "import", "export", "from", "default", "async", "await", "try", "catch", "finally", "throw", "typeof", "instanceof", "in", "of", "yield", "void", "delete", "interface", "type", "enum", "namespace", "abstract", "private", "public", "protected", "static", "readonly", "fn", "struct", "impl", "pub", "mod", "use", "crate", "self", "mut", "ref", "match", "loop", "move", "def", "elif", "pass", "with", "as", "is", "not", "and", "or", "lambda", "nonlocal", "global", "true", "false", "null", "undefined", "nil", "None", "True", "False"]);
|
|
671
|
+
var TYPES = /* @__PURE__ */ new Set(["string", "number", "boolean", "object", "any", "void", "never", "unknown", "bigint", "symbol", "String", "Number", "Boolean", "Object", "Array", "Map", "Set", "Promise", "Record", "Partial", "int", "float", "double", "char", "long", "short", "byte", "i32", "u32", "i64", "u64", "f64", "f32", "usize", "isize", "bool", "str", "Vec", "Option", "Result", "Box", "Rc", "Arc"]);
|
|
672
|
+
function tokenizeLine(line) {
|
|
673
|
+
const tokens = [];
|
|
674
|
+
const pattern = /\/\/.*$|\/\*.*?\*\/|#.*$|""".*?"""|'''.*?'''|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`|\b\d+(?:\.\d+)?\b|[a-zA-Z_$]\w*(?=\s*\()|[a-zA-Z_$]\w*|[{}()\[\];:,.<>=!&|?+\-*/%^~@]|\s+/g;
|
|
675
|
+
let match;
|
|
676
|
+
let lastIndex = 0;
|
|
677
|
+
while ((match = pattern.exec(line)) !== null) {
|
|
678
|
+
if (match.index > lastIndex) {
|
|
679
|
+
tokens.push({ text: line.slice(lastIndex, match.index) });
|
|
680
|
+
}
|
|
681
|
+
lastIndex = match.index + match[0].length;
|
|
682
|
+
const text = match[0];
|
|
683
|
+
if (text.startsWith("//") || text.startsWith("#") || text.startsWith("/*")) {
|
|
684
|
+
tokens.push({ text, color: SYN_COMMENT });
|
|
685
|
+
} else if (/^["'`]/.test(text) || text.startsWith('"""') || text.startsWith("'''")) {
|
|
686
|
+
tokens.push({ text, color: SYN_STRING });
|
|
687
|
+
} else if (/^\d/.test(text)) {
|
|
688
|
+
tokens.push({ text, color: SYN_NUMBER });
|
|
689
|
+
} else if (/^[a-zA-Z_$]\w*$/.test(text) && line[match.index + text.length] === "(") {
|
|
690
|
+
if (KEYWORDS.has(text)) {
|
|
691
|
+
tokens.push({ text, color: SYN_KEYWORD });
|
|
692
|
+
} else {
|
|
693
|
+
tokens.push({ text, color: SYN_FN });
|
|
694
|
+
}
|
|
695
|
+
} else if (KEYWORDS.has(text)) {
|
|
696
|
+
tokens.push({ text, color: SYN_KEYWORD });
|
|
697
|
+
} else if (TYPES.has(text)) {
|
|
698
|
+
tokens.push({ text, color: SYN_TYPE });
|
|
699
|
+
} else if (/^[{}()\[\];:,.<>=!&|?+\-*/%^~@]$/.test(text)) {
|
|
700
|
+
tokens.push({ text, color: SYN_PUNCT });
|
|
701
|
+
} else {
|
|
702
|
+
tokens.push({ text });
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (lastIndex < line.length) {
|
|
706
|
+
tokens.push({ text: line.slice(lastIndex) });
|
|
707
|
+
}
|
|
708
|
+
return tokens;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// src/generated/blocks/arena.tsx
|
|
712
|
+
import "react";
|
|
713
|
+
import { Box as Box2, Text as Text2 } from "ink";
|
|
714
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
715
|
+
function ForgeArena({ engines }) {
|
|
716
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingLeft: 2, children: [
|
|
717
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
718
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#f97316", bold: true, children: "Forge" }),
|
|
719
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: forgeSummary(engines) })
|
|
720
|
+
] }),
|
|
721
|
+
renderForgeRows(engines)
|
|
722
|
+
] });
|
|
723
|
+
}
|
|
724
|
+
function BrainstormStorm({ engines }) {
|
|
725
|
+
const elapsed = engines[0]?.elapsed ?? 0;
|
|
726
|
+
const frame = elapsed % STORM_BOLTS.length;
|
|
727
|
+
const bolt = STORM_BOLTS[frame];
|
|
728
|
+
const doneCount = engines.filter((e) => e.done).length;
|
|
729
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingLeft: 2, children: [
|
|
730
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#22d3ee", dimColor: true, children: bolt }),
|
|
731
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#64748b", children: STORM_CLOUDS[0] }),
|
|
732
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#64748b", children: STORM_CLOUDS[1] }),
|
|
733
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#22d3ee", bold: true, children: " \u26A1 B R A I N S T O R M \u26A1" }),
|
|
734
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#22d3ee", children: "\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E" }),
|
|
735
|
+
engines.map((e, i) => {
|
|
736
|
+
const spark = e.done ? "\u2713" : (elapsed + i) % 3 === 0 ? "\u26A1" : "\xB7";
|
|
737
|
+
return /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
738
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#22d3ee", children: "\u2502 " }),
|
|
739
|
+
/* @__PURE__ */ jsx2(Text2, { color: e.done ? "green" : e.failed ? "red" : (elapsed + i) % 3 === 0 ? "#22d3ee" : "yellow", children: spark }),
|
|
740
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
741
|
+
/* @__PURE__ */ jsx2(Box2, { width: 12, children: /* @__PURE__ */ jsx2(Text2, { bold: true, color: engineColor(e.id), children: e.id }) }),
|
|
742
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: e.status }),
|
|
743
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#22d3ee", children: " \u2502" })
|
|
744
|
+
] }, e.id);
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#22d3ee", children: "\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F" }),
|
|
747
|
+
doneCount > 0 && /* @__PURE__ */ jsxs2(Text2, { color: "#22d3ee", italic: true, children: [
|
|
748
|
+
" ",
|
|
749
|
+
String(doneCount),
|
|
750
|
+
" of ",
|
|
751
|
+
String(engines.length),
|
|
752
|
+
" ideas sparked"
|
|
753
|
+
] })
|
|
754
|
+
] });
|
|
755
|
+
}
|
|
756
|
+
function CampfireFire({ engines }) {
|
|
757
|
+
const elapsed = engines[0]?.elapsed ?? 0;
|
|
758
|
+
const frame = elapsed % FIRE_FRAMES.length;
|
|
759
|
+
const flames = FIRE_FRAMES[frame];
|
|
760
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingLeft: 2, children: [
|
|
761
|
+
flames.map((line, i) => /* @__PURE__ */ jsx2(Text2, { color: i < 3 ? "#f97316" : "#7c2d12", children: line }, i)),
|
|
762
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#78350f", children: " \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550" }),
|
|
763
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#f97316", bold: true, children: " \u2500\u2500 C A M P F I R E \u2500\u2500" }),
|
|
764
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
765
|
+
/* @__PURE__ */ jsxs2(Box2, { children: [
|
|
766
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
767
|
+
engines.map((e, i) => /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
768
|
+
/* @__PURE__ */ jsx2(Text2, { color: engineColor(e.id), bold: true, children: e.id }),
|
|
769
|
+
i < engines.length - 1 && /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: " \xB7 " })
|
|
770
|
+
] }, e.id))
|
|
771
|
+
] }),
|
|
772
|
+
/* @__PURE__ */ jsxs2(Box2, { children: [
|
|
773
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
774
|
+
engines.map((e, i) => {
|
|
775
|
+
const bubble = e.done ? "\u2713" : (elapsed + i) % 4 < 2 ? "\u2620" : "\xB7";
|
|
776
|
+
const padLen = Math.max(0, e.id.length - 1);
|
|
777
|
+
const pad = " ".repeat(Math.floor(padLen / 2));
|
|
778
|
+
return /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
779
|
+
/* @__PURE__ */ jsxs2(Text2, { color: e.done ? "green" : "#f97316", children: [
|
|
780
|
+
pad,
|
|
781
|
+
bubble,
|
|
782
|
+
pad,
|
|
783
|
+
" "
|
|
784
|
+
] }),
|
|
785
|
+
i < engines.length - 1 && /* @__PURE__ */ jsx2(Text2, { children: " " })
|
|
786
|
+
] }, e.id);
|
|
787
|
+
})
|
|
788
|
+
] }),
|
|
789
|
+
/* @__PURE__ */ jsxs2(Box2, { children: [
|
|
790
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
791
|
+
engines.map((e, i) => {
|
|
792
|
+
const padLen = Math.max(0, e.id.length - String(e.elapsed).length - 1);
|
|
793
|
+
const pad = " ".repeat(Math.floor(padLen / 2));
|
|
794
|
+
return /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
795
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
796
|
+
pad,
|
|
797
|
+
String(e.elapsed),
|
|
798
|
+
"s",
|
|
799
|
+
pad
|
|
800
|
+
] }),
|
|
801
|
+
i < engines.length - 1 && /* @__PURE__ */ jsx2(Text2, { children: " " })
|
|
802
|
+
] }, e.id);
|
|
803
|
+
})
|
|
804
|
+
] })
|
|
805
|
+
] });
|
|
806
|
+
}
|
|
807
|
+
function TribunalCourt({ engines }) {
|
|
808
|
+
const elapsed = engines[0]?.elapsed ?? 0;
|
|
809
|
+
const frame = elapsed % SCALES_FRAMES.length;
|
|
810
|
+
const title = SCALES_FRAMES[frame];
|
|
811
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingLeft: 2, children: [
|
|
812
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#c084fc", bold: true, children: title }),
|
|
813
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#c084fc", children: "\u2551" }),
|
|
814
|
+
engines.map((e) => {
|
|
815
|
+
const statusParts = e.status.split(" ");
|
|
816
|
+
const round = statusParts[0] ?? "";
|
|
817
|
+
const position = statusParts.slice(1).join(" ");
|
|
818
|
+
const posColor = position.includes("pro") || position.includes("defender") ? "#22c55e" : position.includes("con") || position.includes("challenger") ? "#ef4444" : "#c084fc";
|
|
819
|
+
return /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
820
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#c084fc", children: "\u2551 " }),
|
|
821
|
+
/* @__PURE__ */ jsx2(Text2, { color: e.done ? "green" : e.status === "waiting" ? "#64748b" : "yellow", children: e.done ? "\u2713" : e.status === "waiting" ? "\u25CB" : "\u25CF" }),
|
|
822
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
823
|
+
/* @__PURE__ */ jsx2(Box2, { width: 14, children: /* @__PURE__ */ jsx2(Text2, { bold: true, color: engineColor(e.id), children: e.id }) }),
|
|
824
|
+
e.status === "waiting" ? /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "awaiting turn" }) : e.done ? /* @__PURE__ */ jsx2(Text2, { color: "green", children: e.status }) : /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
825
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
826
|
+
round,
|
|
827
|
+
" "
|
|
828
|
+
] }),
|
|
829
|
+
/* @__PURE__ */ jsx2(Text2, { color: posColor, bold: true, children: position })
|
|
830
|
+
] }),
|
|
831
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#c084fc", children: " \u2551" })
|
|
832
|
+
] }, e.id);
|
|
833
|
+
}),
|
|
834
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#c084fc", children: "\u2551" }),
|
|
835
|
+
/* @__PURE__ */ jsx2(Text2, { color: "#c084fc", bold: true, children: title })
|
|
836
|
+
] });
|
|
837
|
+
}
|
|
838
|
+
function forgeBar(pct, width) {
|
|
839
|
+
const filled = Math.round(pct * width);
|
|
840
|
+
const half = pct > 0 && filled < width ? 1 : 0;
|
|
841
|
+
const halfChar = half ? "\u2592" : "";
|
|
842
|
+
return "\u2588".repeat(filled) + halfChar + "\u2591".repeat(Math.max(0, width - filled - half));
|
|
843
|
+
}
|
|
844
|
+
function forgeSummary(engines) {
|
|
845
|
+
const doneCount = engines.filter((e) => e.done).length;
|
|
846
|
+
const failedCount = engines.filter((e) => e.failed).length;
|
|
847
|
+
const failedSuffix = failedCount ? " \xB7 " + failedCount + " failed" : "";
|
|
848
|
+
return " " + doneCount + "/" + engines.length + " done" + failedSuffix;
|
|
849
|
+
}
|
|
850
|
+
function renderForgeRows(engines) {
|
|
851
|
+
const maxElapsed = 120;
|
|
852
|
+
const leader = engines.reduce((acc, e) => {
|
|
853
|
+
const status = String(e.status ?? "");
|
|
854
|
+
const active = !e.done && !e.failed && !status.startsWith("queued") && !status.startsWith("preparing") && !status.startsWith("waiting");
|
|
855
|
+
const pct = e.done ? 1 : active ? Math.min(e.elapsed / maxElapsed, 0.9) : 0;
|
|
856
|
+
return pct > acc.bestPct || e.done ? { leaderId: e.id, bestPct: pct } : acc;
|
|
857
|
+
}, { leaderId: "", bestPct: -1 });
|
|
858
|
+
return engines.map((e) => {
|
|
859
|
+
const status = String(e.status ?? "");
|
|
860
|
+
const isWaiting = status.startsWith("queued") || status.startsWith("preparing") || status.startsWith("waiting");
|
|
861
|
+
const isActive = !e.done && !e.failed && !isWaiting;
|
|
862
|
+
const pct = e.done ? 1 : e.failed ? 0 : isActive ? Math.min(e.elapsed / maxElapsed, 0.9) : 0;
|
|
863
|
+
const bar = forgeBar(pct, 12);
|
|
864
|
+
const isLead = e.id === leader.leaderId && !e.failed;
|
|
865
|
+
const statusTxt = e.done ? e.score ? `score ${e.score}` : "done" : e.failed ? "failed" : isWaiting ? status : `${status} ${Math.round(pct * 100)}%`;
|
|
866
|
+
return /* @__PURE__ */ jsxs2(Box2, { children: [
|
|
867
|
+
/* @__PURE__ */ jsx2(Text2, { color: e.done ? "green" : e.failed ? "red" : "yellow", children: e.done ? "\u2713" : e.failed ? "\u2717" : isWaiting ? "\u25E6" : isLead ? "\u25B8" : "\xB7" }),
|
|
868
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
869
|
+
/* @__PURE__ */ jsxs2(Box2, { width: 16, children: [
|
|
870
|
+
e.isAgent ? /* @__PURE__ */ jsx2(Text2, { color: "#fbbf24", children: "\u26A1 " }) : null,
|
|
871
|
+
/* @__PURE__ */ jsx2(Text2, { bold: true, color: engineColor(e.id), children: e.id })
|
|
872
|
+
] }),
|
|
873
|
+
/* @__PURE__ */ jsx2(Text2, { color: e.done ? "#22c55e" : e.failed ? "#ef4444" : "#f97316", children: bar }),
|
|
874
|
+
/* @__PURE__ */ jsx2(Text2, { children: " " }),
|
|
875
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: statusTxt })
|
|
876
|
+
] }, e.id);
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
var STORM_BOLTS = ["\u26A1 \u26A1 \u26A1", " \u26A1 \u26A1 ", "\u26A1 \u26A1 \u26A1", " \u26A1 \u26A1 "];
|
|
880
|
+
var STORM_CLOUDS = [" \u2571\u2572\u2571\u2572\u2571\u2572\u2571\u2572\u2571\u2572\u2571\u2572", " \u2572\u2571\u2572\u2571\u2572\u2571\u2572\u2571\u2572\u2571\u2572\u2571\u2572"];
|
|
881
|
+
var FIRE_FRAMES = [[" ( ) ( ) ", " ( )( ) ", " ) ( ) ( ", " \u2571\u2591\u2592\u2593\u2588\u2588\u2593\u2592\u2591\u2572 "], [" ( )( )( ) ", " ( )( ) ", " ( )( )( ) ", " \u2571\u2591\u2592\u2593\u2588\u2588\u2593\u2592\u2591\u2572 "], [" ( )( ) ", " ( )( )( ", " ( . )( ) ", " \u2571\u2591\u2592\u2593\u2588\u2588\u2593\u2592\u2591\u2572 "]];
|
|
882
|
+
var SCALES_FRAMES = [" \u2696\u2550\u2550\u2550\u2550 T R I B U N A L \u2550\u2550\u2550\u2550\u2696", " \u2696\u2550\u2550\u2726\u2550 T R I B U N A L \u2550\u2726\u2550\u2550\u2696", " \u2696\u2550\u2550\u2550\u2550 T R I B U N A L \u2550\u2550\u2550\u2550\u2696"];
|
|
883
|
+
|
|
884
|
+
// src/generated/blocks/plan-view.tsx
|
|
885
|
+
import React3 from "react";
|
|
886
|
+
import { Box as Box3, Text as Text3 } from "ink";
|
|
887
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
888
|
+
var PlanProposalView = React3.memo(function PlanProposalView2({ plan, markdown, costEstimate, committed, selectedIndex }) {
|
|
889
|
+
const steps = plan.steps ?? [];
|
|
890
|
+
const est = costEstimate;
|
|
891
|
+
const totalTokens = est?.totalTokens ?? plan.totalEstimatedTokens ?? steps.reduce((sum, s) => sum + (s.estimatedTokens ?? 0), 0);
|
|
892
|
+
const totalCost = est?.totalCostUsd ?? plan.totalEstimatedCostUsd ?? steps.reduce((sum, s) => sum + (s.estimatedCostUsd ?? 0), 0);
|
|
893
|
+
const allEngines = [...new Set(steps.flatMap((s) => s.engines ?? (s.engine ? [s.engine] : [])))];
|
|
894
|
+
const w = contentWidth(6);
|
|
895
|
+
const thinBar = "\u2500".repeat(Math.min(w, 64));
|
|
896
|
+
const planFilePath = plan.planFilePath || plan.planFilePath;
|
|
897
|
+
const stepCost = (s) => {
|
|
898
|
+
const stepEst = est?.steps?.find((e) => e.id === s.id);
|
|
899
|
+
return stepEst?.costUsd ?? s.estimatedCostUsd ?? 0;
|
|
900
|
+
};
|
|
901
|
+
const stepTokens = (s) => {
|
|
902
|
+
const stepEst = est?.steps?.find((e) => e.id === s.id);
|
|
903
|
+
return stepEst?.tokens ?? s.estimatedTokens ?? 0;
|
|
904
|
+
};
|
|
905
|
+
if (markdown && markdown.trim()) {
|
|
906
|
+
const wrapWidth = contentWidth(6);
|
|
907
|
+
const segments = parseMarkdownBlocks(markdown);
|
|
908
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", paddingLeft: 2, marginY: 1, children: [
|
|
909
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, color: "white", children: "Plan" }),
|
|
910
|
+
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
911
|
+
steps.length,
|
|
912
|
+
" steps \xB7 ~",
|
|
913
|
+
totalTokens.toLocaleString(),
|
|
914
|
+
" tokens \xB7 $",
|
|
915
|
+
totalCost.toFixed(2),
|
|
916
|
+
" est"
|
|
917
|
+
] }),
|
|
918
|
+
planFilePath && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
919
|
+
"File: ",
|
|
920
|
+
planFilePath
|
|
921
|
+
] }),
|
|
922
|
+
allEngines.length > 0 && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
923
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "Engines: " }),
|
|
924
|
+
allEngines.map((id, i) => /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
925
|
+
/* @__PURE__ */ jsx3(Text3, { color: engineColor(id), children: id }),
|
|
926
|
+
i < allEngines.length - 1 && /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: ", " })
|
|
927
|
+
] }, id))
|
|
928
|
+
] }),
|
|
929
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: thinBar }),
|
|
930
|
+
/* @__PURE__ */ jsx3(RenderedSegments, { segments, borderColor: "", wrapWidth }),
|
|
931
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: thinBar }),
|
|
932
|
+
committed ? /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "Plan moved to history." }) : /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
|
|
933
|
+
/* @__PURE__ */ jsx3(Text3, { color: "#fbbf24", bold: true, children: "Awaiting approval" }),
|
|
934
|
+
/* @__PURE__ */ jsxs3(Text3, { color: (selectedIndex ?? 0) === 0 ? "#4ade80" : "#6b7280", bold: (selectedIndex ?? 0) === 0, children: [
|
|
935
|
+
(selectedIndex ?? 0) === 0 ? "\u276F " : " ",
|
|
936
|
+
"1. Approve & run"
|
|
937
|
+
] }),
|
|
938
|
+
/* @__PURE__ */ jsxs3(Text3, { color: (selectedIndex ?? 0) === 1 ? "#ef4444" : "#6b7280", bold: (selectedIndex ?? 0) === 1, children: [
|
|
939
|
+
(selectedIndex ?? 0) === 1 ? "\u276F " : " ",
|
|
940
|
+
"2. Reject"
|
|
941
|
+
] }),
|
|
942
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " \u2191\u2193 move \xB7 Enter select \xB7 \u270E type to change \xB7 /approve \xB7 /cancel" })
|
|
943
|
+
] })
|
|
944
|
+
] });
|
|
945
|
+
}
|
|
946
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", paddingLeft: 2, marginY: 1, children: [
|
|
947
|
+
/* @__PURE__ */ jsxs3(Text3, { bold: true, color: "white", children: [
|
|
948
|
+
"Plan: ",
|
|
949
|
+
plan.intent
|
|
950
|
+
] }),
|
|
951
|
+
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
952
|
+
steps.length,
|
|
953
|
+
" steps \xB7 ~",
|
|
954
|
+
totalTokens.toLocaleString(),
|
|
955
|
+
" tokens \xB7 $",
|
|
956
|
+
totalCost.toFixed(2),
|
|
957
|
+
" est"
|
|
958
|
+
] }),
|
|
959
|
+
planFilePath && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
960
|
+
"File: ",
|
|
961
|
+
planFilePath
|
|
962
|
+
] }),
|
|
963
|
+
allEngines.length > 0 && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
964
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "Engines: " }),
|
|
965
|
+
allEngines.map((id, i) => /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
966
|
+
/* @__PURE__ */ jsx3(Text3, { color: engineColor(id), children: id }),
|
|
967
|
+
i < allEngines.length - 1 && /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: ", " })
|
|
968
|
+
] }, id))
|
|
969
|
+
] }),
|
|
970
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: thinBar }),
|
|
971
|
+
steps.map((s, i) => {
|
|
972
|
+
const cfg = STEP_TYPE_CONFIG[s.type] ?? { icon: "?", color: "#888", label: s.type };
|
|
973
|
+
const stepEngines = s.engines?.length ? s.engines : s.engine ? [s.engine] : [];
|
|
974
|
+
const stateInfo = STEP_STATE_ICONS[s.state ?? "pending"] ?? STEP_STATE_ICONS.pending;
|
|
975
|
+
const hasDepends = s.dependsOn && s.dependsOn.length > 0;
|
|
976
|
+
const hasFitness = s.fitnessCmd;
|
|
977
|
+
const isParallel = s.parallel;
|
|
978
|
+
const cost = stepCost(s);
|
|
979
|
+
const tokens = stepTokens(s);
|
|
980
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
|
|
981
|
+
/* @__PURE__ */ jsxs3(Box3, { children: [
|
|
982
|
+
/* @__PURE__ */ jsxs3(Text3, { color: stateInfo.color, children: [
|
|
983
|
+
stateInfo.icon,
|
|
984
|
+
" "
|
|
985
|
+
] }),
|
|
986
|
+
/* @__PURE__ */ jsxs3(Text3, { bold: true, color: "white", children: [
|
|
987
|
+
String(i + 1),
|
|
988
|
+
"."
|
|
989
|
+
] }),
|
|
990
|
+
/* @__PURE__ */ jsx3(Text3, { children: " " }),
|
|
991
|
+
/* @__PURE__ */ jsxs3(Text3, { color: cfg.color, bold: true, children: [
|
|
992
|
+
cfg.icon,
|
|
993
|
+
" "
|
|
994
|
+
] }),
|
|
995
|
+
/* @__PURE__ */ jsx3(Text3, { children: s.description })
|
|
996
|
+
] }),
|
|
997
|
+
/* @__PURE__ */ jsxs3(Box3, { children: [
|
|
998
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " " }),
|
|
999
|
+
/* @__PURE__ */ jsx3(Text3, { color: cfg.color, children: cfg.label }),
|
|
1000
|
+
stepEngines.length > 0 && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1001
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " \u2192 " }),
|
|
1002
|
+
stepEngines.map((eId, j) => /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1003
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, color: engineColor(eId), children: eId }),
|
|
1004
|
+
j < stepEngines.length - 1 && /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: ", " })
|
|
1005
|
+
] }, eId))
|
|
1006
|
+
] }),
|
|
1007
|
+
tokens > 0 && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
1008
|
+
" \xB7 ~",
|
|
1009
|
+
tokens.toLocaleString(),
|
|
1010
|
+
" t"
|
|
1011
|
+
] }),
|
|
1012
|
+
cost > 0 && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
1013
|
+
" \xB7 $",
|
|
1014
|
+
cost.toFixed(2)
|
|
1015
|
+
] }),
|
|
1016
|
+
isParallel && /* @__PURE__ */ jsx3(Text3, { color: "#34d399", children: " \xB7 parallel" })
|
|
1017
|
+
] }),
|
|
1018
|
+
hasFitness && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1019
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " test: " }),
|
|
1020
|
+
/* @__PURE__ */ jsx3(Text3, { children: s.fitnessCmd })
|
|
1021
|
+
] }),
|
|
1022
|
+
hasDepends && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1023
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " after: " }),
|
|
1024
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: s.dependsOn.join(", ") })
|
|
1025
|
+
] }),
|
|
1026
|
+
s.tribunalMode && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1027
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " mode: " }),
|
|
1028
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: s.tribunalMode })
|
|
1029
|
+
] }),
|
|
1030
|
+
s.rationale && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1031
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " why: " }),
|
|
1032
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: s.rationale })
|
|
1033
|
+
] }),
|
|
1034
|
+
s.verifyCmd && /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1035
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " verify: " }),
|
|
1036
|
+
/* @__PURE__ */ jsx3(Text3, { children: s.verifyCmd })
|
|
1037
|
+
] }),
|
|
1038
|
+
i < steps.length - 1 && /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " " })
|
|
1039
|
+
] }, s.id);
|
|
1040
|
+
}),
|
|
1041
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: thinBar }),
|
|
1042
|
+
committed ? /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "Plan moved to history." }) : /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
|
|
1043
|
+
/* @__PURE__ */ jsx3(Text3, { color: "#fbbf24", bold: true, children: "Awaiting approval" }),
|
|
1044
|
+
/* @__PURE__ */ jsxs3(Text3, { color: (selectedIndex ?? 0) === 0 ? "#4ade80" : "#6b7280", bold: (selectedIndex ?? 0) === 0, children: [
|
|
1045
|
+
(selectedIndex ?? 0) === 0 ? "\u276F " : " ",
|
|
1046
|
+
"1. Approve & run"
|
|
1047
|
+
] }),
|
|
1048
|
+
/* @__PURE__ */ jsxs3(Text3, { color: (selectedIndex ?? 0) === 1 ? "#ef4444" : "#6b7280", bold: (selectedIndex ?? 0) === 1, children: [
|
|
1049
|
+
(selectedIndex ?? 0) === 1 ? "\u276F " : " ",
|
|
1050
|
+
"2. Reject"
|
|
1051
|
+
] }),
|
|
1052
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " \u2191\u2193 move \xB7 Enter select \xB7 \u270E type to change \xB7 /approve \xB7 /cancel" })
|
|
1053
|
+
] })
|
|
1054
|
+
] });
|
|
1055
|
+
});
|
|
1056
|
+
function PlanExecutionView({ plan }) {
|
|
1057
|
+
const steps = plan.steps ?? [];
|
|
1058
|
+
const doneSteps = steps.filter((s) => s.state === "done");
|
|
1059
|
+
const failedSteps = steps.filter((s) => s.state === "failed");
|
|
1060
|
+
const runningSteps = steps.filter((s) => s.state === "running");
|
|
1061
|
+
const pct = steps.length > 0 ? Math.round(doneSteps.length / steps.length * 100) : 0;
|
|
1062
|
+
const planColor = "#94a3b8";
|
|
1063
|
+
const barWidth = 20;
|
|
1064
|
+
const filled = Math.round(doneSteps.length / Math.max(steps.length, 1) * barWidth);
|
|
1065
|
+
const progressBar = "\u2588".repeat(filled) + "\u2591".repeat(barWidth - filled);
|
|
1066
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", paddingLeft: 2, children: [
|
|
1067
|
+
/* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1068
|
+
/* @__PURE__ */ jsx3(Text3, { color: planColor, bold: true, children: "\u25B8 Plan: " }),
|
|
1069
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, children: plan.intent })
|
|
1070
|
+
] }),
|
|
1071
|
+
/* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1072
|
+
/* @__PURE__ */ jsx3(Text3, { color: planColor, children: progressBar }),
|
|
1073
|
+
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
1074
|
+
" ",
|
|
1075
|
+
String(pct),
|
|
1076
|
+
"% \xB7 ",
|
|
1077
|
+
String(doneSteps.length),
|
|
1078
|
+
"/",
|
|
1079
|
+
String(steps.length),
|
|
1080
|
+
" steps"
|
|
1081
|
+
] }),
|
|
1082
|
+
failedSteps.length > 0 && /* @__PURE__ */ jsxs3(Text3, { color: "red", children: [
|
|
1083
|
+
" \xB7 ",
|
|
1084
|
+
String(failedSteps.length),
|
|
1085
|
+
" failed"
|
|
1086
|
+
] }),
|
|
1087
|
+
plan.totalActualCostUsd > 0 && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
1088
|
+
" \xB7 $",
|
|
1089
|
+
plan.totalActualCostUsd.toFixed(4)
|
|
1090
|
+
] })
|
|
1091
|
+
] }),
|
|
1092
|
+
/* @__PURE__ */ jsx3(Text3, { children: " " }),
|
|
1093
|
+
steps.map((s, i) => {
|
|
1094
|
+
const cfg = STEP_TYPE_CONFIG[s.type] ?? { icon: "?", color: "#888", label: s.type };
|
|
1095
|
+
const stateInfo = STEP_STATE_ICONS[s.state ?? "pending"] ?? STEP_STATE_ICONS.pending;
|
|
1096
|
+
const result = s.result;
|
|
1097
|
+
const elapsed = result?.durationMs ? `${(result.durationMs / 1e3).toFixed(1)}s` : "";
|
|
1098
|
+
const cost = result?.actualCostUsd ? `$${result.actualCostUsd.toFixed(4)}` : "";
|
|
1099
|
+
return /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
1100
|
+
/* @__PURE__ */ jsxs3(Text3, { color: stateInfo.color, children: [
|
|
1101
|
+
stateInfo.icon,
|
|
1102
|
+
" "
|
|
1103
|
+
] }),
|
|
1104
|
+
/* @__PURE__ */ jsx3(Box3, { width: 3, children: /* @__PURE__ */ jsxs3(Text3, { bold: true, color: "white", children: [
|
|
1105
|
+
String(i + 1),
|
|
1106
|
+
"."
|
|
1107
|
+
] }) }),
|
|
1108
|
+
/* @__PURE__ */ jsxs3(Text3, { color: cfg.color, children: [
|
|
1109
|
+
cfg.icon,
|
|
1110
|
+
" "
|
|
1111
|
+
] }),
|
|
1112
|
+
/* @__PURE__ */ jsxs3(Text3, { color: s.state === "done" ? "#64748b" : s.state === "running" ? "white" : void 0, children: [
|
|
1113
|
+
s.description.slice(0, 50),
|
|
1114
|
+
s.description.length > 50 ? "\u2026" : ""
|
|
1115
|
+
] }),
|
|
1116
|
+
(elapsed || cost) && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
1117
|
+
" (",
|
|
1118
|
+
elapsed,
|
|
1119
|
+
elapsed && cost ? ", " : "",
|
|
1120
|
+
cost,
|
|
1121
|
+
")"
|
|
1122
|
+
] }),
|
|
1123
|
+
result?.status === "failure" && result?.error && /* @__PURE__ */ jsxs3(Text3, { color: "red", children: [
|
|
1124
|
+
" \u2014 ",
|
|
1125
|
+
result.error.slice(0, 40)
|
|
1126
|
+
] })
|
|
1127
|
+
] }, s.id);
|
|
1128
|
+
}),
|
|
1129
|
+
runningSteps.length > 0 && /* @__PURE__ */ jsxs3(Box3, { marginTop: 1, children: [
|
|
1130
|
+
/* @__PURE__ */ jsx3(Text3, { color: "#fbbf24", children: "\u25CF Running: " }),
|
|
1131
|
+
/* @__PURE__ */ jsx3(Text3, { children: runningSteps.map((s) => s.description).join(", ") })
|
|
1132
|
+
] })
|
|
1133
|
+
] });
|
|
1134
|
+
}
|
|
1135
|
+
var STEP_TYPE_CONFIG = { self: { icon: "\u2699", color: "#94a3b8", label: "Cesar" }, forge: { icon: "\u2694", color: "#cbd5e1", label: "Forge" }, teamforge: { icon: "\u2694\u2694", color: "#cbd5e1", label: "Team Forge" }, brainstorm: { icon: "\u26A1", color: "#94a3b8", label: "Brainstorm" }, campfire: { icon: "\u2500", color: "#94a3b8", label: "Campfire" }, tribunal: { icon: "\u2696", color: "#cbd5e1", label: "Tribunal" }, delegate: { icon: "\u27A4", color: "#94a3b8", label: "Delegate" }, pipeline: { icon: "\u2192", color: "#94a3b8", label: "Pipeline" } };
|
|
1136
|
+
var STEP_STATE_ICONS = { pending: { icon: "\u25CB", color: "#64748b" }, blocked: { icon: "\u25A1", color: "#475569" }, running: { icon: "\u25CF", color: "#fbbf24" }, done: { icon: "\u2713", color: "#22c55e" }, failed: { icon: "\u2717", color: "#ef4444" }, skipped: { icon: "\u2500", color: "#64748b" }, cancelled: { icon: "\u2500", color: "#64748b" } };
|
|
1137
|
+
|
|
1138
|
+
// src/generated/blocks/engine.tsx
|
|
1139
|
+
import { createRequire } from "module";
|
|
1140
|
+
import { readFileSync, existsSync } from "fs";
|
|
1141
|
+
import { dirname, join } from "path";
|
|
1142
|
+
import { fileURLToPath } from "url";
|
|
1143
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1144
|
+
function EngineProgressView({ engines, mode }) {
|
|
1145
|
+
const arenaModes = ["forge", "brainstorm", "campfire", "tribunal"];
|
|
1146
|
+
const detected = mode && arenaModes.includes(mode) ? mode : (() => {
|
|
1147
|
+
const s = engines[0]?.status ?? "";
|
|
1148
|
+
if (s.startsWith("drafting")) return "brainstorm";
|
|
1149
|
+
if (s.startsWith("thinking")) return "campfire";
|
|
1150
|
+
if (["preparing", "queued", "building"].some((k) => s.startsWith(k)) || s.startsWith("done (")) return "forge";
|
|
1151
|
+
if (s.startsWith("R") || s.startsWith("waiting")) return "tribunal";
|
|
1152
|
+
return "default";
|
|
1153
|
+
})();
|
|
1154
|
+
if (detected === "forge") return /* @__PURE__ */ jsx4(ForgeArena, { engines });
|
|
1155
|
+
if (detected === "brainstorm") return /* @__PURE__ */ jsx4(BrainstormStorm, { engines });
|
|
1156
|
+
if (detected === "campfire") return /* @__PURE__ */ jsx4(CampfireFire, { engines });
|
|
1157
|
+
if (detected === "tribunal") return /* @__PURE__ */ jsx4(TribunalCourt, { engines });
|
|
1158
|
+
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", children: engines.map((engine) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1159
|
+
/* @__PURE__ */ jsx4(Text4, { color: engine.done ? "green" : engine.failed ? "red" : "yellow", children: engine.done ? icons().success : engine.failed ? icons().fail : icons().dotOn }),
|
|
1160
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1161
|
+
/* @__PURE__ */ jsx4(Box4, { width: 14, children: /* @__PURE__ */ jsx4(Text4, { bold: true, color: engineColor(engine.id), children: engine.id }) }),
|
|
1162
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: engine.status })
|
|
1163
|
+
] }, engine.id)) });
|
|
1164
|
+
}
|
|
1165
|
+
var EngineBlock = React4.memo(function EngineBlock2({ engineId, color, content, actingNote }) {
|
|
1166
|
+
const wrapWidth = contentWidth(8);
|
|
1167
|
+
const cleaned = cleanEngineOutput(content);
|
|
1168
|
+
const hexColor = color256toHex(color);
|
|
1169
|
+
if (!cleaned.trim()) {
|
|
1170
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginY: 0, paddingLeft: 2, children: [
|
|
1171
|
+
/* @__PURE__ */ jsxs4(Text4, { color: hexColor, children: [
|
|
1172
|
+
"\u250C\u2500\u2500 ",
|
|
1173
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: engineId }),
|
|
1174
|
+
actingNote ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1175
|
+
" (",
|
|
1176
|
+
actingNote,
|
|
1177
|
+
")"
|
|
1178
|
+
] }) : null
|
|
1179
|
+
] }),
|
|
1180
|
+
/* @__PURE__ */ jsxs4(Text4, { color: hexColor, children: [
|
|
1181
|
+
"\u2502 ",
|
|
1182
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "(no response)" })
|
|
1183
|
+
] }),
|
|
1184
|
+
/* @__PURE__ */ jsx4(Text4, { color: hexColor, children: "\u2514\u2500\u2500" })
|
|
1185
|
+
] });
|
|
1186
|
+
}
|
|
1187
|
+
const segments = parseMarkdownBlocks(cleaned);
|
|
1188
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginY: 1, paddingLeft: 2, children: [
|
|
1189
|
+
/* @__PURE__ */ jsxs4(Text4, { color: hexColor, children: [
|
|
1190
|
+
"\u250C\u2500\u2500 ",
|
|
1191
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: hexColor, children: engineId }),
|
|
1192
|
+
actingNote ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1193
|
+
" (",
|
|
1194
|
+
actingNote,
|
|
1195
|
+
")"
|
|
1196
|
+
] }) : null
|
|
1197
|
+
] }),
|
|
1198
|
+
/* @__PURE__ */ jsx4(Text4, { color: hexColor, children: "\u2502" }),
|
|
1199
|
+
/* @__PURE__ */ jsx4(RenderedSegments, { segments, borderColor: hexColor, wrapWidth }),
|
|
1200
|
+
/* @__PURE__ */ jsx4(Text4, { color: hexColor, children: "\u2514\u2500\u2500" })
|
|
1201
|
+
] });
|
|
1202
|
+
});
|
|
1203
|
+
var ConversationalResponse = React4.memo(function ConversationalResponse2({ engineId, content, actingNote }) {
|
|
1204
|
+
const wrapWidth = contentWidth(2);
|
|
1205
|
+
const cleaned = cleanEngineOutput(content);
|
|
1206
|
+
if (!cleaned.trim()) return null;
|
|
1207
|
+
const segments = parseMarkdownBlocks(cleaned);
|
|
1208
|
+
const accentColor = color256toHex(ENGINE_COLORS[engineId] ?? 124);
|
|
1209
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, marginBottom: 0, paddingLeft: 1, children: [
|
|
1210
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1211
|
+
/* @__PURE__ */ jsxs4(Text4, { color: accentColor, bold: true, children: [
|
|
1212
|
+
icons().dotOn + " ",
|
|
1213
|
+
engineId
|
|
1214
|
+
] }),
|
|
1215
|
+
actingNote ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1216
|
+
" (",
|
|
1217
|
+
actingNote,
|
|
1218
|
+
")"
|
|
1219
|
+
] }) : null
|
|
1220
|
+
] }),
|
|
1221
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1222
|
+
/* @__PURE__ */ jsx4(RenderedSegments, { segments, borderColor: "", wrapWidth })
|
|
1223
|
+
] });
|
|
1224
|
+
});
|
|
1225
|
+
var CesarRecapBlock = React4.memo(function CesarRecapBlock2({ event }) {
|
|
1226
|
+
const files = Array.isArray(event.files) ? event.files : [];
|
|
1227
|
+
const commands = Array.isArray(event.commands) ? event.commands : [];
|
|
1228
|
+
const warnings = Array.isArray(event.warnings) ? event.warnings : [];
|
|
1229
|
+
const toolSummary = Array.isArray(event.toolSummary) ? event.toolSummary : [];
|
|
1230
|
+
const checkpoints = Array.isArray(event.checkpoints) ? event.checkpoints : [];
|
|
1231
|
+
const diffFiles = Array.isArray(event.diffPreview?.files) ? event.diffPreview.files : [];
|
|
1232
|
+
const confidence = typeof event.confidence === "number" ? `${Math.round(event.confidence)}% confidence` : "";
|
|
1233
|
+
const seconds = typeof event.durationMs === "number" ? `${(event.durationMs / 1e3).toFixed(1)}s` : "";
|
|
1234
|
+
const failedTools = Number(event.failedTools ?? 0);
|
|
1235
|
+
const statusColor = failedTools > 0 ? "#fbbf24" : "#4ade80";
|
|
1236
|
+
const statusIcon = failedTools > 0 ? icons().warning : icons().success;
|
|
1237
|
+
const change = event.changeSummary ?? { created: 0, edited: 0, read: 0 };
|
|
1238
|
+
const createdCount = Number(change.created ?? 0);
|
|
1239
|
+
const editedCount = Number(change.edited ?? 0);
|
|
1240
|
+
const readCount = Number(change.read ?? 0);
|
|
1241
|
+
const changedTotal = createdCount + editedCount;
|
|
1242
|
+
const changeParts = [];
|
|
1243
|
+
if (createdCount > 0) changeParts.push(`+${createdCount} created`);
|
|
1244
|
+
if (editedCount > 0) changeParts.push(`~${editedCount} edited`);
|
|
1245
|
+
const verification = Array.isArray(event.verification) ? event.verification : [];
|
|
1246
|
+
const changedFiles = files.filter((f) => String(f.status) !== "read");
|
|
1247
|
+
const toolLine = toolSummary.length > 0 ? `${event.toolCount ?? toolSummary.length} tools: ${toolSummary.slice(0, 8).join(", ")}${toolSummary.length > 8 ? ", ..." : ""}` : `${event.toolCount ?? 0} tools`;
|
|
1248
|
+
const commandStatus = (status) => String(status).toLowerCase() === "error" ? icons().fail : icons().success;
|
|
1249
|
+
const fileGlyph = (status) => status === "edited" ? "M" : status === "created" ? "+" : "r";
|
|
1250
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 1, marginTop: 1, children: [
|
|
1251
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", bold: true, children: "\u25C6 Cesar recap" }),
|
|
1252
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1253
|
+
/* @__PURE__ */ jsx4(Text4, { color: statusColor, children: statusIcon }),
|
|
1254
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1255
|
+
" ",
|
|
1256
|
+
event.outcome ?? "Completed"
|
|
1257
|
+
] }),
|
|
1258
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1259
|
+
" \xB7 ",
|
|
1260
|
+
event.mode ?? "self"
|
|
1261
|
+
] }),
|
|
1262
|
+
confidence ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1263
|
+
" \xB7 ",
|
|
1264
|
+
confidence
|
|
1265
|
+
] }) : null,
|
|
1266
|
+
seconds ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1267
|
+
" \xB7 ",
|
|
1268
|
+
seconds
|
|
1269
|
+
] }) : null
|
|
1270
|
+
] }),
|
|
1271
|
+
changedTotal > 0 ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1272
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#4ade80", bold: true, children: " changes: " }),
|
|
1273
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#4ade80", children: changeParts.join(", ") }),
|
|
1274
|
+
readCount > 0 ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1275
|
+
" \xB7 ",
|
|
1276
|
+
readCount,
|
|
1277
|
+
" read"
|
|
1278
|
+
] }) : null
|
|
1279
|
+
] }) : /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1280
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#fbbf24", bold: true, children: " changes: " }),
|
|
1281
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#fbbf24", children: "none (explored only)" }),
|
|
1282
|
+
readCount > 0 ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1283
|
+
" \xB7 ",
|
|
1284
|
+
readCount,
|
|
1285
|
+
" read"
|
|
1286
|
+
] }) : null
|
|
1287
|
+
] }),
|
|
1288
|
+
verification.length > 0 ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1289
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " verified: " }),
|
|
1290
|
+
verification.map((v, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1291
|
+
/* @__PURE__ */ jsx4(Text4, { color: v.ok ? "#4ade80" : "#ef4444", children: v.ok ? icons().success : icons().fail }),
|
|
1292
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1293
|
+
" ",
|
|
1294
|
+
v.label
|
|
1295
|
+
] }),
|
|
1296
|
+
i < verification.length - 1 ? /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \xB7 " }) : null
|
|
1297
|
+
] }, `verify-${i}`))
|
|
1298
|
+
] }) : null,
|
|
1299
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1300
|
+
" ",
|
|
1301
|
+
toolLine,
|
|
1302
|
+
failedTools > 0 ? ` \xB7 ${failedTools} failed` : ""
|
|
1303
|
+
] }),
|
|
1304
|
+
event.confidenceReasoning ? /* @__PURE__ */ jsxs4(Text4, { italic: true, color: "#a8a8a8", children: [
|
|
1305
|
+
" why: ",
|
|
1306
|
+
event.confidenceReasoning
|
|
1307
|
+
] }) : null,
|
|
1308
|
+
commands.slice(0, 5).map((cmd, index) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1309
|
+
/* @__PURE__ */ jsxs4(Text4, { color: String(cmd.status).toLowerCase() === "error" ? "#ef4444" : "#4ade80", children: [
|
|
1310
|
+
" ",
|
|
1311
|
+
commandStatus(cmd.status)
|
|
1312
|
+
] }),
|
|
1313
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1314
|
+
" ",
|
|
1315
|
+
cmd.label
|
|
1316
|
+
] }),
|
|
1317
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1318
|
+
" \xB7 ",
|
|
1319
|
+
cmd.command
|
|
1320
|
+
] })
|
|
1321
|
+
] }, `cmd-${index}`)),
|
|
1322
|
+
changedFiles.length > 0 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1323
|
+
" files: ",
|
|
1324
|
+
changedFiles.slice(0, 5).map((f) => `${fileGlyph(String(f.status))} ${f.relPath ?? f.path}`).join(", "),
|
|
1325
|
+
changedFiles.length > 5 ? `, +${changedFiles.length - 5} more` : ""
|
|
1326
|
+
] }),
|
|
1327
|
+
checkpoints.length > 0 ? /* @__PURE__ */ jsxs4(Text4, { color: "#22d3ee", children: [
|
|
1328
|
+
" checkpoint: ",
|
|
1329
|
+
checkpoints[0].id,
|
|
1330
|
+
checkpoints.length > 1 ? ` (+${checkpoints.length - 1})` : "",
|
|
1331
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: ` \xB7 /undo ${checkpoints[0].id} reverts checkpoint` })
|
|
1332
|
+
] }) : null,
|
|
1333
|
+
diffFiles.slice(0, 4).map((file, index) => /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
|
|
1334
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1335
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#22d3ee", children: [
|
|
1336
|
+
" \u0394 ",
|
|
1337
|
+
file.relPath ?? file.path
|
|
1338
|
+
] }),
|
|
1339
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1340
|
+
" +",
|
|
1341
|
+
Number(file.additions ?? 0),
|
|
1342
|
+
" -",
|
|
1343
|
+
Number(file.deletions ?? 0)
|
|
1344
|
+
] })
|
|
1345
|
+
] }),
|
|
1346
|
+
(Array.isArray(file.lines) ? file.lines : []).slice(0, 6).map((line, lineIndex) => /* @__PURE__ */ jsxs4(Text4, { color: line.startsWith("+") ? "#4ade80" : line.startsWith("-") ? "#ef4444" : "#fbbf24", dimColor: line.startsWith("@@"), children: [
|
|
1347
|
+
" ",
|
|
1348
|
+
line
|
|
1349
|
+
] }, `diff-line-${index}-${lineIndex}`)),
|
|
1350
|
+
Number(file.omitted ?? 0) > 0 ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1351
|
+
" \u2026 ",
|
|
1352
|
+
Number(file.omitted),
|
|
1353
|
+
" more diff lines"
|
|
1354
|
+
] }) : null
|
|
1355
|
+
] }, `diff-${index}`)),
|
|
1356
|
+
warnings.slice(0, 3).map((warning, index) => /* @__PURE__ */ jsxs4(Text4, { color: "#fbbf24", children: [
|
|
1357
|
+
" ",
|
|
1358
|
+
icons().warning,
|
|
1359
|
+
" ",
|
|
1360
|
+
warning
|
|
1361
|
+
] }, `warn-${index}`))
|
|
1362
|
+
] });
|
|
1363
|
+
});
|
|
1364
|
+
function DashboardView({ event }) {
|
|
1365
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [
|
|
1366
|
+
LOGO_LINES.map((line, i) => /* @__PURE__ */ jsx4(GradientLine, { text: line, colors: BRAND }, i)),
|
|
1367
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1368
|
+
/* @__PURE__ */ jsx4(Text4, { italic: true, color: "#d4a041", children: " Any AI can join. They compete. You ship." }),
|
|
1369
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1370
|
+
" v",
|
|
1371
|
+
VERSION,
|
|
1372
|
+
" \xB7 Powered by ",
|
|
1373
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "#fbbf24", children: "KERNlang.dev" }),
|
|
1374
|
+
KERN_VERSION ? ` (KERN ${KERN_VERSION})` : ""
|
|
1375
|
+
] }),
|
|
1376
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1377
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1378
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", children: " Engines: " }),
|
|
1379
|
+
event.enabled.map((id, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1380
|
+
/* @__PURE__ */ jsx4(Text4, { color: engineColor(id), bold: true, children: id }),
|
|
1381
|
+
i < event.enabled.length - 1 && /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " })
|
|
1382
|
+
] }, id)),
|
|
1383
|
+
event.eloTop && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1384
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \xB7 " }),
|
|
1385
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#fbbf24", children: "\u265B " }),
|
|
1386
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: engineColor(event.eloTop.id), children: event.eloTop.id }),
|
|
1387
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1388
|
+
" ",
|
|
1389
|
+
String(event.eloTop.rating),
|
|
1390
|
+
" Glicko"
|
|
1391
|
+
] })
|
|
1392
|
+
] })
|
|
1393
|
+
] }),
|
|
1394
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1395
|
+
/* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
|
|
1396
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1397
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1398
|
+
/* @__PURE__ */ jsx4(Text4, { italic: true, dimColor: true, children: '"explain the auth flow"' }),
|
|
1399
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1400
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#fbbf24", children: "\u2192 chat" })
|
|
1401
|
+
] }),
|
|
1402
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1403
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1404
|
+
/* @__PURE__ */ jsx4(Text4, { italic: true, dimColor: true, children: '"codex how would you do this?"' }),
|
|
1405
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1406
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#22d3ee", children: "\u2192 codex" })
|
|
1407
|
+
] }),
|
|
1408
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1409
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1410
|
+
/* @__PURE__ */ jsx4(Text4, { italic: true, dimColor: true, children: '"fix login bug, test with npm test"' }),
|
|
1411
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1412
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", children: "\u2192 forge" })
|
|
1413
|
+
] }),
|
|
1414
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1415
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1416
|
+
/* @__PURE__ */ jsx4(Text4, { italic: true, dimColor: true, children: '"should we use REST or GraphQL?"' }),
|
|
1417
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1418
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: "\u2192 tribunal" })
|
|
1419
|
+
] })
|
|
1420
|
+
] }),
|
|
1421
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1422
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1423
|
+
" Just talk, type ",
|
|
1424
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", children: "/" }),
|
|
1425
|
+
" for commands, ",
|
|
1426
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", children: "Tab" }),
|
|
1427
|
+
" plan, ",
|
|
1428
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", children: "Ctrl+A" }),
|
|
1429
|
+
" auto."
|
|
1430
|
+
] }),
|
|
1431
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " })
|
|
1432
|
+
] });
|
|
1433
|
+
}
|
|
1434
|
+
function TableView({ headers, rows }) {
|
|
1435
|
+
const widths = headers.map(
|
|
1436
|
+
(h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)) + 2
|
|
1437
|
+
);
|
|
1438
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, marginY: 1, children: [
|
|
1439
|
+
/* @__PURE__ */ jsx4(Box4, { children: headers.map((h, i) => /* @__PURE__ */ jsx4(Box4, { width: widths[i], children: /* @__PURE__ */ jsx4(Text4, { bold: true, children: h }) }, h)) }),
|
|
1440
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "\u2500".repeat(widths.reduce((a, b) => a + b, 0)) }),
|
|
1441
|
+
rows.map((row, ri) => /* @__PURE__ */ jsx4(Box4, { children: row.map((cell, ci) => /* @__PURE__ */ jsx4(Box4, { width: widths[ci], children: /* @__PURE__ */ jsx4(Text4, { children: cell }) }, `${headers[ci]}-${ci}`)) }, `row-${ri}-${row[0] ?? ""}`))
|
|
1442
|
+
] });
|
|
1443
|
+
}
|
|
1444
|
+
var OutputBlockView = React4.memo(function OutputBlockView2({ event, mode, toolOutputExpanded, thinkingExpanded }) {
|
|
1445
|
+
switch (event.type) {
|
|
1446
|
+
case "text": {
|
|
1447
|
+
const wrapWidth = contentWidth(4);
|
|
1448
|
+
const richLines = parseProseToRichLines(event.content, wrapWidth);
|
|
1449
|
+
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", paddingLeft: 2, children: richLines.map((line, i) => /* @__PURE__ */ jsx4(RichLineView, { line }, `text-${i}`)) });
|
|
1450
|
+
}
|
|
1451
|
+
case "user-message":
|
|
1452
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 1, marginTop: 1, marginBottom: 0, flexDirection: "row", children: [
|
|
1453
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f97316", bold: true, children: "\u276F " }),
|
|
1454
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: event.content })
|
|
1455
|
+
] });
|
|
1456
|
+
case "engine-block":
|
|
1457
|
+
return mode === "chat" ? /* @__PURE__ */ jsx4(ConversationalResponse, { engineId: event.engineId, content: event.content, actingNote: event.actingNote }) : /* @__PURE__ */ jsx4(EngineBlock, { engineId: event.engineId, color: event.color, content: event.content, actingNote: event.actingNote });
|
|
1458
|
+
case "separator":
|
|
1459
|
+
return /* @__PURE__ */ jsx4(Text4, { children: " " });
|
|
1460
|
+
case "header":
|
|
1461
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
|
|
1462
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1463
|
+
/* @__PURE__ */ jsxs4(Text4, { bold: true, color: "cyan", children: [
|
|
1464
|
+
" " + icons().header + " ",
|
|
1465
|
+
event.title
|
|
1466
|
+
] })
|
|
1467
|
+
] });
|
|
1468
|
+
case "success":
|
|
1469
|
+
return /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1470
|
+
" ",
|
|
1471
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#4ade80", children: icons().success }),
|
|
1472
|
+
" ",
|
|
1473
|
+
event.message
|
|
1474
|
+
] });
|
|
1475
|
+
case "error": {
|
|
1476
|
+
const errLines = event.message.split("\n");
|
|
1477
|
+
const firstLine = errLines[0] ?? "";
|
|
1478
|
+
const errMatch = firstLine.match(/^(\w+Error):\s*(.*)/);
|
|
1479
|
+
const fileMatch = event.message.match(/at\s+.*?([^\s/]+\.\w+:\d+(?::\d+)?)/);
|
|
1480
|
+
if (errMatch || errLines.length > 1) {
|
|
1481
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, children: [
|
|
1482
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1483
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#ef4444", bold: true, children: [
|
|
1484
|
+
icons().fail + " ",
|
|
1485
|
+
errMatch ? errMatch[1] : "Error"
|
|
1486
|
+
] }),
|
|
1487
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#ef4444", children: errMatch ? ": " + errMatch[2] : ": " + firstLine })
|
|
1488
|
+
] }),
|
|
1489
|
+
fileMatch && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1490
|
+
" at ",
|
|
1491
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: fileMatch[1] })
|
|
1492
|
+
] }),
|
|
1493
|
+
errLines.length > 1 && errLines.slice(1, 5).map((line, i) => /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1494
|
+
" ",
|
|
1495
|
+
line.trim()
|
|
1496
|
+
] }, `err-${i}`)),
|
|
1497
|
+
errLines.length > 5 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1498
|
+
" \u2026 ",
|
|
1499
|
+
errLines.length - 5,
|
|
1500
|
+
" more lines"
|
|
1501
|
+
] })
|
|
1502
|
+
] });
|
|
1503
|
+
}
|
|
1504
|
+
return /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1505
|
+
" ",
|
|
1506
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#ef4444", children: icons().fail }),
|
|
1507
|
+
" ",
|
|
1508
|
+
event.message
|
|
1509
|
+
] });
|
|
1510
|
+
}
|
|
1511
|
+
case "warning":
|
|
1512
|
+
return /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1513
|
+
" ",
|
|
1514
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#fbbf24", children: icons().warning }),
|
|
1515
|
+
" ",
|
|
1516
|
+
event.message
|
|
1517
|
+
] });
|
|
1518
|
+
case "info": {
|
|
1519
|
+
const message = String(event.message ?? "");
|
|
1520
|
+
const cesarTelemetry = isCesarTelemetryLine(message);
|
|
1521
|
+
return cesarTelemetry ? /* @__PURE__ */ jsxs4(Text4, { italic: true, color: "#a8a8a8", children: [
|
|
1522
|
+
" ",
|
|
1523
|
+
message
|
|
1524
|
+
] }) : /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1525
|
+
" ",
|
|
1526
|
+
message
|
|
1527
|
+
] });
|
|
1528
|
+
}
|
|
1529
|
+
case "permission-ask": {
|
|
1530
|
+
const permCmd = event.command;
|
|
1531
|
+
const permDesc = event.description;
|
|
1532
|
+
const permReason = event.reason;
|
|
1533
|
+
const permTool = event.tool;
|
|
1534
|
+
const cmdLines = permCmd.split("\n").slice(0, 6);
|
|
1535
|
+
const moreLines = permCmd.split("\n").length > 6;
|
|
1536
|
+
const { rawInput, parsed } = parseToolInputPayload(permCmd);
|
|
1537
|
+
const permToolKey = String(permTool ?? "").toLowerCase();
|
|
1538
|
+
const previewRows = [];
|
|
1539
|
+
const addDiffPreview = (key, lines, sign, color) => {
|
|
1540
|
+
lines.slice(0, 3).forEach((line, i) => {
|
|
1541
|
+
previewRows.push(/* @__PURE__ */ jsxs4(Text4, { color, children: [
|
|
1542
|
+
" ",
|
|
1543
|
+
sign,
|
|
1544
|
+
truncateCodeLine(line, contentWidth(12))
|
|
1545
|
+
] }, `${key}-${i}`));
|
|
1546
|
+
});
|
|
1547
|
+
if (lines.length > 3) previewRows.push(/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1548
|
+
" \u2026 ",
|
|
1549
|
+
lines.length - 3,
|
|
1550
|
+
" more lines"
|
|
1551
|
+
] }, `${key}-more`));
|
|
1552
|
+
};
|
|
1553
|
+
if (permToolKey === "edit" || permToolKey === "update" || permToolKey === "agonedit") {
|
|
1554
|
+
const filePath = String(parsed.file_path || parsed.filePath || "");
|
|
1555
|
+
const oldLines = String(parsed.old_string || parsed.oldString || "").split("\n").filter((line, index, all) => line.length > 0 || all.length === 1);
|
|
1556
|
+
const newLines = String(parsed.new_string || parsed.newString || "").split("\n").filter((line, index, all) => line.length > 0 || all.length === 1);
|
|
1557
|
+
previewRows.push(/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1558
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#22d3ee", children: " Preview update" }),
|
|
1559
|
+
filePath ? /* @__PURE__ */ jsxs4(Text4, { color: "#a78bfa", children: [
|
|
1560
|
+
" ",
|
|
1561
|
+
shortToolPath(filePath)
|
|
1562
|
+
] }) : null,
|
|
1563
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1564
|
+
" -",
|
|
1565
|
+
oldLines.length,
|
|
1566
|
+
" +",
|
|
1567
|
+
newLines.length
|
|
1568
|
+
] })
|
|
1569
|
+
] }, "preview-head"));
|
|
1570
|
+
addDiffPreview("preview-old", oldLines, "-", "#ef4444");
|
|
1571
|
+
addDiffPreview("preview-new", newLines, "+", "#4ade80");
|
|
1572
|
+
} else if (permToolKey === "write" || permToolKey === "agonwrite") {
|
|
1573
|
+
const filePath = String(parsed.file_path || parsed.filePath || "");
|
|
1574
|
+
const contentLines = String(parsed.content || "").split("\n").filter((line, index, all) => line.length > 0 || all.length === 1);
|
|
1575
|
+
previewRows.push(/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1576
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#22d3ee", children: " Preview write" }),
|
|
1577
|
+
filePath ? /* @__PURE__ */ jsxs4(Text4, { color: "#a78bfa", children: [
|
|
1578
|
+
" ",
|
|
1579
|
+
shortToolPath(filePath)
|
|
1580
|
+
] }) : null,
|
|
1581
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1582
|
+
" +",
|
|
1583
|
+
contentLines.length
|
|
1584
|
+
] })
|
|
1585
|
+
] }, "preview-head"));
|
|
1586
|
+
addDiffPreview("preview-write", contentLines, "+", "#4ade80");
|
|
1587
|
+
} else if (permToolKey === "applypatch" || permToolKey === "apply_patch") {
|
|
1588
|
+
const patch = parsePatchPreview(rawInput, parsed);
|
|
1589
|
+
if (patch.lines.length > 0 || patch.files.length > 0) {
|
|
1590
|
+
previewRows.push(/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1591
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#22d3ee", children: " Preview patch" }),
|
|
1592
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1593
|
+
" -",
|
|
1594
|
+
patch.deletions,
|
|
1595
|
+
" +",
|
|
1596
|
+
patch.additions
|
|
1597
|
+
] }),
|
|
1598
|
+
patch.files.length > 0 ? /* @__PURE__ */ jsxs4(Text4, { color: "#a78bfa", children: [
|
|
1599
|
+
" ",
|
|
1600
|
+
patch.files.slice(0, 2).map((filePath) => shortToolPath(filePath)).join(", ")
|
|
1601
|
+
] }) : null
|
|
1602
|
+
] }, "preview-head"));
|
|
1603
|
+
patch.lines.slice(0, 6).forEach((line, i) => {
|
|
1604
|
+
previewRows.push(/* @__PURE__ */ jsxs4(Text4, { color: line.startsWith("+") ? "#4ade80" : line.startsWith("-") ? "#ef4444" : "#fbbf24", dimColor: line.startsWith("@@"), children: [
|
|
1605
|
+
" ",
|
|
1606
|
+
truncateCodeLine(line, contentWidth(12))
|
|
1607
|
+
] }, `preview-patch-${i}`));
|
|
1608
|
+
});
|
|
1609
|
+
if (patch.lines.length > 6) previewRows.push(/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1610
|
+
" \u2026 ",
|
|
1611
|
+
patch.lines.length - 6,
|
|
1612
|
+
" more lines"
|
|
1613
|
+
] }, "preview-patch-more"));
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", paddingLeft: 1, marginY: 1, children: /* @__PURE__ */ jsxs4(Box4, { borderStyle: "bold", borderColor: "#fbbf24", paddingX: 1, flexDirection: "column", children: [
|
|
1617
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#fbbf24", bold: true, children: [
|
|
1618
|
+
permTool === "Bash" || permTool === "bash" ? `${icons().bash} Bash` : `${icons().warning} ${permTool}`,
|
|
1619
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#ef4444", children: " \u2014 APPROVAL REQUIRED" })
|
|
1620
|
+
] }),
|
|
1621
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1622
|
+
cmdLines.map((line, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1623
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1624
|
+
" ",
|
|
1625
|
+
i === 0 ? "$ " : " "
|
|
1626
|
+
] }),
|
|
1627
|
+
/* @__PURE__ */ jsx4(Text4, { children: line })
|
|
1628
|
+
] }, `perm-cmd-${i}`)),
|
|
1629
|
+
moreLines && /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \u2026" }),
|
|
1630
|
+
previewRows.length > 0 && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1631
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1632
|
+
previewRows
|
|
1633
|
+
] }),
|
|
1634
|
+
permDesc && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1635
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1636
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1637
|
+
" ",
|
|
1638
|
+
permDesc
|
|
1639
|
+
] })
|
|
1640
|
+
] }),
|
|
1641
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1642
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#fbbf24", children: permReason }),
|
|
1643
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1644
|
+
" Press ",
|
|
1645
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "#4ade80", children: "Y" }),
|
|
1646
|
+
" to approve, ",
|
|
1647
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "#ef4444", children: "N" }),
|
|
1648
|
+
" to deny, ",
|
|
1649
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "#60a5fa", children: "A" }),
|
|
1650
|
+
" to always allow"
|
|
1651
|
+
] })
|
|
1652
|
+
] }) });
|
|
1653
|
+
}
|
|
1654
|
+
case "table":
|
|
1655
|
+
return /* @__PURE__ */ jsx4(TableView, { headers: event.headers, rows: event.rows });
|
|
1656
|
+
case "thinking-chunk": {
|
|
1657
|
+
if (thinkingExpanded === false) return null;
|
|
1658
|
+
const thinkText = event.chunk;
|
|
1659
|
+
const lines = thinkText.split("\n").filter((l) => l.trim());
|
|
1660
|
+
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", paddingLeft: 2, children: lines.map((line, i) => /* @__PURE__ */ jsxs4(Text4, { italic: true, color: "#a8a8a8", children: [
|
|
1661
|
+
" \u25B9 ",
|
|
1662
|
+
line
|
|
1663
|
+
] }, `think-${i}`)) });
|
|
1664
|
+
}
|
|
1665
|
+
case "streaming-chunk": {
|
|
1666
|
+
const chunkText = event.chunk;
|
|
1667
|
+
const isThinking = /^~?\d{1,3}%\s/.test(chunkText.trim());
|
|
1668
|
+
if (isThinking) {
|
|
1669
|
+
if (thinkingExpanded === false) return null;
|
|
1670
|
+
return /* @__PURE__ */ jsxs4(Text4, { italic: true, color: "#a8a8a8", children: [
|
|
1671
|
+
" \u25B9 ",
|
|
1672
|
+
chunkText
|
|
1673
|
+
] });
|
|
1674
|
+
}
|
|
1675
|
+
return /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1676
|
+
" ",
|
|
1677
|
+
chunkText
|
|
1678
|
+
] });
|
|
1679
|
+
}
|
|
1680
|
+
case "kern-draft": {
|
|
1681
|
+
const eColor = engineColor(event.engineId);
|
|
1682
|
+
const wrapWidth = contentWidth(8);
|
|
1683
|
+
const segments = parseMarkdownBlocks(event.content.trim().replace(/<think>[\s\S]*?<\/think>\s*/gi, ""));
|
|
1684
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, children: [
|
|
1685
|
+
/* @__PURE__ */ jsxs4(Text4, { color: eColor, children: [
|
|
1686
|
+
"\u250C\u2500\u2500 ",
|
|
1687
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: event.engineId }),
|
|
1688
|
+
event.critique ? /* @__PURE__ */ jsxs4(Text4, { color: "green", children: [
|
|
1689
|
+
" ",
|
|
1690
|
+
event.critique
|
|
1691
|
+
] }) : ""
|
|
1692
|
+
] }),
|
|
1693
|
+
/* @__PURE__ */ jsx4(Text4, { color: eColor, children: "\u2502" }),
|
|
1694
|
+
/* @__PURE__ */ jsx4(RenderedSegments, { segments, borderColor: eColor, wrapWidth }),
|
|
1695
|
+
/* @__PURE__ */ jsx4(Text4, { color: eColor, children: "\u2514\u2500\u2500" })
|
|
1696
|
+
] });
|
|
1697
|
+
}
|
|
1698
|
+
case "debate-round": {
|
|
1699
|
+
const dColor = engineColor(event.engineId);
|
|
1700
|
+
const wrapWidth = contentWidth(8);
|
|
1701
|
+
const segments = parseMarkdownBlocks(event.argument.trim().replace(/<think>[\s\S]*?<\/think>\s*/gi, ""));
|
|
1702
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, children: [
|
|
1703
|
+
/* @__PURE__ */ jsxs4(Text4, { color: dColor, children: [
|
|
1704
|
+
"\u250C\u2500\u2500 ",
|
|
1705
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: event.engineId }),
|
|
1706
|
+
" ",
|
|
1707
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1708
|
+
"(",
|
|
1709
|
+
event.position,
|
|
1710
|
+
")"
|
|
1711
|
+
] })
|
|
1712
|
+
] }),
|
|
1713
|
+
/* @__PURE__ */ jsx4(Text4, { color: dColor, children: "\u2502" }),
|
|
1714
|
+
/* @__PURE__ */ jsx4(RenderedSegments, { segments, borderColor: dColor, wrapWidth }),
|
|
1715
|
+
/* @__PURE__ */ jsx4(Text4, { color: dColor, children: "\u2514\u2500\u2500" })
|
|
1716
|
+
] });
|
|
1717
|
+
}
|
|
1718
|
+
case "verdict": {
|
|
1719
|
+
const wrapWidth = contentWidth(4);
|
|
1720
|
+
const richLines = parseProseToRichLines(event.summary.trim().replace(/<think>[\s\S]*?<\/think>\s*/gi, ""), wrapWidth);
|
|
1721
|
+
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", paddingLeft: 2, children: richLines.map((line, i) => /* @__PURE__ */ jsx4(RichLineView, { line }, `v-${i}`)) });
|
|
1722
|
+
}
|
|
1723
|
+
case "scoreboard":
|
|
1724
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, marginY: 1, children: [
|
|
1725
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: event.title }),
|
|
1726
|
+
event.winner && /* @__PURE__ */ jsxs4(Text4, { bold: true, color: "green", children: [
|
|
1727
|
+
" \u2605 Winner: ",
|
|
1728
|
+
event.winner
|
|
1729
|
+
] }),
|
|
1730
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1731
|
+
" ",
|
|
1732
|
+
"\u2500".repeat(46)
|
|
1733
|
+
] }),
|
|
1734
|
+
event.metrics.map((m) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1735
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1736
|
+
/* @__PURE__ */ jsx4(Box4, { width: 16, children: /* @__PURE__ */ jsx4(Text4, { bold: true, children: m.label }) }),
|
|
1737
|
+
/* @__PURE__ */ jsx4(Text4, { children: m.values.join(" \u2502 ") })
|
|
1738
|
+
] }, m.label))
|
|
1739
|
+
] });
|
|
1740
|
+
case "plan":
|
|
1741
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, marginY: 1, children: [
|
|
1742
|
+
/* @__PURE__ */ jsxs4(Text4, { bold: true, color: "cyan", children: [
|
|
1743
|
+
"\u25B8 Plan: ",
|
|
1744
|
+
event.plan.id.slice(0, 12)
|
|
1745
|
+
] }),
|
|
1746
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1747
|
+
" State: ",
|
|
1748
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: event.plan.state })
|
|
1749
|
+
] }),
|
|
1750
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1751
|
+
" Task: ",
|
|
1752
|
+
event.plan.action.task
|
|
1753
|
+
] }),
|
|
1754
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1755
|
+
" ",
|
|
1756
|
+
"\u2500".repeat(46)
|
|
1757
|
+
] }),
|
|
1758
|
+
event.plan.steps.map((step) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1759
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1760
|
+
/* @__PURE__ */ jsx4(Text4, { color: step.result.state === "completed" ? "green" : step.result.state === "failed" ? "red" : step.result.state === "running" ? "yellow" : void 0, children: step.result.state === "completed" ? icons().success : step.result.state === "failed" ? icons().fail : step.result.state === "running" ? icons().dotOn : icons().dotOff }),
|
|
1761
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1762
|
+
" ",
|
|
1763
|
+
step.label
|
|
1764
|
+
] })
|
|
1765
|
+
] }, step.id)),
|
|
1766
|
+
event.plan.state === "draft" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1767
|
+
"\n Awaiting approval \u2014 ",
|
|
1768
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "green", children: "Y" }),
|
|
1769
|
+
" accept ",
|
|
1770
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "red", children: "N" }),
|
|
1771
|
+
" cancel"
|
|
1772
|
+
] })
|
|
1773
|
+
] });
|
|
1774
|
+
case "plan-list":
|
|
1775
|
+
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", paddingLeft: 2, children: event.plans.map((p) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1776
|
+
/* @__PURE__ */ jsx4(Box4, { width: 14, children: /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: p.id.slice(0, 12) }) }),
|
|
1777
|
+
/* @__PURE__ */ jsx4(Box4, { width: 12, children: /* @__PURE__ */ jsx4(Text4, { color: p.state === "completed" ? "green" : p.state === "failed" ? "red" : void 0, children: p.state }) }),
|
|
1778
|
+
/* @__PURE__ */ jsx4(Text4, { children: p.action.task.slice(0, 40) })
|
|
1779
|
+
] }, p.id)) });
|
|
1780
|
+
case "tool-call": {
|
|
1781
|
+
if (!event.input && !event.output && (event.tool === "Delegate" || event.tool === "delegate")) return null;
|
|
1782
|
+
const toolColor = event.status === "error" ? "#ef4444" : event.status === "done" ? "#4ade80" : "#fbbf24";
|
|
1783
|
+
const icon = event.status === "error" ? icons().fail : event.status === "done" ? icons().success : "\u27F3";
|
|
1784
|
+
const eColor = engineColor(event.engineId);
|
|
1785
|
+
const codeWidth = contentWidth(10);
|
|
1786
|
+
const nest = /* @__PURE__ */ jsx4(Text4, { color: eColor, children: " \u23BF " });
|
|
1787
|
+
let parsed = {};
|
|
1788
|
+
const rawInput = event.input || "";
|
|
1789
|
+
try {
|
|
1790
|
+
if (rawInput.startsWith("{")) parsed = JSON.parse(rawInput);
|
|
1791
|
+
} catch {
|
|
1792
|
+
}
|
|
1793
|
+
const toolKey = event.tool.toLowerCase();
|
|
1794
|
+
const forceExpanded = ["edit", "write", "update", "applypatch", "apply_patch"].includes(toolKey);
|
|
1795
|
+
const collapsedHint = null;
|
|
1796
|
+
if (toolKey === "reportconfidence") {
|
|
1797
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { italic: true, color: "#a8a8a8", children: [
|
|
1798
|
+
" \u25B9 ",
|
|
1799
|
+
formatConfidenceToolLabel(parsed, rawInput)
|
|
1800
|
+
] }) });
|
|
1801
|
+
}
|
|
1802
|
+
if (toolKey === "bash" || toolKey === "run" || toolKey === "agonbash") {
|
|
1803
|
+
const cmd = parsed.command || rawInput || "";
|
|
1804
|
+
const desc = parsed.description;
|
|
1805
|
+
if (!cmd) {
|
|
1806
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1807
|
+
nest,
|
|
1808
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
1809
|
+
icon,
|
|
1810
|
+
" ",
|
|
1811
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: "Bash" })
|
|
1812
|
+
] }),
|
|
1813
|
+
desc ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1814
|
+
" \xB7 ",
|
|
1815
|
+
desc
|
|
1816
|
+
] }) : ""
|
|
1817
|
+
] }) });
|
|
1818
|
+
}
|
|
1819
|
+
if (!toolOutputExpanded) {
|
|
1820
|
+
const outputLines = event.output ? event.output.split("\n").length : 0;
|
|
1821
|
+
const cmdPreview = desc || cmd.split("\n")[0].slice(0, 60);
|
|
1822
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1823
|
+
nest,
|
|
1824
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
1825
|
+
icon,
|
|
1826
|
+
" ",
|
|
1827
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: "Bash" })
|
|
1828
|
+
] }),
|
|
1829
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1830
|
+
desc ? " \xB7 " : " $ ",
|
|
1831
|
+
cmdPreview,
|
|
1832
|
+
cmdPreview.length >= 60 ? "\u2026" : ""
|
|
1833
|
+
] }),
|
|
1834
|
+
outputLines > 0 && event.status !== "running" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1835
|
+
" \u2192 ",
|
|
1836
|
+
outputLines,
|
|
1837
|
+
" lines"
|
|
1838
|
+
] }),
|
|
1839
|
+
collapsedHint
|
|
1840
|
+
] }) });
|
|
1841
|
+
}
|
|
1842
|
+
const cmdLines = cmd.split("\n").slice(0, 3);
|
|
1843
|
+
const moreCmd = cmd.split("\n").length > 3;
|
|
1844
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
1845
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1846
|
+
nest,
|
|
1847
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
1848
|
+
icon,
|
|
1849
|
+
" ",
|
|
1850
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: "Bash" })
|
|
1851
|
+
] }),
|
|
1852
|
+
desc ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1853
|
+
" \xB7 ",
|
|
1854
|
+
desc
|
|
1855
|
+
] }) : ""
|
|
1856
|
+
] }),
|
|
1857
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1858
|
+
cmdLines.map((line, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1859
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1860
|
+
" ",
|
|
1861
|
+
i === 0 ? "$ " : " "
|
|
1862
|
+
] }),
|
|
1863
|
+
/* @__PURE__ */ jsx4(Text4, { children: truncateCodeLine(line, codeWidth) })
|
|
1864
|
+
] }, `cmd-${i}`)),
|
|
1865
|
+
moreCmd && /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \u2026" }),
|
|
1866
|
+
event.output && event.status !== "running" && (() => {
|
|
1867
|
+
const outLines = event.output.split("\n");
|
|
1868
|
+
const total = outLines.length;
|
|
1869
|
+
const maxHead = total > 80 ? 30 : 50;
|
|
1870
|
+
const tailCount = 5;
|
|
1871
|
+
const showTail = total > maxHead + tailCount;
|
|
1872
|
+
const headLines = outLines.slice(0, showTail ? maxHead : total);
|
|
1873
|
+
const tailLines = showTail ? outLines.slice(-tailCount) : [];
|
|
1874
|
+
const skipped = total - maxHead - tailLines.length;
|
|
1875
|
+
const renderLine = (line, i, prefix) => /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
1876
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1877
|
+
event.status === "error" ? /* @__PURE__ */ jsx4(Text4, { color: "#ef4444", children: truncateCodeLine(line, codeWidth) }) : /* @__PURE__ */ jsx4(AnsiLine, { text: line, maxWidth: codeWidth, fallbackDim: true })
|
|
1878
|
+
] }, `${prefix}-${i}`);
|
|
1879
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1880
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
1881
|
+
headLines.map((line, i) => renderLine(line, i, "head")),
|
|
1882
|
+
skipped > 0 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1883
|
+
" \u2026 ",
|
|
1884
|
+
skipped,
|
|
1885
|
+
" more lines \u2026"
|
|
1886
|
+
] }),
|
|
1887
|
+
tailLines.map((line, i) => renderLine(line, i, "tail"))
|
|
1888
|
+
] });
|
|
1889
|
+
})()
|
|
1890
|
+
] });
|
|
1891
|
+
}
|
|
1892
|
+
if (toolKey === "edit" || toolKey === "update" || toolKey === "agonedit") {
|
|
1893
|
+
const filePath = parsed.file_path || parsed.filePath || "";
|
|
1894
|
+
const oldStr = parsed.old_string || parsed.oldString || "";
|
|
1895
|
+
const newStr = parsed.new_string || parsed.newString || "";
|
|
1896
|
+
const shortPath = filePath ? filePath.replace(process.cwd() + "/", "").replace(process.env.HOME ?? "", "~") : "";
|
|
1897
|
+
const addedCount = newStr ? newStr.split("\n").length : 0;
|
|
1898
|
+
const removedCount = oldStr ? oldStr.split("\n").length : 0;
|
|
1899
|
+
if (!toolOutputExpanded && !forceExpanded) {
|
|
1900
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1901
|
+
nest,
|
|
1902
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
1903
|
+
icon,
|
|
1904
|
+
" ",
|
|
1905
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().edit + " Update" })
|
|
1906
|
+
] }),
|
|
1907
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1908
|
+
"(",
|
|
1909
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: shortPath }),
|
|
1910
|
+
")"
|
|
1911
|
+
] }) : "",
|
|
1912
|
+
" ",
|
|
1913
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "\\u00b7 " }),
|
|
1914
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#ef4444", children: [
|
|
1915
|
+
"-",
|
|
1916
|
+
removedCount
|
|
1917
|
+
] }),
|
|
1918
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
1919
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#4ade80", children: [
|
|
1920
|
+
"+",
|
|
1921
|
+
addedCount
|
|
1922
|
+
] }),
|
|
1923
|
+
" lines",
|
|
1924
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "" })
|
|
1925
|
+
] }) });
|
|
1926
|
+
}
|
|
1927
|
+
const maxLines = Infinity;
|
|
1928
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
1929
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1930
|
+
nest,
|
|
1931
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
1932
|
+
icon,
|
|
1933
|
+
" ",
|
|
1934
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().edit + " Update" })
|
|
1935
|
+
] }),
|
|
1936
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1937
|
+
"(",
|
|
1938
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: shortPath }),
|
|
1939
|
+
")"
|
|
1940
|
+
] }) : ""
|
|
1941
|
+
] }),
|
|
1942
|
+
(oldStr || newStr) && event.status !== "running" && (() => {
|
|
1943
|
+
const oldLines = oldStr.split("\n").slice(0, maxLines);
|
|
1944
|
+
const newLines = newStr.split("\n").slice(0, maxLines);
|
|
1945
|
+
const gutterW = Math.max(String(Math.max(removedCount, addedCount)).length, 2);
|
|
1946
|
+
const pad = (n) => String(n).padStart(gutterW);
|
|
1947
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1948
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1949
|
+
" ",
|
|
1950
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#ef4444", children: [
|
|
1951
|
+
"-",
|
|
1952
|
+
removedCount
|
|
1953
|
+
] }),
|
|
1954
|
+
" ",
|
|
1955
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#4ade80", children: [
|
|
1956
|
+
"+",
|
|
1957
|
+
addedCount
|
|
1958
|
+
] }),
|
|
1959
|
+
" lines"
|
|
1960
|
+
] }),
|
|
1961
|
+
oldLines.map((line, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1962
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#6b7280", children: [
|
|
1963
|
+
" ",
|
|
1964
|
+
pad(i + 1),
|
|
1965
|
+
" "
|
|
1966
|
+
] }),
|
|
1967
|
+
/* @__PURE__ */ jsx4(DiffLine, { line: `-${line}`, maxWidth: codeWidth - gutterW - 2 })
|
|
1968
|
+
] }, `old-${i}`)),
|
|
1969
|
+
removedCount > maxLines && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1970
|
+
" \u2026 ",
|
|
1971
|
+
removedCount - maxLines,
|
|
1972
|
+
" more removed"
|
|
1973
|
+
] }),
|
|
1974
|
+
newLines.map((line, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1975
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#6b7280", children: [
|
|
1976
|
+
" ",
|
|
1977
|
+
pad(i + 1),
|
|
1978
|
+
" "
|
|
1979
|
+
] }),
|
|
1980
|
+
/* @__PURE__ */ jsx4(DiffLine, { line: `+${line}`, maxWidth: codeWidth - gutterW - 2 })
|
|
1981
|
+
] }, `new-${i}`)),
|
|
1982
|
+
addedCount > maxLines && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
1983
|
+
" \u2026 ",
|
|
1984
|
+
addedCount - maxLines,
|
|
1985
|
+
" more added"
|
|
1986
|
+
] })
|
|
1987
|
+
] });
|
|
1988
|
+
})()
|
|
1989
|
+
] });
|
|
1990
|
+
}
|
|
1991
|
+
if (toolKey === "write" || toolKey === "agonwrite") {
|
|
1992
|
+
const filePath = parsed.file_path || parsed.filePath || "";
|
|
1993
|
+
const content = parsed.content || "";
|
|
1994
|
+
const shortPath = shortToolPath(filePath);
|
|
1995
|
+
const lineCount = content ? content.split("\n").length : 0;
|
|
1996
|
+
if (!toolOutputExpanded && !forceExpanded) {
|
|
1997
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
1998
|
+
nest,
|
|
1999
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2000
|
+
icon,
|
|
2001
|
+
" ",
|
|
2002
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().write + " Write" })
|
|
2003
|
+
] }),
|
|
2004
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2005
|
+
"(",
|
|
2006
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: shortPath }),
|
|
2007
|
+
")"
|
|
2008
|
+
] }) : "",
|
|
2009
|
+
lineCount > 0 && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
2010
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \xB7 " }),
|
|
2011
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#4ade80", children: [
|
|
2012
|
+
"+",
|
|
2013
|
+
lineCount
|
|
2014
|
+
] }),
|
|
2015
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " lines" })
|
|
2016
|
+
] }),
|
|
2017
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "" })
|
|
2018
|
+
] }) });
|
|
2019
|
+
}
|
|
2020
|
+
const maxLines = Infinity;
|
|
2021
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2022
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2023
|
+
nest,
|
|
2024
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2025
|
+
icon,
|
|
2026
|
+
" ",
|
|
2027
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().write + " Write" })
|
|
2028
|
+
] }),
|
|
2029
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2030
|
+
"(",
|
|
2031
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: shortPath }),
|
|
2032
|
+
")"
|
|
2033
|
+
] }) : ""
|
|
2034
|
+
] }),
|
|
2035
|
+
content && event.status !== "running" && (() => {
|
|
2036
|
+
const allLines = content.split("\n");
|
|
2037
|
+
const shown = allLines.slice(0, maxLines);
|
|
2038
|
+
const gutterW = Math.max(String(lineCount).length, 2);
|
|
2039
|
+
const pad = (n) => String(n).padStart(gutterW);
|
|
2040
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
2041
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2042
|
+
" ",
|
|
2043
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#4ade80", children: [
|
|
2044
|
+
"+",
|
|
2045
|
+
lineCount
|
|
2046
|
+
] }),
|
|
2047
|
+
" lines"
|
|
2048
|
+
] }),
|
|
2049
|
+
shown.map((line, i) => /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2050
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#6b7280", children: [
|
|
2051
|
+
" ",
|
|
2052
|
+
pad(i + 1),
|
|
2053
|
+
" "
|
|
2054
|
+
] }),
|
|
2055
|
+
/* @__PURE__ */ jsx4(DiffLine, { line: `+${line}`, maxWidth: codeWidth - gutterW - 2 })
|
|
2056
|
+
] }, `w-${i}`)),
|
|
2057
|
+
lineCount > maxLines && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2058
|
+
" \u2026 ",
|
|
2059
|
+
lineCount - maxLines,
|
|
2060
|
+
" more lines"
|
|
2061
|
+
] })
|
|
2062
|
+
] });
|
|
2063
|
+
})()
|
|
2064
|
+
] });
|
|
2065
|
+
}
|
|
2066
|
+
if (toolKey === "applypatch" || toolKey === "apply_patch") {
|
|
2067
|
+
const patch = parsePatchPreview(rawInput, parsed);
|
|
2068
|
+
const fileSummary = patch.files.length > 0 ? patch.files.slice(0, 2).map((filePath) => shortToolPath(filePath)).join(", ") + (patch.files.length > 2 ? ", \u2026" : "") : "";
|
|
2069
|
+
const maxLines = 80;
|
|
2070
|
+
const shown = patch.lines.slice(0, maxLines);
|
|
2071
|
+
const omitted = Math.max(0, patch.lines.length - shown.length);
|
|
2072
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2073
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2074
|
+
nest,
|
|
2075
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2076
|
+
icon,
|
|
2077
|
+
" ",
|
|
2078
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().edit + " Patch" })
|
|
2079
|
+
] }),
|
|
2080
|
+
fileSummary ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2081
|
+
"(",
|
|
2082
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: fileSummary }),
|
|
2083
|
+
")"
|
|
2084
|
+
] }) : "",
|
|
2085
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \xB7 " }),
|
|
2086
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#ef4444", children: [
|
|
2087
|
+
"-",
|
|
2088
|
+
patch.deletions
|
|
2089
|
+
] }),
|
|
2090
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " " }),
|
|
2091
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#4ade80", children: [
|
|
2092
|
+
"+",
|
|
2093
|
+
patch.additions
|
|
2094
|
+
] }),
|
|
2095
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " lines" })
|
|
2096
|
+
] }),
|
|
2097
|
+
shown.map((line, i) => /* @__PURE__ */ jsx4(DiffLine, { line, maxWidth: codeWidth }, `patch-${i}`)),
|
|
2098
|
+
omitted > 0 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2099
|
+
" \u2026 ",
|
|
2100
|
+
omitted,
|
|
2101
|
+
" more patch lines"
|
|
2102
|
+
] })
|
|
2103
|
+
] });
|
|
2104
|
+
}
|
|
2105
|
+
if (toolKey === "read") {
|
|
2106
|
+
const filePath = parsed.file_path || parsed.filePath || "";
|
|
2107
|
+
const shortPath = filePath ? filePath.replace(process.cwd() + "/", "").replace(process.env.HOME ?? "", "~") : "";
|
|
2108
|
+
if (!toolOutputExpanded) {
|
|
2109
|
+
const lineCount = event.output ? event.output.split("\n").length : 0;
|
|
2110
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2111
|
+
nest,
|
|
2112
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2113
|
+
icon,
|
|
2114
|
+
" ",
|
|
2115
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().read + " Read" })
|
|
2116
|
+
] }),
|
|
2117
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2118
|
+
"(",
|
|
2119
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: shortPath }),
|
|
2120
|
+
")"
|
|
2121
|
+
] }) : "",
|
|
2122
|
+
lineCount > 0 && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2123
|
+
" ",
|
|
2124
|
+
lineCount,
|
|
2125
|
+
" lines"
|
|
2126
|
+
] }),
|
|
2127
|
+
collapsedHint
|
|
2128
|
+
] }) });
|
|
2129
|
+
}
|
|
2130
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2131
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2132
|
+
nest,
|
|
2133
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2134
|
+
icon,
|
|
2135
|
+
" ",
|
|
2136
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().read + " Read" })
|
|
2137
|
+
] }),
|
|
2138
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2139
|
+
"(",
|
|
2140
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: shortPath }),
|
|
2141
|
+
")"
|
|
2142
|
+
] }) : ""
|
|
2143
|
+
] }),
|
|
2144
|
+
event.output && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2145
|
+
" ",
|
|
2146
|
+
event.output.split("\n").length,
|
|
2147
|
+
" lines (",
|
|
2148
|
+
Math.ceil(event.output.length / 1024),
|
|
2149
|
+
"kb)"
|
|
2150
|
+
] })
|
|
2151
|
+
] });
|
|
2152
|
+
}
|
|
2153
|
+
if (toolKey === "grep" || toolKey === "search") {
|
|
2154
|
+
const pattern = parsed.pattern || rawInput || "";
|
|
2155
|
+
const path = parsed.path || "";
|
|
2156
|
+
const shortPath = path ? path.replace(process.cwd() + "/", "").replace(process.env.HOME ?? "", "~") : "";
|
|
2157
|
+
if (!toolOutputExpanded) {
|
|
2158
|
+
const matchCount = event.output ? event.output.split("\n").length : 0;
|
|
2159
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2160
|
+
nest,
|
|
2161
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2162
|
+
icon,
|
|
2163
|
+
" ",
|
|
2164
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().search + " Search" })
|
|
2165
|
+
] }),
|
|
2166
|
+
" ",
|
|
2167
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: pattern }),
|
|
2168
|
+
matchCount > 0 && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2169
|
+
" \u2192 ",
|
|
2170
|
+
matchCount,
|
|
2171
|
+
" matches"
|
|
2172
|
+
] }),
|
|
2173
|
+
collapsedHint
|
|
2174
|
+
] }) });
|
|
2175
|
+
}
|
|
2176
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2177
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2178
|
+
nest,
|
|
2179
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2180
|
+
icon,
|
|
2181
|
+
" ",
|
|
2182
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().search + " Search" })
|
|
2183
|
+
] }),
|
|
2184
|
+
" ",
|
|
2185
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: pattern }),
|
|
2186
|
+
shortPath ? /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2187
|
+
" in ",
|
|
2188
|
+
shortPath
|
|
2189
|
+
] }) : ""
|
|
2190
|
+
] }),
|
|
2191
|
+
event.output && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2192
|
+
" ",
|
|
2193
|
+
event.output.split("\n").length,
|
|
2194
|
+
" matches"
|
|
2195
|
+
] })
|
|
2196
|
+
] });
|
|
2197
|
+
}
|
|
2198
|
+
if (toolKey === "glob" || toolKey === "find") {
|
|
2199
|
+
const pattern = parsed.pattern || rawInput || "";
|
|
2200
|
+
if (!toolOutputExpanded) {
|
|
2201
|
+
const fileCount = event.output ? event.output.split("\n").filter((l) => l.trim()).length : 0;
|
|
2202
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2203
|
+
nest,
|
|
2204
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2205
|
+
icon,
|
|
2206
|
+
" ",
|
|
2207
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().find + " Find" })
|
|
2208
|
+
] }),
|
|
2209
|
+
" ",
|
|
2210
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: pattern }),
|
|
2211
|
+
fileCount > 0 && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2212
|
+
" \u2192 ",
|
|
2213
|
+
fileCount,
|
|
2214
|
+
" files"
|
|
2215
|
+
] }),
|
|
2216
|
+
collapsedHint
|
|
2217
|
+
] }) });
|
|
2218
|
+
}
|
|
2219
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2220
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2221
|
+
nest,
|
|
2222
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2223
|
+
icon,
|
|
2224
|
+
" ",
|
|
2225
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: icons().find + " Find" })
|
|
2226
|
+
] }),
|
|
2227
|
+
" ",
|
|
2228
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: pattern })
|
|
2229
|
+
] }),
|
|
2230
|
+
event.output && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2231
|
+
" ",
|
|
2232
|
+
event.output.split("\n").filter((l) => l.trim()).length,
|
|
2233
|
+
" files"
|
|
2234
|
+
] })
|
|
2235
|
+
] });
|
|
2236
|
+
}
|
|
2237
|
+
const ic = icons();
|
|
2238
|
+
const toolLabels = {
|
|
2239
|
+
"Read": `${ic.read} Read`,
|
|
2240
|
+
"Edit": `${ic.edit} Edit`,
|
|
2241
|
+
"Write": `${ic.write} Write`,
|
|
2242
|
+
"Bash": `${ic.bash} Run`,
|
|
2243
|
+
"Grep": `${ic.search} Search`,
|
|
2244
|
+
"Glob": `${ic.find} Find`,
|
|
2245
|
+
"tool": `${ic.tool} Tool`
|
|
2246
|
+
};
|
|
2247
|
+
const label = toolLabels[event.tool] ?? `${ic.tool} ${event.tool}`;
|
|
2248
|
+
const inputPreview = event.input.length > 80 ? event.input.slice(0, 80) + "\u2026" : event.input;
|
|
2249
|
+
if (!toolOutputExpanded && !forceExpanded) {
|
|
2250
|
+
const outLines = event.output ? event.output.split("\n").length : 0;
|
|
2251
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2252
|
+
nest,
|
|
2253
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2254
|
+
icon,
|
|
2255
|
+
" ",
|
|
2256
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: label })
|
|
2257
|
+
] }),
|
|
2258
|
+
" ",
|
|
2259
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: inputPreview }),
|
|
2260
|
+
outLines > 0 && event.status === "done" && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2261
|
+
" \u2192 ",
|
|
2262
|
+
outLines,
|
|
2263
|
+
" lines"
|
|
2264
|
+
] }),
|
|
2265
|
+
collapsedHint
|
|
2266
|
+
] }) });
|
|
2267
|
+
}
|
|
2268
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2269
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2270
|
+
nest,
|
|
2271
|
+
/* @__PURE__ */ jsxs4(Text4, { color: toolColor, children: [
|
|
2272
|
+
icon,
|
|
2273
|
+
" ",
|
|
2274
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: label })
|
|
2275
|
+
] }),
|
|
2276
|
+
" ",
|
|
2277
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: inputPreview })
|
|
2278
|
+
] }),
|
|
2279
|
+
event.output && event.status === "done" && event.output.length <= 200 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2280
|
+
" ",
|
|
2281
|
+
event.output.length > 120 ? event.output.slice(0, 120) + "\u2026" : event.output
|
|
2282
|
+
] }),
|
|
2283
|
+
event.output && event.status === "done" && event.output.length > 200 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2284
|
+
" ",
|
|
2285
|
+
event.output.split("\n").length,
|
|
2286
|
+
" lines (",
|
|
2287
|
+
Math.ceil(event.output.length / 1024),
|
|
2288
|
+
"kb)"
|
|
2289
|
+
] })
|
|
2290
|
+
] });
|
|
2291
|
+
}
|
|
2292
|
+
case "response-meta": {
|
|
2293
|
+
const secs = (event.elapsed / 1e3).toFixed(1);
|
|
2294
|
+
const tokens = event.inputTokens || event.outputTokens ? `${(event.inputTokens ?? 0) + (event.outputTokens ?? 0)} tok` : "";
|
|
2295
|
+
const cost = event.cost ? `$${event.cost.toFixed(4)}` : "";
|
|
2296
|
+
const parts = [event.engineId, `${secs}s`, tokens, cost].filter(Boolean);
|
|
2297
|
+
return /* @__PURE__ */ jsx4(Box4, { paddingLeft: 2, children: /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: parts.join(" \xB7 ") }) });
|
|
2298
|
+
}
|
|
2299
|
+
case "cesar-recap":
|
|
2300
|
+
return /* @__PURE__ */ jsx4(CesarRecapBlock, { event });
|
|
2301
|
+
case "file-changes": {
|
|
2302
|
+
const files = event.files;
|
|
2303
|
+
if (!files || files.length === 0) return null;
|
|
2304
|
+
const cwd = process.cwd();
|
|
2305
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, marginY: 1, children: [
|
|
2306
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: "Files changed" }),
|
|
2307
|
+
files.map((f) => {
|
|
2308
|
+
const shortPath = f.path.replace(cwd + "/", "");
|
|
2309
|
+
const total = f.additions + f.deletions;
|
|
2310
|
+
const barW = 10;
|
|
2311
|
+
const addBar = total > 0 ? Math.max(1, Math.round(f.additions / total * barW)) : 0;
|
|
2312
|
+
const delBar = barW - addBar;
|
|
2313
|
+
return /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
2314
|
+
/* @__PURE__ */ jsx4(Text4, { color: f.status === "created" ? "#22d3ee" : f.status === "deleted" ? "#ef4444" : "#4ade80", children: f.status === "created" ? icons().dotOn : f.status === "deleted" ? "\u2296" : icons().success }),
|
|
2315
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2316
|
+
" ",
|
|
2317
|
+
shortPath
|
|
2318
|
+
] }),
|
|
2319
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2320
|
+
" +",
|
|
2321
|
+
f.additions,
|
|
2322
|
+
" -",
|
|
2323
|
+
f.deletions,
|
|
2324
|
+
" "
|
|
2325
|
+
] }),
|
|
2326
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2327
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#4ade80", children: "\u2588".repeat(addBar) }),
|
|
2328
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#ef4444", children: "\u2588".repeat(delBar) })
|
|
2329
|
+
] })
|
|
2330
|
+
] }, f.path);
|
|
2331
|
+
})
|
|
2332
|
+
] });
|
|
2333
|
+
}
|
|
2334
|
+
case "dashboard":
|
|
2335
|
+
return /* @__PURE__ */ jsx4(DashboardView, { event });
|
|
2336
|
+
case "plan-proposal":
|
|
2337
|
+
return /* @__PURE__ */ jsx4(PlanProposalView, { plan: event.plan, markdown: event.markdown, committed: event.committed });
|
|
2338
|
+
case "plan-execution":
|
|
2339
|
+
return /* @__PURE__ */ jsx4(PlanExecutionView, { plan: event.plan });
|
|
2340
|
+
case "tool-call-group":
|
|
2341
|
+
return /* @__PURE__ */ jsx4(ToolCallGroup, { blocks: event.blocks });
|
|
2342
|
+
default:
|
|
2343
|
+
return null;
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
var ToolCallGroup = React4.memo(function ToolCallGroup2({ blocks }) {
|
|
2347
|
+
const labelForTool = (raw) => {
|
|
2348
|
+
const toolKey = String(raw ?? "").toLowerCase();
|
|
2349
|
+
if (toolKey === "bash" || toolKey === "run" || toolKey === "agonbash") return "Bash";
|
|
2350
|
+
if (toolKey === "read") return "Read";
|
|
2351
|
+
if (toolKey === "grep" || toolKey === "search") return "Search";
|
|
2352
|
+
if (toolKey === "glob" || toolKey === "find") return "Find";
|
|
2353
|
+
if (toolKey === "edit" || toolKey === "update" || toolKey === "agonedit") return "Update";
|
|
2354
|
+
if (toolKey === "write" || toolKey === "agonwrite") return "Write";
|
|
2355
|
+
if (toolKey === "applypatch" || toolKey === "apply_patch") return "Patch";
|
|
2356
|
+
if (toolKey === "reportconfidence") return "Confidence";
|
|
2357
|
+
if (toolKey === "quicknero") return "QuickNero";
|
|
2358
|
+
return String(raw ?? "Tool");
|
|
2359
|
+
};
|
|
2360
|
+
const timestampMs = (ev) => {
|
|
2361
|
+
const candidates = [ev?.timestamp, ev?.startedAt, ev?.endedAt, ev?.completedAt, ev?.finishedAt];
|
|
2362
|
+
for (const value of candidates) {
|
|
2363
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
2364
|
+
if (typeof value === "string" && value.trim()) {
|
|
2365
|
+
const parsed = Date.parse(value);
|
|
2366
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
return null;
|
|
2370
|
+
};
|
|
2371
|
+
const durationMs = (ev) => {
|
|
2372
|
+
for (const key of ["elapsedMs", "durationMs"]) {
|
|
2373
|
+
const value = ev?.[key];
|
|
2374
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
|
|
2375
|
+
}
|
|
2376
|
+
return null;
|
|
2377
|
+
};
|
|
2378
|
+
const toolCounts = {};
|
|
2379
|
+
let confidenceLabel = "";
|
|
2380
|
+
let errors = 0;
|
|
2381
|
+
let running = 0;
|
|
2382
|
+
let totalOutputBytes = 0;
|
|
2383
|
+
let explicitElapsedMs = 0;
|
|
2384
|
+
let firstTimestampMs = null;
|
|
2385
|
+
let lastTimestampMs = null;
|
|
2386
|
+
const changedFiles = [];
|
|
2387
|
+
const changeEvents = [];
|
|
2388
|
+
const changeRows = [];
|
|
2389
|
+
let omittedChangeRows = 0;
|
|
2390
|
+
const pushChangeRow = (key, text) => {
|
|
2391
|
+
if (changeRows.length < 14) changeRows.push({ key, text });
|
|
2392
|
+
else omittedChangeRows += 1;
|
|
2393
|
+
};
|
|
2394
|
+
for (const b of blocks) {
|
|
2395
|
+
const ev = b.event;
|
|
2396
|
+
const ts = timestampMs(ev);
|
|
2397
|
+
if (ts != null) {
|
|
2398
|
+
firstTimestampMs = firstTimestampMs == null ? ts : Math.min(firstTimestampMs, ts);
|
|
2399
|
+
lastTimestampMs = lastTimestampMs == null ? ts : Math.max(lastTimestampMs, ts);
|
|
2400
|
+
}
|
|
2401
|
+
const elapsed = durationMs(ev);
|
|
2402
|
+
if (elapsed != null) explicitElapsedMs += elapsed;
|
|
2403
|
+
if (typeof ev.output === "string" && ev.output.length > 0) {
|
|
2404
|
+
totalOutputBytes += Buffer.byteLength(ev.output, "utf8");
|
|
2405
|
+
}
|
|
2406
|
+
const rawName = ev.tool || "tool";
|
|
2407
|
+
const toolKey = String(rawName).toLowerCase();
|
|
2408
|
+
const { rawInput, parsed } = parseToolInputPayload(ev.input ?? "");
|
|
2409
|
+
const name = labelForTool(rawName);
|
|
2410
|
+
if (ev.status === "error") errors++;
|
|
2411
|
+
if (ev.status === "running") running++;
|
|
2412
|
+
if (toolKey === "reportconfidence") {
|
|
2413
|
+
confidenceLabel = formatConfidenceToolLabel(parsed, rawInput);
|
|
2414
|
+
continue;
|
|
2415
|
+
}
|
|
2416
|
+
toolCounts[name] = (toolCounts[name] || 0) + 1;
|
|
2417
|
+
if ((toolKey === "edit" || toolKey === "update" || toolKey === "write" || toolKey === "agonedit" || toolKey === "agonwrite") && typeof ev.input === "string" && ev.input.trim().startsWith("{")) {
|
|
2418
|
+
try {
|
|
2419
|
+
const filePath = parsed.file_path || parsed.filePath || "";
|
|
2420
|
+
if (filePath) {
|
|
2421
|
+
const shortPath = shortToolPath(filePath);
|
|
2422
|
+
if (!changedFiles.includes(shortPath)) changedFiles.push(shortPath);
|
|
2423
|
+
}
|
|
2424
|
+
} catch {
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
if (toolKey === "edit" || toolKey === "update" || toolKey === "agonedit") {
|
|
2428
|
+
changeEvents.push(ev);
|
|
2429
|
+
const oldLines = String(parsed.old_string || parsed.oldString || "").split("\n");
|
|
2430
|
+
const newLines = String(parsed.new_string || parsed.newString || "").split("\n");
|
|
2431
|
+
oldLines.slice(0, 3).forEach((line, index) => pushChangeRow(`${b.id}-old-${index}`, `-${line}`));
|
|
2432
|
+
newLines.slice(0, 3).forEach((line, index) => pushChangeRow(`${b.id}-new-${index}`, `+${line}`));
|
|
2433
|
+
omittedChangeRows += Math.max(0, oldLines.length - 3) + Math.max(0, newLines.length - 3);
|
|
2434
|
+
} else if (toolKey === "write" || toolKey === "agonwrite") {
|
|
2435
|
+
changeEvents.push(ev);
|
|
2436
|
+
const lines = String(parsed.content || "").split("\n");
|
|
2437
|
+
lines.slice(0, 6).forEach((line, index) => pushChangeRow(`${b.id}-write-${index}`, `+${line}`));
|
|
2438
|
+
omittedChangeRows += Math.max(0, lines.length - 6);
|
|
2439
|
+
} else if (toolKey === "applypatch" || toolKey === "apply_patch") {
|
|
2440
|
+
changeEvents.push(ev);
|
|
2441
|
+
const patch = parsePatchPreview(rawInput, parsed);
|
|
2442
|
+
for (const patchFile of patch.files) {
|
|
2443
|
+
const shortPath = shortToolPath(patchFile);
|
|
2444
|
+
if (!changedFiles.includes(shortPath)) changedFiles.push(shortPath);
|
|
2445
|
+
}
|
|
2446
|
+
patch.lines.slice(0, 8).forEach((line, index) => pushChangeRow(`${b.id}-patch-${index}`, line));
|
|
2447
|
+
omittedChangeRows += Math.max(0, patch.lines.length - 8);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
const summary = Object.entries(toolCounts).map(([name, count]) => count > 1 ? `${name}\xD7${count}` : name).join(", ");
|
|
2451
|
+
const statusSummary = errors > 0 ? ` \xB7 ${errors} error${errors === 1 ? "" : "s"}` : running > 0 ? " \xB7 running" : "";
|
|
2452
|
+
const changedSummary = changedFiles.length > 0 ? ` \xB7 changed ${changedFiles.length} file${changedFiles.length > 1 ? "s" : ""}: ${changedFiles.slice(0, 2).join(", ")}${changedFiles.length > 2 ? ", \u2026" : ""}` : "";
|
|
2453
|
+
const firstEvent = blocks[0]?.event ?? {};
|
|
2454
|
+
const metaEngine = String(firstEvent.engineId ?? "").trim() || "engine";
|
|
2455
|
+
const inferredElapsedMs = firstTimestampMs != null && lastTimestampMs != null ? Math.max(0, lastTimestampMs - firstTimestampMs) : 0;
|
|
2456
|
+
const metaElapsedMs = explicitElapsedMs > 0 ? explicitElapsedMs : inferredElapsedMs;
|
|
2457
|
+
const metaParts = [
|
|
2458
|
+
metaEngine,
|
|
2459
|
+
`${blocks.length} tool${blocks.length === 1 ? "" : "s"}`,
|
|
2460
|
+
`changed ${changedFiles.length} file${changedFiles.length === 1 ? "" : "s"}`,
|
|
2461
|
+
metaElapsedMs > 0 ? `${(metaElapsedMs / 1e3).toFixed(1)}s` : "",
|
|
2462
|
+
totalOutputBytes > 0 ? `${Math.ceil(totalOutputBytes / 1024)}kb` : ""
|
|
2463
|
+
].filter(Boolean);
|
|
2464
|
+
return /* @__PURE__ */ jsxs4(Box4, { paddingLeft: 2, flexDirection: "column", children: [
|
|
2465
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2466
|
+
" \u23F5 ",
|
|
2467
|
+
metaParts.join(" \xB7 ")
|
|
2468
|
+
] }),
|
|
2469
|
+
confidenceLabel && /* @__PURE__ */ jsx4(Text4, { children: /* @__PURE__ */ jsxs4(Text4, { italic: true, color: "#a8a8a8", children: [
|
|
2470
|
+
" \u25B9 ",
|
|
2471
|
+
confidenceLabel
|
|
2472
|
+
] }) }),
|
|
2473
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2474
|
+
" ",
|
|
2475
|
+
blocks.length,
|
|
2476
|
+
" tool calls",
|
|
2477
|
+
summary ? ` \xB7 ${summary}` : "",
|
|
2478
|
+
statusSummary,
|
|
2479
|
+
changedSummary,
|
|
2480
|
+
" ",
|
|
2481
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f59e0b", children: "Ctrl+E" })
|
|
2482
|
+
] }),
|
|
2483
|
+
changeRows.map((row) => /* @__PURE__ */ jsx4(DiffLine, { line: row.text, maxWidth: contentWidth(10) }, row.key)),
|
|
2484
|
+
omittedChangeRows > 0 && /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2485
|
+
" \u2026 ",
|
|
2486
|
+
omittedChangeRows,
|
|
2487
|
+
" more changed lines"
|
|
2488
|
+
] })
|
|
2489
|
+
] });
|
|
2490
|
+
});
|
|
2491
|
+
var DebateGroup = React4.memo(function DebateGroup2({ blocks }) {
|
|
2492
|
+
const round = blocks[0]?.event?.round ?? "?";
|
|
2493
|
+
const w = contentWidth(6);
|
|
2494
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, children: [
|
|
2495
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#a78bfa", bold: true, children: [
|
|
2496
|
+
"\u250C\u2500\u2500 Round ",
|
|
2497
|
+
round,
|
|
2498
|
+
" \u2500\u2500"
|
|
2499
|
+
] }),
|
|
2500
|
+
blocks.map((b, i) => {
|
|
2501
|
+
const ev = b.event;
|
|
2502
|
+
const eColor = engineColor(ev.engineId);
|
|
2503
|
+
const summary = extractSummary(ev.argument || "", w - 30);
|
|
2504
|
+
return /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2505
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#a78bfa", children: "\u2502 " }),
|
|
2506
|
+
/* @__PURE__ */ jsx4(Text4, { color: eColor, bold: true, children: ev.engineId }),
|
|
2507
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2508
|
+
" (",
|
|
2509
|
+
ev.position,
|
|
2510
|
+
"): "
|
|
2511
|
+
] }),
|
|
2512
|
+
/* @__PURE__ */ jsx4(Text4, { children: summary })
|
|
2513
|
+
] }, `dr-${i}`);
|
|
2514
|
+
}),
|
|
2515
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#a78bfa", children: [
|
|
2516
|
+
"\u2514",
|
|
2517
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f59e0b", children: "" })
|
|
2518
|
+
] })
|
|
2519
|
+
] });
|
|
2520
|
+
});
|
|
2521
|
+
var BidGroup = React4.memo(function BidGroup2({ blocks }) {
|
|
2522
|
+
const w = contentWidth(6);
|
|
2523
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingLeft: 2, children: [
|
|
2524
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#22d3ee", bold: true, children: "\u250C\u2500\u2500 Brainstorm Bids \u2500\u2500" }),
|
|
2525
|
+
blocks.map((b, i) => {
|
|
2526
|
+
const ev = b.event;
|
|
2527
|
+
const eColor = engineColor(ev.engineId);
|
|
2528
|
+
const isWinner = ev.critique && ev.critique.includes("best");
|
|
2529
|
+
const scoreMatch = ev.critique ? ev.critique.match(/score:\s*(\d+)/) : null;
|
|
2530
|
+
const score = scoreMatch ? scoreMatch[1] : "?";
|
|
2531
|
+
const icon = isWinner ? "\u2B50" : "\u2713";
|
|
2532
|
+
const summary = extractSummary(ev.content || "", w - 30);
|
|
2533
|
+
return /* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2534
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#22d3ee", children: "\u2502 " }),
|
|
2535
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
2536
|
+
icon,
|
|
2537
|
+
" "
|
|
2538
|
+
] }),
|
|
2539
|
+
/* @__PURE__ */ jsx4(Text4, { color: eColor, bold: true, children: ev.engineId }),
|
|
2540
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
2541
|
+
" (",
|
|
2542
|
+
score,
|
|
2543
|
+
"): "
|
|
2544
|
+
] }),
|
|
2545
|
+
/* @__PURE__ */ jsx4(Text4, { children: summary })
|
|
2546
|
+
] }, `bid-${i}`);
|
|
2547
|
+
}),
|
|
2548
|
+
/* @__PURE__ */ jsxs4(Text4, { color: "#22d3ee", children: [
|
|
2549
|
+
"\u2514",
|
|
2550
|
+
/* @__PURE__ */ jsx4(Text4, { color: "#f59e0b", children: "" })
|
|
2551
|
+
] })
|
|
2552
|
+
] });
|
|
2553
|
+
});
|
|
2554
|
+
var BRAND = ["#fbbf24", "#f9a816", "#f97316", "#f45a2a", "#ef4444"];
|
|
2555
|
+
var LOGO_LINES = [" \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557", " \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551", " \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551", " \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551", " \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551", " \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D"];
|
|
2556
|
+
function resolvePackageVersion(resolveSpecifier, wantName, fallback) {
|
|
2557
|
+
try {
|
|
2558
|
+
const req = createRequire(import.meta.url);
|
|
2559
|
+
const startFile = resolveSpecifier ? req.resolve(resolveSpecifier) : fileURLToPath(import.meta.url);
|
|
2560
|
+
let dir = dirname(startFile);
|
|
2561
|
+
for (let i = 0; i < 10; i += 1) {
|
|
2562
|
+
const pkgPath = join(dir, "package.json");
|
|
2563
|
+
if (existsSync(pkgPath)) {
|
|
2564
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
2565
|
+
if (pkg && pkg.name === wantName && typeof pkg.version === "string") return pkg.version;
|
|
2566
|
+
}
|
|
2567
|
+
const parent = dirname(dir);
|
|
2568
|
+
if (parent === dir) break;
|
|
2569
|
+
dir = parent;
|
|
2570
|
+
}
|
|
2571
|
+
} catch {
|
|
2572
|
+
}
|
|
2573
|
+
return fallback;
|
|
2574
|
+
}
|
|
2575
|
+
var VERSION = resolvePackageVersion(null, "@kernlang/agon", "0.1.5");
|
|
2576
|
+
var KERN_VERSION = resolvePackageVersion("@kernlang/terminal/runtime", "@kernlang/terminal", "3.5.7");
|
|
2577
|
+
|
|
2578
|
+
// src/generated/services/update-check.ts
|
|
2579
|
+
import { execFile } from "child_process";
|
|
2580
|
+
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
2581
|
+
import { existsSync as existsSync2 } from "fs";
|
|
2582
|
+
import { homedir } from "os";
|
|
2583
|
+
import { join as join2, dirname as dirname2, sep } from "path";
|
|
2584
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2585
|
+
function isLinkedDevInstall() {
|
|
2586
|
+
try {
|
|
2587
|
+
let dir = dirname2(fileURLToPath2(import.meta.url));
|
|
2588
|
+
for (let i = 0; i < 12; i++) {
|
|
2589
|
+
if (dir.split(sep).includes("node_modules")) return false;
|
|
2590
|
+
if (existsSync2(join2(dir, ".git"))) return true;
|
|
2591
|
+
const parent = dirname2(dir);
|
|
2592
|
+
if (parent === dir) break;
|
|
2593
|
+
dir = parent;
|
|
2594
|
+
}
|
|
2595
|
+
} catch {
|
|
2596
|
+
}
|
|
2597
|
+
return false;
|
|
2598
|
+
}
|
|
2599
|
+
function parseSemver(raw) {
|
|
2600
|
+
if (typeof raw !== "string") return null;
|
|
2601
|
+
const cleaned = raw.trim().replace(/^v/i, "");
|
|
2602
|
+
if (!cleaned) return null;
|
|
2603
|
+
const m = cleaned.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
2604
|
+
if (!m) return null;
|
|
2605
|
+
const major = parseInt(m[1], 10);
|
|
2606
|
+
const minor = m[2] != null ? parseInt(m[2], 10) : 0;
|
|
2607
|
+
const patch = m[3] != null ? parseInt(m[3], 10) : 0;
|
|
2608
|
+
const pre = m[4] || "";
|
|
2609
|
+
return [major, minor, patch, pre ? 1 : 0];
|
|
2610
|
+
}
|
|
2611
|
+
function extractPrerelease(raw) {
|
|
2612
|
+
if (typeof raw !== "string") return "";
|
|
2613
|
+
const body = raw.trim().replace(/^v/i, "").replace(/\+.*$/, "");
|
|
2614
|
+
const dash = body.indexOf("-");
|
|
2615
|
+
return dash >= 0 ? body.slice(dash + 1) : "";
|
|
2616
|
+
}
|
|
2617
|
+
function comparePrerelease(a, b) {
|
|
2618
|
+
const ax = a.split(".");
|
|
2619
|
+
const bx = b.split(".");
|
|
2620
|
+
const n = Math.max(ax.length, bx.length);
|
|
2621
|
+
for (let i = 0; i < n; i++) {
|
|
2622
|
+
const ai = ax[i];
|
|
2623
|
+
const bi = bx[i];
|
|
2624
|
+
if (ai === void 0) return -1;
|
|
2625
|
+
if (bi === void 0) return 1;
|
|
2626
|
+
const aNum = /^[0-9]+$/.test(ai);
|
|
2627
|
+
const bNum = /^[0-9]+$/.test(bi);
|
|
2628
|
+
if (aNum && bNum) {
|
|
2629
|
+
const d = parseInt(ai, 10) - parseInt(bi, 10);
|
|
2630
|
+
if (d !== 0) return d < 0 ? -1 : 1;
|
|
2631
|
+
} else if (aNum !== bNum) {
|
|
2632
|
+
return aNum ? -1 : 1;
|
|
2633
|
+
} else if (ai !== bi) {
|
|
2634
|
+
return ai < bi ? -1 : 1;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
return 0;
|
|
2638
|
+
}
|
|
2639
|
+
function semverGte(a, b) {
|
|
2640
|
+
const pa = parseSemver(a);
|
|
2641
|
+
const pb = parseSemver(b);
|
|
2642
|
+
if (!pa || !pb) return false;
|
|
2643
|
+
for (let i = 0; i < 3; i++) {
|
|
2644
|
+
if (pa[i] !== pb[i]) return pa[i] > pb[i];
|
|
2645
|
+
}
|
|
2646
|
+
const preA = extractPrerelease(a);
|
|
2647
|
+
const preB = extractPrerelease(b);
|
|
2648
|
+
if (!preA && !preB) return true;
|
|
2649
|
+
if (!preA) return true;
|
|
2650
|
+
if (!preB) return false;
|
|
2651
|
+
return comparePrerelease(preA, preB) >= 0;
|
|
2652
|
+
}
|
|
2653
|
+
async function runNpmViewVersion(packageName, timeoutMs) {
|
|
2654
|
+
return await new Promise((resolve) => {
|
|
2655
|
+
let settled = false;
|
|
2656
|
+
const finish = (val) => {
|
|
2657
|
+
if (!settled) {
|
|
2658
|
+
settled = true;
|
|
2659
|
+
resolve(val);
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
let child;
|
|
2663
|
+
try {
|
|
2664
|
+
child = execFile("npm", ["view", packageName, "version"], { timeout: timeoutMs }, (err, stdout) => {
|
|
2665
|
+
if (err) return finish("");
|
|
2666
|
+
finish(typeof stdout === "string" ? stdout.trim() : "");
|
|
2667
|
+
});
|
|
2668
|
+
} catch {
|
|
2669
|
+
return finish("");
|
|
2670
|
+
}
|
|
2671
|
+
child.on("error", () => finish(""));
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
async function checkForUpdate(currentVersion, opts) {
|
|
2675
|
+
const packageName = opts && opts.packageName || "@kernlang/agon";
|
|
2676
|
+
const timeoutMs = opts && typeof opts.registryTimeoutMs === "number" ? opts.registryTimeoutMs : 5e3;
|
|
2677
|
+
const result = {
|
|
2678
|
+
currentVersion,
|
|
2679
|
+
latestVersion: currentVersion,
|
|
2680
|
+
hasUpdate: false,
|
|
2681
|
+
releaseTag: "latest",
|
|
2682
|
+
error: ""
|
|
2683
|
+
};
|
|
2684
|
+
let raw;
|
|
2685
|
+
try {
|
|
2686
|
+
raw = await runNpmViewVersion(packageName, timeoutMs);
|
|
2687
|
+
} catch (err) {
|
|
2688
|
+
const e = err;
|
|
2689
|
+
result.error = e && e.message ? e.message : String(e);
|
|
2690
|
+
return result;
|
|
2691
|
+
}
|
|
2692
|
+
if (!raw) {
|
|
2693
|
+
result.error = "registry-unreachable";
|
|
2694
|
+
return result;
|
|
2695
|
+
}
|
|
2696
|
+
const normalized = raw.replace(/^v/i, "");
|
|
2697
|
+
if (!parseSemver(normalized)) {
|
|
2698
|
+
result.error = "malformed-registry-version";
|
|
2699
|
+
result.latestVersion = raw;
|
|
2700
|
+
return result;
|
|
2701
|
+
}
|
|
2702
|
+
result.latestVersion = normalized;
|
|
2703
|
+
result.hasUpdate = semverGte(normalized, currentVersion) && normalized !== currentVersion;
|
|
2704
|
+
return result;
|
|
2705
|
+
}
|
|
2706
|
+
function updateStatePath() {
|
|
2707
|
+
const home = getAgonHome ? getAgonHome() : join2(homedir(), ".agon");
|
|
2708
|
+
return Promise.resolve(join2(home, "update-state.json"));
|
|
2709
|
+
}
|
|
2710
|
+
async function loadDismissedVersion() {
|
|
2711
|
+
try {
|
|
2712
|
+
const p = await updateStatePath();
|
|
2713
|
+
const raw = await readFile(p, "utf-8");
|
|
2714
|
+
const data = JSON.parse(raw);
|
|
2715
|
+
return typeof data === "object" && data && typeof data.dismissedFor === "string" ? data.dismissedFor : "";
|
|
2716
|
+
} catch {
|
|
2717
|
+
return "";
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
async function saveDismissedVersion(version) {
|
|
2721
|
+
try {
|
|
2722
|
+
const home = getAgonHome ? getAgonHome() : join2(homedir(), ".agon");
|
|
2723
|
+
await mkdir(home, { recursive: true });
|
|
2724
|
+
const p = join2(home, "update-state.json");
|
|
2725
|
+
const payload = JSON.stringify({ dismissedFor: version, lastChecked: Date.now() });
|
|
2726
|
+
await writeFile(p, payload, "utf-8");
|
|
2727
|
+
} catch {
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
// src/generated/commands/update.ts
|
|
2732
|
+
var DEFAULT_PACKAGE = "@kernlang/agon";
|
|
2733
|
+
var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2734
|
+
var RESTART_DELAY_MS = 1500;
|
|
2735
|
+
function buildNpmArgs(packageSpec) {
|
|
2736
|
+
return ["install", "-g", packageSpec];
|
|
2737
|
+
}
|
|
2738
|
+
async function runNpmInstall(packageSpec, timeoutMs) {
|
|
2739
|
+
const args = buildNpmArgs(packageSpec);
|
|
2740
|
+
return await new Promise((resolve) => {
|
|
2741
|
+
let settled = false;
|
|
2742
|
+
let stderr = "";
|
|
2743
|
+
const finish = (code) => {
|
|
2744
|
+
if (!settled) {
|
|
2745
|
+
settled = true;
|
|
2746
|
+
resolve({ code, stderr });
|
|
2747
|
+
}
|
|
2748
|
+
};
|
|
2749
|
+
let child;
|
|
2750
|
+
try {
|
|
2751
|
+
child = spawn("npm", args, { stdio: ["inherit", "inherit", "pipe"] });
|
|
2752
|
+
} catch (err) {
|
|
2753
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2754
|
+
fail(`Failed to spawn npm: ${msg}`);
|
|
2755
|
+
finish(1);
|
|
2756
|
+
return;
|
|
2757
|
+
}
|
|
2758
|
+
if (child.stderr) {
|
|
2759
|
+
child.stderr.on("data", (d) => {
|
|
2760
|
+
const s = d.toString();
|
|
2761
|
+
stderr += s;
|
|
2762
|
+
process.stderr.write(s);
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2765
|
+
const timer = setTimeout(() => {
|
|
2766
|
+
try {
|
|
2767
|
+
child.kill("SIGTERM");
|
|
2768
|
+
} catch {
|
|
2769
|
+
}
|
|
2770
|
+
finish(124);
|
|
2771
|
+
}, timeoutMs);
|
|
2772
|
+
child.on("error", (err) => {
|
|
2773
|
+
clearTimeout(timer);
|
|
2774
|
+
const msg = err && err.message ? err.message : String(err);
|
|
2775
|
+
fail(`npm process error: ${msg}`);
|
|
2776
|
+
finish(1);
|
|
2777
|
+
});
|
|
2778
|
+
child.on("exit", (code) => {
|
|
2779
|
+
clearTimeout(timer);
|
|
2780
|
+
finish(typeof code === "number" ? code : 1);
|
|
2781
|
+
});
|
|
2782
|
+
});
|
|
2783
|
+
}
|
|
2784
|
+
function suggestPermissionFix(code, stderrText) {
|
|
2785
|
+
if (code === 0) return "";
|
|
2786
|
+
const blob = String(stderrText || "").toLowerCase();
|
|
2787
|
+
if (blob.includes("eacces") || blob.includes("permission denied") || blob.includes("needs to be run as root")) {
|
|
2788
|
+
return "Hint: global installs usually need elevated privileges. Re-run with `sudo npm install -g @kernlang/agon@latest`, or set npm_config_prefix to a user-writable directory.";
|
|
2789
|
+
}
|
|
2790
|
+
if (code === 124) {
|
|
2791
|
+
return "Hint: the install timed out. Check your network connection, or pass a higher --timeout.";
|
|
2792
|
+
}
|
|
2793
|
+
return "";
|
|
2794
|
+
}
|
|
2795
|
+
function announcePhase(phase, detail) {
|
|
2796
|
+
info(`${bold(phase)} ${dim(detail)}`);
|
|
2797
|
+
}
|
|
2798
|
+
async function runUpdate(latestVersion) {
|
|
2799
|
+
const version = typeof latestVersion === "string" && latestVersion.trim() ? latestVersion.trim() : "latest";
|
|
2800
|
+
const packageSpec = version === "latest" ? DEFAULT_PACKAGE : `${DEFAULT_PACKAGE}@${version}`;
|
|
2801
|
+
header(`Updating ${bold(DEFAULT_PACKAGE)} \u2192 ${bold(version)}`);
|
|
2802
|
+
announcePhase("\u25CF", `running: npm ${buildNpmArgs(packageSpec).join(" ")}`);
|
|
2803
|
+
const { code, stderr } = await runNpmInstall(packageSpec, DEFAULT_TIMEOUT_MS);
|
|
2804
|
+
if (code === 0) {
|
|
2805
|
+
success(`Updated to ${bold(version)}. Restart Agon to use the new version.`);
|
|
2806
|
+
await new Promise((r) => setTimeout(r, RESTART_DELAY_MS));
|
|
2807
|
+
try {
|
|
2808
|
+
process.exit(0);
|
|
2809
|
+
} catch {
|
|
2810
|
+
}
|
|
2811
|
+
return 0;
|
|
2812
|
+
}
|
|
2813
|
+
fail(`npm exited with code ${code}.`);
|
|
2814
|
+
const hint = suggestPermissionFix(code, stderr);
|
|
2815
|
+
if (hint) info(hint);
|
|
2816
|
+
return code;
|
|
2817
|
+
}
|
|
2818
|
+
var updateCommand = defineCommand({
|
|
2819
|
+
meta: {
|
|
2820
|
+
name: "update",
|
|
2821
|
+
description: "Update Agon to the latest (or a specific) version from npm. Streams npm output live and exits 0 on success."
|
|
2822
|
+
},
|
|
2823
|
+
args: {
|
|
2824
|
+
version: {
|
|
2825
|
+
type: "positional",
|
|
2826
|
+
description: "Specific version to install (e.g. 0.2.0). Omit to install the latest.",
|
|
2827
|
+
required: false
|
|
2828
|
+
},
|
|
2829
|
+
check: {
|
|
2830
|
+
type: "boolean",
|
|
2831
|
+
description: "Only check the registry \u2014 print the latest version and exit. No install.",
|
|
2832
|
+
default: false
|
|
2833
|
+
},
|
|
2834
|
+
"no-restart": {
|
|
2835
|
+
type: "boolean",
|
|
2836
|
+
description: "Skip the final process.exit(0) on success (for callers that want to relaunch themselves).",
|
|
2837
|
+
default: false
|
|
2838
|
+
},
|
|
2839
|
+
timeout: {
|
|
2840
|
+
type: "string",
|
|
2841
|
+
description: "Install timeout in seconds (default 300).",
|
|
2842
|
+
default: "300"
|
|
2843
|
+
}
|
|
2844
|
+
},
|
|
2845
|
+
async run({ args }) {
|
|
2846
|
+
const version = (args.version ?? "").trim() || "latest";
|
|
2847
|
+
const timeoutSec = parseInt(String(args.timeout ?? "300"), 10);
|
|
2848
|
+
const timeoutMs = (Number.isFinite(timeoutSec) && timeoutSec > 0 ? timeoutSec : 300) * 1e3;
|
|
2849
|
+
if (args.check) {
|
|
2850
|
+
const probed = await checkForUpdate(VERSION, void 0);
|
|
2851
|
+
if (probed.error && !probed.hasUpdate) {
|
|
2852
|
+
fail(`Could not reach the npm registry: ${probed.error}`);
|
|
2853
|
+
process.exit(1);
|
|
2854
|
+
return;
|
|
2855
|
+
}
|
|
2856
|
+
if (probed.hasUpdate) {
|
|
2857
|
+
info(`Update available: ${bold(probed.currentVersion)} \u2192 ${bold(probed.latestVersion)}`);
|
|
2858
|
+
info(`Run ${yellow("agon update")} to install.`);
|
|
2859
|
+
} else {
|
|
2860
|
+
success(`Already on the latest version (${bold(probed.latestVersion)}).`);
|
|
2861
|
+
}
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
const packageSpec = version === "latest" ? DEFAULT_PACKAGE : `${DEFAULT_PACKAGE}@${version}`;
|
|
2865
|
+
header(`Updating ${bold(DEFAULT_PACKAGE)} \u2192 ${bold(version)}`);
|
|
2866
|
+
announcePhase("\u25CF", `running: npm ${buildNpmArgs(packageSpec).join(" ")}`);
|
|
2867
|
+
const { code, stderr } = await runNpmInstall(packageSpec, timeoutMs);
|
|
2868
|
+
if (code !== 0) {
|
|
2869
|
+
fail(`npm exited with code ${code}.`);
|
|
2870
|
+
const hint = suggestPermissionFix(code, stderr);
|
|
2871
|
+
if (hint) info(hint);
|
|
2872
|
+
process.exit(code);
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
success(`Updated to ${bold(version)}. Restart Agon to use the new version.`);
|
|
2876
|
+
if (!args["no-restart"]) {
|
|
2877
|
+
await new Promise((r) => setTimeout(r, RESTART_DELAY_MS));
|
|
2878
|
+
try {
|
|
2879
|
+
process.exit(0);
|
|
2880
|
+
} catch {
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
});
|
|
2885
|
+
var DEFAULT_UPDATE_PACKAGE = "@kernlang/agon";
|
|
2886
|
+
|
|
2887
|
+
export {
|
|
2888
|
+
parseProseToRichLines,
|
|
2889
|
+
DiffLine,
|
|
2890
|
+
SyntaxLine,
|
|
2891
|
+
RichLineView,
|
|
2892
|
+
RenderedSegments,
|
|
2893
|
+
GradientLine,
|
|
2894
|
+
AnsiLine,
|
|
2895
|
+
contentWidth,
|
|
2896
|
+
color256toHex,
|
|
2897
|
+
engineColor,
|
|
2898
|
+
CODE_RAIL,
|
|
2899
|
+
CODE_RAIL_COLOR,
|
|
2900
|
+
MAX_CODE_LINES,
|
|
2901
|
+
PlanProposalView,
|
|
2902
|
+
EngineProgressView,
|
|
2903
|
+
DashboardView,
|
|
2904
|
+
OutputBlockView,
|
|
2905
|
+
BRAND,
|
|
2906
|
+
LOGO_LINES,
|
|
2907
|
+
VERSION,
|
|
2908
|
+
KERN_VERSION,
|
|
2909
|
+
isLinkedDevInstall,
|
|
2910
|
+
checkForUpdate,
|
|
2911
|
+
loadDismissedVersion,
|
|
2912
|
+
saveDismissedVersion,
|
|
2913
|
+
DEFAULT_PACKAGE,
|
|
2914
|
+
DEFAULT_TIMEOUT_MS,
|
|
2915
|
+
RESTART_DELAY_MS,
|
|
2916
|
+
buildNpmArgs,
|
|
2917
|
+
runNpmInstall,
|
|
2918
|
+
suggestPermissionFix,
|
|
2919
|
+
announcePhase,
|
|
2920
|
+
runUpdate,
|
|
2921
|
+
updateCommand,
|
|
2922
|
+
DEFAULT_UPDATE_PACKAGE
|
|
2923
|
+
};
|
|
2924
|
+
//# sourceMappingURL=chunk-GPYWJO2Q.js.map
|