@ywldan/kiro 0.3.0 → 0.3.1
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 +516 -515
- package/dist/doctor.js +13 -13
- package/dist/index.js +44 -44
- package/dist/sessions.js +96 -14
- package/dist/ui/App.js +77 -28
- package/dist/ui/SessionPicker.js +112 -0
- package/dist/ui/commands.js +2 -2
- package/dist/ui/session-picker.js +96 -0
- package/package.json +61 -61
package/dist/doctor.js
CHANGED
|
@@ -6,19 +6,19 @@ import { discoverModels, testConnection } from './model/discovery.js';
|
|
|
6
6
|
import { redactSecrets, registerSecretEnv } from './secrets.js';
|
|
7
7
|
import { formatDuration } from './ui/text.js';
|
|
8
8
|
import { VERSION } from './version.js';
|
|
9
|
-
const DOCTOR_HELP = `Kiro doctor
|
|
10
|
-
|
|
11
|
-
Usage:
|
|
12
|
-
kiro doctor [options]
|
|
13
|
-
|
|
14
|
-
Checks the Node version, config file, where the key is stored, and the active
|
|
15
|
-
endpoint. Prints one line per check and exits 1 when a check fails.
|
|
16
|
-
|
|
17
|
-
Options:
|
|
18
|
-
--profile <name> inspect a profile other than the active one
|
|
19
|
-
--offline skip the network checks
|
|
20
|
-
--test send a small chat completion to verify the key and model
|
|
21
|
-
-h, --help show this help
|
|
9
|
+
const DOCTOR_HELP = `Kiro doctor
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
kiro doctor [options]
|
|
13
|
+
|
|
14
|
+
Checks the Node version, config file, where the key is stored, and the active
|
|
15
|
+
endpoint. Prints one line per check and exits 1 when a check fails.
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
--profile <name> inspect a profile other than the active one
|
|
19
|
+
--offline skip the network checks
|
|
20
|
+
--test send a small chat completion to verify the key and model
|
|
21
|
+
-h, --help show this help
|
|
22
22
|
`;
|
|
23
23
|
class DoctorUsageError extends Error {
|
|
24
24
|
}
|
package/dist/index.js
CHANGED
|
@@ -14,50 +14,50 @@ import { App } from './ui/App.js';
|
|
|
14
14
|
import { runCheck, runUpdate } from './update.js';
|
|
15
15
|
import { runDoctor } from './doctor.js';
|
|
16
16
|
import { VERSION } from './version.js';
|
|
17
|
-
const HELP = `Kiro: a small terminal coding agent
|
|
18
|
-
|
|
19
|
-
Usage: kiro [options]
|
|
20
|
-
kiro model [command]
|
|
21
|
-
kiro doctor [options]
|
|
22
|
-
|
|
23
|
-
Options:
|
|
24
|
-
--profile <name> Use a profile from ~/.kiro/config.json
|
|
25
|
-
--base-url <url> Override the active profile's OpenAI-compatible base URL
|
|
26
|
-
--model <name> Override the active profile's model name
|
|
27
|
-
-c, --continue Resume the most recent session for this directory
|
|
28
|
-
--resume <id> Resume a specific saved session
|
|
29
|
-
-p, --prompt <text>
|
|
30
|
-
Run one turn without a TUI ("-" or no text reads the
|
|
31
|
-
prompt from stdin); replies stream to stdout, notices
|
|
32
|
-
and reasoning to stderr
|
|
33
|
-
--yolo Skip all approval prompts (use with care)
|
|
34
|
-
--mouse Mouse reporting is on by default: the wheel scrolls the
|
|
35
|
-
transcript, Shift+drag selects text for copying.
|
|
36
|
-
--no-mouse Disable mouse reporting so plain click-drag selection works.
|
|
37
|
-
--no-alt-screen Do not switch to the terminal's alternate screen
|
|
38
|
-
--no-skills Do not load skills from .kiro/skills, .claude/skills, or
|
|
39
|
-
~/.kiro/skills (KIRO_NO_SKILLS=1 does the same)
|
|
40
|
-
-h, --help Show this help
|
|
41
|
-
-v, --version Show the version
|
|
42
|
-
|
|
43
|
-
Model commands:
|
|
44
|
-
kiro model Interactive wizard: select, add, edit, or remove models
|
|
45
|
-
kiro model list List configured profiles
|
|
46
|
-
kiro model add ... Add a profile without prompts (see "kiro model --help")
|
|
47
|
-
kiro model use <n> Make a profile active
|
|
48
|
-
kiro model remove <n>
|
|
49
|
-
kiro model test [n]
|
|
50
|
-
|
|
51
|
-
Update commands:
|
|
52
|
-
kiro check Compare the installed version with the latest on npm
|
|
53
|
-
kiro update Install the latest version from npm globally
|
|
54
|
-
|
|
55
|
-
Diagnostics:
|
|
56
|
-
kiro doctor Check Node, config, key storage, and the active endpoint
|
|
57
|
-
|
|
58
|
-
Config: ~/.kiro/config.json (created with a template on first run)
|
|
59
|
-
Keys: ~/.kiro/.env (mode 0600), or the environment variable named by "apiKeyEnv".
|
|
60
|
-
Sessions: ~/.kiro/sessions (one directory per working directory)
|
|
17
|
+
const HELP = `Kiro: a small terminal coding agent
|
|
18
|
+
|
|
19
|
+
Usage: kiro [options]
|
|
20
|
+
kiro model [command]
|
|
21
|
+
kiro doctor [options]
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
--profile <name> Use a profile from ~/.kiro/config.json
|
|
25
|
+
--base-url <url> Override the active profile's OpenAI-compatible base URL
|
|
26
|
+
--model <name> Override the active profile's model name
|
|
27
|
+
-c, --continue Resume the most recent session for this directory
|
|
28
|
+
--resume <id> Resume a specific saved session
|
|
29
|
+
-p, --prompt <text>
|
|
30
|
+
Run one turn without a TUI ("-" or no text reads the
|
|
31
|
+
prompt from stdin); replies stream to stdout, notices
|
|
32
|
+
and reasoning to stderr
|
|
33
|
+
--yolo Skip all approval prompts (use with care)
|
|
34
|
+
--mouse Mouse reporting is on by default: the wheel scrolls the
|
|
35
|
+
transcript, Shift+drag selects text for copying.
|
|
36
|
+
--no-mouse Disable mouse reporting so plain click-drag selection works.
|
|
37
|
+
--no-alt-screen Do not switch to the terminal's alternate screen
|
|
38
|
+
--no-skills Do not load skills from .kiro/skills, .claude/skills, or
|
|
39
|
+
~/.kiro/skills (KIRO_NO_SKILLS=1 does the same)
|
|
40
|
+
-h, --help Show this help
|
|
41
|
+
-v, --version Show the version
|
|
42
|
+
|
|
43
|
+
Model commands:
|
|
44
|
+
kiro model Interactive wizard: select, add, edit, or remove models
|
|
45
|
+
kiro model list List configured profiles
|
|
46
|
+
kiro model add ... Add a profile without prompts (see "kiro model --help")
|
|
47
|
+
kiro model use <n> Make a profile active
|
|
48
|
+
kiro model remove <n>
|
|
49
|
+
kiro model test [n]
|
|
50
|
+
|
|
51
|
+
Update commands:
|
|
52
|
+
kiro check Compare the installed version with the latest on npm
|
|
53
|
+
kiro update Install the latest version from npm globally
|
|
54
|
+
|
|
55
|
+
Diagnostics:
|
|
56
|
+
kiro doctor Check Node, config, key storage, and the active endpoint
|
|
57
|
+
|
|
58
|
+
Config: ~/.kiro/config.json (created with a template on first run)
|
|
59
|
+
Keys: ~/.kiro/.env (mode 0600), or the environment variable named by "apiKeyEnv".
|
|
60
|
+
Sessions: ~/.kiro/sessions (one directory per working directory)
|
|
61
61
|
`;
|
|
62
62
|
const ENTER_ALT_SCREEN = '\x1b[?1049h\x1b[H\x1b[2J';
|
|
63
63
|
const LEAVE_ALT_SCREEN = '\x1b[?1049l';
|
package/dist/sessions.js
CHANGED
|
@@ -159,18 +159,7 @@ export async function saveSession(input) {
|
|
|
159
159
|
}
|
|
160
160
|
return record;
|
|
161
161
|
}
|
|
162
|
-
|
|
163
|
-
const file = sessionFile(cwd, id);
|
|
164
|
-
let raw;
|
|
165
|
-
try {
|
|
166
|
-
raw = await readFile(file, 'utf8');
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
if (error.code === 'ENOENT') {
|
|
170
|
-
throw new SessionError(`Session "${id}" was not found for this directory.`);
|
|
171
|
-
}
|
|
172
|
-
throw new SessionError(`Could not read session "${id}": ${error.message}`);
|
|
173
|
-
}
|
|
162
|
+
function parseSessionRecord(raw, id, expectedCwd) {
|
|
174
163
|
let parsed;
|
|
175
164
|
try {
|
|
176
165
|
parsed = JSON.parse(raw);
|
|
@@ -183,7 +172,8 @@ export async function loadSession(cwd, id) {
|
|
|
183
172
|
if (parsed.version !== SESSION_VERSION) {
|
|
184
173
|
throw new SessionError(`Session "${id}" uses unsupported version ${String(parsed.version)}; expected ${SESSION_VERSION}.`);
|
|
185
174
|
}
|
|
186
|
-
if (typeof parsed.cwd !== 'string' ||
|
|
175
|
+
if (typeof parsed.cwd !== 'string' ||
|
|
176
|
+
(expectedCwd !== undefined && path.resolve(parsed.cwd) !== path.resolve(expectedCwd))) {
|
|
187
177
|
throw new SessionError(`Session "${id}" belongs to a different working directory.`);
|
|
188
178
|
}
|
|
189
179
|
const messages = normalizeMessages(parsed.messages);
|
|
@@ -191,7 +181,7 @@ export async function loadSession(cwd, id) {
|
|
|
191
181
|
return {
|
|
192
182
|
version: SESSION_VERSION,
|
|
193
183
|
id,
|
|
194
|
-
cwd: path.resolve(cwd),
|
|
184
|
+
cwd: path.resolve(parsed.cwd),
|
|
195
185
|
profile: typeof parsed.profile === 'string' ? parsed.profile : '',
|
|
196
186
|
model: typeof parsed.model === 'string' ? parsed.model : '',
|
|
197
187
|
title: typeof parsed.title === 'string' && parsed.title ? parsed.title : titleFromMessages(messages),
|
|
@@ -201,9 +191,24 @@ export async function loadSession(cwd, id) {
|
|
|
201
191
|
usage: normalizeUsage(parsed.usage),
|
|
202
192
|
};
|
|
203
193
|
}
|
|
194
|
+
export async function loadSession(cwd, id) {
|
|
195
|
+
const file = sessionFile(cwd, id);
|
|
196
|
+
let raw;
|
|
197
|
+
try {
|
|
198
|
+
raw = await readFile(file, 'utf8');
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
if (error.code === 'ENOENT') {
|
|
202
|
+
throw new SessionError(`Session "${id}" was not found for this directory.`);
|
|
203
|
+
}
|
|
204
|
+
throw new SessionError(`Could not read session "${id}": ${error.message}`);
|
|
205
|
+
}
|
|
206
|
+
return parseSessionRecord(raw, id, cwd);
|
|
207
|
+
}
|
|
204
208
|
function summarize(record) {
|
|
205
209
|
return {
|
|
206
210
|
id: record.id,
|
|
211
|
+
cwd: record.cwd,
|
|
207
212
|
profile: record.profile,
|
|
208
213
|
model: record.model,
|
|
209
214
|
title: record.title,
|
|
@@ -243,6 +248,83 @@ export async function listSessions(cwd, limit = 20) {
|
|
|
243
248
|
sessions.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
244
249
|
return { sessions: sessions.slice(0, limit), skipped };
|
|
245
250
|
}
|
|
251
|
+
/** Reads one project directory straight from disk, for cross-directory listing. */
|
|
252
|
+
async function summarizeProjectDir(dir, limit) {
|
|
253
|
+
let entries;
|
|
254
|
+
try {
|
|
255
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
if (error.code === 'ENOENT')
|
|
259
|
+
return { sessions: [], skipped: 0 };
|
|
260
|
+
return { sessions: [], skipped: 1 };
|
|
261
|
+
}
|
|
262
|
+
const sessions = [];
|
|
263
|
+
let skipped = 0;
|
|
264
|
+
for (const entry of entries) {
|
|
265
|
+
if (!entry.isFile() || !entry.name.endsWith('.json'))
|
|
266
|
+
continue;
|
|
267
|
+
const id = entry.name.slice(0, -'.json'.length);
|
|
268
|
+
if (!isSessionId(id)) {
|
|
269
|
+
skipped++;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const raw = await readFile(path.join(dir, entry.name), 'utf8');
|
|
274
|
+
sessions.push(summarize(parseSessionRecord(raw, id)));
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
skipped++;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
sessions.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
281
|
+
return { sessions: sessions.slice(0, limit), skipped };
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Lists sessions for `cwd` and every other directory found under the sessions
|
|
285
|
+
* root. Sessions are grouped by the cwd stored in each record, so a moved or
|
|
286
|
+
* copied project folder still lists under its recorded directory.
|
|
287
|
+
*/
|
|
288
|
+
export async function listAllSessions(cwd, limitPerDir = 20) {
|
|
289
|
+
const root = sessionsRoot();
|
|
290
|
+
let entries;
|
|
291
|
+
try {
|
|
292
|
+
entries = await readdir(root, { withFileTypes: true });
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
if (error.code === 'ENOENT') {
|
|
296
|
+
return { current: [], others: [], skipped: 0 };
|
|
297
|
+
}
|
|
298
|
+
throw new SessionError(`Could not list sessions: ${error.message}`);
|
|
299
|
+
}
|
|
300
|
+
const groups = new Map();
|
|
301
|
+
let skipped = 0;
|
|
302
|
+
for (const entry of entries) {
|
|
303
|
+
if (!entry.isDirectory())
|
|
304
|
+
continue;
|
|
305
|
+
const result = await summarizeProjectDir(path.join(root, entry.name), limitPerDir);
|
|
306
|
+
skipped += result.skipped;
|
|
307
|
+
for (const session of result.sessions) {
|
|
308
|
+
const list = groups.get(session.cwd);
|
|
309
|
+
if (list)
|
|
310
|
+
list.push(session);
|
|
311
|
+
else
|
|
312
|
+
groups.set(session.cwd, [session]);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const resolved = path.resolve(cwd);
|
|
316
|
+
const byUpdated = (left, right) => right.updatedAt.localeCompare(left.updatedAt);
|
|
317
|
+
const current = (groups.get(resolved) ?? []).sort(byUpdated).slice(0, limitPerDir);
|
|
318
|
+
groups.delete(resolved);
|
|
319
|
+
const others = [...groups.entries()]
|
|
320
|
+
.filter(([, sessions]) => sessions.length > 0)
|
|
321
|
+
.map(([dirCwd, sessions]) => ({
|
|
322
|
+
cwd: dirCwd,
|
|
323
|
+
sessions: sessions.sort(byUpdated).slice(0, limitPerDir),
|
|
324
|
+
}))
|
|
325
|
+
.sort((left, right) => (right.sessions[0]?.updatedAt ?? '').localeCompare(left.sessions[0]?.updatedAt ?? ''));
|
|
326
|
+
return { current, others, skipped };
|
|
327
|
+
}
|
|
246
328
|
export async function latestSession(cwd) {
|
|
247
329
|
const { sessions } = await listSessions(cwd, 1);
|
|
248
330
|
const newest = sessions[0];
|
package/dist/ui/App.js
CHANGED
|
@@ -12,7 +12,7 @@ import { applyOverrides, contextWindowFor, resolveProfile, saveConfig, } from '.
|
|
|
12
12
|
import { discoverModels, testConnection } from '../model/discovery.js';
|
|
13
13
|
import { runAddFlow, runEditFlow, runRemoveFlow, } from '../model/wizard.js';
|
|
14
14
|
import { createProvider } from '../providers/index.js';
|
|
15
|
-
import { dropIncompleteToolCalls, formatSessionTime, isSessionId, listSessions, loadSession, newSessionId, projectSessionsDir, saveSession, titleFromMessages, } from '../sessions.js';
|
|
15
|
+
import { dropIncompleteToolCalls, formatSessionTime, isSessionId, listAllSessions, listSessions, loadSession, newSessionId, projectSessionsDir, saveSession, titleFromMessages, } from '../sessions.js';
|
|
16
16
|
import { ApprovalPrompt } from './ApprovalPrompt.js';
|
|
17
17
|
import { ApprovalPolicy } from './approval-policy.js';
|
|
18
18
|
import { builtinCommandNames, buildSkillCommands, SLASH_COMMANDS, slashHelpLines, } from './commands.js';
|
|
@@ -23,6 +23,8 @@ import { Input } from './Input.js';
|
|
|
23
23
|
import { MessageList } from './MessageList.js';
|
|
24
24
|
import { MOUSE_OFF, MOUSE_ON } from './mouse.js';
|
|
25
25
|
import { ModelPicker } from './ModelPicker.js';
|
|
26
|
+
import { SessionPicker } from './SessionPicker.js';
|
|
27
|
+
import { SESSION_INLINE_ROWS, shortCwd } from './session-picker.js';
|
|
26
28
|
import { PICKER_INLINE_ROWS, pickerPopupRect, withProfileModel, withProfileModels, } from './model-picker.js';
|
|
27
29
|
import { formatProfileList } from './profile-list.js';
|
|
28
30
|
import { loadPromptHistory, recordPrompt } from './prompt-history.js';
|
|
@@ -84,6 +86,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
84
86
|
const [cancelling, setCancelling] = useState(false);
|
|
85
87
|
const [pendingApproval, setPendingApproval] = useState(null);
|
|
86
88
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
89
|
+
const [sessionPicker, setSessionPicker] = useState(null);
|
|
87
90
|
const [quitArmed, setQuitArmed] = useState(false);
|
|
88
91
|
const [palette, setPalette] = useState(null);
|
|
89
92
|
const [usageCardEnabled, setUsageCardEnabled] = useState(true);
|
|
@@ -492,6 +495,15 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
492
495
|
useEffect(() => {
|
|
493
496
|
void refreshSkillCommands();
|
|
494
497
|
}, [refreshSkillCommands]);
|
|
498
|
+
/** Loads the session list for the picker; other directories are grouped by cwd. */
|
|
499
|
+
const openSessionPicker = useCallback(async () => {
|
|
500
|
+
try {
|
|
501
|
+
setSessionPicker(await listAllSessions(cwd, 20));
|
|
502
|
+
}
|
|
503
|
+
catch (error) {
|
|
504
|
+
addNotice('error', error instanceof Error ? error.message : String(error));
|
|
505
|
+
}
|
|
506
|
+
}, [cwd, addNotice]);
|
|
495
507
|
/** Mentions once per run when the model pulls instructions that came from the repo. */
|
|
496
508
|
const noteProjectSkill = useCallback(async (rawArguments) => {
|
|
497
509
|
let name;
|
|
@@ -819,6 +831,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
819
831
|
'',
|
|
820
832
|
' Model subcommands: /model <name> · /model add · /model edit [name] ·',
|
|
821
833
|
' /model remove [name] · /model test [name] · /model list --remote',
|
|
834
|
+
' Sessions: /resume opens a picker; ←/→ switches between this directory and others.',
|
|
822
835
|
'',
|
|
823
836
|
'Keys: Enter sends · / opens commands · PgUp/PgDn scrolls · Ctrl+O expands tool output ·',
|
|
824
837
|
' Tab completes a command · Esc cancels a wizard step · /mouse toggles wheel scroll',
|
|
@@ -1002,27 +1015,42 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1002
1015
|
case '/resume': {
|
|
1003
1016
|
transitioningRef.current = true;
|
|
1004
1017
|
try {
|
|
1018
|
+
if (command === '/resume' && !argument) {
|
|
1019
|
+
await openSessionPicker();
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1005
1022
|
if (command === '/sessions' || !argument) {
|
|
1006
|
-
const
|
|
1007
|
-
listedSessionsRef.current =
|
|
1008
|
-
|
|
1023
|
+
const data = await listAllSessions(cwd, 10);
|
|
1024
|
+
listedSessionsRef.current = data.current;
|
|
1025
|
+
const otherCount = data.others.reduce((total, group) => total + group.sessions.length, 0);
|
|
1026
|
+
if (data.current.length === 0 && otherCount === 0) {
|
|
1009
1027
|
addNotice('info', `No saved sessions for this directory yet. Sessions are stored in ${projectSessionsDir(cwd)}.`);
|
|
1010
1028
|
}
|
|
1011
1029
|
else {
|
|
1012
|
-
const lines =
|
|
1030
|
+
const lines = ['Sessions (most recent first):'];
|
|
1031
|
+
lines.push(`This directory (${data.current.length}):`);
|
|
1032
|
+
if (data.current.length === 0)
|
|
1033
|
+
lines.push(' (none)');
|
|
1034
|
+
data.current.forEach((session, index) => {
|
|
1013
1035
|
const marker = session.id === sessionRef.current?.id ? '*' : ' ';
|
|
1014
1036
|
const messages = `${session.messageCount} msg${session.messageCount === 1 ? '' : 's'}`;
|
|
1015
|
-
|
|
1037
|
+
lines.push(`${marker} ${index + 1}. ${session.id} ${formatSessionTime(session.updatedAt)} ${messages} ${session.title}`);
|
|
1016
1038
|
});
|
|
1017
|
-
|
|
1018
|
-
'
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1039
|
+
if (otherCount > 0) {
|
|
1040
|
+
lines.push('Other directories:');
|
|
1041
|
+
for (const group of data.others) {
|
|
1042
|
+
lines.push(` ${shortCwd(group.cwd, cwd)}`);
|
|
1043
|
+
for (const session of group.sessions) {
|
|
1044
|
+
const messages = `${session.messageCount} msg${session.messageCount === 1 ? '' : 's'}`;
|
|
1045
|
+
lines.push(` ${session.id} ${formatSessionTime(session.updatedAt)} ${messages} ${session.title}`);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
lines.push('', 'Use /resume to pick a session, or /resume <number|id> for this directory.');
|
|
1050
|
+
addNotice('info', lines.join('\n'));
|
|
1023
1051
|
}
|
|
1024
|
-
if (skipped > 0) {
|
|
1025
|
-
addNotice('muted', `Skipped ${skipped} unreadable session file${skipped === 1 ? '' : 's'}.`);
|
|
1052
|
+
if (data.skipped > 0) {
|
|
1053
|
+
addNotice('muted', `Skipped ${data.skipped} unreadable session file${data.skipped === 1 ? '' : 's'}.`);
|
|
1026
1054
|
}
|
|
1027
1055
|
return;
|
|
1028
1056
|
}
|
|
@@ -1226,6 +1254,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1226
1254
|
cwd,
|
|
1227
1255
|
listRemoteModels,
|
|
1228
1256
|
mouseOn,
|
|
1257
|
+
openSessionPicker,
|
|
1229
1258
|
persistSession,
|
|
1230
1259
|
profileName,
|
|
1231
1260
|
quit,
|
|
@@ -1239,6 +1268,15 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1239
1268
|
version,
|
|
1240
1269
|
yolo,
|
|
1241
1270
|
]);
|
|
1271
|
+
/** Resumes a picker selection only when it belongs to the current directory. */
|
|
1272
|
+
const handleSessionPick = (session) => {
|
|
1273
|
+
setSessionPicker(null);
|
|
1274
|
+
if (path.resolve(session.cwd) !== path.resolve(cwd)) {
|
|
1275
|
+
addNotice('info', `Session ${session.id} belongs to ${shortCwd(session.cwd, cwd)}. Start kiro in that directory to resume it.`);
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
void handleCommand(`/resume ${session.id}`);
|
|
1279
|
+
};
|
|
1242
1280
|
/** Runs the next queued item once the app is idle, including queued slash commands. */
|
|
1243
1281
|
const drainQueue = useCallback(() => {
|
|
1244
1282
|
if (busyRef.current ||
|
|
@@ -1326,7 +1364,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1326
1364
|
if (key.ctrl && input === 'o') {
|
|
1327
1365
|
if (wizardActiveRef.current || wizardPromptRef.current || pendingApprovalRef.current)
|
|
1328
1366
|
return;
|
|
1329
|
-
if (pickerOpen)
|
|
1367
|
+
if (pickerOpen || sessionPicker !== null)
|
|
1330
1368
|
return;
|
|
1331
1369
|
expandLastToolOutput();
|
|
1332
1370
|
return;
|
|
@@ -1338,6 +1376,11 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1338
1376
|
setPickerOpen(false);
|
|
1339
1377
|
return;
|
|
1340
1378
|
}
|
|
1379
|
+
if (sessionPicker !== null) {
|
|
1380
|
+
disarmQuit();
|
|
1381
|
+
setSessionPicker(null);
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1341
1384
|
if (wizardActiveRef.current) {
|
|
1342
1385
|
disarmQuit();
|
|
1343
1386
|
cancelWizard();
|
|
@@ -1381,26 +1424,32 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1381
1424
|
: null;
|
|
1382
1425
|
const activeProfile = runtimeConfig.profiles[profileName];
|
|
1383
1426
|
const contextWindow = contextWindowFor(activeProfile);
|
|
1384
|
-
const pickerPopup = pickerOpen
|
|
1427
|
+
const pickerPopup = (pickerOpen || sessionPicker !== null) && !pendingApproval
|
|
1428
|
+
? pickerPopupRect(columns, rows)
|
|
1429
|
+
: null;
|
|
1385
1430
|
const pickerInline = pickerOpen && !pendingApproval && pickerPopup === null;
|
|
1386
|
-
const
|
|
1431
|
+
const sessionInline = sessionPicker !== null && !pendingApproval && pickerPopup === null && !pickerOpen;
|
|
1432
|
+
const extraInputRows = pendingApproval || pickerInline || sessionInline ? 0 : Math.max(0, inputRows - 1);
|
|
1387
1433
|
const viewportHeight = Math.max(3, rows -
|
|
1388
1434
|
5 -
|
|
1389
1435
|
extraInputRows -
|
|
1390
1436
|
(pendingApproval ? 12 : 0) -
|
|
1391
|
-
(pickerInline ? PICKER_INLINE_ROWS : 0)
|
|
1437
|
+
(pickerInline ? PICKER_INLINE_ROWS : 0) -
|
|
1438
|
+
(sessionInline ? SESSION_INLINE_ROWS : 0));
|
|
1392
1439
|
const showUsageCard = usageCardEnabled && shouldShowUsageCard(columns, viewportHeight);
|
|
1393
1440
|
const chatWidth = showUsageCard ? Math.max(40, width - USAGE_CARD_WIDTH - USAGE_CARD_GAP) : width;
|
|
1394
|
-
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-end", width: width, children: [_jsx(MessageList, { items: items, width: chatWidth, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), showUsageCard ? (_jsx(Box, { marginLeft: USAGE_CARD_GAP, flexShrink: 0, children: _jsx(UsageCard, { usage: sessionUsage, contextTokens: contextTokens, contextWindow: contextWindow, contextEstimated: usageRef.current === null, lastReply: lastReply, busy: busy }) })) : null] }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerInline ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : (_jsx(Input, { disabled: pickerOpen, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, fileMenu: !wizardActive && !wizardPrompt, loadFiles: loadFileIndex, maxRows: Math.max(1, Math.min(6, rows - 9)), history: wizardPrompt || wizardActive ? undefined : promptHistory, slashCommands: [...SLASH_COMMANDS, ...skillCommands], onPaletteChange: setPalette, onHeightChange: setInputRows, placeholder: pickerOpen
|
|
1441
|
+
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-end", width: width, children: [_jsx(MessageList, { items: items, width: chatWidth, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && sessionPicker === null && !wizardActive && wizardPrompt === null }), showUsageCard ? (_jsx(Box, { marginLeft: USAGE_CARD_GAP, flexShrink: 0, children: _jsx(UsageCard, { usage: sessionUsage, contextTokens: contextTokens, contextWindow: contextWindow, contextEstimated: usageRef.current === null, lastReply: lastReply, busy: busy }) })) : null] }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerInline ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : sessionInline && sessionPicker ? (_jsx(SessionPicker, { cwd: cwd, data: sessionPicker, activeSessionId: sessionRef.current?.id ?? null, width: width, onSelect: handleSessionPick, onCancel: () => setSessionPicker(null) })) : (_jsx(Input, { disabled: pickerOpen || sessionPicker !== null, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, fileMenu: !wizardActive && !wizardPrompt, loadFiles: loadFileIndex, maxRows: Math.max(1, Math.min(6, rows - 9)), history: wizardPrompt || wizardActive ? undefined : promptHistory, slashCommands: [...SLASH_COMMANDS, ...skillCommands], onPaletteChange: setPalette, onHeightChange: setInputRows, placeholder: pickerOpen
|
|
1395
1442
|
? 'Model picker open · Esc to close'
|
|
1396
|
-
:
|
|
1397
|
-
?
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
:
|
|
1403
|
-
? '
|
|
1404
|
-
:
|
|
1443
|
+
: sessionPicker
|
|
1444
|
+
? 'Session picker open · Esc to close'
|
|
1445
|
+
: wizardPrompt
|
|
1446
|
+
? wizardPrompt.defaultValue && !wizardPrompt.mask
|
|
1447
|
+
? `${wizardPrompt.label} [${wizardPrompt.defaultValue}]`
|
|
1448
|
+
: wizardPrompt.label
|
|
1449
|
+
: busy
|
|
1450
|
+
? 'Kiro is working… type ahead, or Ctrl+C to cancel'
|
|
1451
|
+
: wizardActive
|
|
1452
|
+
? 'Working… Esc to cancel'
|
|
1453
|
+
: '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, quitHint: quitArmed, contextTokens: showUsageCard ? undefined : contextTokens, contextWindow: showUsageCard ? undefined : contextWindow }), pickerOpen && pickerPopup ? (_jsx(Box, { position: "absolute", marginTop: pickerPopup.top, marginLeft: pickerPopup.left, children: _jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: pickerPopup.width, height: pickerPopup.height, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) }) })) : sessionPicker && pickerPopup ? (_jsx(Box, { position: "absolute", marginTop: pickerPopup.top, marginLeft: pickerPopup.left, children: _jsx(SessionPicker, { cwd: cwd, data: sessionPicker, activeSessionId: sessionRef.current?.id ?? null, width: pickerPopup.width, height: pickerPopup.height, onSelect: handleSessionPick, onCancel: () => setSessionPicker(null) }) })) : null] }));
|
|
1405
1454
|
}
|
|
1406
1455
|
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
4
|
+
import { pickerPopupRows, pickerRangeLabel, pickerWindow } from './model-picker.js';
|
|
5
|
+
import { buildSessionRows, sessionCounts, sessionEmptyText, sessionRange, sessionRowItems, sessionRowLines, sessionRowText, sessionTabLabel, } from './session-picker.js';
|
|
6
|
+
/** Keys are highlighted so the hint reads at a glance; the rest stays dim. */
|
|
7
|
+
const KEY_COLOR = '#ff9e64';
|
|
8
|
+
function Key({ children }) {
|
|
9
|
+
return _jsx(Text, { color: KEY_COLOR, children: children });
|
|
10
|
+
}
|
|
11
|
+
function Said({ children }) {
|
|
12
|
+
return _jsx(Text, { dimColor: true, children: children });
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Session picker with two tabs: the current directory and every other
|
|
16
|
+
* directory that has saved sessions. Left/right switch tabs.
|
|
17
|
+
*/
|
|
18
|
+
export function SessionPicker({ cwd, data, activeSessionId = null, width, maxRows = 8, height, onSelect, onCancel, }) {
|
|
19
|
+
const [scope, setScope] = useState('current');
|
|
20
|
+
const [index, setIndex] = useState(0);
|
|
21
|
+
const [query, setQuery] = useState('');
|
|
22
|
+
const counts = sessionCounts(data);
|
|
23
|
+
const rows = buildSessionRows(data, scope, cwd, query);
|
|
24
|
+
const lines = sessionRowLines(rows);
|
|
25
|
+
const sessions = sessionRowItems(rows);
|
|
26
|
+
const count = sessions.length;
|
|
27
|
+
const selected = Math.min(index, Math.max(0, count - 1));
|
|
28
|
+
const selectedLine = lines[selected] ?? 0;
|
|
29
|
+
const popup = height !== undefined;
|
|
30
|
+
const hintRows = scope === 'others' ? 1 : 0;
|
|
31
|
+
// The tab bar takes one row the model picker does not have.
|
|
32
|
+
const listRows = popup ? pickerPopupRows(height, hintRows + 1) : maxRows;
|
|
33
|
+
const { start, end } = pickerWindow(selectedLine, rows.length, listRows);
|
|
34
|
+
const range = popup ? sessionRange(rows, start, end) : null;
|
|
35
|
+
const empty = sessionEmptyText(scope, query, count > 0);
|
|
36
|
+
// The opaque frame needs an explicit foreground even on light terminal themes.
|
|
37
|
+
const base = popup ? 'white' : undefined;
|
|
38
|
+
const switchScope = (next) => {
|
|
39
|
+
if (next === scope)
|
|
40
|
+
return;
|
|
41
|
+
setScope(next);
|
|
42
|
+
setIndex(0);
|
|
43
|
+
setQuery('');
|
|
44
|
+
};
|
|
45
|
+
useInput((input, key) => {
|
|
46
|
+
if (key.leftArrow) {
|
|
47
|
+
switchScope('current');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (key.rightArrow) {
|
|
51
|
+
switchScope('others');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (key.tab) {
|
|
55
|
+
switchScope(scope === 'current' ? 'others' : 'current');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (key.escape) {
|
|
59
|
+
if (query) {
|
|
60
|
+
setQuery('');
|
|
61
|
+
setIndex(0);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
onCancel();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (key.upArrow || key.downArrow) {
|
|
68
|
+
if (count === 0)
|
|
69
|
+
return;
|
|
70
|
+
const delta = key.upArrow ? -1 : 1;
|
|
71
|
+
setIndex(Math.min(count - 1, Math.max(0, selected + delta)));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (key.home) {
|
|
75
|
+
setIndex(0);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (key.end) {
|
|
79
|
+
setIndex(Math.max(0, count - 1));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!key.return) {
|
|
83
|
+
if (key.backspace || key.delete) {
|
|
84
|
+
if (query) {
|
|
85
|
+
setQuery(query.slice(0, -1));
|
|
86
|
+
setIndex(0);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (key.ctrl || key.meta || key.pageUp || key.pageDown)
|
|
91
|
+
return;
|
|
92
|
+
const typed = input.replace(/[\u0000-\u001f\u007f]/g, '');
|
|
93
|
+
if (typed) {
|
|
94
|
+
setQuery(query + typed);
|
|
95
|
+
setIndex(0);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const session = sessions[selected];
|
|
100
|
+
if (session)
|
|
101
|
+
onSelect(session);
|
|
102
|
+
});
|
|
103
|
+
return (_jsxs(Box, { flexDirection: "column", width: width, height: height, borderStyle: "round", borderColor: "cyan", paddingX: 1, flexShrink: 0, backgroundColor: popup ? 'black' : undefined, overflow: height === undefined ? undefined : 'hidden', children: [_jsx(Text, { bold: true, color: "cyan", wrap: "truncate-end", children: "Sessions" }), _jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Text, { inverse: scope === 'current', color: scope === 'current' ? 'cyan' : base, children: ` ${sessionTabLabel('current', counts)} ` }), _jsx(Said, { children: " " }), _jsx(Text, { inverse: scope === 'others', color: scope === 'others' ? 'cyan' : base, children: ` ${sessionTabLabel('others', counts)} ` })] }), _jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Said, { children: "Search: " }), query || _jsx(Said, { children: "type to filter" })] }), rows.slice(start, end).map((row, offset) => {
|
|
104
|
+
const line = start + offset;
|
|
105
|
+
if (row.kind === 'header') {
|
|
106
|
+
return (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: row.text }, `h${line}`));
|
|
107
|
+
}
|
|
108
|
+
const focused = line === selectedLine;
|
|
109
|
+
return (_jsx(Text, { color: focused ? 'cyan' : base, bold: focused, wrap: "truncate-end", children: sessionRowText(row.session, row.session.id === activeSessionId) }, `s${line}`));
|
|
110
|
+
}), empty ? (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: empty })) : null, scope === 'others' ? (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: "Enter shows the directory to resume from." })) : null, range ? (_jsx(Text, { dimColor: true, color: base, wrap: "truncate-end", children: pickerRangeLabel(range) })) : null, height === undefined ? null : _jsx(Box, { flexGrow: 1 }), _jsxs(Text, { color: base, wrap: "truncate-end", children: [_jsx(Key, { children: "\u2190/\u2192" }), _jsx(Said, { children: " tab \u00B7 " }), _jsx(Key, { children: "\u2191/\u2193" }), _jsx(Said, { children: " move \u00B7 " }), _jsx(Key, { children: "Enter" }), _jsx(Said, { children: " resume \u00B7 " }), _jsx(Key, { children: "Esc" }), _jsx(Said, { children: ` ${query ? 'clear search' : 'close'}` })] })] }));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=SessionPicker.js.map
|
package/dist/ui/commands.js
CHANGED
|
@@ -6,8 +6,8 @@ export const SLASH_COMMANDS = [
|
|
|
6
6
|
{ name: '/context', description: 'show approximate context usage' },
|
|
7
7
|
{ name: '/usage', description: 'show or hide the usage card' },
|
|
8
8
|
{ name: '/compact', description: 'summarize older turns to free context' },
|
|
9
|
-
{ name: '/sessions', description: 'list saved sessions
|
|
10
|
-
{ name: '/resume', usage: '
|
|
9
|
+
{ name: '/sessions', description: 'list saved sessions, this directory and others' },
|
|
10
|
+
{ name: '/resume', usage: '[n | id]', description: 'open the session picker, or resume by number or id' },
|
|
11
11
|
{ name: '/undo', description: 'revert the last file change Kiro made (write/edit/patch)' },
|
|
12
12
|
{ name: '/clear', description: 'start a new session' },
|
|
13
13
|
{ name: '/export', usage: '[file]', description: 'write the transcript to a Markdown file' },
|