@iola_adm/iola-cli 0.1.81 → 0.1.82

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/package.json +1 -1
  2. package/src/cli.js +37 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iola_adm/iola-cli",
3
- "version": "0.1.81",
3
+ "version": "0.1.82",
4
4
  "description": "CLI и AI-агент городского округа Йошкар-Ола.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/adm-iola/iola-cli#readme",
package/src/cli.js CHANGED
@@ -774,9 +774,10 @@ async function startAgentReadline() {
774
774
  }
775
775
 
776
776
  async function startAgentRawInput() {
777
- const state = { history: [], buffer: "", selected: 0, slashOffset: 0, slashOpen: false, running: false, renderedInputLines: 0, renderedLines: 0, rawMode: true, pendingOutput: "", aiStatus: null };
777
+ const state = { history: [], buffer: "", selected: 0, slashOffset: 0, slashOpen: false, running: false, renderedInputLines: 0, renderedLines: 0, rawMode: true, pendingOutput: "", aiStatus: null, statusBar: false, statusRows: 0 };
778
778
  const wasRaw = input.isRaw;
779
779
  activateRawInput(input);
780
+ setupAgentStatusBar(state);
780
781
 
781
782
  await refreshAgentAiStatus(state);
782
783
  const render = () => renderAgentInput(state);
@@ -857,6 +858,8 @@ async function startAgentRawInput() {
857
858
  }
858
859
  }
859
860
  } finally {
861
+ clearAgentInputArea(state);
862
+ clearAgentStatusBar(state);
860
863
  if (!wasRaw) input.setRawMode(false);
861
864
  input.pause();
862
865
  }
@@ -1305,8 +1308,6 @@ function renderAgentInput(state) {
1305
1308
  const prompt = "> ";
1306
1309
  const lines = state.buffer.split("\n");
1307
1310
  const inputLines = [`${prompt}${lines[0] || ""}`, ...lines.slice(1)];
1308
- const statusLine = truncateTerminalLine(` ${buildAgentStatusLine(state)}`);
1309
- const cwdLine = colorMuted(statusLine);
1310
1311
  const menuLines = [];
1311
1312
  if (state.slashOpen) {
1312
1313
  const matches = currentSlashMatches(state);
@@ -1328,7 +1329,8 @@ function renderAgentInput(state) {
1328
1329
  }
1329
1330
  }
1330
1331
 
1331
- const renderedLines = [cwdLine, ...menuLines, ...inputLines];
1332
+ renderAgentStatusBar(state);
1333
+ const renderedLines = [...menuLines, ...inputLines];
1332
1334
  output.write(renderedLines.join("\n"));
1333
1335
  if (output.isTTY) {
1334
1336
  const cursorColumn = visibleLength(inputLines[inputLines.length - 1]);
@@ -1349,6 +1351,37 @@ function clearAgentInputArea(state = null) {
1349
1351
  }
1350
1352
  }
1351
1353
 
1354
+ function setupAgentStatusBar(state) {
1355
+ if (!output.isTTY) return;
1356
+ const rows = Number(output.rows || 0);
1357
+ if (rows < 4) return;
1358
+ state.statusBar = true;
1359
+ state.statusRows = rows;
1360
+ output.write(`\x1b[1;${rows - 1}r`);
1361
+ output.write(`\x1b[${rows - 1};1H`);
1362
+ }
1363
+
1364
+ function renderAgentStatusBar(state) {
1365
+ if (!output.isTTY || !state.statusBar) return;
1366
+ const rows = Number(output.rows || state.statusRows || 0);
1367
+ if (rows < 4) return;
1368
+ if (rows !== state.statusRows) {
1369
+ state.statusRows = rows;
1370
+ output.write(`\x1b[1;${rows - 1}r`);
1371
+ }
1372
+ const statusLine = colorMuted(truncateTerminalLine(` ${buildAgentStatusLine(state)} `));
1373
+ output.write(`\x1b7\x1b[${rows};1H\x1b[2K${statusLine}\x1b8`);
1374
+ }
1375
+
1376
+ function clearAgentStatusBar(state) {
1377
+ if (!output.isTTY || !state?.statusBar) return;
1378
+ const rows = Number(output.rows || state.statusRows || 0);
1379
+ output.write("\x1b[r");
1380
+ if (rows >= 1) output.write(`\x1b7\x1b[${rows};1H\x1b[2K\x1b8`);
1381
+ state.statusBar = false;
1382
+ state.statusRows = 0;
1383
+ }
1384
+
1352
1385
  function startActivityIndicator(label = "работаю") {
1353
1386
  const doneLabel = "готово";
1354
1387
  if (!output.isTTY || process.env.NO_COLOR === "1") {