@jaggerxtrm/pi-extensions 0.7.20 → 0.7.21
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/extensions/xtrm-ui/index.ts +16 -31
- package/package.json +1 -1
|
@@ -252,7 +252,7 @@ type PatchableToolExecutionComponent = {
|
|
|
252
252
|
type ExternalToolFrameKind = "serena" | "gitnexus" | "structured" | "process" | "external";
|
|
253
253
|
|
|
254
254
|
const PATCHED_EXTERNAL_TOOL_FRAME = "__xtrmUiExternalToolFrame";
|
|
255
|
-
const EXTERNAL_TOOL_FRAME_PATCH_VERSION =
|
|
255
|
+
const EXTERNAL_TOOL_FRAME_PATCH_VERSION = 11;
|
|
256
256
|
const ANSI_PATTERN = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
257
257
|
|
|
258
258
|
function stripAnsi(text: string): string {
|
|
@@ -326,39 +326,22 @@ function trimRenderedToolLines(lines: string[]): string[] {
|
|
|
326
326
|
return lines.slice(start, end).map((line) => line.replace(/\s+$/u, ""));
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
function externalToolBgRgb(kind: ExternalToolFrameKind): [number, number, number] {
|
|
330
|
-
const bgColors: Record<ExternalToolFrameKind, [number, number, number]> = {
|
|
331
|
-
serena: [13, 34, 49],
|
|
332
|
-
gitnexus: [31, 23, 55],
|
|
333
|
-
structured: [35, 23, 55],
|
|
334
|
-
process: [10, 42, 52],
|
|
335
|
-
external: [27, 33, 43],
|
|
336
|
-
};
|
|
337
|
-
return bgColors[kind];
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function externalToolBgColor(kind: ExternalToolFrameKind, text: string): string {
|
|
341
|
-
const [r, g, b] = externalToolBgRgb(kind);
|
|
342
|
-
return `\x1b[48;2;${r};${g};${b}m${text}\x1b[49m`;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
329
|
function externalToolBadgeColor(kind: ExternalToolFrameKind, text: string): string {
|
|
346
330
|
const bgColors: Record<ExternalToolFrameKind, [number, number, number]> = {
|
|
347
|
-
serena: [
|
|
348
|
-
gitnexus: [
|
|
349
|
-
structured: [
|
|
350
|
-
process: [
|
|
351
|
-
external: [
|
|
331
|
+
serena: [82, 210, 255],
|
|
332
|
+
gitnexus: [178, 154, 255],
|
|
333
|
+
structured: [205, 166, 255],
|
|
334
|
+
process: [92, 226, 255],
|
|
335
|
+
external: [178, 190, 210],
|
|
352
336
|
};
|
|
353
337
|
const [badgeR, badgeG, badgeB] = bgColors[kind];
|
|
354
|
-
|
|
355
|
-
return `\x1b[1m\x1b[48;2;${badgeR};${badgeG};${badgeB}m${text}\x1b[22m\x1b[48;2;${rowR};${rowG};${rowB}m`;
|
|
338
|
+
return `\x1b[38;2;3;8;12m\x1b[48;2;${badgeR};${badgeG};${badgeB}m${text}\x1b[39m\x1b[49m`;
|
|
356
339
|
}
|
|
357
340
|
|
|
358
341
|
function highlightExternalToolBadge(kind: ExternalToolFrameKind, line: string): string {
|
|
359
|
-
const match = line.match(/^(•\s+(
|
|
360
|
-
if (!match?.[1]) return line;
|
|
361
|
-
return externalToolBadgeColor(kind, match[
|
|
342
|
+
const match = line.match(/^(•\s+)(\S+)/u);
|
|
343
|
+
if (!match?.[1] || !match[2]) return line;
|
|
344
|
+
return match[1] + externalToolBadgeColor(kind, match[2]) + line.slice(match[1].length + match[2].length);
|
|
362
345
|
}
|
|
363
346
|
|
|
364
347
|
function externalToolBorderColor(kind: ExternalToolFrameKind, text: string): string {
|
|
@@ -388,9 +371,8 @@ function renderExternalToolBackgroundLines(
|
|
|
388
371
|
const visibleLines = collapsedExternalToolLines(contentLines, expanded);
|
|
389
372
|
|
|
390
373
|
return visibleLines.map((rawLine) => {
|
|
391
|
-
const line = truncateToWidth(rawLine, Math.max(1, renderWidth
|
|
392
|
-
|
|
393
|
-
return externalToolBgColor(kind, ` ${padVisible(highlighted, Math.max(1, renderWidth - 2))} `);
|
|
374
|
+
const line = truncateToWidth(rawLine, Math.max(1, renderWidth));
|
|
375
|
+
return highlightExternalToolBadge(kind, line);
|
|
394
376
|
});
|
|
395
377
|
}
|
|
396
378
|
|
|
@@ -1421,7 +1403,10 @@ function registerXtrmUiTools(pi: ExtensionAPI, getPrefs: () => XtrmUiPrefs): voi
|
|
|
1421
1403
|
|
|
1422
1404
|
pi.on("tool_result", async (event: ToolResultEvent, _ctx) => {
|
|
1423
1405
|
if (event.isError) return undefined;
|
|
1424
|
-
if (XTRM_BUILTIN_TOOLS.has(event.toolName))
|
|
1406
|
+
if (XTRM_BUILTIN_TOOLS.has(event.toolName)) {
|
|
1407
|
+
trackToolCallEnd(event.toolCallId);
|
|
1408
|
+
return undefined;
|
|
1409
|
+
}
|
|
1425
1410
|
if (!getPrefs().compactExternalToolResults) return undefined;
|
|
1426
1411
|
|
|
1427
1412
|
const text = getTextContent({ content: event.content as Array<{ type: string; text?: string }> });
|