blun-king-cli 2.8.0 → 2.9.1
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 +65 -3
- package/package.json +1 -1
package/bin/blun.js
CHANGED
|
@@ -520,13 +520,23 @@ async function handleCommand(input) {
|
|
|
520
520
|
async function sendChat(message) {
|
|
521
521
|
try {
|
|
522
522
|
printUserMessage(message);
|
|
523
|
-
// Animated thinking
|
|
523
|
+
// Animated thinking + keep input box visible
|
|
524
524
|
var dots = 0;
|
|
525
525
|
var thinkFrames = ["thinking", "thinking.", "thinking..", "thinking..."];
|
|
526
|
+
console.log(""); // line for thinking text
|
|
526
527
|
var thinkTimer = setInterval(function() {
|
|
527
|
-
process.stdout.write("\
|
|
528
|
+
process.stdout.write("\x1b[s"); // save cursor
|
|
529
|
+
// Move to thinking line (above the UI)
|
|
530
|
+
if (uiStartRow > 0) process.stdout.write("\x1b[" + (uiStartRow + 1) + "A");
|
|
531
|
+
process.stdout.write("\r\x1b[2K" + C.dim + " " + BOX.bot + " " + thinkFrames[dots % 4] + " " + C.reset);
|
|
532
|
+
process.stdout.write("\x1b[u"); // restore cursor
|
|
528
533
|
dots++;
|
|
529
534
|
}, 300);
|
|
535
|
+
// Redraw input box below thinking line
|
|
536
|
+
processing = false;
|
|
537
|
+
uiStartRow = -1;
|
|
538
|
+
drawPrompt();
|
|
539
|
+
processing = true;
|
|
530
540
|
|
|
531
541
|
var resp = await apiCall("POST", "/chat", {
|
|
532
542
|
message: message,
|
|
@@ -534,7 +544,10 @@ async function sendChat(message) {
|
|
|
534
544
|
});
|
|
535
545
|
|
|
536
546
|
clearInterval(thinkTimer);
|
|
537
|
-
|
|
547
|
+
// Erase UI before printing answer
|
|
548
|
+
eraseUI();
|
|
549
|
+
// Clear thinking line
|
|
550
|
+
process.stdout.write("\x1b[1A\r\x1b[2K");
|
|
538
551
|
|
|
539
552
|
if (resp.status !== 200) {
|
|
540
553
|
printError(resp.data.error || "API Error " + resp.status);
|
|
@@ -2437,6 +2450,52 @@ async function main() {
|
|
|
2437
2450
|
printInfo("Run: blun setup — to configure");
|
|
2438
2451
|
}
|
|
2439
2452
|
|
|
2453
|
+
// Mode selection at startup
|
|
2454
|
+
var sessionMode = "chat"; // chat or agent
|
|
2455
|
+
if (!process.argv.includes("--agent") && !process.argv.includes("--chat")) {
|
|
2456
|
+
console.log("");
|
|
2457
|
+
console.log(C.brightWhite + C.bold + " How do you want to work?" + C.reset);
|
|
2458
|
+
console.log("");
|
|
2459
|
+
var modeOptions = [
|
|
2460
|
+
{ label: "Chat — talk back and forth", mode: "chat" },
|
|
2461
|
+
{ label: "Agent — give a goal, I do the rest autonomously", mode: "agent" }
|
|
2462
|
+
];
|
|
2463
|
+
var modeSel = 0;
|
|
2464
|
+
var modeChoice = await new Promise(function(resolve) {
|
|
2465
|
+
function renderModeMenu() {
|
|
2466
|
+
process.stdout.write("\x1b[2A\r");
|
|
2467
|
+
modeOptions.forEach(function(opt, i) {
|
|
2468
|
+
var prefix = i === modeSel ? C.green + C.bold + " \u276F " : " ";
|
|
2469
|
+
var color = i === modeSel ? C.brightWhite + C.bold : C.gray;
|
|
2470
|
+
process.stdout.write("\x1b[2K" + prefix + color + (i + 1) + ". " + opt.label + C.reset + "\n");
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
console.log(""); console.log("");
|
|
2474
|
+
renderModeMenu();
|
|
2475
|
+
process.stdin.setRawMode(true);
|
|
2476
|
+
process.stdin.resume();
|
|
2477
|
+
process.stdin.setEncoding("utf8");
|
|
2478
|
+
function onKey(key) {
|
|
2479
|
+
if (key === "\x1b[A") { modeSel = 0; renderModeMenu(); return; }
|
|
2480
|
+
if (key === "\x1b[B") { modeSel = 1; renderModeMenu(); return; }
|
|
2481
|
+
if (key === "1") { process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve("chat"); return; }
|
|
2482
|
+
if (key === "2") { process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve("agent"); return; }
|
|
2483
|
+
if (key === "\r" || key === "\n") {
|
|
2484
|
+
process.stdin.removeListener("data", onKey);
|
|
2485
|
+
process.stdin.setRawMode(false);
|
|
2486
|
+
resolve(modeOptions[modeSel].mode);
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
process.stdin.on("data", onKey);
|
|
2491
|
+
});
|
|
2492
|
+
sessionMode = modeChoice;
|
|
2493
|
+
printSuccess("Mode: " + (sessionMode === "agent" ? "Agent (autonomous)" : "Chat (interactive)"));
|
|
2494
|
+
console.log("");
|
|
2495
|
+
} else {
|
|
2496
|
+
sessionMode = process.argv.includes("--agent") ? "agent" : "chat";
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2440
2499
|
var ALL_COMMANDS = [
|
|
2441
2500
|
"/help", "/clear", "/skills", "/skill", "/search", "/learn", "/learn-url",
|
|
2442
2501
|
"/generate", "/analyze", "/score", "/eval", "/settings", "/set",
|
|
@@ -2672,6 +2731,9 @@ async function main() {
|
|
|
2672
2731
|
runHook("pre", detected.split(/\s+/)[0].slice(1));
|
|
2673
2732
|
await handleCommand(detected);
|
|
2674
2733
|
runHook("post", detected.split(/\s+/)[0].slice(1));
|
|
2734
|
+
} else if (sessionMode === "agent") {
|
|
2735
|
+
// Agent mode: auto-route to autonomous agent
|
|
2736
|
+
await cmdAgent(input);
|
|
2675
2737
|
} else {
|
|
2676
2738
|
await sendChat(input);
|
|
2677
2739
|
}
|