@abacus-ai/cli 1.106.25007 → 2.0.0-canary.0

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.
Files changed (200) hide show
  1. package/.oxlintrc.json +8 -0
  2. package/dist/index.mjs +12603 -0
  3. package/package.json +7 -39
  4. package/resources/abacus.ico +0 -0
  5. package/resources/entitlements.plist +9 -0
  6. package/src/__e2e__/README.md +196 -0
  7. package/src/__e2e__/agent-interactions.e2e.test.tsx +61 -0
  8. package/src/__e2e__/cli-commands.e2e.test.tsx +77 -0
  9. package/src/__e2e__/conversation-throttle.e2e.test.ts +453 -0
  10. package/src/__e2e__/conversation.e2e.test.tsx +56 -0
  11. package/src/__e2e__/diff-preview.e2e.test.tsx +3399 -0
  12. package/src/__e2e__/file-creation.e2e.test.tsx +149 -0
  13. package/src/__e2e__/helpers/test-helpers.ts +450 -0
  14. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +34 -0
  15. package/src/__e2e__/llm-models.e2e.test.ts +402 -0
  16. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +71 -0
  17. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +167 -0
  18. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +185 -0
  19. package/src/__e2e__/repl.e2e.test.tsx +78 -0
  20. package/src/__e2e__/shell-compatibility.e2e.test.tsx +76 -0
  21. package/src/__e2e__/theme-mcp.e2e.test.tsx +98 -0
  22. package/src/__e2e__/tool-permissions.e2e.test.tsx +66 -0
  23. package/src/args.ts +22 -0
  24. package/src/components/__tests__/react-compiler.test.tsx +78 -0
  25. package/src/components/__tests__/status-indicator.test.tsx +403 -0
  26. package/src/components/composer/__tests__/bash-runner.test.tsx +263 -0
  27. package/src/components/composer/agent-mode-indicator.tsx +63 -0
  28. package/src/components/composer/bash-runner.tsx +54 -0
  29. package/src/components/composer/commands/default-commands.tsx +615 -0
  30. package/src/components/composer/commands/handler.tsx +59 -0
  31. package/src/components/composer/commands/picker.tsx +273 -0
  32. package/src/components/composer/commands/registry.ts +233 -0
  33. package/src/components/composer/commands/types.ts +33 -0
  34. package/src/components/composer/context.tsx +88 -0
  35. package/src/components/composer/file-mention-picker.tsx +83 -0
  36. package/src/components/composer/help.tsx +44 -0
  37. package/src/components/composer/index.tsx +1006 -0
  38. package/src/components/composer/mentions.ts +57 -0
  39. package/src/components/composer/message-queue.tsx +70 -0
  40. package/src/components/composer/mode-panel.tsx +35 -0
  41. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +755 -0
  42. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +1108 -0
  43. package/src/components/composer/modes/bash-handler.tsx +132 -0
  44. package/src/components/composer/modes/bash-renderer.tsx +175 -0
  45. package/src/components/composer/modes/default-handlers.tsx +33 -0
  46. package/src/components/composer/modes/index.ts +41 -0
  47. package/src/components/composer/modes/types.ts +21 -0
  48. package/src/components/composer/persistent-shell.ts +283 -0
  49. package/src/components/composer/process.ts +65 -0
  50. package/src/components/composer/types.ts +9 -0
  51. package/src/components/composer/use-mention-search.ts +68 -0
  52. package/src/components/error-boundry.tsx +60 -0
  53. package/src/components/exit-message.tsx +29 -0
  54. package/src/components/expanded-view.tsx +74 -0
  55. package/src/components/file-completion.tsx +127 -0
  56. package/src/components/header.tsx +47 -0
  57. package/src/components/logo.tsx +37 -0
  58. package/src/components/segments.tsx +356 -0
  59. package/src/components/status-indicator.tsx +306 -0
  60. package/src/components/tool-group-summary.tsx +263 -0
  61. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +312 -0
  62. package/src/components/tool-permissions/diff-preview.tsx +355 -0
  63. package/src/components/tool-permissions/index.ts +5 -0
  64. package/src/components/tool-permissions/permission-options.tsx +375 -0
  65. package/src/components/tool-permissions/permission-preview-header.tsx +57 -0
  66. package/src/components/tool-permissions/tool-permission-ui.tsx +398 -0
  67. package/src/components/tools/agent/ask-user-question.tsx +101 -0
  68. package/src/components/tools/agent/enter-plan-mode.tsx +49 -0
  69. package/src/components/tools/agent/exit-plan-mode.tsx +75 -0
  70. package/src/components/tools/agent/handoff-to-main.tsx +27 -0
  71. package/src/components/tools/agent/subagent.tsx +37 -0
  72. package/src/components/tools/agent/todo-write.tsx +104 -0
  73. package/src/components/tools/browser/close-tab.tsx +58 -0
  74. package/src/components/tools/browser/computer.tsx +70 -0
  75. package/src/components/tools/browser/get-interactive-elements.tsx +54 -0
  76. package/src/components/tools/browser/get-tab-content.tsx +51 -0
  77. package/src/components/tools/browser/navigate-to.tsx +59 -0
  78. package/src/components/tools/browser/new-tab.tsx +60 -0
  79. package/src/components/tools/browser/perform-action.tsx +63 -0
  80. package/src/components/tools/browser/refresh-tab.tsx +43 -0
  81. package/src/components/tools/browser/switch-tab.tsx +58 -0
  82. package/src/components/tools/filesystem/delete-file.tsx +104 -0
  83. package/src/components/tools/filesystem/edit.tsx +220 -0
  84. package/src/components/tools/filesystem/list-dir.tsx +78 -0
  85. package/src/components/tools/filesystem/read-file.tsx +180 -0
  86. package/src/components/tools/filesystem/upload-image.tsx +76 -0
  87. package/src/components/tools/ide/ide-diagnostics.tsx +62 -0
  88. package/src/components/tools/index.ts +91 -0
  89. package/src/components/tools/mcp/mcp-tool.tsx +158 -0
  90. package/src/components/tools/search/fetch-url.tsx +73 -0
  91. package/src/components/tools/search/file-search.tsx +78 -0
  92. package/src/components/tools/search/grep.tsx +90 -0
  93. package/src/components/tools/search/semantic-search.tsx +66 -0
  94. package/src/components/tools/search/web-search.tsx +71 -0
  95. package/src/components/tools/shared/index.tsx +48 -0
  96. package/src/components/tools/shared/zod-coercion.ts +35 -0
  97. package/src/components/tools/terminal/bash-tool-output.tsx +174 -0
  98. package/src/components/tools/terminal/get-terminal-output.tsx +85 -0
  99. package/src/components/tools/terminal/run-in-terminal.tsx +106 -0
  100. package/src/components/tools/types.ts +16 -0
  101. package/src/components/tools.tsx +66 -0
  102. package/src/components/ui/__tests__/divider.test.tsx +61 -0
  103. package/src/components/ui/__tests__/gradient.test.tsx +125 -0
  104. package/src/components/ui/__tests__/input.test.tsx +166 -0
  105. package/src/components/ui/__tests__/select.test.tsx +273 -0
  106. package/src/components/ui/__tests__/shimmer.test.tsx +99 -0
  107. package/src/components/ui/blinking-indicator.tsx +25 -0
  108. package/src/components/ui/divider.tsx +162 -0
  109. package/src/components/ui/gradient.tsx +56 -0
  110. package/src/components/ui/input.tsx +228 -0
  111. package/src/components/ui/select.tsx +151 -0
  112. package/src/components/ui/shimmer.tsx +84 -0
  113. package/src/context/agent-mode.tsx +95 -0
  114. package/src/context/extension-file.tsx +136 -0
  115. package/src/context/network-activity.tsx +45 -0
  116. package/src/context/notification.tsx +62 -0
  117. package/src/context/shell-size.tsx +49 -0
  118. package/src/context/shell-title.tsx +38 -0
  119. package/src/entrypoints/print-mode.ts +312 -0
  120. package/src/entrypoints/repl.tsx +401 -0
  121. package/src/hooks/use-agent.ts +15 -0
  122. package/src/hooks/use-api-client.ts +1 -0
  123. package/src/hooks/use-available-height.ts +8 -0
  124. package/src/hooks/use-cleanup.ts +29 -0
  125. package/src/hooks/use-interrupt-manager.ts +242 -0
  126. package/src/hooks/use-models.ts +22 -0
  127. package/src/index.ts +217 -0
  128. package/src/lib/__tests__/ansi.test.ts +255 -0
  129. package/src/lib/__tests__/cli.test.ts +122 -0
  130. package/src/lib/__tests__/commands.test.ts +325 -0
  131. package/src/lib/__tests__/constants.test.ts +15 -0
  132. package/src/lib/__tests__/focusables.test.ts +25 -0
  133. package/src/lib/__tests__/fs.test.ts +231 -0
  134. package/src/lib/__tests__/markdown.test.tsx +348 -0
  135. package/src/lib/__tests__/mcpCommandHandler.test.ts +173 -0
  136. package/src/lib/__tests__/mcpManagement.test.ts +38 -0
  137. package/src/lib/__tests__/path-paste.test.ts +144 -0
  138. package/src/lib/__tests__/path.test.ts +300 -0
  139. package/src/lib/__tests__/queries.test.ts +39 -0
  140. package/src/lib/__tests__/standaloneMcpService.test.ts +71 -0
  141. package/src/lib/__tests__/text-buffer.test.ts +328 -0
  142. package/src/lib/__tests__/text-utils.test.ts +32 -0
  143. package/src/lib/__tests__/timing.test.ts +78 -0
  144. package/src/lib/__tests__/utils.test.ts +238 -0
  145. package/src/lib/__tests__/vim-buffer-actions.test.ts +154 -0
  146. package/src/lib/ansi.ts +150 -0
  147. package/src/lib/cli-push-server.ts +112 -0
  148. package/src/lib/cli.ts +44 -0
  149. package/src/lib/clipboard.ts +226 -0
  150. package/src/lib/command-utils.ts +93 -0
  151. package/src/lib/commands.ts +270 -0
  152. package/src/lib/constants.ts +3 -0
  153. package/src/lib/extension-connection.ts +181 -0
  154. package/src/lib/focusables.ts +7 -0
  155. package/src/lib/fs.ts +533 -0
  156. package/src/lib/markdown/code-block.tsx +63 -0
  157. package/src/lib/markdown/index.ts +4 -0
  158. package/src/lib/markdown/link.tsx +19 -0
  159. package/src/lib/markdown/markdown.tsx +372 -0
  160. package/src/lib/markdown/types.ts +15 -0
  161. package/src/lib/mcpCommandHandler.ts +121 -0
  162. package/src/lib/mcpManagement.ts +44 -0
  163. package/src/lib/path-paste.ts +185 -0
  164. package/src/lib/path.ts +179 -0
  165. package/src/lib/queries.ts +15 -0
  166. package/src/lib/standaloneMcpService.ts +688 -0
  167. package/src/lib/status-utils.ts +237 -0
  168. package/src/lib/test-utils.tsx +72 -0
  169. package/src/lib/text-buffer.ts +2415 -0
  170. package/src/lib/text-utils.ts +272 -0
  171. package/src/lib/timing.ts +63 -0
  172. package/src/lib/types.ts +295 -0
  173. package/src/lib/utils.ts +182 -0
  174. package/src/lib/vim-buffer-actions.ts +732 -0
  175. package/src/providers/agent.tsx +1075 -0
  176. package/src/providers/api-client.tsx +43 -0
  177. package/src/services/logger.ts +85 -0
  178. package/src/terminal/detection.ts +187 -0
  179. package/src/terminal/exit.ts +279 -0
  180. package/src/terminal/notification.ts +83 -0
  181. package/src/terminal/progress.ts +201 -0
  182. package/src/terminal/setup.ts +797 -0
  183. package/src/terminal/suspend.ts +58 -0
  184. package/src/terminal/types.ts +51 -0
  185. package/src/theme/context.tsx +57 -0
  186. package/src/theme/index.ts +4 -0
  187. package/src/theme/themed.tsx +35 -0
  188. package/src/theme/themes.json +546 -0
  189. package/src/theme/types.ts +110 -0
  190. package/src/tools/types.ts +59 -0
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +33 -0
  192. package/src/tools/utils/tool-ui-components.tsx +631 -0
  193. package/src/tools/utils/zod-coercion.ts +35 -0
  194. package/tsconfig.json +11 -0
  195. package/tsconfig.node.json +29 -0
  196. package/tsconfig.test.json +27 -0
  197. package/tsdown.config.ts +17 -0
  198. package/vitest.config.ts +76 -0
  199. package/README.md +0 -28
  200. package/dist/index.js +0 -26
@@ -0,0 +1,62 @@
1
+ import type { ParsedToolResult } from "@codellm/agent";
2
+
3
+ import { View } from "@codellm/jar";
4
+ import React from "react";
5
+ import { z } from "zod";
6
+
7
+ import type { ToolDef, ToolStatus } from "../types.js";
8
+
9
+ import { ToolHeader, ToolResult, snakeToCamel } from "../shared/index.js";
10
+
11
+ const IdeDiagnosticsParams = z.object({
12
+ uri: z.string().optional(),
13
+ });
14
+
15
+ export const ideDiagnosticsTool: ToolDef = {
16
+ displayName: "GetDiagnostics",
17
+ getHeaderParams(input: Record<string, unknown>): string {
18
+ const uri = input?.uri as string | undefined;
19
+ return uri ? `for ${uri}` : "for all files";
20
+ },
21
+ renderUI(
22
+ rawInput: Record<string, unknown>,
23
+ status: ToolStatus,
24
+ parsedResult?: ParsedToolResult,
25
+ ): React.ReactElement {
26
+ const pr = IdeDiagnosticsParams.safeParse(snakeToCamel(rawInput));
27
+ const uri = pr.success ? pr.data.uri : undefined;
28
+ const displayParams = uri ? `for ${uri}` : "for all files";
29
+
30
+ const isExecuting = !parsedResult && (status === "executing" || status === "pending");
31
+
32
+ if (isExecuting) {
33
+ return (
34
+ <ToolHeader name="GetDiagnostics" params={displayParams} status="pending" showSpinner />
35
+ );
36
+ }
37
+
38
+ if (status === "error") {
39
+ return (
40
+ <View flexDirection="column">
41
+ <ToolHeader name="GetDiagnostics" params={displayParams} status="error" />
42
+ <ToolResult color="red">Error getting diagnostics</ToolResult>
43
+ </View>
44
+ );
45
+ }
46
+
47
+ if (!parsedResult) {
48
+ return (
49
+ <View flexDirection="column">
50
+ <ToolHeader name="GetDiagnostics" params={displayParams} status="pending" />
51
+ </View>
52
+ );
53
+ }
54
+
55
+ return (
56
+ <View flexDirection="column">
57
+ <ToolHeader name="GetDiagnostics" params={displayParams} status="success" />
58
+ <ToolResult>{parsedResult.summary}</ToolResult>
59
+ </View>
60
+ );
61
+ },
62
+ };
@@ -0,0 +1,91 @@
1
+ import type { ToolDef } from "./types.js";
2
+
3
+ // Agent tools
4
+ import { askUserQuestionTool } from "./agent/ask-user-question.js";
5
+ import { enterPlanModeTool } from "./agent/enter-plan-mode.js";
6
+ import { exitPlanModeTool } from "./agent/exit-plan-mode.js";
7
+ import { handOffToMainTool } from "./agent/handoff-to-main.js";
8
+ import { subagentTool } from "./agent/subagent.js";
9
+ import { todoWriteTool } from "./agent/todo-write.js";
10
+ import { closeTabTool } from "./browser/close-tab.js";
11
+ import { computerTool } from "./browser/computer.js";
12
+ import { getInteractiveElementsTool } from "./browser/get-interactive-elements.js";
13
+ import { getTabContentTool } from "./browser/get-tab-content.js";
14
+ // Browser tools
15
+ import { navigateToTool } from "./browser/navigate-to.js";
16
+ import { newTabTool } from "./browser/new-tab.js";
17
+ import { performActionTool } from "./browser/perform-action.js";
18
+ import { refreshTabTool } from "./browser/refresh-tab.js";
19
+ import { switchTabTool } from "./browser/switch-tab.js";
20
+ import { deleteFileTool } from "./filesystem/delete-file.js";
21
+ import { editTool } from "./filesystem/edit.js";
22
+ import { listDirTool } from "./filesystem/list-dir.js";
23
+ // Filesystem tools
24
+ import { readFileTool } from "./filesystem/read-file.js";
25
+ import { uploadImageTool } from "./filesystem/upload-image.js";
26
+ // IDE tools
27
+ import { ideDiagnosticsTool } from "./ide/ide-diagnostics.js";
28
+ import { createMcpToolDef } from "./mcp/mcp-tool.js";
29
+ import { fetchUrlTool } from "./search/fetch-url.js";
30
+ import { fileSearchTool } from "./search/file-search.js";
31
+ // Search tools
32
+ import { grepTool } from "./search/grep.js";
33
+ import { semanticSearchTool } from "./search/semantic-search.js";
34
+ import { webSearchTool } from "./search/web-search.js";
35
+ import { getTerminalOutputTool } from "./terminal/get-terminal-output.js";
36
+ // Terminal tools
37
+ import { runInTerminalTool } from "./terminal/run-in-terminal.js";
38
+
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ export const toolMap: Record<string, ToolDef<any>> = {
41
+ // Filesystem
42
+ read_file: readFileTool,
43
+ edit: editTool,
44
+ list_dir: listDirTool,
45
+ delete_file: deleteFileTool,
46
+ upload_image: uploadImageTool,
47
+
48
+ // Search
49
+ grep: grepTool,
50
+ file_search: fileSearchTool,
51
+ semantic_search_server: semanticSearchTool,
52
+ web_search: webSearchTool,
53
+ fetch_url: fetchUrlTool,
54
+
55
+ // Terminal
56
+ run_in_terminal: runInTerminalTool,
57
+ get_terminal_output: getTerminalOutputTool,
58
+
59
+ // Browser
60
+ navigate_to: navigateToTool,
61
+ new_tab: newTabTool,
62
+ close_tab: closeTabTool,
63
+ switch_active_tab: switchTabTool,
64
+ refresh_tab: refreshTabTool,
65
+ get_tab_content: getTabContentTool,
66
+ computer: computerTool,
67
+ get_interactive_elements: getInteractiveElementsTool,
68
+ perform_interactive_element_action: performActionTool,
69
+
70
+ // Agent
71
+ ask_user_question: askUserQuestionTool,
72
+ enter_plan_mode: enterPlanModeTool,
73
+ exit_plan_mode: exitPlanModeTool,
74
+ subagent: subagentTool,
75
+ hand_off_to_main: handOffToMainTool,
76
+ todo_write: todoWriteTool,
77
+
78
+ // IDE
79
+ get_diagnostics: ideDiagnosticsTool,
80
+ };
81
+
82
+ /**
83
+ * Register a dynamically-discovered MCP tool by name.
84
+ */
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ export function registerMCPTool(name: string, def?: ToolDef<any>): void {
87
+ toolMap[name] = def ?? createMcpToolDef(name);
88
+ }
89
+
90
+ export type { ToolDef } from "./types.js";
91
+ export type { ToolStatus } from "./types.js";
@@ -0,0 +1,158 @@
1
+ import type { ParsedToolResult } from "@codellm/agent";
2
+
3
+ import { View, Text } from "@codellm/jar";
4
+ import React from "react";
5
+
6
+ import type { ToolDef, ToolStatus } from "../types.js";
7
+
8
+ import { useAgent } from "../../../hooks/use-agent.js";
9
+ import { AgentStatus } from "../../../providers/agent.js";
10
+ import { ToolHeader, ToolResult } from "../shared/index.js";
11
+
12
+ function snakeToPascalCase(str: string): string {
13
+ return str
14
+ .split("_")
15
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
16
+ .join("");
17
+ }
18
+
19
+ function MCPToolUI({
20
+ toolName,
21
+ rawInput,
22
+ status,
23
+ parsedResult,
24
+ }: {
25
+ toolName: string;
26
+ rawInput: Record<string, unknown>;
27
+ status: ToolStatus;
28
+ parsedResult?: ParsedToolResult;
29
+ }) {
30
+ const { agentStatus } = useAgent();
31
+ const displayName = snakeToPascalCase(toolName);
32
+
33
+ if (status === "interrupted") {
34
+ return (
35
+ <View flexDirection="column">
36
+ <ToolHeader name={displayName} status="interrupted" />
37
+ <ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
38
+ </View>
39
+ );
40
+ }
41
+
42
+ if (status === "rejected") {
43
+ if (parsedResult?.userNote) {
44
+ return (
45
+ <View flexDirection="column">
46
+ <ToolHeader name={displayName} status="rejected" />
47
+ <ToolResult color="yellow">
48
+ Rejected · <Text italic>"{parsedResult.userNote}"</Text>
49
+ </ToolResult>
50
+ </View>
51
+ );
52
+ }
53
+ return (
54
+ <View flexDirection="column">
55
+ <ToolHeader name={displayName} status="rejected" />
56
+ <ToolResult color="yellow">Rejected</ToolResult>
57
+ </View>
58
+ );
59
+ }
60
+
61
+ if (status === "error") {
62
+ return (
63
+ <View flexDirection="column">
64
+ <ToolHeader name={displayName} status="error" />
65
+ <ToolResult color="red">
66
+ {parsedResult?.errorMessage ?? parsedResult?.summary ?? "MCP tool execution failed"}
67
+ </ToolResult>
68
+ </View>
69
+ );
70
+ }
71
+
72
+ const isWaitingForPermission =
73
+ agentStatus === AgentStatus.WaitingForToolPermission && !parsedResult;
74
+ const isExecuting =
75
+ !parsedResult &&
76
+ (agentStatus === AgentStatus.Streaming || agentStatus === AgentStatus.ExecutingTool);
77
+ const isError = parsedResult?.phase === "error";
78
+
79
+ if (isWaitingForPermission) {
80
+ return (
81
+ <View flexDirection="row" gap={1}>
82
+ <Text color="yellow">●</Text>
83
+ <Text color="cyan">{displayName}</Text>
84
+ </View>
85
+ );
86
+ }
87
+
88
+ if (isExecuting) {
89
+ return <ToolHeader name={displayName} status="pending" showSpinner />;
90
+ }
91
+
92
+ if (parsedResult) {
93
+ return (
94
+ <View flexDirection="column">
95
+ <ToolHeader name={displayName} status={isError ? "error" : "success"} />
96
+ <ToolResult color={isError ? "red" : "gray"}>
97
+ {isError
98
+ ? `Error: ${parsedResult.errorMessage ?? parsedResult.summary ?? "Tool execution failed"}`
99
+ : (parsedResult.summary ?? "Executed successfully")}
100
+ </ToolResult>
101
+ </View>
102
+ );
103
+ }
104
+
105
+ return (
106
+ <View flexDirection="column">
107
+ <ToolHeader name={displayName} status="pending" />
108
+ </View>
109
+ );
110
+ }
111
+
112
+ /**
113
+ * Create a ToolDef for a dynamically-registered MCP tool.
114
+ */
115
+ export function createMcpToolDef(toolName: string): ToolDef {
116
+ return {
117
+ displayName: snakeToPascalCase(toolName),
118
+ getHeaderParams(_input: Record<string, unknown>): string {
119
+ return "";
120
+ },
121
+ renderUI(
122
+ rawInput: Record<string, unknown>,
123
+ status: ToolStatus,
124
+ parsedResult?: ParsedToolResult,
125
+ ): React.ReactElement {
126
+ return (
127
+ <MCPToolUI
128
+ toolName={toolName}
129
+ rawInput={rawInput}
130
+ status={status}
131
+ parsedResult={parsedResult}
132
+ />
133
+ );
134
+ },
135
+ };
136
+ }
137
+
138
+ /** Default MCP ToolDef used when no specific MCP tool is registered */
139
+ export const defaultMcpTool: ToolDef = {
140
+ displayName: "MCPTool",
141
+ getHeaderParams(_input: Record<string, unknown>): string {
142
+ return "";
143
+ },
144
+ renderUI(
145
+ rawInput: Record<string, unknown>,
146
+ status: ToolStatus,
147
+ parsedResult?: ParsedToolResult,
148
+ ): React.ReactElement {
149
+ return (
150
+ <MCPToolUI
151
+ toolName="mcp_tool"
152
+ rawInput={rawInput}
153
+ status={status}
154
+ parsedResult={parsedResult}
155
+ />
156
+ );
157
+ },
158
+ };
@@ -0,0 +1,73 @@
1
+ import type { ParsedToolResult } from "@codellm/agent";
2
+
3
+ import { View } from "@codellm/jar";
4
+ import React from "react";
5
+ import { z } from "zod";
6
+
7
+ import type { ToolDef, ToolStatus } from "../types.js";
8
+
9
+ import { ToolHeader, ToolResult, snakeToCamel } from "../shared/index.js";
10
+
11
+ const fetchUrlSchema = z.object({
12
+ url: z.string(),
13
+ });
14
+
15
+ export const fetchUrlTool: ToolDef = {
16
+ displayName: "Fetch",
17
+
18
+ getHeaderParams(input: Record<string, unknown>): string {
19
+ try {
20
+ const url = (input?.url || "") as string;
21
+ return url.length > 50 ? url.substring(0, 47) + "..." : url;
22
+ } catch {
23
+ return "[unknown]";
24
+ }
25
+ },
26
+
27
+ renderUI(
28
+ rawInput: Record<string, unknown>,
29
+ status: ToolStatus,
30
+ parsedResult?: ParsedToolResult,
31
+ ): React.ReactElement {
32
+ const parseResult = fetchUrlSchema.safeParse(snakeToCamel(rawInput));
33
+ if (!parseResult.success) {
34
+ return (
35
+ <View flexDirection="column">
36
+ <ToolHeader name="Fetch" params="" status="error" />
37
+ <ToolResult color="red">Invalid params</ToolResult>
38
+ </View>
39
+ );
40
+ }
41
+ const params = parseResult.data;
42
+ const url = params.url || "";
43
+ const truncatedUrl = url.length > 50 ? url.substring(0, 47) + "..." : url;
44
+
45
+ if (status === "error") {
46
+ return (
47
+ <View flexDirection="column">
48
+ <ToolHeader name="Fetch" params={truncatedUrl} status="error" />
49
+ <ToolResult color="red">Error fetching URL</ToolResult>
50
+ </View>
51
+ );
52
+ }
53
+
54
+ if (status === "executing") {
55
+ return <ToolHeader name="Fetch" params={truncatedUrl} status="executing" showSpinner />;
56
+ }
57
+
58
+ if (!parsedResult) {
59
+ return (
60
+ <View flexDirection="column">
61
+ <ToolHeader name="Fetch" params={truncatedUrl} status="pending" />
62
+ </View>
63
+ );
64
+ }
65
+
66
+ return (
67
+ <View flexDirection="column">
68
+ <ToolHeader name="Fetch" params={truncatedUrl} status="success" />
69
+ <ToolResult>{parsedResult.summary ?? "Fetched content"}</ToolResult>
70
+ </View>
71
+ );
72
+ },
73
+ };
@@ -0,0 +1,78 @@
1
+ import type { FileSearchParsedData } from "@codellm/agent";
2
+
3
+ import { View } from "@codellm/jar";
4
+ import React from "react";
5
+ import { z } from "zod";
6
+
7
+ import type { ToolDef, ToolStatus } from "../types.js";
8
+
9
+ import { ToolHeader, ToolResult, snakeToCamel } from "../shared/index.js";
10
+
11
+ const fileSearchSchema = z.object({
12
+ query: z.string(),
13
+ includePattern: z.string().optional(),
14
+ excludePattern: z.string().optional(),
15
+ explanation: z.string().optional(),
16
+ });
17
+
18
+ export const fileSearchTool: ToolDef<FileSearchParsedData> = {
19
+ displayName: "FileSearch",
20
+
21
+ getHeaderParams(input: Record<string, unknown>): string {
22
+ try {
23
+ const query = (input?.query || "[no pattern]") as string;
24
+ return `pattern: "${query}"`;
25
+ } catch {
26
+ return "[unknown]";
27
+ }
28
+ },
29
+
30
+ renderUI(
31
+ rawInput: Record<string, unknown>,
32
+ status: ToolStatus,
33
+ parsedResult,
34
+ ): React.ReactElement {
35
+ const parseResult = fileSearchSchema.safeParse(snakeToCamel(rawInput));
36
+ if (!parseResult.success) {
37
+ return (
38
+ <View flexDirection="column">
39
+ <ToolHeader name="Search" params="" status="error" />
40
+ <ToolResult color="red">Invalid params</ToolResult>
41
+ </View>
42
+ );
43
+ }
44
+ const params = parseResult.data;
45
+ const paramParts: string[] = [`pattern: "${params.query}"`];
46
+ if (params.includePattern) paramParts.push(`path: "${params.includePattern}"`);
47
+ if (params.excludePattern) paramParts.push(`exclude: "${params.excludePattern}"`);
48
+ const searchParams = paramParts.join(", ");
49
+
50
+ if (status === "error") {
51
+ return (
52
+ <View flexDirection="column">
53
+ <ToolHeader name="Search" params={searchParams} status="error" />
54
+ <ToolResult color="red">Error searching files</ToolResult>
55
+ </View>
56
+ );
57
+ }
58
+
59
+ if (status === "executing") {
60
+ return <ToolHeader name="Search" params={searchParams} status="executing" showSpinner />;
61
+ }
62
+
63
+ if (!parsedResult) {
64
+ return (
65
+ <View flexDirection="column">
66
+ <ToolHeader name="Search" params={searchParams} status="pending" />
67
+ </View>
68
+ );
69
+ }
70
+
71
+ return (
72
+ <View flexDirection="column">
73
+ <ToolHeader name="Search" params={searchParams} status="success" />
74
+ <ToolResult>{parsedResult.summary}</ToolResult>
75
+ </View>
76
+ );
77
+ },
78
+ };
@@ -0,0 +1,90 @@
1
+ import type { GrepParsedData } from "@codellm/agent";
2
+
3
+ import { View, Text } from "@codellm/jar";
4
+ import React from "react";
5
+
6
+ import type { ToolDef, ToolStatus } from "../types.js";
7
+
8
+ import { ToolHeader, ToolResult, PreviewContent } from "../shared/index.js";
9
+
10
+ function buildSearchParams(input: Record<string, unknown>): string {
11
+ const paramParts: string[] = [];
12
+ const pattern = input?.pattern;
13
+ if (pattern) paramParts.push(`pattern: "${pattern}"`);
14
+ const path = input?.path;
15
+ if (path) paramParts.push(`path: "${path}"`);
16
+ const outputMode = input?.outputMode || input?.output_mode;
17
+ if (outputMode) paramParts.push(`outputMode: "${outputMode}"`);
18
+ const glob = input?.glob;
19
+ if (glob) paramParts.push(`glob: "${glob}"`);
20
+ const caseInsensitive = input?.["-i"];
21
+ if (caseInsensitive) paramParts.push("case-insensitive");
22
+ return paramParts.length > 0 ? paramParts.join(", ") : "[no pattern]";
23
+ }
24
+
25
+ export const grepTool: ToolDef<GrepParsedData> = {
26
+ displayName: "Search",
27
+
28
+ getHeaderParams(input: Record<string, unknown>): string {
29
+ try {
30
+ return buildSearchParams(input);
31
+ } catch {
32
+ return "[unknown]";
33
+ }
34
+ },
35
+
36
+ renderUI(
37
+ rawInput: Record<string, unknown>,
38
+ status: ToolStatus,
39
+ parsedResult,
40
+ ): React.ReactElement {
41
+ const searchParams = buildSearchParams(rawInput);
42
+
43
+ if (status === "error") {
44
+ return (
45
+ <View flexDirection="column">
46
+ <ToolHeader name="Search" params={searchParams} status="error" />
47
+ <ToolResult color="red">Error searching content</ToolResult>
48
+ </View>
49
+ );
50
+ }
51
+
52
+ if (status === "executing") {
53
+ return <ToolHeader name="Search" params={searchParams} status="executing" showSpinner />;
54
+ }
55
+
56
+ if (!parsedResult) {
57
+ return (
58
+ <View flexDirection="column">
59
+ <ToolHeader name="Search" params={searchParams} status="pending" />
60
+ </View>
61
+ );
62
+ }
63
+
64
+ const matchesArray = parsedResult.data.matches ?? [];
65
+ const MAX_DISPLAY = 10;
66
+ const displayMatches = matchesArray.slice(0, MAX_DISPLAY);
67
+ const hiddenCount = matchesArray.length - displayMatches.length;
68
+
69
+ return (
70
+ <View flexDirection="column">
71
+ <ToolHeader name="Search" params={searchParams} status="success" />
72
+ <ToolResult>{parsedResult.summary}</ToolResult>
73
+ {matchesArray.length > 0 && (
74
+ <PreviewContent>
75
+ {displayMatches.map((match, idx) => (
76
+ <Text key={idx} dimColor>
77
+ {match}
78
+ </Text>
79
+ ))}
80
+ {hiddenCount > 0 && (
81
+ <Text dimColor>
82
+ … +{hiddenCount} more match{hiddenCount !== 1 ? "es" : ""}
83
+ </Text>
84
+ )}
85
+ </PreviewContent>
86
+ )}
87
+ </View>
88
+ );
89
+ },
90
+ };
@@ -0,0 +1,66 @@
1
+ import type { ParsedToolResult } from "@codellm/agent";
2
+
3
+ import { View } from "@codellm/jar";
4
+ import React from "react";
5
+ import { z } from "zod";
6
+
7
+ import type { ToolDef, ToolStatus } from "../types.js";
8
+
9
+ import { ToolHeader, ToolResult, snakeToCamel } from "../shared/index.js";
10
+
11
+ const semanticSearchSchema = z.object({
12
+ query: z.string(),
13
+ command: z.string().optional(),
14
+ explanation: z.string().optional(),
15
+ });
16
+
17
+ export const semanticSearchTool: ToolDef = {
18
+ displayName: "Search",
19
+
20
+ getHeaderParams(input: Record<string, unknown>): string {
21
+ try {
22
+ const query = (input?.query || "") as string;
23
+ return `"${query}"`;
24
+ } catch {
25
+ return "[unknown]";
26
+ }
27
+ },
28
+
29
+ renderUI(
30
+ rawInput: Record<string, unknown>,
31
+ status: ToolStatus,
32
+ _parsedResult?: ParsedToolResult,
33
+ ): React.ReactElement {
34
+ const parseResult = semanticSearchSchema.safeParse(snakeToCamel(rawInput));
35
+ if (!parseResult.success) {
36
+ return (
37
+ <View flexDirection="column">
38
+ <ToolHeader name="Search" params="" status="error" />
39
+ <ToolResult color="red">Invalid params</ToolResult>
40
+ </View>
41
+ );
42
+ }
43
+ const params = parseResult.data;
44
+ const searchParams = `"${params.query}"`;
45
+
46
+ if (status === "error") {
47
+ return (
48
+ <View flexDirection="column">
49
+ <ToolHeader name="Search" params={searchParams} status="error" />
50
+ <ToolResult color="red">Error performing semantic search</ToolResult>
51
+ </View>
52
+ );
53
+ }
54
+
55
+ if (status === "executing") {
56
+ return <ToolHeader name="Search" params={searchParams} status="executing" showSpinner />;
57
+ }
58
+
59
+ return (
60
+ <View flexDirection="column">
61
+ <ToolHeader name="Search" params={searchParams} status="success" />
62
+ <ToolResult>Completed</ToolResult>
63
+ </View>
64
+ );
65
+ },
66
+ };
@@ -0,0 +1,71 @@
1
+ import type { ParsedToolResult } from "@codellm/agent";
2
+
3
+ import { View } from "@codellm/jar";
4
+ import React from "react";
5
+ import { z } from "zod";
6
+
7
+ import type { ToolDef, ToolStatus } from "../types.js";
8
+
9
+ import { ToolHeader, ToolResult, snakeToCamel } from "../shared/index.js";
10
+
11
+ const webSearchSchema = z.object({
12
+ searchTerm: z.string(),
13
+ query: z.string().optional(),
14
+ explanation: z.string().optional(),
15
+ });
16
+
17
+ export const webSearchTool: ToolDef = {
18
+ displayName: "WebSearch",
19
+
20
+ getHeaderParams(input: Record<string, unknown>): string {
21
+ try {
22
+ const searchTerm = (input?.searchTerm ||
23
+ input?.search_term ||
24
+ input?.query ||
25
+ "[no query]") as string;
26
+ return `"${searchTerm}"`;
27
+ } catch {
28
+ return "[unknown]";
29
+ }
30
+ },
31
+
32
+ renderUI(
33
+ rawInput: Record<string, unknown>,
34
+ status: ToolStatus,
35
+ _parsedResult?: ParsedToolResult,
36
+ ): React.ReactElement {
37
+ const parseResult = webSearchSchema.safeParse(snakeToCamel(rawInput));
38
+ if (!parseResult.success) {
39
+ return (
40
+ <View flexDirection="column">
41
+ <ToolHeader name="WebSearch" params="" status="error" />
42
+ <ToolResult color="red">Invalid params</ToolResult>
43
+ </View>
44
+ );
45
+ }
46
+ const params = parseResult.data;
47
+ const searchTerm = params.searchTerm || params.query || "";
48
+ const truncatedTerm = searchTerm.length > 40 ? searchTerm.substring(0, 37) + "..." : searchTerm;
49
+ const searchParams = `"${truncatedTerm}"`;
50
+
51
+ if (status === "error") {
52
+ return (
53
+ <View flexDirection="column">
54
+ <ToolHeader name="WebSearch" params={searchParams} status="error" />
55
+ <ToolResult color="red">Error performing web search</ToolResult>
56
+ </View>
57
+ );
58
+ }
59
+
60
+ if (status === "executing") {
61
+ return <ToolHeader name="WebSearch" params={searchParams} status="executing" showSpinner />;
62
+ }
63
+
64
+ return (
65
+ <View flexDirection="column">
66
+ <ToolHeader name="WebSearch" params={searchParams} status="success" />
67
+ <ToolResult>Found results</ToolResult>
68
+ </View>
69
+ );
70
+ },
71
+ };