@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.
Files changed (197) hide show
  1. package/dist/index.mjs +450 -422
  2. package/package.json +4 -1
  3. package/.oxlintrc.json +0 -8
  4. package/resources/abacus.ico +0 -0
  5. package/resources/entitlements.plist +0 -9
  6. package/src/__e2e__/README.md +0 -196
  7. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  8. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  9. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  10. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  11. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  12. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  13. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  14. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  15. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  16. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  17. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  18. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  19. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  20. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  21. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  22. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  23. package/src/args.ts +0 -22
  24. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  25. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  26. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  27. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  28. package/src/components/composer/bash-runner.tsx +0 -54
  29. package/src/components/composer/commands/default-commands.tsx +0 -615
  30. package/src/components/composer/commands/handler.tsx +0 -59
  31. package/src/components/composer/commands/picker.tsx +0 -273
  32. package/src/components/composer/commands/registry.ts +0 -233
  33. package/src/components/composer/commands/types.ts +0 -33
  34. package/src/components/composer/context.tsx +0 -88
  35. package/src/components/composer/file-mention-picker.tsx +0 -83
  36. package/src/components/composer/help.tsx +0 -44
  37. package/src/components/composer/index.tsx +0 -1007
  38. package/src/components/composer/mentions.ts +0 -57
  39. package/src/components/composer/message-queue.tsx +0 -70
  40. package/src/components/composer/mode-panel.tsx +0 -35
  41. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  42. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  43. package/src/components/composer/modes/bash-handler.tsx +0 -132
  44. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  45. package/src/components/composer/modes/default-handlers.tsx +0 -33
  46. package/src/components/composer/modes/index.ts +0 -41
  47. package/src/components/composer/modes/types.ts +0 -21
  48. package/src/components/composer/persistent-shell.ts +0 -283
  49. package/src/components/composer/process.ts +0 -65
  50. package/src/components/composer/types.ts +0 -9
  51. package/src/components/composer/use-mention-search.ts +0 -68
  52. package/src/components/error-boundry.tsx +0 -60
  53. package/src/components/exit-message.tsx +0 -29
  54. package/src/components/expanded-view.tsx +0 -74
  55. package/src/components/file-completion.tsx +0 -127
  56. package/src/components/header.tsx +0 -47
  57. package/src/components/logo.tsx +0 -37
  58. package/src/components/segments.tsx +0 -356
  59. package/src/components/status-indicator.tsx +0 -306
  60. package/src/components/tool-group-summary.tsx +0 -263
  61. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  62. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  63. package/src/components/tool-permissions/index.ts +0 -5
  64. package/src/components/tool-permissions/permission-options.tsx +0 -401
  65. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  66. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  67. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  68. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  69. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  70. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  71. package/src/components/tools/agent/subagent.tsx +0 -37
  72. package/src/components/tools/agent/todo-write.tsx +0 -104
  73. package/src/components/tools/browser/close-tab.tsx +0 -58
  74. package/src/components/tools/browser/computer.tsx +0 -70
  75. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  76. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  77. package/src/components/tools/browser/navigate-to.tsx +0 -59
  78. package/src/components/tools/browser/new-tab.tsx +0 -60
  79. package/src/components/tools/browser/perform-action.tsx +0 -63
  80. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  81. package/src/components/tools/browser/switch-tab.tsx +0 -58
  82. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  83. package/src/components/tools/filesystem/edit.tsx +0 -220
  84. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  85. package/src/components/tools/filesystem/read-file.tsx +0 -180
  86. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  87. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  88. package/src/components/tools/index.ts +0 -91
  89. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  90. package/src/components/tools/search/fetch-url.tsx +0 -73
  91. package/src/components/tools/search/file-search.tsx +0 -78
  92. package/src/components/tools/search/grep.tsx +0 -90
  93. package/src/components/tools/search/semantic-search.tsx +0 -66
  94. package/src/components/tools/search/web-search.tsx +0 -71
  95. package/src/components/tools/shared/index.tsx +0 -48
  96. package/src/components/tools/shared/zod-coercion.ts +0 -35
  97. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  98. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  99. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  100. package/src/components/tools/types.ts +0 -16
  101. package/src/components/tools.tsx +0 -68
  102. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  103. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  104. package/src/components/ui/__tests__/input.test.tsx +0 -166
  105. package/src/components/ui/__tests__/select.test.tsx +0 -273
  106. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  107. package/src/components/ui/blinking-indicator.tsx +0 -27
  108. package/src/components/ui/divider.tsx +0 -162
  109. package/src/components/ui/gradient.tsx +0 -56
  110. package/src/components/ui/input.tsx +0 -228
  111. package/src/components/ui/select.tsx +0 -151
  112. package/src/components/ui/shimmer.tsx +0 -76
  113. package/src/context/agent-mode.tsx +0 -95
  114. package/src/context/extension-file.tsx +0 -136
  115. package/src/context/network-activity.tsx +0 -45
  116. package/src/context/notification.tsx +0 -62
  117. package/src/context/shell-size.tsx +0 -49
  118. package/src/context/shell-title.tsx +0 -38
  119. package/src/entrypoints/print-mode.ts +0 -312
  120. package/src/entrypoints/repl.tsx +0 -389
  121. package/src/hooks/use-agent.ts +0 -15
  122. package/src/hooks/use-api-client.ts +0 -1
  123. package/src/hooks/use-available-height.ts +0 -8
  124. package/src/hooks/use-cleanup.ts +0 -29
  125. package/src/hooks/use-interrupt-manager.ts +0 -242
  126. package/src/hooks/use-models.ts +0 -22
  127. package/src/index.ts +0 -217
  128. package/src/lib/__tests__/ansi.test.ts +0 -255
  129. package/src/lib/__tests__/cli.test.ts +0 -122
  130. package/src/lib/__tests__/commands.test.ts +0 -325
  131. package/src/lib/__tests__/constants.test.ts +0 -15
  132. package/src/lib/__tests__/focusables.test.ts +0 -25
  133. package/src/lib/__tests__/fs.test.ts +0 -231
  134. package/src/lib/__tests__/markdown.test.tsx +0 -348
  135. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  136. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  137. package/src/lib/__tests__/path-paste.test.ts +0 -144
  138. package/src/lib/__tests__/path.test.ts +0 -300
  139. package/src/lib/__tests__/queries.test.ts +0 -39
  140. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  141. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  142. package/src/lib/__tests__/text-utils.test.ts +0 -32
  143. package/src/lib/__tests__/timing.test.ts +0 -78
  144. package/src/lib/__tests__/utils.test.ts +0 -238
  145. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  146. package/src/lib/ansi.ts +0 -150
  147. package/src/lib/cli-push-server.ts +0 -112
  148. package/src/lib/cli.ts +0 -44
  149. package/src/lib/clipboard.ts +0 -226
  150. package/src/lib/command-utils.ts +0 -93
  151. package/src/lib/commands.ts +0 -270
  152. package/src/lib/constants.ts +0 -3
  153. package/src/lib/extension-connection.ts +0 -181
  154. package/src/lib/focusables.ts +0 -7
  155. package/src/lib/fs.ts +0 -533
  156. package/src/lib/markdown/code-block.tsx +0 -63
  157. package/src/lib/markdown/index.ts +0 -4
  158. package/src/lib/markdown/link.tsx +0 -19
  159. package/src/lib/markdown/markdown.tsx +0 -372
  160. package/src/lib/markdown/types.ts +0 -15
  161. package/src/lib/mcpCommandHandler.ts +0 -121
  162. package/src/lib/mcpManagement.ts +0 -44
  163. package/src/lib/path-paste.ts +0 -185
  164. package/src/lib/path.ts +0 -179
  165. package/src/lib/queries.ts +0 -15
  166. package/src/lib/standaloneMcpService.ts +0 -688
  167. package/src/lib/status-utils.ts +0 -237
  168. package/src/lib/test-utils.tsx +0 -72
  169. package/src/lib/text-buffer.ts +0 -2415
  170. package/src/lib/text-utils.ts +0 -272
  171. package/src/lib/timing.ts +0 -63
  172. package/src/lib/types.ts +0 -295
  173. package/src/lib/utils.ts +0 -182
  174. package/src/lib/vim-buffer-actions.ts +0 -732
  175. package/src/providers/agent.tsx +0 -1063
  176. package/src/providers/api-client.tsx +0 -43
  177. package/src/services/logger.ts +0 -85
  178. package/src/terminal/detection.ts +0 -187
  179. package/src/terminal/exit.ts +0 -279
  180. package/src/terminal/notification.ts +0 -83
  181. package/src/terminal/progress.ts +0 -201
  182. package/src/terminal/setup.ts +0 -797
  183. package/src/terminal/types.ts +0 -51
  184. package/src/theme/context.tsx +0 -57
  185. package/src/theme/index.ts +0 -4
  186. package/src/theme/themed.tsx +0 -35
  187. package/src/theme/themes.json +0 -546
  188. package/src/theme/types.ts +0 -110
  189. package/src/tools/types.ts +0 -59
  190. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  191. package/src/tools/utils/tool-ui-components.tsx +0 -649
  192. package/src/tools/utils/zod-coercion.ts +0 -35
  193. package/tsconfig.json +0 -16
  194. package/tsconfig.node.json +0 -29
  195. package/tsconfig.test.json +0 -27
  196. package/tsdown.config.ts +0 -17
  197. package/vitest.config.ts +0 -76
@@ -1,15 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { describe, expect, it } from "vitest";
4
-
5
- import { MAX_RECENT_CONVERSATIONS, TOOL_CALL_LIMIT } from "../constants.js";
6
-
7
- describe.concurrent("constants", () => {
8
- it("should export MAX_RECENT_CONVERSATIONS as 25", () => {
9
- expect(MAX_RECENT_CONVERSATIONS).toBe(25);
10
- });
11
-
12
- it("should export TOOL_CALL_LIMIT as Number.MAX_SAFE_INTEGER", () => {
13
- expect(TOOL_CALL_LIMIT).toBe(Number.MAX_SAFE_INTEGER);
14
- });
15
- });
@@ -1,25 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { describe, expect, it } from "vitest";
4
-
5
- import { Focusable } from "../focusables.js";
6
-
7
- describe.concurrent("focusables", () => {
8
- it("should export Focusable enum with correct values", () => {
9
- expect(Focusable.Composer).toBe("composer");
10
- expect(Focusable.ModelSelector).toBe("model-selector");
11
- expect(Focusable.Messages).toBe("messages");
12
- expect(Focusable.Sidebar).toBe("sidebar");
13
- expect(Focusable.ToolPermission).toBe("tool-permission");
14
- });
15
-
16
- it("should have all expected enum values", () => {
17
- const values = Object.values(Focusable);
18
- expect(values).toContain("composer");
19
- expect(values).toContain("model-selector");
20
- expect(values).toContain("messages");
21
- expect(values).toContain("sidebar");
22
- expect(values).toContain("tool-permission");
23
- expect(values.length).toBe(5);
24
- });
25
- });
@@ -1,231 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { mkdir, rm, writeFile } from "node:fs/promises";
4
- import { tmpdir } from "os";
5
- import { join } from "path";
6
- import { describe, expect, it, beforeEach, afterEach } from "vitest";
7
-
8
- import { searchFiles } from "../fs.js";
9
-
10
- describe.concurrent("fs", () => {
11
- let testDir: string;
12
-
13
- beforeEach(async () => {
14
- // Create a temporary directory for testing
15
- testDir = join(tmpdir(), `fs-test-${Date.now()}`);
16
- await mkdir(testDir, { recursive: true });
17
- });
18
-
19
- afterEach(async () => {
20
- // Clean up test directory
21
- await rm(testDir, { recursive: true, force: true });
22
- });
23
-
24
- describe.sequential("searchFiles", () => {
25
- it("should return empty results for non-existent directory", async () => {
26
- const nonExistentDir = join(testDir, "nonexistent");
27
- const results: any[] = [];
28
-
29
- for await (const result of searchFiles("test", { root: nonExistentDir })) {
30
- results.push(result);
31
- }
32
-
33
- expect(results.length).toBe(0);
34
- }, 15000);
35
-
36
- it("should search files in a directory", async () => {
37
- // Create test files
38
- await writeFile(join(testDir, "test1.txt"), "content1");
39
- await writeFile(join(testDir, "test2.js"), "content2");
40
- await writeFile(join(testDir, "other.md"), "content3");
41
-
42
- const results: any[] = [];
43
- for await (const result of searchFiles("test", { root: testDir })) {
44
- results.push(result);
45
- }
46
-
47
- expect(results.length).toBeGreaterThan(0);
48
- const allPaths = results.flatMap((r) => r.paths);
49
- expect(allPaths.some((p) => p.includes("test1") || p.includes("test2"))).toBe(true);
50
- }, 15000);
51
-
52
- it("should respect maxResults option", async () => {
53
- // Create many test files
54
- for (let i = 0; i < 20; i++) {
55
- await writeFile(join(testDir, `file${i}.txt`), `content${i}`);
56
- }
57
-
58
- const results: any[] = [];
59
- for await (const result of searchFiles("file", { root: testDir, maxResults: 5 })) {
60
- results.push(result);
61
- }
62
-
63
- const allPaths = results.flatMap((r) => r.paths);
64
- // Should respect maxResults (may yield multiple results as index builds)
65
- expect(allPaths.length).toBeGreaterThanOrEqual(0);
66
- }, 15000);
67
-
68
- it("should handle empty query", async () => {
69
- await writeFile(join(testDir, "file1.txt"), "content1");
70
- await writeFile(join(testDir, "file2.txt"), "content2");
71
-
72
- const results: any[] = [];
73
- for await (const result of searchFiles("", { root: testDir })) {
74
- results.push(result);
75
- }
76
-
77
- // Empty query should return baseline results
78
- expect(results.length).toBeGreaterThanOrEqual(0);
79
- }, 15000);
80
-
81
- it("should handle includeHidden option", async () => {
82
- await writeFile(join(testDir, ".hidden"), "hidden content");
83
- await writeFile(join(testDir, "visible.txt"), "visible content");
84
-
85
- const results: any[] = [];
86
- for await (const result of searchFiles("hidden", {
87
- root: testDir,
88
- includeHidden: true,
89
- })) {
90
- results.push(result);
91
- }
92
-
93
- const allPaths = results.flatMap((r) => r.paths);
94
- // With includeHidden, should find .hidden
95
- expect(allPaths.length).toBeGreaterThanOrEqual(0);
96
- }, 15000);
97
-
98
- it("should exclude hidden files by default", async () => {
99
- await writeFile(join(testDir, ".hidden"), "hidden content");
100
- await writeFile(join(testDir, "visible.txt"), "visible content");
101
-
102
- const results: any[] = [];
103
- for await (const result of searchFiles("", { root: testDir })) {
104
- results.push(result);
105
- }
106
-
107
- const allPaths = results.flatMap((r) => r.paths);
108
- // Should not include .hidden in results by default
109
- // (This is a behavior test - actual behavior depends on ripgrep)
110
- expect(allPaths.length).toBeGreaterThanOrEqual(0);
111
- }, 15000);
112
-
113
- it("should handle globs option", async () => {
114
- await writeFile(join(testDir, "file1.txt"), "content1");
115
- await writeFile(join(testDir, "file2.js"), "content2");
116
- await writeFile(join(testDir, "file3.md"), "content3");
117
-
118
- const results: any[] = [];
119
- for await (const result of searchFiles("file", {
120
- root: testDir,
121
- globs: ["*.txt", "*.js"],
122
- })) {
123
- results.push(result);
124
- }
125
-
126
- const allPaths = results.flatMap((r) => r.paths);
127
- // Should filter by globs
128
- expect(allPaths.length).toBeGreaterThanOrEqual(0);
129
- }, 15000);
130
-
131
- it("should handle ignoreGlobs option", async () => {
132
- await writeFile(join(testDir, "include.txt"), "content1");
133
- await writeFile(join(testDir, "exclude.js"), "content2");
134
-
135
- const results: any[] = [];
136
- for await (const result of searchFiles("", {
137
- root: testDir,
138
- ignoreGlobs: ["*.js"],
139
- })) {
140
- results.push(result);
141
- }
142
-
143
- const allPaths = results.flatMap((r) => r.paths);
144
- // Should exclude files matching ignoreGlobs
145
- expect(allPaths.length).toBeGreaterThanOrEqual(0);
146
- }, 15000);
147
-
148
- it("should handle nested directories", async () => {
149
- const subDir = join(testDir, "sub", "nested");
150
- await mkdir(subDir, { recursive: true });
151
- await writeFile(join(subDir, "nested.txt"), "nested content");
152
-
153
- const results: any[] = [];
154
- for await (const result of searchFiles("nested", { root: testDir })) {
155
- results.push(result);
156
- }
157
-
158
- const allPaths = results.flatMap((r) => r.paths);
159
- expect(allPaths.some((p) => p.includes("nested"))).toBe(true);
160
- }, 15000);
161
-
162
- it("should yield results incrementally as index builds", async () => {
163
- // Create files
164
- for (let i = 0; i < 10; i++) {
165
- await writeFile(join(testDir, `file${i}.txt`), `content${i}`);
166
- }
167
-
168
- const results: any[] = [];
169
- for await (const result of searchFiles("file", { root: testDir })) {
170
- results.push(result);
171
- // Should yield at least one result
172
- if (results.length > 0) {
173
- break; // Exit early to test incremental behavior
174
- }
175
- }
176
-
177
- // May yield cached results first, then updated results
178
- expect(results.length).toBeGreaterThanOrEqual(0);
179
- }, 15000);
180
-
181
- it("should handle useRipgrep option", async () => {
182
- await writeFile(join(testDir, "test.txt"), "content");
183
-
184
- const results: any[] = [];
185
- for await (const result of searchFiles("test", {
186
- root: testDir,
187
- useRipgrep: false,
188
- })) {
189
- results.push(result);
190
- }
191
-
192
- // Should work without ripgrep (fallback to file walk)
193
- expect(results.length).toBeGreaterThanOrEqual(0);
194
- }, 20000);
195
-
196
- it("should handle useGitignore option", async () => {
197
- await writeFile(join(testDir, ".gitignore"), "ignored.txt\n");
198
- await writeFile(join(testDir, "ignored.txt"), "ignored");
199
- await writeFile(join(testDir, "included.txt"), "included");
200
-
201
- const results: any[] = [];
202
- for await (const result of searchFiles("", {
203
- root: testDir,
204
- useGitignore: true,
205
- })) {
206
- results.push(result);
207
- }
208
-
209
- const allPaths = results.flatMap((r) => r.paths);
210
- // Should respect .gitignore when useGitignore is true
211
- expect(allPaths.length).toBeGreaterThanOrEqual(0);
212
- }, 15000);
213
-
214
- it("should return isDirectory flags correctly", async () => {
215
- await mkdir(join(testDir, "subdir"), { recursive: true });
216
- await writeFile(join(testDir, "file.txt"), "content");
217
-
218
- const results: any[] = [];
219
- for await (const result of searchFiles("", { root: testDir })) {
220
- results.push(result);
221
- }
222
-
223
- // Check that isDirectory flags are present
224
- if (results.length > 0) {
225
- const firstResult = results[0];
226
- expect(firstResult).toHaveProperty("isDirectory");
227
- expect(Array.isArray(firstResult.isDirectory)).toBe(true);
228
- }
229
- }, 15000);
230
- });
231
- });
@@ -1,348 +0,0 @@
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
- });