blun-king-cli 5.0.0 → 5.0.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/blun-cli.js +61 -4
- package/package.json +1 -1
package/blun-cli.js
CHANGED
|
@@ -12,7 +12,7 @@ const CONFIG_FILE = path.join(HOME, "config.json");
|
|
|
12
12
|
if (!fs.existsSync(HOME)) fs.mkdirSync(HOME, { recursive: true });
|
|
13
13
|
|
|
14
14
|
const DEFAULT_CONFIG = {
|
|
15
|
-
apiUrl: process.env.BLUN_API_URL || "http://
|
|
15
|
+
apiUrl: process.env.BLUN_API_URL || "http://176.9.158.30:3200",
|
|
16
16
|
token: process.env.BLUN_API_TOKEN || "",
|
|
17
17
|
streamLevel: "normal"
|
|
18
18
|
};
|
|
@@ -506,15 +506,72 @@ async function main() {
|
|
|
506
506
|
renderPrompt();
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
// ── Trust Prompt ──
|
|
510
|
+
const TRUST_FILE = path.join(HOME, "trusted.json");
|
|
511
|
+
let trustedDirs = [];
|
|
512
|
+
try { if (fs.existsSync(TRUST_FILE)) trustedDirs = JSON.parse(fs.readFileSync(TRUST_FILE, "utf8")); } catch {}
|
|
513
|
+
const isTrusted = trustedDirs.includes(workdir) || process.argv.includes("--trust");
|
|
514
|
+
|
|
515
|
+
if (!isTrusted && process.stdin.isTTY) {
|
|
516
|
+
console.log("");
|
|
517
|
+
console.log(` \u{1F4C1} Working in: ${workdir}`);
|
|
518
|
+
console.log(" Do you trust this folder? BLUN King will read/write files here.");
|
|
519
|
+
console.log("");
|
|
520
|
+
const trustRl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
521
|
+
const trustAnswer = await new Promise((resolve) => {
|
|
522
|
+
trustRl.question(" [Y]es / [A]lways / [C]hoose another > ", resolve);
|
|
523
|
+
});
|
|
524
|
+
trustRl.close();
|
|
525
|
+
const t = trustAnswer.trim().toLowerCase();
|
|
526
|
+
if (t === "a" || t === "always") {
|
|
527
|
+
trustedDirs.push(workdir);
|
|
528
|
+
fs.writeFileSync(TRUST_FILE, JSON.stringify(trustedDirs, null, 2));
|
|
529
|
+
console.log(" Folder trusted permanently.");
|
|
530
|
+
} else if (t === "c" || t === "choose") {
|
|
531
|
+
const dirRl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
532
|
+
const newDir = await new Promise((resolve) => {
|
|
533
|
+
dirRl.question(" Enter path: ", resolve);
|
|
534
|
+
});
|
|
535
|
+
dirRl.close();
|
|
536
|
+
if (newDir && fs.existsSync(newDir.trim())) {
|
|
537
|
+
process.chdir(newDir.trim());
|
|
538
|
+
console.log(` Workspace: ${newDir.trim()}`);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
console.log("");
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// ── Mode Selection ──
|
|
545
|
+
if (!process.argv.includes("--agent") && !process.argv.includes("--chat") && process.stdin.isTTY) {
|
|
546
|
+
console.log(" How do you want to work?");
|
|
547
|
+
console.log(" [1] Chat — talk back and forth");
|
|
548
|
+
console.log(" [2] Agent — give a goal, I do the rest autonomously");
|
|
549
|
+
console.log("");
|
|
550
|
+
const modeRl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
551
|
+
const modeAnswer = await new Promise((resolve) => {
|
|
552
|
+
modeRl.question(" > ", resolve);
|
|
553
|
+
});
|
|
554
|
+
modeRl.close();
|
|
555
|
+
if (modeAnswer.trim() === "1" || modeAnswer.trim().toLowerCase() === "chat") {
|
|
556
|
+
mode = "chat";
|
|
557
|
+
} else {
|
|
558
|
+
mode = "agent";
|
|
559
|
+
}
|
|
560
|
+
console.log(` Mode: ${mode}`);
|
|
561
|
+
console.log("");
|
|
562
|
+
}
|
|
563
|
+
if (process.argv.includes("--chat")) mode = "chat";
|
|
564
|
+
|
|
565
|
+
// ── Startup ──
|
|
509
566
|
try {
|
|
510
567
|
const health = await fetch(`${cfg.apiUrl}/health`).then((resp) => resp.json());
|
|
511
|
-
console.log(`Connected to BLUN King API (${health.model})`);
|
|
568
|
+
console.log(` Connected to BLUN King API (${health.model})`);
|
|
512
569
|
} catch (error) {
|
|
513
|
-
console.error(`API connection failed: ${error.message}`);
|
|
570
|
+
console.error(` API connection failed: ${error.message}`);
|
|
514
571
|
}
|
|
515
572
|
|
|
516
573
|
console.log("");
|
|
517
|
-
console.log(" BLUN KING CLI v5.0.
|
|
574
|
+
console.log(" BLUN KING CLI v5.0.1");
|
|
518
575
|
console.log(` API: ${cfg.apiUrl}`);
|
|
519
576
|
console.log(` Dir: ${workdir}`);
|
|
520
577
|
console.log(" Chat input stays available while jobs run.");
|