@abacus-ai/cli 2.0.0-canary.1 → 2.0.0-canary.3

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 (197) hide show
  1. package/dist/index.mjs +450 -422
  2. package/package.json +4 -1
  3. package/.oxlintrc.json +0 -8
  4. package/resources/abacus.ico +0 -0
  5. package/resources/entitlements.plist +0 -9
  6. package/src/__e2e__/README.md +0 -196
  7. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  8. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  9. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  10. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  11. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  12. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  13. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  14. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  15. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  16. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  17. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  18. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  19. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  20. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  21. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  22. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  23. package/src/args.ts +0 -22
  24. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  25. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  26. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  27. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  28. package/src/components/composer/bash-runner.tsx +0 -54
  29. package/src/components/composer/commands/default-commands.tsx +0 -615
  30. package/src/components/composer/commands/handler.tsx +0 -59
  31. package/src/components/composer/commands/picker.tsx +0 -273
  32. package/src/components/composer/commands/registry.ts +0 -233
  33. package/src/components/composer/commands/types.ts +0 -33
  34. package/src/components/composer/context.tsx +0 -88
  35. package/src/components/composer/file-mention-picker.tsx +0 -83
  36. package/src/components/composer/help.tsx +0 -44
  37. package/src/components/composer/index.tsx +0 -1007
  38. package/src/components/composer/mentions.ts +0 -57
  39. package/src/components/composer/message-queue.tsx +0 -70
  40. package/src/components/composer/mode-panel.tsx +0 -35
  41. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  42. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  43. package/src/components/composer/modes/bash-handler.tsx +0 -132
  44. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  45. package/src/components/composer/modes/default-handlers.tsx +0 -33
  46. package/src/components/composer/modes/index.ts +0 -41
  47. package/src/components/composer/modes/types.ts +0 -21
  48. package/src/components/composer/persistent-shell.ts +0 -283
  49. package/src/components/composer/process.ts +0 -65
  50. package/src/components/composer/types.ts +0 -9
  51. package/src/components/composer/use-mention-search.ts +0 -68
  52. package/src/components/error-boundry.tsx +0 -60
  53. package/src/components/exit-message.tsx +0 -29
  54. package/src/components/expanded-view.tsx +0 -74
  55. package/src/components/file-completion.tsx +0 -127
  56. package/src/components/header.tsx +0 -47
  57. package/src/components/logo.tsx +0 -37
  58. package/src/components/segments.tsx +0 -356
  59. package/src/components/status-indicator.tsx +0 -306
  60. package/src/components/tool-group-summary.tsx +0 -263
  61. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  62. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  63. package/src/components/tool-permissions/index.ts +0 -5
  64. package/src/components/tool-permissions/permission-options.tsx +0 -401
  65. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  66. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  67. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  68. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  69. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  70. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  71. package/src/components/tools/agent/subagent.tsx +0 -37
  72. package/src/components/tools/agent/todo-write.tsx +0 -104
  73. package/src/components/tools/browser/close-tab.tsx +0 -58
  74. package/src/components/tools/browser/computer.tsx +0 -70
  75. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  76. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  77. package/src/components/tools/browser/navigate-to.tsx +0 -59
  78. package/src/components/tools/browser/new-tab.tsx +0 -60
  79. package/src/components/tools/browser/perform-action.tsx +0 -63
  80. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  81. package/src/components/tools/browser/switch-tab.tsx +0 -58
  82. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  83. package/src/components/tools/filesystem/edit.tsx +0 -220
  84. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  85. package/src/components/tools/filesystem/read-file.tsx +0 -180
  86. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  87. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  88. package/src/components/tools/index.ts +0 -91
  89. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  90. package/src/components/tools/search/fetch-url.tsx +0 -73
  91. package/src/components/tools/search/file-search.tsx +0 -78
  92. package/src/components/tools/search/grep.tsx +0 -90
  93. package/src/components/tools/search/semantic-search.tsx +0 -66
  94. package/src/components/tools/search/web-search.tsx +0 -71
  95. package/src/components/tools/shared/index.tsx +0 -48
  96. package/src/components/tools/shared/zod-coercion.ts +0 -35
  97. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  98. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  99. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  100. package/src/components/tools/types.ts +0 -16
  101. package/src/components/tools.tsx +0 -68
  102. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  103. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  104. package/src/components/ui/__tests__/input.test.tsx +0 -166
  105. package/src/components/ui/__tests__/select.test.tsx +0 -273
  106. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  107. package/src/components/ui/blinking-indicator.tsx +0 -27
  108. package/src/components/ui/divider.tsx +0 -162
  109. package/src/components/ui/gradient.tsx +0 -56
  110. package/src/components/ui/input.tsx +0 -228
  111. package/src/components/ui/select.tsx +0 -151
  112. package/src/components/ui/shimmer.tsx +0 -76
  113. package/src/context/agent-mode.tsx +0 -95
  114. package/src/context/extension-file.tsx +0 -136
  115. package/src/context/network-activity.tsx +0 -45
  116. package/src/context/notification.tsx +0 -62
  117. package/src/context/shell-size.tsx +0 -49
  118. package/src/context/shell-title.tsx +0 -38
  119. package/src/entrypoints/print-mode.ts +0 -312
  120. package/src/entrypoints/repl.tsx +0 -389
  121. package/src/hooks/use-agent.ts +0 -15
  122. package/src/hooks/use-api-client.ts +0 -1
  123. package/src/hooks/use-available-height.ts +0 -8
  124. package/src/hooks/use-cleanup.ts +0 -29
  125. package/src/hooks/use-interrupt-manager.ts +0 -242
  126. package/src/hooks/use-models.ts +0 -22
  127. package/src/index.ts +0 -217
  128. package/src/lib/__tests__/ansi.test.ts +0 -255
  129. package/src/lib/__tests__/cli.test.ts +0 -122
  130. package/src/lib/__tests__/commands.test.ts +0 -325
  131. package/src/lib/__tests__/constants.test.ts +0 -15
  132. package/src/lib/__tests__/focusables.test.ts +0 -25
  133. package/src/lib/__tests__/fs.test.ts +0 -231
  134. package/src/lib/__tests__/markdown.test.tsx +0 -348
  135. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  136. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  137. package/src/lib/__tests__/path-paste.test.ts +0 -144
  138. package/src/lib/__tests__/path.test.ts +0 -300
  139. package/src/lib/__tests__/queries.test.ts +0 -39
  140. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  141. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  142. package/src/lib/__tests__/text-utils.test.ts +0 -32
  143. package/src/lib/__tests__/timing.test.ts +0 -78
  144. package/src/lib/__tests__/utils.test.ts +0 -238
  145. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  146. package/src/lib/ansi.ts +0 -150
  147. package/src/lib/cli-push-server.ts +0 -112
  148. package/src/lib/cli.ts +0 -44
  149. package/src/lib/clipboard.ts +0 -226
  150. package/src/lib/command-utils.ts +0 -93
  151. package/src/lib/commands.ts +0 -270
  152. package/src/lib/constants.ts +0 -3
  153. package/src/lib/extension-connection.ts +0 -181
  154. package/src/lib/focusables.ts +0 -7
  155. package/src/lib/fs.ts +0 -533
  156. package/src/lib/markdown/code-block.tsx +0 -63
  157. package/src/lib/markdown/index.ts +0 -4
  158. package/src/lib/markdown/link.tsx +0 -19
  159. package/src/lib/markdown/markdown.tsx +0 -372
  160. package/src/lib/markdown/types.ts +0 -15
  161. package/src/lib/mcpCommandHandler.ts +0 -121
  162. package/src/lib/mcpManagement.ts +0 -44
  163. package/src/lib/path-paste.ts +0 -185
  164. package/src/lib/path.ts +0 -179
  165. package/src/lib/queries.ts +0 -15
  166. package/src/lib/standaloneMcpService.ts +0 -688
  167. package/src/lib/status-utils.ts +0 -237
  168. package/src/lib/test-utils.tsx +0 -72
  169. package/src/lib/text-buffer.ts +0 -2415
  170. package/src/lib/text-utils.ts +0 -272
  171. package/src/lib/timing.ts +0 -63
  172. package/src/lib/types.ts +0 -295
  173. package/src/lib/utils.ts +0 -182
  174. package/src/lib/vim-buffer-actions.ts +0 -732
  175. package/src/providers/agent.tsx +0 -1063
  176. package/src/providers/api-client.tsx +0 -43
  177. package/src/services/logger.ts +0 -85
  178. package/src/terminal/detection.ts +0 -187
  179. package/src/terminal/exit.ts +0 -279
  180. package/src/terminal/notification.ts +0 -83
  181. package/src/terminal/progress.ts +0 -201
  182. package/src/terminal/setup.ts +0 -797
  183. package/src/terminal/types.ts +0 -51
  184. package/src/theme/context.tsx +0 -57
  185. package/src/theme/index.ts +0 -4
  186. package/src/theme/themed.tsx +0 -35
  187. package/src/theme/themes.json +0 -546
  188. package/src/theme/types.ts +0 -110
  189. package/src/tools/types.ts +0 -59
  190. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  191. package/src/tools/utils/tool-ui-components.tsx +0 -649
  192. package/src/tools/utils/zod-coercion.ts +0 -35
  193. package/tsconfig.json +0 -16
  194. package/tsconfig.node.json +0 -29
  195. package/tsconfig.test.json +0 -27
  196. package/tsdown.config.ts +0 -17
  197. package/vitest.config.ts +0 -76
@@ -1,62 +0,0 @@
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
- };
@@ -1,91 +0,0 @@
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";
@@ -1,158 +0,0 @@
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
- };
@@ -1,73 +0,0 @@
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
- };
@@ -1,78 +0,0 @@
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
- };
@@ -1,90 +0,0 @@
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
- };
@@ -1,66 +0,0 @@
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
- };
@@ -1,71 +0,0 @@
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
- };