@bubblebrain-ai/bubble 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/agent.js +1 -1
- package/dist/clipboard.d.ts +14 -0
- package/dist/clipboard.js +132 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +22 -6
- package/dist/goal/format.js +34 -4
- package/dist/goal/store.d.ts +3 -0
- package/dist/goal/store.js +14 -1
- package/dist/goal/usage.d.ts +2 -0
- package/dist/goal/usage.js +3 -0
- package/dist/main.js +23 -42
- package/dist/model-catalog.d.ts +3 -1
- package/dist/model-catalog.js +17 -28
- package/dist/prompt/compose.js +1 -1
- package/dist/provider-anthropic.d.ts +4 -0
- package/dist/provider-anthropic.js +31 -0
- package/dist/provider-ark-responses.d.ts +17 -0
- package/dist/provider-ark-responses.js +462 -0
- package/dist/provider-transform.js +7 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +170 -27
- package/dist/slash-commands/commands.js +22 -0
- package/dist/tools/todo.js +22 -38
- package/dist/tui/detect-theme.d.ts +1 -0
- package/dist/tui/detect-theme.js +23 -0
- package/dist/tui/image-display.d.ts +13 -0
- package/dist/tui/image-display.js +49 -0
- package/dist/tui/input-history.d.ts +37 -6
- package/dist/tui/input-history.js +194 -23
- package/dist/tui/model-switch.d.ts +42 -0
- package/dist/tui/model-switch.js +55 -0
- package/dist/tui-ink/app.d.ts +32 -2
- package/dist/tui-ink/app.js +1409 -549
- package/dist/tui-ink/approval/select.js +10 -0
- package/dist/tui-ink/detect-theme.d.ts +1 -2
- package/dist/tui-ink/detect-theme.js +1 -87
- package/dist/tui-ink/display-history.d.ts +1 -0
- package/dist/tui-ink/display-history.js +11 -0
- package/dist/tui-ink/feedback-dialog.js +10 -0
- package/dist/tui-ink/feishu-setup-picker.js +10 -0
- package/dist/tui-ink/footer.d.ts +1 -0
- package/dist/tui-ink/footer.js +8 -2
- package/dist/tui-ink/input-box.d.ts +71 -9
- package/dist/tui-ink/input-box.js +359 -121
- package/dist/tui-ink/input-history.d.ts +1 -16
- package/dist/tui-ink/input-history.js +1 -79
- package/dist/tui-ink/input-queue.d.ts +12 -0
- package/dist/tui-ink/input-queue.js +17 -0
- package/dist/tui-ink/key-events.d.ts +9 -0
- package/dist/tui-ink/key-events.js +8 -0
- package/dist/tui-ink/markdown.js +1 -1
- package/dist/tui-ink/message-list.d.ts +19 -1
- package/dist/tui-ink/message-list.js +111 -32
- package/dist/tui-ink/model-picker.d.ts +25 -2
- package/dist/tui-ink/model-picker.js +237 -20
- package/dist/tui-ink/plan-confirm.js +10 -0
- package/dist/tui-ink/question-dialog.js +46 -10
- package/dist/tui-ink/run.d.ts +10 -1
- package/dist/tui-ink/run.js +27 -42
- package/dist/tui-ink/session-picker.js +3 -0
- package/dist/tui-ink/submit-dedupe.d.ts +5 -0
- package/dist/tui-ink/submit-dedupe.js +25 -0
- package/dist/tui-ink/terminal-mouse.d.ts +24 -1
- package/dist/tui-ink/terminal-mouse.js +76 -21
- package/dist/tui-ink/theme.d.ts +6 -3
- package/dist/tui-ink/theme.js +10 -4
- package/dist/tui-ink/welcome.d.ts +1 -0
- package/dist/tui-ink/welcome.js +34 -27
- package/dist/variant/variant-resolver.js +4 -1
- package/package.json +1 -5
- package/dist/tui/clipboard.d.ts +0 -1
- package/dist/tui/clipboard.js +0 -53
- package/dist/tui/escape-confirmation.d.ts +0 -15
- package/dist/tui/escape-confirmation.js +0 -30
- package/dist/tui/global-key-router.d.ts +0 -3
- package/dist/tui/global-key-router.js +0 -87
- package/dist/tui/markdown-inline.d.ts +0 -22
- package/dist/tui/markdown-inline.js +0 -68
- package/dist/tui/markdown-theme-rules.d.ts +0 -23
- package/dist/tui/markdown-theme-rules.js +0 -164
- package/dist/tui/markdown-theme.d.ts +0 -5
- package/dist/tui/markdown-theme.js +0 -27
- package/dist/tui/opencode-spinner.d.ts +0 -22
- package/dist/tui/opencode-spinner.js +0 -216
- package/dist/tui/prompt-keybindings.d.ts +0 -42
- package/dist/tui/prompt-keybindings.js +0 -35
- package/dist/tui/render-signature.d.ts +0 -1
- package/dist/tui/render-signature.js +0 -7
- package/dist/tui/run.d.ts +0 -67
- package/dist/tui/run.js +0 -10166
- package/dist/tui/sidebar-mcp.d.ts +0 -31
- package/dist/tui/sidebar-mcp.js +0 -62
- package/dist/tui/sidebar-state.d.ts +0 -12
- package/dist/tui/sidebar-state.js +0 -69
- package/dist/tui/streaming-tool-args.d.ts +0 -15
- package/dist/tui/streaming-tool-args.js +0 -30
- package/dist/tui/tool-renderers/fallback.d.ts +0 -2
- package/dist/tui/tool-renderers/fallback.js +0 -75
- package/dist/tui/tool-renderers/registry.d.ts +0 -3
- package/dist/tui/tool-renderers/registry.js +0 -11
- package/dist/tui/tool-renderers/subagent.d.ts +0 -2
- package/dist/tui/tool-renderers/subagent.js +0 -135
- package/dist/tui/tool-renderers/types.d.ts +0 -36
- package/dist/tui/tool-renderers/types.js +0 -1
- package/dist/tui/tool-renderers/write-preview.d.ts +0 -12
- package/dist/tui/tool-renderers/write-preview.js +0 -32
- package/dist/tui/tool-renderers/write.d.ts +0 -6
- package/dist/tui/tool-renderers/write.js +0 -88
- package/dist/tui/transcript-scroll.d.ts +0 -25
- package/dist/tui/transcript-scroll.js +0 -20
- package/dist/tui-ink/transcript-viewport-math.d.ts +0 -11
- package/dist/tui-ink/transcript-viewport-math.js +0 -17
- package/dist/tui-ink/transcript-viewport.d.ts +0 -24
- package/dist/tui-ink/transcript-viewport.js +0 -83
- package/dist/tui-opentui/app.d.ts +0 -54
- package/dist/tui-opentui/app.js +0 -1371
- package/dist/tui-opentui/approval/approval-dialog.d.ts +0 -15
- package/dist/tui-opentui/approval/approval-dialog.js +0 -155
- package/dist/tui-opentui/approval/diff-view.d.ts +0 -9
- package/dist/tui-opentui/approval/diff-view.js +0 -43
- package/dist/tui-opentui/approval/select.d.ts +0 -37
- package/dist/tui-opentui/approval/select.js +0 -91
- package/dist/tui-opentui/detect-theme.d.ts +0 -2
- package/dist/tui-opentui/detect-theme.js +0 -87
- package/dist/tui-opentui/display-history.d.ts +0 -56
- package/dist/tui-opentui/display-history.js +0 -130
- package/dist/tui-opentui/edit-diff.d.ts +0 -11
- package/dist/tui-opentui/edit-diff.js +0 -57
- package/dist/tui-opentui/feedback-dialog.d.ts +0 -21
- package/dist/tui-opentui/feedback-dialog.js +0 -164
- package/dist/tui-opentui/feishu-setup-picker.d.ts +0 -7
- package/dist/tui-opentui/feishu-setup-picker.js +0 -272
- package/dist/tui-opentui/file-mentions.d.ts +0 -29
- package/dist/tui-opentui/file-mentions.js +0 -174
- package/dist/tui-opentui/footer.d.ts +0 -26
- package/dist/tui-opentui/footer.js +0 -40
- package/dist/tui-opentui/image-paste.d.ts +0 -54
- package/dist/tui-opentui/image-paste.js +0 -288
- package/dist/tui-opentui/input-box.d.ts +0 -32
- package/dist/tui-opentui/input-box.js +0 -462
- package/dist/tui-opentui/input-history.d.ts +0 -16
- package/dist/tui-opentui/input-history.js +0 -79
- package/dist/tui-opentui/markdown.d.ts +0 -66
- package/dist/tui-opentui/markdown.js +0 -127
- package/dist/tui-opentui/message-list.d.ts +0 -31
- package/dist/tui-opentui/message-list.js +0 -131
- package/dist/tui-opentui/model-picker.d.ts +0 -63
- package/dist/tui-opentui/model-picker.js +0 -450
- package/dist/tui-opentui/plan-confirm.d.ts +0 -9
- package/dist/tui-opentui/plan-confirm.js +0 -124
- package/dist/tui-opentui/question-dialog.d.ts +0 -10
- package/dist/tui-opentui/question-dialog.js +0 -110
- package/dist/tui-opentui/recent-activity.d.ts +0 -8
- package/dist/tui-opentui/recent-activity.js +0 -71
- package/dist/tui-opentui/run-session-picker.d.ts +0 -10
- package/dist/tui-opentui/run-session-picker.js +0 -28
- package/dist/tui-opentui/run.d.ts +0 -38
- package/dist/tui-opentui/run.js +0 -48
- package/dist/tui-opentui/session-picker.d.ts +0 -12
- package/dist/tui-opentui/session-picker.js +0 -120
- package/dist/tui-opentui/theme.d.ts +0 -89
- package/dist/tui-opentui/theme.js +0 -157
- package/dist/tui-opentui/todos.d.ts +0 -9
- package/dist/tui-opentui/todos.js +0 -45
- package/dist/tui-opentui/trace-groups.d.ts +0 -27
- package/dist/tui-opentui/trace-groups.js +0 -455
- package/dist/tui-opentui/use-terminal-size.d.ts +0 -4
- package/dist/tui-opentui/use-terminal-size.js +0 -5
- package/dist/tui-opentui/welcome.d.ts +0 -25
- package/dist/tui-opentui/welcome.js +0 -77
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Theme for the OpenTUI TUI, structured after opencode's grayscale + semantic
|
|
3
|
-
* accent model. Bubble keeps the quiet terminal surface, blue focus color, and
|
|
4
|
-
* warm command accent instead of turning light mode into a plain gray port.
|
|
5
|
-
*
|
|
6
|
-
* The exported `Theme` shape preserves the keys consumed by the rest of the
|
|
7
|
-
* TUI so no caller needs to change.
|
|
8
|
-
*/
|
|
9
|
-
import { createContext, useContext } from "react";
|
|
10
|
-
/**
|
|
11
|
-
* 12-step grayscale + lavender accent.
|
|
12
|
-
*
|
|
13
|
-
* step1 #0a0a0a root bg
|
|
14
|
-
* step2 #141414 panel bg (dialogs, chips)
|
|
15
|
-
* step3 #1c1820 element bg (input fill, slightly purple-tinged)
|
|
16
|
-
* step4 #232028 surface (current input bg base)
|
|
17
|
-
* step5 #2a2630 raised panel
|
|
18
|
-
* step6 #3a3242 borderSubtle
|
|
19
|
-
* step7 #4a4254 border
|
|
20
|
-
* step8 #5e5570 borderActive
|
|
21
|
-
* step9 #bd91db accent / primary ← brand
|
|
22
|
-
* step10 #d4afe8 accent hover / soft
|
|
23
|
-
* step11 #808080 text muted
|
|
24
|
-
* step12 #eeeeee text
|
|
25
|
-
*/
|
|
26
|
-
export const darkTheme = {
|
|
27
|
-
user: "#8E3A52", // user messages render in accent — opencode pattern
|
|
28
|
-
agent: "#EEEEEE", // assistant messages render in full white
|
|
29
|
-
error: "#E06C75",
|
|
30
|
-
warning: "#F5A742",
|
|
31
|
-
success: "#7FD88F",
|
|
32
|
-
accent: "#8E3A52",
|
|
33
|
-
border: "#4A3A40",
|
|
34
|
-
borderActive: "#8E3A52",
|
|
35
|
-
inputBorder: "#8E3A52", // heavy left rail color
|
|
36
|
-
inputBorderDisabled: "#3A2A2F",
|
|
37
|
-
inputBg: "#1A1014", // surface — slightly raised from root
|
|
38
|
-
inputBgDisabled: "#141414",
|
|
39
|
-
inputText: "#EEEEEE",
|
|
40
|
-
inputPlaceholder: "#808080",
|
|
41
|
-
muted: "#808080",
|
|
42
|
-
dim: "#606070",
|
|
43
|
-
thinking: "#6B2A3E",
|
|
44
|
-
thinkingDim: "#808080",
|
|
45
|
-
toolName: "#808080", // tool header lines are dim (opencode pattern)
|
|
46
|
-
toolResult: "#EEEEEE",
|
|
47
|
-
toolError: "#E06C75",
|
|
48
|
-
toolPending: "#F5A742",
|
|
49
|
-
code: "#7FD88F",
|
|
50
|
-
traceAction: "#8E3A52",
|
|
51
|
-
traceCount: "#808080",
|
|
52
|
-
traceDetail: "#606070",
|
|
53
|
-
traceCommand: "#56B6C2",
|
|
54
|
-
tracePending: "#F5A742",
|
|
55
|
-
userMessageBorder: "transparent", // unused under opencode style
|
|
56
|
-
userMessageBg: "transparent",
|
|
57
|
-
userMessageText: "#8E3A52", // user message body color
|
|
58
|
-
userRail: "#8E3A52",
|
|
59
|
-
diffAdd: "#20303B",
|
|
60
|
-
diffRemove: "#37222C",
|
|
61
|
-
diffAddFg: "#4FD6BE",
|
|
62
|
-
diffRemoveFg: "#C53B53",
|
|
63
|
-
toolFile: "#7FD88F",
|
|
64
|
-
toolShell: "#F5A742",
|
|
65
|
-
toolSearch: "#56B6C2",
|
|
66
|
-
toolThink: "#6B2A3E",
|
|
67
|
-
toolNet: "#5C9CF5",
|
|
68
|
-
toolEdit: "#8E3A52",
|
|
69
|
-
brand: "#8E3A52",
|
|
70
|
-
brandSoft: "#B85574",
|
|
71
|
-
brandDeep: "#6B2A3E",
|
|
72
|
-
background: "#0A0A0A",
|
|
73
|
-
backgroundPanel: "#141414",
|
|
74
|
-
backgroundElement: "#1A1014",
|
|
75
|
-
text: "#EEEEEE",
|
|
76
|
-
textMuted: "#808080",
|
|
77
|
-
textDim: "#606070",
|
|
78
|
-
surface: "#1A1014",
|
|
79
|
-
shade: "#141414",
|
|
80
|
-
};
|
|
81
|
-
export const lightTheme = {
|
|
82
|
-
user: "#356FD2",
|
|
83
|
-
agent: "#171717",
|
|
84
|
-
error: "#B62633",
|
|
85
|
-
warning: "#8B4A00",
|
|
86
|
-
success: "#2F7D4A",
|
|
87
|
-
accent: "#8B4A00",
|
|
88
|
-
border: "#B9BDB8",
|
|
89
|
-
borderActive: "#356FD2",
|
|
90
|
-
inputBorder: "#356FD2",
|
|
91
|
-
inputBorderDisabled: "#D7DAD4",
|
|
92
|
-
inputBg: "#F1F3F0",
|
|
93
|
-
inputBgDisabled: "#E6E8E3",
|
|
94
|
-
inputText: "#171717",
|
|
95
|
-
inputPlaceholder: "#6F7377",
|
|
96
|
-
muted: "#6F7377",
|
|
97
|
-
dim: "#8B9094",
|
|
98
|
-
thinking: "#5F666D",
|
|
99
|
-
thinkingDim: "#8B9094",
|
|
100
|
-
toolName: "#495057",
|
|
101
|
-
toolResult: "#171717",
|
|
102
|
-
toolError: "#B62633",
|
|
103
|
-
toolPending: "#8B4A00",
|
|
104
|
-
code: "#2F7D4A",
|
|
105
|
-
traceAction: "#8B4A00",
|
|
106
|
-
traceCount: "#6F7377",
|
|
107
|
-
traceDetail: "#8B9094",
|
|
108
|
-
traceCommand: "#257E8A",
|
|
109
|
-
tracePending: "#8B4A00",
|
|
110
|
-
userMessageBorder: "transparent",
|
|
111
|
-
userMessageBg: "transparent",
|
|
112
|
-
userMessageText: "#234B93",
|
|
113
|
-
userRail: "#356FD2",
|
|
114
|
-
diffAdd: "#D7E8D8",
|
|
115
|
-
diffRemove: "#F7DADC",
|
|
116
|
-
diffAddFg: "#173D2D",
|
|
117
|
-
diffRemoveFg: "#5D1922",
|
|
118
|
-
toolFile: "#2F7D4A",
|
|
119
|
-
toolShell: "#257E8A",
|
|
120
|
-
toolSearch: "#356FD2",
|
|
121
|
-
toolThink: "#5F666D",
|
|
122
|
-
toolNet: "#356FD2",
|
|
123
|
-
toolEdit: "#8B4A00",
|
|
124
|
-
brand: "#8B4A00",
|
|
125
|
-
brandSoft: "#B86B15",
|
|
126
|
-
brandDeep: "#5A2F00",
|
|
127
|
-
background: "#FCFCFA",
|
|
128
|
-
backgroundPanel: "#F6F6F3",
|
|
129
|
-
backgroundElement: "#ECEDEA",
|
|
130
|
-
text: "#171717",
|
|
131
|
-
textMuted: "#6F7377",
|
|
132
|
-
textDim: "#8B9094",
|
|
133
|
-
surface: "#F1F3F0",
|
|
134
|
-
shade: "#E6E8E3",
|
|
135
|
-
};
|
|
136
|
-
const ThemeContext = createContext(darkTheme);
|
|
137
|
-
export const ThemeProvider = ThemeContext.Provider;
|
|
138
|
-
export function useTheme() {
|
|
139
|
-
return useContext(ThemeContext);
|
|
140
|
-
}
|
|
141
|
-
export function paletteFor(mode, overrides) {
|
|
142
|
-
const base = mode === "light" ? lightTheme : darkTheme;
|
|
143
|
-
if (!overrides)
|
|
144
|
-
return base;
|
|
145
|
-
const filtered = {};
|
|
146
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
147
|
-
if (typeof value === "string" && key in base) {
|
|
148
|
-
filtered[key] = value;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return { ...base, ...filtered };
|
|
152
|
-
}
|
|
153
|
-
/** opencode style: tool category is encoded by header text, not color. Keep
|
|
154
|
-
* a single accent for tool names so users get visual consistency. */
|
|
155
|
-
export function toolAccent(theme, _toolName) {
|
|
156
|
-
return theme.text;
|
|
157
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @opentui/react */
|
|
2
|
-
import React from "react";
|
|
3
|
-
import type { Todo } from "../types.js";
|
|
4
|
-
interface TodosPanelProps {
|
|
5
|
-
todos: Todo[];
|
|
6
|
-
terminalColumns: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function TodosPanel({ todos, terminalColumns }: TodosPanelProps): React.ReactNode;
|
|
9
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import { useTheme } from "./theme.js";
|
|
3
|
-
const MAX_ROWS = 8;
|
|
4
|
-
export function TodosPanel({ todos, terminalColumns }) {
|
|
5
|
-
const theme = useTheme();
|
|
6
|
-
if (todos.length === 0) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const rows = selectVisibleRows(todos);
|
|
10
|
-
const hiddenCount = todos.length - rows.length;
|
|
11
|
-
const contentWidth = Math.max(20, terminalColumns - 4);
|
|
12
|
-
return (_jsxs("box", { style: { flexDirection: "column", marginBottom: 1 }, children: [_jsx("text", { fg: theme.accent, attributes: 1, children: "\u25CF Todos" }), rows.map((todo, index) => (_jsx(TodoRow, { todo: todo, maxWidth: contentWidth }, index))), hiddenCount > 0 && (_jsxs("text", { fg: theme.muted, children: ["... ", hiddenCount, " more item", hiddenCount === 1 ? "" : "s", " hidden"] }))] }));
|
|
13
|
-
}
|
|
14
|
-
function selectVisibleRows(todos) {
|
|
15
|
-
if (todos.length <= MAX_ROWS) {
|
|
16
|
-
return todos;
|
|
17
|
-
}
|
|
18
|
-
// Prefer to show: all in_progress, the last N completed just before current, and upcoming pending.
|
|
19
|
-
const inProgressIdx = todos.findIndex((t) => t.status === "in_progress");
|
|
20
|
-
const anchor = inProgressIdx >= 0 ? inProgressIdx : todos.findIndex((t) => t.status === "pending");
|
|
21
|
-
const pivot = anchor >= 0 ? anchor : 0;
|
|
22
|
-
const half = Math.floor(MAX_ROWS / 2);
|
|
23
|
-
let start = Math.max(0, pivot - half);
|
|
24
|
-
let end = Math.min(todos.length, start + MAX_ROWS);
|
|
25
|
-
if (end - start < MAX_ROWS) {
|
|
26
|
-
start = Math.max(0, end - MAX_ROWS);
|
|
27
|
-
}
|
|
28
|
-
return todos.slice(start, end);
|
|
29
|
-
}
|
|
30
|
-
function TodoRow({ todo, maxWidth }) {
|
|
31
|
-
const theme = useTheme();
|
|
32
|
-
const { glyph, color, label } = statusStyle(todo, theme);
|
|
33
|
-
const text = label || todo.content;
|
|
34
|
-
const trimmed = text.length > maxWidth - 4 ? text.slice(0, maxWidth - 5) + "…" : text;
|
|
35
|
-
return (_jsx("box", { style: { height: 1 }, children: _jsxs("text", { fg: color, children: [glyph, " ", trimmed] }) }));
|
|
36
|
-
}
|
|
37
|
-
function statusStyle(todo, theme) {
|
|
38
|
-
if (todo.status === "completed") {
|
|
39
|
-
return { glyph: "✔", color: theme.dim, dim: true, label: todo.content };
|
|
40
|
-
}
|
|
41
|
-
if (todo.status === "in_progress") {
|
|
42
|
-
return { glyph: "▶", color: theme.accent, dim: false, label: todo.activeForm || todo.content };
|
|
43
|
-
}
|
|
44
|
-
return { glyph: "○", color: theme.muted, dim: false, label: todo.content };
|
|
45
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { DisplayToolCall } from "./display-history.js";
|
|
2
|
-
export type TraceGroupKind = "list" | "read" | "search" | "execute" | "edit" | "write" | "subagent" | "other";
|
|
3
|
-
export interface TraceGroup {
|
|
4
|
-
kind: TraceGroupKind;
|
|
5
|
-
title: string;
|
|
6
|
-
raw: DisplayToolCall[];
|
|
7
|
-
count?: number;
|
|
8
|
-
noun?: string;
|
|
9
|
-
command?: string;
|
|
10
|
-
items: string[];
|
|
11
|
-
previewLines: string[];
|
|
12
|
-
errorLines: string[];
|
|
13
|
-
omitted: number;
|
|
14
|
-
pending: boolean;
|
|
15
|
-
hasError: boolean;
|
|
16
|
-
errorCount: number;
|
|
17
|
-
startedAt?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface TraceGroupOptions {
|
|
20
|
-
maxItems?: number;
|
|
21
|
-
maxPreviewLines?: number;
|
|
22
|
-
homeDir?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function buildTraceGroups(toolCalls: DisplayToolCall[], options?: TraceGroupOptions): TraceGroup[];
|
|
25
|
-
export declare function formatTracePath(value: unknown, homeDir?: string): string;
|
|
26
|
-
export declare function formatElapsed(startedAt: number | undefined, now?: number): string | null;
|
|
27
|
-
export declare function traceGroupLabel(group: TraceGroup): string;
|
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
import os from "node:os";
|
|
2
|
-
import { getEditDiffDetails } from "./edit-diff.js";
|
|
3
|
-
import { formatSubagentRoute } from "../agent/subagent-route-format.js";
|
|
4
|
-
const DEFAULT_MAX_ITEMS = 6;
|
|
5
|
-
const DEFAULT_MAX_PREVIEW_LINES = 8;
|
|
6
|
-
export function buildTraceGroups(toolCalls, options = {}) {
|
|
7
|
-
const maxItems = options.maxItems ?? DEFAULT_MAX_ITEMS;
|
|
8
|
-
const maxPreviewLines = options.maxPreviewLines ?? DEFAULT_MAX_PREVIEW_LINES;
|
|
9
|
-
const homeDir = options.homeDir ?? os.homedir();
|
|
10
|
-
const groups = [];
|
|
11
|
-
let bucket = [];
|
|
12
|
-
let bucketClassifier = null;
|
|
13
|
-
const flush = () => {
|
|
14
|
-
if (bucket.length === 0 || !bucketClassifier)
|
|
15
|
-
return;
|
|
16
|
-
groups.push(buildTraceGroup(bucketClassifier, bucket, {
|
|
17
|
-
maxItems,
|
|
18
|
-
maxPreviewLines,
|
|
19
|
-
homeDir,
|
|
20
|
-
}));
|
|
21
|
-
bucket = [];
|
|
22
|
-
bucketClassifier = null;
|
|
23
|
-
};
|
|
24
|
-
for (const toolCall of toolCalls) {
|
|
25
|
-
const classifier = classifyTool(toolCall);
|
|
26
|
-
if (!classifier.groupable) {
|
|
27
|
-
flush();
|
|
28
|
-
groups.push(buildTraceGroup(classifier, [toolCall], {
|
|
29
|
-
maxItems,
|
|
30
|
-
maxPreviewLines,
|
|
31
|
-
homeDir,
|
|
32
|
-
}));
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (bucketClassifier?.bucketKey === classifier.bucketKey) {
|
|
36
|
-
bucket.push(toolCall);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
flush();
|
|
40
|
-
bucket = [toolCall];
|
|
41
|
-
bucketClassifier = classifier;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
flush();
|
|
45
|
-
return groups;
|
|
46
|
-
}
|
|
47
|
-
export function formatTracePath(value, homeDir = os.homedir()) {
|
|
48
|
-
const text = String(value ?? "").trim();
|
|
49
|
-
if (!text)
|
|
50
|
-
return "";
|
|
51
|
-
if (text === homeDir)
|
|
52
|
-
return "~";
|
|
53
|
-
if (text.startsWith(homeDir + "/"))
|
|
54
|
-
return "~" + text.slice(homeDir.length);
|
|
55
|
-
return text;
|
|
56
|
-
}
|
|
57
|
-
export function formatElapsed(startedAt, now = Date.now()) {
|
|
58
|
-
if (!startedAt)
|
|
59
|
-
return null;
|
|
60
|
-
const seconds = Math.max(0, Math.floor((now - startedAt) / 1000));
|
|
61
|
-
if (seconds < 60)
|
|
62
|
-
return `${seconds}s`;
|
|
63
|
-
const minutes = Math.floor(seconds / 60);
|
|
64
|
-
const remainder = seconds % 60;
|
|
65
|
-
return `${minutes}m${remainder.toString().padStart(2, "0")}s`;
|
|
66
|
-
}
|
|
67
|
-
export function traceGroupLabel(group) {
|
|
68
|
-
if (group.command)
|
|
69
|
-
return `${group.title} ${group.command}`;
|
|
70
|
-
if (group.count !== undefined && group.noun)
|
|
71
|
-
return `${group.title} ${group.count} ${group.noun}`;
|
|
72
|
-
return group.title;
|
|
73
|
-
}
|
|
74
|
-
function classifyTool(toolCall) {
|
|
75
|
-
if (toolCall.metadata?.kind === "subagent") {
|
|
76
|
-
return { kind: "subagent", title: "Subagents", bucketKey: `subagent:${toolCall.id}`, groupable: false };
|
|
77
|
-
}
|
|
78
|
-
switch (toolCall.name) {
|
|
79
|
-
case "glob": {
|
|
80
|
-
const pattern = String(toolCall.args.pattern ?? "");
|
|
81
|
-
const title = isDirectoryLikeGlob(pattern) ? "List Directory" : "Find Files";
|
|
82
|
-
return {
|
|
83
|
-
kind: "list",
|
|
84
|
-
title,
|
|
85
|
-
bucketKey: `list:${title}`,
|
|
86
|
-
groupable: true,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
case "read":
|
|
90
|
-
return { kind: "read", title: "Read", bucketKey: "read", groupable: true };
|
|
91
|
-
case "grep":
|
|
92
|
-
return { kind: "search", title: "Search", bucketKey: "search", groupable: true };
|
|
93
|
-
case "bash":
|
|
94
|
-
return { kind: "execute", title: "Execute", bucketKey: `execute:${toolCall.id}`, groupable: false };
|
|
95
|
-
case "edit":
|
|
96
|
-
return { kind: "edit", title: "Edit", bucketKey: `edit:${toolCall.id}`, groupable: false };
|
|
97
|
-
case "write":
|
|
98
|
-
return { kind: "write", title: "Write", bucketKey: "write", groupable: true };
|
|
99
|
-
default:
|
|
100
|
-
return {
|
|
101
|
-
kind: "other",
|
|
102
|
-
title: displayToolName(toolCall.name),
|
|
103
|
-
bucketKey: `${toolCall.name}:${toolCall.id}`,
|
|
104
|
-
groupable: false,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function buildTraceGroup(classifier, raw, options) {
|
|
109
|
-
const pending = raw.some((tool) => isToolPending(tool));
|
|
110
|
-
const startedAt = raw
|
|
111
|
-
.filter((tool) => isToolPending(tool))
|
|
112
|
-
.map((tool) => tool.startedAt)
|
|
113
|
-
.filter((value) => typeof value === "number")
|
|
114
|
-
.sort((a, b) => a - b)[0];
|
|
115
|
-
const hasError = raw.some((tool) => !!tool.isError);
|
|
116
|
-
const errorCount = raw.filter((tool) => !!tool.isError).length;
|
|
117
|
-
switch (classifier.kind) {
|
|
118
|
-
case "list":
|
|
119
|
-
return buildListGroup(classifier, raw, options, pending, startedAt, hasError, errorCount);
|
|
120
|
-
case "read":
|
|
121
|
-
return buildPathGroup(classifier, raw, options, pending, startedAt, hasError, errorCount, "files");
|
|
122
|
-
case "search":
|
|
123
|
-
return buildSearchGroup(classifier, raw, options, pending, startedAt, hasError, errorCount);
|
|
124
|
-
case "execute":
|
|
125
|
-
return buildExecuteGroup(classifier, raw[0], options, pending, startedAt, hasError, errorCount);
|
|
126
|
-
case "edit":
|
|
127
|
-
case "write":
|
|
128
|
-
return buildMutationGroup(classifier, raw, options, pending, startedAt, hasError, errorCount);
|
|
129
|
-
case "subagent":
|
|
130
|
-
return buildSubagentGroup(classifier, raw[0], options, pending, startedAt);
|
|
131
|
-
default:
|
|
132
|
-
return buildOtherGroup(classifier, raw, options, pending, startedAt, hasError, errorCount);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function buildListGroup(classifier, raw, options, pending, startedAt, hasError, errorCount) {
|
|
136
|
-
const matchCount = listMatchCount(raw);
|
|
137
|
-
const resultItems = raw.flatMap((tool) => listResultItems(tool, options.homeDir));
|
|
138
|
-
const fallbackItems = raw
|
|
139
|
-
.map((tool) => String(tool.args.pattern ?? tool.args.path ?? "").trim())
|
|
140
|
-
.filter(Boolean)
|
|
141
|
-
.map((item) => formatTracePath(item, options.homeDir));
|
|
142
|
-
const hasResultData = matchCount !== undefined || resultItems.length > 0 || raw.some((tool) => isEmptyListResult(tool.result));
|
|
143
|
-
const sourceItems = hasResultData ? resultItems : fallbackItems;
|
|
144
|
-
const { shown, omitted } = take(sourceItems, options.maxItems);
|
|
145
|
-
const count = matchCount ?? (hasResultData ? resultItems.length : sourceItems.length || raw.length);
|
|
146
|
-
const noun = hasResultData ? plural(count, "file", "files") : plural(count, "search", "searches");
|
|
147
|
-
return {
|
|
148
|
-
kind: "list",
|
|
149
|
-
title: classifier.title,
|
|
150
|
-
raw,
|
|
151
|
-
count,
|
|
152
|
-
noun,
|
|
153
|
-
items: shown,
|
|
154
|
-
previewLines: [],
|
|
155
|
-
errorLines: collectErrorLines(raw, options),
|
|
156
|
-
omitted,
|
|
157
|
-
pending,
|
|
158
|
-
hasError,
|
|
159
|
-
errorCount,
|
|
160
|
-
startedAt,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function listResultItems(tool, homeDir) {
|
|
164
|
-
const metadataPaths = Array.isArray(tool.metadata?.paths)
|
|
165
|
-
? tool.metadata.paths.filter((item) => typeof item === "string" && item.trim().length > 0)
|
|
166
|
-
: [];
|
|
167
|
-
if (metadataPaths.length > 0 || typeof tool.metadata?.matches === "number") {
|
|
168
|
-
return metadataPaths.map((line) => formatTracePath(line, homeDir));
|
|
169
|
-
}
|
|
170
|
-
return resultLines(tool.result)
|
|
171
|
-
.filter(isListResultLine)
|
|
172
|
-
.map((line) => formatTracePath(line, homeDir));
|
|
173
|
-
}
|
|
174
|
-
function listMatchCount(raw) {
|
|
175
|
-
let count = 0;
|
|
176
|
-
let sawMetadata = false;
|
|
177
|
-
for (const tool of raw) {
|
|
178
|
-
const matches = tool.metadata?.matches;
|
|
179
|
-
if (typeof matches === "number" && Number.isFinite(matches)) {
|
|
180
|
-
count += Math.max(0, matches);
|
|
181
|
-
sawMetadata = true;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return sawMetadata ? count : undefined;
|
|
185
|
-
}
|
|
186
|
-
function isEmptyListResult(result) {
|
|
187
|
-
if (result === undefined)
|
|
188
|
-
return false;
|
|
189
|
-
const lines = resultLines(result);
|
|
190
|
-
return lines.length > 0 && lines.every((line) => !isListResultLine(line));
|
|
191
|
-
}
|
|
192
|
-
function isListResultLine(line) {
|
|
193
|
-
const normalized = line.trim();
|
|
194
|
-
return !/^No files found\.?$/i.test(normalized)
|
|
195
|
-
&& !/^\[More than \d+ files, output truncated\]$/i.test(normalized);
|
|
196
|
-
}
|
|
197
|
-
function buildPathGroup(classifier, raw, options, pending, startedAt, hasError, errorCount, nounBase) {
|
|
198
|
-
const items = unique(raw
|
|
199
|
-
.map((tool) => formatTracePath(tool.args.path ?? tool.args.file ?? "", options.homeDir))
|
|
200
|
-
.filter(Boolean));
|
|
201
|
-
const { shown, omitted } = take(items, options.maxItems);
|
|
202
|
-
const count = items.length || raw.length;
|
|
203
|
-
return {
|
|
204
|
-
kind: classifier.kind,
|
|
205
|
-
title: classifier.title,
|
|
206
|
-
raw,
|
|
207
|
-
count,
|
|
208
|
-
noun: plural(count, nounBase.slice(0, -1), nounBase),
|
|
209
|
-
items: shown,
|
|
210
|
-
previewLines: [],
|
|
211
|
-
errorLines: collectErrorLines(raw, options),
|
|
212
|
-
omitted,
|
|
213
|
-
pending,
|
|
214
|
-
hasError,
|
|
215
|
-
errorCount,
|
|
216
|
-
startedAt,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
function buildSearchGroup(classifier, raw, options, pending, startedAt, hasError, errorCount) {
|
|
220
|
-
const items = raw.map((tool) => {
|
|
221
|
-
const pattern = String(tool.args.pattern ?? tool.args.query ?? "").trim();
|
|
222
|
-
const scope = String(tool.args.path ?? tool.args.glob ?? tool.args.include ?? "").trim();
|
|
223
|
-
const patternText = pattern ? `"${pattern}"` : "(pattern)";
|
|
224
|
-
return scope ? `${patternText} in ${formatTracePath(scope, options.homeDir)}` : patternText;
|
|
225
|
-
});
|
|
226
|
-
const { shown, omitted } = take(items, options.maxItems);
|
|
227
|
-
const count = raw.length;
|
|
228
|
-
return {
|
|
229
|
-
kind: "search",
|
|
230
|
-
title: classifier.title,
|
|
231
|
-
raw,
|
|
232
|
-
count,
|
|
233
|
-
noun: plural(count, "search", "searches"),
|
|
234
|
-
items: shown,
|
|
235
|
-
previewLines: [],
|
|
236
|
-
errorLines: collectErrorLines(raw, options),
|
|
237
|
-
omitted,
|
|
238
|
-
pending,
|
|
239
|
-
hasError,
|
|
240
|
-
errorCount,
|
|
241
|
-
startedAt,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function buildExecuteGroup(classifier, tool, options, pending, startedAt, hasError, errorCount) {
|
|
245
|
-
const lines = resultLines(tool.result).map((line) => formatTracePath(line, options.homeDir));
|
|
246
|
-
const { shown, omitted } = take(lines, options.maxPreviewLines);
|
|
247
|
-
return {
|
|
248
|
-
kind: "execute",
|
|
249
|
-
title: classifier.title,
|
|
250
|
-
raw: [tool],
|
|
251
|
-
command: normalizeCommand(tool.args.command ?? tool.args.cmd ?? commandFromRawArguments(tool.rawArguments)),
|
|
252
|
-
items: [],
|
|
253
|
-
previewLines: shown,
|
|
254
|
-
errorLines: [],
|
|
255
|
-
omitted,
|
|
256
|
-
pending,
|
|
257
|
-
hasError,
|
|
258
|
-
errorCount,
|
|
259
|
-
startedAt,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
function buildMutationGroup(classifier, raw, options, pending, startedAt, hasError, errorCount) {
|
|
263
|
-
const items = raw
|
|
264
|
-
.map((tool) => {
|
|
265
|
-
const path = formatTracePath(tool.args.path ?? firstMetadataPath(tool) ?? "", options.homeDir);
|
|
266
|
-
const details = tool.name === "edit" || tool.name === "apply_patch" ? getEditDiffDetails(tool) : null;
|
|
267
|
-
const suffix = details ? ` ${formatCompactEditStats(details.added, details.removed)}` : "";
|
|
268
|
-
return path ? `${path}${suffix}` : "";
|
|
269
|
-
})
|
|
270
|
-
.filter(Boolean);
|
|
271
|
-
const { shown, omitted } = take(items, options.maxItems);
|
|
272
|
-
const count = items.length || raw.length;
|
|
273
|
-
const errorPreview = hasError
|
|
274
|
-
? raw
|
|
275
|
-
.filter((tool) => tool.isError)
|
|
276
|
-
.flatMap((tool) => resultLines(tool.result).map((line) => formatTracePath(line, options.homeDir)))
|
|
277
|
-
.slice(0, options.maxPreviewLines)
|
|
278
|
-
: [];
|
|
279
|
-
return {
|
|
280
|
-
kind: classifier.kind,
|
|
281
|
-
title: classifier.title,
|
|
282
|
-
raw,
|
|
283
|
-
count,
|
|
284
|
-
noun: plural(count, "file", "files"),
|
|
285
|
-
items: shown,
|
|
286
|
-
previewLines: errorPreview,
|
|
287
|
-
errorLines: [],
|
|
288
|
-
omitted,
|
|
289
|
-
pending,
|
|
290
|
-
hasError,
|
|
291
|
-
errorCount,
|
|
292
|
-
startedAt,
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
function buildSubagentGroup(classifier, tool, options, pending, startedAt) {
|
|
296
|
-
const subagents = subagentsFromMetadata(tool);
|
|
297
|
-
const rows = subagents.length > 0
|
|
298
|
-
? subagents.map(formatSubagentRow)
|
|
299
|
-
: resultLines(tool.result).map((line) => formatTracePath(line, options.homeDir));
|
|
300
|
-
const { shown, omitted } = take(rows, options.maxPreviewLines);
|
|
301
|
-
const errorCount = subagents.filter(isFailedSubagent).length + (tool.isError ? 1 : 0);
|
|
302
|
-
return {
|
|
303
|
-
kind: "subagent",
|
|
304
|
-
title: classifier.title,
|
|
305
|
-
raw: [tool],
|
|
306
|
-
count: subagents.length || 1,
|
|
307
|
-
noun: plural(subagents.length || 1, "agent", "agents"),
|
|
308
|
-
items: [],
|
|
309
|
-
previewLines: shown,
|
|
310
|
-
errorLines: [],
|
|
311
|
-
omitted,
|
|
312
|
-
pending: pending || subagents.some((subagent) => ["queued", "running"].includes(subagent.status ?? "running")),
|
|
313
|
-
hasError: !!tool.isError || errorCount > 0,
|
|
314
|
-
errorCount,
|
|
315
|
-
startedAt,
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
function buildOtherGroup(classifier, raw, options, pending, startedAt, hasError, errorCount) {
|
|
319
|
-
const tool = raw[0];
|
|
320
|
-
const header = toolHeader(tool, options.homeDir);
|
|
321
|
-
const preview = resultLines(tool.result).map((line) => formatTracePath(line, options.homeDir));
|
|
322
|
-
const { shown, omitted } = take(preview, options.maxPreviewLines);
|
|
323
|
-
return {
|
|
324
|
-
kind: "other",
|
|
325
|
-
title: classifier.title,
|
|
326
|
-
raw,
|
|
327
|
-
count: header ? undefined : raw.length,
|
|
328
|
-
noun: header ? undefined : plural(raw.length, "call", "calls"),
|
|
329
|
-
items: header ? [header] : [],
|
|
330
|
-
previewLines: shown,
|
|
331
|
-
errorLines: [],
|
|
332
|
-
omitted,
|
|
333
|
-
pending,
|
|
334
|
-
hasError,
|
|
335
|
-
errorCount,
|
|
336
|
-
startedAt,
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
function subagentsFromMetadata(tool) {
|
|
340
|
-
const raw = tool.metadata?.subagents;
|
|
341
|
-
if (!Array.isArray(raw))
|
|
342
|
-
return [];
|
|
343
|
-
return raw.filter((item) => typeof item === "object" && item !== null);
|
|
344
|
-
}
|
|
345
|
-
function formatSubagentRow(subagent) {
|
|
346
|
-
const label = subagent.nickname || subagent.agentName || subagent.subAgentId || "subagent";
|
|
347
|
-
const role = [subagent.agentName, subagent.category ? `/${subagent.category}` : ""].join("") || "default";
|
|
348
|
-
const route = formatSubagentRoute(subagent.route);
|
|
349
|
-
const descriptor = route ? `${role} @ ${route}` : role;
|
|
350
|
-
const status = subagent.status || "running";
|
|
351
|
-
const note = subagent.error
|
|
352
|
-
|| subagent.toolNotes?.filter(Boolean).at(-1)
|
|
353
|
-
|| subagent.summary
|
|
354
|
-
|| subagent.task
|
|
355
|
-
|| "";
|
|
356
|
-
return [label, `(${descriptor})`, status, note].filter(Boolean).join(" ");
|
|
357
|
-
}
|
|
358
|
-
function isFailedSubagent(subagent) {
|
|
359
|
-
return subagent.status === "failed" || subagent.status === "blocked" || subagent.status === "cancelled";
|
|
360
|
-
}
|
|
361
|
-
function isToolPending(tool) {
|
|
362
|
-
return tool.result === undefined && tool.resultCollapsed !== true;
|
|
363
|
-
}
|
|
364
|
-
function isDirectoryLikeGlob(pattern) {
|
|
365
|
-
const normalized = pattern.trim();
|
|
366
|
-
return normalized === "" || normalized === "*" || normalized === "**" || normalized === "**/*";
|
|
367
|
-
}
|
|
368
|
-
function resultLines(result) {
|
|
369
|
-
if (result === undefined)
|
|
370
|
-
return [];
|
|
371
|
-
return result
|
|
372
|
-
.replace(/\r\n/g, "\n")
|
|
373
|
-
.split("\n")
|
|
374
|
-
.map((line) => line.trimEnd())
|
|
375
|
-
.filter((line) => line.trim() !== "");
|
|
376
|
-
}
|
|
377
|
-
function take(items, max) {
|
|
378
|
-
const shown = items.slice(0, max);
|
|
379
|
-
return { shown, omitted: Math.max(0, items.length - shown.length) };
|
|
380
|
-
}
|
|
381
|
-
function unique(items) {
|
|
382
|
-
return [...new Set(items)];
|
|
383
|
-
}
|
|
384
|
-
function collectErrorLines(raw, options) {
|
|
385
|
-
return raw
|
|
386
|
-
.filter((tool) => tool.isError)
|
|
387
|
-
.flatMap((tool) => resultLines(tool.result).map((line) => formatTraceLine(line, options.homeDir)))
|
|
388
|
-
.slice(0, options.maxPreviewLines);
|
|
389
|
-
}
|
|
390
|
-
function formatTraceLine(value, homeDir) {
|
|
391
|
-
const text = String(value ?? "").trimEnd();
|
|
392
|
-
if (!homeDir)
|
|
393
|
-
return text;
|
|
394
|
-
return text.split(homeDir + "/").join("~/").split(homeDir).join("~");
|
|
395
|
-
}
|
|
396
|
-
function plural(count, singular, pluralValue) {
|
|
397
|
-
return count === 1 ? singular : pluralValue;
|
|
398
|
-
}
|
|
399
|
-
function normalizeCommand(value) {
|
|
400
|
-
const command = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
401
|
-
return command;
|
|
402
|
-
}
|
|
403
|
-
function commandFromRawArguments(rawArguments) {
|
|
404
|
-
if (!rawArguments)
|
|
405
|
-
return "";
|
|
406
|
-
try {
|
|
407
|
-
const parsed = JSON.parse(rawArguments);
|
|
408
|
-
if (parsed && typeof parsed === "object") {
|
|
409
|
-
const command = parsed.command ?? parsed.cmd;
|
|
410
|
-
return typeof command === "string" ? command : "";
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
catch {
|
|
414
|
-
const match = rawArguments.match(/"(?:command|cmd)"\s*:\s*"((?:\\.|[^"\\])*)/);
|
|
415
|
-
if (match?.[1]) {
|
|
416
|
-
try {
|
|
417
|
-
return JSON.parse(`"${match[1]}"`);
|
|
418
|
-
}
|
|
419
|
-
catch {
|
|
420
|
-
return match[1];
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return "";
|
|
425
|
-
}
|
|
426
|
-
function displayToolName(name) {
|
|
427
|
-
if (!name)
|
|
428
|
-
return "Tool";
|
|
429
|
-
return name.charAt(0).toUpperCase() + name.slice(1).replace(/_/g, " ");
|
|
430
|
-
}
|
|
431
|
-
function toolHeader(tool, homeDir) {
|
|
432
|
-
const args = tool.args || {};
|
|
433
|
-
for (const key of ["path", "command", "pattern", "query", "url"]) {
|
|
434
|
-
const value = args[key];
|
|
435
|
-
if (value !== undefined && value !== null && String(value).trim() !== "") {
|
|
436
|
-
return formatTracePath(value, homeDir);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
const path = firstMetadataPath(tool);
|
|
440
|
-
if (path)
|
|
441
|
-
return formatTracePath(path, homeDir);
|
|
442
|
-
return undefined;
|
|
443
|
-
}
|
|
444
|
-
function firstMetadataPath(tool) {
|
|
445
|
-
const paths = tool.metadata?.paths;
|
|
446
|
-
return Array.isArray(paths) && typeof paths[0] === "string" ? paths[0] : undefined;
|
|
447
|
-
}
|
|
448
|
-
function formatCompactEditStats(added, removed) {
|
|
449
|
-
const parts = [];
|
|
450
|
-
if (added > 0)
|
|
451
|
-
parts.push(`+${added}`);
|
|
452
|
-
if (removed > 0)
|
|
453
|
-
parts.push(`-${removed}`);
|
|
454
|
-
return parts.length > 0 ? `(${parts.join(" ")})` : "";
|
|
455
|
-
}
|