blun-king-cli 3.0.5 → 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.
- package/bin/blun.js +33 -22
- package/package.json +1 -1
package/bin/blun.js
CHANGED
|
@@ -578,25 +578,32 @@ 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
|
-
|
|
587
|
+
|
|
588
|
+
// Show thinking status line
|
|
587
589
|
var dots = 0;
|
|
588
590
|
var thinkFrames = ["thinking", "thinking.", "thinking..", "thinking..."];
|
|
589
|
-
var
|
|
590
|
-
|
|
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
|
|
591
598
|
var thinkTimer = setInterval(function() {
|
|
592
|
-
process.stdout.write("\x1b[s"); // save cursor
|
|
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
|
|
593
603
|
process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " " + thinkFrames[dots % 4] + " " + C.reset);
|
|
594
|
-
process.stdout.write("\x1b[u"); // restore cursor
|
|
604
|
+
process.stdout.write("\x1b[u"); // restore cursor position
|
|
595
605
|
dots++;
|
|
596
606
|
}, 300);
|
|
597
|
-
// Show input box below thinking so user can type ahead
|
|
598
|
-
console.log("");
|
|
599
|
-
if (_globalDrawPrompt) { processing = false; _globalDrawPrompt(); processing = true; }
|
|
600
607
|
|
|
601
608
|
var resp = await apiCall("POST", "/chat", {
|
|
602
609
|
message: message,
|
|
@@ -604,10 +611,10 @@ async function sendChat(message) {
|
|
|
604
611
|
});
|
|
605
612
|
|
|
606
613
|
clearInterval(thinkTimer);
|
|
607
|
-
//
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
|
|
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");
|
|
611
618
|
|
|
612
619
|
if (resp.status !== 200) {
|
|
613
620
|
printError(resp.data.error || "API Error " + resp.status);
|
|
@@ -1527,17 +1534,18 @@ async function cmdAgent(args) {
|
|
|
1527
1534
|
var context = [];
|
|
1528
1535
|
var workdir = config.workdir;
|
|
1529
1536
|
|
|
1530
|
-
// Show thinking
|
|
1531
|
-
|
|
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
|
+
|
|
1532
1541
|
var thinkTimer = setInterval(function() {
|
|
1533
1542
|
var phase = loop === 0 ? "planning" : "step " + loop + "/" + maxLoops;
|
|
1534
|
-
process.stdout.write("\x1b[s");
|
|
1543
|
+
process.stdout.write("\x1b[s");
|
|
1544
|
+
var uiLines = _globalDrawPrompt ? (_globalUILines || 4) + 1 : 1;
|
|
1545
|
+
process.stdout.write("\x1b[" + uiLines + "A");
|
|
1535
1546
|
process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " [" + phase + "] working..." + C.reset);
|
|
1536
|
-
process.stdout.write("\x1b[u");
|
|
1547
|
+
process.stdout.write("\x1b[u");
|
|
1537
1548
|
}, 300);
|
|
1538
|
-
// Show input box below thinking
|
|
1539
|
-
console.log("");
|
|
1540
|
-
if (_globalDrawPrompt) { processing = false; _globalDrawPrompt(); processing = true; }
|
|
1541
1549
|
|
|
1542
1550
|
while (loop < maxLoops) {
|
|
1543
1551
|
loop++;
|
|
@@ -1551,7 +1559,8 @@ async function cmdAgent(args) {
|
|
|
1551
1559
|
|
|
1552
1560
|
if (resp.status !== 200) {
|
|
1553
1561
|
clearInterval(thinkTimer);
|
|
1554
|
-
|
|
1562
|
+
if (_globalEraseUI) _globalEraseUI();
|
|
1563
|
+
process.stdout.write("\x1b[1A\r\x1b[2K\x1b[1B");
|
|
1555
1564
|
printError("Step " + loop + " failed: " + (resp.data.error || "Error"));
|
|
1556
1565
|
break;
|
|
1557
1566
|
}
|
|
@@ -1630,7 +1639,8 @@ async function cmdAgent(args) {
|
|
|
1630
1639
|
}
|
|
1631
1640
|
|
|
1632
1641
|
clearInterval(thinkTimer);
|
|
1633
|
-
|
|
1642
|
+
if (_globalEraseUI) _globalEraseUI();
|
|
1643
|
+
process.stdout.write("\x1b[1A\r\x1b[2K\x1b[1B");
|
|
1634
1644
|
|
|
1635
1645
|
// Final summary
|
|
1636
1646
|
console.log("");
|
|
@@ -2755,12 +2765,13 @@ async function main() {
|
|
|
2755
2765
|
|
|
2756
2766
|
// Track for eraseUI: store how far up the start is from cursor
|
|
2757
2767
|
uiStartRow = totalLines; // repurpose as "total lines drawn"
|
|
2768
|
+
_globalUILines = totalLines;
|
|
2758
2769
|
|
|
2759
2770
|
process.stdout.write("\x1b[?25h"); // show cursor
|
|
2760
2771
|
}
|
|
2761
2772
|
|
|
2762
2773
|
// Override eraseUI to use line count
|
|
2763
|
-
eraseUI = function() {
|
|
2774
|
+
_globalEraseUI = eraseUI = function() {
|
|
2764
2775
|
if (uiStartRow <= 0) return;
|
|
2765
2776
|
process.stdout.write("\x1b[?25l");
|
|
2766
2777
|
// Cursor is on content line (line 1). Move up 1 to reach top.
|