@pikaa-ai/pikaa 0.3.15 → 0.3.16

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.
Files changed (2) hide show
  1. package/dist/cli.js +38 -33
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6429,7 +6429,7 @@ function parsePatch(oldSrc, newSrc, contextLines = 3) {
6429
6429
  // package.json
6430
6430
  var package_default = {
6431
6431
  name: "@pikaa-ai/pikaa",
6432
- version: "0.3.15",
6432
+ version: "0.3.16",
6433
6433
  description: "PIKAA CLI - AI coding agent that runs locally in your terminal.",
6434
6434
  main: "./dist/index.js",
6435
6435
  module: "./dist/index.js",
@@ -7065,8 +7065,8 @@ class InteractiveLineEditor {
7065
7065
  let cursor = 0;
7066
7066
  let selectedIndex = 0;
7067
7067
  let scrollTop = 0;
7068
- let renderedMenuLines = 0;
7069
7068
  let popupDismissed = false;
7069
+ let lastCursorRowFromTop = 0;
7070
7070
  if (process.stdin.isTTY) {
7071
7071
  try {
7072
7072
  process.stdin.setRawMode(true);
@@ -7129,20 +7129,21 @@ class InteractiveLineEditor {
7129
7129
  if (scrollTop > maxScroll)
7130
7130
  scrollTop = maxScroll;
7131
7131
  };
7132
- const clearMenu = () => {
7133
- if (renderedMenuLines > 0) {
7134
- process.stdout.write("\x1B[J");
7135
- renderedMenuLines = 0;
7136
- }
7137
- };
7138
7132
  const redraw = () => {
7139
- process.stdout.write("\x1B[J");
7140
- process.stdout.write(`\r\x1B[2K${this.promptSymbol}${buffer}`);
7133
+ const termCols = getTerminalCols();
7134
+ const visiblePromptWidth = this.promptSymbol.replace(/\x1b\[[0-9;]*m/g, "").length;
7135
+ if (lastCursorRowFromTop > 0) {
7136
+ process.stdout.write(`\x1B[${lastCursorRowFromTop}A`);
7137
+ }
7138
+ process.stdout.write("\r\x1B[J");
7139
+ process.stdout.write(`${this.promptSymbol}${buffer}`);
7140
+ const totalPromptChars = visiblePromptWidth + buffer.length;
7141
+ const promptRows = Math.max(1, Math.floor(totalPromptChars / termCols) + 1);
7141
7142
  const slashMatches = getMatchingCommands();
7142
7143
  const activeFile = getActiveFileQuery();
7143
7144
  const fileMatches = activeFile ? getMatchingFiles(activeFile.query) : [];
7145
+ let menuRows = 0;
7144
7146
  if (buffer.startsWith("/") && !popupDismissed && slashMatches.length > 0) {
7145
- const termCols = getTerminalCols();
7146
7147
  const BOX_WIDTH = Math.max(20, Math.min(termCols - 4, 120));
7147
7148
  const maxVisible = Math.min(slashMatches.length, 7);
7148
7149
  ensureVisible(slashMatches.length, maxVisible);
@@ -7173,10 +7174,8 @@ class InteractiveLineEditor {
7173
7174
  process.stdout.write(`
7174
7175
  \x1B[2K${line}`);
7175
7176
  }
7176
- renderedMenuLines = menuLines.length;
7177
- process.stdout.write(`\x1B[${renderedMenuLines}A`);
7177
+ menuRows = menuLines.length;
7178
7178
  } else if (activeFile && !popupDismissed && fileMatches.length > 0) {
7179
- const termCols = getTerminalCols();
7180
7179
  const BOX_WIDTH = Math.max(20, Math.min(termCols - 4, 120));
7181
7180
  const maxVisible = Math.min(fileMatches.length, 7);
7182
7181
  ensureVisible(fileMatches.length, maxVisible);
@@ -7212,8 +7211,7 @@ class InteractiveLineEditor {
7212
7211
  process.stdout.write(`
7213
7212
  \x1B[2K${line}`);
7214
7213
  }
7215
- renderedMenuLines = menuLines.length;
7216
- process.stdout.write(`\x1B[${renderedMenuLines}A`);
7214
+ menuRows = menuLines.length;
7217
7215
  } else {
7218
7216
  const RULE_COLOR2 = "\x1B[38;2;60;60;68m";
7219
7217
  const bottomRule = ` ${RULE_COLOR2}${getRule()}\x1B[0m`;
@@ -7221,16 +7219,20 @@ class InteractiveLineEditor {
7221
7219
  process.stdout.write(`
7222
7220
  \x1B[2K${bottomRule}
7223
7221
  \x1B[2K${modeLine}`);
7224
- renderedMenuLines = 2;
7225
- process.stdout.write(`\x1B[2A`);
7222
+ menuRows = 2;
7223
+ }
7224
+ const cursorCharsFromTop = visiblePromptWidth + cursor;
7225
+ const cursorRow = Math.floor(cursorCharsFromTop / termCols);
7226
+ const cursorCol = cursorCharsFromTop % termCols;
7227
+ const moveUpRows = promptRows - 1 - cursorRow + menuRows;
7228
+ if (moveUpRows > 0) {
7229
+ process.stdout.write(`\x1B[${moveUpRows}A`);
7226
7230
  }
7227
- const visiblePromptLength = this.promptSymbol.replace(/\x1b\[[0-9;]*m/g, "").length;
7228
- const cursorCol = visiblePromptLength + cursor;
7231
+ process.stdout.write("\r");
7229
7232
  if (cursorCol > 0) {
7230
- process.stdout.write(`\r\x1B[${cursorCol}C`);
7231
- } else {
7232
- process.stdout.write("\r");
7233
+ process.stdout.write(`\x1B[${cursorCol}C`);
7233
7234
  }
7235
+ lastCursorRowFromTop = cursorRow;
7234
7236
  };
7235
7237
  const onResize = () => {
7236
7238
  redraw();
@@ -7242,19 +7244,22 @@ class InteractiveLineEditor {
7242
7244
  if (process.stdout && typeof process.stdout.removeListener === "function") {
7243
7245
  process.stdout.removeListener("resize", onResize);
7244
7246
  }
7245
- clearMenu();
7246
7247
  process.stdin.removeListener("keypress", onKeypress);
7247
7248
  if (process.stdin.isTTY) {
7248
7249
  try {
7249
7250
  process.stdin.setRawMode(false);
7250
7251
  } catch {}
7251
7252
  }
7253
+ if (lastCursorRowFromTop > 0) {
7254
+ process.stdout.write(`\x1B[${lastCursorRowFromTop}A`);
7255
+ }
7256
+ process.stdout.write("\r\x1B[J");
7252
7257
  if (result.trim().length > 0 && !result.startsWith("/")) {
7253
- process.stdout.write(`\x1B[1A\r\x1B[2K\x1B[J${CliFormatter.formatClaudeUserPrompt(result)}
7258
+ process.stdout.write(`${CliFormatter.formatClaudeUserPrompt(result)}
7254
7259
 
7255
7260
  `);
7256
7261
  } else {
7257
- process.stdout.write(`\x1B[1A\r\x1B[2K\x1B[J
7262
+ process.stdout.write(`
7258
7263
  `);
7259
7264
  }
7260
7265
  resolve17(result);
@@ -7275,7 +7280,10 @@ class InteractiveLineEditor {
7275
7280
  if (process.stdout && typeof process.stdout.removeListener === "function") {
7276
7281
  process.stdout.removeListener("resize", onResize);
7277
7282
  }
7278
- clearMenu();
7283
+ if (lastCursorRowFromTop > 0) {
7284
+ process.stdout.write(`\x1B[${lastCursorRowFromTop}A`);
7285
+ }
7286
+ process.stdout.write("\r\x1B[J");
7279
7287
  if (process.stdin.isTTY) {
7280
7288
  try {
7281
7289
  process.stdin.setRawMode(false);
@@ -7290,12 +7298,9 @@ class InteractiveLineEditor {
7290
7298
  process.exit(0);
7291
7299
  }
7292
7300
  if (key.name === "escape") {
7293
- if (renderedMenuLines > 0) {
7294
- popupDismissed = true;
7295
- clearMenu();
7296
- redraw();
7297
- return;
7298
- }
7301
+ popupDismissed = true;
7302
+ redraw();
7303
+ return;
7299
7304
  }
7300
7305
  if (key.ctrl && key.name === "d") {
7301
7306
  cleanupAndResolve("/exit");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikaa-ai/pikaa",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "description": "PIKAA CLI - AI coding agent that runs locally in your terminal.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",