@pikaa-ai/pikaa 0.3.24 → 0.3.25
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/dist/cli.js +71 -58
- package/dist/index.js +6 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1910,6 +1910,12 @@ class WindowsSandbox {
|
|
|
1910
1910
|
return null;
|
|
1911
1911
|
}
|
|
1912
1912
|
try {
|
|
1913
|
+
if (this.jobObjectHandle) {
|
|
1914
|
+
try {
|
|
1915
|
+
this.kernel32.symbols.CloseHandle(this.jobObjectHandle);
|
|
1916
|
+
} catch {}
|
|
1917
|
+
this.jobObjectHandle = null;
|
|
1918
|
+
}
|
|
1913
1919
|
const jobHandle = this.kernel32.symbols.CreateJobObjectW(null, null);
|
|
1914
1920
|
if (!jobHandle || jobHandle === 0) {
|
|
1915
1921
|
return null;
|
|
@@ -6723,7 +6729,7 @@ function parsePatch(oldSrc, newSrc, contextLines = 3) {
|
|
|
6723
6729
|
// package.json
|
|
6724
6730
|
var package_default = {
|
|
6725
6731
|
name: "@pikaa-ai/pikaa",
|
|
6726
|
-
version: "0.3.
|
|
6732
|
+
version: "0.3.25",
|
|
6727
6733
|
description: "PIKAA CLI - AI coding agent that runs locally in your terminal.",
|
|
6728
6734
|
main: "./dist/index.js",
|
|
6729
6735
|
module: "./dist/index.js",
|
|
@@ -7290,8 +7296,25 @@ import readline2 from "readline";
|
|
|
7290
7296
|
import readline from "readline";
|
|
7291
7297
|
var keypressEventsInitialized = false;
|
|
7292
7298
|
var listeners = new Set;
|
|
7299
|
+
var rawModeState = null;
|
|
7300
|
+
function ensureRawMode(active) {
|
|
7301
|
+
if (!process.stdin.isTTY)
|
|
7302
|
+
return;
|
|
7303
|
+
if (rawModeState === active)
|
|
7304
|
+
return;
|
|
7305
|
+
try {
|
|
7306
|
+
process.stdin.setRawMode(active);
|
|
7307
|
+
rawModeState = active;
|
|
7308
|
+
if (active) {
|
|
7309
|
+
process.stdin.resume();
|
|
7310
|
+
}
|
|
7311
|
+
} catch {}
|
|
7312
|
+
}
|
|
7293
7313
|
function initGlobalKeypress() {
|
|
7294
7314
|
if (!keypressEventsInitialized && process.stdin.isTTY) {
|
|
7315
|
+
try {
|
|
7316
|
+
process.stdin.on("error", () => {});
|
|
7317
|
+
} catch {}
|
|
7295
7318
|
readline.emitKeypressEvents(process.stdin);
|
|
7296
7319
|
keypressEventsInitialized = true;
|
|
7297
7320
|
process.stdin.on("keypress", (str, key) => {
|
|
@@ -7384,12 +7407,7 @@ class InteractiveLineEditor {
|
|
|
7384
7407
|
let popupDismissed = false;
|
|
7385
7408
|
let lastCursorRowFromTop = 0;
|
|
7386
7409
|
let unsubscribeKeypress = null;
|
|
7387
|
-
|
|
7388
|
-
try {
|
|
7389
|
-
process.stdin.setRawMode(true);
|
|
7390
|
-
} catch {}
|
|
7391
|
-
}
|
|
7392
|
-
process.stdin.resume();
|
|
7410
|
+
ensureRawMode(true);
|
|
7393
7411
|
const getMatchingCommands = () => {
|
|
7394
7412
|
if (!buffer.startsWith("/") || popupDismissed)
|
|
7395
7413
|
return [];
|
|
@@ -7423,7 +7441,7 @@ class InteractiveLineEditor {
|
|
|
7423
7441
|
};
|
|
7424
7442
|
const getRule = () => {
|
|
7425
7443
|
const cols = getTerminalCols();
|
|
7426
|
-
const ruleLen = Math.max(10, cols -
|
|
7444
|
+
const ruleLen = Math.max(10, cols - 6);
|
|
7427
7445
|
return "\u2500".repeat(ruleLen);
|
|
7428
7446
|
};
|
|
7429
7447
|
const ensureVisible = (totalItems, visibleRows) => {
|
|
@@ -7449,11 +7467,12 @@ class InteractiveLineEditor {
|
|
|
7449
7467
|
const redraw = () => {
|
|
7450
7468
|
const termCols = getTerminalCols();
|
|
7451
7469
|
const visiblePromptWidth = this.promptSymbol.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
7470
|
+
let frame = "";
|
|
7452
7471
|
if (lastCursorRowFromTop > 0) {
|
|
7453
|
-
|
|
7472
|
+
frame += `\x1B[${lastCursorRowFromTop}A`;
|
|
7454
7473
|
}
|
|
7455
|
-
|
|
7456
|
-
|
|
7474
|
+
frame += "\r\x1B[J";
|
|
7475
|
+
frame += `${this.promptSymbol}${buffer}`;
|
|
7457
7476
|
const totalPromptChars = visiblePromptWidth + buffer.length;
|
|
7458
7477
|
const promptRows = Math.max(1, Math.floor(totalPromptChars / termCols) + 1);
|
|
7459
7478
|
const slashMatches = getMatchingCommands();
|
|
@@ -7461,7 +7480,7 @@ class InteractiveLineEditor {
|
|
|
7461
7480
|
const fileMatches = activeFile ? getMatchingFiles(activeFile.query) : [];
|
|
7462
7481
|
let menuRows = 0;
|
|
7463
7482
|
if (buffer.startsWith("/") && !popupDismissed && slashMatches.length > 0) {
|
|
7464
|
-
const BOX_WIDTH = Math.max(20, Math.min(termCols -
|
|
7483
|
+
const BOX_WIDTH = Math.max(20, Math.min(termCols - 6, 120));
|
|
7465
7484
|
const maxVisible = Math.min(slashMatches.length, 7);
|
|
7466
7485
|
ensureVisible(slashMatches.length, maxVisible);
|
|
7467
7486
|
const visibleMatches = slashMatches.slice(scrollTop, scrollTop + maxVisible);
|
|
@@ -7488,12 +7507,12 @@ class InteractiveLineEditor {
|
|
|
7488
7507
|
}
|
|
7489
7508
|
menuLines.push(` ${RULE_COLOR2}${rule}${RESET2}`);
|
|
7490
7509
|
for (const line of menuLines) {
|
|
7491
|
-
|
|
7492
|
-
\x1B[2K${line}
|
|
7510
|
+
frame += `
|
|
7511
|
+
\x1B[2K${line}`;
|
|
7493
7512
|
}
|
|
7494
7513
|
menuRows = menuLines.length;
|
|
7495
7514
|
} else if (activeFile && !popupDismissed && fileMatches.length > 0) {
|
|
7496
|
-
const BOX_WIDTH = Math.max(20, Math.min(termCols -
|
|
7515
|
+
const BOX_WIDTH = Math.max(20, Math.min(termCols - 6, 120));
|
|
7497
7516
|
const maxVisible = Math.min(fileMatches.length, 7);
|
|
7498
7517
|
ensureVisible(fileMatches.length, maxVisible);
|
|
7499
7518
|
const visibleMatches = fileMatches.slice(scrollTop, scrollTop + maxVisible);
|
|
@@ -7525,31 +7544,34 @@ class InteractiveLineEditor {
|
|
|
7525
7544
|
menuLines.push(` ${style.dim("\u2502")}${style.dim(footerPadded)}${style.dim("\u2502")}`);
|
|
7526
7545
|
menuLines.push(` ${style.dim("\u2514" + "\u2500".repeat(BOX_WIDTH) + "\u2518")}`);
|
|
7527
7546
|
for (const line of menuLines) {
|
|
7528
|
-
|
|
7529
|
-
\x1B[2K${line}
|
|
7547
|
+
frame += `
|
|
7548
|
+
\x1B[2K${line}`;
|
|
7530
7549
|
}
|
|
7531
7550
|
menuRows = menuLines.length;
|
|
7532
7551
|
} else {
|
|
7533
7552
|
const RULE_COLOR2 = "\x1B[38;2;60;60;68m";
|
|
7534
7553
|
const bottomRule = ` ${RULE_COLOR2}${getRule()}\x1B[0m`;
|
|
7535
7554
|
const modeLine = this.getModeLine();
|
|
7536
|
-
|
|
7555
|
+
frame += `
|
|
7537
7556
|
\x1B[2K${bottomRule}
|
|
7538
|
-
\x1B[2K${modeLine}
|
|
7557
|
+
\x1B[2K${modeLine}`;
|
|
7539
7558
|
menuRows = 2;
|
|
7540
7559
|
}
|
|
7541
7560
|
const cursorCharsFromTop = visiblePromptWidth + cursor;
|
|
7542
7561
|
const cursorRow = Math.floor(cursorCharsFromTop / termCols);
|
|
7543
7562
|
const cursorCol = cursorCharsFromTop % termCols;
|
|
7544
|
-
const moveUpRows = promptRows - 1 - cursorRow + menuRows;
|
|
7563
|
+
const moveUpRows = Math.max(0, promptRows - 1 - cursorRow + menuRows);
|
|
7545
7564
|
if (moveUpRows > 0) {
|
|
7546
|
-
|
|
7565
|
+
frame += `\x1B[${moveUpRows}A`;
|
|
7547
7566
|
}
|
|
7548
|
-
|
|
7567
|
+
frame += "\r";
|
|
7549
7568
|
if (cursorCol > 0) {
|
|
7550
|
-
|
|
7569
|
+
frame += `\x1B[${cursorCol}C`;
|
|
7551
7570
|
}
|
|
7552
7571
|
lastCursorRowFromTop = cursorRow;
|
|
7572
|
+
try {
|
|
7573
|
+
process.stdout.write(frame);
|
|
7574
|
+
} catch {}
|
|
7553
7575
|
};
|
|
7554
7576
|
const onResize = () => {
|
|
7555
7577
|
redraw();
|
|
@@ -7565,23 +7587,23 @@ class InteractiveLineEditor {
|
|
|
7565
7587
|
unsubscribeKeypress();
|
|
7566
7588
|
unsubscribeKeypress = null;
|
|
7567
7589
|
}
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
process.stdin.setRawMode(false);
|
|
7571
|
-
} catch {}
|
|
7572
|
-
}
|
|
7590
|
+
ensureRawMode(false);
|
|
7591
|
+
let cleanupFrame = "";
|
|
7573
7592
|
if (lastCursorRowFromTop > 0) {
|
|
7574
|
-
|
|
7593
|
+
cleanupFrame += `\x1B[${lastCursorRowFromTop}A`;
|
|
7575
7594
|
}
|
|
7576
|
-
|
|
7595
|
+
cleanupFrame += "\r\x1B[J";
|
|
7577
7596
|
if (result.trim().length > 0 && !result.startsWith("/")) {
|
|
7578
|
-
|
|
7597
|
+
cleanupFrame += `${CliFormatter.formatClaudeUserPrompt(result)}
|
|
7579
7598
|
|
|
7580
|
-
|
|
7599
|
+
`;
|
|
7581
7600
|
} else {
|
|
7582
|
-
|
|
7583
|
-
|
|
7601
|
+
cleanupFrame += `
|
|
7602
|
+
`;
|
|
7584
7603
|
}
|
|
7604
|
+
try {
|
|
7605
|
+
process.stdout.write(cleanupFrame);
|
|
7606
|
+
} catch {}
|
|
7585
7607
|
resolve18(result);
|
|
7586
7608
|
};
|
|
7587
7609
|
const onKeypress = (_str, key) => {
|
|
@@ -7790,11 +7812,8 @@ async function promptChoice(config) {
|
|
|
7790
7812
|
let selectedIndex = defaultIndex;
|
|
7791
7813
|
if (selectedIndex < 0 || selectedIndex >= choices.length)
|
|
7792
7814
|
selectedIndex = 0;
|
|
7793
|
-
const wasRaw = process.stdin.isRaw;
|
|
7794
|
-
|
|
7795
|
-
process.stdin.setRawMode(true);
|
|
7796
|
-
} catch {}
|
|
7797
|
-
process.stdin.resume();
|
|
7815
|
+
const wasRaw = process.stdin.isRaw ?? false;
|
|
7816
|
+
ensureRawMode(true);
|
|
7798
7817
|
const render = () => {
|
|
7799
7818
|
const parts = choices.map((choice, idx) => {
|
|
7800
7819
|
const isSelected = idx === selectedIndex;
|
|
@@ -7813,9 +7832,7 @@ async function promptChoice(config) {
|
|
|
7813
7832
|
unsubscribe();
|
|
7814
7833
|
unsubscribe = null;
|
|
7815
7834
|
}
|
|
7816
|
-
|
|
7817
|
-
process.stdin.setRawMode(wasRaw ?? false);
|
|
7818
|
-
} catch {}
|
|
7835
|
+
ensureRawMode(wasRaw);
|
|
7819
7836
|
process.stdout.write(`\r\x1B[1A\r\x1B[2K ${style.bold(message)} ${style.cyan(`[${confirmedChoice.key}] ${confirmedChoice.label}`)}
|
|
7820
7837
|
\r\x1B[2K`);
|
|
7821
7838
|
resolve18(confirmedChoice.value);
|
|
@@ -7886,11 +7903,8 @@ async function promptToolApproval(params) {
|
|
|
7886
7903
|
}
|
|
7887
7904
|
return new Promise((resolve18) => {
|
|
7888
7905
|
let selectedIndex = 1;
|
|
7889
|
-
const wasRaw = process.stdin.isRaw;
|
|
7890
|
-
|
|
7891
|
-
process.stdin.setRawMode(true);
|
|
7892
|
-
} catch {}
|
|
7893
|
-
process.stdin.resume();
|
|
7906
|
+
const wasRaw = process.stdin.isRaw ?? false;
|
|
7907
|
+
ensureRawMode(true);
|
|
7894
7908
|
const render = () => {
|
|
7895
7909
|
renderCard(selectedIndex);
|
|
7896
7910
|
};
|
|
@@ -7900,9 +7914,7 @@ async function promptToolApproval(params) {
|
|
|
7900
7914
|
unsubscribe();
|
|
7901
7915
|
unsubscribe = null;
|
|
7902
7916
|
}
|
|
7903
|
-
|
|
7904
|
-
process.stdin.setRawMode(wasRaw ?? false);
|
|
7905
|
-
} catch {}
|
|
7917
|
+
ensureRawMode(wasRaw);
|
|
7906
7918
|
console.log();
|
|
7907
7919
|
resolve18(val);
|
|
7908
7920
|
};
|
|
@@ -8057,11 +8069,8 @@ async function promptInteractiveList(config) {
|
|
|
8057
8069
|
let selectedIndex = Math.max(0, Math.min(defaultIndex, items.length - 1));
|
|
8058
8070
|
let scrollTop = 0;
|
|
8059
8071
|
let renderedLines = 0;
|
|
8060
|
-
const wasRaw = process.stdin.isRaw;
|
|
8061
|
-
|
|
8062
|
-
process.stdin.setRawMode(true);
|
|
8063
|
-
} catch {}
|
|
8064
|
-
process.stdin.resume();
|
|
8072
|
+
const wasRaw = process.stdin.isRaw ?? false;
|
|
8073
|
+
ensureRawMode(true);
|
|
8065
8074
|
process.stdout.write("\x1B[?25l");
|
|
8066
8075
|
const BOX_WIDTH = Math.min(process.stdout.columns ?? 80, 76);
|
|
8067
8076
|
const ensureVisible = () => {
|
|
@@ -8145,9 +8154,7 @@ async function promptInteractiveList(config) {
|
|
|
8145
8154
|
unsubscribe();
|
|
8146
8155
|
unsubscribe = null;
|
|
8147
8156
|
}
|
|
8148
|
-
|
|
8149
|
-
process.stdin.setRawMode(wasRaw ?? false);
|
|
8150
|
-
} catch {}
|
|
8157
|
+
ensureRawMode(wasRaw);
|
|
8151
8158
|
resolve18(res);
|
|
8152
8159
|
};
|
|
8153
8160
|
const onKeypress = async (_str, key) => {
|
|
@@ -10795,6 +10802,12 @@ class CliRepl {
|
|
|
10795
10802
|
}
|
|
10796
10803
|
});
|
|
10797
10804
|
while (!this.isClosed) {
|
|
10805
|
+
await new Promise((resolve22) => setTimeout(resolve22, 20));
|
|
10806
|
+
if (typeof Bun !== "undefined" && typeof Bun.gc === "function") {
|
|
10807
|
+
try {
|
|
10808
|
+
Bun.gc(false);
|
|
10809
|
+
} catch {}
|
|
10810
|
+
}
|
|
10798
10811
|
let rawLine;
|
|
10799
10812
|
try {
|
|
10800
10813
|
rawLine = await editor.readLine();
|
package/dist/index.js
CHANGED
|
@@ -2007,6 +2007,12 @@ class WindowsSandbox {
|
|
|
2007
2007
|
return null;
|
|
2008
2008
|
}
|
|
2009
2009
|
try {
|
|
2010
|
+
if (this.jobObjectHandle) {
|
|
2011
|
+
try {
|
|
2012
|
+
this.kernel32.symbols.CloseHandle(this.jobObjectHandle);
|
|
2013
|
+
} catch {}
|
|
2014
|
+
this.jobObjectHandle = null;
|
|
2015
|
+
}
|
|
2010
2016
|
const jobHandle = this.kernel32.symbols.CreateJobObjectW(null, null);
|
|
2011
2017
|
if (!jobHandle || jobHandle === 0) {
|
|
2012
2018
|
return null;
|