natureco-cli 2.17.7 → 2.17.8
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/package.json +1 -1
- package/src/commands/chat.js +27 -32
package/package.json
CHANGED
package/src/commands/chat.js
CHANGED
|
@@ -125,6 +125,8 @@ async function chat(botName, options = {}) {
|
|
|
125
125
|
title: `NatureCo · ${displayBotName}`,
|
|
126
126
|
terminal: 'xterm-256color',
|
|
127
127
|
fullUnicode: true,
|
|
128
|
+
grabKeys: false, // readline'ın keypress almasına izin ver
|
|
129
|
+
ignoreLocked: ['C-c'],
|
|
128
130
|
});
|
|
129
131
|
|
|
130
132
|
// ── Logo kutusu (üst %30) ───────────────────────────────────────────────────
|
|
@@ -143,12 +145,12 @@ async function chat(botName, options = {}) {
|
|
|
143
145
|
style: { fg: 'green', bg: 'default' },
|
|
144
146
|
});
|
|
145
147
|
|
|
146
|
-
// ── Mesaj alanı
|
|
148
|
+
// ── Mesaj alanı ─────────────────────────────────────────────────────────────
|
|
147
149
|
const messageBox = blessed.log({
|
|
148
150
|
top: '28%',
|
|
149
151
|
left: 0,
|
|
150
152
|
width: '100%',
|
|
151
|
-
|
|
153
|
+
bottom: 5, // separator(1) + status(1) + input alanı(3) = 5
|
|
152
154
|
scrollable: true,
|
|
153
155
|
alwaysScroll: true,
|
|
154
156
|
tags: true,
|
|
@@ -157,7 +159,7 @@ async function chat(botName, options = {}) {
|
|
|
157
159
|
style: { bg: 'default' },
|
|
158
160
|
});
|
|
159
161
|
|
|
160
|
-
// ── Input
|
|
162
|
+
// ── Input separator çizgisi ─────────────────────────────────────────────────
|
|
161
163
|
const inputSeparator = blessed.line({
|
|
162
164
|
bottom: 4,
|
|
163
165
|
left: 0,
|
|
@@ -166,21 +168,6 @@ async function chat(botName, options = {}) {
|
|
|
166
168
|
style: { fg: 'gray' },
|
|
167
169
|
});
|
|
168
170
|
|
|
169
|
-
const inputBox = blessed.textbox({
|
|
170
|
-
bottom: 1,
|
|
171
|
-
left: 0,
|
|
172
|
-
width: '100%',
|
|
173
|
-
height: 3,
|
|
174
|
-
inputOnFocus: false,
|
|
175
|
-
keys: true,
|
|
176
|
-
mouse: true,
|
|
177
|
-
padding: { left: 2 },
|
|
178
|
-
style: {
|
|
179
|
-
fg: 'white',
|
|
180
|
-
bg: 'default',
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
|
|
184
171
|
// ── Status bar (en alt 1 satır) ─────────────────────────────────────────────
|
|
185
172
|
const cwd = process.cwd().replace(os.homedir(), '~');
|
|
186
173
|
const statusBar = blessed.box({
|
|
@@ -196,10 +183,8 @@ async function chat(botName, options = {}) {
|
|
|
196
183
|
screen.append(logoBox);
|
|
197
184
|
screen.append(messageBox);
|
|
198
185
|
screen.append(inputSeparator);
|
|
199
|
-
screen.append(inputBox);
|
|
200
186
|
screen.append(statusBar);
|
|
201
187
|
|
|
202
|
-
inputBox.focus();
|
|
203
188
|
screen.render();
|
|
204
189
|
|
|
205
190
|
// ── What's New ──────────────────────────────────────────────────────────────
|
|
@@ -243,7 +228,7 @@ async function chat(botName, options = {}) {
|
|
|
243
228
|
// ── Mesaj gönderme ──────────────────────────────────────────────────────────
|
|
244
229
|
async function handleMessage(userMessage) {
|
|
245
230
|
userMessage = userMessage.trim();
|
|
246
|
-
if (!userMessage)
|
|
231
|
+
if (!userMessage) return;
|
|
247
232
|
|
|
248
233
|
// /komutlar
|
|
249
234
|
if (userMessage.startsWith('/')) {
|
|
@@ -401,31 +386,41 @@ async function chat(botName, options = {}) {
|
|
|
401
386
|
messageBox.setScrollPerc(100);
|
|
402
387
|
screen.render();
|
|
403
388
|
}
|
|
404
|
-
|
|
405
|
-
inputBox.focus();
|
|
406
389
|
}
|
|
407
390
|
|
|
408
|
-
// ──
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
391
|
+
// ── Readline ile native input loop ──────────────────────────────────────────
|
|
392
|
+
const readline = require('readline');
|
|
393
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
|
|
394
|
+
|
|
395
|
+
// Blessed cursor'ı gizlemesin, readline yazsın
|
|
396
|
+
screen.program.showCursor();
|
|
397
|
+
screen.program.on('render', () => screen.program.showCursor());
|
|
398
|
+
|
|
399
|
+
async function promptLoop() {
|
|
400
|
+
rl.question('', async (msg) => {
|
|
401
|
+
// Readline'ın yazdığı satırı temizle
|
|
402
|
+
process.stdout.write('\x1b[1A\x1b[2K');
|
|
403
|
+
await handleMessage(msg);
|
|
404
|
+
screen.render();
|
|
405
|
+
promptLoop();
|
|
406
|
+
});
|
|
407
|
+
}
|
|
417
408
|
|
|
418
409
|
// ── Ctrl+C çıkış ────────────────────────────────────────────────────────────
|
|
419
410
|
screen.key(['C-c'], async () => {
|
|
420
411
|
await runHooks('on-exit', null, { botId: bot.id, botName: bot.name });
|
|
412
|
+
rl.close();
|
|
421
413
|
screen.destroy();
|
|
422
414
|
process.exit(0);
|
|
423
415
|
});
|
|
424
416
|
|
|
417
|
+
rl.on('close', () => process.exit(0));
|
|
418
|
+
|
|
425
419
|
// ── on-start hooks ──────────────────────────────────────────────────────────
|
|
426
420
|
await runHooks('on-start', null, { botId: bot.id, botName: bot.name });
|
|
427
421
|
|
|
428
422
|
screen.render();
|
|
423
|
+
promptLoop();
|
|
429
424
|
}
|
|
430
425
|
|
|
431
426
|
// ── Fallback: blessed yoksa eski readline tabanlı chat ────────────────────────
|