@claude-code-kit/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +284 -0
- package/dist/index.d.ts +284 -0
- package/dist/index.js +2419 -0
- package/dist/index.mjs +2364 -0
- package/package.json +68 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Color } from '@claude-code-kit/ink-renderer';
|
|
2
|
+
export * from '@claude-code-kit/ink-renderer';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
type DividerProps = {
|
|
7
|
+
width?: number;
|
|
8
|
+
color?: Color;
|
|
9
|
+
char?: string;
|
|
10
|
+
padding?: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
};
|
|
13
|
+
declare function Divider({ width, color, char, padding, title }: DividerProps): React.ReactNode;
|
|
14
|
+
|
|
15
|
+
type Props$2 = {
|
|
16
|
+
ratio: number;
|
|
17
|
+
width: number;
|
|
18
|
+
fillColor?: Color;
|
|
19
|
+
emptyColor?: Color;
|
|
20
|
+
};
|
|
21
|
+
declare function ProgressBar({ ratio: inputRatio, width, fillColor, emptyColor }: Props$2): React.ReactNode;
|
|
22
|
+
|
|
23
|
+
type Status = 'success' | 'error' | 'warning' | 'info' | 'pending' | 'loading';
|
|
24
|
+
type Props$1 = {
|
|
25
|
+
status: Status;
|
|
26
|
+
withSpace?: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare function StatusIcon({ status, withSpace }: Props$1): React.ReactNode;
|
|
29
|
+
|
|
30
|
+
type StatusLineSegment = {
|
|
31
|
+
content: string;
|
|
32
|
+
color?: Color;
|
|
33
|
+
flex?: boolean;
|
|
34
|
+
};
|
|
35
|
+
type StatusLineProps = {
|
|
36
|
+
segments?: StatusLineSegment[];
|
|
37
|
+
text?: string;
|
|
38
|
+
paddingX?: number;
|
|
39
|
+
gap?: number;
|
|
40
|
+
borderStyle?: 'none' | 'single' | 'round';
|
|
41
|
+
borderColor?: Color;
|
|
42
|
+
};
|
|
43
|
+
declare function StatusLine({ segments, text, paddingX, gap, borderStyle, borderColor, }: StatusLineProps): React.ReactNode;
|
|
44
|
+
declare function useStatusLine(updater: () => StatusLineSegment[] | string, deps: unknown[], intervalMs?: number): StatusLineSegment[] | string;
|
|
45
|
+
|
|
46
|
+
type CommandResult = {
|
|
47
|
+
type: 'text';
|
|
48
|
+
value: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'skip';
|
|
51
|
+
};
|
|
52
|
+
type CommandOnDone = (result?: string) => void;
|
|
53
|
+
type CommandBase = {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
aliases?: string[];
|
|
57
|
+
isHidden?: boolean;
|
|
58
|
+
isEnabled?: () => boolean;
|
|
59
|
+
argumentHint?: string;
|
|
60
|
+
};
|
|
61
|
+
type LocalCommand = CommandBase & {
|
|
62
|
+
type: 'local';
|
|
63
|
+
execute: (args: string) => Promise<CommandResult> | CommandResult;
|
|
64
|
+
};
|
|
65
|
+
type JSXCommand = CommandBase & {
|
|
66
|
+
type: 'jsx';
|
|
67
|
+
render: (onDone: CommandOnDone, args: string) => React.ReactNode;
|
|
68
|
+
};
|
|
69
|
+
type Command$1 = LocalCommand | JSXCommand;
|
|
70
|
+
|
|
71
|
+
declare class CommandRegistry {
|
|
72
|
+
private commands;
|
|
73
|
+
register(...commands: Command$1[]): void;
|
|
74
|
+
get(name: string): Command$1 | undefined;
|
|
75
|
+
getAll(): Command$1[];
|
|
76
|
+
getVisible(): Command$1[];
|
|
77
|
+
parse(input: string): {
|
|
78
|
+
command: Command$1;
|
|
79
|
+
args: string;
|
|
80
|
+
} | null;
|
|
81
|
+
getSuggestions(partial: string): Command$1[];
|
|
82
|
+
}
|
|
83
|
+
declare function createCommandRegistry(commands: Command$1[]): CommandRegistry;
|
|
84
|
+
|
|
85
|
+
declare function defineCommand(cmd: Command$1): Command$1;
|
|
86
|
+
declare function defineLocalCommand(cmd: Omit<LocalCommand, 'type'>): LocalCommand;
|
|
87
|
+
declare function defineJSXCommand(cmd: Omit<JSXCommand, 'type'>): JSXCommand;
|
|
88
|
+
|
|
89
|
+
declare const exitCommand: Command$1;
|
|
90
|
+
declare const helpCommand: (registry: {
|
|
91
|
+
getVisible: () => Command$1[];
|
|
92
|
+
}) => Command$1;
|
|
93
|
+
declare const clearCommand: Command$1;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Zod schema for keybindings.json configuration.
|
|
97
|
+
* Used for validation and JSON schema generation.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Valid context names where keybindings can be applied.
|
|
102
|
+
*/
|
|
103
|
+
declare const KEYBINDING_CONTEXTS: readonly ["Global", "Chat", "Autocomplete", "Confirmation", "Help", "Transcript", "HistorySearch", "Task", "ThemePicker", "Settings", "Tabs", "Attachments", "Footer", "MessageSelector", "DiffDialog", "ModelPicker", "Select", "Plugin", "Scroll"];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Core types for the keybinding system.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
type KeybindingContextName = (typeof KEYBINDING_CONTEXTS)[number];
|
|
110
|
+
type KeybindingBlock = {
|
|
111
|
+
context: KeybindingContextName;
|
|
112
|
+
bindings: Record<string, string | null>;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
type Options = {
|
|
116
|
+
/** Which context this binding belongs to (default: 'Global') */
|
|
117
|
+
context?: KeybindingContextName;
|
|
118
|
+
/** Only handle when active (like useInput's isActive) */
|
|
119
|
+
isActive?: boolean;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Ink-native hook for handling a keybinding.
|
|
123
|
+
*
|
|
124
|
+
* The handler stays in the component (React way).
|
|
125
|
+
* The binding (keystroke → action) comes from config.
|
|
126
|
+
*
|
|
127
|
+
* Supports chord sequences (e.g., "ctrl+k ctrl+s"). When a chord is started,
|
|
128
|
+
* the hook will manage the pending state automatically.
|
|
129
|
+
*
|
|
130
|
+
* Uses stopImmediatePropagation() to prevent other handlers from firing
|
|
131
|
+
* once this binding is handled.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* useKeybinding('app:toggleTodos', () => {
|
|
136
|
+
* setShowTodos(prev => !prev)
|
|
137
|
+
* }, { context: 'Global' })
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function useKeybinding(action: string, handler: () => void | false | Promise<void>, options?: Options): void;
|
|
141
|
+
/**
|
|
142
|
+
* Handle multiple keybindings in one hook (reduces useInput calls).
|
|
143
|
+
*
|
|
144
|
+
* Supports chord sequences. When a chord is started, the hook will
|
|
145
|
+
* manage the pending state automatically.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```tsx
|
|
149
|
+
* useKeybindings({
|
|
150
|
+
* 'chat:submit': () => handleSubmit(),
|
|
151
|
+
* 'chat:cancel': () => handleCancel(),
|
|
152
|
+
* }, { context: 'Chat' })
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function useKeybindings(handlers: Record<string, () => void | false | Promise<void>>, options?: Options): void;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Setup utilities for integrating KeybindingProvider into the app.
|
|
159
|
+
*
|
|
160
|
+
* Loads both default bindings and user-defined bindings from
|
|
161
|
+
* ~/.claude/keybindings.json, with hot-reload support when the file changes.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
type Props = {
|
|
165
|
+
children: React.ReactNode;
|
|
166
|
+
/** Optional callback invoked when keybinding warnings are present */
|
|
167
|
+
onWarnings?: (message: string, isError: boolean) => void;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Keybinding provider with default + user bindings and hot-reload support.
|
|
171
|
+
*
|
|
172
|
+
* Usage: Wrap your app with this provider to enable keybinding support.
|
|
173
|
+
*
|
|
174
|
+
* ```tsx
|
|
175
|
+
* <KeybindingSetup>
|
|
176
|
+
* <App ... />
|
|
177
|
+
* </KeybindingSetup>
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* Features:
|
|
181
|
+
* - Loads default bindings from code
|
|
182
|
+
* - Merges with user bindings from ~/.claude/keybindings.json
|
|
183
|
+
* - Watches for file changes and reloads automatically (hot-reload)
|
|
184
|
+
* - User bindings override defaults (later entries win)
|
|
185
|
+
* - Chord support with automatic timeout
|
|
186
|
+
*/
|
|
187
|
+
declare function KeybindingSetup({ children, onWarnings }: Props): React.ReactNode;
|
|
188
|
+
|
|
189
|
+
declare const DEFAULT_BINDINGS: KeybindingBlock[];
|
|
190
|
+
|
|
191
|
+
type Command = {
|
|
192
|
+
name: string;
|
|
193
|
+
description: string;
|
|
194
|
+
};
|
|
195
|
+
type PromptInputProps = {
|
|
196
|
+
value: string;
|
|
197
|
+
onChange: (value: string) => void;
|
|
198
|
+
onSubmit: (value: string) => void;
|
|
199
|
+
placeholder?: string;
|
|
200
|
+
prefix?: string;
|
|
201
|
+
prefixColor?: string;
|
|
202
|
+
disabled?: boolean;
|
|
203
|
+
commands?: Command[];
|
|
204
|
+
onCommandSelect?: (name: string) => void;
|
|
205
|
+
history?: string[];
|
|
206
|
+
};
|
|
207
|
+
declare function PromptInput({ value, onChange, onSubmit, placeholder, prefix, prefixColor, disabled, commands, onCommandSelect, history, }: PromptInputProps): React.ReactNode;
|
|
208
|
+
|
|
209
|
+
type SpinnerProps = {
|
|
210
|
+
label?: string;
|
|
211
|
+
verb?: string;
|
|
212
|
+
verbs?: string[];
|
|
213
|
+
color?: string;
|
|
214
|
+
showElapsed?: boolean;
|
|
215
|
+
};
|
|
216
|
+
declare function Spinner({ label, verb, verbs, color, showElapsed, }: SpinnerProps): React.ReactNode;
|
|
217
|
+
|
|
218
|
+
type SelectOption<T = string> = {
|
|
219
|
+
value: T;
|
|
220
|
+
label: string;
|
|
221
|
+
description?: string;
|
|
222
|
+
disabled?: boolean;
|
|
223
|
+
};
|
|
224
|
+
type SelectProps<T = string> = {
|
|
225
|
+
options: SelectOption<T>[];
|
|
226
|
+
defaultValue?: T;
|
|
227
|
+
onChange: (value: T) => void;
|
|
228
|
+
onCancel?: () => void;
|
|
229
|
+
title?: string;
|
|
230
|
+
maxVisible?: number;
|
|
231
|
+
};
|
|
232
|
+
type MultiSelectProps<T = string> = Omit<SelectProps<T>, 'onChange'> & {
|
|
233
|
+
selectedValues?: T[];
|
|
234
|
+
onToggle: (value: T) => void;
|
|
235
|
+
onConfirm: (values: T[]) => void;
|
|
236
|
+
};
|
|
237
|
+
declare function Select<T = string>({ options, defaultValue, onChange, onCancel, title, maxVisible, }: SelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
238
|
+
declare function MultiSelect<T = string>({ options, selectedValues, onToggle, onConfirm, onCancel, title, maxVisible, }: MultiSelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
239
|
+
|
|
240
|
+
type Message = {
|
|
241
|
+
id: string;
|
|
242
|
+
role: 'user' | 'assistant' | 'system';
|
|
243
|
+
content: string;
|
|
244
|
+
timestamp?: number;
|
|
245
|
+
};
|
|
246
|
+
type MessageListProps = {
|
|
247
|
+
messages: Message[];
|
|
248
|
+
streamingContent?: string | null;
|
|
249
|
+
renderMessage?: (message: Message) => React.ReactNode;
|
|
250
|
+
};
|
|
251
|
+
declare function MessageList({ messages, streamingContent, renderMessage, }: MessageListProps): React.ReactNode;
|
|
252
|
+
|
|
253
|
+
type StreamingTextProps = {
|
|
254
|
+
text: string;
|
|
255
|
+
speed?: number;
|
|
256
|
+
interval?: number;
|
|
257
|
+
onComplete?: () => void;
|
|
258
|
+
color?: string;
|
|
259
|
+
};
|
|
260
|
+
declare function StreamingText({ text, speed, interval, onComplete, color, }: StreamingTextProps): React.ReactNode;
|
|
261
|
+
|
|
262
|
+
type REPLCommand = {
|
|
263
|
+
name: string;
|
|
264
|
+
description: string;
|
|
265
|
+
onExecute: (args: string) => void;
|
|
266
|
+
};
|
|
267
|
+
type REPLProps = {
|
|
268
|
+
onSubmit: (message: string) => Promise<void> | void;
|
|
269
|
+
onExit?: () => void;
|
|
270
|
+
messages: Message[];
|
|
271
|
+
isLoading?: boolean;
|
|
272
|
+
streamingContent?: string | null;
|
|
273
|
+
commands?: REPLCommand[];
|
|
274
|
+
model?: string;
|
|
275
|
+
statusSegments?: StatusLineSegment[];
|
|
276
|
+
prefix?: string;
|
|
277
|
+
placeholder?: string;
|
|
278
|
+
history?: string[];
|
|
279
|
+
renderMessage?: (message: Message) => React.ReactNode;
|
|
280
|
+
spinner?: React.ReactNode;
|
|
281
|
+
};
|
|
282
|
+
declare function REPL({ onSubmit, onExit, messages, isLoading, streamingContent, commands, model, statusSegments, prefix, placeholder, history: externalHistory, renderMessage, spinner, }: REPLProps): React.ReactNode;
|
|
283
|
+
|
|
284
|
+
export { type Command$1 as Command, type CommandBase, type CommandOnDone, CommandRegistry, type CommandResult, DEFAULT_BINDINGS, Divider, type JSXCommand, KeybindingSetup, type LocalCommand, type Message, MessageList, type MessageListProps, MultiSelect, type MultiSelectProps, ProgressBar, PromptInput, REPL, type REPLProps, Select, type SelectOption, type SelectProps, Spinner, StatusIcon, StatusLine, type StatusLineProps, type StatusLineSegment, StreamingText, type StreamingTextProps, clearCommand, createCommandRegistry, defineCommand, defineJSXCommand, defineLocalCommand, exitCommand, helpCommand, useKeybinding, useKeybindings, useStatusLine };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Color } from '@claude-code-kit/ink-renderer';
|
|
2
|
+
export * from '@claude-code-kit/ink-renderer';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
type DividerProps = {
|
|
7
|
+
width?: number;
|
|
8
|
+
color?: Color;
|
|
9
|
+
char?: string;
|
|
10
|
+
padding?: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
};
|
|
13
|
+
declare function Divider({ width, color, char, padding, title }: DividerProps): React.ReactNode;
|
|
14
|
+
|
|
15
|
+
type Props$2 = {
|
|
16
|
+
ratio: number;
|
|
17
|
+
width: number;
|
|
18
|
+
fillColor?: Color;
|
|
19
|
+
emptyColor?: Color;
|
|
20
|
+
};
|
|
21
|
+
declare function ProgressBar({ ratio: inputRatio, width, fillColor, emptyColor }: Props$2): React.ReactNode;
|
|
22
|
+
|
|
23
|
+
type Status = 'success' | 'error' | 'warning' | 'info' | 'pending' | 'loading';
|
|
24
|
+
type Props$1 = {
|
|
25
|
+
status: Status;
|
|
26
|
+
withSpace?: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare function StatusIcon({ status, withSpace }: Props$1): React.ReactNode;
|
|
29
|
+
|
|
30
|
+
type StatusLineSegment = {
|
|
31
|
+
content: string;
|
|
32
|
+
color?: Color;
|
|
33
|
+
flex?: boolean;
|
|
34
|
+
};
|
|
35
|
+
type StatusLineProps = {
|
|
36
|
+
segments?: StatusLineSegment[];
|
|
37
|
+
text?: string;
|
|
38
|
+
paddingX?: number;
|
|
39
|
+
gap?: number;
|
|
40
|
+
borderStyle?: 'none' | 'single' | 'round';
|
|
41
|
+
borderColor?: Color;
|
|
42
|
+
};
|
|
43
|
+
declare function StatusLine({ segments, text, paddingX, gap, borderStyle, borderColor, }: StatusLineProps): React.ReactNode;
|
|
44
|
+
declare function useStatusLine(updater: () => StatusLineSegment[] | string, deps: unknown[], intervalMs?: number): StatusLineSegment[] | string;
|
|
45
|
+
|
|
46
|
+
type CommandResult = {
|
|
47
|
+
type: 'text';
|
|
48
|
+
value: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'skip';
|
|
51
|
+
};
|
|
52
|
+
type CommandOnDone = (result?: string) => void;
|
|
53
|
+
type CommandBase = {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
aliases?: string[];
|
|
57
|
+
isHidden?: boolean;
|
|
58
|
+
isEnabled?: () => boolean;
|
|
59
|
+
argumentHint?: string;
|
|
60
|
+
};
|
|
61
|
+
type LocalCommand = CommandBase & {
|
|
62
|
+
type: 'local';
|
|
63
|
+
execute: (args: string) => Promise<CommandResult> | CommandResult;
|
|
64
|
+
};
|
|
65
|
+
type JSXCommand = CommandBase & {
|
|
66
|
+
type: 'jsx';
|
|
67
|
+
render: (onDone: CommandOnDone, args: string) => React.ReactNode;
|
|
68
|
+
};
|
|
69
|
+
type Command$1 = LocalCommand | JSXCommand;
|
|
70
|
+
|
|
71
|
+
declare class CommandRegistry {
|
|
72
|
+
private commands;
|
|
73
|
+
register(...commands: Command$1[]): void;
|
|
74
|
+
get(name: string): Command$1 | undefined;
|
|
75
|
+
getAll(): Command$1[];
|
|
76
|
+
getVisible(): Command$1[];
|
|
77
|
+
parse(input: string): {
|
|
78
|
+
command: Command$1;
|
|
79
|
+
args: string;
|
|
80
|
+
} | null;
|
|
81
|
+
getSuggestions(partial: string): Command$1[];
|
|
82
|
+
}
|
|
83
|
+
declare function createCommandRegistry(commands: Command$1[]): CommandRegistry;
|
|
84
|
+
|
|
85
|
+
declare function defineCommand(cmd: Command$1): Command$1;
|
|
86
|
+
declare function defineLocalCommand(cmd: Omit<LocalCommand, 'type'>): LocalCommand;
|
|
87
|
+
declare function defineJSXCommand(cmd: Omit<JSXCommand, 'type'>): JSXCommand;
|
|
88
|
+
|
|
89
|
+
declare const exitCommand: Command$1;
|
|
90
|
+
declare const helpCommand: (registry: {
|
|
91
|
+
getVisible: () => Command$1[];
|
|
92
|
+
}) => Command$1;
|
|
93
|
+
declare const clearCommand: Command$1;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Zod schema for keybindings.json configuration.
|
|
97
|
+
* Used for validation and JSON schema generation.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Valid context names where keybindings can be applied.
|
|
102
|
+
*/
|
|
103
|
+
declare const KEYBINDING_CONTEXTS: readonly ["Global", "Chat", "Autocomplete", "Confirmation", "Help", "Transcript", "HistorySearch", "Task", "ThemePicker", "Settings", "Tabs", "Attachments", "Footer", "MessageSelector", "DiffDialog", "ModelPicker", "Select", "Plugin", "Scroll"];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Core types for the keybinding system.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
type KeybindingContextName = (typeof KEYBINDING_CONTEXTS)[number];
|
|
110
|
+
type KeybindingBlock = {
|
|
111
|
+
context: KeybindingContextName;
|
|
112
|
+
bindings: Record<string, string | null>;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
type Options = {
|
|
116
|
+
/** Which context this binding belongs to (default: 'Global') */
|
|
117
|
+
context?: KeybindingContextName;
|
|
118
|
+
/** Only handle when active (like useInput's isActive) */
|
|
119
|
+
isActive?: boolean;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Ink-native hook for handling a keybinding.
|
|
123
|
+
*
|
|
124
|
+
* The handler stays in the component (React way).
|
|
125
|
+
* The binding (keystroke → action) comes from config.
|
|
126
|
+
*
|
|
127
|
+
* Supports chord sequences (e.g., "ctrl+k ctrl+s"). When a chord is started,
|
|
128
|
+
* the hook will manage the pending state automatically.
|
|
129
|
+
*
|
|
130
|
+
* Uses stopImmediatePropagation() to prevent other handlers from firing
|
|
131
|
+
* once this binding is handled.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* useKeybinding('app:toggleTodos', () => {
|
|
136
|
+
* setShowTodos(prev => !prev)
|
|
137
|
+
* }, { context: 'Global' })
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function useKeybinding(action: string, handler: () => void | false | Promise<void>, options?: Options): void;
|
|
141
|
+
/**
|
|
142
|
+
* Handle multiple keybindings in one hook (reduces useInput calls).
|
|
143
|
+
*
|
|
144
|
+
* Supports chord sequences. When a chord is started, the hook will
|
|
145
|
+
* manage the pending state automatically.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```tsx
|
|
149
|
+
* useKeybindings({
|
|
150
|
+
* 'chat:submit': () => handleSubmit(),
|
|
151
|
+
* 'chat:cancel': () => handleCancel(),
|
|
152
|
+
* }, { context: 'Chat' })
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function useKeybindings(handlers: Record<string, () => void | false | Promise<void>>, options?: Options): void;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Setup utilities for integrating KeybindingProvider into the app.
|
|
159
|
+
*
|
|
160
|
+
* Loads both default bindings and user-defined bindings from
|
|
161
|
+
* ~/.claude/keybindings.json, with hot-reload support when the file changes.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
type Props = {
|
|
165
|
+
children: React.ReactNode;
|
|
166
|
+
/** Optional callback invoked when keybinding warnings are present */
|
|
167
|
+
onWarnings?: (message: string, isError: boolean) => void;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Keybinding provider with default + user bindings and hot-reload support.
|
|
171
|
+
*
|
|
172
|
+
* Usage: Wrap your app with this provider to enable keybinding support.
|
|
173
|
+
*
|
|
174
|
+
* ```tsx
|
|
175
|
+
* <KeybindingSetup>
|
|
176
|
+
* <App ... />
|
|
177
|
+
* </KeybindingSetup>
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* Features:
|
|
181
|
+
* - Loads default bindings from code
|
|
182
|
+
* - Merges with user bindings from ~/.claude/keybindings.json
|
|
183
|
+
* - Watches for file changes and reloads automatically (hot-reload)
|
|
184
|
+
* - User bindings override defaults (later entries win)
|
|
185
|
+
* - Chord support with automatic timeout
|
|
186
|
+
*/
|
|
187
|
+
declare function KeybindingSetup({ children, onWarnings }: Props): React.ReactNode;
|
|
188
|
+
|
|
189
|
+
declare const DEFAULT_BINDINGS: KeybindingBlock[];
|
|
190
|
+
|
|
191
|
+
type Command = {
|
|
192
|
+
name: string;
|
|
193
|
+
description: string;
|
|
194
|
+
};
|
|
195
|
+
type PromptInputProps = {
|
|
196
|
+
value: string;
|
|
197
|
+
onChange: (value: string) => void;
|
|
198
|
+
onSubmit: (value: string) => void;
|
|
199
|
+
placeholder?: string;
|
|
200
|
+
prefix?: string;
|
|
201
|
+
prefixColor?: string;
|
|
202
|
+
disabled?: boolean;
|
|
203
|
+
commands?: Command[];
|
|
204
|
+
onCommandSelect?: (name: string) => void;
|
|
205
|
+
history?: string[];
|
|
206
|
+
};
|
|
207
|
+
declare function PromptInput({ value, onChange, onSubmit, placeholder, prefix, prefixColor, disabled, commands, onCommandSelect, history, }: PromptInputProps): React.ReactNode;
|
|
208
|
+
|
|
209
|
+
type SpinnerProps = {
|
|
210
|
+
label?: string;
|
|
211
|
+
verb?: string;
|
|
212
|
+
verbs?: string[];
|
|
213
|
+
color?: string;
|
|
214
|
+
showElapsed?: boolean;
|
|
215
|
+
};
|
|
216
|
+
declare function Spinner({ label, verb, verbs, color, showElapsed, }: SpinnerProps): React.ReactNode;
|
|
217
|
+
|
|
218
|
+
type SelectOption<T = string> = {
|
|
219
|
+
value: T;
|
|
220
|
+
label: string;
|
|
221
|
+
description?: string;
|
|
222
|
+
disabled?: boolean;
|
|
223
|
+
};
|
|
224
|
+
type SelectProps<T = string> = {
|
|
225
|
+
options: SelectOption<T>[];
|
|
226
|
+
defaultValue?: T;
|
|
227
|
+
onChange: (value: T) => void;
|
|
228
|
+
onCancel?: () => void;
|
|
229
|
+
title?: string;
|
|
230
|
+
maxVisible?: number;
|
|
231
|
+
};
|
|
232
|
+
type MultiSelectProps<T = string> = Omit<SelectProps<T>, 'onChange'> & {
|
|
233
|
+
selectedValues?: T[];
|
|
234
|
+
onToggle: (value: T) => void;
|
|
235
|
+
onConfirm: (values: T[]) => void;
|
|
236
|
+
};
|
|
237
|
+
declare function Select<T = string>({ options, defaultValue, onChange, onCancel, title, maxVisible, }: SelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
238
|
+
declare function MultiSelect<T = string>({ options, selectedValues, onToggle, onConfirm, onCancel, title, maxVisible, }: MultiSelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
239
|
+
|
|
240
|
+
type Message = {
|
|
241
|
+
id: string;
|
|
242
|
+
role: 'user' | 'assistant' | 'system';
|
|
243
|
+
content: string;
|
|
244
|
+
timestamp?: number;
|
|
245
|
+
};
|
|
246
|
+
type MessageListProps = {
|
|
247
|
+
messages: Message[];
|
|
248
|
+
streamingContent?: string | null;
|
|
249
|
+
renderMessage?: (message: Message) => React.ReactNode;
|
|
250
|
+
};
|
|
251
|
+
declare function MessageList({ messages, streamingContent, renderMessage, }: MessageListProps): React.ReactNode;
|
|
252
|
+
|
|
253
|
+
type StreamingTextProps = {
|
|
254
|
+
text: string;
|
|
255
|
+
speed?: number;
|
|
256
|
+
interval?: number;
|
|
257
|
+
onComplete?: () => void;
|
|
258
|
+
color?: string;
|
|
259
|
+
};
|
|
260
|
+
declare function StreamingText({ text, speed, interval, onComplete, color, }: StreamingTextProps): React.ReactNode;
|
|
261
|
+
|
|
262
|
+
type REPLCommand = {
|
|
263
|
+
name: string;
|
|
264
|
+
description: string;
|
|
265
|
+
onExecute: (args: string) => void;
|
|
266
|
+
};
|
|
267
|
+
type REPLProps = {
|
|
268
|
+
onSubmit: (message: string) => Promise<void> | void;
|
|
269
|
+
onExit?: () => void;
|
|
270
|
+
messages: Message[];
|
|
271
|
+
isLoading?: boolean;
|
|
272
|
+
streamingContent?: string | null;
|
|
273
|
+
commands?: REPLCommand[];
|
|
274
|
+
model?: string;
|
|
275
|
+
statusSegments?: StatusLineSegment[];
|
|
276
|
+
prefix?: string;
|
|
277
|
+
placeholder?: string;
|
|
278
|
+
history?: string[];
|
|
279
|
+
renderMessage?: (message: Message) => React.ReactNode;
|
|
280
|
+
spinner?: React.ReactNode;
|
|
281
|
+
};
|
|
282
|
+
declare function REPL({ onSubmit, onExit, messages, isLoading, streamingContent, commands, model, statusSegments, prefix, placeholder, history: externalHistory, renderMessage, spinner, }: REPLProps): React.ReactNode;
|
|
283
|
+
|
|
284
|
+
export { type Command$1 as Command, type CommandBase, type CommandOnDone, CommandRegistry, type CommandResult, DEFAULT_BINDINGS, Divider, type JSXCommand, KeybindingSetup, type LocalCommand, type Message, MessageList, type MessageListProps, MultiSelect, type MultiSelectProps, ProgressBar, PromptInput, REPL, type REPLProps, Select, type SelectOption, type SelectProps, Spinner, StatusIcon, StatusLine, type StatusLineProps, type StatusLineSegment, StreamingText, type StreamingTextProps, clearCommand, createCommandRegistry, defineCommand, defineJSXCommand, defineLocalCommand, exitCommand, helpCommand, useKeybinding, useKeybindings, useStatusLine };
|