blun-king-cli 2.2.0 → 2.2.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 +51 -0
- package/package.json +1 -1
package/bin/blun.js
CHANGED
|
@@ -2458,6 +2458,57 @@ async function main() {
|
|
|
2458
2458
|
return;
|
|
2459
2459
|
}
|
|
2460
2460
|
|
|
2461
|
+
// Ctrl+V — paste (check clipboard for image)
|
|
2462
|
+
if (key === "\x16") {
|
|
2463
|
+
(async function() {
|
|
2464
|
+
try {
|
|
2465
|
+
var imgPath = path.join(os.tmpdir(), "blun_paste_" + Date.now() + ".png");
|
|
2466
|
+
var isWin = process.platform === "win32";
|
|
2467
|
+
if (isWin) {
|
|
2468
|
+
var psCmd = "powershell -NoProfile -Command \"$img = Get-Clipboard -Format Image; if($img){ $img.Save('" + imgPath.replace(/\\/g, "\\\\") + "'); Write-Output 'OK' } else { Write-Output 'NO' }\"";
|
|
2469
|
+
var psResult = require("child_process").execSync(psCmd, { encoding: "utf8", timeout: 5000 }).trim();
|
|
2470
|
+
if (psResult === "OK" && fs.existsSync(imgPath)) {
|
|
2471
|
+
eraseUI();
|
|
2472
|
+
printInfo("Image pasted from clipboard");
|
|
2473
|
+
var imgData = fs.readFileSync(imgPath).toString("base64");
|
|
2474
|
+
var prompt = inputBuffer.trim() || "Describe this image";
|
|
2475
|
+
processing = true;
|
|
2476
|
+
var resp = await apiCall("POST", "/chat", {
|
|
2477
|
+
message: prompt,
|
|
2478
|
+
image: imgData,
|
|
2479
|
+
history: chatHistory.slice(-10)
|
|
2480
|
+
});
|
|
2481
|
+
if (resp.status === 200) {
|
|
2482
|
+
chatHistory.push({ role: "user", content: "[image] " + prompt });
|
|
2483
|
+
chatHistory.push({ role: "assistant", content: resp.data.answer });
|
|
2484
|
+
printAnswer(resp.data.answer, "vision");
|
|
2485
|
+
} else {
|
|
2486
|
+
printError(resp.data.error || "Vision error");
|
|
2487
|
+
}
|
|
2488
|
+
inputBuffer = "";
|
|
2489
|
+
cursorPos = 0;
|
|
2490
|
+
processing = false;
|
|
2491
|
+
drawPrompt();
|
|
2492
|
+
try { fs.unlinkSync(imgPath); } catch(e) {}
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
// No image — just paste text from clipboard
|
|
2497
|
+
if (isWin) {
|
|
2498
|
+
var clipText = require("child_process").execSync("powershell -NoProfile -Command Get-Clipboard", { encoding: "utf8", timeout: 3000 }).trim();
|
|
2499
|
+
if (clipText) {
|
|
2500
|
+
inputBuffer += clipText;
|
|
2501
|
+
cursorPos = inputBuffer.length;
|
|
2502
|
+
refreshUI();
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
} catch(e) {
|
|
2506
|
+
// Fallback: ignore paste errors
|
|
2507
|
+
}
|
|
2508
|
+
})();
|
|
2509
|
+
return;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2461
2512
|
// Tab — autocomplete from menu
|
|
2462
2513
|
if (key === "\t") {
|
|
2463
2514
|
if (menuVisible && menuItems.length > 0) {
|