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

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 (198) hide show
  1. package/README.md +25 -0
  2. package/dist/index.mjs +466 -438
  3. package/package.json +4 -1
  4. package/.oxlintrc.json +0 -8
  5. package/resources/abacus.ico +0 -0
  6. package/resources/entitlements.plist +0 -9
  7. package/src/__e2e__/README.md +0 -196
  8. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  9. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  10. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  11. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  12. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  13. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  14. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  15. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  16. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  17. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  18. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  19. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  20. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  21. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  22. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  23. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  24. package/src/args.ts +0 -22
  25. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  26. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  27. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  28. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  29. package/src/components/composer/bash-runner.tsx +0 -54
  30. package/src/components/composer/commands/default-commands.tsx +0 -615
  31. package/src/components/composer/commands/handler.tsx +0 -59
  32. package/src/components/composer/commands/picker.tsx +0 -273
  33. package/src/components/composer/commands/registry.ts +0 -233
  34. package/src/components/composer/commands/types.ts +0 -33
  35. package/src/components/composer/context.tsx +0 -88
  36. package/src/components/composer/file-mention-picker.tsx +0 -83
  37. package/src/components/composer/help.tsx +0 -44
  38. package/src/components/composer/index.tsx +0 -1007
  39. package/src/components/composer/mentions.ts +0 -57
  40. package/src/components/composer/message-queue.tsx +0 -70
  41. package/src/components/composer/mode-panel.tsx +0 -35
  42. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  43. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  44. package/src/components/composer/modes/bash-handler.tsx +0 -132
  45. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  46. package/src/components/composer/modes/default-handlers.tsx +0 -33
  47. package/src/components/composer/modes/index.ts +0 -41
  48. package/src/components/composer/modes/types.ts +0 -21
  49. package/src/components/composer/persistent-shell.ts +0 -283
  50. package/src/components/composer/process.ts +0 -65
  51. package/src/components/composer/types.ts +0 -9
  52. package/src/components/composer/use-mention-search.ts +0 -68
  53. package/src/components/error-boundry.tsx +0 -60
  54. package/src/components/exit-message.tsx +0 -29
  55. package/src/components/expanded-view.tsx +0 -74
  56. package/src/components/file-completion.tsx +0 -127
  57. package/src/components/header.tsx +0 -47
  58. package/src/components/logo.tsx +0 -37
  59. package/src/components/segments.tsx +0 -356
  60. package/src/components/status-indicator.tsx +0 -306
  61. package/src/components/tool-group-summary.tsx +0 -263
  62. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  63. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  64. package/src/components/tool-permissions/index.ts +0 -5
  65. package/src/components/tool-permissions/permission-options.tsx +0 -401
  66. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  67. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  68. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  69. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  70. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  71. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  72. package/src/components/tools/agent/subagent.tsx +0 -37
  73. package/src/components/tools/agent/todo-write.tsx +0 -104
  74. package/src/components/tools/browser/close-tab.tsx +0 -58
  75. package/src/components/tools/browser/computer.tsx +0 -70
  76. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  77. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  78. package/src/components/tools/browser/navigate-to.tsx +0 -59
  79. package/src/components/tools/browser/new-tab.tsx +0 -60
  80. package/src/components/tools/browser/perform-action.tsx +0 -63
  81. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  82. package/src/components/tools/browser/switch-tab.tsx +0 -58
  83. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  84. package/src/components/tools/filesystem/edit.tsx +0 -220
  85. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  86. package/src/components/tools/filesystem/read-file.tsx +0 -180
  87. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  88. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  89. package/src/components/tools/index.ts +0 -91
  90. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  91. package/src/components/tools/search/fetch-url.tsx +0 -73
  92. package/src/components/tools/search/file-search.tsx +0 -78
  93. package/src/components/tools/search/grep.tsx +0 -90
  94. package/src/components/tools/search/semantic-search.tsx +0 -66
  95. package/src/components/tools/search/web-search.tsx +0 -71
  96. package/src/components/tools/shared/index.tsx +0 -48
  97. package/src/components/tools/shared/zod-coercion.ts +0 -35
  98. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  99. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  100. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  101. package/src/components/tools/types.ts +0 -16
  102. package/src/components/tools.tsx +0 -68
  103. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  104. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  105. package/src/components/ui/__tests__/input.test.tsx +0 -166
  106. package/src/components/ui/__tests__/select.test.tsx +0 -273
  107. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  108. package/src/components/ui/blinking-indicator.tsx +0 -27
  109. package/src/components/ui/divider.tsx +0 -162
  110. package/src/components/ui/gradient.tsx +0 -56
  111. package/src/components/ui/input.tsx +0 -228
  112. package/src/components/ui/select.tsx +0 -151
  113. package/src/components/ui/shimmer.tsx +0 -76
  114. package/src/context/agent-mode.tsx +0 -95
  115. package/src/context/extension-file.tsx +0 -136
  116. package/src/context/network-activity.tsx +0 -45
  117. package/src/context/notification.tsx +0 -62
  118. package/src/context/shell-size.tsx +0 -49
  119. package/src/context/shell-title.tsx +0 -38
  120. package/src/entrypoints/print-mode.ts +0 -312
  121. package/src/entrypoints/repl.tsx +0 -389
  122. package/src/hooks/use-agent.ts +0 -15
  123. package/src/hooks/use-api-client.ts +0 -1
  124. package/src/hooks/use-available-height.ts +0 -8
  125. package/src/hooks/use-cleanup.ts +0 -29
  126. package/src/hooks/use-interrupt-manager.ts +0 -242
  127. package/src/hooks/use-models.ts +0 -22
  128. package/src/index.ts +0 -217
  129. package/src/lib/__tests__/ansi.test.ts +0 -255
  130. package/src/lib/__tests__/cli.test.ts +0 -122
  131. package/src/lib/__tests__/commands.test.ts +0 -325
  132. package/src/lib/__tests__/constants.test.ts +0 -15
  133. package/src/lib/__tests__/focusables.test.ts +0 -25
  134. package/src/lib/__tests__/fs.test.ts +0 -231
  135. package/src/lib/__tests__/markdown.test.tsx +0 -348
  136. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  137. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  138. package/src/lib/__tests__/path-paste.test.ts +0 -144
  139. package/src/lib/__tests__/path.test.ts +0 -300
  140. package/src/lib/__tests__/queries.test.ts +0 -39
  141. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  142. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  143. package/src/lib/__tests__/text-utils.test.ts +0 -32
  144. package/src/lib/__tests__/timing.test.ts +0 -78
  145. package/src/lib/__tests__/utils.test.ts +0 -238
  146. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  147. package/src/lib/ansi.ts +0 -150
  148. package/src/lib/cli-push-server.ts +0 -112
  149. package/src/lib/cli.ts +0 -44
  150. package/src/lib/clipboard.ts +0 -226
  151. package/src/lib/command-utils.ts +0 -93
  152. package/src/lib/commands.ts +0 -270
  153. package/src/lib/constants.ts +0 -3
  154. package/src/lib/extension-connection.ts +0 -181
  155. package/src/lib/focusables.ts +0 -7
  156. package/src/lib/fs.ts +0 -533
  157. package/src/lib/markdown/code-block.tsx +0 -63
  158. package/src/lib/markdown/index.ts +0 -4
  159. package/src/lib/markdown/link.tsx +0 -19
  160. package/src/lib/markdown/markdown.tsx +0 -372
  161. package/src/lib/markdown/types.ts +0 -15
  162. package/src/lib/mcpCommandHandler.ts +0 -121
  163. package/src/lib/mcpManagement.ts +0 -44
  164. package/src/lib/path-paste.ts +0 -185
  165. package/src/lib/path.ts +0 -179
  166. package/src/lib/queries.ts +0 -15
  167. package/src/lib/standaloneMcpService.ts +0 -688
  168. package/src/lib/status-utils.ts +0 -237
  169. package/src/lib/test-utils.tsx +0 -72
  170. package/src/lib/text-buffer.ts +0 -2415
  171. package/src/lib/text-utils.ts +0 -272
  172. package/src/lib/timing.ts +0 -63
  173. package/src/lib/types.ts +0 -295
  174. package/src/lib/utils.ts +0 -182
  175. package/src/lib/vim-buffer-actions.ts +0 -732
  176. package/src/providers/agent.tsx +0 -1063
  177. package/src/providers/api-client.tsx +0 -43
  178. package/src/services/logger.ts +0 -85
  179. package/src/terminal/detection.ts +0 -187
  180. package/src/terminal/exit.ts +0 -279
  181. package/src/terminal/notification.ts +0 -83
  182. package/src/terminal/progress.ts +0 -201
  183. package/src/terminal/setup.ts +0 -797
  184. package/src/terminal/types.ts +0 -51
  185. package/src/theme/context.tsx +0 -57
  186. package/src/theme/index.ts +0 -4
  187. package/src/theme/themed.tsx +0 -35
  188. package/src/theme/themes.json +0 -546
  189. package/src/theme/types.ts +0 -110
  190. package/src/tools/types.ts +0 -59
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  192. package/src/tools/utils/tool-ui-components.tsx +0 -649
  193. package/src/tools/utils/zod-coercion.ts +0 -35
  194. package/tsconfig.json +0 -16
  195. package/tsconfig.node.json +0 -29
  196. package/tsconfig.test.json +0 -27
  197. package/tsdown.config.ts +0 -17
  198. package/vitest.config.ts +0 -76
@@ -1,104 +0,0 @@
1
- import type { ParsedToolResult } from "@codellm/agent";
2
-
3
- import { View, Text } 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, truncatePath, snakeToCamel } from "../shared/index.js";
10
-
11
- const DeleteFileToolParams = z.object({
12
- targetFile: z.string(),
13
- explanation: z.string().optional(),
14
- });
15
-
16
- export const deleteFileTool: ToolDef = {
17
- displayName: "Delete",
18
-
19
- getHeaderParams(input: Record<string, unknown>): string {
20
- try {
21
- const targetFile = (input?.targetFile || input?.target_file || "[unknown]") as string;
22
- return truncatePath(targetFile);
23
- } catch {
24
- return "[unknown]";
25
- }
26
- },
27
-
28
- renderUI(
29
- rawInput: Record<string, unknown>,
30
- status: ToolStatus,
31
- parsedResult?: ParsedToolResult,
32
- ): React.ReactElement {
33
- const parseResult = DeleteFileToolParams.safeParse(snakeToCamel(rawInput));
34
- if (!parseResult.success) {
35
- return (
36
- <View flexDirection="column">
37
- <ToolHeader name="Delete" params="" status="error" />
38
- <ToolResult color="red">Invalid params</ToolResult>
39
- </View>
40
- );
41
- }
42
- const params = parseResult.data;
43
- const { targetFile } = params;
44
- const displayParams = truncatePath(targetFile);
45
-
46
- if (status === "interrupted") {
47
- return (
48
- <View flexDirection="column">
49
- <ToolHeader name="Delete" params={displayParams} status="interrupted" />
50
- <ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
51
- </View>
52
- );
53
- }
54
-
55
- if (status === "rejected") {
56
- if (parsedResult?.userNote) {
57
- return (
58
- <View flexDirection="column">
59
- <ToolHeader name="Delete" params={displayParams} status="rejected" />
60
- <ToolResult color="yellow">
61
- Rejected · <Text italic>"{parsedResult.userNote}"</Text>
62
- </ToolResult>
63
- </View>
64
- );
65
- }
66
- return (
67
- <View flexDirection="column">
68
- <ToolHeader name="Delete" params={displayParams} status="rejected" />
69
- <ToolResult color="yellow">Rejected</ToolResult>
70
- </View>
71
- );
72
- }
73
-
74
- if (status === "error") {
75
- return (
76
- <View flexDirection="column">
77
- <ToolHeader name="Delete" params={displayParams} status="error" />
78
- <ToolResult color="red">Error deleting file</ToolResult>
79
- </View>
80
- );
81
- }
82
-
83
- const isExecuting = !parsedResult && (status === "executing" || status === "pending");
84
-
85
- if (isExecuting) {
86
- return <ToolHeader name="Delete" params={displayParams} status="pending" showSpinner />;
87
- }
88
-
89
- if (!parsedResult) {
90
- return (
91
- <View flexDirection="column">
92
- <ToolHeader name="Delete" params={displayParams} status="pending" />
93
- </View>
94
- );
95
- }
96
-
97
- return (
98
- <View flexDirection="column">
99
- <ToolHeader name="Delete" params={displayParams} status="success" />
100
- <ToolResult>Deleted</ToolResult>
101
- </View>
102
- );
103
- },
104
- };
@@ -1,220 +0,0 @@
1
- import type { EditParsedData, ParsedToolResult, ToolDisplayData } from "@codellm/agent";
2
-
3
- import { View, Text, useFocus, useInput } from "@codellm/jar";
4
- import React, { useState } from "react";
5
- import { z } from "zod";
6
-
7
- import type { ToolDef, ToolStatus } from "../types.js";
8
-
9
- import { DiffPreview } from "../../tool-permissions/diff-preview.js";
10
- import {
11
- ToolHeader,
12
- ToolResult,
13
- PreviewContent,
14
- truncatePath,
15
- CodePreview,
16
- snakeToCamel,
17
- } from "../shared/index.js";
18
- import { coerceOptionalBoolean } from "../shared/zod-coercion.js";
19
-
20
- const EditToolParams = z.object({
21
- targetFile: z.string(),
22
- codeEdit: z.string(),
23
- overwriteFile: coerceOptionalBoolean,
24
- instructions: z.string().optional(),
25
- startLine: z
26
- .union([z.number(), z.string(), z.null(), z.undefined()])
27
- .optional()
28
- .transform((val) => {
29
- if (val === null || val === undefined) return undefined;
30
- const num = Number(val);
31
- return isNaN(num) ? undefined : num;
32
- }),
33
- endLine: z
34
- .union([z.number(), z.string(), z.null(), z.undefined()])
35
- .optional()
36
- .transform((val) => {
37
- if (val === null || val === undefined) return undefined;
38
- const num = Number(val);
39
- return isNaN(num) ? undefined : num;
40
- }),
41
- explanation: z.string().optional(),
42
- });
43
-
44
- const EDIT_MAX_LINES_COLLAPSED = 15;
45
- const EDIT_MAX_LINES_EXPANDED = 100;
46
-
47
- function EditToolUI({
48
- rawInput,
49
- status,
50
- parsedResult,
51
- toolDisplayData,
52
- }: {
53
- rawInput: Record<string, unknown>;
54
- status: ToolStatus;
55
- parsedResult?: ParsedToolResult<EditParsedData>;
56
- toolDisplayData?: ToolDisplayData;
57
- }) {
58
- const [isExpanded, setIsExpanded] = useState(false);
59
- const hasResult =
60
- parsedResult != null && (status === "success" || parsedResult.phase === "skipped");
61
-
62
- const { isFocused } = useFocus({
63
- id: `edit-tool-${(rawInput?.targetFile || rawInput?.target_file || "unknown") as string}`,
64
- isActive: hasResult,
65
- });
66
-
67
- useInput(
68
- (input, key) => {
69
- if (isFocused && key.ctrl && input === "o") {
70
- setIsExpanded((prev) => !prev);
71
- }
72
- },
73
- { isActive: isFocused && hasResult },
74
- );
75
-
76
- const parseResult = EditToolParams.safeParse(snakeToCamel(rawInput));
77
- if (!parseResult.success) {
78
- return (
79
- <View flexDirection="column">
80
- <ToolHeader name="Edit" params="" status="error" />
81
- <ToolResult color="red">Invalid params</ToolResult>
82
- </View>
83
- );
84
- }
85
- const params = parseResult.data;
86
-
87
- const targetFile = parsedResult?.data.targetFile ?? params.targetFile;
88
-
89
- const isExecuting = !parsedResult && (status === "executing" || status === "pending");
90
- const displayPath = truncatePath(targetFile);
91
-
92
- // Resolve display data — prefer toolDisplayData side-channel
93
- const isPlanFile = toolDisplayData?.isPlanFile ?? false;
94
- const isNewFile = parsedResult?.data.isNewFile ?? toolDisplayData?.isNewFile ?? false;
95
- const operation = isNewFile ? "Create" : "Update";
96
-
97
- // Plan file edits: no diff shown
98
- if (isPlanFile && status === "success") {
99
- return (
100
- <View flexDirection="column">
101
- <ToolHeader name={operation} params={displayPath} status="success" />
102
- <ToolResult>Updated plan</ToolResult>
103
- </View>
104
- );
105
- }
106
-
107
- if (status === "interrupted") {
108
- return (
109
- <View flexDirection="column">
110
- <ToolHeader name={operation} params={displayPath} status="interrupted" />
111
- <ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
112
- </View>
113
- );
114
- }
115
-
116
- if (status === "rejected") {
117
- const origContent = toolDisplayData?.originalContent ?? "";
118
- const newCont = toolDisplayData?.newContent ?? "";
119
- const interruptMessage = parsedResult?.userNote ? (
120
- <ToolResult color="yellow">
121
- Rejected · <Text italic>"{parsedResult.userNote}"</Text>
122
- </ToolResult>
123
- ) : (
124
- <ToolResult color="yellow">Rejected</ToolResult>
125
- );
126
- return (
127
- <View flexDirection="column">
128
- <ToolHeader name={operation} params={displayPath} status="rejected" />
129
- {!isPlanFile && origContent && newCont && (
130
- <PreviewContent>
131
- <DiffPreview
132
- filePath={targetFile}
133
- originalContent={origContent}
134
- newContent={newCont}
135
- dimmed
136
- />
137
- </PreviewContent>
138
- )}
139
- {interruptMessage}
140
- </View>
141
- );
142
- }
143
-
144
- if (isExecuting) {
145
- return <ToolHeader name={operation} params={displayPath} status="pending" showSpinner />;
146
- }
147
-
148
- if (!parsedResult) {
149
- return (
150
- <View flexDirection="column">
151
- <ToolHeader name={operation} params={displayPath} status="pending" />
152
- </View>
153
- );
154
- }
155
-
156
- const isNoChanges = parsedResult.phase === "skipped";
157
- const resultText = parsedResult.summary ?? "Updated";
158
-
159
- // Content for diff preview — ONLY from toolDisplayData (EditTool.format() strips it)
160
- const originalContent = toolDisplayData?.originalContent;
161
- const finalContent = toolDisplayData?.finalContent ?? toolDisplayData?.newContent;
162
-
163
- return (
164
- <View flexDirection="column">
165
- <ToolHeader
166
- name={operation}
167
- params={displayPath}
168
- status={isNoChanges ? "rejected" : "success"}
169
- />
170
- <ToolResult color={isNoChanges ? "yellow" : undefined}>{resultText}</ToolResult>
171
-
172
- {!isNoChanges && originalContent !== undefined && finalContent !== undefined && (
173
- <PreviewContent>
174
- {isNewFile ? (
175
- <CodePreview
176
- filePath={targetFile}
177
- content={finalContent}
178
- maxLines={isExpanded ? EDIT_MAX_LINES_EXPANDED : EDIT_MAX_LINES_COLLAPSED}
179
- />
180
- ) : (
181
- <DiffPreview
182
- filePath={targetFile}
183
- originalContent={originalContent}
184
- newContent={finalContent}
185
- />
186
- )}
187
- </PreviewContent>
188
- )}
189
- </View>
190
- );
191
- }
192
-
193
- export const editTool: ToolDef<EditParsedData> = {
194
- displayName: "Edit",
195
-
196
- getHeaderParams(input: Record<string, unknown>): string {
197
- try {
198
- const targetFile = (input?.targetFile || input?.target_file || "[unknown]") as string;
199
- return truncatePath(targetFile);
200
- } catch {
201
- return "[unknown]";
202
- }
203
- },
204
-
205
- renderUI(
206
- rawInput: Record<string, unknown>,
207
- status: ToolStatus,
208
- parsedResult,
209
- displayData,
210
- ): React.ReactElement {
211
- return (
212
- <EditToolUI
213
- rawInput={rawInput}
214
- status={status}
215
- parsedResult={parsedResult}
216
- toolDisplayData={displayData}
217
- />
218
- );
219
- },
220
- };
@@ -1,78 +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, truncatePath, snakeToCamel } from "../shared/index.js";
10
-
11
- const ListDirToolParams = z.object({
12
- relativeWorkspacePath: z.string().optional(),
13
- explanation: z.string().optional(),
14
- });
15
-
16
- export const listDirTool: ToolDef = {
17
- displayName: "ListDir",
18
-
19
- getHeaderParams(input: Record<string, unknown>): string {
20
- try {
21
- const path = (input?.relativeWorkspacePath ||
22
- input?.relative_workspace_path ||
23
- ".") as string;
24
- return truncatePath(path);
25
- } catch {
26
- return "[unknown]";
27
- }
28
- },
29
-
30
- renderUI(
31
- rawInput: Record<string, unknown>,
32
- status: ToolStatus,
33
- parsedResult?: ParsedToolResult,
34
- ): React.ReactElement {
35
- const parseResult = ListDirToolParams.safeParse(snakeToCamel(rawInput));
36
- if (!parseResult.success) {
37
- return (
38
- <View flexDirection="column">
39
- <ToolHeader name="LS" params="" status="error" />
40
- <ToolResult color="red">Invalid params</ToolResult>
41
- </View>
42
- );
43
- }
44
- const params = parseResult.data;
45
- const path = params.relativeWorkspacePath || ".";
46
- const displayParams = truncatePath(path);
47
-
48
- if (status === "error") {
49
- return (
50
- <View flexDirection="column">
51
- <ToolHeader name="List" params={displayParams} status="error" />
52
- <ToolResult color="red">Error listing directory</ToolResult>
53
- </View>
54
- );
55
- }
56
-
57
- const isExecuting = !parsedResult && (status === "executing" || status === "pending");
58
-
59
- if (isExecuting) {
60
- return <ToolHeader name="LS" params={displayParams} status="pending" showSpinner />;
61
- }
62
-
63
- if (!parsedResult) {
64
- return (
65
- <View flexDirection="column">
66
- <ToolHeader name="LS" params={displayParams} status="pending" />
67
- </View>
68
- );
69
- }
70
-
71
- return (
72
- <View flexDirection="column">
73
- <ToolHeader name="LS" params={displayParams} status="success" />
74
- <ToolResult>{parsedResult.summary}</ToolResult>
75
- </View>
76
- );
77
- },
78
- };
@@ -1,180 +0,0 @@
1
- import type { ReadFileParsedData } from "@codellm/agent";
2
-
3
- import { View, useFocus, useInput } from "@codellm/jar";
4
- import React, { useState } from "react";
5
- import { z } from "zod";
6
-
7
- import type { ToolDef, ToolStatus } from "../types.js";
8
-
9
- import {
10
- ToolHeader,
11
- ToolResult,
12
- PreviewContent,
13
- CodePreview,
14
- truncatePath,
15
- snakeToCamel,
16
- } from "../shared/index.js";
17
- import { coerceOptionalBoolean, coerceOptionalNumber } from "../shared/zod-coercion.js";
18
-
19
- const MAX_LINES_COLLAPSED = 4;
20
- const MAX_LINES_EXPANDED = 100;
21
-
22
- const ReadFileToolParams = z.object({
23
- targetFile: z.string(),
24
- startLineOneIndexed: coerceOptionalNumber,
25
- endLineOneIndexed: coerceOptionalNumber,
26
- startLine: coerceOptionalNumber,
27
- endLine: coerceOptionalNumber,
28
- shouldReadEntireFile: coerceOptionalBoolean,
29
- explanation: z.string().optional(),
30
- });
31
-
32
- export const readFileTool: ToolDef<ReadFileParsedData> = {
33
- displayName: "Read",
34
-
35
- getHeaderParams(input: Record<string, unknown>): string {
36
- try {
37
- const targetFile = (input?.targetFile || input?.target_file || "[unknown]") as string;
38
- const displayPath = truncatePath(targetFile);
39
-
40
- const startLine =
41
- input?.startLineOneIndexed ||
42
- input?.start_line_one_indexed ||
43
- input?.startLine ||
44
- input?.start_line;
45
- const endLine =
46
- input?.endLineOneIndexed ||
47
- input?.end_line_one_indexed ||
48
- input?.endLine ||
49
- input?.end_line;
50
-
51
- if (startLine !== undefined && endLine !== undefined) {
52
- return `${displayPath}:${startLine}-${endLine}`;
53
- }
54
- return displayPath;
55
- } catch {
56
- return "[unknown]";
57
- }
58
- },
59
-
60
- renderUI(
61
- rawInput: Record<string, unknown>,
62
- status: ToolStatus,
63
- parsedResult,
64
- ): React.ReactElement {
65
- const parseResult = ReadFileToolParams.safeParse(snakeToCamel(rawInput));
66
- if (!parseResult.success) {
67
- return (
68
- <View flexDirection="column">
69
- <ToolHeader name="Read" params="" status="error" />
70
- <ToolResult color="red">Invalid params</ToolResult>
71
- </View>
72
- );
73
- }
74
- const params = parseResult.data;
75
- const { targetFile, startLineOneIndexed, endLineOneIndexed } = params;
76
-
77
- if (!targetFile || typeof targetFile !== "string") {
78
- return (
79
- <View flexDirection="column">
80
- <ToolHeader name="Read" params="[invalid file path]" status="error" />
81
- <ToolResult color="red">Error: Invalid file path parameter</ToolResult>
82
- </View>
83
- );
84
- }
85
-
86
- const isExecuting = !parsedResult && (status === "executing" || status === "pending");
87
- const filePath = truncatePath(targetFile);
88
- const paramStartLine = startLineOneIndexed ?? params.startLine;
89
- const endLine = endLineOneIndexed ?? params.endLine;
90
-
91
- let displayParams = filePath;
92
- if (paramStartLine !== undefined && endLine !== undefined) {
93
- displayParams = `${filePath}:${paramStartLine}-${endLine}`;
94
- }
95
-
96
- if (isExecuting) {
97
- return <ToolHeader name="Read" params={displayParams} status="pending" showSpinner />;
98
- }
99
-
100
- if (status === "error") {
101
- return (
102
- <View flexDirection="column">
103
- <ToolHeader name="Read" params={displayParams} status="error" />
104
- <ToolResult color="red">Error reading file</ToolResult>
105
- </View>
106
- );
107
- }
108
-
109
- if (!parsedResult) {
110
- return (
111
- <View flexDirection="column">
112
- <ToolHeader name="Read" params={displayParams} status="pending" />
113
- </View>
114
- );
115
- }
116
-
117
- // Content comes clean from parsedResult.data (prefixes stripped by SDK parse())
118
- const content = parsedResult.data.content ?? "";
119
- const startLine = parsedResult.data.startLine ?? paramStartLine ?? 1;
120
- const lineCount = parsedResult.data.lineCount ?? content.split("\n").length;
121
-
122
- return (
123
- <ReadFileResult
124
- displayParams={displayParams}
125
- content={content}
126
- filePath={targetFile}
127
- startLine={startLine}
128
- lineCount={lineCount}
129
- />
130
- );
131
- },
132
- };
133
-
134
- function ReadFileResult({
135
- displayParams,
136
- content,
137
- filePath,
138
- startLine,
139
- lineCount,
140
- }: {
141
- displayParams: string;
142
- content: string;
143
- filePath: string;
144
- startLine: number;
145
- lineCount: number;
146
- }) {
147
- const [isExpanded, setIsExpanded] = useState(false);
148
- const totalLines = content.split("\n").length;
149
- const maxLines = isExpanded ? MAX_LINES_EXPANDED : MAX_LINES_COLLAPSED;
150
- const canExpand = totalLines > MAX_LINES_COLLAPSED;
151
-
152
- const { isFocused } = useFocus({
153
- id: `read-file-${filePath}`,
154
- isActive: canExpand,
155
- });
156
-
157
- useInput(
158
- (input, key) => {
159
- if (isFocused && key.ctrl && input === "o") {
160
- setIsExpanded((prev) => !prev);
161
- }
162
- },
163
- { isActive: isFocused && canExpand },
164
- );
165
-
166
- return (
167
- <View flexDirection="column">
168
- <ToolHeader name="Read" params={displayParams} status="success" />
169
- <ToolResult>Read {lineCount} lines</ToolResult>
170
- <PreviewContent>
171
- <CodePreview
172
- content={content}
173
- filePath={filePath}
174
- startLine={startLine}
175
- maxLines={maxLines}
176
- />
177
- </PreviewContent>
178
- </View>
179
- );
180
- }
@@ -1,76 +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, truncatePath, snakeToCamel } from "../shared/index.js";
10
-
11
- const UploadImageToolParams = z.object({
12
- targetFile: z.string(),
13
- explanation: z.string().optional(),
14
- });
15
-
16
- export const uploadImageTool: ToolDef = {
17
- displayName: "Upload",
18
-
19
- getHeaderParams(input: Record<string, unknown>): string {
20
- try {
21
- const targetFile = (input?.targetFile || input?.target_file || "[unknown]") as string;
22
- return truncatePath(targetFile);
23
- } catch {
24
- return "[unknown]";
25
- }
26
- },
27
-
28
- renderUI(
29
- rawInput: Record<string, unknown>,
30
- status: ToolStatus,
31
- parsedResult?: ParsedToolResult,
32
- ): React.ReactElement {
33
- const parseResult = UploadImageToolParams.safeParse(snakeToCamel(rawInput));
34
- if (!parseResult.success) {
35
- return (
36
- <View flexDirection="column">
37
- <ToolHeader name="Upload" params="" status="error" />
38
- <ToolResult color="red">Invalid params</ToolResult>
39
- </View>
40
- );
41
- }
42
- const params = parseResult.data;
43
- const { targetFile } = params;
44
- const displayParams = truncatePath(targetFile);
45
-
46
- const isExecuting = !parsedResult && (status === "executing" || status === "pending");
47
-
48
- if (isExecuting) {
49
- return <ToolHeader name="Upload" params={displayParams} status="pending" showSpinner />;
50
- }
51
-
52
- if (!parsedResult) {
53
- return (
54
- <View flexDirection="column">
55
- <ToolHeader name="Upload" params={displayParams} status="pending" />
56
- </View>
57
- );
58
- }
59
-
60
- if (parsedResult.phase === "error") {
61
- return (
62
- <View flexDirection="column">
63
- <ToolHeader name="Upload" params={displayParams} status="error" />
64
- <ToolResult color="red">{parsedResult.errorMessage ?? "Error executing tool"}</ToolResult>
65
- </View>
66
- );
67
- }
68
-
69
- return (
70
- <View flexDirection="column">
71
- <ToolHeader name="Upload" params={displayParams} status="success" />
72
- <ToolResult>{parsedResult.summary}</ToolResult>
73
- </View>
74
- );
75
- },
76
- };