@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.
Files changed (200) hide show
  1. package/.oxlintrc.json +8 -0
  2. package/dist/index.mjs +12603 -0
  3. package/package.json +7 -39
  4. package/resources/abacus.ico +0 -0
  5. package/resources/entitlements.plist +9 -0
  6. package/src/__e2e__/README.md +196 -0
  7. package/src/__e2e__/agent-interactions.e2e.test.tsx +61 -0
  8. package/src/__e2e__/cli-commands.e2e.test.tsx +77 -0
  9. package/src/__e2e__/conversation-throttle.e2e.test.ts +453 -0
  10. package/src/__e2e__/conversation.e2e.test.tsx +56 -0
  11. package/src/__e2e__/diff-preview.e2e.test.tsx +3399 -0
  12. package/src/__e2e__/file-creation.e2e.test.tsx +149 -0
  13. package/src/__e2e__/helpers/test-helpers.ts +450 -0
  14. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +34 -0
  15. package/src/__e2e__/llm-models.e2e.test.ts +402 -0
  16. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +71 -0
  17. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +167 -0
  18. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +185 -0
  19. package/src/__e2e__/repl.e2e.test.tsx +78 -0
  20. package/src/__e2e__/shell-compatibility.e2e.test.tsx +76 -0
  21. package/src/__e2e__/theme-mcp.e2e.test.tsx +98 -0
  22. package/src/__e2e__/tool-permissions.e2e.test.tsx +66 -0
  23. package/src/args.ts +22 -0
  24. package/src/components/__tests__/react-compiler.test.tsx +78 -0
  25. package/src/components/__tests__/status-indicator.test.tsx +403 -0
  26. package/src/components/composer/__tests__/bash-runner.test.tsx +263 -0
  27. package/src/components/composer/agent-mode-indicator.tsx +63 -0
  28. package/src/components/composer/bash-runner.tsx +54 -0
  29. package/src/components/composer/commands/default-commands.tsx +615 -0
  30. package/src/components/composer/commands/handler.tsx +59 -0
  31. package/src/components/composer/commands/picker.tsx +273 -0
  32. package/src/components/composer/commands/registry.ts +233 -0
  33. package/src/components/composer/commands/types.ts +33 -0
  34. package/src/components/composer/context.tsx +88 -0
  35. package/src/components/composer/file-mention-picker.tsx +83 -0
  36. package/src/components/composer/help.tsx +44 -0
  37. package/src/components/composer/index.tsx +1006 -0
  38. package/src/components/composer/mentions.ts +57 -0
  39. package/src/components/composer/message-queue.tsx +70 -0
  40. package/src/components/composer/mode-panel.tsx +35 -0
  41. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +755 -0
  42. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +1108 -0
  43. package/src/components/composer/modes/bash-handler.tsx +132 -0
  44. package/src/components/composer/modes/bash-renderer.tsx +175 -0
  45. package/src/components/composer/modes/default-handlers.tsx +33 -0
  46. package/src/components/composer/modes/index.ts +41 -0
  47. package/src/components/composer/modes/types.ts +21 -0
  48. package/src/components/composer/persistent-shell.ts +283 -0
  49. package/src/components/composer/process.ts +65 -0
  50. package/src/components/composer/types.ts +9 -0
  51. package/src/components/composer/use-mention-search.ts +68 -0
  52. package/src/components/error-boundry.tsx +60 -0
  53. package/src/components/exit-message.tsx +29 -0
  54. package/src/components/expanded-view.tsx +74 -0
  55. package/src/components/file-completion.tsx +127 -0
  56. package/src/components/header.tsx +47 -0
  57. package/src/components/logo.tsx +37 -0
  58. package/src/components/segments.tsx +356 -0
  59. package/src/components/status-indicator.tsx +306 -0
  60. package/src/components/tool-group-summary.tsx +263 -0
  61. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +312 -0
  62. package/src/components/tool-permissions/diff-preview.tsx +355 -0
  63. package/src/components/tool-permissions/index.ts +5 -0
  64. package/src/components/tool-permissions/permission-options.tsx +375 -0
  65. package/src/components/tool-permissions/permission-preview-header.tsx +57 -0
  66. package/src/components/tool-permissions/tool-permission-ui.tsx +398 -0
  67. package/src/components/tools/agent/ask-user-question.tsx +101 -0
  68. package/src/components/tools/agent/enter-plan-mode.tsx +49 -0
  69. package/src/components/tools/agent/exit-plan-mode.tsx +75 -0
  70. package/src/components/tools/agent/handoff-to-main.tsx +27 -0
  71. package/src/components/tools/agent/subagent.tsx +37 -0
  72. package/src/components/tools/agent/todo-write.tsx +104 -0
  73. package/src/components/tools/browser/close-tab.tsx +58 -0
  74. package/src/components/tools/browser/computer.tsx +70 -0
  75. package/src/components/tools/browser/get-interactive-elements.tsx +54 -0
  76. package/src/components/tools/browser/get-tab-content.tsx +51 -0
  77. package/src/components/tools/browser/navigate-to.tsx +59 -0
  78. package/src/components/tools/browser/new-tab.tsx +60 -0
  79. package/src/components/tools/browser/perform-action.tsx +63 -0
  80. package/src/components/tools/browser/refresh-tab.tsx +43 -0
  81. package/src/components/tools/browser/switch-tab.tsx +58 -0
  82. package/src/components/tools/filesystem/delete-file.tsx +104 -0
  83. package/src/components/tools/filesystem/edit.tsx +220 -0
  84. package/src/components/tools/filesystem/list-dir.tsx +78 -0
  85. package/src/components/tools/filesystem/read-file.tsx +180 -0
  86. package/src/components/tools/filesystem/upload-image.tsx +76 -0
  87. package/src/components/tools/ide/ide-diagnostics.tsx +62 -0
  88. package/src/components/tools/index.ts +91 -0
  89. package/src/components/tools/mcp/mcp-tool.tsx +158 -0
  90. package/src/components/tools/search/fetch-url.tsx +73 -0
  91. package/src/components/tools/search/file-search.tsx +78 -0
  92. package/src/components/tools/search/grep.tsx +90 -0
  93. package/src/components/tools/search/semantic-search.tsx +66 -0
  94. package/src/components/tools/search/web-search.tsx +71 -0
  95. package/src/components/tools/shared/index.tsx +48 -0
  96. package/src/components/tools/shared/zod-coercion.ts +35 -0
  97. package/src/components/tools/terminal/bash-tool-output.tsx +174 -0
  98. package/src/components/tools/terminal/get-terminal-output.tsx +85 -0
  99. package/src/components/tools/terminal/run-in-terminal.tsx +106 -0
  100. package/src/components/tools/types.ts +16 -0
  101. package/src/components/tools.tsx +66 -0
  102. package/src/components/ui/__tests__/divider.test.tsx +61 -0
  103. package/src/components/ui/__tests__/gradient.test.tsx +125 -0
  104. package/src/components/ui/__tests__/input.test.tsx +166 -0
  105. package/src/components/ui/__tests__/select.test.tsx +273 -0
  106. package/src/components/ui/__tests__/shimmer.test.tsx +99 -0
  107. package/src/components/ui/blinking-indicator.tsx +25 -0
  108. package/src/components/ui/divider.tsx +162 -0
  109. package/src/components/ui/gradient.tsx +56 -0
  110. package/src/components/ui/input.tsx +228 -0
  111. package/src/components/ui/select.tsx +151 -0
  112. package/src/components/ui/shimmer.tsx +84 -0
  113. package/src/context/agent-mode.tsx +95 -0
  114. package/src/context/extension-file.tsx +136 -0
  115. package/src/context/network-activity.tsx +45 -0
  116. package/src/context/notification.tsx +62 -0
  117. package/src/context/shell-size.tsx +49 -0
  118. package/src/context/shell-title.tsx +38 -0
  119. package/src/entrypoints/print-mode.ts +312 -0
  120. package/src/entrypoints/repl.tsx +401 -0
  121. package/src/hooks/use-agent.ts +15 -0
  122. package/src/hooks/use-api-client.ts +1 -0
  123. package/src/hooks/use-available-height.ts +8 -0
  124. package/src/hooks/use-cleanup.ts +29 -0
  125. package/src/hooks/use-interrupt-manager.ts +242 -0
  126. package/src/hooks/use-models.ts +22 -0
  127. package/src/index.ts +217 -0
  128. package/src/lib/__tests__/ansi.test.ts +255 -0
  129. package/src/lib/__tests__/cli.test.ts +122 -0
  130. package/src/lib/__tests__/commands.test.ts +325 -0
  131. package/src/lib/__tests__/constants.test.ts +15 -0
  132. package/src/lib/__tests__/focusables.test.ts +25 -0
  133. package/src/lib/__tests__/fs.test.ts +231 -0
  134. package/src/lib/__tests__/markdown.test.tsx +348 -0
  135. package/src/lib/__tests__/mcpCommandHandler.test.ts +173 -0
  136. package/src/lib/__tests__/mcpManagement.test.ts +38 -0
  137. package/src/lib/__tests__/path-paste.test.ts +144 -0
  138. package/src/lib/__tests__/path.test.ts +300 -0
  139. package/src/lib/__tests__/queries.test.ts +39 -0
  140. package/src/lib/__tests__/standaloneMcpService.test.ts +71 -0
  141. package/src/lib/__tests__/text-buffer.test.ts +328 -0
  142. package/src/lib/__tests__/text-utils.test.ts +32 -0
  143. package/src/lib/__tests__/timing.test.ts +78 -0
  144. package/src/lib/__tests__/utils.test.ts +238 -0
  145. package/src/lib/__tests__/vim-buffer-actions.test.ts +154 -0
  146. package/src/lib/ansi.ts +150 -0
  147. package/src/lib/cli-push-server.ts +112 -0
  148. package/src/lib/cli.ts +44 -0
  149. package/src/lib/clipboard.ts +226 -0
  150. package/src/lib/command-utils.ts +93 -0
  151. package/src/lib/commands.ts +270 -0
  152. package/src/lib/constants.ts +3 -0
  153. package/src/lib/extension-connection.ts +181 -0
  154. package/src/lib/focusables.ts +7 -0
  155. package/src/lib/fs.ts +533 -0
  156. package/src/lib/markdown/code-block.tsx +63 -0
  157. package/src/lib/markdown/index.ts +4 -0
  158. package/src/lib/markdown/link.tsx +19 -0
  159. package/src/lib/markdown/markdown.tsx +372 -0
  160. package/src/lib/markdown/types.ts +15 -0
  161. package/src/lib/mcpCommandHandler.ts +121 -0
  162. package/src/lib/mcpManagement.ts +44 -0
  163. package/src/lib/path-paste.ts +185 -0
  164. package/src/lib/path.ts +179 -0
  165. package/src/lib/queries.ts +15 -0
  166. package/src/lib/standaloneMcpService.ts +688 -0
  167. package/src/lib/status-utils.ts +237 -0
  168. package/src/lib/test-utils.tsx +72 -0
  169. package/src/lib/text-buffer.ts +2415 -0
  170. package/src/lib/text-utils.ts +272 -0
  171. package/src/lib/timing.ts +63 -0
  172. package/src/lib/types.ts +295 -0
  173. package/src/lib/utils.ts +182 -0
  174. package/src/lib/vim-buffer-actions.ts +732 -0
  175. package/src/providers/agent.tsx +1075 -0
  176. package/src/providers/api-client.tsx +43 -0
  177. package/src/services/logger.ts +85 -0
  178. package/src/terminal/detection.ts +187 -0
  179. package/src/terminal/exit.ts +279 -0
  180. package/src/terminal/notification.ts +83 -0
  181. package/src/terminal/progress.ts +201 -0
  182. package/src/terminal/setup.ts +797 -0
  183. package/src/terminal/suspend.ts +58 -0
  184. package/src/terminal/types.ts +51 -0
  185. package/src/theme/context.tsx +57 -0
  186. package/src/theme/index.ts +4 -0
  187. package/src/theme/themed.tsx +35 -0
  188. package/src/theme/themes.json +546 -0
  189. package/src/theme/types.ts +110 -0
  190. package/src/tools/types.ts +59 -0
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +33 -0
  192. package/src/tools/utils/tool-ui-components.tsx +631 -0
  193. package/src/tools/utils/zod-coercion.ts +35 -0
  194. package/tsconfig.json +11 -0
  195. package/tsconfig.node.json +29 -0
  196. package/tsconfig.test.json +27 -0
  197. package/tsdown.config.ts +17 -0
  198. package/vitest.config.ts +76 -0
  199. package/README.md +0 -28
  200. package/dist/index.js +0 -26
@@ -0,0 +1,65 @@
1
+ import { spawn } from "node:child_process";
2
+
3
+ export type StreamChunk = { type: "stdout" | "stderr"; data: string };
4
+
5
+ type Resolver = (() => void) | null;
6
+
7
+ export function runCommandStreaming(commandLine: string): {
8
+ stream: AsyncGenerator<StreamChunk, void, void>;
9
+ exit: Promise<number>;
10
+ } {
11
+ const child = spawn(commandLine, { shell: true, stdio: ["ignore", "pipe", "pipe"] });
12
+
13
+ const queue: StreamChunk[] = [];
14
+ let notify: Resolver = null;
15
+ let closed = false;
16
+ let exitCode = 0;
17
+
18
+ const onData = (type: "stdout" | "stderr") => (chunk: unknown) => {
19
+ const data =
20
+ typeof chunk === "string"
21
+ ? chunk
22
+ : Buffer.isBuffer(chunk)
23
+ ? chunk.toString("utf8")
24
+ : String(chunk);
25
+ queue.push({ type, data });
26
+ if (notify) {
27
+ const n = notify;
28
+ notify = null;
29
+ n();
30
+ }
31
+ };
32
+
33
+ child.stdout?.on("data", onData("stdout"));
34
+ child.stderr?.on("data", onData("stderr"));
35
+
36
+ const exit = new Promise<number>((resolve) => {
37
+ child.on("close", (code) => {
38
+ exitCode = typeof code === "number" ? code : 0;
39
+ closed = true;
40
+ if (notify) {
41
+ const n = notify;
42
+ notify = null;
43
+ n();
44
+ }
45
+ resolve(exitCode);
46
+ });
47
+ });
48
+
49
+ async function* stream(): AsyncGenerator<StreamChunk, void, void> {
50
+ while (true) {
51
+ while (queue.length > 0) {
52
+ const item = queue.shift() as StreamChunk;
53
+ yield item;
54
+ }
55
+ if (closed) {
56
+ return;
57
+ }
58
+ await new Promise<void>((r) => {
59
+ notify = r;
60
+ });
61
+ }
62
+ }
63
+
64
+ return { stream: stream(), exit };
65
+ }
@@ -0,0 +1,9 @@
1
+ export { AgentMode } from "@codellm/agent";
2
+ export enum ComposerMode {
3
+ Prompt,
4
+ Help,
5
+ Bash,
6
+ Command,
7
+ Files,
8
+ }
9
+ export type ModeMeta = { color?: string; placeholder: string; prefix: string };
@@ -0,0 +1,68 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ import { searchFiles } from "../../lib/fs.js";
4
+ import { abbreviateCwd } from "../../lib/path.js";
5
+
6
+ const DEBOUNCE_MS = 100;
7
+
8
+ export function useMentionSearch(query: string) {
9
+ const [results, setResults] = useState<string[]>([]);
10
+ const [isDirectory, setIsDirectory] = useState<boolean[]>([]);
11
+ const abortControllerRef = useRef<AbortController | null>(null);
12
+ const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
13
+ const lastQueryRef = useRef<string>("");
14
+
15
+ useEffect(() => {
16
+ if (debounceTimerRef.current) {
17
+ clearTimeout(debounceTimerRef.current);
18
+ }
19
+
20
+ if (abortControllerRef.current) {
21
+ abortControllerRef.current.abort();
22
+ }
23
+
24
+ if (query.trim().length === 0) {
25
+ setResults([]);
26
+ setIsDirectory([]);
27
+ lastQueryRef.current = "";
28
+ return;
29
+ }
30
+
31
+ debounceTimerRef.current = setTimeout(() => {
32
+ if (query === lastQueryRef.current) {
33
+ return;
34
+ }
35
+ lastQueryRef.current = query;
36
+ const controller = new AbortController();
37
+ abortControllerRef.current = controller;
38
+
39
+ const run = async () => {
40
+ try {
41
+ const iter = searchFiles(query, { root: process.cwd() });
42
+ for await (const batch of iter) {
43
+ if (controller.signal.aborted) {
44
+ return;
45
+ }
46
+ const abbreviated = batch.paths.map(abbreviateCwd);
47
+ setResults(abbreviated);
48
+ setIsDirectory(batch.isDirectory);
49
+ }
50
+ } catch {
51
+ // Silently handle errors - likely aborted
52
+ }
53
+ };
54
+ void run();
55
+ }, DEBOUNCE_MS);
56
+
57
+ return () => {
58
+ if (debounceTimerRef.current) {
59
+ clearTimeout(debounceTimerRef.current);
60
+ }
61
+ if (abortControllerRef.current) {
62
+ abortControllerRef.current.abort();
63
+ }
64
+ };
65
+ }, [query]);
66
+
67
+ return { results, isDirectory };
68
+ }
@@ -0,0 +1,60 @@
1
+ import { View, Text } from "@codellm/jar";
2
+ import { Component } from "react";
3
+
4
+ export interface ErrorBoundaryProps extends React.PropsWithChildren {
5
+ fallback?:
6
+ | React.ReactNode
7
+ | ((error: Error, errorInfo: React.ErrorInfo | null) => React.ReactNode);
8
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
9
+ }
10
+
11
+ interface ErrorBoundaryState {
12
+ hasError: boolean;
13
+ error: Error | null;
14
+ errorInfo: React.ErrorInfo | null;
15
+ }
16
+
17
+ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
18
+ override state: ErrorBoundaryState = {
19
+ hasError: false,
20
+ error: null,
21
+ errorInfo: null,
22
+ };
23
+
24
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState {
25
+ return { hasError: true, error, errorInfo: null };
26
+ }
27
+
28
+ override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
29
+ this.setState({ error, errorInfo });
30
+ if (this.props.onError) {
31
+ this.props.onError(error, errorInfo);
32
+ }
33
+ }
34
+
35
+ override render() {
36
+ const { hasError, error, errorInfo } = this.state;
37
+ const { fallback, children } = this.props;
38
+
39
+ if (hasError) {
40
+ if (fallback) {
41
+ return typeof fallback === "function" ? fallback(error!, errorInfo) : fallback;
42
+ }
43
+ return (
44
+ <View flexDirection="column" padding={1}>
45
+ <Text color="red" bold>
46
+ Something went wrong.
47
+ </Text>
48
+ {error && (
49
+ <View marginTop={1} flexDirection="column">
50
+ <Text color="yellow">{error.toString()}</Text>
51
+ {errorInfo?.componentStack && <Text color="gray">{errorInfo.componentStack}</Text>}
52
+ </View>
53
+ )}
54
+ </View>
55
+ );
56
+ }
57
+
58
+ return children;
59
+ }
60
+ }
@@ -0,0 +1,29 @@
1
+ import { View, Text } from "@codellm/jar";
2
+ import { memo } from "react";
3
+
4
+ import { useTheme } from "../theme/index.js";
5
+ import { SMALL_BLOCK } from "./logo.js";
6
+
7
+ interface ExitMessageProps {
8
+ duration: string;
9
+ credits: number;
10
+ conversationId?: string | null;
11
+ }
12
+
13
+ export const ExitMessage = memo(({ duration, credits, conversationId }: ExitMessageProps) => {
14
+ const { colors } = useTheme();
15
+
16
+ return (
17
+ <View flexDirection="column" paddingY={1}>
18
+ <Text color={colors.primary}>{SMALL_BLOCK}</Text>
19
+ <View height={1} />
20
+ <Text color={colors.info}>https://desktop.abacus.ai</Text>
21
+ <View height={1} />
22
+ <Text dimColor>Spent {duration} in the CLI</Text>
23
+ {credits > 0 && <Text dimColor>Total credits used: {Math.floor(credits * 100) / 100}</Text>}
24
+ {conversationId && <Text dimColor>abacusai --resume {conversationId}</Text>}
25
+ </View>
26
+ );
27
+ });
28
+
29
+ ExitMessage.displayName = "ExitMessage";
@@ -0,0 +1,74 @@
1
+ import { View, Text, useInput } from "@codellm/jar";
2
+ import { memo, useMemo } from "react";
3
+
4
+ import type { HistorySegment } from "../lib/types.js";
5
+
6
+ import { useTheme } from "../theme/index.js";
7
+ import { Segment, ExpandedThinkingSegment } from "./segments.js";
8
+
9
+ interface ExpandedViewProps {
10
+ /** Snapshot of segments taken when expand mode was activated — never updates */
11
+ snapshot: HistorySegment[];
12
+ onClose: () => void;
13
+ }
14
+
15
+ /**
16
+ * Read-only expanded view: shows all segments including thoughts and full tool results.
17
+ * This is a static snapshot — it won't update while open.
18
+ * Ctrl+O or Escape closes it.
19
+ */
20
+ export const ExpandedView = memo(({ snapshot, onClose }: ExpandedViewProps) => {
21
+ const { colors } = useTheme();
22
+
23
+ // Handle Ctrl+O and Escape to close
24
+ useInput((input, key) => {
25
+ if ((key.ctrl || key.super) && input === "o") {
26
+ onClose();
27
+ }
28
+ if (key.escape) {
29
+ onClose();
30
+ }
31
+ });
32
+
33
+ // Filter out temp/spinny segments
34
+ const segments = useMemo(() => snapshot.filter((s) => !s.temp && !s.isSpinny), [snapshot]);
35
+
36
+ return (
37
+ <View flexDirection="column" gap={1}>
38
+ <View flexDirection="column" gap={1} paddingBottom={1} width="95%">
39
+ {segments.map((seg) => (
40
+ <ExpandedSegment key={seg.id} segment={seg} />
41
+ ))}
42
+ </View>
43
+
44
+ {/* Footer */}
45
+ <View
46
+ borderStyle="single"
47
+ borderColor={colors.border}
48
+ paddingLeft={1}
49
+ paddingRight={1}
50
+ flexDirection="row"
51
+ gap={2}
52
+ >
53
+ <Text color={colors.textMuted}>expanded view</Text>
54
+ <Text dimColor>ctrl+o or esc to collapse</Text>
55
+ </View>
56
+ </View>
57
+ );
58
+ });
59
+ ExpandedView.displayName = "ExpandedView";
60
+
61
+ /**
62
+ * In expanded view:
63
+ * - thinking segments are always shown via ExpandedThinkingSegment
64
+ * - all other segments (including tool calls) render normally via Segment,
65
+ * which already includes full tool result output via ToolDef.renderUI
66
+ */
67
+ const ExpandedSegment = memo(({ segment }: { segment: HistorySegment }) => {
68
+ if (segment.type === "thinking") {
69
+ return <ExpandedThinkingSegment {...segment} />;
70
+ }
71
+
72
+ return <Segment segment={segment} />;
73
+ });
74
+ ExpandedSegment.displayName = "ExpandedSegment";
@@ -0,0 +1,127 @@
1
+ import { View, Text } from "@codellm/jar";
2
+ import * as path from "path";
3
+ import { memo } from "react";
4
+
5
+ export interface FileMatch {
6
+ resource: string;
7
+ }
8
+
9
+ export interface FileCompletionProps {
10
+ readonly suggestions: FileMatch[];
11
+ readonly selectedIndex: number;
12
+ readonly visible: boolean;
13
+ readonly maxHeight?: number;
14
+ }
15
+
16
+ const getFileType = (fileName: string): string => {
17
+ const ext = path.extname(fileName);
18
+ switch (ext) {
19
+ case ".ts":
20
+ case ".tsx":
21
+ return "ts";
22
+ case ".js":
23
+ case ".jsx":
24
+ return "js";
25
+ case ".json":
26
+ return "json";
27
+ case ".md":
28
+ return "md";
29
+ case ".css":
30
+ case ".scss":
31
+ return "css";
32
+ case ".html":
33
+ return "html";
34
+ case ".py":
35
+ return "py";
36
+ case ".rs":
37
+ return "rs";
38
+ case ".go":
39
+ return "go";
40
+ case ".yaml":
41
+ case ".yml":
42
+ return "yaml";
43
+ default:
44
+ return fileName.includes(".") ? "file" : "dir";
45
+ }
46
+ };
47
+
48
+ const FileCompletionComponent = ({
49
+ suggestions,
50
+ selectedIndex,
51
+ visible,
52
+ maxHeight = 8,
53
+ }: FileCompletionProps) => {
54
+ if (!visible || suggestions.length === 0) {
55
+ return null;
56
+ }
57
+
58
+ // Show only a window of results for performance
59
+ const startIndex = Math.max(0, selectedIndex - Math.floor(maxHeight / 2));
60
+ const endIndex = Math.min(suggestions.length, startIndex + maxHeight);
61
+ const visibleSuggestions = suggestions.slice(startIndex, endIndex);
62
+
63
+ return (
64
+ <View
65
+ flexDirection="column"
66
+ borderStyle="round"
67
+ borderColor="gray"
68
+ paddingX={1}
69
+ marginBottom={1}
70
+ >
71
+ <Text dimColor>
72
+ {suggestions.length} file{suggestions.length !== 1 ? "s" : ""}
73
+ </Text>
74
+
75
+ {visibleSuggestions.map((suggestion, index) => {
76
+ const actualIndex = startIndex + index;
77
+ const isSelected = actualIndex === selectedIndex;
78
+ const fileName = path.basename(suggestion.resource);
79
+ const fileType = getFileType(fileName);
80
+
81
+ // Smart path display - show relative to cwd
82
+ const relativePath = suggestion.resource.startsWith(process.cwd())
83
+ ? suggestion.resource.slice(process.cwd().length + 1).replace(/\\/g, "/")
84
+ : suggestion.resource.replace(/\\/g, "/");
85
+
86
+ const displayPath =
87
+ relativePath.length > 60 ? "..." + relativePath.slice(-57) : relativePath;
88
+
89
+ return (
90
+ <View key={suggestion.resource} flexDirection="row">
91
+ <Text color={isSelected ? "blue" : "gray"} bold={isSelected} dimColor={!isSelected}>
92
+ {isSelected ? ">" : " "}
93
+ </Text>
94
+ <Text color={isSelected ? "blue" : undefined} bold={isSelected}>
95
+ {" " + displayPath}
96
+ </Text>
97
+ <Text dimColor> [{fileType}]</Text>
98
+ </View>
99
+ );
100
+ })}
101
+
102
+ {suggestions.length > maxHeight && (
103
+ <Text dimColor>
104
+ {selectedIndex + 1}/{suggestions.length} • ↑↓ navigate • Tab select • Esc cancel
105
+ </Text>
106
+ )}
107
+ </View>
108
+ );
109
+ };
110
+
111
+ export const FileCompletion = memo(FileCompletionComponent);
112
+
113
+ export interface CompletionState {
114
+ suggestions: FileMatch[];
115
+ selectedIndex: number;
116
+ visible: boolean;
117
+ pattern: string;
118
+ startPosition: number;
119
+ }
120
+
121
+ export const initialCompletionState: CompletionState = {
122
+ suggestions: [],
123
+ selectedIndex: 0,
124
+ visible: false,
125
+ pattern: "",
126
+ startPosition: 0,
127
+ };
@@ -0,0 +1,47 @@
1
+ import { View, Text } from "@codellm/jar";
2
+ import { memo, useMemo } from "react";
3
+
4
+ import pkg from "@/package.json" with { type: "json" };
5
+
6
+ import { useShellSize } from "../context/shell-size.js";
7
+ import { useTheme } from "../theme/index.js";
8
+ import { Gradient } from "./ui/gradient.js";
9
+
10
+ export const RUBI = `\
11
+ ▗▄▖ ▗▄▄▖ ▗▄▖ ▗▄▄▖▗▖ ▗▖ ▗▄▄▖ ▗▄▖ ▗▄▄▄▖ ▗▄▄▖▗▖ ▗▄▄▄▖
12
+ ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌ ▐▌▐▌ ▐▌ ▐▌ █ ▐▌ ▐▌ █
13
+ ▐▛▀▜▌▐▛▀▚▖▐▛▀▜▌▐▌ ▐▌ ▐▌ ▝▀▚▖▐▛▀▜▌ █ ▐▌ ▐▌ █
14
+ ▐▌ ▐▌▐▙▄▞▘▐▌ ▐▌▝▚▄▄▖▝▚▄▞▘▗▄▄▞▘▐▌ ▐▌▗▄█▄▖ ▝▚▄▄▖▐▙▄▄▖▗▄█▄▖ `;
15
+
16
+ const NARROW_TERMINAL_WIDTH = 50;
17
+
18
+ export const Header = memo(() => {
19
+ const { width } = useShellSize();
20
+ const { colors } = useTheme();
21
+
22
+ const gradientColors = useMemo(
23
+ () => [colors.gradientStart, colors.gradientMid, colors.gradientEnd],
24
+ [colors],
25
+ );
26
+
27
+ if (width <= NARROW_TERMINAL_WIDTH) {
28
+ return (
29
+ <View flexDirection="row" gap={1} flexWrap="wrap">
30
+ <Gradient colors={gradientColors}>
31
+ <Text>Abacus AI</Text>
32
+ </Gradient>
33
+ <Text color={colors.textMuted}>v{pkg.version}</Text>
34
+ </View>
35
+ );
36
+ }
37
+
38
+ return (
39
+ <View flexDirection="column">
40
+ <Gradient colors={gradientColors}>
41
+ <Text>{RUBI}</Text>
42
+ </Gradient>
43
+ <Text color={colors.textMuted}>v{pkg.version}</Text>
44
+ </View>
45
+ );
46
+ });
47
+ Header.displayName = "Header";
@@ -0,0 +1,37 @@
1
+ type GradientColors = Array<string>;
2
+
3
+ export const COLLOSAL = `
4
+ d8888 888 d8888 8888888
5
+ d88888 888 d88888 888
6
+ d88P888 888 d88P888 888
7
+ d88P 888 88888b. 8888b. .d8888b 888 888 .d8888b d88P 888 888
8
+ d88P 888 888 "88b "88b d88P" 888 888 88K d88P 888 888
9
+ d88P 888 888 888 .d888888 888 888 888 "Y8888b. d88P 888 888
10
+ d8888888888 888 d88P 888 888 Y88b. Y88b 888 X88 d8b d8888888888 888
11
+ d88P 888 88888P" "Y888888 "Y8888P "Y88888 88888P' Y8P d88P 888 8888888
12
+ `;
13
+
14
+ export const ANSI_SHADOW = `
15
+ █████╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗ █████╗ ██╗ ██████╗██╗ ██╗
16
+ ██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║██╔════╝ ██╔══██╗██║ ██╔════╝██║ ██║
17
+ ███████║██████╔╝███████║██║ ██║ ██║███████╗ ███████║██║ ██║ ██║ ██║
18
+ ██╔══██║██╔══██╗██╔══██║██║ ██║ ██║╚════██║ ██╔══██║██║ ██║ ██║ ██║
19
+ ██║ ██║██████╔╝██║ ██║╚██████╗╚██████╔╝███████║██╗██║ ██║██║ ╚██████╗███████╗██║
20
+ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝╚══════╝╚═╝
21
+ `;
22
+
23
+ export const SMALL_BLOCK = `
24
+ ▞▀▖▌ ▞▀▖▜▘ ▞▀▖▌ ▜▘
25
+ ▙▄▌▛▀▖▝▀▖▞▀▖▌ ▌▞▀▘ ▙▄▌▐ ▌ ▌ ▐
26
+ ▌ ▌▌ ▌▞▀▌▌ ▖▌ ▌▝▀▖▗▖▌ ▌▐ ▌ ▖▌ ▐
27
+ ▘ ▘▀▀ ▝▀▘▝▀ ▝▀▘▀▀ ▝▘▘ ▘▀▘ ▝▀ ▀▀▘▀▘
28
+ `;
29
+
30
+ export const SMALL_BLOCK_2 = `
31
+ ▞▀▖▌ ▞▀▖▜▘
32
+ ▙▄▌▛▀▖▝▀▖▞▀▖▌ ▌▞▀▘ ▙▄▌▐
33
+ ▌ ▌▌ ▌▞▀▌▌ ▖▌ ▌▝▀▖▗▖▌ ▌▐
34
+ ▘ ▘▀▀ ▝▀▘▝▀ ▝▀▘▀▀ ▝▘▘ ▘▀▘
35
+ `;
36
+
37
+ export const GRADIENT: GradientColors = ["pink", "lightblue", "plum", "lightcyan", "lightgray"];