@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,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
@@ -1,181 +0,0 @@
1
- import type { ContractRouterClient } from "@orpc/contract";
2
-
3
- import { createSocketClient, ideContract } from "@codellm/comms";
4
- import { product } from "@codellm/product";
5
- import { createORPCClient } from "@orpc/client";
6
- import * as fs from "fs";
7
- import * as os from "os";
8
- import * as path from "path";
9
-
10
- import type { CliPushServer } from "./cli-push-server.js";
11
-
12
- type IdeClient = ContractRouterClient<typeof ideContract>;
13
-
14
- /**
15
- * Client to connect manual CLI to the VS Code extension via oRPC over Unix socket.
16
- * Uses push-based communication — no polling.
17
- */
18
- export class ExtensionConnection {
19
- private client: IdeClient | null = null;
20
- private disposeSocket: (() => void) | null = null;
21
-
22
- private currentFile: string | undefined = undefined;
23
- private selectionStartLine: number | undefined = undefined;
24
- private selectionEndLine: number | undefined = undefined;
25
-
26
- private onFileChangeCallback:
27
- | ((file: string | undefined, startLine?: number, endLine?: number) => void)
28
- | null = null;
29
-
30
- constructor(private readonly pushServer: CliPushServer) {}
31
-
32
- private findSocketPath(): string | null {
33
- const envPath = process.env[product.socketEnvVar];
34
- if (envPath && fs.existsSync(envPath)) {
35
- return envPath;
36
- }
37
-
38
- // Fallback: scan the IDE socket dir for the most recently modified socket file
39
- // This handles the case where the terminal was opened before the extension set the env var
40
- try {
41
- const socketDir = path.join(os.homedir(), product.configDirName, product.ideDirName);
42
- const entries = fs.readdirSync(socketDir).filter((f) => f.endsWith(".sock"));
43
- if (entries.length === 0) return null;
44
-
45
- let best: { path: string; mtime: number } | null = null;
46
- for (const entry of entries) {
47
- const fullPath = path.join(socketDir, entry);
48
- try {
49
- const stat = fs.statSync(fullPath);
50
- if (!best || stat.mtimeMs > best.mtime) {
51
- best = { path: fullPath, mtime: stat.mtimeMs };
52
- }
53
- } catch {
54
- // stale entry
55
- }
56
- }
57
- if (best && fs.existsSync(best.path)) return best.path;
58
- } catch {
59
- // ignore
60
- }
61
- return null;
62
- }
63
-
64
- async connect(): Promise<boolean> {
65
- try {
66
- const socketPath = this.findSocketPath();
67
- if (!socketPath) {
68
- return false;
69
- }
70
-
71
- const handle = await createSocketClient(socketPath, { timeoutMs: 2000 });
72
- this.client = createORPCClient<IdeClient>(handle.link);
73
- this.disposeSocket = () => handle.dispose();
74
-
75
- // Register our push server with the extension
76
- await this.client.register({
77
- cliSocketPath: this.pushServer.socketPath,
78
- pid: process.pid,
79
- });
80
-
81
- // Seed state from push server (may already have state)
82
- const state = this.pushServer.getEditorState();
83
- this.currentFile = state.file;
84
- this.selectionStartLine = state.startLine;
85
- this.selectionEndLine = state.endLine;
86
-
87
- // Wire push-based updates
88
- this.pushServer.onEditorChange((s) => {
89
- this.currentFile = s.file;
90
- this.selectionStartLine = s.startLine;
91
- this.selectionEndLine = s.endLine;
92
- this.onFileChangeCallback?.(s.file, s.startLine, s.endLine);
93
- });
94
-
95
- return true;
96
- } catch {
97
- return false;
98
- }
99
- }
100
-
101
- getCurrentFile(): string | undefined {
102
- return this.currentFile;
103
- }
104
-
105
- getSelectionRange(): { startLine?: number; endLine?: number } {
106
- return {
107
- startLine: this.selectionStartLine,
108
- endLine: this.selectionEndLine,
109
- };
110
- }
111
-
112
- isConnected(): boolean {
113
- return this.client !== null;
114
- }
115
-
116
- onFileChange(
117
- callback: (file: string | undefined, startLine?: number, endLine?: number) => void,
118
- ): void {
119
- this.onFileChangeCallback = callback;
120
- }
121
-
122
- async showDiff(params: {
123
- filePath: string;
124
- originalContent: string;
125
- modifiedContent: string;
126
- toolId: string;
127
- }): Promise<boolean> {
128
- if (!this.client) return false;
129
- try {
130
- const result = await this.client.showDiff({
131
- ...params,
132
- cliSocketPath: this.pushServer.socketPath,
133
- });
134
- return result.success;
135
- } catch {
136
- return false;
137
- }
138
- }
139
-
140
- async showToolView(params: { filePath: string; toolKey: string }): Promise<boolean> {
141
- if (!this.client) return false;
142
- try {
143
- const result = await this.client.showToolView({
144
- ...params,
145
- cliSocketPath: this.pushServer.socketPath,
146
- });
147
- return result.success;
148
- } catch {
149
- return false;
150
- }
151
- }
152
-
153
- async notifyDiffDecision(params: {
154
- targetFile: string;
155
- decision: "accept" | "reject";
156
- }): Promise<void> {
157
- if (!this.client) throw new Error("Not connected to extension");
158
- await this.client.notifyDiffDecision(params);
159
- }
160
-
161
- async openPlanFile(planFilePath: string): Promise<{ opened: boolean }> {
162
- if (!this.client) throw new Error("Not connected to extension");
163
- const result = await this.client.openFile({ file: planFilePath });
164
- return { opened: result.success };
165
- }
166
-
167
- async getDiagnostics(files?: string[]): Promise<unknown> {
168
- if (!this.client) throw new Error("Not connected to extension");
169
- return this.client.getDiagnostics({ ...(files && { files }) });
170
- }
171
-
172
- dispose(): void {
173
- this.disposeSocket?.();
174
- this.disposeSocket = null;
175
- this.client = null;
176
- this.currentFile = undefined;
177
- this.selectionStartLine = undefined;
178
- this.selectionEndLine = undefined;
179
- this.onFileChangeCallback = null;
180
- }
181
- }
@@ -1,7 +0,0 @@
1
- export enum Focusable {
2
- Composer = "composer",
3
- ModelSelector = "model-selector",
4
- Messages = "messages",
5
- Sidebar = "sidebar",
6
- ToolPermission = "tool-permission",
7
- }