@ywldan/kiro 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/ui/App.js +44 -15
- package/dist/ui/Input.js +9 -12
- package/dist/ui/MessageList.js +50 -3
- package/dist/ui/ModelPicker.js +36 -7
- package/dist/ui/StatusBar.js +10 -5
- package/dist/ui/model-picker.js +10 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -280,17 +280,19 @@ Exit codes: `0` success, `1` model/tool/session error, `2` usage error (includin
|
|
|
280
280
|
| `Ctrl+W` | Delete the previous word |
|
|
281
281
|
| Left / Right / Home / End | Move the cursor |
|
|
282
282
|
|
|
283
|
-
The status bar shows the active profile and model, the working directory, the context meter (`ctx 42k/128k`), the number of queued messages, and the current state (`ready`, `thinking…`, `
|
|
283
|
+
The status bar shows the active profile and model, the working directory, the context meter (`ctx 42k/128k`), the number of queued messages, and the current state (`ready`, `thinking…`, `replying…`, `running <tool>…`, `approval needed`, `cancelling…`) with a spinner and the elapsed seconds for the current turn (`replying… · 12s`). A long profile name is shortened in the middle, so the model and directory stay readable.
|
|
284
284
|
|
|
285
285
|
The input stays enabled while the agent works: type the next prompt and press Enter to queue it, and it runs as soon as the current turn ends. Queued prompts appear in the transcript right away, the status bar shows `N queued`, and Ctrl+C clears the queue together with the running turn. Slash commands typed while busy are queued the same way.
|
|
286
286
|
|
|
287
287
|
Prompt history is stored per working directory in `~/.kiro/history/` (mode `0600`, up to 200 entries). With an empty input, `↑` recalls the most recent prompt, `↓` walks forward again, and editing the recalled text leaves history mode. Registered API-key values are redacted before a prompt is written. Set `KIRO_HISTORY_DIR` to store the files elsewhere.
|
|
288
288
|
|
|
289
|
-
Reasoning models stream their thinking traces live as a dim `thinking…` block. Once the visible answer starts, the trace collapses to a single `reasoning (done, not saved)` line: traces are display-only and are never written to sessions or `/export`.
|
|
289
|
+
Reasoning models stream their thinking traces live as a dim `thinking…` block. Once the visible answer starts, the trace collapses to a single `reasoning (done, not saved)` line: traces are display-only and are never written to sessions or `/export`. While the model is producing text the status bar switches from `thinking…` to `replying…`; tool execution shows `running <tool>…`.
|
|
290
|
+
|
|
291
|
+
Each finished assistant round shows how long it took and, when the endpoint reports usage, its output throughput: `· 8.4s · 23 tok/s`. The countdown in the status bar and the per-reply timing are wall-clock (including network time), are display-only, and are not stored in saved sessions; resumed replies and replies from servers without usage simply omit them.
|
|
290
292
|
|
|
291
293
|
Assistant replies are rendered as Markdown: headings, bold/italic, inline code, bullet and numbered lists, task checkboxes, blockquotes, links, and fenced code blocks. Unknown or incomplete markers fall back to their literal text, so streaming never breaks the layout.
|
|
292
294
|
|
|
293
|
-
Typing `/` opens a command palette
|
|
295
|
+
Typing `/` opens a command palette. It is drawn over the bottom of the transcript instead of resizing it, so the conversation does not jump when the menu opens or closes. It filters as you type, `↑`/`↓` select a command, `Enter` runs it, and `Tab` completes it. `Esc` clears the input.
|
|
294
296
|
|
|
295
297
|
On a real TTY, `kiro` switches to the terminal's alternate screen: you get a clean page instead of the TUI drawing underneath the command you just ran. When Kiro exits — `/exit`, `Ctrl+C`, or an error — the terminal restores the previous shell contents and prompt. Redirected output (pipes, CI logs) is left untouched. Pass `--no-alt-screen` to stay on the normal screen instead.
|
|
296
298
|
|
|
@@ -303,7 +305,7 @@ Slash commands:
|
|
|
303
305
|
| Command | Action |
|
|
304
306
|
| --- | --- |
|
|
305
307
|
| `/help` | Show commands and keys |
|
|
306
|
-
| `/model` | Open the model picker: profile first, then
|
|
308
|
+
| `/model` | Open the model picker: profile first, then searchable stored models |
|
|
307
309
|
| `/model <name>` | Switch profile without restarting |
|
|
308
310
|
| `/model add` | Guided setup; prompts appear in the input box and the key is masked |
|
|
309
311
|
| `/model edit [name]` | Edit fields, replace the key, re-test, and save |
|
|
@@ -322,7 +324,7 @@ Slash commands:
|
|
|
322
324
|
| `/allow clear` | Ask for approval again for every tool |
|
|
323
325
|
| `/exit` | Quit |
|
|
324
326
|
|
|
325
|
-
`/model` opens a two-step picker. The first step lists profiles grouped by endpoint (the active one is marked `*`); `Enter` opens that profile's models. The second step lists the ids stored in the profile's `models` field with the one in use marked `*`; `Enter` applies it, switches to that profile, and saves the choice to `config.json`.
|
|
327
|
+
`/model` opens a two-step picker. The first step lists profiles grouped by endpoint (the active one is marked `*`); `Enter` opens that profile's models. The second step lists the ids stored in the profile's `models` field with the one in use marked `*`; `Enter` applies it, switches to that profile, and saves the choice to `config.json`. On the model step, type to filter (case-insensitive; space-separated terms must all match), `Backspace` edits the query, `Esc` clears the query first and then goes back, and `↑`/`↓` move through the filtered list. `Ctrl+R` refetches `GET /models` from that endpoint and stores the result; later switches need no network. `Ctrl+C` closes the picker. A profile with no stored list still shows its current model, and adding a profile through the wizard stores whatever discovery returned for it.
|
|
326
328
|
|
|
327
329
|
## Sessions
|
|
328
330
|
|
|
@@ -415,6 +417,7 @@ If an `AGENTS.md` file exists in the working directory, its contents are appende
|
|
|
415
417
|
- Ctrl+C aborts the HTTP stream and any running command; partial assistant text is preserved.
|
|
416
418
|
- `kiro -p` runs the same agent loop without Ink, streams assistant text to stdout and diagnostics to stderr, denies tool calls unless `--yolo` is given, and saves the session like the TUI.
|
|
417
419
|
- Sessions are saved atomically after each user message and completed turn, and are restored by rebuilding the visible transcript from the stored messages.
|
|
420
|
+
- Reply timing is measured per model round (request start to finished reply) and includes network latency. Token throughput uses the endpoint's completion-token usage; both are shown only in the live TUI and are not persisted.
|
|
418
421
|
- Model discovery calls `GET {baseUrl}/models` with a 10-second timeout; the connection test sends one tiny non-tool chat completion with the same timeout. Both can be cancelled.
|
|
419
422
|
- Config saves are atomic and merge into the file on disk, so fields Kiro does not know about are preserved. Invalid JSON can be backed up and replaced with a fresh template.
|
|
420
423
|
- Keys are never written to `config.json`, sessions, or logs. They live in `~/.kiro/.env` (mode `0600`) or the real environment, and the config stores only `apiKeyEnv`; actual values are never printed, are stripped from `run_command`'s environment, and are redacted from tool output before it reaches the model.
|
package/dist/ui/App.js
CHANGED
|
@@ -27,7 +27,7 @@ import { loadPromptHistory, recordPrompt } from './prompt-history.js';
|
|
|
27
27
|
import { StatusBar } from './StatusBar.js';
|
|
28
28
|
import { summarizeToolArgs } from './text.js';
|
|
29
29
|
import { undoLastCheckpoint } from '../tools/checkpoint.js';
|
|
30
|
-
import { MAX_EXPANDED_TOOL_CHARS, MAX_REASONING_CHARS } from './types.js';
|
|
30
|
+
import { MAX_EXPANDED_TOOL_CHARS, MAX_REASONING_CHARS, } from './types.js';
|
|
31
31
|
function useTerminalSize() {
|
|
32
32
|
const { stdout } = useStdout();
|
|
33
33
|
const read = useCallback(() => ({
|
|
@@ -70,17 +70,21 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
70
70
|
const [runtimeConfig, setRuntimeConfig] = useState(config);
|
|
71
71
|
const [profileName, setProfileName] = useState(config.activeProfile);
|
|
72
72
|
const [busy, setBusy] = useState(false);
|
|
73
|
+
const [replying, setReplying] = useState(false);
|
|
74
|
+
const [busySince, setBusySince] = useState(null);
|
|
73
75
|
const [wizardPrompt, setWizardPrompt] = useState(null);
|
|
74
76
|
const [wizardActive, setWizardActive] = useState(false);
|
|
75
77
|
const [activeTool, setActiveTool] = useState(null);
|
|
76
78
|
const [cancelling, setCancelling] = useState(false);
|
|
77
79
|
const [pendingApproval, setPendingApproval] = useState(null);
|
|
78
80
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
79
|
-
const [
|
|
81
|
+
const [palette, setPalette] = useState(null);
|
|
80
82
|
const [mouseOn, setMouseOn] = useState(mouseEnabled);
|
|
81
83
|
const [expandedToolId, setExpandedToolId] = useState(null);
|
|
82
84
|
const messagesRef = useRef((initialSession?.messages ?? []).filter((message) => message.role !== 'system'));
|
|
83
85
|
const usageRef = useRef(null);
|
|
86
|
+
const roundStartedAtRef = useRef(0);
|
|
87
|
+
const roundCompletionTokensRef = useRef(null);
|
|
84
88
|
const [contextTokens, setContextTokens] = useState(() => estimateMessagesTokens(messagesRef.current));
|
|
85
89
|
const contextTokensRef = useRef(contextTokens);
|
|
86
90
|
const sessionRef = useRef(initialSession
|
|
@@ -130,9 +134,6 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
130
134
|
contextTokensRef.current = rounded;
|
|
131
135
|
setContextTokens(rounded);
|
|
132
136
|
}, []);
|
|
133
|
-
const handleMenuRowsChange = useCallback((rows) => {
|
|
134
|
-
setSlashMenuRows((current) => (current === rows ? current : rows));
|
|
135
|
-
}, []);
|
|
136
137
|
const recomputeContext = useCallback(() => {
|
|
137
138
|
const messages = messagesRef.current;
|
|
138
139
|
const usage = usageRef.current;
|
|
@@ -374,13 +375,19 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
374
375
|
}, 30);
|
|
375
376
|
}
|
|
376
377
|
}, [flushText]);
|
|
377
|
-
const finalizeAssistant = useCallback((content) => {
|
|
378
|
+
const finalizeAssistant = useCallback((content, durationMs, tokensPerSecond) => {
|
|
378
379
|
setItems((current) => {
|
|
379
380
|
const last = current[current.length - 1];
|
|
380
381
|
if (last?.kind === 'assistant' && last.draft) {
|
|
381
|
-
return [
|
|
382
|
+
return [
|
|
383
|
+
...current.slice(0, -1),
|
|
384
|
+
{ ...last, text: content, draft: false, durationMs, tokensPerSecond },
|
|
385
|
+
];
|
|
382
386
|
}
|
|
383
|
-
return [
|
|
387
|
+
return [
|
|
388
|
+
...current,
|
|
389
|
+
{ kind: 'assistant', id: nextItemIdRef.current++, text: content, durationMs, tokensPerSecond },
|
|
390
|
+
];
|
|
384
391
|
});
|
|
385
392
|
}, []);
|
|
386
393
|
/** Marks live "thinking…" items finished; reasoning is display-only and not saved. */
|
|
@@ -430,6 +437,11 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
430
437
|
busyRef.current = true;
|
|
431
438
|
cancelRequestedRef.current = false;
|
|
432
439
|
setBusy(true);
|
|
440
|
+
setReplying(false);
|
|
441
|
+
const startedAt = Date.now();
|
|
442
|
+
setBusySince(startedAt);
|
|
443
|
+
roundStartedAtRef.current = startedAt;
|
|
444
|
+
roundCompletionTokensRef.current = null;
|
|
433
445
|
setCancelling(false);
|
|
434
446
|
setActiveTool(null);
|
|
435
447
|
if (!alreadyDisplayed) {
|
|
@@ -468,6 +480,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
468
480
|
case 'text':
|
|
469
481
|
flushText();
|
|
470
482
|
finalizeReasoning();
|
|
483
|
+
setReplying(true);
|
|
471
484
|
queueText(event.text);
|
|
472
485
|
break;
|
|
473
486
|
case 'reasoning': {
|
|
@@ -490,15 +503,24 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
490
503
|
});
|
|
491
504
|
break;
|
|
492
505
|
}
|
|
493
|
-
case 'assistant':
|
|
506
|
+
case 'assistant': {
|
|
494
507
|
flushText();
|
|
495
508
|
finalizeReasoning();
|
|
496
|
-
|
|
509
|
+
const durationMs = Math.max(0, Date.now() - roundStartedAtRef.current);
|
|
510
|
+
const completionTokens = roundCompletionTokensRef.current;
|
|
511
|
+
const tokensPerSecond = completionTokens !== null && completionTokens > 0 && durationMs > 0
|
|
512
|
+
? Math.round(completionTokens / (durationMs / 1_000))
|
|
513
|
+
: undefined;
|
|
514
|
+
finalizeAssistant(event.content, durationMs, tokensPerSecond);
|
|
515
|
+
roundCompletionTokensRef.current = null;
|
|
516
|
+
setReplying(false);
|
|
497
517
|
recomputeContext();
|
|
498
518
|
break;
|
|
519
|
+
}
|
|
499
520
|
case 'tool-start':
|
|
500
521
|
flushText();
|
|
501
522
|
finalizeReasoning();
|
|
523
|
+
setReplying(false);
|
|
502
524
|
setActiveTool(event.toolCall.function.name);
|
|
503
525
|
setItems((current) => [
|
|
504
526
|
...current,
|
|
@@ -532,6 +554,9 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
532
554
|
return next;
|
|
533
555
|
});
|
|
534
556
|
recomputeContext();
|
|
557
|
+
// The next model round starts once the tools for this one finish.
|
|
558
|
+
roundStartedAtRef.current = Date.now();
|
|
559
|
+
roundCompletionTokensRef.current = null;
|
|
535
560
|
break;
|
|
536
561
|
case 'usage':
|
|
537
562
|
usageRef.current = {
|
|
@@ -540,6 +565,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
540
565
|
// stream ends and is already counted in totalTokens.
|
|
541
566
|
messageCount: messagesRef.current.length + 1,
|
|
542
567
|
};
|
|
568
|
+
roundCompletionTokensRef.current = event.usage.completionTokens;
|
|
543
569
|
recomputeContext();
|
|
544
570
|
break;
|
|
545
571
|
case 'notice':
|
|
@@ -568,6 +594,8 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
568
594
|
abortRef.current = null;
|
|
569
595
|
busyRef.current = false;
|
|
570
596
|
setBusy(false);
|
|
597
|
+
setReplying(false);
|
|
598
|
+
setBusySince(null);
|
|
571
599
|
setActiveTool(null);
|
|
572
600
|
setCancelling(false);
|
|
573
601
|
if (pendingApprovalRef.current)
|
|
@@ -1169,13 +1197,14 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1169
1197
|
: busy
|
|
1170
1198
|
? activeTool
|
|
1171
1199
|
? 'running'
|
|
1172
|
-
:
|
|
1200
|
+
: replying
|
|
1201
|
+
? 'replying'
|
|
1202
|
+
: 'thinking'
|
|
1173
1203
|
: null;
|
|
1174
1204
|
const activeProfile = runtimeConfig.profiles[profileName];
|
|
1175
1205
|
const contextWindow = contextWindowFor(activeProfile);
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsx(MessageList, { items: items, width: width, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerOpen ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : (_jsx(Input, { disabled: false, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, history: wizardPrompt || wizardActive ? undefined : promptHistory, placeholder: wizardPrompt
|
|
1206
|
+
const viewportHeight = Math.max(3, rows - 5 - (pendingApproval ? 12 : 0) - (pickerOpen ? 13 : 0));
|
|
1207
|
+
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsx(MessageList, { items: items, width: width, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerOpen ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : (_jsx(Input, { disabled: false, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, history: wizardPrompt || wizardActive ? undefined : promptHistory, onPaletteChange: setPalette, placeholder: wizardPrompt
|
|
1179
1208
|
? wizardPrompt.defaultValue && !wizardPrompt.mask
|
|
1180
1209
|
? `${wizardPrompt.label} [${wizardPrompt.defaultValue}]`
|
|
1181
1210
|
: wizardPrompt.label
|
|
@@ -1183,6 +1212,6 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1183
1212
|
? 'Kiro is working… type ahead, or Ctrl+C to cancel'
|
|
1184
1213
|
: wizardActive
|
|
1185
1214
|
? 'Working… Esc to cancel'
|
|
1186
|
-
: 'Ask Kiro to build or change something…', slashMenu: !wizardActive && !wizardPrompt,
|
|
1215
|
+
: 'Ask Kiro to build or change something…', slashMenu: !wizardActive && !wizardPrompt, onSubmit: handleSubmit, onCancel: wizardActive ? cancelWizard : undefined }, wizardPrompt?.id ?? 0)), _jsx(StatusBar, { width: width, profile: profileName, model: activeProfile?.model ?? 'unknown', cwd: cwd, activity: activity, toolName: activeTool ?? undefined, busySince: busySince ?? undefined, queued: queuedCount > 0 ? queuedCount : undefined, yolo: yolo, autoAllowed: autoAllowed, contextTokens: contextTokens, contextWindow: contextWindow })] }));
|
|
1187
1216
|
}
|
|
1188
1217
|
//# sourceMappingURL=App.js.map
|
package/dist/ui/Input.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isMouseSequence } from './mouse.js';
|
|
|
7
7
|
import { applyInputOps, parseEditSequence, parseInputChunk, } from './text.js';
|
|
8
8
|
const MAX_INPUT_CHARS = 20_000;
|
|
9
9
|
const MAX_MENU_ROWS = 6;
|
|
10
|
-
export function Input({ disabled, placeholder, width, mask = false, allowEmpty = false, slashMenu = true, history, onSubmit, onCancel,
|
|
10
|
+
export function Input({ disabled, placeholder, width, mask = false, allowEmpty = false, slashMenu = true, history, onSubmit, onCancel, onPaletteChange, }) {
|
|
11
11
|
const { stdin } = useStdin();
|
|
12
12
|
const [state, setState] = useState({ chars: [], cursor: 0 });
|
|
13
13
|
const [selected, setSelected] = useState(0);
|
|
@@ -31,13 +31,13 @@ export function Input({ disabled, placeholder, width, mask = false, allowEmpty =
|
|
|
31
31
|
setSelected(0);
|
|
32
32
|
}, [text]);
|
|
33
33
|
useEffect(() => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
onPaletteChange?.(menuOpen
|
|
35
|
+
? { commands: visibleCommands, activeIndex: Math.max(0, activeIndex - menuStart) }
|
|
36
|
+
: null);
|
|
37
|
+
// visibleCommands is derived from text, activeIndex and menuStart.
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
}, [menuOpen, text, activeIndex, menuStart, onPaletteChange]);
|
|
40
|
+
useEffect(() => () => onPaletteChange?.(null), [onPaletteChange]);
|
|
41
41
|
const update = (chars, cursor) => {
|
|
42
42
|
const next = { chars, cursor: Math.max(0, Math.min(cursor, chars.length)) };
|
|
43
43
|
stateRef.current = next;
|
|
@@ -246,9 +246,6 @@ export function Input({ disabled, placeholder, width, mask = false, allowEmpty =
|
|
|
246
246
|
const at = displayChars[cursor] ?? ' ';
|
|
247
247
|
const after = displayChars.slice(cursor + 1, end).join('');
|
|
248
248
|
const showPlaceholder = chars.length === 0;
|
|
249
|
-
return (_jsxs(Box, {
|
|
250
|
-
const active = menuStart + offset === activeIndex;
|
|
251
|
-
return (_jsxs(Text, { inverse: active, bold: active, wrap: "truncate-end", children: [active ? '› ' : ' ', command.name, command.usage ? _jsx(Text, { dimColor: !active, children: ` ${command.usage}` }) : null, _jsx(Text, { dimColor: !active, children: ` ${command.description}` })] }, command.name));
|
|
252
|
-
}), Array.from({ length: MAX_MENU_ROWS - visibleCommands.length }, (_, index) => (_jsx(Text, { children: " " }, `empty-${index}`)))] })) : null, _jsxs(Box, { flexShrink: 0, children: [_jsx(Text, { color: disabled ? 'gray' : 'cyan', bold: true, children: '› ' }), disabled ? (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: placeholder })) : showPlaceholder ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { inverse: true, children: " " }), _jsxs(Text, { dimColor: true, children: [" ", placeholder] })] })) : (_jsxs(Text, { wrap: "truncate-end", children: [before, _jsx(Text, { inverse: true, children: at }), after] }))] })] }));
|
|
249
|
+
return (_jsxs(Box, { flexShrink: 0, children: [_jsx(Text, { color: disabled ? 'gray' : 'cyan', bold: true, children: '› ' }), disabled ? (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: placeholder })) : showPlaceholder ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { inverse: true, children: " " }), _jsxs(Text, { dimColor: true, children: [" ", placeholder] })] })) : (_jsxs(Text, { wrap: "truncate-end", children: [before, _jsx(Text, { inverse: true, children: at }), after] }))] }));
|
|
253
250
|
}
|
|
254
251
|
//# sourceMappingURL=Input.js.map
|
package/dist/ui/MessageList.js
CHANGED
|
@@ -132,6 +132,14 @@ function itemLines(item, width, expandedToolId) {
|
|
|
132
132
|
text: '',
|
|
133
133
|
segments: line.segments,
|
|
134
134
|
}));
|
|
135
|
+
if (!item.draft && item.durationMs !== undefined) {
|
|
136
|
+
const speed = item.tokensPerSecond !== undefined ? ` · ${item.tokensPerSecond} tok/s` : '';
|
|
137
|
+
lines.push({
|
|
138
|
+
prefix: ' ',
|
|
139
|
+
text: `· ${formatDuration(item.durationMs)}${speed}`,
|
|
140
|
+
dim: true,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
135
143
|
lines.push(blankLine());
|
|
136
144
|
return lines;
|
|
137
145
|
}
|
|
@@ -175,7 +183,45 @@ export function buildLines(items, width, expandedToolId = null) {
|
|
|
175
183
|
}
|
|
176
184
|
return lines;
|
|
177
185
|
}
|
|
178
|
-
|
|
186
|
+
const PALETTE_ROWS = 6;
|
|
187
|
+
/** Header plus the visible command rows; padded so filtering never changes its height. */
|
|
188
|
+
export function buildPaletteLines(palette, width) {
|
|
189
|
+
const header = {
|
|
190
|
+
prefix: ' ',
|
|
191
|
+
text: truncateToWidth('commands · ↑/↓ move · Tab complete · Enter run', width),
|
|
192
|
+
dim: true,
|
|
193
|
+
};
|
|
194
|
+
const rows = palette.commands.slice(0, PALETTE_ROWS).map((command, index) => {
|
|
195
|
+
const active = index === palette.activeIndex;
|
|
196
|
+
const label = command.usage ? `${command.name} ${command.usage}` : command.name;
|
|
197
|
+
return {
|
|
198
|
+
prefix: active ? '› ' : ' ',
|
|
199
|
+
prefixColor: active ? 'cyan' : undefined,
|
|
200
|
+
text: '',
|
|
201
|
+
segments: [
|
|
202
|
+
{ text: label, bold: active },
|
|
203
|
+
{ text: ` ${command.description}`, dim: !active },
|
|
204
|
+
],
|
|
205
|
+
inverse: active,
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
while (rows.length < PALETTE_ROWS)
|
|
209
|
+
rows.push({ prefix: '', text: '' });
|
|
210
|
+
return [header, ...rows];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Replaces the last rows of the visible transcript with the palette, so opening
|
|
214
|
+
* the menu never resizes the transcript or moves the conversation.
|
|
215
|
+
*/
|
|
216
|
+
export function applyPalette(lines, palette, width, maxRows) {
|
|
217
|
+
if (!palette)
|
|
218
|
+
return lines;
|
|
219
|
+
const height = Math.max(1, maxRows);
|
|
220
|
+
const overlay = buildPaletteLines(palette, width).slice(0, height);
|
|
221
|
+
const keep = Math.max(0, Math.min(lines.length, height) - overlay.length);
|
|
222
|
+
return [...lines.slice(0, keep), ...overlay];
|
|
223
|
+
}
|
|
224
|
+
export function MessageList({ items, width, height, resetSignal, expandedToolId = null, palette = null, interactive = true, }) {
|
|
179
225
|
const { stdin } = useStdin();
|
|
180
226
|
const lines = buildLines(items, width, expandedToolId);
|
|
181
227
|
const maxScroll = Math.max(0, lines.length - height);
|
|
@@ -229,9 +275,10 @@ export function MessageList({ items, width, height, resetSignal, expandedToolId
|
|
|
229
275
|
}
|
|
230
276
|
}, { isActive: interactive });
|
|
231
277
|
const visible = lines.slice(scrollTop, scrollTop + height);
|
|
232
|
-
|
|
278
|
+
const shown = applyPalette(visible, palette, width, height);
|
|
279
|
+
return (_jsx(Box, { flexDirection: "column", height: height, overflowY: "hidden", flexShrink: 0, justifyContent: "flex-end", children: shown.map((line, index) => {
|
|
233
280
|
const hasSuffix = line.suffix !== undefined;
|
|
234
|
-
return (_jsxs(Text, { wrap: "truncate-end", color: line.color, dimColor: line.dim, bold: line.bold, children: [line.prefix ? (_jsx(Text, { color: line.prefixColor, dimColor: line.prefixDim, bold: line.prefixColor === 'cyan', children: line.prefix })) : null, line.segments
|
|
281
|
+
return (_jsxs(Text, { wrap: "truncate-end", color: line.color, dimColor: line.dim, bold: line.bold, inverse: line.inverse, children: [line.prefix ? (_jsx(Text, { color: line.prefixColor, dimColor: line.prefixDim, bold: line.prefixColor === 'cyan', children: line.prefix })) : null, line.segments
|
|
235
282
|
? line.segments.map((segment, segmentIndex) => (_jsx(Text, { color: segment.color, dimColor: segment.dim, bold: segment.bold, italic: segment.italic, underline: segment.underline, strikethrough: segment.strikethrough, children: segment.text }, segmentIndex)))
|
|
236
283
|
: line.text || (hasSuffix ? '' : ' '), line.suffix ? (_jsx(Text, { color: line.suffix.color, dimColor: line.suffix.dim, bold: line.suffix.bold, children: line.suffix.text })) : null] }, `${scrollTop}-${index}`));
|
|
237
284
|
}) }));
|
package/dist/ui/ModelPicker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Box, Text, useInput } from 'ink';
|
|
4
|
-
import { modelIds, pickerWindow, profileRows, selectableLines, selectableNames, } from './model-picker.js';
|
|
4
|
+
import { filterModelIds, modelIds, pickerWindow, profileRows, selectableLines, selectableNames, } from './model-picker.js';
|
|
5
5
|
/** Keys are highlighted so the hint reads at a glance; the rest stays dim. */
|
|
6
6
|
const KEY_COLOR = '#ff9e64';
|
|
7
7
|
function Key({ children }) {
|
|
@@ -19,11 +19,13 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
19
19
|
const [index, setIndex] = useState(0);
|
|
20
20
|
const [refreshing, setRefreshing] = useState(false);
|
|
21
21
|
const [error, setError] = useState(null);
|
|
22
|
+
const [query, setQuery] = useState('');
|
|
22
23
|
const rows = profileRows(config, activeProfile);
|
|
23
24
|
const names = selectableNames(rows);
|
|
24
25
|
const lines = selectableLines(rows);
|
|
25
26
|
const profile = step.kind === 'model' ? config.profiles[step.profile] : undefined;
|
|
26
|
-
const
|
|
27
|
+
const allModels = modelIds(profile);
|
|
28
|
+
const models = step.kind === 'model' ? filterModelIds(allModels, query) : allModels;
|
|
27
29
|
const count = step.kind === 'profile' ? names.length : models.length;
|
|
28
30
|
const selected = Math.min(index, Math.max(0, count - 1));
|
|
29
31
|
const selectedLine = step.kind === 'profile' ? (lines[selected] ?? 0) : selected;
|
|
@@ -42,10 +44,21 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
42
44
|
useInput((input, key) => {
|
|
43
45
|
if (refreshing)
|
|
44
46
|
return;
|
|
47
|
+
if (step.kind === 'model' && key.ctrl && input === 'r') {
|
|
48
|
+
void refresh(step.profile);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
45
51
|
if (key.escape) {
|
|
52
|
+
if (step.kind === 'model' && query) {
|
|
53
|
+
setQuery('');
|
|
54
|
+
setIndex(0);
|
|
55
|
+
setError(null);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
46
58
|
if (step.kind === 'model') {
|
|
47
59
|
setStep({ kind: 'profile' });
|
|
48
60
|
setIndex(0);
|
|
61
|
+
setQuery('');
|
|
49
62
|
setError(null);
|
|
50
63
|
}
|
|
51
64
|
else {
|
|
@@ -60,8 +73,21 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
60
73
|
setIndex(Math.min(count - 1, Math.max(0, selected + delta)));
|
|
61
74
|
return;
|
|
62
75
|
}
|
|
63
|
-
if (step.kind === 'model' &&
|
|
64
|
-
|
|
76
|
+
if (step.kind === 'model' && !key.return) {
|
|
77
|
+
if (key.backspace || key.delete) {
|
|
78
|
+
if (query) {
|
|
79
|
+
setQuery(query.slice(0, -1));
|
|
80
|
+
setIndex(0);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (key.ctrl || key.meta || key.tab || key.pageUp || key.pageDown)
|
|
85
|
+
return;
|
|
86
|
+
const typed = input.replace(/[\u0000-\u001f\u007f]/g, '');
|
|
87
|
+
if (typed) {
|
|
88
|
+
setQuery(query + typed);
|
|
89
|
+
setIndex(0);
|
|
90
|
+
}
|
|
65
91
|
return;
|
|
66
92
|
}
|
|
67
93
|
if (!key.return)
|
|
@@ -72,6 +98,7 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
72
98
|
return;
|
|
73
99
|
setStep({ kind: 'model', profile: name });
|
|
74
100
|
setIndex(0);
|
|
101
|
+
setQuery('');
|
|
75
102
|
setError(null);
|
|
76
103
|
return;
|
|
77
104
|
}
|
|
@@ -81,8 +108,10 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
81
108
|
});
|
|
82
109
|
const title = step.kind === 'profile'
|
|
83
110
|
? `Model · ${names.length} profile${names.length === 1 ? '' : 's'}`
|
|
84
|
-
:
|
|
85
|
-
|
|
111
|
+
: query.trim()
|
|
112
|
+
? `Models · ${step.profile} (${models.length}/${allModels.length} match)`
|
|
113
|
+
: `Models · ${step.profile} (${models.length})`;
|
|
114
|
+
return (_jsxs(Box, { flexDirection: "column", width: width, borderStyle: "round", borderColor: "cyan", paddingX: 1, flexShrink: 0, children: [_jsx(Text, { bold: true, color: "cyan", wrap: "truncate-end", children: title }), step.kind === 'model' ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Said, { children: "Search: " }), query || _jsx(Said, { children: "type to filter" })] })) : null, step.kind === 'profile'
|
|
86
115
|
? rows.slice(start, end).map((row, offset) => {
|
|
87
116
|
const line = start + offset;
|
|
88
117
|
if (row.kind === 'header') {
|
|
@@ -95,6 +124,6 @@ export function ModelPicker({ config, activeProfile, width, maxRows = 8, onSelec
|
|
|
95
124
|
const line = start + offset;
|
|
96
125
|
const focused = line === selectedLine;
|
|
97
126
|
return (_jsx(Text, { color: focused ? 'cyan' : undefined, bold: focused, wrap: "truncate-end", children: ` ${id === profile?.model ? '*' : ' '} ${id}` }, `m${line}`));
|
|
98
|
-
}), step.kind === 'model' && profile && !profile.models?.length ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Said, { children: "Only the active model is stored; press " }), _jsx(Key, { children: "
|
|
127
|
+
}), step.kind === 'model' && models.length === 0 ? (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: ["No models match \"", query, "\". Backspace to edit, Esc to clear."] })) : null, step.kind === 'model' && profile && !profile.models?.length ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Said, { children: "Only the active model is stored; press " }), _jsx(Key, { children: "Ctrl+R" }), _jsx(Said, { children: " to fetch this endpoint." })] })) : null, error ? (_jsx(Text, { color: "red", wrap: "truncate-end", children: error })) : null, step.kind === 'profile' ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " choose profile \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: " close" })] })) : refreshing ? (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: "Fetching models\u2026" })) : (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " use \u00B7 type to filter \u00B7 " }), _jsx(Key, { children: "Ctrl+R" }), _jsx(Said, { children: " refetch \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: query ? ' clear search' : ' back' })] }))] }));
|
|
99
128
|
}
|
|
100
129
|
//# sourceMappingURL=ModelPicker.js.map
|
package/dist/ui/StatusBar.js
CHANGED
|
@@ -14,7 +14,7 @@ function prettyCwd(cwd) {
|
|
|
14
14
|
}
|
|
15
15
|
return cwd;
|
|
16
16
|
}
|
|
17
|
-
export function StatusBar({ width, profile, model, cwd, activity, toolName, queued, yolo = false, autoAllowed = [], contextTokens, contextWindow, }) {
|
|
17
|
+
export function StatusBar({ width, profile, model, cwd, activity, toolName, busySince, queued, yolo = false, autoAllowed = [], contextTokens, contextWindow, }) {
|
|
18
18
|
const busy = activity !== null;
|
|
19
19
|
const [frame, setFrame] = useState(0);
|
|
20
20
|
useEffect(() => {
|
|
@@ -29,11 +29,16 @@ export function StatusBar({ width, profile, model, cwd, activity, toolName, queu
|
|
|
29
29
|
? 'cancelling…'
|
|
30
30
|
: activity === 'running'
|
|
31
31
|
? `running ${toolName ?? 'tool'}…`
|
|
32
|
-
: activity === '
|
|
33
|
-
? '
|
|
34
|
-
: '
|
|
32
|
+
: activity === 'replying'
|
|
33
|
+
? 'replying…'
|
|
34
|
+
: activity === 'thinking'
|
|
35
|
+
? 'thinking…'
|
|
36
|
+
: 'ready';
|
|
35
37
|
const stateColor = activity === 'cancelling' ? 'red' : activity === null ? 'green' : 'yellow';
|
|
36
38
|
const spinner = busy ? `${SPINNER[frame] ?? '⠋'} ` : '';
|
|
39
|
+
const elapsedMs = busy && busySince !== undefined ? Math.max(0, Date.now() - busySince) : 0;
|
|
40
|
+
// Whole seconds keep the re-rendering spinner from making the timer flicker.
|
|
41
|
+
const elapsedNote = elapsedMs >= 1_000 ? ` · ${Math.floor(elapsedMs / 1_000)}s` : '';
|
|
37
42
|
const queueNote = queued ? `${queued} queued · ` : '';
|
|
38
43
|
const badge = yolo
|
|
39
44
|
? 'YOLO'
|
|
@@ -43,7 +48,7 @@ export function StatusBar({ width, profile, model, cwd, activity, toolName, queu
|
|
|
43
48
|
const badgeWidth = badge === '' ? 0 : displayWidth(badge) + 2;
|
|
44
49
|
// The bar is indented to line up with the chat text, so budgets use the inner width.
|
|
45
50
|
const innerWidth = Math.max(10, width - 2);
|
|
46
|
-
const state = `${spinner}${queueNote}${stateText}`;
|
|
51
|
+
const state = `${spinner}${queueNote}${stateText}${elapsedNote}`;
|
|
47
52
|
const stateBudget = Math.max(4, Math.max(10, Math.floor(innerWidth / 2)) - badgeWidth);
|
|
48
53
|
const stateShown = truncateToWidth(state, stateBudget);
|
|
49
54
|
const restBudget = Math.max(0, innerWidth - badgeWidth - displayWidth(stateShown) - 2 - 6);
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -26,6 +26,16 @@ export function modelIds(profile) {
|
|
|
26
26
|
const stored = profile.models ?? [];
|
|
27
27
|
return stored.includes(profile.model) ? stored : [profile.model, ...stored];
|
|
28
28
|
}
|
|
29
|
+
/** Case-insensitive multi-term search: every whitespace-separated term must match. */
|
|
30
|
+
export function filterModelIds(ids, query) {
|
|
31
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
32
|
+
if (terms.length === 0)
|
|
33
|
+
return ids;
|
|
34
|
+
return ids.filter((id) => {
|
|
35
|
+
const haystack = id.toLowerCase();
|
|
36
|
+
return terms.every((term) => haystack.includes(term));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
29
39
|
/** Keeps the highlighted line inside a window of `maxRows` entries. */
|
|
30
40
|
export function pickerWindow(index, count, maxRows) {
|
|
31
41
|
if (count <= 0)
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.3';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|