@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,420 +0,0 @@
1
- import type { PermissionDecision } from "@codellm/agent";
2
-
3
- import { View, Text } from "@codellm/jar";
4
- import { highlight, supportsLanguage } from "cli-highlight";
5
- import { memo } from "react";
6
-
7
- import type { PendingToolPermission, ToolPermissionResult } from "../../providers/agent.js";
8
-
9
- import { AgentMode } from "../../components/composer/types.js";
10
- import { useAgentMode } from "../../context/agent-mode.js";
11
- import { Markdown } from "../../lib/markdown/markdown.js";
12
- import { CodePreview } from "../tools/shared/index.js";
13
- import { AskUserQuestionPermissionUI } from "./ask-user-question-permission-ui.js";
14
- import { DiffPreview } from "./diff-preview.js";
15
- import { PermissionOptions, type PermissionOption } from "./permission-options.js";
16
- import { PermissionPreviewHeader, dashedBorderStyle } from "./permission-preview-header.js";
17
-
18
- interface ToolPermissionUIProps {
19
- pendingTool: PendingToolPermission;
20
- }
21
-
22
- function mapResultToDecision(result: ToolPermissionResult): PermissionDecision {
23
- if (result.decision === "accept" && result.userMessage) {
24
- return { type: "accept_with_message", message: result.userMessage };
25
- }
26
- if (result.decision === "reject" && result.userMessage) {
27
- return { type: "reject_with_message", message: result.userMessage };
28
- }
29
- return result.decision;
30
- }
31
-
32
- const EditFilePermissionUI = memo(
33
- ({
34
- filePath,
35
- originalContent,
36
- newContent,
37
- diffShownInEditor,
38
- onResolve,
39
- }: {
40
- filePath: string;
41
- originalContent: string;
42
- newContent: string;
43
- diffShownInEditor?: boolean;
44
- onResolve: (decision: PermissionDecision) => void;
45
- }) => {
46
- const isNewFile = !originalContent;
47
- const { agentMode } = useAgentMode();
48
- const inPlanMode = agentMode === AgentMode.PlanMode;
49
-
50
- const options: PermissionOption[] = [
51
- { label: "Yes, apply changes", value: "accept" },
52
- ...(!inPlanMode
53
- ? [
54
- {
55
- label: "Yes, and auto-accept all edits",
56
- value: "allowAlways" as const,
57
- hint: "shift+tab",
58
- },
59
- ]
60
- : []),
61
- { label: "No, reject changes", value: "reject" },
62
- ];
63
-
64
- const handleSelect = (result: ToolPermissionResult) => {
65
- onResolve(mapResultToDecision(result));
66
- };
67
-
68
- if (diffShownInEditor) {
69
- return (
70
- <View flexDirection="column">
71
- <PermissionPreviewHeader
72
- title={`${isNewFile ? "Create" : "Update"} file ${filePath}`}
73
- subtitle="Opened changes in the editor"
74
- />
75
- <View flexDirection="column" paddingLeft={1}>
76
- <PermissionOptions options={options} onSelect={handleSelect} />
77
- </View>
78
- </View>
79
- );
80
- }
81
-
82
- return (
83
- <View flexDirection="column">
84
- <PermissionPreviewHeader title={`${isNewFile ? "Create" : "Update"} file ${filePath}`} />
85
- {isNewFile ? (
86
- <CodePreview filePath={filePath} content={newContent} maxLines={100} />
87
- ) : (
88
- <DiffPreview
89
- filePath={filePath}
90
- originalContent={originalContent}
91
- newContent={newContent}
92
- paddingLeft={1}
93
- />
94
- )}
95
- <View
96
- borderStyle={dashedBorderStyle}
97
- borderBottom
98
- borderTop={false}
99
- borderLeft={false}
100
- borderRight={false}
101
- />
102
- <View flexDirection="column" paddingLeft={1}>
103
- <PermissionOptions options={options} onSelect={handleSelect} />
104
- </View>
105
- </View>
106
- );
107
- },
108
- );
109
- EditFilePermissionUI.displayName = "EditFilePermissionUI";
110
-
111
- const DeleteFilePermissionUI = memo(
112
- ({
113
- filePath,
114
- onResolve,
115
- }: {
116
- filePath: string;
117
- onResolve: (decision: PermissionDecision) => void;
118
- }) => {
119
- const options: PermissionOption[] = [
120
- { label: "Yes, delete file", value: "accept" },
121
- { label: "No, keep file", value: "reject" },
122
- ];
123
-
124
- const handleSelect = (result: ToolPermissionResult) => {
125
- onResolve(mapResultToDecision(result));
126
- };
127
-
128
- return (
129
- <View flexDirection="column">
130
- <PermissionPreviewHeader title={`Delete file ${filePath}`} />
131
- <View flexDirection="column" paddingLeft={1} paddingY={1}>
132
- <Text color="red">{filePath}</Text>
133
- </View>
134
- <View
135
- borderStyle={dashedBorderStyle}
136
- borderBottom
137
- borderTop={false}
138
- borderLeft={false}
139
- borderRight={false}
140
- />
141
- <View flexDirection="column" paddingLeft={1}>
142
- <PermissionOptions options={options} onSelect={handleSelect} />
143
- </View>
144
- </View>
145
- );
146
- },
147
- );
148
- DeleteFilePermissionUI.displayName = "DeleteFilePermissionUI";
149
-
150
- const BrowserActionPermissionUI = memo(
151
- ({
152
- description,
153
- url,
154
- onResolve,
155
- }: {
156
- description: string;
157
- url?: string;
158
- onResolve: (decision: PermissionDecision) => void;
159
- }) => {
160
- const options: PermissionOption[] = [
161
- { label: "Yes, allow action", value: "accept" },
162
- { label: "No, deny action", value: "reject" },
163
- ];
164
-
165
- const handleSelect = (result: ToolPermissionResult) => {
166
- onResolve(mapResultToDecision(result));
167
- };
168
-
169
- return (
170
- <View flexDirection="column">
171
- <PermissionPreviewHeader title={`Browser action: ${description}`} />
172
- <View flexDirection="column" paddingLeft={1} paddingY={1}>
173
- <Text>{description}</Text>
174
- {url && <Text dimColor>URL: {url}</Text>}
175
- </View>
176
- <View
177
- borderStyle={dashedBorderStyle}
178
- borderBottom
179
- borderTop={false}
180
- borderLeft={false}
181
- borderRight={false}
182
- />
183
- <View flexDirection="column" paddingLeft={1}>
184
- <PermissionOptions options={options} onSelect={handleSelect} />
185
- </View>
186
- </View>
187
- );
188
- },
189
- );
190
- BrowserActionPermissionUI.displayName = "BrowserActionPermissionUI";
191
-
192
- const RunTerminalPermissionUI = memo(
193
- ({
194
- command,
195
- background,
196
- onResolve,
197
- }: {
198
- command: string;
199
- background: boolean;
200
- onResolve: (decision: PermissionDecision) => void;
201
- }) => {
202
- const options: PermissionOption[] = [
203
- { label: "Yes, run command", value: "accept" },
204
- { label: "Yes, and auto-accept all commands", value: "allowAlways", hint: "shift+tab" },
205
- { label: "No, skip command", value: "reject" },
206
- ];
207
-
208
- const handleSelect = (result: ToolPermissionResult) => {
209
- onResolve(mapResultToDecision(result));
210
- };
211
-
212
- return (
213
- <View flexDirection="column">
214
- <PermissionPreviewHeader title="Bash command" />
215
- <View flexDirection="column" paddingLeft={1} paddingY={1}>
216
- <Text>
217
- {supportsLanguage("bash")
218
- ? (() => {
219
- try {
220
- return highlight(command, { language: "bash" });
221
- } catch {
222
- return command;
223
- }
224
- })()
225
- : command}
226
- </Text>
227
- {background && (
228
- <View paddingTop={1}>
229
- <Text dimColor>(Running in background)</Text>
230
- </View>
231
- )}
232
- </View>
233
- <View
234
- borderStyle={dashedBorderStyle}
235
- borderBottom
236
- borderTop={false}
237
- borderLeft={false}
238
- borderRight={false}
239
- />
240
- <View flexDirection="column" paddingLeft={1}>
241
- <PermissionOptions
242
- options={options}
243
- onSelect={handleSelect}
244
- inputPlaceholder="Type here to tell AbacusAI what to do differently"
245
- />
246
- </View>
247
- </View>
248
- );
249
- },
250
- );
251
- RunTerminalPermissionUI.displayName = "RunTerminalPermissionUI";
252
-
253
- const GenericPermissionUI = memo(
254
- ({
255
- title,
256
- description,
257
- onResolve,
258
- }: {
259
- title: string;
260
- description: string;
261
- onResolve: (decision: PermissionDecision) => void;
262
- }) => {
263
- const options: PermissionOption[] = [
264
- { label: "Yes, allow", value: "accept" },
265
- { label: "No, deny", value: "reject" },
266
- ];
267
-
268
- const handleSelect = (result: ToolPermissionResult) => {
269
- onResolve(mapResultToDecision(result));
270
- };
271
-
272
- return (
273
- <View flexDirection="column">
274
- <PermissionPreviewHeader title={title} />
275
- <View flexDirection="column" paddingLeft={1} paddingY={1}>
276
- <Text>
277
- {supportsLanguage("json")
278
- ? (() => {
279
- try {
280
- return highlight(description, { language: "json" });
281
- } catch {
282
- return description;
283
- }
284
- })()
285
- : description}
286
- </Text>
287
- </View>
288
- <View
289
- borderStyle={dashedBorderStyle}
290
- borderBottom
291
- borderTop={false}
292
- borderLeft={false}
293
- borderRight={false}
294
- />
295
- <View flexDirection="column" paddingLeft={1}>
296
- <PermissionOptions options={options} onSelect={handleSelect} />
297
- </View>
298
- </View>
299
- );
300
- },
301
- );
302
- GenericPermissionUI.displayName = "GenericPermissionUI";
303
-
304
- const ExitPlanModePermissionUI = memo(
305
- ({
306
- planFilePath,
307
- planContent,
308
- onResolve,
309
- }: {
310
- planFilePath: string;
311
- planContent: string;
312
- onResolve: (decision: PermissionDecision) => void;
313
- }) => {
314
- const options: PermissionOption[] = [
315
- { label: "Yes, implement the plan (approve each edit)", value: "accept" },
316
- {
317
- label: "Yes, implement the plan (auto-accept all edits)",
318
- value: "allowAlways",
319
- hint: "shift+tab",
320
- },
321
- { label: "No, keep planning", value: "reject" },
322
- ];
323
-
324
- const handleSelect = (result: ToolPermissionResult) => {
325
- onResolve(mapResultToDecision(result));
326
- };
327
-
328
- const truncatedPath = planFilePath.length > 60 ? `…${planFilePath.slice(-60)}` : planFilePath;
329
-
330
- return (
331
- <View flexDirection="column">
332
- <PermissionPreviewHeader title={`Ready to code? Implement plan: ${truncatedPath}`} />
333
- {planContent && (
334
- <View flexDirection="column" paddingLeft={1} paddingY={1}>
335
- <Text dimColor>Here is Abacus's plan:</Text>
336
- <Markdown>{planContent}</Markdown>
337
- </View>
338
- )}
339
- <View
340
- borderStyle={dashedBorderStyle}
341
- borderBottom
342
- borderTop={false}
343
- borderLeft={false}
344
- borderRight={false}
345
- />
346
- <View flexDirection="column" paddingLeft={1}>
347
- <PermissionOptions
348
- options={options}
349
- onSelect={handleSelect}
350
- inputPlaceholder="Add instructions for the implementation"
351
- />
352
- </View>
353
- </View>
354
- );
355
- },
356
- );
357
- ExitPlanModePermissionUI.displayName = "ExitPlanModePermissionUI";
358
-
359
- export const ToolPermissionUI = memo(({ pendingTool }: ToolPermissionUIProps) => {
360
- const { request, resolve } = pendingTool;
361
-
362
- switch (request.type) {
363
- case "edit_file":
364
- return (
365
- <EditFilePermissionUI
366
- filePath={request.filePath}
367
- originalContent={request.originalContent}
368
- newContent={request.newContent}
369
- diffShownInEditor={request.diffShownInEditor}
370
- onResolve={resolve}
371
- />
372
- );
373
-
374
- case "delete_file":
375
- return <DeleteFilePermissionUI filePath={request.filePath} onResolve={resolve} />;
376
-
377
- case "run_terminal":
378
- return (
379
- <RunTerminalPermissionUI
380
- command={request.command}
381
- background={request.background}
382
- onResolve={resolve}
383
- />
384
- );
385
-
386
- case "browser_action":
387
- return (
388
- <BrowserActionPermissionUI
389
- description={request.description}
390
- url={request.url}
391
- onResolve={resolve}
392
- />
393
- );
394
-
395
- case "generic":
396
- return (
397
- <GenericPermissionUI
398
- title={`Tool: ${request.toolName}`}
399
- description={request.inputSummary}
400
- onResolve={resolve}
401
- />
402
- );
403
-
404
- case "exit_plan_mode":
405
- return (
406
- <ExitPlanModePermissionUI
407
- planFilePath={request.planFilePath}
408
- planContent={request.planContent}
409
- onResolve={resolve}
410
- />
411
- );
412
-
413
- case "ask_user_question":
414
- return <AskUserQuestionPermissionUI questions={request.questions} onResolve={resolve} />;
415
-
416
- default:
417
- return null;
418
- }
419
- });
420
- ToolPermissionUI.displayName = "ToolPermissionUI";
@@ -1,107 +0,0 @@
1
- import type { AskUserQuestionParsedData } 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, PreviewContent } from "../shared/index.js";
10
- import { snakeToCamel } from "../shared/index.js";
11
- import { coerceBoolean } from "../shared/zod-coercion.js";
12
-
13
- const AskUserQuestionParams = z.object({
14
- questions: z.array(
15
- z.object({
16
- question: z.string(),
17
- header: z.string(),
18
- options: z.array(z.object({ label: z.string(), description: z.string() })),
19
- multiSelect: coerceBoolean,
20
- }),
21
- ),
22
- answers: z.record(z.string(), z.string()).optional(),
23
- });
24
-
25
- export const askUserQuestionTool: ToolDef<AskUserQuestionParsedData> = {
26
- displayName: "AskUserQuestion",
27
- getHeaderParams(_input: Record<string, unknown>): string {
28
- return "";
29
- },
30
- renderUI(
31
- rawInput: Record<string, unknown>,
32
- status: ToolStatus,
33
- parsedResult,
34
- ): React.ReactElement {
35
- const pr = AskUserQuestionParams.safeParse(snakeToCamel(rawInput));
36
- if (!pr.success) {
37
- return (
38
- <View flexDirection="column">
39
- <ToolHeader name="AskUserQuestion" status="error" />
40
- <ToolResult color="red">Invalid params</ToolResult>
41
- </View>
42
- );
43
- }
44
- const params = pr.data;
45
- const questions = params.questions || [];
46
- const answers = parsedResult?.data.answers ?? params.answers ?? {};
47
-
48
- if (status === "interrupted") {
49
- return (
50
- <View flexDirection="column">
51
- <ToolHeader name="AskUserQuestion" status="interrupted" />
52
- <ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
53
- </View>
54
- );
55
- }
56
-
57
- if (status === "rejected") {
58
- const hasAnswers = Object.keys(answers).length > 0;
59
- return (
60
- <View flexDirection="column">
61
- <ToolHeader name="AskUserQuestion" status={hasAnswers ? "success" : "rejected"} />
62
- <ToolResult color={hasAnswers ? "green" : "yellow"}>
63
- {hasAnswers ? (
64
- `User answered ${Object.keys(answers).length} question${Object.keys(answers).length !== 1 ? "s" : ""}`
65
- ) : parsedResult?.userNote ? (
66
- <>
67
- Rejected · <Text italic>"{parsedResult.userNote}"</Text>
68
- </>
69
- ) : (
70
- "User cancelled the questions"
71
- )}
72
- </ToolResult>
73
- </View>
74
- );
75
- }
76
-
77
- if (status === "pending" || status === "executing") {
78
- return <ToolHeader name="AskUserQuestion" status="pending" showSpinner />;
79
- }
80
-
81
- const questionCount = questions.length;
82
- const answerCount = Object.keys(answers).length;
83
-
84
- return (
85
- <View flexDirection="column" gap={0}>
86
- <ToolHeader name="AskUserQuestion" status="success" />
87
- <ToolResult>
88
- Answered {questionCount} question{questionCount !== 1 ? "s" : ""}
89
- </ToolResult>
90
- {answerCount > 0 && (
91
- <PreviewContent>
92
- {Object.entries(answers).map(([key, value], index) => {
93
- const questionIndex = parseInt(key.replace("question_", ""), 10);
94
- const question = questions[questionIndex];
95
- return (
96
- <View key={index} flexDirection="column" marginBottom={1}>
97
- <Text dimColor>{question?.header || `Question ${questionIndex + 1}`}</Text>
98
- <Text color="cyan">→ {String(value)}</Text>
99
- </View>
100
- );
101
- })}
102
- </PreviewContent>
103
- )}
104
- </View>
105
- );
106
- },
107
- };
@@ -1,55 +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 { ToolHeader, ToolResult } from "../shared/index.js";
9
-
10
- export const enterPlanModeTool: ToolDef = {
11
- displayName: "EnterPlanMode",
12
- getHeaderParams(_input: Record<string, unknown>): string {
13
- return "";
14
- },
15
- renderUI(
16
- _rawInput: Record<string, unknown>,
17
- status: ToolStatus,
18
- parsedResult?: ParsedToolResult,
19
- ): React.ReactElement {
20
- if (status === "interrupted") {
21
- return (
22
- <View flexDirection="column">
23
- <ToolHeader name="EnterPlanMode" status="interrupted" />
24
- <ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
25
- </View>
26
- );
27
- }
28
-
29
- if (status === "rejected") {
30
- return (
31
- <View flexDirection="column">
32
- <ToolHeader name="EnterPlanMode" status="rejected" />
33
- {parsedResult?.userNote ? (
34
- <ToolResult color="yellow">
35
- Rejected · <Text italic>"{parsedResult.userNote}"</Text>
36
- </ToolResult>
37
- ) : (
38
- <ToolResult color="yellow">Rejected</ToolResult>
39
- )}
40
- </View>
41
- );
42
- }
43
-
44
- if (status === "pending" || status === "executing") {
45
- return <ToolHeader name="EnterPlanMode" status="pending" showSpinner />;
46
- }
47
-
48
- return (
49
- <View flexDirection="column" gap={0}>
50
- <ToolHeader name="EnterPlanMode" status="success" />
51
- <ToolResult>Entered plan mode</ToolResult>
52
- </View>
53
- );
54
- },
55
- };
@@ -1,83 +0,0 @@
1
- import type { ParsedToolResult } from "@codellm/agent";
2
-
3
- import { AgentMode } from "@codellm/agent";
4
- import { View, Text } from "@codellm/jar";
5
- import React from "react";
6
- import { z } from "zod";
7
-
8
- import type { ToolDef, ToolStatus } from "../types.js";
9
-
10
- import { useAgentMode } from "../../../context/agent-mode.js";
11
- import { ToolHeader, ToolResult, truncatePath } from "../shared/index.js";
12
- import { snakeToCamel } from "../shared/index.js";
13
-
14
- const ExitPlanModeParams = z.object({ planFilePath: z.string() });
15
-
16
- function ExitPlanModeUI({
17
- rawInput,
18
- status,
19
- parsedResult,
20
- }: {
21
- rawInput: Record<string, unknown>;
22
- status: ToolStatus;
23
- parsedResult?: ParsedToolResult;
24
- }) {
25
- const { agentMode } = useAgentMode();
26
- const pr = ExitPlanModeParams.safeParse(snakeToCamel(rawInput));
27
- const planFilePath =
28
- (pr.success ? pr.data.planFilePath : (rawInput?.planFilePath as string)) || "";
29
-
30
- if (status === "interrupted") {
31
- return (
32
- <View flexDirection="column">
33
- <ToolHeader name="ExitPlanMode" status="interrupted" />
34
- <ToolResult color="yellow">Interrupted · What should I do instead?</ToolResult>
35
- </View>
36
- );
37
- }
38
-
39
- if (status === "rejected") {
40
- return (
41
- <View flexDirection="column">
42
- <ToolHeader name="ExitPlanMode" status="rejected" />
43
- {parsedResult?.userNote ? (
44
- <ToolResult color="yellow">
45
- Rejected · <Text italic>"{parsedResult.userNote}"</Text>
46
- </ToolResult>
47
- ) : (
48
- <ToolResult color="yellow">Rejected</ToolResult>
49
- )}
50
- </View>
51
- );
52
- }
53
-
54
- if (status === "pending" || status === "executing") {
55
- return <ToolHeader name="ExitPlanMode" status="pending" showSpinner />;
56
- }
57
-
58
- const modeMessage =
59
- agentMode === AgentMode.AcceptEdits ? "Plan approved (auto-accept mode)" : "Plan approved";
60
-
61
- return (
62
- <View flexDirection="column" gap={0}>
63
- <ToolHeader name="ExitPlanMode" status="success" />
64
- <ToolResult>
65
- {modeMessage}: {truncatePath(planFilePath)}
66
- </ToolResult>
67
- </View>
68
- );
69
- }
70
-
71
- export const exitPlanModeTool: ToolDef = {
72
- displayName: "ExitPlanMode",
73
- getHeaderParams(input: Record<string, unknown>): string {
74
- return (input?.planFilePath as string) || "";
75
- },
76
- renderUI(
77
- rawInput: Record<string, unknown>,
78
- status: ToolStatus,
79
- parsedResult?: ParsedToolResult,
80
- ): React.ReactElement {
81
- return <ExitPlanModeUI rawInput={rawInput} status={status} parsedResult={parsedResult} />;
82
- },
83
- };
@@ -1,27 +0,0 @@
1
- import type { ParsedToolResult } from "@codellm/agent";
2
-
3
- import { View } from "@codellm/jar";
4
- import React from "react";
5
-
6
- import type { ToolDef, ToolStatus } from "../types.js";
7
-
8
- import { ToolHeader, ToolResult } from "../shared/index.js";
9
-
10
- export const handOffToMainTool: ToolDef = {
11
- displayName: "HandOff",
12
- getHeaderParams(_input: Record<string, unknown>): string {
13
- return "";
14
- },
15
- renderUI(
16
- _rawInput: Record<string, unknown>,
17
- _status: ToolStatus,
18
- _parsedResult?: ParsedToolResult,
19
- ): React.ReactElement {
20
- return (
21
- <View flexDirection="column">
22
- <ToolHeader name="HandOff" status="success" />
23
- <ToolResult>Handed off to main agent</ToolResult>
24
- </View>
25
- );
26
- },
27
- };