@abacus-ai/cli 2.0.0-canary.1 → 2.0.0-canary.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +25 -0
  2. package/dist/index.mjs +466 -438
  3. package/package.json +4 -1
  4. package/.oxlintrc.json +0 -8
  5. package/resources/abacus.ico +0 -0
  6. package/resources/entitlements.plist +0 -9
  7. package/src/__e2e__/README.md +0 -196
  8. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  9. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  10. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  11. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  12. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  13. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  14. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  15. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  16. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  17. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  18. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  19. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  20. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  21. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  22. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  23. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  24. package/src/args.ts +0 -22
  25. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  26. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  27. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  28. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  29. package/src/components/composer/bash-runner.tsx +0 -54
  30. package/src/components/composer/commands/default-commands.tsx +0 -615
  31. package/src/components/composer/commands/handler.tsx +0 -59
  32. package/src/components/composer/commands/picker.tsx +0 -273
  33. package/src/components/composer/commands/registry.ts +0 -233
  34. package/src/components/composer/commands/types.ts +0 -33
  35. package/src/components/composer/context.tsx +0 -88
  36. package/src/components/composer/file-mention-picker.tsx +0 -83
  37. package/src/components/composer/help.tsx +0 -44
  38. package/src/components/composer/index.tsx +0 -1007
  39. package/src/components/composer/mentions.ts +0 -57
  40. package/src/components/composer/message-queue.tsx +0 -70
  41. package/src/components/composer/mode-panel.tsx +0 -35
  42. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  43. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  44. package/src/components/composer/modes/bash-handler.tsx +0 -132
  45. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  46. package/src/components/composer/modes/default-handlers.tsx +0 -33
  47. package/src/components/composer/modes/index.ts +0 -41
  48. package/src/components/composer/modes/types.ts +0 -21
  49. package/src/components/composer/persistent-shell.ts +0 -283
  50. package/src/components/composer/process.ts +0 -65
  51. package/src/components/composer/types.ts +0 -9
  52. package/src/components/composer/use-mention-search.ts +0 -68
  53. package/src/components/error-boundry.tsx +0 -60
  54. package/src/components/exit-message.tsx +0 -29
  55. package/src/components/expanded-view.tsx +0 -74
  56. package/src/components/file-completion.tsx +0 -127
  57. package/src/components/header.tsx +0 -47
  58. package/src/components/logo.tsx +0 -37
  59. package/src/components/segments.tsx +0 -356
  60. package/src/components/status-indicator.tsx +0 -306
  61. package/src/components/tool-group-summary.tsx +0 -263
  62. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  63. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  64. package/src/components/tool-permissions/index.ts +0 -5
  65. package/src/components/tool-permissions/permission-options.tsx +0 -401
  66. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  67. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  68. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  69. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  70. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  71. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  72. package/src/components/tools/agent/subagent.tsx +0 -37
  73. package/src/components/tools/agent/todo-write.tsx +0 -104
  74. package/src/components/tools/browser/close-tab.tsx +0 -58
  75. package/src/components/tools/browser/computer.tsx +0 -70
  76. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  77. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  78. package/src/components/tools/browser/navigate-to.tsx +0 -59
  79. package/src/components/tools/browser/new-tab.tsx +0 -60
  80. package/src/components/tools/browser/perform-action.tsx +0 -63
  81. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  82. package/src/components/tools/browser/switch-tab.tsx +0 -58
  83. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  84. package/src/components/tools/filesystem/edit.tsx +0 -220
  85. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  86. package/src/components/tools/filesystem/read-file.tsx +0 -180
  87. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  88. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  89. package/src/components/tools/index.ts +0 -91
  90. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  91. package/src/components/tools/search/fetch-url.tsx +0 -73
  92. package/src/components/tools/search/file-search.tsx +0 -78
  93. package/src/components/tools/search/grep.tsx +0 -90
  94. package/src/components/tools/search/semantic-search.tsx +0 -66
  95. package/src/components/tools/search/web-search.tsx +0 -71
  96. package/src/components/tools/shared/index.tsx +0 -48
  97. package/src/components/tools/shared/zod-coercion.ts +0 -35
  98. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  99. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  100. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  101. package/src/components/tools/types.ts +0 -16
  102. package/src/components/tools.tsx +0 -68
  103. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  104. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  105. package/src/components/ui/__tests__/input.test.tsx +0 -166
  106. package/src/components/ui/__tests__/select.test.tsx +0 -273
  107. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  108. package/src/components/ui/blinking-indicator.tsx +0 -27
  109. package/src/components/ui/divider.tsx +0 -162
  110. package/src/components/ui/gradient.tsx +0 -56
  111. package/src/components/ui/input.tsx +0 -228
  112. package/src/components/ui/select.tsx +0 -151
  113. package/src/components/ui/shimmer.tsx +0 -76
  114. package/src/context/agent-mode.tsx +0 -95
  115. package/src/context/extension-file.tsx +0 -136
  116. package/src/context/network-activity.tsx +0 -45
  117. package/src/context/notification.tsx +0 -62
  118. package/src/context/shell-size.tsx +0 -49
  119. package/src/context/shell-title.tsx +0 -38
  120. package/src/entrypoints/print-mode.ts +0 -312
  121. package/src/entrypoints/repl.tsx +0 -389
  122. package/src/hooks/use-agent.ts +0 -15
  123. package/src/hooks/use-api-client.ts +0 -1
  124. package/src/hooks/use-available-height.ts +0 -8
  125. package/src/hooks/use-cleanup.ts +0 -29
  126. package/src/hooks/use-interrupt-manager.ts +0 -242
  127. package/src/hooks/use-models.ts +0 -22
  128. package/src/index.ts +0 -217
  129. package/src/lib/__tests__/ansi.test.ts +0 -255
  130. package/src/lib/__tests__/cli.test.ts +0 -122
  131. package/src/lib/__tests__/commands.test.ts +0 -325
  132. package/src/lib/__tests__/constants.test.ts +0 -15
  133. package/src/lib/__tests__/focusables.test.ts +0 -25
  134. package/src/lib/__tests__/fs.test.ts +0 -231
  135. package/src/lib/__tests__/markdown.test.tsx +0 -348
  136. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  137. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  138. package/src/lib/__tests__/path-paste.test.ts +0 -144
  139. package/src/lib/__tests__/path.test.ts +0 -300
  140. package/src/lib/__tests__/queries.test.ts +0 -39
  141. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  142. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  143. package/src/lib/__tests__/text-utils.test.ts +0 -32
  144. package/src/lib/__tests__/timing.test.ts +0 -78
  145. package/src/lib/__tests__/utils.test.ts +0 -238
  146. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  147. package/src/lib/ansi.ts +0 -150
  148. package/src/lib/cli-push-server.ts +0 -112
  149. package/src/lib/cli.ts +0 -44
  150. package/src/lib/clipboard.ts +0 -226
  151. package/src/lib/command-utils.ts +0 -93
  152. package/src/lib/commands.ts +0 -270
  153. package/src/lib/constants.ts +0 -3
  154. package/src/lib/extension-connection.ts +0 -181
  155. package/src/lib/focusables.ts +0 -7
  156. package/src/lib/fs.ts +0 -533
  157. package/src/lib/markdown/code-block.tsx +0 -63
  158. package/src/lib/markdown/index.ts +0 -4
  159. package/src/lib/markdown/link.tsx +0 -19
  160. package/src/lib/markdown/markdown.tsx +0 -372
  161. package/src/lib/markdown/types.ts +0 -15
  162. package/src/lib/mcpCommandHandler.ts +0 -121
  163. package/src/lib/mcpManagement.ts +0 -44
  164. package/src/lib/path-paste.ts +0 -185
  165. package/src/lib/path.ts +0 -179
  166. package/src/lib/queries.ts +0 -15
  167. package/src/lib/standaloneMcpService.ts +0 -688
  168. package/src/lib/status-utils.ts +0 -237
  169. package/src/lib/test-utils.tsx +0 -72
  170. package/src/lib/text-buffer.ts +0 -2415
  171. package/src/lib/text-utils.ts +0 -272
  172. package/src/lib/timing.ts +0 -63
  173. package/src/lib/types.ts +0 -295
  174. package/src/lib/utils.ts +0 -182
  175. package/src/lib/vim-buffer-actions.ts +0 -732
  176. package/src/providers/agent.tsx +0 -1063
  177. package/src/providers/api-client.tsx +0 -43
  178. package/src/services/logger.ts +0 -85
  179. package/src/terminal/detection.ts +0 -187
  180. package/src/terminal/exit.ts +0 -279
  181. package/src/terminal/notification.ts +0 -83
  182. package/src/terminal/progress.ts +0 -201
  183. package/src/terminal/setup.ts +0 -797
  184. package/src/terminal/types.ts +0 -51
  185. package/src/theme/context.tsx +0 -57
  186. package/src/theme/index.ts +0 -4
  187. package/src/theme/themed.tsx +0 -35
  188. package/src/theme/themes.json +0 -546
  189. package/src/theme/types.ts +0 -110
  190. package/src/tools/types.ts +0 -59
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  192. package/src/tools/utils/tool-ui-components.tsx +0 -649
  193. package/src/tools/utils/zod-coercion.ts +0 -35
  194. package/tsconfig.json +0 -16
  195. package/tsconfig.node.json +0 -29
  196. package/tsconfig.test.json +0 -27
  197. package/tsdown.config.ts +0 -17
  198. package/vitest.config.ts +0 -76
@@ -1,39 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { describe, expect, it } from "vitest";
4
-
5
- import { QueryKey } from "../queries.js";
6
-
7
- describe.concurrent("queries", () => {
8
- it("should export QueryKey enum with correct values", () => {
9
- expect(QueryKey.Models).toBe("models");
10
- expect(QueryKey.CreateConversation).toBe("create-conversation");
11
- expect(QueryKey.GetConversation).toBe("get-conversation");
12
- expect(QueryKey.Grep).toBe("grep");
13
- expect(QueryKey.FileSearch).toBe("file-search");
14
- expect(QueryKey.ListDir).toBe("list-dir");
15
- expect(QueryKey.ReadFile).toBe("read-file");
16
- expect(QueryKey.DeleteFile).toBe("delete-file");
17
- expect(QueryKey.EditFile).toBe("edit-file");
18
- expect(QueryKey.RunTerminal).toBe("run-terminal");
19
- expect(QueryKey.GetTerminalOutput).toBe("get-terminal-output");
20
- expect(QueryKey.MCPTool).toBe("mcp-tool");
21
- });
22
-
23
- it("should have all expected enum values", () => {
24
- const values = Object.values(QueryKey);
25
- expect(values.length).toBe(12);
26
- expect(values).toContain("models");
27
- expect(values).toContain("create-conversation");
28
- expect(values).toContain("get-conversation");
29
- expect(values).toContain("grep");
30
- expect(values).toContain("file-search");
31
- expect(values).toContain("list-dir");
32
- expect(values).toContain("read-file");
33
- expect(values).toContain("delete-file");
34
- expect(values).toContain("edit-file");
35
- expect(values).toContain("run-terminal");
36
- expect(values).toContain("get-terminal-output");
37
- expect(values).toContain("mcp-tool");
38
- });
39
- });
@@ -1,71 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { describe, expect, it } from "vitest";
4
-
5
- import type { IMcpServerInfo } from "../types.js";
6
-
7
- import { StandaloneMcpService } from "../standaloneMcpService.js";
8
-
9
- describe.concurrent("StandaloneMcpService", () => {
10
- describe.concurrent("constructor", () => {
11
- it("should create instance", () => {
12
- const service = new StandaloneMcpService();
13
- expect(service).toBeInstanceOf(StandaloneMcpService);
14
- });
15
- });
16
-
17
- describe.concurrent("listServers", () => {
18
- it("should return array of servers", async () => {
19
- const service = new StandaloneMcpService();
20
- const servers = await service.listServers();
21
- expect(Array.isArray(servers)).toBe(true);
22
- });
23
- });
24
-
25
- describe.concurrent("formatServerList", () => {
26
- it("should format empty server list", () => {
27
- const service = new StandaloneMcpService();
28
- const formatted = service.formatServerList([]);
29
- expect(typeof formatted).toBe("string");
30
- });
31
- });
32
-
33
- describe.concurrent("getServer", () => {
34
- it("should return undefined for non-existent server", async () => {
35
- const service = new StandaloneMcpService();
36
- const server = await service.getServer("nonexistent-server-12345");
37
- expect(server).toBeUndefined();
38
- });
39
- });
40
-
41
- describe.concurrent("formatServerInfo", () => {
42
- it("should format server info with stdio config", () => {
43
- const service = new StandaloneMcpService();
44
- const serverInfo: IMcpServerInfo = {
45
- id: "test-server",
46
- name: "test-server",
47
- config: {
48
- command: "node",
49
- args: ["server.js"],
50
- },
51
- };
52
- const formatted = service.formatServerInfo(serverInfo);
53
- expect(typeof formatted).toBe("string");
54
- expect(formatted).toContain("test-server");
55
- });
56
-
57
- it("should format server info with http config", () => {
58
- const service = new StandaloneMcpService();
59
- const serverInfo: IMcpServerInfo = {
60
- id: "test-server",
61
- name: "test-server",
62
- config: {
63
- url: "http://localhost:3000",
64
- },
65
- };
66
- const formatted = service.formatServerInfo(serverInfo);
67
- expect(typeof formatted).toBe("string");
68
- expect(formatted).toContain("test-server");
69
- });
70
- });
71
- });
@@ -1,328 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { describe, expect, it } from "vitest";
4
-
5
- import {
6
- isWordCharStrict,
7
- isWhitespace,
8
- isCombiningMark,
9
- isWordCharWithCombining,
10
- getCharScript,
11
- isDifferentScript,
12
- findNextWordStartInLine,
13
- findPrevWordStartInLine,
14
- findWordEndInLine,
15
- offsetToLogicalPos,
16
- logicalPosToOffset,
17
- pushUndo,
18
- replaceRangeInternal,
19
- type TextBufferState,
20
- } from "../text-buffer.js";
21
-
22
- describe.concurrent("text-buffer", () => {
23
- describe.concurrent("isWordCharStrict", () => {
24
- it("should identify word characters", () => {
25
- expect(isWordCharStrict("a")).toBe(true);
26
- expect(isWordCharStrict("Z")).toBe(true);
27
- expect(isWordCharStrict("5")).toBe(true);
28
- expect(isWordCharStrict("_")).toBe(true);
29
- });
30
-
31
- it("should identify non-word characters", () => {
32
- expect(isWordCharStrict(" ")).toBe(false);
33
- expect(isWordCharStrict(".")).toBe(false);
34
- expect(isWordCharStrict("!")).toBe(false);
35
- });
36
- });
37
-
38
- describe.concurrent("isWhitespace", () => {
39
- it("should identify whitespace characters", () => {
40
- expect(isWhitespace(" ")).toBe(true);
41
- expect(isWhitespace("\t")).toBe(true);
42
- expect(isWhitespace("\n")).toBe(true);
43
- });
44
-
45
- it("should identify non-whitespace characters", () => {
46
- expect(isWhitespace("a")).toBe(false);
47
- expect(isWhitespace("1")).toBe(false);
48
- });
49
- });
50
-
51
- describe.concurrent("isCombiningMark", () => {
52
- it("should identify combining marks", () => {
53
- // Combining marks like diacritics
54
- expect(isCombiningMark("\u0300")).toBe(true); // Combining grave accent
55
- });
56
-
57
- it("should identify non-combining characters", () => {
58
- expect(isCombiningMark("a")).toBe(false);
59
- expect(isCombiningMark("1")).toBe(false);
60
- });
61
- });
62
-
63
- describe.concurrent("isWordCharWithCombining", () => {
64
- it("should identify word characters including combining marks", () => {
65
- expect(isWordCharWithCombining("a")).toBe(true);
66
- expect(isWordCharWithCombining("\u0300")).toBe(true); // Combining mark
67
- });
68
-
69
- it("should identify non-word characters", () => {
70
- expect(isWordCharWithCombining(" ")).toBe(false);
71
- expect(isWordCharWithCombining(".")).toBe(false);
72
- });
73
- });
74
-
75
- describe.concurrent("getCharScript", () => {
76
- it("should identify Latin script", () => {
77
- expect(getCharScript("a")).toBe("latin");
78
- expect(getCharScript("A")).toBe("latin");
79
- });
80
-
81
- it("should identify other scripts", () => {
82
- expect(getCharScript("中")).toBe("han");
83
- expect(getCharScript("ا")).toBe("arabic");
84
- });
85
-
86
- it("should return other for unknown scripts", () => {
87
- expect(getCharScript(" ")).toBe("other");
88
- });
89
- });
90
-
91
- describe.concurrent("isDifferentScript", () => {
92
- it("should detect different scripts", () => {
93
- expect(isDifferentScript("a", "中")).toBe(true);
94
- });
95
-
96
- it("should detect same script", () => {
97
- expect(isDifferentScript("a", "b")).toBe(false);
98
- });
99
-
100
- it("should return false for non-word characters", () => {
101
- expect(isDifferentScript(" ", "a")).toBe(false);
102
- });
103
- });
104
-
105
- describe.concurrent("findNextWordStartInLine", () => {
106
- it("should find next word start", () => {
107
- const result = findNextWordStartInLine("hello world", 0);
108
- expect(result).toBe(6);
109
- });
110
-
111
- it("should return null at end of line", () => {
112
- const result = findNextWordStartInLine("hello", 0);
113
- expect(result).toBeNull();
114
- });
115
-
116
- it("should handle empty line", () => {
117
- const result = findNextWordStartInLine("", 0);
118
- expect(result).toBeNull();
119
- });
120
- });
121
-
122
- describe.concurrent("findPrevWordStartInLine", () => {
123
- it("should find previous word start", () => {
124
- const result = findPrevWordStartInLine("hello world", 11);
125
- expect(result).toBe(6);
126
- });
127
-
128
- it("should return null at start of line", () => {
129
- const result = findPrevWordStartInLine("hello", 0);
130
- expect(result).toBeNull();
131
- });
132
- });
133
-
134
- describe.concurrent("findWordEndInLine", () => {
135
- it("should find word end", () => {
136
- const result = findWordEndInLine("hello world", 0);
137
- expect(result).toBe(4);
138
- });
139
-
140
- it("should return null when no word found", () => {
141
- const result = findWordEndInLine(" ", 0);
142
- expect(result).toBeNull();
143
- });
144
- });
145
-
146
- describe.concurrent("offsetToLogicalPos", () => {
147
- it("should convert offset to position", () => {
148
- const [row, col] = offsetToLogicalPos("hello\nworld", 0);
149
- expect(row).toBe(0);
150
- expect(col).toBe(0);
151
- });
152
-
153
- it("should handle offset in middle of line", () => {
154
- const [row, col] = offsetToLogicalPos("hello\nworld", 3);
155
- expect(row).toBe(0);
156
- expect(col).toBe(3);
157
- });
158
-
159
- it("should handle offset across lines", () => {
160
- const [row, col] = offsetToLogicalPos("hello\nworld", 7);
161
- expect(row).toBe(1);
162
- expect(col).toBe(1);
163
- });
164
-
165
- it("should handle empty text", () => {
166
- const [row, col] = offsetToLogicalPos("", 0);
167
- expect(row).toBe(0);
168
- expect(col).toBe(0);
169
- });
170
- });
171
-
172
- describe.concurrent("logicalPosToOffset", () => {
173
- it("should convert position to offset", () => {
174
- const offset = logicalPosToOffset(["hello", "world"], 0, 0);
175
- expect(offset).toBe(0);
176
- });
177
-
178
- it("should handle position in middle of line", () => {
179
- const offset = logicalPosToOffset(["hello", "world"], 0, 3);
180
- expect(offset).toBe(3);
181
- });
182
-
183
- it("should handle position across lines", () => {
184
- const offset = logicalPosToOffset(["hello", "world"], 1, 2);
185
- expect(offset).toBe(8); // 5 (hello) + 1 (newline) + 2 (wo)
186
- });
187
-
188
- it("should be inverse of offsetToLogicalPos", () => {
189
- // TODO: VERIFICATION - The functions are documented as inverse operations,
190
- // but this round-trip test should verify they work correctly for all cases,
191
- // especially with Unicode characters, empty lines, and edge positions.
192
- // Current test only covers basic case - should add more comprehensive tests.
193
- const lines = ["hello", "world", "test"];
194
- const text = lines.join("\n");
195
- const [row, col] = offsetToLogicalPos(text, 8);
196
- const offset = logicalPosToOffset(lines, row, col);
197
- expect(offset).toBe(8);
198
- });
199
- });
200
-
201
- describe.concurrent("pushUndo", () => {
202
- it("should add state to undo stack", () => {
203
- const state: TextBufferState = {
204
- lines: ["hello"],
205
- cursorRow: 0,
206
- cursorCol: 5,
207
- preferredCol: null,
208
- undoStack: [],
209
- redoStack: [],
210
- clipboard: null,
211
- selectionAnchor: null,
212
- viewportWidth: 80,
213
- viewportHeight: 24,
214
- visualLayout: {
215
- visualLines: ["hello"],
216
- logicalToVisualMap: [[[0, 0]]],
217
- visualToLogicalMap: [[0, 0]],
218
- },
219
- };
220
-
221
- const newState = pushUndo(state);
222
- expect(newState.undoStack.length).toBe(1);
223
- expect(newState.redoStack.length).toBe(0);
224
- });
225
-
226
- it("should clear redo stack", () => {
227
- const state: TextBufferState = {
228
- lines: ["hello"],
229
- cursorRow: 0,
230
- cursorCol: 5,
231
- preferredCol: null,
232
- undoStack: [],
233
- redoStack: [{ lines: ["old"], cursorRow: 0, cursorCol: 3 }],
234
- clipboard: null,
235
- selectionAnchor: null,
236
- viewportWidth: 80,
237
- viewportHeight: 24,
238
- visualLayout: {
239
- visualLines: ["hello"],
240
- logicalToVisualMap: [[[0, 0]]],
241
- visualToLogicalMap: [[0, 0]],
242
- },
243
- };
244
-
245
- const newState = pushUndo(state);
246
- expect(newState.redoStack.length).toBe(0);
247
- });
248
- });
249
-
250
- describe.concurrent("replaceRangeInternal", () => {
251
- it("should replace text in range", () => {
252
- const state: TextBufferState = {
253
- lines: ["hello world"],
254
- cursorRow: 0,
255
- cursorCol: 5,
256
- preferredCol: null,
257
- undoStack: [],
258
- redoStack: [],
259
- clipboard: null,
260
- selectionAnchor: null,
261
- viewportWidth: 80,
262
- viewportHeight: 24,
263
- visualLayout: {
264
- visualLines: ["hello world"],
265
- logicalToVisualMap: [[[0, 0]]],
266
- visualToLogicalMap: [[0, 0]],
267
- },
268
- };
269
-
270
- const newState = replaceRangeInternal(state, 0, 0, 0, 5, "hi");
271
- expect(newState.lines[0]).toBe("hi world");
272
- });
273
-
274
- it("should handle multi-line replacement", () => {
275
- const state: TextBufferState = {
276
- lines: ["hello", "world"],
277
- cursorRow: 0,
278
- cursorCol: 0,
279
- preferredCol: null,
280
- undoStack: [],
281
- redoStack: [],
282
- clipboard: null,
283
- selectionAnchor: null,
284
- viewportWidth: 80,
285
- viewportHeight: 24,
286
- visualLayout: {
287
- visualLines: ["hello", "world"],
288
- logicalToVisualMap: [[[0, 0]], [[1, 0]]],
289
- visualToLogicalMap: [
290
- [0, 0],
291
- [1, 0],
292
- ],
293
- },
294
- };
295
-
296
- const newState = replaceRangeInternal(state, 0, 0, 1, 5, "test");
297
- expect(newState.lines).toEqual(["test"]);
298
- });
299
-
300
- it("should return original state for invalid range", () => {
301
- // TODO: DESIGN ISSUE - replaceRangeInternal silently fails for invalid ranges
302
- // by returning the original state unchanged. This makes it impossible to
303
- // distinguish between "no change needed" and "invalid input".
304
- // Consider: Throwing an error, returning a result object with success flag,
305
- // or at least logging a warning for invalid ranges.
306
- const state: TextBufferState = {
307
- lines: ["hello"],
308
- cursorRow: 0,
309
- cursorCol: 0,
310
- preferredCol: null,
311
- undoStack: [],
312
- redoStack: [],
313
- clipboard: null,
314
- selectionAnchor: null,
315
- viewportWidth: 80,
316
- viewportHeight: 24,
317
- visualLayout: {
318
- visualLines: ["hello"],
319
- logicalToVisualMap: [[[0, 0]]],
320
- visualToLogicalMap: [[0, 0]],
321
- },
322
- };
323
-
324
- const newState = replaceRangeInternal(state, 10, 0, 10, 0, "test");
325
- expect(newState).toBe(state);
326
- });
327
- });
328
- });
@@ -1,32 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- import { getAsciiArtWidth, toCodePoints } from "../text-utils.js";
4
-
5
- describe.concurrent("text-utils", () => {
6
- describe.concurrent("getAsciiArtWidth", () => {
7
- it("should return 0 for empty string", () => {
8
- expect(getAsciiArtWidth("")).toBe(0);
9
- });
10
-
11
- it("should return the width of a single line", () => {
12
- expect(getAsciiArtWidth("hello")).toBe(5);
13
- });
14
-
15
- it("should return the maximum width of multiple lines", () => {
16
- const asciiArt = "hello\nworld\nhi";
17
- expect(getAsciiArtWidth(asciiArt)).toBe(5);
18
- });
19
- });
20
-
21
- describe.concurrent("toCodePoints", () => {
22
- it("should split ASCII string into characters", () => {
23
- expect(toCodePoints("abc")).toEqual(["a", "b", "c"]);
24
- });
25
-
26
- it("should handle emoji correctly", () => {
27
- const result = toCodePoints("👋");
28
- expect(result.length).toBe(1);
29
- expect(result[0]).toBe("👋");
30
- });
31
- });
32
- });
@@ -1,78 +0,0 @@
1
- // @vitest-environment node
2
-
3
- import { describe, expect, it, vi, beforeEach } from "vitest";
4
-
5
- import { Timing } from "../timing.js";
6
-
7
- describe.concurrent("Timing", () => {
8
- beforeEach(() => {
9
- vi.useFakeTimers();
10
- });
11
-
12
- it("should initialize with current time", () => {
13
- const timing = new Timing();
14
- expect(timing.getElapsedMs()).toBe(0);
15
- expect(timing.getElapsedSeconds()).toBe(0);
16
- });
17
-
18
- it("should calculate elapsed time in milliseconds", () => {
19
- const timing = new Timing();
20
- vi.advanceTimersByTime(100);
21
- expect(timing.getElapsedMs()).toBe(100);
22
- });
23
-
24
- it("should calculate elapsed time in seconds", () => {
25
- const timing = new Timing();
26
- vi.advanceTimersByTime(2500);
27
- expect(timing.getElapsedSeconds()).toBe(2.5);
28
- });
29
-
30
- it("should format duration correctly", () => {
31
- const timing = new Timing();
32
- vi.advanceTimersByTime(1234);
33
- const formatted = timing.getFormattedDuration();
34
- expect(formatted).toBe("1s");
35
- });
36
-
37
- it("should format duration with minutes", () => {
38
- const timing = new Timing();
39
- vi.advanceTimersByTime(125000); // 2 minutes 5 seconds
40
- const formatted = timing.getFormattedDuration();
41
- expect(formatted).toBe("2m 5s");
42
- });
43
-
44
- it("should format duration with hours", () => {
45
- const timing = new Timing();
46
- vi.advanceTimersByTime(3665000); // 1 hour 1 minute 5 seconds
47
- const formatted = timing.getFormattedDuration();
48
- expect(formatted).toBe("1h 1m 5s");
49
- });
50
-
51
- it("should reset the timer", () => {
52
- const timing = new Timing();
53
- vi.advanceTimersByTime(1000);
54
- expect(timing.getElapsedMs()).toBeGreaterThan(0);
55
-
56
- timing.reset();
57
- expect(timing.getElapsedMs()).toBe(0);
58
- expect(timing.getElapsedSeconds()).toBe(0);
59
- });
60
-
61
- it("should continue timing after reset", () => {
62
- const timing = new Timing();
63
- vi.advanceTimersByTime(1000);
64
- timing.reset();
65
- vi.advanceTimersByTime(500);
66
- expect(timing.getElapsedMs()).toBe(500);
67
- });
68
-
69
- it("should handle multiple resets", () => {
70
- const timing = new Timing();
71
- vi.advanceTimersByTime(1000);
72
- timing.reset();
73
- vi.advanceTimersByTime(500);
74
- timing.reset();
75
- vi.advanceTimersByTime(250);
76
- expect(timing.getElapsedMs()).toBe(250);
77
- });
78
- });