@ywldan/kiro 0.2.11 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ export const PLACEHOLDER_TOOL_RESULT_CHARS = 2_000;
5
5
  export const MAX_SUMMARY_INPUT_CHARS = 100_000;
6
6
  const MAX_TRANSCRIPT_MESSAGE_CHARS = 4_000;
7
7
  const TOOL_ARGS_PREVIEW_CHARS = 500;
8
- export const SUMMARY_PREFIX = '[Context summary — earlier turns were compacted to save space]';
8
+ export const SUMMARY_PREFIX = '[Context summary: earlier turns were compacted to save space]';
9
9
  export function shouldCompact(usedTokens, contextWindow, threshold = COMPACT_THRESHOLD) {
10
10
  return contextWindow > 0 && usedTokens >= Math.floor(contextWindow * threshold);
11
11
  }
@@ -43,6 +43,7 @@ export async function buildSystemPrompt(cwd) {
43
43
  '- Use apply_patch for coordinated changes across multiple files, or when you already have a unified diff. Patches are validated before anything is written.',
44
44
  '- Use write_file only for new files or complete rewrites.',
45
45
  '- All file paths are resolved relative to the working directory. Paths escaping it require user approval.',
46
+ '- A path written as @path in a user message points at a file in the working directory. Read it with read_file before relying on its contents.',
46
47
  '- Prefer run_command for builds, tests, and quick checks so you can verify your work. Commands run in the working directory.',
47
48
  '- Tool output may be truncated. Use read_file offsets, narrower grep patterns/globs, or smaller result limits if you need more detail.',
48
49
  '- If a tool returns an error, read it carefully and adjust; edit_file/multi_edit errors include a hint about the closest line or whitespace mismatch.',
package/dist/doctor.js ADDED
@@ -0,0 +1,251 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { stat } from 'node:fs/promises';
3
+ import { configPath, ConfigError, loadConfig, } from './config.js';
4
+ import { envPath, keyStatus, loadEnvFile } from './env.js';
5
+ import { discoverModels, testConnection } from './model/discovery.js';
6
+ import { redactSecrets, registerSecretEnv } from './secrets.js';
7
+ import { formatDuration } from './ui/text.js';
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
22
+ `;
23
+ class DoctorUsageError extends Error {
24
+ }
25
+ function parseOptions(argv) {
26
+ const options = { offline: false, test: false, help: false };
27
+ for (let index = 0; index < argv.length; index++) {
28
+ const arg = argv[index];
29
+ if (arg === '-h' || arg === '--help') {
30
+ options.help = true;
31
+ continue;
32
+ }
33
+ if (arg === '--offline') {
34
+ options.offline = true;
35
+ continue;
36
+ }
37
+ if (arg === '--test') {
38
+ options.test = true;
39
+ continue;
40
+ }
41
+ if (arg === '--profile' || arg.startsWith('--profile=')) {
42
+ const value = arg.includes('=') ? arg.slice(arg.indexOf('=') + 1) : argv[++index];
43
+ if (!value)
44
+ throw new DoctorUsageError('Option --profile requires a value.');
45
+ options.profile = value;
46
+ continue;
47
+ }
48
+ throw new DoctorUsageError(`Unknown option: ${arg}`);
49
+ }
50
+ return options;
51
+ }
52
+ function nodeCheck() {
53
+ const major = Number(process.versions.node.split('.')[0]);
54
+ const text = `Node v${process.versions.node} (requires >= 20)`;
55
+ return major >= 20
56
+ ? { level: 'ok', text }
57
+ : {
58
+ level: 'fail',
59
+ text,
60
+ hint: 'Upgrade Node to 20 or newer, then run kiro again.',
61
+ };
62
+ }
63
+ async function configChecks(profileName) {
64
+ const file = configPath();
65
+ if (!existsSync(file)) {
66
+ return {
67
+ checks: [
68
+ {
69
+ level: 'fail',
70
+ text: `Config ${file} does not exist`,
71
+ hint: 'Run "kiro model" to create a profile.',
72
+ },
73
+ ],
74
+ };
75
+ }
76
+ let config;
77
+ try {
78
+ ({ config } = await loadConfig());
79
+ }
80
+ catch (error) {
81
+ return {
82
+ checks: [
83
+ {
84
+ level: 'fail',
85
+ text: `Config ${file} is invalid`,
86
+ hint: error instanceof ConfigError ? error.message : String(error),
87
+ },
88
+ ],
89
+ };
90
+ }
91
+ const checks = [{ level: 'ok', text: `Config ${file}` }];
92
+ const name = profileName ?? config.activeProfile;
93
+ const profile = config.profiles[name];
94
+ if (!profile) {
95
+ checks.push({
96
+ level: 'fail',
97
+ text: `Profile "${name}" is not configured`,
98
+ hint: `Available profiles: ${Object.keys(config.profiles).join(', ')}.`,
99
+ });
100
+ return { checks };
101
+ }
102
+ checks.push({
103
+ level: 'ok',
104
+ text: `Profile ${name}: ${profile.model} @ ${profile.baseUrl}`,
105
+ });
106
+ const status = keyStatus(profile);
107
+ if (profile.apiKeyEnv && !process.env[profile.apiKeyEnv]) {
108
+ checks.push({
109
+ level: 'fail',
110
+ text: `Key ${status}`,
111
+ hint: `Store it with "kiro model" (Edit a model) or export ${profile.apiKeyEnv}=...`,
112
+ });
113
+ }
114
+ else {
115
+ checks.push({ level: 'ok', text: `Key ${status}` });
116
+ }
117
+ const apiKey = profile.apiKeyEnv ? process.env[profile.apiKeyEnv] : undefined;
118
+ if (profile.apiKeyEnv)
119
+ registerSecretEnv(profile.apiKeyEnv, apiKey, true);
120
+ return { checks, profile, apiKey };
121
+ }
122
+ async function envCheck() {
123
+ const file = envPath();
124
+ let missing = false;
125
+ try {
126
+ const result = await loadEnvFile();
127
+ missing = result.missing;
128
+ }
129
+ catch (error) {
130
+ return {
131
+ level: 'fail',
132
+ text: `Key file ${file} could not be read`,
133
+ hint: error.message,
134
+ };
135
+ }
136
+ if (missing) {
137
+ return {
138
+ level: 'warn',
139
+ text: `Key file ${file} does not exist`,
140
+ hint: 'Keys can still come from the environment. Run "kiro model" to store one.',
141
+ };
142
+ }
143
+ if (process.platform !== 'win32') {
144
+ try {
145
+ const mode = (await stat(file)).mode & 0o777;
146
+ if ((mode & 0o077) !== 0) {
147
+ return {
148
+ level: 'warn',
149
+ text: `Key file ${file} is readable by other users (mode ${mode.toString(8)})`,
150
+ hint: `Run: chmod 600 ${file}`,
151
+ };
152
+ }
153
+ }
154
+ catch (error) {
155
+ return {
156
+ level: 'fail',
157
+ text: `Key file ${file} could not be inspected`,
158
+ hint: error.message,
159
+ };
160
+ }
161
+ }
162
+ return { level: 'ok', text: `Key file ${file}` };
163
+ }
164
+ async function networkChecks(profile, apiKey, test) {
165
+ const checks = [];
166
+ const started = performance.now();
167
+ const result = await discoverModels({
168
+ baseUrl: profile.baseUrl,
169
+ apiKey,
170
+ timeoutMs: 5000,
171
+ });
172
+ const latency = formatDuration(Math.max(0, Math.round(performance.now() - started)));
173
+ if (!result.ok) {
174
+ const transient = result.status === 404 || result.status === 429;
175
+ checks.push({
176
+ level: transient ? 'warn' : 'fail',
177
+ text: redactSecrets(result.message),
178
+ hint: result.status === 404
179
+ ? 'Some servers do not implement GET /models. The profile can still work.'
180
+ : undefined,
181
+ });
182
+ return checks;
183
+ }
184
+ checks.push({
185
+ level: 'ok',
186
+ text: `GET ${result.url} returned ${result.models.length} model${result.models.length === 1 ? '' : 's'} in ${latency}`,
187
+ });
188
+ if (!result.models.includes(profile.model)) {
189
+ checks.push({
190
+ level: 'warn',
191
+ text: `Model "${profile.model}" is not in the endpoint's list`,
192
+ hint: 'Check the model id; some servers hide models from /models.',
193
+ });
194
+ }
195
+ if (test) {
196
+ const tested = await testConnection(profile, apiKey);
197
+ checks.push({
198
+ level: tested.ok ? 'ok' : 'fail',
199
+ text: redactSecrets(tested.message),
200
+ });
201
+ }
202
+ return checks;
203
+ }
204
+ function printChecks(checks) {
205
+ for (const check of checks) {
206
+ process.stdout.write(`${check.level.padEnd(4)} ${redactSecrets(check.text)}\n`);
207
+ if (check.hint) {
208
+ process.stdout.write(` ${redactSecrets(check.hint)}\n`);
209
+ }
210
+ }
211
+ }
212
+ export async function runDoctor(argv) {
213
+ let options;
214
+ try {
215
+ options = parseOptions(argv);
216
+ }
217
+ catch (error) {
218
+ if (error instanceof DoctorUsageError) {
219
+ console.error(`Kiro doctor: ${error.message}`);
220
+ console.error('Run "kiro doctor --help" for usage.');
221
+ return 2;
222
+ }
223
+ throw error;
224
+ }
225
+ if (options.help) {
226
+ process.stdout.write(DOCTOR_HELP);
227
+ return 0;
228
+ }
229
+ if (options.offline && options.test) {
230
+ console.error('Kiro doctor: --test needs the network; drop --offline or --test.');
231
+ return 2;
232
+ }
233
+ const checks = [nodeCheck()];
234
+ const keyFile = await envCheck();
235
+ const configResult = await configChecks(options.profile);
236
+ checks.push(...configResult.checks);
237
+ if (configResult.profile)
238
+ checks.push(keyFile);
239
+ if (configResult.profile) {
240
+ if (options.offline) {
241
+ checks.push({ level: 'skip', text: 'Network checks skipped (--offline)' });
242
+ }
243
+ else {
244
+ checks.push(...(await networkChecks(configResult.profile, configResult.apiKey, options.test)));
245
+ }
246
+ }
247
+ process.stdout.write(`Kiro ${VERSION} doctor\n\n`);
248
+ printChecks(checks);
249
+ return checks.some((check) => check.level === 'fail') ? 1 : 0;
250
+ }
251
+ //# sourceMappingURL=doctor.js.map
package/dist/headless.js CHANGED
@@ -12,7 +12,7 @@ import { addUsage, normalizeUsage } from './usage.js';
12
12
  * Text streams to stdout; notices, tool calls, and reasoning go to stderr, so
13
13
  * `kiro -p … > out.md` stays clean for scripting. Same session store, system
14
14
  * prompt, compaction, and tools as the TUI. Approvals are denied outside
15
- * --yolo mode — a piped run never performs an unsupervised mutation.
15
+ * --yolo mode: a piped run never performs an unsupervised mutation.
16
16
  */
17
17
  export async function runHeadless(options) {
18
18
  const { config, cwd, yolo } = options;
package/dist/index.js CHANGED
@@ -12,11 +12,13 @@ import { latestSession, loadSession } from './sessions.js';
12
12
  import { MOUSE_OFF } from './ui/mouse.js';
13
13
  import { App } from './ui/App.js';
14
14
  import { runCheck, runUpdate } from './update.js';
15
+ import { runDoctor } from './doctor.js';
15
16
  import { VERSION } from './version.js';
16
- const HELP = `Kiro — a small terminal coding agent
17
+ const HELP = `Kiro: a small terminal coding agent
17
18
 
18
19
  Usage: kiro [options]
19
20
  kiro model [command]
21
+ kiro doctor [options]
20
22
 
21
23
  Options:
22
24
  --profile <name> Use a profile from ~/.kiro/config.json
@@ -50,6 +52,9 @@ Update commands:
50
52
  kiro check Compare the installed version with the latest on npm
51
53
  kiro update Install the latest version from npm globally
52
54
 
55
+ Diagnostics:
56
+ kiro doctor Check Node, config, key storage, and the active endpoint
57
+
53
58
  Config: ~/.kiro/config.json (created with a template on first run)
54
59
  Keys: ~/.kiro/.env (mode 0600), or the environment variable named by "apiKeyEnv".
55
60
  Sessions: ~/.kiro/sessions (one directory per working directory)
@@ -201,6 +206,10 @@ async function main() {
201
206
  process.exitCode = await runUpdate();
202
207
  return;
203
208
  }
209
+ if (rawArgs[0] === 'doctor') {
210
+ process.exitCode = await runDoctor(rawArgs.slice(1));
211
+ return;
212
+ }
204
213
  let options;
205
214
  try {
206
215
  options = parseArgs(rawArgs);
@@ -89,7 +89,7 @@ async function pickProfile(ctx, title) {
89
89
  return chooseMenu(ctx, title, names.map((name) => {
90
90
  const profile = ctx.config.profiles[name];
91
91
  const active = name === ctx.config.activeProfile ? ' [active]' : '';
92
- return { key: name, label: `${name}${active} — ${profile.model} @ ${profile.baseUrl}` };
92
+ return { key: name, label: `${name}${active} · ${profile.model} @ ${profile.baseUrl}` };
93
93
  }));
94
94
  }
95
95
  function hostLabel(baseUrl) {
@@ -365,10 +365,10 @@ export async function runAddFlow(ctx) {
365
365
  const presetId = await chooseMenu(ctx, 'Choose a provider', presets.map((preset) => ({
366
366
  key: preset.id,
367
367
  label: preset.local
368
- ? `${preset.label} — ${preset.baseUrl} (no key)`
368
+ ? `${preset.label} · ${preset.baseUrl} (no key)`
369
369
  : preset.apiKeyEnv
370
- ? `${preset.label} — ${preset.baseUrl} ($${preset.apiKeyEnv})`
371
- : `${preset.label} — enter a base URL`,
370
+ ? `${preset.label} · ${preset.baseUrl} ($${preset.apiKeyEnv})`
371
+ : `${preset.label} · enter a base URL`,
372
372
  })));
373
373
  if (presetId === null)
374
374
  return cancel(ctx);
@@ -48,7 +48,7 @@ export async function executeTool(name, rawArguments, ctx) {
48
48
  }
49
49
  catch (error) {
50
50
  return toolError(`Invalid JSON arguments for ${name}: ${error.message}. ` +
51
- 'The arguments were truncated or malformed — often because the response hit its ' +
51
+ 'The arguments were truncated or malformed, often because the response hit its ' +
52
52
  'max_tokens limit. Resend this call with smaller arguments (split the work into ' +
53
53
  'several calls) or ask for a higher maxTokens.');
54
54
  }
@@ -1,72 +1,14 @@
1
1
  import { spawn } from 'node:child_process';
2
- import { readFile, readdir, stat } from 'node:fs/promises';
2
+ import { readFile, stat } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { denied, ok, toolError } from './types.js';
5
5
  import { matchGlob } from './glob.js';
6
- import { isIgnored, parseIgnoreFile } from './ignore.js';
7
6
  import { booleanArg, displayPath, integerArg, resolvePath, stringArg } from './paths.js';
7
+ import { ALWAYS_SKIP, walkTree } from './walk.js';
8
8
  const GLOB_LIMIT = 200;
9
- const MAX_WALK_ENTRIES = 200_000;
10
9
  const MAX_GREP_FILE_BYTES = 2 * 1024 * 1024;
11
10
  const MAX_GREP_LINE_CHARS = 500;
12
11
  const MAX_CAPTURE_CHARS = 4_000_000;
13
- const ALWAYS_SKIP = new Set(['node_modules', '.git', 'dist', 'build']);
14
- async function readIgnoreRules(dirAbs, baseRel) {
15
- try {
16
- return parseIgnoreFile(await readFile(path.join(dirAbs, '.gitignore'), 'utf8'), baseRel);
17
- }
18
- catch {
19
- return [];
20
- }
21
- }
22
- /** Depth-first walk that honours .gitignore and always skips heavy directories. */
23
- async function walkTree(options) {
24
- const { cwd, rootAbs, signal, visit } = options;
25
- const rootRel = path.relative(cwd, rootAbs).split(path.sep).join('/');
26
- let visited = 0;
27
- let stopped = false;
28
- const visitDir = async (dirAbs, relDir, inherited) => {
29
- if (stopped || signal.aborted)
30
- return;
31
- const rules = [...inherited, ...(await readIgnoreRules(dirAbs, relDir))];
32
- let entries;
33
- try {
34
- entries = await readdir(dirAbs, { withFileTypes: true });
35
- }
36
- catch {
37
- return;
38
- }
39
- entries.sort((left, right) => left.name.localeCompare(right.name));
40
- for (const entry of entries) {
41
- if (stopped || signal.aborted)
42
- return;
43
- if (entry.isSymbolicLink())
44
- continue;
45
- const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
46
- const isDir = entry.isDirectory();
47
- if (isDir && ALWAYS_SKIP.has(entry.name))
48
- continue;
49
- if (isIgnored(rules, rel, isDir))
50
- continue;
51
- visited++;
52
- if (visited > MAX_WALK_ENTRIES) {
53
- stopped = true;
54
- return;
55
- }
56
- const abs = path.join(dirAbs, entry.name);
57
- if ((await visit({ abs, rel, isDir })) === false) {
58
- stopped = true;
59
- return;
60
- }
61
- if (isDir) {
62
- await visitDir(abs, rel, rules);
63
- if (stopped)
64
- return;
65
- }
66
- }
67
- };
68
- await visitDir(rootAbs, rootRel, []);
69
- }
70
12
  const globTool = {
71
13
  readOnly: true,
72
14
  definition: {
@@ -135,7 +135,7 @@ export const runCommandTool = {
135
135
  flags.push('cancelled by user');
136
136
  const statusLine = `exit code: ${exit}` +
137
137
  (signal ? ` (signal ${signal})` : '') +
138
- (flags.length ? ` — ${flags.join(', ')}` : '');
138
+ (flags.length ? ` (${flags.join(', ')})` : '');
139
139
  const content = truncateMiddle(`${statusLine}\n${sections.join('\n')}`, MAX_OUTPUT_CHARS);
140
140
  const summary = timedOut
141
141
  ? `timed out after ${timeoutSeconds}s`
@@ -0,0 +1,62 @@
1
+ import { readFile, readdir } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { isIgnored, parseIgnoreFile } from './ignore.js';
4
+ export const MAX_WALK_ENTRIES = 200_000;
5
+ export const ALWAYS_SKIP = new Set(['node_modules', '.git', 'dist', 'build']);
6
+ async function readIgnoreRules(dirAbs, baseRel) {
7
+ try {
8
+ return parseIgnoreFile(await readFile(path.join(dirAbs, '.gitignore'), 'utf8'), baseRel);
9
+ }
10
+ catch {
11
+ return [];
12
+ }
13
+ }
14
+ /** Depth-first walk that honours .gitignore and always skips heavy directories. */
15
+ export async function walkTree(options) {
16
+ const { cwd, rootAbs, signal, visit } = options;
17
+ const rootRel = path.relative(cwd, rootAbs).split(path.sep).join('/');
18
+ let visited = 0;
19
+ let stopped = false;
20
+ const visitDir = async (dirAbs, relDir, inherited) => {
21
+ if (stopped || signal.aborted)
22
+ return;
23
+ const rules = [...inherited, ...(await readIgnoreRules(dirAbs, relDir))];
24
+ let entries;
25
+ try {
26
+ entries = await readdir(dirAbs, { withFileTypes: true });
27
+ }
28
+ catch {
29
+ return;
30
+ }
31
+ entries.sort((left, right) => left.name.localeCompare(right.name));
32
+ for (const entry of entries) {
33
+ if (stopped || signal.aborted)
34
+ return;
35
+ if (entry.isSymbolicLink())
36
+ continue;
37
+ const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
38
+ const isDir = entry.isDirectory();
39
+ if (isDir && ALWAYS_SKIP.has(entry.name))
40
+ continue;
41
+ if (isIgnored(rules, rel, isDir))
42
+ continue;
43
+ visited++;
44
+ if (visited > MAX_WALK_ENTRIES) {
45
+ stopped = true;
46
+ return;
47
+ }
48
+ const abs = path.join(dirAbs, entry.name);
49
+ if ((await visit({ abs, rel, isDir })) === false) {
50
+ stopped = true;
51
+ return;
52
+ }
53
+ if (isDir) {
54
+ await visitDir(abs, rel, rules);
55
+ if (stopped)
56
+ return;
57
+ }
58
+ }
59
+ };
60
+ await visitDir(rootAbs, rootRel, []);
61
+ }
62
+ //# sourceMappingURL=walk.js.map
package/dist/ui/App.js CHANGED
@@ -17,6 +17,7 @@ import { ApprovalPrompt } from './ApprovalPrompt.js';
17
17
  import { ApprovalPolicy } from './approval-policy.js';
18
18
  import { builtinCommandNames, buildSkillCommands, SLASH_COMMANDS, slashHelpLines, } from './commands.js';
19
19
  import { defaultExportPath, renderTranscriptMarkdown } from './export.js';
20
+ import { listProjectFiles } from './file-index.js';
20
21
  import { buildResumedView } from './history.js';
21
22
  import { Input } from './Input.js';
22
23
  import { MessageList } from './MessageList.js';
@@ -88,6 +89,17 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
88
89
  const [usageCardEnabled, setUsageCardEnabled] = useState(true);
89
90
  const [mouseOn, setMouseOn] = useState(mouseEnabled);
90
91
  const [expandedToolId, setExpandedToolId] = useState(null);
92
+ const [inputRows, setInputRows] = useState(1);
93
+ const fileIndexRef = useRef(null);
94
+ const loadFileIndex = useCallback(async () => {
95
+ const cached = fileIndexRef.current;
96
+ if (cached && cached.cwd === cwd && Date.now() - cached.builtAt < 5000) {
97
+ return cached.files;
98
+ }
99
+ const files = await listProjectFiles(cwd);
100
+ fileIndexRef.current = { cwd, files, builtAt: Date.now() };
101
+ return files;
102
+ }, [cwd]);
91
103
  const messagesRef = useRef((initialSession?.messages ?? []).filter((message) => message.role !== 'system'));
92
104
  const usageRef = useRef(null);
93
105
  const roundStartedAtRef = useRef(0);
@@ -882,7 +894,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
882
894
  `Context: ~${formatTokens(used)} / ${formatTokens(window)} tokens (${formatPercent(used, window)} used)` +
883
895
  (profile?.contextWindow
884
896
  ? '.'
885
- : ' — window inferred from the model id; set "contextWindow" in the profile to override.'),
897
+ : '. Window inferred from the model id; set "contextWindow" in the profile to override.'),
886
898
  ` system ~${formatTokens(count('system'))} · user ~${formatTokens(count('user'))} · ` +
887
899
  `assistant ~${formatTokens(count('assistant'))} · tool ~${formatTokens(count('tool'))}`,
888
900
  usage
@@ -1254,6 +1266,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1254
1266
  const trimmed = value.trim();
1255
1267
  if (!trimmed)
1256
1268
  return;
1269
+ const isCommand = trimmed.startsWith('/') && !trimmed.includes('\n');
1257
1270
  if (wizardActiveRef.current || transitioningRef.current) {
1258
1271
  // The wizard owns the keyboard; ignore stray input.
1259
1272
  return;
@@ -1262,7 +1275,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1262
1275
  // Type-ahead: the message runs as soon as the current turn finishes.
1263
1276
  queuedRef.current.push(trimmed);
1264
1277
  setQueuedCount(queuedRef.current.length);
1265
- if (!trimmed.startsWith('/')) {
1278
+ if (!isCommand) {
1266
1279
  setItems((current) => [
1267
1280
  ...current,
1268
1281
  { kind: 'user', id: nextItemIdRef.current++, text: trimmed },
@@ -1271,7 +1284,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1271
1284
  addNotice('muted', 'Queued. It runs after the current turn; PgUp/PgDn still scrolls the transcript meanwhile.');
1272
1285
  return;
1273
1286
  }
1274
- if (trimmed.startsWith('/')) {
1287
+ if (isCommand) {
1275
1288
  void handleCommand(trimmed).finally(() => drainQueueRef.current?.());
1276
1289
  return;
1277
1290
  }
@@ -1370,10 +1383,15 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1370
1383
  const contextWindow = contextWindowFor(activeProfile);
1371
1384
  const pickerPopup = pickerOpen && !pendingApproval ? pickerPopupRect(columns, rows) : null;
1372
1385
  const pickerInline = pickerOpen && !pendingApproval && pickerPopup === null;
1373
- const viewportHeight = Math.max(3, rows - 5 - (pendingApproval ? 12 : 0) - (pickerInline ? PICKER_INLINE_ROWS : 0));
1386
+ const extraInputRows = pendingApproval || pickerInline ? 0 : Math.max(0, inputRows - 1);
1387
+ const viewportHeight = Math.max(3, rows -
1388
+ 5 -
1389
+ extraInputRows -
1390
+ (pendingApproval ? 12 : 0) -
1391
+ (pickerInline ? PICKER_INLINE_ROWS : 0));
1374
1392
  const showUsageCard = usageCardEnabled && shouldShowUsageCard(columns, viewportHeight);
1375
1393
  const chatWidth = showUsageCard ? Math.max(40, width - USAGE_CARD_WIDTH - USAGE_CARD_GAP) : width;
1376
- 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, history: wizardPrompt || wizardActive ? undefined : promptHistory, slashCommands: [...SLASH_COMMANDS, ...skillCommands], onPaletteChange: setPalette, placeholder: pickerOpen
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
1377
1395
  ? 'Model picker open · Esc to close'
1378
1396
  : wizardPrompt
1379
1397
  ? wizardPrompt.defaultValue && !wizardPrompt.mask