@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.
- package/dist/index.mjs +807 -561
- package/package.json +4 -1
- package/.oxlintrc.json +0 -8
- package/resources/abacus.ico +0 -0
- package/resources/entitlements.plist +0 -9
- package/src/__e2e__/README.md +0 -196
- package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
- package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
- package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
- package/src/__e2e__/conversation.e2e.test.tsx +0 -56
- package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
- package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
- package/src/__e2e__/helpers/test-helpers.ts +0 -450
- package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
- package/src/__e2e__/llm-models.e2e.test.ts +0 -402
- package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
- package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
- package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
- package/src/__e2e__/repl.e2e.test.tsx +0 -78
- package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
- package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
- package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
- package/src/args.ts +0 -22
- package/src/components/__tests__/react-compiler.test.tsx +0 -78
- package/src/components/__tests__/status-indicator.test.tsx +0 -403
- package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
- package/src/components/composer/agent-mode-indicator.tsx +0 -63
- package/src/components/composer/bash-runner.tsx +0 -54
- package/src/components/composer/commands/default-commands.tsx +0 -615
- package/src/components/composer/commands/handler.tsx +0 -59
- package/src/components/composer/commands/picker.tsx +0 -273
- package/src/components/composer/commands/registry.ts +0 -233
- package/src/components/composer/commands/types.ts +0 -33
- package/src/components/composer/context.tsx +0 -88
- package/src/components/composer/file-mention-picker.tsx +0 -83
- package/src/components/composer/help.tsx +0 -44
- package/src/components/composer/index.tsx +0 -1006
- package/src/components/composer/mentions.ts +0 -57
- package/src/components/composer/message-queue.tsx +0 -70
- package/src/components/composer/mode-panel.tsx +0 -35
- package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
- package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
- package/src/components/composer/modes/bash-handler.tsx +0 -132
- package/src/components/composer/modes/bash-renderer.tsx +0 -175
- package/src/components/composer/modes/default-handlers.tsx +0 -33
- package/src/components/composer/modes/index.ts +0 -41
- package/src/components/composer/modes/types.ts +0 -21
- package/src/components/composer/persistent-shell.ts +0 -283
- package/src/components/composer/process.ts +0 -65
- package/src/components/composer/types.ts +0 -9
- package/src/components/composer/use-mention-search.ts +0 -68
- package/src/components/error-boundry.tsx +0 -60
- package/src/components/exit-message.tsx +0 -29
- package/src/components/expanded-view.tsx +0 -74
- package/src/components/file-completion.tsx +0 -127
- package/src/components/header.tsx +0 -47
- package/src/components/logo.tsx +0 -37
- package/src/components/segments.tsx +0 -356
- package/src/components/status-indicator.tsx +0 -306
- package/src/components/tool-group-summary.tsx +0 -263
- package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -312
- package/src/components/tool-permissions/diff-preview.tsx +0 -355
- package/src/components/tool-permissions/index.ts +0 -5
- package/src/components/tool-permissions/permission-options.tsx +0 -375
- package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
- package/src/components/tool-permissions/tool-permission-ui.tsx +0 -398
- package/src/components/tools/agent/ask-user-question.tsx +0 -101
- package/src/components/tools/agent/enter-plan-mode.tsx +0 -49
- package/src/components/tools/agent/exit-plan-mode.tsx +0 -75
- package/src/components/tools/agent/handoff-to-main.tsx +0 -27
- package/src/components/tools/agent/subagent.tsx +0 -37
- package/src/components/tools/agent/todo-write.tsx +0 -104
- package/src/components/tools/browser/close-tab.tsx +0 -58
- package/src/components/tools/browser/computer.tsx +0 -70
- package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
- package/src/components/tools/browser/get-tab-content.tsx +0 -51
- package/src/components/tools/browser/navigate-to.tsx +0 -59
- package/src/components/tools/browser/new-tab.tsx +0 -60
- package/src/components/tools/browser/perform-action.tsx +0 -63
- package/src/components/tools/browser/refresh-tab.tsx +0 -43
- package/src/components/tools/browser/switch-tab.tsx +0 -58
- package/src/components/tools/filesystem/delete-file.tsx +0 -104
- package/src/components/tools/filesystem/edit.tsx +0 -220
- package/src/components/tools/filesystem/list-dir.tsx +0 -78
- package/src/components/tools/filesystem/read-file.tsx +0 -180
- package/src/components/tools/filesystem/upload-image.tsx +0 -76
- package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
- package/src/components/tools/index.ts +0 -91
- package/src/components/tools/mcp/mcp-tool.tsx +0 -158
- package/src/components/tools/search/fetch-url.tsx +0 -73
- package/src/components/tools/search/file-search.tsx +0 -78
- package/src/components/tools/search/grep.tsx +0 -90
- package/src/components/tools/search/semantic-search.tsx +0 -66
- package/src/components/tools/search/web-search.tsx +0 -71
- package/src/components/tools/shared/index.tsx +0 -48
- package/src/components/tools/shared/zod-coercion.ts +0 -35
- package/src/components/tools/terminal/bash-tool-output.tsx +0 -174
- package/src/components/tools/terminal/get-terminal-output.tsx +0 -85
- package/src/components/tools/terminal/run-in-terminal.tsx +0 -106
- package/src/components/tools/types.ts +0 -16
- package/src/components/tools.tsx +0 -66
- package/src/components/ui/__tests__/divider.test.tsx +0 -61
- package/src/components/ui/__tests__/gradient.test.tsx +0 -125
- package/src/components/ui/__tests__/input.test.tsx +0 -166
- package/src/components/ui/__tests__/select.test.tsx +0 -273
- package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
- package/src/components/ui/blinking-indicator.tsx +0 -25
- package/src/components/ui/divider.tsx +0 -162
- package/src/components/ui/gradient.tsx +0 -56
- package/src/components/ui/input.tsx +0 -228
- package/src/components/ui/select.tsx +0 -151
- package/src/components/ui/shimmer.tsx +0 -84
- package/src/context/agent-mode.tsx +0 -95
- package/src/context/extension-file.tsx +0 -136
- package/src/context/network-activity.tsx +0 -45
- package/src/context/notification.tsx +0 -62
- package/src/context/shell-size.tsx +0 -49
- package/src/context/shell-title.tsx +0 -38
- package/src/entrypoints/print-mode.ts +0 -312
- package/src/entrypoints/repl.tsx +0 -401
- package/src/hooks/use-agent.ts +0 -15
- package/src/hooks/use-api-client.ts +0 -1
- package/src/hooks/use-available-height.ts +0 -8
- package/src/hooks/use-cleanup.ts +0 -29
- package/src/hooks/use-interrupt-manager.ts +0 -242
- package/src/hooks/use-models.ts +0 -22
- package/src/index.ts +0 -217
- package/src/lib/__tests__/ansi.test.ts +0 -255
- package/src/lib/__tests__/cli.test.ts +0 -122
- package/src/lib/__tests__/commands.test.ts +0 -325
- package/src/lib/__tests__/constants.test.ts +0 -15
- package/src/lib/__tests__/focusables.test.ts +0 -25
- package/src/lib/__tests__/fs.test.ts +0 -231
- package/src/lib/__tests__/markdown.test.tsx +0 -348
- package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
- package/src/lib/__tests__/mcpManagement.test.ts +0 -38
- package/src/lib/__tests__/path-paste.test.ts +0 -144
- package/src/lib/__tests__/path.test.ts +0 -300
- package/src/lib/__tests__/queries.test.ts +0 -39
- package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
- package/src/lib/__tests__/text-buffer.test.ts +0 -328
- package/src/lib/__tests__/text-utils.test.ts +0 -32
- package/src/lib/__tests__/timing.test.ts +0 -78
- package/src/lib/__tests__/utils.test.ts +0 -238
- package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
- package/src/lib/ansi.ts +0 -150
- package/src/lib/cli-push-server.ts +0 -112
- package/src/lib/cli.ts +0 -44
- package/src/lib/clipboard.ts +0 -226
- package/src/lib/command-utils.ts +0 -93
- package/src/lib/commands.ts +0 -270
- package/src/lib/constants.ts +0 -3
- package/src/lib/extension-connection.ts +0 -181
- package/src/lib/focusables.ts +0 -7
- package/src/lib/fs.ts +0 -533
- package/src/lib/markdown/code-block.tsx +0 -63
- package/src/lib/markdown/index.ts +0 -4
- package/src/lib/markdown/link.tsx +0 -19
- package/src/lib/markdown/markdown.tsx +0 -372
- package/src/lib/markdown/types.ts +0 -15
- package/src/lib/mcpCommandHandler.ts +0 -121
- package/src/lib/mcpManagement.ts +0 -44
- package/src/lib/path-paste.ts +0 -185
- package/src/lib/path.ts +0 -179
- package/src/lib/queries.ts +0 -15
- package/src/lib/standaloneMcpService.ts +0 -688
- package/src/lib/status-utils.ts +0 -237
- package/src/lib/test-utils.tsx +0 -72
- package/src/lib/text-buffer.ts +0 -2415
- package/src/lib/text-utils.ts +0 -272
- package/src/lib/timing.ts +0 -63
- package/src/lib/types.ts +0 -295
- package/src/lib/utils.ts +0 -182
- package/src/lib/vim-buffer-actions.ts +0 -732
- package/src/providers/agent.tsx +0 -1075
- package/src/providers/api-client.tsx +0 -43
- package/src/services/logger.ts +0 -85
- package/src/terminal/detection.ts +0 -187
- package/src/terminal/exit.ts +0 -279
- package/src/terminal/notification.ts +0 -83
- package/src/terminal/progress.ts +0 -201
- package/src/terminal/setup.ts +0 -797
- package/src/terminal/suspend.ts +0 -58
- package/src/terminal/types.ts +0 -51
- package/src/theme/context.tsx +0 -57
- package/src/theme/index.ts +0 -4
- package/src/theme/themed.tsx +0 -35
- package/src/theme/themes.json +0 -546
- package/src/theme/types.ts +0 -110
- package/src/tools/types.ts +0 -59
- package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
- package/src/tools/utils/tool-ui-components.tsx +0 -631
- package/src/tools/utils/zod-coercion.ts +0 -35
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -29
- package/tsconfig.test.json +0 -27
- package/tsdown.config.ts +0 -17
- package/vitest.config.ts +0 -76
package/src/lib/command-utils.ts
DELETED
|
@@ -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
|
-
};
|
package/src/lib/commands.ts
DELETED
|
@@ -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
|
-
};
|
package/src/lib/constants.ts
DELETED
|
@@ -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
|
-
}
|