@abacus-ai/cli 1.106.25007 → 2.0.0-canary.0
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/.oxlintrc.json +8 -0
- package/dist/index.mjs +12603 -0
- package/package.json +7 -39
- package/resources/abacus.ico +0 -0
- package/resources/entitlements.plist +9 -0
- package/src/__e2e__/README.md +196 -0
- package/src/__e2e__/agent-interactions.e2e.test.tsx +61 -0
- package/src/__e2e__/cli-commands.e2e.test.tsx +77 -0
- package/src/__e2e__/conversation-throttle.e2e.test.ts +453 -0
- package/src/__e2e__/conversation.e2e.test.tsx +56 -0
- package/src/__e2e__/diff-preview.e2e.test.tsx +3399 -0
- package/src/__e2e__/file-creation.e2e.test.tsx +149 -0
- package/src/__e2e__/helpers/test-helpers.ts +450 -0
- package/src/__e2e__/keyboard-navigation.e2e.test.tsx +34 -0
- package/src/__e2e__/llm-models.e2e.test.ts +402 -0
- package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +71 -0
- package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +167 -0
- package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +185 -0
- package/src/__e2e__/repl.e2e.test.tsx +78 -0
- package/src/__e2e__/shell-compatibility.e2e.test.tsx +76 -0
- package/src/__e2e__/theme-mcp.e2e.test.tsx +98 -0
- package/src/__e2e__/tool-permissions.e2e.test.tsx +66 -0
- package/src/args.ts +22 -0
- package/src/components/__tests__/react-compiler.test.tsx +78 -0
- package/src/components/__tests__/status-indicator.test.tsx +403 -0
- package/src/components/composer/__tests__/bash-runner.test.tsx +263 -0
- package/src/components/composer/agent-mode-indicator.tsx +63 -0
- package/src/components/composer/bash-runner.tsx +54 -0
- package/src/components/composer/commands/default-commands.tsx +615 -0
- package/src/components/composer/commands/handler.tsx +59 -0
- package/src/components/composer/commands/picker.tsx +273 -0
- package/src/components/composer/commands/registry.ts +233 -0
- package/src/components/composer/commands/types.ts +33 -0
- package/src/components/composer/context.tsx +88 -0
- package/src/components/composer/file-mention-picker.tsx +83 -0
- package/src/components/composer/help.tsx +44 -0
- package/src/components/composer/index.tsx +1006 -0
- package/src/components/composer/mentions.ts +57 -0
- package/src/components/composer/message-queue.tsx +70 -0
- package/src/components/composer/mode-panel.tsx +35 -0
- package/src/components/composer/modes/__tests__/bash-handler.test.tsx +755 -0
- package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +1108 -0
- package/src/components/composer/modes/bash-handler.tsx +132 -0
- package/src/components/composer/modes/bash-renderer.tsx +175 -0
- package/src/components/composer/modes/default-handlers.tsx +33 -0
- package/src/components/composer/modes/index.ts +41 -0
- package/src/components/composer/modes/types.ts +21 -0
- package/src/components/composer/persistent-shell.ts +283 -0
- package/src/components/composer/process.ts +65 -0
- package/src/components/composer/types.ts +9 -0
- package/src/components/composer/use-mention-search.ts +68 -0
- package/src/components/error-boundry.tsx +60 -0
- package/src/components/exit-message.tsx +29 -0
- package/src/components/expanded-view.tsx +74 -0
- package/src/components/file-completion.tsx +127 -0
- package/src/components/header.tsx +47 -0
- package/src/components/logo.tsx +37 -0
- package/src/components/segments.tsx +356 -0
- package/src/components/status-indicator.tsx +306 -0
- package/src/components/tool-group-summary.tsx +263 -0
- package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +312 -0
- package/src/components/tool-permissions/diff-preview.tsx +355 -0
- package/src/components/tool-permissions/index.ts +5 -0
- package/src/components/tool-permissions/permission-options.tsx +375 -0
- package/src/components/tool-permissions/permission-preview-header.tsx +57 -0
- package/src/components/tool-permissions/tool-permission-ui.tsx +398 -0
- package/src/components/tools/agent/ask-user-question.tsx +101 -0
- package/src/components/tools/agent/enter-plan-mode.tsx +49 -0
- package/src/components/tools/agent/exit-plan-mode.tsx +75 -0
- package/src/components/tools/agent/handoff-to-main.tsx +27 -0
- package/src/components/tools/agent/subagent.tsx +37 -0
- package/src/components/tools/agent/todo-write.tsx +104 -0
- package/src/components/tools/browser/close-tab.tsx +58 -0
- package/src/components/tools/browser/computer.tsx +70 -0
- package/src/components/tools/browser/get-interactive-elements.tsx +54 -0
- package/src/components/tools/browser/get-tab-content.tsx +51 -0
- package/src/components/tools/browser/navigate-to.tsx +59 -0
- package/src/components/tools/browser/new-tab.tsx +60 -0
- package/src/components/tools/browser/perform-action.tsx +63 -0
- package/src/components/tools/browser/refresh-tab.tsx +43 -0
- package/src/components/tools/browser/switch-tab.tsx +58 -0
- package/src/components/tools/filesystem/delete-file.tsx +104 -0
- package/src/components/tools/filesystem/edit.tsx +220 -0
- package/src/components/tools/filesystem/list-dir.tsx +78 -0
- package/src/components/tools/filesystem/read-file.tsx +180 -0
- package/src/components/tools/filesystem/upload-image.tsx +76 -0
- package/src/components/tools/ide/ide-diagnostics.tsx +62 -0
- package/src/components/tools/index.ts +91 -0
- package/src/components/tools/mcp/mcp-tool.tsx +158 -0
- package/src/components/tools/search/fetch-url.tsx +73 -0
- package/src/components/tools/search/file-search.tsx +78 -0
- package/src/components/tools/search/grep.tsx +90 -0
- package/src/components/tools/search/semantic-search.tsx +66 -0
- package/src/components/tools/search/web-search.tsx +71 -0
- package/src/components/tools/shared/index.tsx +48 -0
- package/src/components/tools/shared/zod-coercion.ts +35 -0
- package/src/components/tools/terminal/bash-tool-output.tsx +174 -0
- package/src/components/tools/terminal/get-terminal-output.tsx +85 -0
- package/src/components/tools/terminal/run-in-terminal.tsx +106 -0
- package/src/components/tools/types.ts +16 -0
- package/src/components/tools.tsx +66 -0
- package/src/components/ui/__tests__/divider.test.tsx +61 -0
- package/src/components/ui/__tests__/gradient.test.tsx +125 -0
- package/src/components/ui/__tests__/input.test.tsx +166 -0
- package/src/components/ui/__tests__/select.test.tsx +273 -0
- package/src/components/ui/__tests__/shimmer.test.tsx +99 -0
- package/src/components/ui/blinking-indicator.tsx +25 -0
- package/src/components/ui/divider.tsx +162 -0
- package/src/components/ui/gradient.tsx +56 -0
- package/src/components/ui/input.tsx +228 -0
- package/src/components/ui/select.tsx +151 -0
- package/src/components/ui/shimmer.tsx +84 -0
- package/src/context/agent-mode.tsx +95 -0
- package/src/context/extension-file.tsx +136 -0
- package/src/context/network-activity.tsx +45 -0
- package/src/context/notification.tsx +62 -0
- package/src/context/shell-size.tsx +49 -0
- package/src/context/shell-title.tsx +38 -0
- package/src/entrypoints/print-mode.ts +312 -0
- package/src/entrypoints/repl.tsx +401 -0
- package/src/hooks/use-agent.ts +15 -0
- package/src/hooks/use-api-client.ts +1 -0
- package/src/hooks/use-available-height.ts +8 -0
- package/src/hooks/use-cleanup.ts +29 -0
- package/src/hooks/use-interrupt-manager.ts +242 -0
- package/src/hooks/use-models.ts +22 -0
- package/src/index.ts +217 -0
- package/src/lib/__tests__/ansi.test.ts +255 -0
- package/src/lib/__tests__/cli.test.ts +122 -0
- package/src/lib/__tests__/commands.test.ts +325 -0
- package/src/lib/__tests__/constants.test.ts +15 -0
- package/src/lib/__tests__/focusables.test.ts +25 -0
- package/src/lib/__tests__/fs.test.ts +231 -0
- package/src/lib/__tests__/markdown.test.tsx +348 -0
- package/src/lib/__tests__/mcpCommandHandler.test.ts +173 -0
- package/src/lib/__tests__/mcpManagement.test.ts +38 -0
- package/src/lib/__tests__/path-paste.test.ts +144 -0
- package/src/lib/__tests__/path.test.ts +300 -0
- package/src/lib/__tests__/queries.test.ts +39 -0
- package/src/lib/__tests__/standaloneMcpService.test.ts +71 -0
- package/src/lib/__tests__/text-buffer.test.ts +328 -0
- package/src/lib/__tests__/text-utils.test.ts +32 -0
- package/src/lib/__tests__/timing.test.ts +78 -0
- package/src/lib/__tests__/utils.test.ts +238 -0
- package/src/lib/__tests__/vim-buffer-actions.test.ts +154 -0
- package/src/lib/ansi.ts +150 -0
- package/src/lib/cli-push-server.ts +112 -0
- package/src/lib/cli.ts +44 -0
- package/src/lib/clipboard.ts +226 -0
- package/src/lib/command-utils.ts +93 -0
- package/src/lib/commands.ts +270 -0
- package/src/lib/constants.ts +3 -0
- package/src/lib/extension-connection.ts +181 -0
- package/src/lib/focusables.ts +7 -0
- package/src/lib/fs.ts +533 -0
- package/src/lib/markdown/code-block.tsx +63 -0
- package/src/lib/markdown/index.ts +4 -0
- package/src/lib/markdown/link.tsx +19 -0
- package/src/lib/markdown/markdown.tsx +372 -0
- package/src/lib/markdown/types.ts +15 -0
- package/src/lib/mcpCommandHandler.ts +121 -0
- package/src/lib/mcpManagement.ts +44 -0
- package/src/lib/path-paste.ts +185 -0
- package/src/lib/path.ts +179 -0
- package/src/lib/queries.ts +15 -0
- package/src/lib/standaloneMcpService.ts +688 -0
- package/src/lib/status-utils.ts +237 -0
- package/src/lib/test-utils.tsx +72 -0
- package/src/lib/text-buffer.ts +2415 -0
- package/src/lib/text-utils.ts +272 -0
- package/src/lib/timing.ts +63 -0
- package/src/lib/types.ts +295 -0
- package/src/lib/utils.ts +182 -0
- package/src/lib/vim-buffer-actions.ts +732 -0
- package/src/providers/agent.tsx +1075 -0
- package/src/providers/api-client.tsx +43 -0
- package/src/services/logger.ts +85 -0
- package/src/terminal/detection.ts +187 -0
- package/src/terminal/exit.ts +279 -0
- package/src/terminal/notification.ts +83 -0
- package/src/terminal/progress.ts +201 -0
- package/src/terminal/setup.ts +797 -0
- package/src/terminal/suspend.ts +58 -0
- package/src/terminal/types.ts +51 -0
- package/src/theme/context.tsx +57 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/themed.tsx +35 -0
- package/src/theme/themes.json +546 -0
- package/src/theme/types.ts +110 -0
- package/src/tools/types.ts +59 -0
- package/src/tools/utils/__tests__/zod-coercion.test.ts +33 -0
- package/src/tools/utils/tool-ui-components.tsx +631 -0
- package/src/tools/utils/zod-coercion.ts +35 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +29 -0
- package/tsconfig.test.json +27 -0
- package/tsdown.config.ts +17 -0
- package/vitest.config.ts +76 -0
- package/README.md +0 -28
- package/dist/index.js +0 -26
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import styles from "ansi-styles";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import stripAnsi from "strip-ansi";
|
|
4
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { ThemeProvider } from "../../theme/context.js";
|
|
7
|
+
import { CodeBlock } from "../markdown/code-block.js";
|
|
8
|
+
import { Link } from "../markdown/link.js";
|
|
9
|
+
import { Markdown } from "../markdown/markdown.js";
|
|
10
|
+
import { cleanup, logInk, render } from "../test-utils.js";
|
|
11
|
+
|
|
12
|
+
const TestWrapper = ({ children }: React.PropsWithChildren) => (
|
|
13
|
+
<ThemeProvider>{children}</ThemeProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
describe.concurrent("markdown components", () => {
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
cleanup();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe.concurrent("Link", () => {
|
|
22
|
+
it("should render link with href and children", () => {
|
|
23
|
+
const ink = render(
|
|
24
|
+
<TestWrapper>
|
|
25
|
+
<Link href="https://example.com">Example Link</Link>
|
|
26
|
+
</TestWrapper>,
|
|
27
|
+
);
|
|
28
|
+
logInk(ink);
|
|
29
|
+
const output = ink.lastFrame();
|
|
30
|
+
|
|
31
|
+
expect(output).toContain("Example Link");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should render link with different href", () => {
|
|
35
|
+
const ink = render(
|
|
36
|
+
<TestWrapper>
|
|
37
|
+
<Link href="https://test.com">Test</Link>
|
|
38
|
+
</TestWrapper>,
|
|
39
|
+
);
|
|
40
|
+
logInk(ink);
|
|
41
|
+
const output = ink.lastFrame();
|
|
42
|
+
expect(output).toContain("Test");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should handle empty children", () => {
|
|
46
|
+
const ink = render(
|
|
47
|
+
<TestWrapper>
|
|
48
|
+
<Link href="https://example.com">{""}</Link>
|
|
49
|
+
</TestWrapper>,
|
|
50
|
+
);
|
|
51
|
+
logInk(ink);
|
|
52
|
+
const output = ink.lastFrame();
|
|
53
|
+
// Should render without error
|
|
54
|
+
expect(output).toBeDefined();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe.concurrent("CodeBlock", () => {
|
|
59
|
+
it("should render code block with children", () => {
|
|
60
|
+
const ink = render(
|
|
61
|
+
<TestWrapper>
|
|
62
|
+
<CodeBlock language="javascript">const x = 1;</CodeBlock>
|
|
63
|
+
</TestWrapper>,
|
|
64
|
+
);
|
|
65
|
+
// Code is syntax highlighted, so strip ANSI codes for comparison
|
|
66
|
+
logInk(ink);
|
|
67
|
+
const frame = ink.lastFrame();
|
|
68
|
+
expect(frame).toBeDefined();
|
|
69
|
+
const output = stripAnsi(frame!);
|
|
70
|
+
expect(output).toContain("const x = 1;");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should render code block without language", () => {
|
|
74
|
+
const ink = render(
|
|
75
|
+
<TestWrapper>
|
|
76
|
+
<CodeBlock>plain code</CodeBlock>
|
|
77
|
+
</TestWrapper>,
|
|
78
|
+
);
|
|
79
|
+
logInk(ink);
|
|
80
|
+
const output = ink.lastFrame();
|
|
81
|
+
expect(output).toContain("plain code");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should handle unsupported language", () => {
|
|
85
|
+
const ink = render(
|
|
86
|
+
<TestWrapper>
|
|
87
|
+
<CodeBlock language="nonexistent-lang">code</CodeBlock>
|
|
88
|
+
</TestWrapper>,
|
|
89
|
+
);
|
|
90
|
+
// Should fallback to plain text
|
|
91
|
+
logInk(ink);
|
|
92
|
+
const output = ink.lastFrame();
|
|
93
|
+
expect(output).toContain("code");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should handle empty code", () => {
|
|
97
|
+
const ink = render(
|
|
98
|
+
<TestWrapper>
|
|
99
|
+
<CodeBlock language="javascript"></CodeBlock>
|
|
100
|
+
</TestWrapper>,
|
|
101
|
+
);
|
|
102
|
+
// Should render without error
|
|
103
|
+
logInk(ink);
|
|
104
|
+
const output = ink.lastFrame();
|
|
105
|
+
expect(output).toBeDefined();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe.concurrent("Markdown", () => {
|
|
110
|
+
it("should render simple markdown text", () => {
|
|
111
|
+
const ink = render(
|
|
112
|
+
<TestWrapper>
|
|
113
|
+
<Markdown>Hello world</Markdown>
|
|
114
|
+
</TestWrapper>,
|
|
115
|
+
);
|
|
116
|
+
logInk(ink);
|
|
117
|
+
const output = ink.lastFrame();
|
|
118
|
+
expect(output).toContain("Hello world");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("should render markdown with code span", () => {
|
|
122
|
+
const ink = render(
|
|
123
|
+
<TestWrapper>
|
|
124
|
+
<Markdown>This is `code` inline</Markdown>
|
|
125
|
+
</TestWrapper>,
|
|
126
|
+
);
|
|
127
|
+
logInk(ink);
|
|
128
|
+
const output = ink.lastFrame();
|
|
129
|
+
expect(output).toContain("code");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("should render markdown with code block", () => {
|
|
133
|
+
const ink = render(
|
|
134
|
+
<TestWrapper>
|
|
135
|
+
<Markdown>
|
|
136
|
+
{`\`\`\`javascript
|
|
137
|
+
const x = 1;
|
|
138
|
+
\`\`\``}
|
|
139
|
+
</Markdown>
|
|
140
|
+
</TestWrapper>,
|
|
141
|
+
);
|
|
142
|
+
// Code is syntax highlighted, so strip ANSI codes for comparison
|
|
143
|
+
logInk(ink);
|
|
144
|
+
const frame = ink.lastFrame();
|
|
145
|
+
expect(frame).toBeDefined();
|
|
146
|
+
const output = stripAnsi(frame!);
|
|
147
|
+
expect(output).toContain("const x = 1;");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("should render markdown with link", () => {
|
|
151
|
+
const ink = render(
|
|
152
|
+
<TestWrapper>
|
|
153
|
+
<Markdown>[Example](https://example.com)</Markdown>
|
|
154
|
+
</TestWrapper>,
|
|
155
|
+
);
|
|
156
|
+
logInk(ink);
|
|
157
|
+
const output = ink.lastFrame();
|
|
158
|
+
expect(output).toContain("Example");
|
|
159
|
+
expect(output).toContain("https://example.com");
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("should render markdown with headers", () => {
|
|
163
|
+
const ink = render(
|
|
164
|
+
<TestWrapper>
|
|
165
|
+
<Markdown># Header 1\n## Header 2</Markdown>
|
|
166
|
+
</TestWrapper>,
|
|
167
|
+
);
|
|
168
|
+
logInk(ink);
|
|
169
|
+
const output = ink.lastFrame();
|
|
170
|
+
expect(output).toContain("Header 1");
|
|
171
|
+
expect(output).toContain("Header 2");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should render markdown with list", () => {
|
|
175
|
+
const ink = render(
|
|
176
|
+
<TestWrapper>
|
|
177
|
+
<Markdown>
|
|
178
|
+
{`- Item 1
|
|
179
|
+
- Item 2
|
|
180
|
+
- Item 3`}
|
|
181
|
+
</Markdown>
|
|
182
|
+
</TestWrapper>,
|
|
183
|
+
);
|
|
184
|
+
logInk(ink);
|
|
185
|
+
const output = ink.lastFrame();
|
|
186
|
+
expect(output).toContain("Item 1");
|
|
187
|
+
expect(output).toContain("Item 2");
|
|
188
|
+
expect(output).toContain("Item 3");
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("should render markdown with numbered list", () => {
|
|
192
|
+
const ink = render(
|
|
193
|
+
<TestWrapper>
|
|
194
|
+
<Markdown>
|
|
195
|
+
{`1. First
|
|
196
|
+
2. Second
|
|
197
|
+
3. Third`}
|
|
198
|
+
</Markdown>
|
|
199
|
+
</TestWrapper>,
|
|
200
|
+
);
|
|
201
|
+
logInk(ink);
|
|
202
|
+
const output = ink.lastFrame();
|
|
203
|
+
expect(output).toContain("First");
|
|
204
|
+
expect(output).toContain("Second");
|
|
205
|
+
expect(output).toContain("Third");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("should render markdown with blockquote", () => {
|
|
209
|
+
const ink = render(
|
|
210
|
+
<TestWrapper>
|
|
211
|
+
<Markdown>{"> This is a quote"}</Markdown>
|
|
212
|
+
</TestWrapper>,
|
|
213
|
+
);
|
|
214
|
+
logInk(ink);
|
|
215
|
+
const output = ink.lastFrame();
|
|
216
|
+
expect(output).toContain("This is a quote");
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("should render markdown with bold", () => {
|
|
220
|
+
const ink = render(
|
|
221
|
+
<TestWrapper>
|
|
222
|
+
<Markdown>**text1** text2</Markdown>
|
|
223
|
+
</TestWrapper>,
|
|
224
|
+
);
|
|
225
|
+
logInk(ink);
|
|
226
|
+
const output = ink.lastFrame();
|
|
227
|
+
expect(output).toContain(`${styles.bold.open}text1${styles.bold.close} text2`);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("should render markdown with italic", () => {
|
|
231
|
+
const ink = render(
|
|
232
|
+
<TestWrapper>
|
|
233
|
+
<Markdown>*text1* text2</Markdown>
|
|
234
|
+
</TestWrapper>,
|
|
235
|
+
);
|
|
236
|
+
logInk(ink);
|
|
237
|
+
const output = ink.lastFrame();
|
|
238
|
+
expect(output).toContain(`${styles.italic.open}text1${styles.italic.close} text2`);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("should render markdown with strikethrough", () => {
|
|
242
|
+
const ink = render(
|
|
243
|
+
<TestWrapper>
|
|
244
|
+
<Markdown>~text1~ text2</Markdown>
|
|
245
|
+
</TestWrapper>,
|
|
246
|
+
);
|
|
247
|
+
logInk(ink);
|
|
248
|
+
const output = ink.lastFrame();
|
|
249
|
+
expect(output).toContain(
|
|
250
|
+
`${styles.strikethrough.open}text1${styles.strikethrough.close} text2`,
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("should render markdown with italic using underscore", () => {
|
|
255
|
+
const ink = render(
|
|
256
|
+
<TestWrapper>
|
|
257
|
+
<Markdown>_text1_ text2</Markdown>
|
|
258
|
+
</TestWrapper>,
|
|
259
|
+
);
|
|
260
|
+
logInk(ink);
|
|
261
|
+
const output = ink.lastFrame();
|
|
262
|
+
expect(output).toContain(`${styles.italic.open}text1${styles.italic.close} text2`);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("should render markdown with bold, italic, and strikethrough text", () => {
|
|
266
|
+
const ink = render(
|
|
267
|
+
<TestWrapper>
|
|
268
|
+
<Markdown>**text1** *text2* _text3_ ~text4~ text5</Markdown>
|
|
269
|
+
</TestWrapper>,
|
|
270
|
+
);
|
|
271
|
+
logInk(ink);
|
|
272
|
+
const output = ink.lastFrame();
|
|
273
|
+
const outputs = output?.split(" ");
|
|
274
|
+
expect(outputs).toBeDefined();
|
|
275
|
+
expect(outputs![0]).toContain(`${styles.bold.open}text1${styles.bold.close}`);
|
|
276
|
+
expect(outputs![1]).toContain(`${styles.italic.open}text2${styles.italic.close}`);
|
|
277
|
+
expect(outputs![2]).toContain(`${styles.italic.open}text3${styles.italic.close}`);
|
|
278
|
+
expect(outputs![3]).toContain(
|
|
279
|
+
`${styles.strikethrough.open}text4${styles.strikethrough.close}`,
|
|
280
|
+
);
|
|
281
|
+
expect(outputs![4]).toContain("text5");
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it("should handle nested formatting correctly (italic with bold inside)", () => {
|
|
285
|
+
const ink = render(
|
|
286
|
+
<TestWrapper>
|
|
287
|
+
<Markdown>_**bold**_</Markdown>
|
|
288
|
+
</TestWrapper>,
|
|
289
|
+
);
|
|
290
|
+
logInk(ink);
|
|
291
|
+
const output = ink.lastFrame();
|
|
292
|
+
// The outer _ should render as italic, inner ** as bold
|
|
293
|
+
expect(output).toContain(styles.italic.open);
|
|
294
|
+
expect(output).toContain(styles.bold.open);
|
|
295
|
+
expect(output).toContain("bold");
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it("should handle nested formatting correctly (italic with bold inside using asterisk)", () => {
|
|
299
|
+
const ink = render(
|
|
300
|
+
<TestWrapper>
|
|
301
|
+
<Markdown>*__bold__*</Markdown>
|
|
302
|
+
</TestWrapper>,
|
|
303
|
+
);
|
|
304
|
+
logInk(ink);
|
|
305
|
+
const output = ink.lastFrame();
|
|
306
|
+
// The outer * should render as italic, inner __ as bold
|
|
307
|
+
expect(output).toContain(styles.italic.open);
|
|
308
|
+
expect(output).toContain(styles.bold.open);
|
|
309
|
+
expect(output).toContain("bold");
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("should handle empty markdown", () => {
|
|
313
|
+
const ink = render(
|
|
314
|
+
<TestWrapper>
|
|
315
|
+
<Markdown>{""}</Markdown>
|
|
316
|
+
</TestWrapper>,
|
|
317
|
+
);
|
|
318
|
+
// Should render without error
|
|
319
|
+
logInk(ink);
|
|
320
|
+
const output = ink.lastFrame();
|
|
321
|
+
expect(output).toBeDefined();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it("should handle complex markdown", () => {
|
|
325
|
+
const ink = render(
|
|
326
|
+
<TestWrapper>
|
|
327
|
+
<Markdown>
|
|
328
|
+
{`# Title
|
|
329
|
+
|
|
330
|
+
This is a paragraph with **bold** and *italic* text.
|
|
331
|
+
|
|
332
|
+
\`\`\`javascript
|
|
333
|
+
const code = 'example';
|
|
334
|
+
\`\`\`
|
|
335
|
+
|
|
336
|
+
[Link](https://example.com)`}
|
|
337
|
+
</Markdown>
|
|
338
|
+
</TestWrapper>,
|
|
339
|
+
);
|
|
340
|
+
logInk(ink);
|
|
341
|
+
const output = ink.lastFrame();
|
|
342
|
+
expect(output).toContain("Title");
|
|
343
|
+
expect(output).toContain("paragraph");
|
|
344
|
+
expect(output).toContain("code");
|
|
345
|
+
expect(output).toContain("Link");
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
});
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
});
|