@iola_adm/iola-cli 0.1.52 → 0.1.53

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 +14 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iola_adm/iola-cli",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
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
@@ -793,7 +793,7 @@ async function startAgentReadline() {
793
793
  }
794
794
 
795
795
  async function startAgentRawInput() {
796
- const state = { history: [], buffer: "", selected: 0, slashOpen: false, running: false, renderedInputLines: 0 };
796
+ const state = { history: [], buffer: "", selected: 0, slashOpen: false, running: false, renderedInputLines: 0, rawMode: true, pendingOutput: "" };
797
797
  emitKeypressEvents(input);
798
798
  const wasRaw = input.isRaw;
799
799
  input.setRawMode(true);
@@ -847,10 +847,11 @@ async function startAgentRawInput() {
847
847
  continue;
848
848
  }
849
849
  output.write(`> ${line}\n`);
850
- const stopActivity = startActivityIndicator("работаю");
850
+ const stopActivity = line.startsWith("/") ? () => {} : startActivityIndicator("работаю");
851
851
  try {
852
852
  const shouldExit = await handleAgentLine(line, state);
853
853
  stopActivity();
854
+ flushPendingAgentOutput(state);
854
855
  if (shouldExit) break;
855
856
  } catch (error) {
856
857
  stopActivity();
@@ -873,9 +874,10 @@ async function startAgentRawInput() {
873
874
 
874
875
  async function handleAgentLine(line, state) {
875
876
  if (!line.startsWith("/")) {
876
- const answer = await aiAsk([line], { history: state.history });
877
+ const answer = await aiAsk(state.rawMode ? [line, "--quiet"] : [line], { history: state.history });
877
878
  state.history.push({ role: "user", content: line });
878
879
  state.history.push({ role: "assistant", content: answer });
880
+ if (state.rawMode) state.pendingOutput = answer;
879
881
  return false;
880
882
  }
881
883
 
@@ -925,8 +927,9 @@ async function handleAgentLine(line, state) {
925
927
  console.log("Нет предыдущего вопроса для повтора.");
926
928
  return false;
927
929
  }
928
- const answer = await aiAsk([lastUser.content], { history: state.history.slice(0, -2) });
930
+ const answer = await aiAsk(state.rawMode ? [lastUser.content, "--quiet"] : [lastUser.content], { history: state.history.slice(0, -2) });
929
931
  state.history.push({ role: "assistant", content: answer });
932
+ if (state.rawMode) state.pendingOutput = answer;
930
933
  return false;
931
934
  }
932
935
 
@@ -1360,6 +1363,13 @@ function startActivityIndicator(label = "работаю") {
1360
1363
  };
1361
1364
  }
1362
1365
 
1366
+ function flushPendingAgentOutput(state) {
1367
+ const text = state.pendingOutput;
1368
+ state.pendingOutput = "";
1369
+ if (!text) return;
1370
+ console.log(text);
1371
+ }
1372
+
1363
1373
  function colorSlashSelection(row) {
1364
1374
  if (!output.isTTY || process.env.NO_COLOR === "1") return row;
1365
1375
  return `\x1b[38;5;213m${row}\x1b[0m`;