@ywldan/kiro 0.3.1 → 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 CHANGED
@@ -366,7 +366,7 @@ kiro --continue # most recent session for this directory
366
366
  kiro --resume <id> # a specific session
367
367
  ```
368
368
 
369
- `/sessions` and `/resume <n|id>` do the same from inside the TUI. `/resume` without arguments opens a picker with two tabs: `This directory` and `Other directories`, grouped by folder. Use `←`/`→` to switch tabs, `↑`/`↓` to move, type to filter by title, id, or path, `Enter` to resume, and `Esc` to close. Sessions from other directories are listed with their folder; selecting one shows where to start Kiro to resume it, because tool calls always run in the current working directory. `/clear` starts a new session without deleting the old one. Kiro does not auto-resume; without a flag it starts fresh.
369
+ `/sessions` and `/resume <n|id>` do the same from inside the TUI. `/resume` without arguments opens a picker with two tabs: `This directory` and `Other directories`, grouped by folder. Use `←`/`→` to switch tabs, `↑`/`↓` to move, type to filter by title, id, or path, `Enter` to resume, and `Esc` to close. Resuming a session from another directory switches Kiro's working directory to that folder, rebuilds the system prompt, skills, and prompt history for it, and saves the session there from then on. `/clear` starts a new session without deleting the old one. Kiro does not auto-resume; without a flag it starts fresh.
370
370
 
371
371
  Session files are plaintext and contain prompts, code from tools, and command output. They never contain API keys, but treat them like shell history.
372
372
 
@@ -504,7 +504,7 @@ test/
504
504
  - `@` lists files only and stops at 50,000 paths; directories and ignored files are not offered.
505
505
  - Removing a profile leaves its key in `~/.kiro/.env`; there is no command that deletes stored secrets.
506
506
  - No sub-agents, MCP, plugins, web search, image input, themes, or git integration.
507
- - Sessions are single-process and stored as plaintext JSON. There is no delete or rename command. The `/resume` picker lists other directories, but a session can only be resumed from its own directory; `/export` writes a Markdown transcript you can keep.
507
+ - Sessions are single-process and stored as plaintext JSON. There is no delete or rename command. The `/resume` picker can load a session from another directory and switches the working directory to it; `/export` writes a Markdown transcript you can keep.
508
508
  - `/undo` covers `write_file`, `edit_file`, `multi_edit`, and `apply_patch` only. It keeps the last 30 calls, and `run_command` changes are outside its reach; use Git for a complete safety net.
509
509
  - Prompt history is plaintext, capped at 200 entries per directory, and only recalled in the TUI (not in `-p` mode).
510
510
  - Only contiguous read-only tool calls run in parallel; writes, edits, patches, and commands stay sequential.
package/dist/ui/App.js CHANGED
@@ -52,11 +52,13 @@ function useTerminalSize() {
52
52
  }, [stdout, read]);
53
53
  return size;
54
54
  }
55
- 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, }) {
56
56
  const { exit } = useApp();
57
57
  const { stdout } = useStdout();
58
58
  const { columns, rows } = useTerminalSize();
59
59
  const width = Math.max(20, columns - 2);
60
+ /** Changes when a session from another directory is resumed. */
61
+ const [cwd, setCwd] = useState(initialCwd);
60
62
  const initialViewRef = useRef(null);
61
63
  if (initialViewRef.current === null) {
62
64
  const view = initialSession
@@ -816,6 +818,43 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
816
818
  }
817
819
  addNotice('muted', 'No finished tool output to expand yet.');
818
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]);
819
858
  const handleCommand = useCallback(async (input) => {
820
859
  if (busyRef.current || transitioningRef.current)
821
860
  return;
@@ -1075,6 +1114,26 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1075
1114
  target = matches[0];
1076
1115
  }
1077
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
+ }
1078
1137
  if (!target && (numeric || !isSessionId(argument))) {
1079
1138
  addNotice('error', `No saved session matches "${argument}". Use /sessions to list them.`);
1080
1139
  return;
@@ -1084,34 +1143,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1084
1143
  addNotice('info', `Session ${targetId} is already active.`);
1085
1144
  return;
1086
1145
  }
1087
- await persistSession();
1088
- await saveChainRef.current;
1089
- const record = await loadSession(cwd, targetId);
1090
- messagesRef.current = record.messages.filter((message) => message.role !== 'system');
1091
- usageRef.current = null;
1092
- const restoredUsage = record.usage ?? EMPTY_USAGE;
1093
- sessionUsageRef.current = restoredUsage;
1094
- setSessionUsage(restoredUsage);
1095
- setLastReply(null);
1096
- recomputeContext();
1097
- sessionRef.current = {
1098
- id: record.id,
1099
- createdAt: record.createdAt,
1100
- title: record.title,
1101
- };
1102
- const view = buildResumedView(messagesRef.current, {
1103
- cwd,
1104
- version,
1105
- sessionId: record.id,
1106
- });
1107
- setItems(view.items);
1108
- nextItemIdRef.current = view.nextId;
1109
- setResetSignal((current) => current + 1);
1110
- setExpandedToolId(null);
1111
- resetAutoAllowed();
1112
- if (record.profile && record.profile !== profileName) {
1113
- addNotice('muted', `Session was saved with profile "${record.profile}"; staying on "${profileName}". Use /model ${record.profile} to switch.`);
1114
- }
1146
+ await applySessionRecord(await loadSession(cwd, targetId));
1115
1147
  }
1116
1148
  catch (error) {
1117
1149
  addNotice('error', error instanceof Error ? error.message : String(error));
@@ -1250,6 +1282,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1250
1282
  }
1251
1283
  }, [
1252
1284
  addNotice,
1285
+ applySessionRecord,
1253
1286
  autoAllowed,
1254
1287
  cwd,
1255
1288
  listRemoteModels,
@@ -1268,14 +1301,25 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1268
1301
  version,
1269
1302
  yolo,
1270
1303
  ]);
1271
- /** Resumes a picker selection only when it belongs to the current directory. */
1304
+ /** Resumes a picker selection, switching directories when the session came from elsewhere. */
1272
1305
  const handleSessionPick = (session) => {
1273
1306
  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.`);
1307
+ if (session.id === sessionRef.current?.id) {
1308
+ addNotice('info', `Session ${session.id} is already active.`);
1276
1309
  return;
1277
1310
  }
1278
- void handleCommand(`/resume ${session.id}`);
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
+ })();
1279
1323
  };
1280
1324
  /** Runs the next queued item once the app is idle, including queued slash commands. */
1281
1325
  const drainQueue = useCallback(() => {
@@ -1333,7 +1377,6 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1333
1377
  if (configCreated) {
1334
1378
  addNotice('info', `Created config template at ${configPath}. Set your endpoint, model, and API key.`);
1335
1379
  }
1336
- void loadPromptHistory(cwd).then(setPromptHistory);
1337
1380
  const active = config.profiles[config.activeProfile];
1338
1381
  if (active) {
1339
1382
  if (active.type !== 'openai') {
@@ -1351,6 +1394,10 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1351
1394
  // Startup notices only.
1352
1395
  // eslint-disable-next-line react-hooks/exhaustive-deps
1353
1396
  }, []);
1397
+ /** History is per directory, so a resumed session reloads it. */
1398
+ useEffect(() => {
1399
+ void loadPromptHistory(cwd).then(setPromptHistory);
1400
+ }, [cwd]);
1354
1401
  useEffect(() => {
1355
1402
  if (!stdout.isTTY)
1356
1403
  return;
@@ -107,6 +107,6 @@ export function SessionPicker({ cwd, data, activeSessionId = null, width, maxRow
107
107
  }
108
108
  const focused = line === selectedLine;
109
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'}` })] })] }));
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 resumes and switches to that directory." })) : 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
111
  }
112
112
  //# sourceMappingURL=SessionPicker.js.map
package/dist/version.js CHANGED
@@ -1,2 +1,5 @@
1
- export const VERSION = '0.3.0';
1
+ import { createRequire } from 'node:module';
2
+ /** Single source of truth: the version npm publishes, read at runtime from package.json. */
3
+ const { version } = createRequire(import.meta.url)('../package.json');
4
+ export const VERSION = version;
2
5
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywldan/kiro",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A small terminal coding agent with your own OpenAI-compatible endpoint",
5
5
  "keywords": [
6
6
  "ai",