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

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