@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,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
- };