2026-03-23 04:05:49 +00:00
|
|
|
|
import { yellow, green, cyan, label } from './colors.js';
|
2026-03-20 00:42:28 +00:00
|
|
|
|
export function renderToolsLine(ctx) {
|
|
|
|
|
|
const { tools } = ctx.transcript;
|
2026-03-23 04:05:49 +00:00
|
|
|
|
const colors = ctx.config?.colors;
|
2026-03-20 00:42:28 +00:00
|
|
|
|
if (tools.length === 0) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
const parts = [];
|
|
|
|
|
|
const runningTools = tools.filter((t) => t.status === 'running');
|
|
|
|
|
|
const completedTools = tools.filter((t) => t.status === 'completed' || t.status === 'error');
|
|
|
|
|
|
for (const tool of runningTools.slice(-2)) {
|
|
|
|
|
|
const target = tool.target ? truncatePath(tool.target) : '';
|
2026-03-23 04:05:49 +00:00
|
|
|
|
parts.push(`${yellow('◐')} ${cyan(tool.name)}${target ? label(`: ${target}`, colors) : ''}`);
|
2026-03-20 00:42:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
const toolCounts = new Map();
|
|
|
|
|
|
for (const tool of completedTools) {
|
|
|
|
|
|
const count = toolCounts.get(tool.name) ?? 0;
|
|
|
|
|
|
toolCounts.set(tool.name, count + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
const sortedTools = Array.from(toolCounts.entries())
|
|
|
|
|
|
.sort((a, b) => b[1] - a[1])
|
|
|
|
|
|
.slice(0, 4);
|
|
|
|
|
|
for (const [name, count] of sortedTools) {
|
2026-03-23 04:05:49 +00:00
|
|
|
|
parts.push(`${green('✓')} ${name} ${label(`×${count}`, colors)}`);
|
2026-03-20 00:42:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (parts.length === 0) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
return parts.join(' | ');
|
|
|
|
|
|
}
|
|
|
|
|
|
function truncatePath(path, maxLen = 20) {
|
|
|
|
|
|
// Normalize Windows backslashes to forward slashes for consistent display
|
|
|
|
|
|
const normalizedPath = path.replace(/\\/g, '/');
|
|
|
|
|
|
if (normalizedPath.length <= maxLen)
|
|
|
|
|
|
return normalizedPath;
|
|
|
|
|
|
// Split by forward slash (already normalized)
|
|
|
|
|
|
const parts = normalizedPath.split('/');
|
|
|
|
|
|
const filename = parts.pop() || normalizedPath;
|
|
|
|
|
|
if (filename.length >= maxLen) {
|
|
|
|
|
|
return filename.slice(0, maxLen - 3) + '...';
|
|
|
|
|
|
}
|
|
|
|
|
|
return '.../' + filename;
|
|
|
|
|
|
}
|
|
|
|
|
|
//# sourceMappingURL=tools-line.js.map
|