@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,226 +0,0 @@
1
- import { execFileSync } from "node:child_process";
2
- import { copyFileSync, existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
3
- import path from "node:path";
4
-
5
- // ── macOS screenshot detection ────────────────────────────────────────────
6
-
7
- const MACOS_TEMP_SCREENSHOT_PATTERN =
8
- /\/var\/folders\/.*\/T\/TemporaryItems\/.*screencaptureui.*\//i;
9
- const SCREENSHOTS_DIR = ".abacusai/screenshots";
10
-
11
- export function isMacOSTempScreenshot(filePath: string): boolean {
12
- return MACOS_TEMP_SCREENSHOT_PATTERN.test(filePath);
13
- }
14
-
15
- export function copyTempScreenshotToProject(tempPath: string): string | null {
16
- try {
17
- const unescaped = tempPath.replace(/\\ /g, " ");
18
- const cleaned = stripFileProtocol(unescaped);
19
-
20
- if (!existsSync(cleaned)) {
21
- return null;
22
- }
23
-
24
- const screenshotsDir = path.resolve(process.cwd(), SCREENSHOTS_DIR);
25
- if (!existsSync(screenshotsDir)) {
26
- mkdirSync(screenshotsDir, { recursive: true });
27
- }
28
-
29
- const filename = path.basename(cleaned);
30
- const destPath = path.join(screenshotsDir, filename);
31
-
32
- copyFileSync(cleaned, destPath);
33
- return destPath;
34
- } catch {
35
- return null;
36
- }
37
- }
38
-
39
- /**
40
- * Strips the file:// protocol prefix from a path if present.
41
- * Also percent-decodes URI-encoded characters (e.g. %20 → space).
42
- */
43
- export function stripFileProtocol(text: string): string {
44
- if (text.startsWith("file://")) {
45
- try {
46
- return decodeURIComponent(text.slice("file://".length));
47
- } catch {
48
- return text.slice("file://".length);
49
- }
50
- }
51
- return text;
52
- }
53
-
54
- // ── Linux clipboard tool detection ───────────────────────────────────────
55
-
56
- let linuxClipboardTool: "wl-paste" | "xclip" | null | undefined;
57
-
58
- function detectLinuxClipboardTool(): "wl-paste" | "xclip" | null {
59
- if (linuxClipboardTool !== undefined) return linuxClipboardTool;
60
- try {
61
- execFileSync("which", ["wl-paste"], { stdio: "ignore" });
62
- linuxClipboardTool = "wl-paste";
63
- return "wl-paste";
64
- } catch {
65
- // not found
66
- }
67
- try {
68
- execFileSync("which", ["xclip"], { stdio: "ignore" });
69
- linuxClipboardTool = "xclip";
70
- return "xclip";
71
- } catch {
72
- // not found
73
- }
74
- linuxClipboardTool = null;
75
- return null;
76
- }
77
-
78
- // ── Clipboard image detection ─────────────────────────────────────────────
79
-
80
- export async function clipboardHasImage(): Promise<boolean> {
81
- try {
82
- if (process.platform === "darwin") {
83
- const result = execFileSync("osascript", ["-e", "clipboard info"], {
84
- encoding: "utf8",
85
- timeout: 2000,
86
- });
87
- return /PNGf|JPEG|TIFF|GIF/i.test(result);
88
- }
89
- if (process.platform === "win32") {
90
- const result = execFileSync(
91
- "powershell",
92
- [
93
- "-NoProfile",
94
- "-Command",
95
- "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::ContainsImage()",
96
- ],
97
- { encoding: "utf8", timeout: 2000 },
98
- );
99
- return result.trim().toLowerCase() === "true";
100
- }
101
- // Linux
102
- const tool = detectLinuxClipboardTool();
103
- if (tool === "wl-paste") {
104
- const result = execFileSync("wl-paste", ["--list-types"], {
105
- encoding: "utf8",
106
- timeout: 2000,
107
- });
108
- return result.includes("image/");
109
- }
110
- if (tool === "xclip") {
111
- const result = execFileSync("xclip", ["-selection", "clipboard", "-t", "TARGETS", "-o"], {
112
- encoding: "utf8",
113
- timeout: 2000,
114
- });
115
- return result.includes("image/");
116
- }
117
- } catch {
118
- // ignore — clipboard tools may not be available
119
- }
120
- return false;
121
- }
122
-
123
- // ── Save clipboard image to disk ──────────────────────────────────────────
124
-
125
- export async function saveClipboardImage(cwd: string): Promise<string | null> {
126
- try {
127
- const screenshotsDir = path.resolve(cwd, SCREENSHOTS_DIR);
128
- if (!existsSync(screenshotsDir)) {
129
- mkdirSync(screenshotsDir, { recursive: true });
130
- }
131
-
132
- const timestamp = Date.now();
133
- const destPath = path.join(screenshotsDir, `clipboard-${timestamp}.png`);
134
-
135
- if (process.platform === "darwin") {
136
- // Try PNG first, then JPEG
137
- const script = `
138
- set destFile to "${destPath}"
139
- try
140
- set imgData to (clipboard info for «class PNGf»)
141
- set fileRef to open for access POSIX file destFile with write permission
142
- set eof of fileRef to 0
143
- write (clipboard as «class PNGf») to fileRef
144
- close access fileRef
145
- on error
146
- try
147
- set imgData to (clipboard info for «class JPEG»)
148
- set fileRef to open for access POSIX file destFile with write permission
149
- set eof of fileRef to 0
150
- write (clipboard as «class JPEG») to fileRef
151
- close access fileRef
152
- end try
153
- end try
154
- `;
155
- execFileSync("osascript", ["-e", script], { timeout: 5000 });
156
- } else if (process.platform === "win32") {
157
- execFileSync(
158
- "powershell",
159
- [
160
- "-NoProfile",
161
- "-Command",
162
- `Add-Type -Assembly System.Windows.Forms; [System.Windows.Forms.Clipboard]::GetImage().Save("${destPath}", [System.Drawing.Imaging.ImageFormat]::Png)`,
163
- ],
164
- { timeout: 5000 },
165
- );
166
- } else {
167
- const tool = detectLinuxClipboardTool();
168
- if (tool === "wl-paste") {
169
- const imgData = execFileSync("wl-paste", ["--no-newline", "--type", "image/png"], {
170
- timeout: 5000,
171
- });
172
- writeFileSync(destPath, imgData);
173
- } else if (tool === "xclip") {
174
- const imgData = execFileSync(
175
- "xclip",
176
- ["-selection", "clipboard", "-t", "image/png", "-o"],
177
- { timeout: 5000 },
178
- );
179
- writeFileSync(destPath, imgData);
180
- } else {
181
- return null;
182
- }
183
- }
184
-
185
- // Verify file exists and has content (prevents empty-file false positives)
186
- try {
187
- const stat = statSync(destPath);
188
- if (stat.size === 0) return null;
189
- } catch {
190
- return null;
191
- }
192
-
193
- return destPath;
194
- } catch {
195
- return null;
196
- }
197
- }
198
-
199
- // ── Read clipboard text ───────────────────────────────────────────────────
200
-
201
- export async function readClipboardText(): Promise<string | null> {
202
- try {
203
- if (process.platform === "darwin") {
204
- return execFileSync("pbpaste", { encoding: "utf8", timeout: 2000 });
205
- }
206
- if (process.platform === "win32") {
207
- return execFileSync("powershell", ["-NoProfile", "-Command", "Get-Clipboard"], {
208
- encoding: "utf8",
209
- timeout: 2000,
210
- });
211
- }
212
- const tool = detectLinuxClipboardTool();
213
- if (tool === "wl-paste") {
214
- return execFileSync("wl-paste", ["--no-newline"], { encoding: "utf8", timeout: 2000 });
215
- }
216
- if (tool === "xclip") {
217
- return execFileSync("xclip", ["-selection", "clipboard", "-o"], {
218
- encoding: "utf8",
219
- timeout: 2000,
220
- });
221
- }
222
- } catch {
223
- // ignore
224
- }
225
- return null;
226
- }
@@ -1,93 +0,0 @@
1
- /**
2
- * Extracts the command type from a terminal command string
3
- * Returns more specific types for common commands with subcommands
4
- * Examples:
5
- * "pwd" -> "pwd"
6
- * "cd /home" -> "cd"
7
- * "npm install" -> "npm install"
8
- * "npm run build" -> "npm run"
9
- * "git status" -> "git status"
10
- * "git commit -m" -> "git commit"
11
- * "docker ps" -> "docker ps"
12
- * "ls -la" -> "ls"
13
- */
14
- export const getCommandType = (command: string): string | null => {
15
- if (!command || typeof command !== "string") {
16
- return null;
17
- }
18
-
19
- // Trim the command and extract the first word
20
- const trimmedCommand = command.trim();
21
- if (!trimmedCommand) {
22
- return null;
23
- }
24
-
25
- // Split by whitespace and get parts
26
- let parts = trimmedCommand.split(/\s+/);
27
-
28
- // Remove leading 'sudo' if present
29
- if (parts[0] === "sudo" && parts.length > 1) {
30
- parts = parts.slice(1);
31
- }
32
-
33
- const baseCommand = parts[0];
34
- const subCommand = parts.length > 1 ? parts[1] : null;
35
-
36
- // Define commands that should include their subcommand for more specific matching
37
- // Format: { command: [list of subcommands to be specific about] }
38
- const specificSubcommands: Record<string, string[]> = {
39
- npm: ["install", "run", "start", "test", "build", "publish", "update", "uninstall", "ci"],
40
- yarn: ["install", "add", "remove", "run", "start", "test", "build", "publish"],
41
- pnpm: ["install", "add", "remove", "run", "start", "test", "build"],
42
- git: [
43
- "clone",
44
- "pull",
45
- "push",
46
- "commit",
47
- "add",
48
- "status",
49
- "checkout",
50
- "branch",
51
- "merge",
52
- "rebase",
53
- "fetch",
54
- "diff",
55
- "log",
56
- "stash",
57
- ],
58
- docker: [
59
- "build",
60
- "run",
61
- "ps",
62
- "stop",
63
- "start",
64
- "pull",
65
- "push",
66
- "images",
67
- "rm",
68
- "exec",
69
- "logs",
70
- "compose",
71
- ],
72
- kubectl: ["get", "apply", "delete", "describe", "logs", "exec", "create", "scale"],
73
- cargo: ["build", "run", "test", "check", "clean", "install", "update", "publish"],
74
- pip: ["install", "uninstall", "list", "show", "freeze", "search"],
75
- brew: ["install", "uninstall", "update", "upgrade", "list", "search", "info"],
76
- apt: ["install", "remove", "update", "upgrade", "search", "show"],
77
- "apt-get": ["install", "remove", "update", "upgrade", "purge"],
78
- yum: ["install", "remove", "update", "search", "info"],
79
- systemctl: ["start", "stop", "restart", "enable", "disable", "status"],
80
- make: ["build", "clean", "install", "test"],
81
- };
82
-
83
- // Check if this command should have a specific subcommand
84
- if (subCommand && specificSubcommands[baseCommand]) {
85
- const validSubcommands = specificSubcommands[baseCommand];
86
- if (validSubcommands.includes(subCommand)) {
87
- return `${baseCommand} ${subCommand}`;
88
- }
89
- }
90
-
91
- // For all other cases, return just the base command
92
- return baseCommand;
93
- };
@@ -1,270 +0,0 @@
1
- export enum Command {
2
- Stop = "/stop",
3
- Quit = "/quit",
4
- Exit = "/exit",
5
- Q = "/q",
6
- Bye = "/bye",
7
- Clear = "/clear",
8
- New = "/new",
9
- Suggest = "/",
10
- Help = "/help",
11
- Sidebar = "/sidebar",
12
- Login = "/login",
13
- Logout = "/logout",
14
- Mcp = "/mcp",
15
- }
16
-
17
- export interface CommandInfo {
18
- command: Command;
19
- description: string;
20
- usage: string;
21
- }
22
-
23
- export const COMMAND_INFO: CommandInfo[] = [
24
- {
25
- command: Command.Stop,
26
- description: "Stop the current streaming response",
27
- usage: "/stop",
28
- },
29
- {
30
- command: Command.Quit,
31
- description: "Exit the application",
32
- usage: "/exit",
33
- },
34
- {
35
- command: Command.Clear,
36
- description: "Clear conversation history and free up context",
37
- usage: "/clear",
38
- },
39
- {
40
- command: Command.New,
41
- description: "Start a new conversation",
42
- usage: "/new",
43
- },
44
- {
45
- command: Command.Suggest,
46
- description: "Show available commands and hints",
47
- usage: "/",
48
- },
49
- {
50
- command: Command.Help,
51
- description: "Show commands and functionalities",
52
- usage: "/help",
53
- },
54
- {
55
- command: Command.Sidebar,
56
- description: "Toggle sidebar visibility",
57
- usage: "/sidebar",
58
- },
59
- {
60
- command: Command.Login,
61
- description: "Log in to AbacusAI with email (device code flow)",
62
- usage: "/login <email>",
63
- },
64
- {
65
- command: Command.Logout,
66
- description: "Log out of AbacusAI",
67
- usage: "/logout",
68
- },
69
- {
70
- command: Command.Mcp,
71
- description: "Manage MCP servers",
72
- usage: "/mcp [command] [options]",
73
- },
74
- ];
75
-
76
- export const getCommandInfo = (command: Command): CommandInfo | undefined => {
77
- return COMMAND_INFO.find((info) => info.command === command);
78
- };
79
-
80
- export const getAllCommands = (): Command[] => {
81
- return Object.values(Command);
82
- };
83
-
84
- export const isValidCommand = (input: string): boolean => {
85
- return Object.values(Command).includes(input as Command);
86
- };
87
-
88
- export const formatCommandHelp = (): string => {
89
- const maxUsageLength = Math.max(...COMMAND_INFO.map((info) => info.usage.length));
90
-
91
- return [
92
- "Abacus.AI CLI",
93
- "",
94
- "Abacus.AI CLI has read access to files in the current directory and can run commands and edit files with your permission.",
95
- "",
96
- "Use npx -y @abacus-ai/cli@latest to run latest version of abacusai interactive mode directly from your terminal",
97
- "",
98
- "Usage Modes:",
99
- "• REPL: abacusai (interactive session)",
100
- '• Non-interactive: abacusai -p "question"',
101
- "",
102
- "Run abacusai --help for all command line options",
103
- "",
104
- "For first time users, use /login to authenticate to Abacus.AI CLI",
105
- "",
106
- "Common Tasks:",
107
- "• Ask questions about your codebase > How does agent.py work?",
108
- "• Edit files > Update code.ts to...",
109
- "• Fix errors > cargo build",
110
- "• Run commands > /help",
111
- "• Run bash commands > wc",
112
- "",
113
- "Interactive Mode Commands:",
114
- "",
115
- ...COMMAND_INFO.map((info) => ` ${info.usage.padEnd(maxUsageLength + 2)} ${info.description}`),
116
- "",
117
- "Type any command and press Enter to execute.",
118
- ].join("\n");
119
- };
120
-
121
- export const getCommandSuggestions = (input: string): Command[] => {
122
- return Object.values(Command).filter((cmd) => cmd.toLowerCase().includes(input.toLowerCase()));
123
- };
124
-
125
- export const getCommandWithDescription = (command: Command): string => {
126
- const info = getCommandInfo(command);
127
- return info ? `${command} - ${info.description}` : command;
128
- };
129
-
130
- // MCP subcommands
131
- export enum McpSubcommand {
132
- Add = "add",
133
- Remove = "remove",
134
- List = "list",
135
- Get = "get",
136
- AddJson = "add-json",
137
- Help = "help",
138
- }
139
-
140
- export interface McpCommandInfo {
141
- subcommand: McpSubcommand;
142
- description: string;
143
- usage: string;
144
- }
145
-
146
- export const MCP_COMMAND_INFO: McpCommandInfo[] = [
147
- {
148
- subcommand: McpSubcommand.Add,
149
- description: "Add a server",
150
- usage: "/mcp add <name> <commandOrUrl> [args...]",
151
- },
152
- {
153
- subcommand: McpSubcommand.Remove,
154
- description: "Remove an MCP server",
155
- usage: "/mcp remove <name>",
156
- },
157
- {
158
- subcommand: McpSubcommand.List,
159
- description: "List configured MCP servers",
160
- usage: "/mcp list",
161
- },
162
- {
163
- subcommand: McpSubcommand.Get,
164
- description: "Get details about an MCP server",
165
- usage: "/mcp get <name>",
166
- },
167
- {
168
- subcommand: McpSubcommand.AddJson,
169
- description: "Add an MCP server (stdio or SSE) with a JSON string",
170
- usage: "/mcp add-json <name> <json>",
171
- },
172
- {
173
- subcommand: McpSubcommand.Help,
174
- description: "Display help for MCP commands",
175
- usage: "/mcp help [command]",
176
- },
177
- ];
178
-
179
- export const getMcpCommandInfo = (subcommand: McpSubcommand): McpCommandInfo | undefined => {
180
- return MCP_COMMAND_INFO.find((info) => info.subcommand === subcommand);
181
- };
182
-
183
- export const getAllMcpSubcommands = (): McpSubcommand[] => {
184
- return Object.values(McpSubcommand);
185
- };
186
-
187
- export const isValidMcpSubcommand = (input: string): boolean => {
188
- return Object.values(McpSubcommand).includes(input as McpSubcommand);
189
- };
190
-
191
- export const formatMcpCommandHelp = (): string => {
192
- const maxUsageLength = Math.max(...MCP_COMMAND_INFO.map((info) => info.usage.length));
193
-
194
- return [
195
- "📡 MCP (Model Context Protocol) Commands:",
196
- "",
197
- ...MCP_COMMAND_INFO.map(
198
- (info) => ` ${info.usage.padEnd(maxUsageLength + 2)} ${info.description}`,
199
- ),
200
- "",
201
- "💡 TUI Features:",
202
- " - Full MCP server management from command line",
203
- " - All commands work independently in TUI",
204
- " - Direct file-based configuration access",
205
- "",
206
- ].join("\n");
207
- };
208
-
209
- export const parseMcpCommand = (input: string): { subcommand?: McpSubcommand; args: string[] } => {
210
- const trimmed = input.trim();
211
- if (!trimmed.startsWith("/mcp")) {
212
- return { args: [] };
213
- }
214
-
215
- // Parse arguments respecting quoted strings
216
- const args: string[] = [];
217
- let current = "";
218
- let inQuotes = false;
219
- let quoteChar = "";
220
- let i = 4; // Skip '/mcp'
221
-
222
- // Skip whitespace after /mcp
223
- while (i < trimmed.length && /\s/.test(trimmed[i])) {
224
- i++;
225
- }
226
-
227
- while (i < trimmed.length) {
228
- const char = trimmed[i];
229
-
230
- if (!inQuotes && /\s/.test(char)) {
231
- // End of current argument
232
- if (current) {
233
- args.push(current);
234
- current = "";
235
- }
236
- // Skip whitespace
237
- while (i < trimmed.length && /\s/.test(trimmed[i])) {
238
- i++;
239
- }
240
- continue;
241
- }
242
- if (!inQuotes && (char === '"' || char === "'")) {
243
- // Start of quoted string
244
- inQuotes = true;
245
- quoteChar = char;
246
- } else if (inQuotes && char === quoteChar) {
247
- // End of quoted string
248
- inQuotes = false;
249
- quoteChar = "";
250
- } else {
251
- // Regular character
252
- current += char;
253
- }
254
-
255
- i++;
256
- }
257
-
258
- // Add final argument if any
259
- if (current) {
260
- args.push(current);
261
- }
262
-
263
- const subcommandStr = args[0];
264
- const subcommand = isValidMcpSubcommand(subcommandStr)
265
- ? (subcommandStr as McpSubcommand)
266
- : undefined;
267
- const commandArgs = args.slice(1);
268
-
269
- return { subcommand, args: commandArgs };
270
- };
@@ -1,3 +0,0 @@
1
- // Maximum number of recent conversations to display in the sidebar and related components
2
- export const MAX_RECENT_CONVERSATIONS = 25;
3
- export const TOOL_CALL_LIMIT = Number.MAX_SAFE_INTEGER; // Disabling tool call limit for CLI TODO (raj): Consider adding it back and separating the permissions flow