blun-king-cli 3.0.4 → 3.0.6

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/bin/blun.js +35 -8
  2. package/package.json +1 -1
package/bin/blun.js CHANGED
@@ -578,26 +578,43 @@ async function handleCommand(input) {
578
578
  // ── Global UI bridge (set by interactive mode) ──
579
579
  var _globalDrawPrompt = null;
580
580
  var _globalEraseUI = null;
581
+ var _globalUILines = 5; // how many lines the input box takes up
581
582
 
582
583
  // ── Chat ──
583
584
  async function sendChat(message) {
584
585
  try {
585
586
  printUserMessage(message);
586
- // Animated thinking + redraw input box
587
+
588
+ // Show thinking status line
587
589
  var dots = 0;
588
590
  var thinkFrames = ["thinking", "thinking.", "thinking..", "thinking..."];
589
- console.log(""); // space for thinking text
591
+ var thinkText = C.dim + " " + BOX.bot + " thinking " + C.reset;
592
+ process.stdout.write("\n" + thinkText + "\n");
593
+
594
+ // Draw input box below thinking — user can type ahead
595
+ if (_globalDrawPrompt) { processing = false; _globalDrawPrompt(); processing = true; }
596
+
597
+ // Animate thinking: move up to thinking line, update, move back down
590
598
  var thinkTimer = setInterval(function() {
599
+ process.stdout.write("\x1b[s"); // save cursor position
600
+ // Move up past the input box to the thinking line
601
+ var uiLines = _globalDrawPrompt ? (_globalUILines || 4) + 1 : 1;
602
+ process.stdout.write("\x1b[" + uiLines + "A"); // move up
591
603
  process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " " + thinkFrames[dots % 4] + " " + C.reset);
604
+ process.stdout.write("\x1b[u"); // restore cursor position
592
605
  dots++;
593
606
  }, 300);
607
+
594
608
  var resp = await apiCall("POST", "/chat", {
595
609
  message: message,
596
610
  history: chatHistory.slice(-10)
597
611
  });
598
612
 
599
613
  clearInterval(thinkTimer);
600
- process.stdout.write("\r\x1b[2K");
614
+ // Erase the input box drawn during thinking
615
+ if (_globalEraseUI) _globalEraseUI();
616
+ // Clear thinking line: move up 1 from current pos, clear, move back
617
+ process.stdout.write("\x1b[1A\r\x1b[2K\x1b[1B");
601
618
 
602
619
  if (resp.status !== 200) {
603
620
  printError(resp.data.error || "API Error " + resp.status);
@@ -1517,12 +1534,19 @@ async function cmdAgent(args) {
1517
1534
  var context = [];
1518
1535
  var workdir = config.workdir;
1519
1536
 
1520
- // Show thinking animation + keep input box
1521
- console.log(""); // space for status
1537
+ // Show thinking status + input box below
1538
+ process.stdout.write("\n" + C.dim + " " + BOX.bot + " [planning] working..." + C.reset + "\n");
1539
+ if (_globalDrawPrompt) { processing = false; _globalDrawPrompt(); processing = true; }
1540
+
1522
1541
  var thinkTimer = setInterval(function() {
1523
1542
  var phase = loop === 0 ? "planning" : "step " + loop + "/" + maxLoops;
1543
+ process.stdout.write("\x1b[s");
1544
+ var uiLines = _globalDrawPrompt ? (_globalUILines || 4) + 1 : 1;
1545
+ process.stdout.write("\x1b[" + uiLines + "A");
1524
1546
  process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " [" + phase + "] working..." + C.reset);
1547
+ process.stdout.write("\x1b[u");
1525
1548
  }, 300);
1549
+
1526
1550
  while (loop < maxLoops) {
1527
1551
  loop++;
1528
1552
 
@@ -1535,7 +1559,8 @@ async function cmdAgent(args) {
1535
1559
 
1536
1560
  if (resp.status !== 200) {
1537
1561
  clearInterval(thinkTimer);
1538
- process.stdout.write("\r\x1b[2K");
1562
+ if (_globalEraseUI) _globalEraseUI();
1563
+ process.stdout.write("\x1b[1A\r\x1b[2K\x1b[1B");
1539
1564
  printError("Step " + loop + " failed: " + (resp.data.error || "Error"));
1540
1565
  break;
1541
1566
  }
@@ -1614,7 +1639,8 @@ async function cmdAgent(args) {
1614
1639
  }
1615
1640
 
1616
1641
  clearInterval(thinkTimer);
1617
- process.stdout.write("\r\x1b[2K");
1642
+ if (_globalEraseUI) _globalEraseUI();
1643
+ process.stdout.write("\x1b[1A\r\x1b[2K\x1b[1B");
1618
1644
 
1619
1645
  // Final summary
1620
1646
  console.log("");
@@ -2739,12 +2765,13 @@ async function main() {
2739
2765
 
2740
2766
  // Track for eraseUI: store how far up the start is from cursor
2741
2767
  uiStartRow = totalLines; // repurpose as "total lines drawn"
2768
+ _globalUILines = totalLines;
2742
2769
 
2743
2770
  process.stdout.write("\x1b[?25h"); // show cursor
2744
2771
  }
2745
2772
 
2746
2773
  // Override eraseUI to use line count
2747
- eraseUI = function() {
2774
+ _globalEraseUI = eraseUI = function() {
2748
2775
  if (uiStartRow <= 0) return;
2749
2776
  process.stdout.write("\x1b[?25l");
2750
2777
  // Cursor is on content line (line 1). Move up 1 to reach top.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "BLUN King CLI — Premium KI Console",
5
5
  "bin": {
6
6
  "blun": "./bin/blun.js"