@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.
- package/README.md +134 -147
- package/dist/agent/compact.js +1 -1
- package/dist/agent/prompt.js +1 -0
- package/dist/doctor.js +251 -0
- package/dist/headless.js +1 -1
- package/dist/index.js +10 -1
- package/dist/model/wizard.js +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/search.js +2 -60
- package/dist/tools/shell.js +1 -1
- package/dist/tools/walk.js +62 -0
- package/dist/ui/App.js +23 -5
- package/dist/ui/Input.js +199 -31
- package/dist/ui/MessageList.js +26 -0
- package/dist/ui/UsageCard.js +2 -2
- package/dist/ui/file-index.js +111 -0
- package/dist/ui/mention.js +63 -0
- package/dist/ui/mouse.js +1 -1
- package/dist/ui/text.js +159 -7
- package/dist/update.js +5 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/ui/text.js
CHANGED
|
@@ -114,7 +114,7 @@ export function parseEditSequence(text) {
|
|
|
114
114
|
}
|
|
115
115
|
const clamp = (value, max) => Math.max(0, Math.min(value, max));
|
|
116
116
|
const ANSI_TOKEN = new RegExp(`(${ANSI_CSI.source}|${ANSI_OSC.source})`, 'g');
|
|
117
|
-
/** Above this chunk size a trailing
|
|
117
|
+
/** Above this chunk size a trailing carriage return is treated as pasted text, not Enter. */
|
|
118
118
|
const MAX_SUBMIT_CHUNK = 200;
|
|
119
119
|
/**
|
|
120
120
|
* Ink hands a whole stdin chunk to a single `useInput` call and only decodes
|
|
@@ -128,7 +128,7 @@ export function parseInputChunk(text) {
|
|
|
128
128
|
if (text === '' || parseEditSequence(text) !== null)
|
|
129
129
|
return [];
|
|
130
130
|
const lineBreaks = (text.match(/[\r\n]/g) ?? []).length;
|
|
131
|
-
const trailingEnter = lineBreaks === 1 && text.length <= MAX_SUBMIT_CHUNK &&
|
|
131
|
+
const trailingEnter = lineBreaks === 1 && text.length <= MAX_SUBMIT_CHUNK && text.endsWith('\r');
|
|
132
132
|
const ops = [];
|
|
133
133
|
let buffer = '';
|
|
134
134
|
const flush = () => {
|
|
@@ -148,21 +148,32 @@ export function parseInputChunk(text) {
|
|
|
148
148
|
}
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
|
-
for (
|
|
151
|
+
for (let index = 0; index < token.length; index++) {
|
|
152
|
+
const char = token[index];
|
|
152
153
|
const code = char.codePointAt(0) ?? 0;
|
|
153
154
|
if (char === '\x7f' || char === '\x08') {
|
|
154
155
|
flush();
|
|
155
156
|
ops.push({ type: 'backspace', count: 1 });
|
|
156
157
|
}
|
|
157
|
-
else if (char === '\r'
|
|
158
|
+
else if (char === '\r') {
|
|
158
159
|
if (trailingEnter) {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
if (buffer.endsWith('\\')) {
|
|
161
|
+
buffer = `${buffer.slice(0, -1)}\n`;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
flush();
|
|
165
|
+
ops.push({ type: 'submit' });
|
|
166
|
+
}
|
|
161
167
|
}
|
|
162
168
|
else {
|
|
163
|
-
buffer += '
|
|
169
|
+
buffer += '\n';
|
|
170
|
+
if (token[index + 1] === '\n')
|
|
171
|
+
index++;
|
|
164
172
|
}
|
|
165
173
|
}
|
|
174
|
+
else if (char === '\n') {
|
|
175
|
+
buffer += '\n';
|
|
176
|
+
}
|
|
166
177
|
else if (char === '\t') {
|
|
167
178
|
buffer += ' ';
|
|
168
179
|
}
|
|
@@ -257,6 +268,147 @@ export function applyInputOps(state, ops, maxChars = Number.POSITIVE_INFINITY) {
|
|
|
257
268
|
}
|
|
258
269
|
return { state: current, submitted: false };
|
|
259
270
|
}
|
|
271
|
+
export const PASTE_START = '\x1b[200~';
|
|
272
|
+
export const PASTE_END = '\x1b[201~';
|
|
273
|
+
const PASTE_START_BARE = '[200~';
|
|
274
|
+
const PASTE_END_BARE = '[201~';
|
|
275
|
+
export function normalizePastedText(text) {
|
|
276
|
+
return text
|
|
277
|
+
.replace(/\r\n?/g, '\n')
|
|
278
|
+
.replace(/\t/g, ' ')
|
|
279
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '');
|
|
280
|
+
}
|
|
281
|
+
function findPasteStart(text) {
|
|
282
|
+
const escaped = text.indexOf(PASTE_START);
|
|
283
|
+
if (escaped !== -1)
|
|
284
|
+
return { index: escaped, length: PASTE_START.length };
|
|
285
|
+
if (text.startsWith(PASTE_START_BARE))
|
|
286
|
+
return { index: 0, length: PASTE_START_BARE.length };
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
function findPasteEnd(text) {
|
|
290
|
+
const escaped = text.indexOf(PASTE_END);
|
|
291
|
+
const bare = text.indexOf(PASTE_END_BARE);
|
|
292
|
+
if (escaped === -1 && bare === -1)
|
|
293
|
+
return null;
|
|
294
|
+
if (escaped === -1)
|
|
295
|
+
return { index: bare, length: PASTE_END_BARE.length };
|
|
296
|
+
if (bare === -1 || escaped <= bare)
|
|
297
|
+
return { index: escaped, length: PASTE_END.length };
|
|
298
|
+
return { index: bare, length: PASTE_END_BARE.length };
|
|
299
|
+
}
|
|
300
|
+
/** Longest suffix that could still become a start marker. */
|
|
301
|
+
function pendingStart(text) {
|
|
302
|
+
const limit = Math.min(PASTE_START.length - 1, text.length);
|
|
303
|
+
for (let length = limit; length >= 3; length--) {
|
|
304
|
+
const suffix = text.slice(-length);
|
|
305
|
+
if (PASTE_START.startsWith(suffix) || PASTE_START_BARE.startsWith(suffix))
|
|
306
|
+
return suffix;
|
|
307
|
+
}
|
|
308
|
+
return '';
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Consumes bracketed paste markers from a raw input chunk. Ink strips one
|
|
312
|
+
* leading escape byte per chunk and a terminal may split a marker across
|
|
313
|
+
* reads, so both cases are buffered.
|
|
314
|
+
*/
|
|
315
|
+
export function feedPaste(state, input) {
|
|
316
|
+
if (state.open) {
|
|
317
|
+
const combined = state.buffer + input;
|
|
318
|
+
const end = findPasteEnd(combined);
|
|
319
|
+
if (!end) {
|
|
320
|
+
return {
|
|
321
|
+
state: { open: true, buffer: combined, pending: '' },
|
|
322
|
+
text: null,
|
|
323
|
+
consumed: true,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const text = normalizePastedText(combined.slice(0, end.index)) +
|
|
327
|
+
normalizePastedText(combined.slice(end.index + end.length));
|
|
328
|
+
return { state: { open: false, buffer: '', pending: '' }, text, consumed: true };
|
|
329
|
+
}
|
|
330
|
+
const hadPending = state.pending !== '';
|
|
331
|
+
const combined = state.pending + input;
|
|
332
|
+
const start = findPasteStart(combined);
|
|
333
|
+
if (!start) {
|
|
334
|
+
const pending = pendingStart(combined);
|
|
335
|
+
if (pending.length >= 3 && pending.length === combined.length) {
|
|
336
|
+
return { state: { open: false, buffer: '', pending }, text: null, consumed: true };
|
|
337
|
+
}
|
|
338
|
+
if (!hadPending) {
|
|
339
|
+
return { state: { open: false, buffer: '', pending: '' }, text: null, consumed: false };
|
|
340
|
+
}
|
|
341
|
+
const flushed = combined.slice(0, combined.length - pending.length);
|
|
342
|
+
return {
|
|
343
|
+
state: { open: false, buffer: '', pending },
|
|
344
|
+
text: flushed ? normalizePastedText(flushed) : null,
|
|
345
|
+
consumed: true,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
const prefix = combined.slice(0, start.index);
|
|
349
|
+
const after = combined.slice(start.index + start.length);
|
|
350
|
+
const end = findPasteEnd(after);
|
|
351
|
+
if (!end) {
|
|
352
|
+
return {
|
|
353
|
+
state: { open: true, buffer: after, pending: '' },
|
|
354
|
+
text: prefix ? normalizePastedText(prefix) : null,
|
|
355
|
+
consumed: true,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const pasted = after.slice(0, end.index);
|
|
359
|
+
const rest = after.slice(end.index + end.length);
|
|
360
|
+
return {
|
|
361
|
+
state: { open: false, buffer: '', pending: '' },
|
|
362
|
+
text: normalizePastedText(prefix + pasted) + normalizePastedText(rest),
|
|
363
|
+
consumed: true,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
/** Splits input into visual lines, honouring explicit newlines and hard wrapping. */
|
|
367
|
+
export function layoutInput(chars, width, masked = false) {
|
|
368
|
+
const maxWidth = Math.max(1, width);
|
|
369
|
+
const lines = [];
|
|
370
|
+
let start = 0;
|
|
371
|
+
let text = '';
|
|
372
|
+
let used = 0;
|
|
373
|
+
const flush = (end, wrapped) => {
|
|
374
|
+
lines.push({ start, end, text, wrapped });
|
|
375
|
+
start = end;
|
|
376
|
+
text = '';
|
|
377
|
+
used = 0;
|
|
378
|
+
};
|
|
379
|
+
for (let index = 0; index < chars.length; index++) {
|
|
380
|
+
const char = masked ? '•' : chars[index];
|
|
381
|
+
if (char === '\n') {
|
|
382
|
+
flush(index, false);
|
|
383
|
+
start = index + 1;
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const charWidth = Math.max(1, stringWidth(char));
|
|
387
|
+
if (used > 0 && used + charWidth > maxWidth)
|
|
388
|
+
flush(index, true);
|
|
389
|
+
text += char;
|
|
390
|
+
used += charWidth;
|
|
391
|
+
}
|
|
392
|
+
flush(chars.length, false);
|
|
393
|
+
return lines;
|
|
394
|
+
}
|
|
395
|
+
/** Finds the visual line holding the caret; wraps forward, newlines stay put. */
|
|
396
|
+
export function cursorLineIndex(lines, cursor) {
|
|
397
|
+
for (let index = 0; index < lines.length; index++) {
|
|
398
|
+
const line = lines[index];
|
|
399
|
+
if (cursor < line.start)
|
|
400
|
+
return Math.max(0, index - 1);
|
|
401
|
+
if (cursor < line.end)
|
|
402
|
+
return index;
|
|
403
|
+
if (cursor === line.end) {
|
|
404
|
+
const next = lines[index + 1];
|
|
405
|
+
if (line.wrapped && next && next.start === cursor)
|
|
406
|
+
return index + 1;
|
|
407
|
+
return index;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return lines.length - 1;
|
|
411
|
+
}
|
|
260
412
|
export function formatDuration(ms) {
|
|
261
413
|
if (ms < 1000)
|
|
262
414
|
return `${ms}ms`;
|
package/dist/update.js
CHANGED
|
@@ -47,25 +47,25 @@ async function latestVersion() {
|
|
|
47
47
|
}
|
|
48
48
|
return latest;
|
|
49
49
|
}
|
|
50
|
-
/** `kiro check
|
|
50
|
+
/** `kiro check`: compare the installed version with the registry. Exit 0 current, 1 update available, 2 check failed. */
|
|
51
51
|
export async function runCheck() {
|
|
52
52
|
let latest;
|
|
53
53
|
try {
|
|
54
54
|
latest = await latestVersion();
|
|
55
55
|
}
|
|
56
56
|
catch (error) {
|
|
57
|
-
console.error(`Kiro ${VERSION}
|
|
57
|
+
console.error(`Kiro ${VERSION}: version check failed: ${error.message}`);
|
|
58
58
|
console.error('Check manually with: npm view @ywldan/kiro version');
|
|
59
59
|
return 2;
|
|
60
60
|
}
|
|
61
61
|
if (compareVersions(VERSION, latest) >= 0) {
|
|
62
|
-
process.stdout.write(`Kiro ${VERSION}
|
|
62
|
+
process.stdout.write(`Kiro ${VERSION}: up to date\n`);
|
|
63
63
|
return 0;
|
|
64
64
|
}
|
|
65
65
|
process.stdout.write(`Kiro ${VERSION} → ${latest} available. Run "kiro update" to upgrade.\n`);
|
|
66
66
|
return 1;
|
|
67
67
|
}
|
|
68
|
-
/** `kiro update
|
|
68
|
+
/** `kiro update`: install the latest published version globally through npm. */
|
|
69
69
|
export async function runUpdate() {
|
|
70
70
|
let latest;
|
|
71
71
|
try {
|
|
@@ -75,7 +75,7 @@ export async function runUpdate() {
|
|
|
75
75
|
latest = 'latest';
|
|
76
76
|
}
|
|
77
77
|
if (latest !== 'latest' && compareVersions(VERSION, latest) >= 0) {
|
|
78
|
-
process.stdout.write(`Kiro ${VERSION}
|
|
78
|
+
process.stdout.write(`Kiro ${VERSION}: already up to date, nothing to do\n`);
|
|
79
79
|
return 0;
|
|
80
80
|
}
|
|
81
81
|
process.stdout.write(`Updating Kiro ${VERSION} → ${latest} via npm…\n`);
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.3.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|