blun-king-cli 3.0.2 → 3.0.3
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 +34 -13
- package/package.json +1 -1
package/bin/blun.js
CHANGED
|
@@ -274,18 +274,21 @@ async function streamAnswer(answer, meta) {
|
|
|
274
274
|
else if (line.match(/^\s*\d+\.\s/)) { var m = line.match(/^(\s*\d+\.)\s(.*)/); prefix = " " + C.yellow + m[1] + C.reset + " "; text = m[2]; }
|
|
275
275
|
else if (line.trim() === "") { console.log(""); continue; }
|
|
276
276
|
|
|
277
|
-
// Stream words
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
277
|
+
// Stream words with word-wrap
|
|
278
|
+
var wrappedLines = wordWrap(text, 4);
|
|
279
|
+
for (var wl = 0; wl < wrappedLines.length; wl++) {
|
|
280
|
+
var words = wrappedLines[wl].split(" ");
|
|
281
|
+
process.stdout.write(wl === 0 ? prefix : " ");
|
|
282
|
+
for (var w = 0; w < words.length; w++) {
|
|
283
|
+
var word = words[w];
|
|
284
|
+
// Inline formatting
|
|
285
|
+
word = word.replace(/\*\*(.+?)\*\*/g, C.bold + C.brightWhite + "$1" + C.reset);
|
|
286
|
+
word = word.replace(/`(.+?)`/g, C.cyan + "$1" + C.reset);
|
|
287
|
+
process.stdout.write(word + (w < words.length - 1 ? " " : ""));
|
|
288
|
+
await new Promise(function(r) { setTimeout(r, delay); });
|
|
289
|
+
}
|
|
290
|
+
process.stdout.write((wl === wrappedLines.length - 1 ? color : "") + "\n");
|
|
287
291
|
}
|
|
288
|
-
process.stdout.write(color + "\n");
|
|
289
292
|
}
|
|
290
293
|
console.log("");
|
|
291
294
|
}
|
|
@@ -572,17 +575,28 @@ async function handleCommand(input) {
|
|
|
572
575
|
}
|
|
573
576
|
}
|
|
574
577
|
|
|
578
|
+
// ── Global UI bridge (set by interactive mode) ──
|
|
579
|
+
var _globalDrawPrompt = null;
|
|
580
|
+
var _globalEraseUI = null;
|
|
581
|
+
|
|
575
582
|
// ── Chat ──
|
|
576
583
|
async function sendChat(message) {
|
|
577
584
|
try {
|
|
578
585
|
printUserMessage(message);
|
|
579
|
-
// Animated thinking
|
|
586
|
+
// Animated thinking + redraw input box
|
|
580
587
|
var dots = 0;
|
|
581
588
|
var thinkFrames = ["thinking", "thinking.", "thinking..", "thinking..."];
|
|
589
|
+
console.log(""); // space for thinking text
|
|
582
590
|
var thinkTimer = setInterval(function() {
|
|
583
591
|
process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " " + thinkFrames[dots % 4] + " " + C.reset);
|
|
584
592
|
dots++;
|
|
585
593
|
}, 300);
|
|
594
|
+
// Redraw input box below thinking line so user sees the prompt
|
|
595
|
+
if (_globalDrawPrompt) {
|
|
596
|
+
processing = false;
|
|
597
|
+
_globalDrawPrompt();
|
|
598
|
+
processing = true;
|
|
599
|
+
}
|
|
586
600
|
|
|
587
601
|
var resp = await apiCall("POST", "/chat", {
|
|
588
602
|
message: message,
|
|
@@ -1510,11 +1524,17 @@ async function cmdAgent(args) {
|
|
|
1510
1524
|
var context = [];
|
|
1511
1525
|
var workdir = config.workdir;
|
|
1512
1526
|
|
|
1513
|
-
// Show thinking animation
|
|
1527
|
+
// Show thinking animation + keep input box
|
|
1528
|
+
console.log(""); // space for status
|
|
1514
1529
|
var thinkTimer = setInterval(function() {
|
|
1515
1530
|
var phase = loop === 0 ? "planning" : "step " + loop + "/" + maxLoops;
|
|
1516
1531
|
process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " [" + phase + "] working..." + C.reset);
|
|
1517
1532
|
}, 300);
|
|
1533
|
+
if (_globalDrawPrompt) {
|
|
1534
|
+
processing = false;
|
|
1535
|
+
_globalDrawPrompt();
|
|
1536
|
+
processing = true;
|
|
1537
|
+
}
|
|
1518
1538
|
|
|
1519
1539
|
while (loop < maxLoops) {
|
|
1520
1540
|
loop++;
|
|
@@ -2770,6 +2790,7 @@ async function main() {
|
|
|
2770
2790
|
}
|
|
2771
2791
|
|
|
2772
2792
|
function drawPrompt() {
|
|
2793
|
+
_globalDrawPrompt = drawPrompt; // expose globally
|
|
2773
2794
|
if (processing) return;
|
|
2774
2795
|
console.log(""); // spacing
|
|
2775
2796
|
uiStartRow = -1;
|