@abacus-ai/cli 2.0.0-canary.1 → 2.0.0-canary.3
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 +450 -422
- 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 -449
- 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 -1007
- 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 -319
- package/src/components/tool-permissions/diff-preview.tsx +0 -359
- package/src/components/tool-permissions/index.ts +0 -5
- package/src/components/tool-permissions/permission-options.tsx +0 -401
- package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
- package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
- package/src/components/tools/agent/ask-user-question.tsx +0 -107
- package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
- package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
- 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 -188
- package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
- package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
- package/src/components/tools/types.ts +0 -16
- package/src/components/tools.tsx +0 -68
- 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 -27
- 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 -76
- 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 -389
- 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 -1063
- 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/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 -649
- package/src/tools/utils/zod-coercion.ts +0 -35
- package/tsconfig.json +0 -16
- package/tsconfig.node.json +0 -29
- package/tsconfig.test.json +0 -27
- package/tsdown.config.ts +0 -17
- package/vitest.config.ts +0 -76
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
// @vitest-environment node
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it, beforeEach, vi } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { McpCommandHandler, helpText } from "../mcpCommandHandler.js";
|
|
6
|
-
|
|
7
|
-
describe.concurrent("McpCommandHandler", () => {
|
|
8
|
-
let mockMcp: any;
|
|
9
|
-
let handler: McpCommandHandler;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
mockMcp = {
|
|
13
|
-
listServers: vi.fn().mockReturnValue([]),
|
|
14
|
-
addServer: vi.fn().mockResolvedValue([]),
|
|
15
|
-
removeServer: vi.fn().mockResolvedValue(undefined),
|
|
16
|
-
callTool: vi.fn().mockResolvedValue(undefined),
|
|
17
|
-
getTools: vi.fn().mockReturnValue([]),
|
|
18
|
-
refresh: vi.fn().mockResolvedValue(undefined),
|
|
19
|
-
};
|
|
20
|
-
handler = new McpCommandHandler(mockMcp);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe.concurrent("constructor", () => {
|
|
24
|
-
it("should create instance without mcp", () => {
|
|
25
|
-
const handler = new McpCommandHandler();
|
|
26
|
-
expect(handler).toBeInstanceOf(McpCommandHandler);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should create instance with mcp", () => {
|
|
30
|
-
const handler = new McpCommandHandler(mockMcp);
|
|
31
|
-
expect(handler).toBeInstanceOf(McpCommandHandler);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe.concurrent("listServers", () => {
|
|
36
|
-
it("should list servers and return formatted string", async () => {
|
|
37
|
-
const result = await handler.listServers();
|
|
38
|
-
expect(typeof result).toBe("string");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should handle empty server list", async () => {
|
|
42
|
-
const result = await handler.listServers();
|
|
43
|
-
// Should return a string even if empty
|
|
44
|
-
expect(typeof result).toBe("string");
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe.sequential("addServer", () => {
|
|
49
|
-
it("should add server and refresh mcp", async () => {
|
|
50
|
-
await handler.addServer("test-server-1", "command", []);
|
|
51
|
-
// refresh is called in background, just ensure no throw
|
|
52
|
-
expect(true).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("should add server with extra args", async () => {
|
|
56
|
-
await handler.addServer("test-server-2", "command", ["arg1", "arg2"]);
|
|
57
|
-
expect(true).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should work without tuiMcpService", async () => {
|
|
61
|
-
const handlerWithoutService = new McpCommandHandler();
|
|
62
|
-
await handlerWithoutService.addServer("test-server-3", "command", []);
|
|
63
|
-
// Should not throw
|
|
64
|
-
expect(true).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe.sequential("removeServer", () => {
|
|
69
|
-
// TODO: These tests rely on file system state and need proper isolation/mocking
|
|
70
|
-
// Skipping for now as they require integration test setup with temp directories
|
|
71
|
-
it.skip("should remove server and reload connections", async () => {
|
|
72
|
-
// This test relies on 'test-server-1' being added by the addServer tests above
|
|
73
|
-
await handler.removeServer("test-server-1");
|
|
74
|
-
expect(true).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it.skip("should work without tuiMcpService", async () => {
|
|
78
|
-
const handlerWithoutService = new McpCommandHandler();
|
|
79
|
-
// This test relies on 'test-server-2' being added by the addServer tests above
|
|
80
|
-
await handlerWithoutService.removeServer("test-server-2");
|
|
81
|
-
// Should not throw
|
|
82
|
-
expect(true).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("should throw error when removing non-existent server", async () => {
|
|
86
|
-
const handlerWithoutService = new McpCommandHandler();
|
|
87
|
-
// TODO: Consider making removeServer return a boolean or handle
|
|
88
|
-
// non-existent servers more gracefully instead of throwing.
|
|
89
|
-
await expect(handlerWithoutService.removeServer("nonexistent-server")).rejects.toThrow();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe.concurrent("getServer", () => {
|
|
94
|
-
it("should return formatted server info when server exists", async () => {
|
|
95
|
-
// First add a server
|
|
96
|
-
await handler.addServer("test-server", "command", []);
|
|
97
|
-
const result = await handler.getServer("test-server");
|
|
98
|
-
expect(result).toBeDefined();
|
|
99
|
-
if (result) {
|
|
100
|
-
expect(typeof result).toBe("string");
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("should return null when server does not exist", async () => {
|
|
105
|
-
const result = await handler.getServer("nonexistent-server");
|
|
106
|
-
expect(result).toBeNull();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe.concurrent("addServerFromJson", () => {
|
|
111
|
-
it("should add server from JSON and refresh mcp", async () => {
|
|
112
|
-
const jsonConfig = JSON.stringify({
|
|
113
|
-
type: "stdio",
|
|
114
|
-
command: "node",
|
|
115
|
-
args: ["server.js"],
|
|
116
|
-
});
|
|
117
|
-
await handler.addServerFromJson("test-server", jsonConfig);
|
|
118
|
-
expect(true).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("should work without tuiMcpService", async () => {
|
|
122
|
-
const handlerWithoutService = new McpCommandHandler();
|
|
123
|
-
const jsonConfig = JSON.stringify({
|
|
124
|
-
type: "stdio",
|
|
125
|
-
command: "node",
|
|
126
|
-
args: ["server.js"],
|
|
127
|
-
});
|
|
128
|
-
await handlerWithoutService.addServerFromJson("test-server", jsonConfig);
|
|
129
|
-
// Should not throw
|
|
130
|
-
expect(true).toBe(true);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("should handle invalid JSON gracefully", async () => {
|
|
134
|
-
// TODO: The addServerFromJson method should validate JSON and throw
|
|
135
|
-
// a meaningful error for invalid JSON. Currently it may throw
|
|
136
|
-
// a generic error from JSON.parse.
|
|
137
|
-
try {
|
|
138
|
-
await handler.addServerFromJson("test-server", "invalid json");
|
|
139
|
-
} catch (error) {
|
|
140
|
-
expect(error).toBeDefined();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe.concurrent("formatHelp", () => {
|
|
146
|
-
it("should return help text", () => {
|
|
147
|
-
const result = handler.formatHelp();
|
|
148
|
-
expect(result).toBe(helpText);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("should return help text with MCP commands", () => {
|
|
152
|
-
const result = handler.formatHelp();
|
|
153
|
-
expect(result).toContain("MCP");
|
|
154
|
-
expect(result).toContain("/mcp list");
|
|
155
|
-
expect(result).toContain("/mcp add");
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe.concurrent("helpText export", () => {
|
|
160
|
-
it("should export help text constant", () => {
|
|
161
|
-
expect(typeof helpText).toBe("string");
|
|
162
|
-
expect(helpText.length).toBeGreaterThan(0);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("should contain expected command descriptions", () => {
|
|
166
|
-
expect(helpText).toContain("list");
|
|
167
|
-
expect(helpText).toContain("add");
|
|
168
|
-
expect(helpText).toContain("remove");
|
|
169
|
-
expect(helpText).toContain("get");
|
|
170
|
-
expect(helpText).toContain("add-json");
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// @vitest-environment node
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { McpManagementService } from "../mcpManagement.js";
|
|
6
|
-
|
|
7
|
-
describe.concurrent("McpManagementService", () => {
|
|
8
|
-
describe.concurrent("constructor", () => {
|
|
9
|
-
it("should create instance", () => {
|
|
10
|
-
const service = new McpManagementService();
|
|
11
|
-
expect(service).toBeInstanceOf(McpManagementService);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe.concurrent("listServers", () => {
|
|
16
|
-
it("should return array of servers", async () => {
|
|
17
|
-
const service = new McpManagementService();
|
|
18
|
-
const servers = await service.listServers();
|
|
19
|
-
expect(Array.isArray(servers)).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe.concurrent("formatServerList", () => {
|
|
24
|
-
it("should format empty server list", () => {
|
|
25
|
-
const service = new McpManagementService();
|
|
26
|
-
const formatted = service.formatServerList([]);
|
|
27
|
-
expect(typeof formatted).toBe("string");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe.concurrent("getServer", () => {
|
|
32
|
-
it("should return undefined for non-existent server", async () => {
|
|
33
|
-
const service = new McpManagementService();
|
|
34
|
-
const server = await service.getServer("nonexistent-server-12345");
|
|
35
|
-
expect(server).toBeUndefined();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
// @vitest-environment node
|
|
2
|
-
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, expect, it, vi } from "vitest";
|
|
5
|
-
|
|
6
|
-
import { stripFileProtocol } from "../clipboard.js";
|
|
7
|
-
import {
|
|
8
|
-
splitDragAndDropPaths,
|
|
9
|
-
parsePastedPaths,
|
|
10
|
-
escapePathForMention,
|
|
11
|
-
isImagePath,
|
|
12
|
-
} from "../path-paste.js";
|
|
13
|
-
|
|
14
|
-
describe.concurrent("path-paste", () => {
|
|
15
|
-
describe.concurrent("splitDragAndDropPaths", () => {
|
|
16
|
-
it("should parse a bare POSIX path", () => {
|
|
17
|
-
const results = [...splitDragAndDropPaths("/usr/local/bin/node")];
|
|
18
|
-
expect(results).toEqual(["/usr/local/bin/node"]);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should parse backslash-escaped spaces", () => {
|
|
22
|
-
const results = [...splitDragAndDropPaths("/path/to/my\\ file.txt")];
|
|
23
|
-
expect(results).toEqual(["/path/to/my file.txt"]);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should parse single-quoted paths", () => {
|
|
27
|
-
const results = [...splitDragAndDropPaths("'/path/to/my file.txt'")];
|
|
28
|
-
expect(results).toEqual(["/path/to/my file.txt"]);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should parse double-quoted Windows paths", () => {
|
|
32
|
-
const results = [...splitDragAndDropPaths('"C:\\Users\\test\\file.txt"')];
|
|
33
|
-
expect(results.length).toBe(1);
|
|
34
|
-
expect(results[0]).toMatch(/file\.txt$/);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should parse file:// URIs with percent-encoding", () => {
|
|
38
|
-
const results = [...splitDragAndDropPaths("file:///path/to/my%20file.txt")];
|
|
39
|
-
expect(results).toEqual(["/path/to/my file.txt"]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should parse PowerShell & 'path' syntax", () => {
|
|
43
|
-
const results = [...splitDragAndDropPaths("& '/path/to/my file.txt'")];
|
|
44
|
-
expect(results).toEqual(["/path/to/my file.txt"]);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should parse multiple space-separated bare paths", () => {
|
|
48
|
-
const results = [...splitDragAndDropPaths("/a/b.txt /c/d.txt")];
|
|
49
|
-
expect(results).toEqual(["/a/b.txt", "/c/d.txt"]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should parse multiple single-quoted paths", () => {
|
|
53
|
-
const results = [...splitDragAndDropPaths("'/a/b c.txt' '/d/e f.txt'")];
|
|
54
|
-
expect(results).toEqual(["/a/b c.txt", "/d/e f.txt"]);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should return nothing for non-path text", () => {
|
|
58
|
-
const results = [...splitDragAndDropPaths("hello world")];
|
|
59
|
-
expect(results).toEqual([]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should handle Windows UNC paths", () => {
|
|
63
|
-
const results = [...splitDragAndDropPaths("\\\\Mac\\Home\\file.txt")];
|
|
64
|
-
expect(results.length).toBe(1);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("should handle quoted paths starting with quotes", () => {
|
|
68
|
-
const results = [...splitDragAndDropPaths("'/tmp/test.txt'")];
|
|
69
|
-
expect(results).toEqual(["/tmp/test.txt"]);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe.concurrent("parsePastedPaths", () => {
|
|
74
|
-
it("should return null for non-path text", () => {
|
|
75
|
-
expect(parsePastedPaths("hello world")).toBeNull();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("should return null when paths don't exist on disk", () => {
|
|
79
|
-
expect(parsePastedPaths("/nonexistent/path/xyz123.txt")).toBeNull();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should return formatted @mentions for paths that exist", () => {
|
|
83
|
-
const thisFile = path.resolve(__dirname, "path-paste.test.ts");
|
|
84
|
-
const result = parsePastedPaths(thisFile);
|
|
85
|
-
expect(result).not.toBeNull();
|
|
86
|
-
expect(result).toContain("@");
|
|
87
|
-
expect(result!.endsWith(" ")).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe.concurrent("escapePathForMention", () => {
|
|
92
|
-
it("should return path as-is when no spaces", () => {
|
|
93
|
-
expect(escapePathForMention("./src/foo.ts")).toBe("./src/foo.ts");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("should wrap paths with spaces in single quotes", () => {
|
|
97
|
-
expect(escapePathForMention("./my file.ts")).toBe("'./my file.ts'");
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("should escape single quotes within paths", () => {
|
|
101
|
-
const result = escapePathForMention("./it's a file.ts");
|
|
102
|
-
expect(result).toContain("'\\''");
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe.concurrent("isImagePath", () => {
|
|
107
|
-
it("should detect png files", () => {
|
|
108
|
-
expect(isImagePath("screenshot.png")).toBe(true);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("should detect jpg files", () => {
|
|
112
|
-
expect(isImagePath("photo.jpg")).toBe(true);
|
|
113
|
-
expect(isImagePath("photo.jpeg")).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("should detect webp files", () => {
|
|
117
|
-
expect(isImagePath("image.webp")).toBe(true);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("should return false for non-image files", () => {
|
|
121
|
-
expect(isImagePath("readme.md")).toBe(false);
|
|
122
|
-
expect(isImagePath("script.ts")).toBe(false);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe.concurrent("stripFileProtocol", () => {
|
|
128
|
-
it("should strip file:// prefix", () => {
|
|
129
|
-
expect(stripFileProtocol("file:///path/to/file.txt")).toBe("/path/to/file.txt");
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("should decode percent-encoded characters", () => {
|
|
133
|
-
expect(stripFileProtocol("file:///path/to/my%20file.txt")).toBe("/path/to/my file.txt");
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("should return non-file:// strings unchanged", () => {
|
|
137
|
-
expect(stripFileProtocol("/plain/path.txt")).toBe("/plain/path.txt");
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should handle malformed percent-encoding gracefully", () => {
|
|
141
|
-
const result = stripFileProtocol("file:///path/%ZZ/bad");
|
|
142
|
-
expect(typeof result).toBe("string");
|
|
143
|
-
});
|
|
144
|
-
});
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
// @vitest-environment node
|
|
2
|
-
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import os from "node:os";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { describe, expect, it, vi, afterEach } from "vitest";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
SHELL_SPECIAL_CHARS,
|
|
10
|
-
unescapePath,
|
|
11
|
-
abbreviateHome,
|
|
12
|
-
abbreviateCwd,
|
|
13
|
-
convertAbsoluteToRelativePath,
|
|
14
|
-
} from "../path.js";
|
|
15
|
-
|
|
16
|
-
describe.concurrent("path", () => {
|
|
17
|
-
describe.concurrent("SHELL_SPECIAL_CHARS", () => {
|
|
18
|
-
it("should match spaces", () => {
|
|
19
|
-
expect(SHELL_SPECIAL_CHARS.test(" ")).toBe(true);
|
|
20
|
-
expect(SHELL_SPECIAL_CHARS.test("file name.txt")).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should match parentheses", () => {
|
|
24
|
-
expect(SHELL_SPECIAL_CHARS.test("(")).toBe(true);
|
|
25
|
-
expect(SHELL_SPECIAL_CHARS.test(")")).toBe(true);
|
|
26
|
-
expect(SHELL_SPECIAL_CHARS.test("file(name).txt")).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should match brackets", () => {
|
|
30
|
-
expect(SHELL_SPECIAL_CHARS.test("[")).toBe(true);
|
|
31
|
-
expect(SHELL_SPECIAL_CHARS.test("]")).toBe(true);
|
|
32
|
-
expect(SHELL_SPECIAL_CHARS.test("file[name].txt")).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should match braces", () => {
|
|
36
|
-
expect(SHELL_SPECIAL_CHARS.test("{")).toBe(true);
|
|
37
|
-
expect(SHELL_SPECIAL_CHARS.test("}")).toBe(true);
|
|
38
|
-
expect(SHELL_SPECIAL_CHARS.test("file{name}.txt")).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should match semicolons", () => {
|
|
42
|
-
expect(SHELL_SPECIAL_CHARS.test(";")).toBe(true);
|
|
43
|
-
expect(SHELL_SPECIAL_CHARS.test("file;name.txt")).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should match other special characters", () => {
|
|
47
|
-
expect(SHELL_SPECIAL_CHARS.test("|")).toBe(true);
|
|
48
|
-
expect(SHELL_SPECIAL_CHARS.test("*")).toBe(true);
|
|
49
|
-
expect(SHELL_SPECIAL_CHARS.test("?")).toBe(true);
|
|
50
|
-
expect(SHELL_SPECIAL_CHARS.test("$")).toBe(true);
|
|
51
|
-
expect(SHELL_SPECIAL_CHARS.test("`")).toBe(true);
|
|
52
|
-
expect(SHELL_SPECIAL_CHARS.test("'")).toBe(true);
|
|
53
|
-
expect(SHELL_SPECIAL_CHARS.test('"')).toBe(true);
|
|
54
|
-
expect(SHELL_SPECIAL_CHARS.test("#")).toBe(true);
|
|
55
|
-
expect(SHELL_SPECIAL_CHARS.test("&")).toBe(true);
|
|
56
|
-
expect(SHELL_SPECIAL_CHARS.test("<")).toBe(true);
|
|
57
|
-
expect(SHELL_SPECIAL_CHARS.test(">")).toBe(true);
|
|
58
|
-
expect(SHELL_SPECIAL_CHARS.test("!")).toBe(true);
|
|
59
|
-
expect(SHELL_SPECIAL_CHARS.test("~")).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should not match regular alphanumeric characters", () => {
|
|
63
|
-
expect(SHELL_SPECIAL_CHARS.test("abc123")).toBe(false);
|
|
64
|
-
expect(SHELL_SPECIAL_CHARS.test("file.txt")).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe.concurrent("unescapePath", () => {
|
|
69
|
-
it("should unescape spaces", () => {
|
|
70
|
-
expect(unescapePath("file\\ name.txt")).toBe("file name.txt");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("should unescape parentheses", () => {
|
|
74
|
-
expect(unescapePath("file\\(name\\).txt")).toBe("file(name).txt");
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should unescape brackets", () => {
|
|
78
|
-
expect(unescapePath("file\\[name\\].txt")).toBe("file[name].txt");
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should unescape braces", () => {
|
|
82
|
-
expect(unescapePath("file\\{name\\}.txt")).toBe("file{name}.txt");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("should unescape semicolons", () => {
|
|
86
|
-
expect(unescapePath("file\\;name.txt")).toBe("file;name.txt");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should unescape multiple special characters", () => {
|
|
90
|
-
expect(unescapePath("file\\ name\\[1\\].txt")).toBe("file name[1].txt");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should handle paths without escaping", () => {
|
|
94
|
-
expect(unescapePath("filename.txt")).toBe("filename.txt");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should handle empty strings", () => {
|
|
98
|
-
expect(unescapePath("")).toBe("");
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe.concurrent("abbreviateHome", () => {
|
|
103
|
-
const actualHome = os.homedir();
|
|
104
|
-
|
|
105
|
-
it("should abbreviate home directory to ~", () => {
|
|
106
|
-
expect(abbreviateHome(actualHome)).toBe("~");
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("should abbreviate paths under home directory", () => {
|
|
110
|
-
const testPath = path.join(actualHome, "documents", "file.txt");
|
|
111
|
-
const result = abbreviateHome(testPath);
|
|
112
|
-
expect(result).toBe("~/documents/file.txt");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("should not abbreviate paths outside home directory", () => {
|
|
116
|
-
// Use a path that's definitely outside home
|
|
117
|
-
const testPath = process.platform === "win32" ? "C:\\Windows\\System32" : "/usr/bin";
|
|
118
|
-
const result = abbreviateHome(testPath);
|
|
119
|
-
expect(result).toBe(path.resolve(testPath));
|
|
120
|
-
expect(result).not.toContain("~");
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("should handle relative paths by resolving them first", () => {
|
|
124
|
-
// Create a relative path that resolves to home
|
|
125
|
-
expect(abbreviateHome(".", actualHome)).toBe("~");
|
|
126
|
-
|
|
127
|
-
expect(abbreviateHome("./documents/file.txt", actualHome)).toBe("~/documents/file.txt");
|
|
128
|
-
expect(abbreviateHome("./file.txt", actualHome)).toBe("~/file.txt");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("if relative path is outside home directory, it should not be abbreviated", () => {
|
|
132
|
-
expect(abbreviateHome("../documents/file.txt", actualHome)).toBe(
|
|
133
|
-
path.join(path.dirname(actualHome), "documents", "file.txt"),
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("should use forward slashes in abbreviated paths", () => {
|
|
138
|
-
const testPath = path.join(actualHome, "documents", "file.txt");
|
|
139
|
-
const result = abbreviateHome(testPath);
|
|
140
|
-
expect(result).toBe("~/documents/file.txt");
|
|
141
|
-
expect(result).not.toContain("\\");
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe.concurrent("abbreviateCwd", () => {
|
|
146
|
-
// TODO: LIMITATION - Mocking process.cwd() in ESM modules may not work reliably.
|
|
147
|
-
// The tests mock process.cwd as a function, but in ESM, process.cwd is a getter/setter
|
|
148
|
-
// that might not be mockable this way. The tests may pass but could be fragile.
|
|
149
|
-
// Consider: Using a wrapper function that can be injected, or using vi.stubGlobal.
|
|
150
|
-
const originalCwd = process.cwd.bind(process);
|
|
151
|
-
|
|
152
|
-
afterEach(() => {
|
|
153
|
-
process.cwd = originalCwd;
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('should return "." for current directory', () => {
|
|
157
|
-
const mockCwd = "/home/user/project";
|
|
158
|
-
process.cwd = vi.fn(() => mockCwd);
|
|
159
|
-
expect(abbreviateCwd(mockCwd)).toBe(".");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("should abbreviate paths relative to current directory", () => {
|
|
163
|
-
const mockCwd = "/home/user/project";
|
|
164
|
-
process.cwd = vi.fn(() => mockCwd);
|
|
165
|
-
expect(abbreviateCwd("/home/user/project/src/file.txt")).toBe("./src/file.txt");
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should handle paths outside current directory", () => {
|
|
169
|
-
const mockCwd = "/home/user/project";
|
|
170
|
-
process.cwd = vi.fn(() => mockCwd);
|
|
171
|
-
const result = abbreviateCwd("/home/user/other/file.txt");
|
|
172
|
-
expect(result).toContain("../other/file.txt");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("should use forward slashes in relative paths", () => {
|
|
176
|
-
const mockCwd = "/home/user/project";
|
|
177
|
-
process.cwd = vi.fn(() => mockCwd);
|
|
178
|
-
const result = abbreviateCwd("/home/user/project/src/file.txt");
|
|
179
|
-
expect(result).toBe("./src/file.txt");
|
|
180
|
-
expect(result).not.toContain("\\");
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('should handle paths that already start with "."', () => {
|
|
184
|
-
const mockCwd = "/home/user/project";
|
|
185
|
-
process.cwd = vi.fn(() => mockCwd);
|
|
186
|
-
const result = abbreviateCwd("/home/user/project/../other");
|
|
187
|
-
expect(result).toMatch(/^\.\./);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("should resolve relative paths before abbreviating", () => {
|
|
191
|
-
const mockCwd = "/home/user/project";
|
|
192
|
-
process.cwd = vi.fn(() => mockCwd);
|
|
193
|
-
const result = abbreviateCwd("./src/file.txt");
|
|
194
|
-
expect(result).toBe("./src/file.txt");
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
describe.concurrent("convertAbsoluteToRelativePath", () => {
|
|
199
|
-
it("should convert path within workspace", () => {
|
|
200
|
-
const result = convertAbsoluteToRelativePath(
|
|
201
|
-
"/home/user/code/src/file.py",
|
|
202
|
-
"/home/user/code",
|
|
203
|
-
);
|
|
204
|
-
expect(result.success).toBe(true);
|
|
205
|
-
if (result.success) {
|
|
206
|
-
expect(result.relativePath).toBe(path.join("src", "file.py"));
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("should reject path outside workspace", () => {
|
|
211
|
-
const result = convertAbsoluteToRelativePath("/other/path/file.py", "/home/user/code");
|
|
212
|
-
expect(result.success).toBe(false);
|
|
213
|
-
if (!result.success) {
|
|
214
|
-
expect(result.reason).toBe("outside_workspace");
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("should handle file at workspace root", () => {
|
|
219
|
-
const result = convertAbsoluteToRelativePath("/home/user/code/file.py", "/home/user/code");
|
|
220
|
-
expect(result.success).toBe(true);
|
|
221
|
-
if (result.success) {
|
|
222
|
-
expect(result.relativePath).toBe("file.py");
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("should handle symlinks when workspace is symlink", () => {
|
|
227
|
-
// Create temporary test directory structure with symlink
|
|
228
|
-
const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "test-symlink-"));
|
|
229
|
-
try {
|
|
230
|
-
const realDir = path.join(tmpBase, "real");
|
|
231
|
-
const symlinkDir = path.join(tmpBase, "symlink");
|
|
232
|
-
fs.mkdirSync(realDir);
|
|
233
|
-
fs.symlinkSync(realDir, symlinkDir);
|
|
234
|
-
|
|
235
|
-
// Test: workspace is symlink, file uses real path
|
|
236
|
-
const result = convertAbsoluteToRelativePath(path.join(realDir, "file.py"), symlinkDir);
|
|
237
|
-
expect(result.success).toBe(true);
|
|
238
|
-
if (result.success) {
|
|
239
|
-
expect(result.relativePath).toBe("file.py");
|
|
240
|
-
}
|
|
241
|
-
} finally {
|
|
242
|
-
// Cleanup
|
|
243
|
-
fs.rmSync(tmpBase, { recursive: true, force: true });
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("should handle symlinks when file path is symlink", () => {
|
|
248
|
-
// Create temporary test directory structure with symlink
|
|
249
|
-
const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "test-symlink-"));
|
|
250
|
-
try {
|
|
251
|
-
const realDir = path.join(tmpBase, "real");
|
|
252
|
-
const symlinkDir = path.join(tmpBase, "symlink");
|
|
253
|
-
fs.mkdirSync(realDir);
|
|
254
|
-
fs.symlinkSync(realDir, symlinkDir);
|
|
255
|
-
|
|
256
|
-
// Test: workspace is real, file uses symlink path
|
|
257
|
-
const result = convertAbsoluteToRelativePath(path.join(symlinkDir, "file.py"), realDir);
|
|
258
|
-
expect(result.success).toBe(true);
|
|
259
|
-
if (result.success) {
|
|
260
|
-
expect(result.relativePath).toBe("file.py");
|
|
261
|
-
}
|
|
262
|
-
} finally {
|
|
263
|
-
// Cleanup
|
|
264
|
-
fs.rmSync(tmpBase, { recursive: true, force: true });
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it("should handle nested paths", () => {
|
|
269
|
-
const result = convertAbsoluteToRelativePath(
|
|
270
|
-
"/home/user/code/a/b/c/file.py",
|
|
271
|
-
"/home/user/code",
|
|
272
|
-
);
|
|
273
|
-
expect(result.success).toBe(true);
|
|
274
|
-
if (result.success) {
|
|
275
|
-
expect(result.relativePath).toBe(path.join("a", "b", "c", "file.py"));
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it("should handle paths with same prefix but different directories", () => {
|
|
280
|
-
// /home/user/code-test is not inside /home/user/code
|
|
281
|
-
const result = convertAbsoluteToRelativePath(
|
|
282
|
-
"/home/user/code-test/file.py",
|
|
283
|
-
"/home/user/code",
|
|
284
|
-
);
|
|
285
|
-
expect(result.success).toBe(false);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("should normalize paths before comparison", () => {
|
|
289
|
-
// Paths with . and .. should be normalized
|
|
290
|
-
const result = convertAbsoluteToRelativePath(
|
|
291
|
-
"/home/user/code/./src/../lib/file.py",
|
|
292
|
-
"/home/user/code",
|
|
293
|
-
);
|
|
294
|
-
expect(result.success).toBe(true);
|
|
295
|
-
if (result.success) {
|
|
296
|
-
expect(result.relativePath).toBe(path.join("lib", "file.py"));
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|