blun-king-cli 5.1.0 → 5.1.2
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/blun-cli.js +30 -17
- package/package.json +1 -1
package/blun-cli.js
CHANGED
|
@@ -2615,19 +2615,18 @@ async function main() {
|
|
|
2615
2615
|
];
|
|
2616
2616
|
var trustSel = 0;
|
|
2617
2617
|
|
|
2618
|
-
// Arrow key menu for trust selection
|
|
2618
|
+
// Arrow key menu for trust selection (PowerShell compatible)
|
|
2619
2619
|
var trustChoice = await new Promise(function(resolve) {
|
|
2620
2620
|
function renderTrustMenu() {
|
|
2621
|
-
//
|
|
2622
|
-
|
|
2621
|
+
// Use VT100 cursor save/restore for Windows compatibility
|
|
2622
|
+
process.stdout.write("\x1b[s"); // save cursor
|
|
2623
2623
|
trustOptions.forEach(function(opt, i) {
|
|
2624
2624
|
var prefix = i === trustSel ? C.green + C.bold + " \u276F " : " ";
|
|
2625
2625
|
var color = i === trustSel ? C.brightWhite + C.bold : C.gray;
|
|
2626
|
-
process.stdout.write(
|
|
2626
|
+
process.stdout.write(prefix + color + (i + 1) + ". " + opt.label + C.reset + "\x1b[K\n");
|
|
2627
2627
|
});
|
|
2628
|
+
process.stdout.write("\x1b[u"); // restore cursor
|
|
2628
2629
|
}
|
|
2629
|
-
// Initial render
|
|
2630
|
-
console.log(""); console.log(""); console.log("");
|
|
2631
2630
|
renderTrustMenu();
|
|
2632
2631
|
|
|
2633
2632
|
process.stdin.setRawMode(true);
|
|
@@ -2636,15 +2635,17 @@ async function main() {
|
|
|
2636
2635
|
function onKey(key) {
|
|
2637
2636
|
if (key === "\x1b[A") { trustSel = Math.max(0, trustSel - 1); renderTrustMenu(); return; }
|
|
2638
2637
|
if (key === "\x1b[B") { trustSel = Math.min(2, trustSel + 1); renderTrustMenu(); return; }
|
|
2639
|
-
if (key === "1") { trustSel = 0; process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve(trustOptions[0].action); return; }
|
|
2640
|
-
if (key === "2") { trustSel = 1; process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve(trustOptions[1].action); return; }
|
|
2641
|
-
if (key === "3") { trustSel = 2; process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve(trustOptions[2].action); return; }
|
|
2638
|
+
if (key === "1") { trustSel = 0; process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); process.stdout.write("\n\n\n"); resolve(trustOptions[0].action); return; }
|
|
2639
|
+
if (key === "2") { trustSel = 1; process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); process.stdout.write("\n\n\n"); resolve(trustOptions[1].action); return; }
|
|
2640
|
+
if (key === "3") { trustSel = 2; process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); process.stdout.write("\n\n\n"); resolve(trustOptions[2].action); return; }
|
|
2642
2641
|
if (key === "\r" || key === "\n") {
|
|
2643
2642
|
process.stdin.removeListener("data", onKey);
|
|
2644
2643
|
process.stdin.setRawMode(false);
|
|
2644
|
+
process.stdout.write("\n\n\n");
|
|
2645
2645
|
resolve(trustOptions[trustSel].action);
|
|
2646
2646
|
return;
|
|
2647
2647
|
}
|
|
2648
|
+
if (key === "\x03") { process.exit(0); }
|
|
2648
2649
|
}
|
|
2649
2650
|
process.stdin.on("data", onKey);
|
|
2650
2651
|
});
|
|
@@ -2689,13 +2690,23 @@ async function main() {
|
|
|
2689
2690
|
printHeader();
|
|
2690
2691
|
checkForUpdates();
|
|
2691
2692
|
|
|
2692
|
-
// API
|
|
2693
|
-
if (
|
|
2694
|
-
|
|
2693
|
+
// API Key check — prompt if missing
|
|
2694
|
+
if (!config.api.key && !process.argv.includes("--api-key")) {
|
|
2695
|
+
console.log("");
|
|
2696
|
+
console.log(C.yellow + " " + BOX.bot + " No API key configured." + C.reset);
|
|
2697
|
+
console.log(C.gray + " Enter your BLUN King API key (or press Enter to skip):" + C.reset);
|
|
2698
|
+
var apiKeyAnswer = await new Promise(function(resolve) {
|
|
2699
|
+
var rlKey = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
2700
|
+
rlKey.question(C.brightBlue + " API Key: " + C.reset, function(answer) {
|
|
2701
|
+
rlKey.close();
|
|
2702
|
+
resolve(answer.trim());
|
|
2703
|
+
});
|
|
2704
|
+
});
|
|
2695
2705
|
if (apiKeyAnswer) {
|
|
2696
2706
|
config.api.key = apiKeyAnswer;
|
|
2697
2707
|
var cfgFile = path.join(CONFIG_DIR, "config.json");
|
|
2698
2708
|
var cfgData = {};
|
|
2709
|
+
if (fs.existsSync(cfgFile)) { try { cfgData = JSON.parse(fs.readFileSync(cfgFile, "utf8")); } catch(e) {} }
|
|
2699
2710
|
if (!cfgData.api) cfgData.api = {};
|
|
2700
2711
|
cfgData.api.key = apiKeyAnswer;
|
|
2701
2712
|
fs.writeFileSync(cfgFile, JSON.stringify(cfgData, null, 2));
|
|
@@ -2730,14 +2741,14 @@ async function main() {
|
|
|
2730
2741
|
var modeSel = 0;
|
|
2731
2742
|
var modeChoice = await new Promise(function(resolve) {
|
|
2732
2743
|
function renderModeMenu() {
|
|
2733
|
-
process.stdout.write("\x1b[
|
|
2744
|
+
process.stdout.write("\x1b[s");
|
|
2734
2745
|
modeOptions.forEach(function(opt, i) {
|
|
2735
2746
|
var prefix = i === modeSel ? C.green + C.bold + " \u276F " : " ";
|
|
2736
2747
|
var color = i === modeSel ? C.brightWhite + C.bold : C.gray;
|
|
2737
|
-
process.stdout.write(
|
|
2748
|
+
process.stdout.write(prefix + color + (i + 1) + ". " + opt.label + C.reset + "\x1b[K\n");
|
|
2738
2749
|
});
|
|
2750
|
+
process.stdout.write("\x1b[u");
|
|
2739
2751
|
}
|
|
2740
|
-
console.log(""); console.log("");
|
|
2741
2752
|
renderModeMenu();
|
|
2742
2753
|
process.stdin.setRawMode(true);
|
|
2743
2754
|
process.stdin.resume();
|
|
@@ -2745,14 +2756,16 @@ async function main() {
|
|
|
2745
2756
|
function onKey(key) {
|
|
2746
2757
|
if (key === "\x1b[A") { modeSel = 0; renderModeMenu(); return; }
|
|
2747
2758
|
if (key === "\x1b[B") { modeSel = 1; renderModeMenu(); return; }
|
|
2748
|
-
if (key === "1") { process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve("chat"); return; }
|
|
2749
|
-
if (key === "2") { process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); resolve("agent"); return; }
|
|
2759
|
+
if (key === "1") { process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); process.stdout.write("\n\n"); resolve("chat"); return; }
|
|
2760
|
+
if (key === "2") { process.stdin.removeListener("data", onKey); process.stdin.setRawMode(false); process.stdout.write("\n\n"); resolve("agent"); return; }
|
|
2750
2761
|
if (key === "\r" || key === "\n") {
|
|
2751
2762
|
process.stdin.removeListener("data", onKey);
|
|
2752
2763
|
process.stdin.setRawMode(false);
|
|
2764
|
+
process.stdout.write("\n\n");
|
|
2753
2765
|
resolve(modeOptions[modeSel].mode);
|
|
2754
2766
|
return;
|
|
2755
2767
|
}
|
|
2768
|
+
if (key === "\x03") { process.exit(0); }
|
|
2756
2769
|
}
|
|
2757
2770
|
process.stdin.on("data", onKey);
|
|
2758
2771
|
});
|