blun-king-cli 7.2.1 → 7.2.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/lib/chat.js +25 -13
- package/package.json +1 -1
package/lib/chat.js
CHANGED
|
@@ -40,7 +40,7 @@ var SLASH_COMMANDS = [
|
|
|
40
40
|
var slashNames = SLASH_COMMANDS.map(function (c) { return c[0]; });
|
|
41
41
|
|
|
42
42
|
// ── Layout Constants ─────────────────────────────────────
|
|
43
|
-
var INPUT_PANEL_HEIGHT =
|
|
43
|
+
var INPUT_PANEL_HEIGHT = 7; // 2 gap + top-frame + input + blank + status + bottom-frame
|
|
44
44
|
|
|
45
45
|
function getRows() { return process.stdout.rows || 24; }
|
|
46
46
|
function getCols() { return process.stdout.columns || 80; }
|
|
@@ -102,7 +102,7 @@ function startChat() {
|
|
|
102
102
|
var rows = getRows();
|
|
103
103
|
var cols = getCols();
|
|
104
104
|
var t = ui.getTheme();
|
|
105
|
-
var panelTop = rows - INPUT_PANEL_HEIGHT +
|
|
105
|
+
var panelTop = rows - INPUT_PANEL_HEIGHT + 3; // +3 to leave 2 empty rows at top of panel area
|
|
106
106
|
var inner = cols - 2;
|
|
107
107
|
|
|
108
108
|
// Permission label
|
|
@@ -129,29 +129,35 @@ function startChat() {
|
|
|
129
129
|
// Save cursor position in scroll region
|
|
130
130
|
process.stdout.write(saveCursor());
|
|
131
131
|
|
|
132
|
-
// Row 1: Top frame
|
|
132
|
+
// Row 1: Top frame ╭─ BLUN ─────...──╮
|
|
133
133
|
process.stdout.write(cursorTo(panelTop, 1) + clearLine());
|
|
134
|
-
|
|
134
|
+
var topLeft = "╭─ BLUN ";
|
|
135
|
+
var fillTop = cols - topLeft.length - 1; // -1 for ╮
|
|
136
|
+
process.stdout.write(t.frame(topLeft) + t.frame("─".repeat(Math.max(1, fillTop))) + t.frame("╮"));
|
|
135
137
|
|
|
136
|
-
// Row 2: Input line
|
|
138
|
+
// Row 2: Input line │ > text... │
|
|
137
139
|
var displayInput = inputBuffer || "";
|
|
138
|
-
var maxInputLen =
|
|
140
|
+
var maxInputLen = cols - 6; // "│ > " (4) + " │" (2)
|
|
139
141
|
var showInput = displayInput.length > maxInputLen ? displayInput.slice(displayInput.length - maxInputLen) : displayInput;
|
|
140
142
|
process.stdout.write(cursorTo(panelTop + 1, 1) + clearLine());
|
|
141
|
-
process.stdout.write(t.frame("│ ") + chalk.bold.green("> ") + chalk.white(showInput)
|
|
143
|
+
process.stdout.write(t.frame("│ ") + chalk.bold.green("> ") + chalk.white(showInput));
|
|
144
|
+
process.stdout.write(cursorTo(panelTop + 1, cols) + t.frame("│"));
|
|
142
145
|
|
|
143
|
-
// Row 3: Empty separator
|
|
146
|
+
// Row 3: Empty separator │ │
|
|
144
147
|
process.stdout.write(cursorTo(panelTop + 2, 1) + clearLine());
|
|
145
|
-
process.stdout.write(t.frame("│")
|
|
148
|
+
process.stdout.write(t.frame("│"));
|
|
149
|
+
process.stdout.write(cursorTo(panelTop + 2, cols) + t.frame("│"));
|
|
146
150
|
|
|
147
|
-
// Row 4: Status line
|
|
151
|
+
// Row 4: Status line │ normal | model:auto ... │
|
|
148
152
|
process.stdout.write(cursorTo(panelTop + 3, 1) + clearLine());
|
|
149
153
|
process.stdout.write(t.frame("│ ") + statusLine);
|
|
150
154
|
process.stdout.write(cursorTo(panelTop + 3, cols) + t.frame("│"));
|
|
151
155
|
|
|
152
|
-
// Row 5: Bottom frame
|
|
156
|
+
// Row 5: Bottom frame ╰─ Tab: ... ──╯
|
|
153
157
|
process.stdout.write(cursorTo(panelTop + 4, 1) + clearLine());
|
|
154
|
-
|
|
158
|
+
var bottomHint = "╰─ Tab: autocomplete /: commands Esc: exit ";
|
|
159
|
+
var fillBottom = cols - bottomHint.length - 1; // -1 for ╯
|
|
160
|
+
process.stdout.write(t.frame(bottomHint) + t.frame("─".repeat(Math.max(1, fillBottom))) + t.frame("╯"));
|
|
155
161
|
|
|
156
162
|
// Restore cursor back to input line
|
|
157
163
|
var cursorCol = 5 + cursorPos; // "│ > " = 4 chars + 1
|
|
@@ -184,6 +190,8 @@ function startChat() {
|
|
|
184
190
|
// ── Process command ──────────────────────────────────
|
|
185
191
|
function processCommand(input) {
|
|
186
192
|
if (!input) return;
|
|
193
|
+
// Case-insensitive commands
|
|
194
|
+
if (input.startsWith("/")) input = input.toLowerCase();
|
|
187
195
|
|
|
188
196
|
// ── Commands ───────────────────────────────────
|
|
189
197
|
if (input === "/exit" || input === "/quit") {
|
|
@@ -455,8 +463,12 @@ function startChat() {
|
|
|
455
463
|
// Reset scroll region for inquirer to work properly
|
|
456
464
|
var rows = getRows();
|
|
457
465
|
process.stdout.write(setScrollRegion(1, rows));
|
|
458
|
-
process.
|
|
466
|
+
process.stdout.write(cursorTo(rows - INPUT_PANEL_HEIGHT, 1));
|
|
467
|
+
process.stdout.write(showCursor());
|
|
468
|
+
try { process.stdin.setRawMode(false); } catch (e) {}
|
|
459
469
|
process.stdin.removeAllListeners("data");
|
|
470
|
+
process.stdin.pause();
|
|
471
|
+
process.stdin.resume();
|
|
460
472
|
|
|
461
473
|
fn(function () {
|
|
462
474
|
// Re-enter TUI mode
|