@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,162 +0,0 @@
1
- import { View, type ViewStyle } from "@codellm/jar";
2
-
3
- /**
4
- * Props for the Divider component.
5
- */
6
- interface DividerProps {
7
- /**
8
- * Width of the divider.
9
- *
10
- * @example
11
- * ```tsx
12
- * <Divider width={50} />
13
- *
14
- * // ──────────────────────────────────────────────────
15
- * ```
16
- * @default 'auto'
17
- */
18
- width?: "auto" | number;
19
-
20
- /**
21
- * Padding at the start and the end of the divider.
22
- *
23
- * @example
24
- * ```tsx
25
- * <Divider padding={2} />
26
- *
27
- * // ··─────────────────────────────··
28
- * ```
29
- * @default 0
30
- */
31
- padding?: number;
32
-
33
- /**
34
- * Char used as a divider.
35
- *
36
- * @example
37
- * ```tsx
38
- * <Divider dividerChar="=" />
39
- *
40
- * // =============================
41
- * ```
42
- *
43
- * @default '─'
44
- */
45
- dividerChar?: string;
46
-
47
- /**
48
- * Color of the divider's border. Matches the type of `borderColor` in the Ink `Box` component.
49
- * Accepts standard Ink color names or hex codes.
50
- *
51
- * @example
52
- * ```tsx
53
- * <Divider dividerColor="red" />
54
- * ```
55
- *
56
- * @default 'gray'
57
- */
58
- dividerColor?: ViewStyle["borderColor"];
59
-
60
- /**
61
- * Padding at the start and the end of the divider.
62
- *
63
- * @example
64
- * ```tsx
65
- * <Divider padding={2} />
66
- *
67
- * // ··─────────────────────────────··
68
- * ```
69
- * @default 0
70
- */
71
- childrenPadding?: number;
72
-
73
- /**
74
- * Additional props to be passed to the underlying Ink `Box` component.
75
- *
76
- * @example
77
- * ```tsx
78
- * <Divider boxProps={{ marginTop: 2 }} />
79
- *
80
- *
81
- * //
82
- * //
83
- * // ─────────────────────────────
84
- * ```
85
- */
86
- boxProps?: ViewStyle;
87
- }
88
-
89
- const BaseDivider: React.FC<DividerProps> = ({
90
- width = "auto",
91
- dividerChar,
92
- dividerColor = "gray",
93
- boxProps,
94
- }) => (
95
- <View
96
- width={width}
97
- // @ts-expect-error
98
- borderStyle={{
99
- bottom: dividerChar,
100
- }}
101
- borderColor={dividerColor}
102
- //
103
- flexGrow={1}
104
- //
105
- borderBottom={true}
106
- //
107
- borderTop={false}
108
- borderLeft={false}
109
- borderRight={false}
110
- //
111
- {...boxProps}
112
- />
113
- );
114
-
115
- /**
116
- * A horizontal divider component styled as a single border line.
117
- *
118
- * @example
119
- * ```tsx
120
- * import { render } from 'ink'
121
- * import Divider from 'ink-divider'
122
- *
123
- * render(<Divider title='Title' />)
124
- *
125
- * // ─────────── Title ───────────
126
- * ```
127
- *
128
- * @returns A styled divider.
129
- */
130
- export const Divider: React.FC<React.PropsWithChildren<DividerProps>> = ({
131
- width = "auto",
132
- padding = 0,
133
- dividerChar = "─",
134
- dividerColor = "gray",
135
- childrenPadding = 0,
136
- boxProps,
137
- children,
138
- }) => {
139
- const dividerLine = (
140
- <BaseDivider dividerChar={dividerChar} dividerColor={dividerColor} boxProps={boxProps} />
141
- );
142
-
143
- // If there is no title, return only the divider line
144
- if (!children) {
145
- return (
146
- <View paddingLeft={padding} paddingRight={padding}>
147
- {dividerLine}
148
- </View>
149
- );
150
- }
151
-
152
- // Otherwise, return the divider line with the title in the middle
153
- return (
154
- <View width={width} paddingLeft={padding} paddingRight={padding} gap={childrenPadding}>
155
- {dividerLine}
156
-
157
- <View>{children}</View>
158
-
159
- {dividerLine}
160
- </View>
161
- );
162
- };
@@ -1,56 +0,0 @@
1
- import { Text } from "@codellm/jar";
2
- import * as gradientString from "gradient-string";
3
- import { memo, useMemo } from "react";
4
- import stripAnsi from "strip-ansi";
5
-
6
- type GradientName =
7
- | "atlas"
8
- | "cristal"
9
- | "teen"
10
- | "mind"
11
- | "morning"
12
- | "vice"
13
- | "passion"
14
- | "fruit"
15
- | "instagram"
16
- | "retro"
17
- | "summer"
18
- | "pastel"
19
- | "rainbow";
20
-
21
- type GradientColors = Array<tinycolor.ColorInput>;
22
-
23
- type GradientProps = {
24
- readonly children: React.ReactNode;
25
- } & (
26
- | {
27
- /**
28
- * The name of a [built-in gradient](https://github.com/bokub/gradient-string#available-built-in-gradients).
29
- * Mutually exclusive with `colors`.
30
- */
31
- readonly name: GradientName;
32
- readonly colors?: never;
33
- }
34
- | {
35
- /**
36
- * [Colors to use to make the gradient.](https://github.com/bokub/gradient-string#initialize-a-gradient)
37
- * Mutually exclusive with `name`.
38
- */
39
- readonly colors: GradientColors;
40
- readonly name?: never;
41
- }
42
- );
43
-
44
- export const Gradient = memo((props: GradientProps) => {
45
- const gradient = useMemo(() => {
46
- if (props.name) {
47
- return gradientString[props.name];
48
- }
49
- return gradientString.default(...props.colors);
50
- }, [props.name, props.colors]);
51
-
52
- const applyGradient = (text: string) => gradient.multiline(stripAnsi(text));
53
-
54
- return <Text transform={applyGradient}>{props.children}</Text>;
55
- });
56
- Gradient.displayName = "Gradient";
@@ -1,228 +0,0 @@
1
- import { View, Text } from "@codellm/jar";
2
- import { type Key, useInput, useFocusState } from "@codellm/jar";
3
- import chalk from "chalk";
4
- import { memo, useCallback, useEffect, useMemo } from "react";
5
-
6
- import { TextBuffer, useTextBuffer } from "../../lib/text-buffer.js";
7
-
8
- export interface InputKeyDownEvent {
9
- input: string;
10
- key: Key;
11
- target: TextBuffer;
12
- preventDefault: () => void;
13
- }
14
-
15
- type GrammarRule = {
16
- regex: RegExp;
17
- color: string;
18
- };
19
-
20
- interface InputProps extends Omit<React.ComponentProps<typeof View>, "children" | "ref"> {
21
- ref?: React.RefObject<TextBuffer | null>;
22
- initialValue?: string;
23
- onKeyDown?: (e: InputKeyDownEvent) => void;
24
- onChange?: (value: string, buffer: TextBuffer) => void;
25
- onSubmit?: (value: string) => void;
26
- placeholder?: string;
27
- placeholderProps?: Omit<React.ComponentProps<typeof Text>, "children">;
28
- grammar?: ReadonlyArray<GrammarRule>;
29
- disabled?: boolean;
30
- width?: number;
31
- height?: number;
32
- }
33
-
34
- const HEX_COLOR_RE = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
35
-
36
- function colorizeWithChalk(text: string, color: string): string {
37
- if (!text) return text;
38
- if (HEX_COLOR_RE.test(color)) return chalk.hex(color)(text);
39
- const maybe = (chalk as unknown as Record<string, unknown>)[color];
40
- if (typeof maybe === "function") {
41
- const fn = maybe as (input: string) => string;
42
- return fn(text);
43
- }
44
- return text;
45
- }
46
-
47
- function ensureGlobalRegex(regex: RegExp): RegExp {
48
- const flags = regex.flags.includes("g") ? regex.flags : `${regex.flags}g`;
49
- return new RegExp(regex.source, flags);
50
- }
51
-
52
- function highlightTextWithGrammar(text: string, rules?: ReadonlyArray<GrammarRule>): string {
53
- if (!rules?.length || !text) return text;
54
-
55
- type Token = { text: string; styled: boolean };
56
- let tokens: Token[] = [{ text, styled: false }];
57
-
58
- for (const rule of rules) {
59
- const regex = ensureGlobalRegex(rule.regex);
60
- const nextTokens: Token[] = [];
61
-
62
- for (const token of tokens) {
63
- if (token.styled || !token.text) {
64
- nextTokens.push(token);
65
- continue;
66
- }
67
-
68
- let lastIndex = 0;
69
- let match: RegExpExecArray | null;
70
- while ((match = regex.exec(token.text)) !== null) {
71
- const start = match.index;
72
- const end = start + match[0].length;
73
-
74
- if (start > lastIndex) {
75
- nextTokens.push({ text: token.text.slice(lastIndex, start), styled: false });
76
- }
77
-
78
- const matched = token.text.slice(start, end);
79
- const colored = colorizeWithChalk(matched, rule.color);
80
- nextTokens.push({ text: colored, styled: true });
81
-
82
- if (end === lastIndex) {
83
- regex.lastIndex += 1;
84
- }
85
- lastIndex = end;
86
- }
87
-
88
- if (lastIndex < token.text.length) {
89
- nextTokens.push({ text: token.text.slice(lastIndex), styled: false });
90
- }
91
- }
92
-
93
- tokens = nextTokens;
94
- }
95
-
96
- return tokens.map((t) => t.text).join("");
97
- }
98
-
99
- export const Input = memo(
100
- ({
101
- initialValue,
102
- onChange,
103
- onSubmit,
104
- placeholder = "Type text...",
105
- ref,
106
- placeholderProps,
107
- onKeyDown,
108
- grammar,
109
- disabled,
110
- width = Number.MAX_SAFE_INTEGER,
111
- height = Number.MAX_SAFE_INTEGER,
112
- ...props
113
- }: InputProps) => {
114
- const { isFocused } = useFocusState();
115
-
116
- const buffer = useTextBuffer({
117
- initialText: initialValue,
118
- initialCursorOffset: 0,
119
- viewport: { width, height },
120
- onChange: (value) => onChange?.(value, buffer),
121
- });
122
-
123
- useEffect(() => {
124
- if (ref) {
125
- ref.current = buffer;
126
- }
127
- }, [buffer, ref]);
128
-
129
- const handleSubmit = useCallback(() => {
130
- const value = buffer.text;
131
- if (!value.trim()) return;
132
- onSubmit?.(value);
133
- buffer.setText("");
134
- }, [buffer, onSubmit]);
135
-
136
- const handleKeypress = useCallback(
137
- (input: string, key: Key) => {
138
- let prevented = false;
139
- onKeyDown?.({
140
- input,
141
- key,
142
- target: buffer,
143
- preventDefault: () => {
144
- prevented = true;
145
- },
146
- });
147
- if (prevented) return;
148
- if (disabled) return;
149
-
150
- if (!disabled && key.return && !key.ctrl && !key.meta && !key.shift) {
151
- // Check for backslash-enter pattern for newline
152
- const text = buffer.text;
153
- if (text.endsWith("\\")) {
154
- // Remove the backslash and insert a newline
155
- buffer.backspace();
156
- buffer.newline();
157
- return;
158
- }
159
- handleSubmit();
160
- return;
161
- }
162
-
163
- buffer.handleInput(input, key);
164
- },
165
- [buffer, handleSubmit, onKeyDown, disabled],
166
- );
167
-
168
- useInput(handleKeypress, { isActive: !disabled });
169
-
170
- const linesToRender = buffer.viewportVisualLines;
171
- const [cursorVisualRowAbsolute, cursorVisualColAbsolute] = buffer.visualCursor;
172
- const scrollVisualRow = buffer.visualScrollRow;
173
-
174
- const showCursor = isFocused;
175
- const applyGrammar = useMemo(
176
- () => (text: string) => highlightTextWithGrammar(text, grammar),
177
- [grammar],
178
- );
179
-
180
- if (!buffer.text && placeholder) {
181
- return (
182
- <View {...props}>
183
- {showCursor ? (
184
- <Text dimColor {...placeholderProps}>
185
- {chalk.inverse(placeholder.slice(0, 1))}
186
- {placeholder.slice(1)}
187
- </Text>
188
- ) : (
189
- <Text color="gray" {...placeholderProps}>
190
- {placeholder}
191
- </Text>
192
- )}
193
- </View>
194
- );
195
- }
196
-
197
- return (
198
- <View flexDirection="column" flexGrow={1} {...props}>
199
- {linesToRender.map((lineText, visualIdxInRenderedSet) => {
200
- const absoluteVisualIdx = scrollVisualRow + visualIdxInRenderedSet;
201
- const cursorVisualRow = cursorVisualRowAbsolute - scrollVisualRow;
202
- const isOnCursorLine = showCursor && visualIdxInRenderedSet === cursorVisualRow;
203
-
204
- if (!isOnCursorLine) {
205
- const content = grammar?.length ? applyGrammar(lineText) : lineText;
206
- return <Text key={`line-${absoluteVisualIdx}`}>{content || " "}</Text>;
207
- }
208
-
209
- const before = lineText.slice(0, cursorVisualColAbsolute);
210
- const cursorChar = lineText[cursorVisualColAbsolute] ?? " ";
211
- const after = lineText.slice(cursorVisualColAbsolute + 1);
212
- const beforeHighlighted = grammar?.length ? applyGrammar(before) : before;
213
- const afterHighlighted = grammar?.length ? applyGrammar(after) : after;
214
-
215
- return (
216
- <Text key={`line-${absoluteVisualIdx}`}>
217
- {beforeHighlighted}
218
- {chalk.inverse(cursorChar)}
219
- {afterHighlighted}
220
- </Text>
221
- );
222
- })}
223
- </View>
224
- );
225
- },
226
- );
227
-
228
- Input.displayName = "Input";
@@ -1,151 +0,0 @@
1
- import { View, Text, useInput } from "@codellm/jar";
2
- import { memo, useCallback, useEffect, useMemo, useState } from "react";
3
-
4
- interface SelectProps {
5
- items: string[];
6
- limit?: number;
7
- maxHeight?: number;
8
- initialIndex?: number;
9
- isActive?: boolean;
10
- showIndex?: boolean;
11
- showIndicators?: boolean;
12
- onHighlight?: (item: string, index: number) => void;
13
- onSubmit?: (item: string, index: number) => void;
14
- onTab?: (item: string, index: number) => void;
15
- onCancel?: () => void;
16
- }
17
-
18
- export const Select = memo(
19
- ({
20
- items,
21
- limit = 10,
22
- maxHeight,
23
- initialIndex = 0,
24
- isActive = true,
25
- showIndex = true,
26
- showIndicators = false,
27
- onHighlight,
28
- onSubmit,
29
- onTab,
30
- onCancel,
31
- }: SelectProps) => {
32
- const total = items.length;
33
- const clampedInitial = Math.max(0, Math.min(initialIndex, Math.max(0, total - 1)));
34
- const [selected, setSelected] = useState(clampedInitial);
35
- const [start, setStart] = useState(0);
36
-
37
- const effectiveLimit = useMemo(() => {
38
- if (maxHeight !== undefined && maxHeight > 0) {
39
- const indicatorRows = (showIndicators ? 2 : 0) + (showIndex ? 1 : 0);
40
- return Math.max(1, Math.min(limit, maxHeight - indicatorRows));
41
- }
42
- return limit;
43
- }, [maxHeight, limit, showIndicators, showIndex]);
44
-
45
- const visibleCount = Math.max(1, Math.min(effectiveLimit, total || effectiveLimit));
46
- const mid = Math.floor(visibleCount / 2);
47
-
48
- useEffect(() => {
49
- if (selected >= total) {
50
- setSelected(total === 0 ? 0 : total - 1);
51
- setStart(0);
52
- }
53
- }, [total, selected]);
54
-
55
- useEffect(() => {
56
- if (typeof onHighlight === "function" && total > 0) {
57
- onHighlight(items[selected], selected);
58
- }
59
- }, [selected, total, items, onHighlight]);
60
-
61
- const clampStart = useCallback(
62
- (s: number) => {
63
- const maxStart = Math.max(0, total - visibleCount);
64
- return Math.max(0, Math.min(s, maxStart));
65
- },
66
- [total, visibleCount],
67
- );
68
-
69
- const moveUp = useCallback(() => {
70
- if (total === 0) return;
71
- const nextSel = (selected - 1 + total) % total;
72
- setSelected(nextSel);
73
- if (nextSel < start + mid) setStart(clampStart(nextSel - mid));
74
- if (nextSel > start + visibleCount - 1) setStart(clampStart(nextSel - visibleCount + 1));
75
- }, [total, selected, start, mid, visibleCount, clampStart]);
76
-
77
- const moveDown = useCallback(() => {
78
- if (total === 0) return;
79
- const nextSel = (selected + 1) % total;
80
- setSelected(nextSel);
81
- if (nextSel > start + mid) setStart(clampStart(nextSel - mid));
82
- if (nextSel < start) setStart(clampStart(nextSel));
83
- }, [total, selected, start, mid, clampStart]);
84
-
85
- useInput(
86
- (_input, key) => {
87
- if (!isActive) return;
88
- if (key.upArrow) {
89
- moveUp();
90
- return;
91
- }
92
- if (key.downArrow) {
93
- moveDown();
94
- return;
95
- }
96
- if (key.escape) {
97
- onCancel?.();
98
- return;
99
- }
100
- if (key.tab && !key.ctrl && !key.meta && !key.shift) {
101
- if (total > 0) onTab?.(items[selected], selected);
102
- return;
103
- }
104
- if (key.return && !key.ctrl && !key.meta && !key.shift) {
105
- if (total > 0) onSubmit?.(items[selected], selected);
106
- else onCancel?.();
107
- }
108
- },
109
- { isActive },
110
- );
111
-
112
- const windowed = useMemo(() => {
113
- if (total === 0) return [] as string[];
114
- const end = Math.min(total, start + visibleCount);
115
- return items.slice(start, end);
116
- }, [items, total, start, visibleCount]);
117
-
118
- const hasSpaceForIndicators = maxHeight === undefined || maxHeight >= 3;
119
- const effectiveShowIndicators = showIndicators && hasSpaceForIndicators;
120
- const effectiveShowIndex = showIndex && hasSpaceForIndicators;
121
-
122
- return (
123
- <View flexDirection="column">
124
- {effectiveShowIndicators && total > 0 && start > 0 && (
125
- <Text dimColor>▲ {effectiveShowIndex && total > 1 && `(${selected + 1}/${total})`}</Text>
126
- )}
127
- {total === 0 ? (
128
- <Text dimColor>No matches</Text>
129
- ) : (
130
- windowed.map((label, idx) => {
131
- const absoluteIndex = start + idx;
132
- const isSelected = absoluteIndex === selected;
133
- return (
134
- <Text key={`${label}-${absoluteIndex}`} color={isSelected ? "cyanBright" : undefined}>
135
- {isSelected ? "> " : " "}
136
- {label}
137
- </Text>
138
- );
139
- })
140
- )}
141
- {effectiveShowIndicators && total > 0 && start + visibleCount < total && (
142
- <Text dimColor>▼ {effectiveShowIndex && total > 1 && `(${selected + 1}/${total})`}</Text>
143
- )}
144
- {!effectiveShowIndicators && effectiveShowIndex && total > 1 && (
145
- <Text dimColor>{`(${selected + 1}/${total})`}</Text>
146
- )}
147
- </View>
148
- );
149
- },
150
- );
151
- Select.displayName = "Select";
@@ -1,76 +0,0 @@
1
- import { Text } from "@codellm/jar";
2
- import chalk from "chalk";
3
- import { startTransition } from "react";
4
- import { memo, useEffect, useMemo, useState } from "react";
5
-
6
- interface ShimmerProps {
7
- text: string;
8
- color?: string;
9
- }
10
-
11
- const SHIMMER_INTERVAL = 100;
12
- const DIM_FACTOR = 0.25;
13
-
14
- export const Shimmer = memo(({ text, color = "#94a3b8" }: ShimmerProps) => {
15
- const [offset, setOffset] = useState(0);
16
- const textLength = text.length;
17
-
18
- useEffect(() => {
19
- const interval = setInterval(() => {
20
- // Lowest priority: animation re-renders must never delay input or streaming.
21
- startTransition(() => {
22
- setOffset((prev) => prev + 1);
23
- });
24
- }, SHIMMER_INTERVAL);
25
-
26
- return () => clearInterval(interval);
27
- }, []);
28
-
29
- const baseRgb = useMemo(() => parseHexColor(color), [color]);
30
-
31
- const coloredText = useMemo(() => {
32
- const peakPosition = offset % textLength;
33
- const gradientWidth = Math.max(textLength * 0.6, 3);
34
- let result = "";
35
- for (let i = 0; i < textLength; i++) {
36
- let distance = Math.abs(i - peakPosition);
37
- const wrapDistance = textLength - distance;
38
- const circularDistance = Math.min(distance, wrapDistance);
39
- const brightness = Math.max(0, 1 - circularDistance / gradientWidth);
40
- const rgb = interpolateRgb(baseRgb, brightness);
41
- result += chalk.rgb(rgb.r, rgb.g, rgb.b)(text[i]);
42
- }
43
- return result;
44
- }, [offset, textLength, baseRgb, text]);
45
-
46
- return <Text>{coloredText}</Text>;
47
- });
48
-
49
- Shimmer.displayName = "Shimmer";
50
-
51
- interface RGB {
52
- r: number;
53
- g: number;
54
- b: number;
55
- }
56
-
57
- function parseHexColor(hex: string): RGB {
58
- const cleanHex = hex.replace("#", "");
59
- return {
60
- r: parseInt(cleanHex.substring(0, 2), 16),
61
- g: parseInt(cleanHex.substring(2, 4), 16),
62
- b: parseInt(cleanHex.substring(4, 6), 16),
63
- };
64
- }
65
-
66
- function interpolateRgb(base: RGB, brightness: number): RGB {
67
- const minR = Math.floor(base.r * DIM_FACTOR);
68
- const minG = Math.floor(base.g * DIM_FACTOR);
69
- const minB = Math.floor(base.b * DIM_FACTOR);
70
-
71
- return {
72
- r: Math.floor(minR + (base.r - minR) * brightness),
73
- g: Math.floor(minG + (base.g - minG) * brightness),
74
- b: Math.floor(minB + (base.b - minB) * brightness),
75
- };
76
- }