@ywldan/kiro 0.3.0 → 0.3.2
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 +154 -58
- package/dist/ui/SessionPicker.js +112 -0
- package/dist/ui/commands.js +2 -2
- package/dist/ui/session-picker.js +96 -0
- package/dist/version.js +4 -1
- 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';
|
|
@@ -50,11 +52,13 @@ function useTerminalSize() {
|
|
|
50
52
|
}, [stdout, read]);
|
|
51
53
|
return size;
|
|
52
54
|
}
|
|
53
|
-
export function App({ config, baseConfig, overrides, configPath, configCreated, cwd, version, yolo, mouseEnabled, initialSession, startupNotices, }) {
|
|
55
|
+
export function App({ config, baseConfig, overrides, configPath, configCreated, cwd: initialCwd, version, yolo, mouseEnabled, initialSession, startupNotices, }) {
|
|
54
56
|
const { exit } = useApp();
|
|
55
57
|
const { stdout } = useStdout();
|
|
56
58
|
const { columns, rows } = useTerminalSize();
|
|
57
59
|
const width = Math.max(20, columns - 2);
|
|
60
|
+
/** Changes when a session from another directory is resumed. */
|
|
61
|
+
const [cwd, setCwd] = useState(initialCwd);
|
|
58
62
|
const initialViewRef = useRef(null);
|
|
59
63
|
if (initialViewRef.current === null) {
|
|
60
64
|
const view = initialSession
|
|
@@ -84,6 +88,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
84
88
|
const [cancelling, setCancelling] = useState(false);
|
|
85
89
|
const [pendingApproval, setPendingApproval] = useState(null);
|
|
86
90
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
91
|
+
const [sessionPicker, setSessionPicker] = useState(null);
|
|
87
92
|
const [quitArmed, setQuitArmed] = useState(false);
|
|
88
93
|
const [palette, setPalette] = useState(null);
|
|
89
94
|
const [usageCardEnabled, setUsageCardEnabled] = useState(true);
|
|
@@ -492,6 +497,15 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
492
497
|
useEffect(() => {
|
|
493
498
|
void refreshSkillCommands();
|
|
494
499
|
}, [refreshSkillCommands]);
|
|
500
|
+
/** Loads the session list for the picker; other directories are grouped by cwd. */
|
|
501
|
+
const openSessionPicker = useCallback(async () => {
|
|
502
|
+
try {
|
|
503
|
+
setSessionPicker(await listAllSessions(cwd, 20));
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
addNotice('error', error instanceof Error ? error.message : String(error));
|
|
507
|
+
}
|
|
508
|
+
}, [cwd, addNotice]);
|
|
495
509
|
/** Mentions once per run when the model pulls instructions that came from the repo. */
|
|
496
510
|
const noteProjectSkill = useCallback(async (rawArguments) => {
|
|
497
511
|
let name;
|
|
@@ -804,6 +818,43 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
804
818
|
}
|
|
805
819
|
addNotice('muted', 'No finished tool output to expand yet.');
|
|
806
820
|
}, [addNotice, expandedToolId, items]);
|
|
821
|
+
/** Loads a session record into the UI, switching the working directory when needed. */
|
|
822
|
+
const applySessionRecord = useCallback(async (record) => {
|
|
823
|
+
await persistSession();
|
|
824
|
+
await saveChainRef.current;
|
|
825
|
+
const directory = path.resolve(record.cwd);
|
|
826
|
+
messagesRef.current = record.messages.filter((message) => message.role !== 'system');
|
|
827
|
+
usageRef.current = null;
|
|
828
|
+
const restoredUsage = record.usage ?? EMPTY_USAGE;
|
|
829
|
+
sessionUsageRef.current = restoredUsage;
|
|
830
|
+
setSessionUsage(restoredUsage);
|
|
831
|
+
setLastReply(null);
|
|
832
|
+
recomputeContext();
|
|
833
|
+
sessionRef.current = {
|
|
834
|
+
id: record.id,
|
|
835
|
+
createdAt: record.createdAt,
|
|
836
|
+
title: record.title,
|
|
837
|
+
};
|
|
838
|
+
const view = buildResumedView(messagesRef.current, {
|
|
839
|
+
cwd: directory,
|
|
840
|
+
version,
|
|
841
|
+
sessionId: record.id,
|
|
842
|
+
});
|
|
843
|
+
setItems(view.items);
|
|
844
|
+
nextItemIdRef.current = view.nextId;
|
|
845
|
+
setResetSignal((current) => current + 1);
|
|
846
|
+
setExpandedToolId(null);
|
|
847
|
+
resetAutoAllowed();
|
|
848
|
+
listedSessionsRef.current = null;
|
|
849
|
+
if (directory !== path.resolve(cwd)) {
|
|
850
|
+
setCwd(directory);
|
|
851
|
+
addNotice('info', `Resumed session ${record.id} from ${shortCwd(directory, initialCwd)}. ` +
|
|
852
|
+
`Working directory is now ${shortCwd(directory, initialCwd)}.`);
|
|
853
|
+
}
|
|
854
|
+
if (record.profile && record.profile !== profileName) {
|
|
855
|
+
addNotice('muted', `Session was saved with profile "${record.profile}"; staying on "${profileName}". Use /model ${record.profile} to switch.`);
|
|
856
|
+
}
|
|
857
|
+
}, [addNotice, cwd, initialCwd, persistSession, profileName, recomputeContext, resetAutoAllowed, version]);
|
|
807
858
|
const handleCommand = useCallback(async (input) => {
|
|
808
859
|
if (busyRef.current || transitioningRef.current)
|
|
809
860
|
return;
|
|
@@ -819,6 +870,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
819
870
|
'',
|
|
820
871
|
' Model subcommands: /model <name> · /model add · /model edit [name] ·',
|
|
821
872
|
' /model remove [name] · /model test [name] · /model list --remote',
|
|
873
|
+
' Sessions: /resume opens a picker; ←/→ switches between this directory and others.',
|
|
822
874
|
'',
|
|
823
875
|
'Keys: Enter sends · / opens commands · PgUp/PgDn scrolls · Ctrl+O expands tool output ·',
|
|
824
876
|
' Tab completes a command · Esc cancels a wizard step · /mouse toggles wheel scroll',
|
|
@@ -1002,27 +1054,42 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1002
1054
|
case '/resume': {
|
|
1003
1055
|
transitioningRef.current = true;
|
|
1004
1056
|
try {
|
|
1057
|
+
if (command === '/resume' && !argument) {
|
|
1058
|
+
await openSessionPicker();
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1005
1061
|
if (command === '/sessions' || !argument) {
|
|
1006
|
-
const
|
|
1007
|
-
listedSessionsRef.current =
|
|
1008
|
-
|
|
1062
|
+
const data = await listAllSessions(cwd, 10);
|
|
1063
|
+
listedSessionsRef.current = data.current;
|
|
1064
|
+
const otherCount = data.others.reduce((total, group) => total + group.sessions.length, 0);
|
|
1065
|
+
if (data.current.length === 0 && otherCount === 0) {
|
|
1009
1066
|
addNotice('info', `No saved sessions for this directory yet. Sessions are stored in ${projectSessionsDir(cwd)}.`);
|
|
1010
1067
|
}
|
|
1011
1068
|
else {
|
|
1012
|
-
const lines =
|
|
1069
|
+
const lines = ['Sessions (most recent first):'];
|
|
1070
|
+
lines.push(`This directory (${data.current.length}):`);
|
|
1071
|
+
if (data.current.length === 0)
|
|
1072
|
+
lines.push(' (none)');
|
|
1073
|
+
data.current.forEach((session, index) => {
|
|
1013
1074
|
const marker = session.id === sessionRef.current?.id ? '*' : ' ';
|
|
1014
1075
|
const messages = `${session.messageCount} msg${session.messageCount === 1 ? '' : 's'}`;
|
|
1015
|
-
|
|
1076
|
+
lines.push(`${marker} ${index + 1}. ${session.id} ${formatSessionTime(session.updatedAt)} ${messages} ${session.title}`);
|
|
1016
1077
|
});
|
|
1017
|
-
|
|
1018
|
-
'
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1078
|
+
if (otherCount > 0) {
|
|
1079
|
+
lines.push('Other directories:');
|
|
1080
|
+
for (const group of data.others) {
|
|
1081
|
+
lines.push(` ${shortCwd(group.cwd, cwd)}`);
|
|
1082
|
+
for (const session of group.sessions) {
|
|
1083
|
+
const messages = `${session.messageCount} msg${session.messageCount === 1 ? '' : 's'}`;
|
|
1084
|
+
lines.push(` ${session.id} ${formatSessionTime(session.updatedAt)} ${messages} ${session.title}`);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
lines.push('', 'Use /resume to pick a session, or /resume <number|id> for this directory.');
|
|
1089
|
+
addNotice('info', lines.join('\n'));
|
|
1023
1090
|
}
|
|
1024
|
-
if (skipped > 0) {
|
|
1025
|
-
addNotice('muted', `Skipped ${skipped} unreadable session file${skipped === 1 ? '' : 's'}.`);
|
|
1091
|
+
if (data.skipped > 0) {
|
|
1092
|
+
addNotice('muted', `Skipped ${data.skipped} unreadable session file${data.skipped === 1 ? '' : 's'}.`);
|
|
1026
1093
|
}
|
|
1027
1094
|
return;
|
|
1028
1095
|
}
|
|
@@ -1047,6 +1114,26 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1047
1114
|
target = matches[0];
|
|
1048
1115
|
}
|
|
1049
1116
|
}
|
|
1117
|
+
if (!target && !numeric && isSessionId(argument)) {
|
|
1118
|
+
// Search the other project directories before giving up.
|
|
1119
|
+
const all = await listAllSessions(cwd, 20);
|
|
1120
|
+
const candidates = all.others
|
|
1121
|
+
.flatMap((group) => group.sessions)
|
|
1122
|
+
.filter((session) => session.id === argument || session.id.startsWith(argument));
|
|
1123
|
+
if (candidates.length > 1) {
|
|
1124
|
+
addNotice('error', `Session id "${argument}" is ambiguous; use more characters.`);
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
const foreign = candidates[0];
|
|
1128
|
+
if (foreign) {
|
|
1129
|
+
if (foreign.id === sessionRef.current?.id) {
|
|
1130
|
+
addNotice('info', `Session ${foreign.id} is already active.`);
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
await applySessionRecord(await loadSession(foreign.cwd, foreign.id));
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1050
1137
|
if (!target && (numeric || !isSessionId(argument))) {
|
|
1051
1138
|
addNotice('error', `No saved session matches "${argument}". Use /sessions to list them.`);
|
|
1052
1139
|
return;
|
|
@@ -1056,34 +1143,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1056
1143
|
addNotice('info', `Session ${targetId} is already active.`);
|
|
1057
1144
|
return;
|
|
1058
1145
|
}
|
|
1059
|
-
await
|
|
1060
|
-
await saveChainRef.current;
|
|
1061
|
-
const record = await loadSession(cwd, targetId);
|
|
1062
|
-
messagesRef.current = record.messages.filter((message) => message.role !== 'system');
|
|
1063
|
-
usageRef.current = null;
|
|
1064
|
-
const restoredUsage = record.usage ?? EMPTY_USAGE;
|
|
1065
|
-
sessionUsageRef.current = restoredUsage;
|
|
1066
|
-
setSessionUsage(restoredUsage);
|
|
1067
|
-
setLastReply(null);
|
|
1068
|
-
recomputeContext();
|
|
1069
|
-
sessionRef.current = {
|
|
1070
|
-
id: record.id,
|
|
1071
|
-
createdAt: record.createdAt,
|
|
1072
|
-
title: record.title,
|
|
1073
|
-
};
|
|
1074
|
-
const view = buildResumedView(messagesRef.current, {
|
|
1075
|
-
cwd,
|
|
1076
|
-
version,
|
|
1077
|
-
sessionId: record.id,
|
|
1078
|
-
});
|
|
1079
|
-
setItems(view.items);
|
|
1080
|
-
nextItemIdRef.current = view.nextId;
|
|
1081
|
-
setResetSignal((current) => current + 1);
|
|
1082
|
-
setExpandedToolId(null);
|
|
1083
|
-
resetAutoAllowed();
|
|
1084
|
-
if (record.profile && record.profile !== profileName) {
|
|
1085
|
-
addNotice('muted', `Session was saved with profile "${record.profile}"; staying on "${profileName}". Use /model ${record.profile} to switch.`);
|
|
1086
|
-
}
|
|
1146
|
+
await applySessionRecord(await loadSession(cwd, targetId));
|
|
1087
1147
|
}
|
|
1088
1148
|
catch (error) {
|
|
1089
1149
|
addNotice('error', error instanceof Error ? error.message : String(error));
|
|
@@ -1222,10 +1282,12 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1222
1282
|
}
|
|
1223
1283
|
}, [
|
|
1224
1284
|
addNotice,
|
|
1285
|
+
applySessionRecord,
|
|
1225
1286
|
autoAllowed,
|
|
1226
1287
|
cwd,
|
|
1227
1288
|
listRemoteModels,
|
|
1228
1289
|
mouseOn,
|
|
1290
|
+
openSessionPicker,
|
|
1229
1291
|
persistSession,
|
|
1230
1292
|
profileName,
|
|
1231
1293
|
quit,
|
|
@@ -1239,6 +1301,26 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1239
1301
|
version,
|
|
1240
1302
|
yolo,
|
|
1241
1303
|
]);
|
|
1304
|
+
/** Resumes a picker selection, switching directories when the session came from elsewhere. */
|
|
1305
|
+
const handleSessionPick = (session) => {
|
|
1306
|
+
setSessionPicker(null);
|
|
1307
|
+
if (session.id === sessionRef.current?.id) {
|
|
1308
|
+
addNotice('info', `Session ${session.id} is already active.`);
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
transitioningRef.current = true;
|
|
1312
|
+
void (async () => {
|
|
1313
|
+
try {
|
|
1314
|
+
await applySessionRecord(await loadSession(session.cwd, session.id));
|
|
1315
|
+
}
|
|
1316
|
+
catch (error) {
|
|
1317
|
+
addNotice('error', error instanceof Error ? error.message : String(error));
|
|
1318
|
+
}
|
|
1319
|
+
finally {
|
|
1320
|
+
transitioningRef.current = false;
|
|
1321
|
+
}
|
|
1322
|
+
})();
|
|
1323
|
+
};
|
|
1242
1324
|
/** Runs the next queued item once the app is idle, including queued slash commands. */
|
|
1243
1325
|
const drainQueue = useCallback(() => {
|
|
1244
1326
|
if (busyRef.current ||
|
|
@@ -1295,7 +1377,6 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1295
1377
|
if (configCreated) {
|
|
1296
1378
|
addNotice('info', `Created config template at ${configPath}. Set your endpoint, model, and API key.`);
|
|
1297
1379
|
}
|
|
1298
|
-
void loadPromptHistory(cwd).then(setPromptHistory);
|
|
1299
1380
|
const active = config.profiles[config.activeProfile];
|
|
1300
1381
|
if (active) {
|
|
1301
1382
|
if (active.type !== 'openai') {
|
|
@@ -1313,6 +1394,10 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1313
1394
|
// Startup notices only.
|
|
1314
1395
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1315
1396
|
}, []);
|
|
1397
|
+
/** History is per directory, so a resumed session reloads it. */
|
|
1398
|
+
useEffect(() => {
|
|
1399
|
+
void loadPromptHistory(cwd).then(setPromptHistory);
|
|
1400
|
+
}, [cwd]);
|
|
1316
1401
|
useEffect(() => {
|
|
1317
1402
|
if (!stdout.isTTY)
|
|
1318
1403
|
return;
|
|
@@ -1326,7 +1411,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1326
1411
|
if (key.ctrl && input === 'o') {
|
|
1327
1412
|
if (wizardActiveRef.current || wizardPromptRef.current || pendingApprovalRef.current)
|
|
1328
1413
|
return;
|
|
1329
|
-
if (pickerOpen)
|
|
1414
|
+
if (pickerOpen || sessionPicker !== null)
|
|
1330
1415
|
return;
|
|
1331
1416
|
expandLastToolOutput();
|
|
1332
1417
|
return;
|
|
@@ -1338,6 +1423,11 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1338
1423
|
setPickerOpen(false);
|
|
1339
1424
|
return;
|
|
1340
1425
|
}
|
|
1426
|
+
if (sessionPicker !== null) {
|
|
1427
|
+
disarmQuit();
|
|
1428
|
+
setSessionPicker(null);
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1341
1431
|
if (wizardActiveRef.current) {
|
|
1342
1432
|
disarmQuit();
|
|
1343
1433
|
cancelWizard();
|
|
@@ -1381,26 +1471,32 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1381
1471
|
: null;
|
|
1382
1472
|
const activeProfile = runtimeConfig.profiles[profileName];
|
|
1383
1473
|
const contextWindow = contextWindowFor(activeProfile);
|
|
1384
|
-
const pickerPopup = pickerOpen
|
|
1474
|
+
const pickerPopup = (pickerOpen || sessionPicker !== null) && !pendingApproval
|
|
1475
|
+
? pickerPopupRect(columns, rows)
|
|
1476
|
+
: null;
|
|
1385
1477
|
const pickerInline = pickerOpen && !pendingApproval && pickerPopup === null;
|
|
1386
|
-
const
|
|
1478
|
+
const sessionInline = sessionPicker !== null && !pendingApproval && pickerPopup === null && !pickerOpen;
|
|
1479
|
+
const extraInputRows = pendingApproval || pickerInline || sessionInline ? 0 : Math.max(0, inputRows - 1);
|
|
1387
1480
|
const viewportHeight = Math.max(3, rows -
|
|
1388
1481
|
5 -
|
|
1389
1482
|
extraInputRows -
|
|
1390
1483
|
(pendingApproval ? 12 : 0) -
|
|
1391
|
-
(pickerInline ? PICKER_INLINE_ROWS : 0)
|
|
1484
|
+
(pickerInline ? PICKER_INLINE_ROWS : 0) -
|
|
1485
|
+
(sessionInline ? SESSION_INLINE_ROWS : 0));
|
|
1392
1486
|
const showUsageCard = usageCardEnabled && shouldShowUsageCard(columns, viewportHeight);
|
|
1393
1487
|
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
|
|
1488
|
+
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
1489
|
? 'Model picker open · Esc to close'
|
|
1396
|
-
:
|
|
1397
|
-
?
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
:
|
|
1403
|
-
? '
|
|
1404
|
-
:
|
|
1490
|
+
: sessionPicker
|
|
1491
|
+
? 'Session picker open · Esc to close'
|
|
1492
|
+
: wizardPrompt
|
|
1493
|
+
? wizardPrompt.defaultValue && !wizardPrompt.mask
|
|
1494
|
+
? `${wizardPrompt.label} [${wizardPrompt.defaultValue}]`
|
|
1495
|
+
: wizardPrompt.label
|
|
1496
|
+
: busy
|
|
1497
|
+
? 'Kiro is working… type ahead, or Ctrl+C to cancel'
|
|
1498
|
+
: wizardActive
|
|
1499
|
+
? 'Working… Esc to cancel'
|
|
1500
|
+
: '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
1501
|
}
|
|
1406
1502
|
//# sourceMappingURL=App.js.map
|