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

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