natureco-cli 2.17.6 → 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 +32 -29
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,21 +159,13 @@ async function chat(botName, options = {}) {
|
|
|
157
159
|
style: { bg: 'default' },
|
|
158
160
|
});
|
|
159
161
|
|
|
160
|
-
// ── Input
|
|
161
|
-
const
|
|
162
|
-
bottom:
|
|
162
|
+
// ── Input separator çizgisi ─────────────────────────────────────────────────
|
|
163
|
+
const inputSeparator = blessed.line({
|
|
164
|
+
bottom: 4,
|
|
163
165
|
left: 0,
|
|
164
166
|
width: '100%',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
padding: { left: 2 },
|
|
168
|
-
border: { type: 'line' },
|
|
169
|
-
style: {
|
|
170
|
-
border: { fg: 'green' },
|
|
171
|
-
fg: 'white',
|
|
172
|
-
bg: 'default',
|
|
173
|
-
focus: { border: { fg: 'cyan' } },
|
|
174
|
-
},
|
|
167
|
+
orientation: 'horizontal',
|
|
168
|
+
style: { fg: 'gray' },
|
|
175
169
|
});
|
|
176
170
|
|
|
177
171
|
// ── Status bar (en alt 1 satır) ─────────────────────────────────────────────
|
|
@@ -188,10 +182,9 @@ async function chat(botName, options = {}) {
|
|
|
188
182
|
|
|
189
183
|
screen.append(logoBox);
|
|
190
184
|
screen.append(messageBox);
|
|
191
|
-
screen.append(
|
|
185
|
+
screen.append(inputSeparator);
|
|
192
186
|
screen.append(statusBar);
|
|
193
187
|
|
|
194
|
-
inputBox.focus();
|
|
195
188
|
screen.render();
|
|
196
189
|
|
|
197
190
|
// ── What's New ──────────────────────────────────────────────────────────────
|
|
@@ -235,7 +228,7 @@ async function chat(botName, options = {}) {
|
|
|
235
228
|
// ── Mesaj gönderme ──────────────────────────────────────────────────────────
|
|
236
229
|
async function handleMessage(userMessage) {
|
|
237
230
|
userMessage = userMessage.trim();
|
|
238
|
-
if (!userMessage)
|
|
231
|
+
if (!userMessage) return;
|
|
239
232
|
|
|
240
233
|
// /komutlar
|
|
241
234
|
if (userMessage.startsWith('/')) {
|
|
@@ -393,31 +386,41 @@ async function chat(botName, options = {}) {
|
|
|
393
386
|
messageBox.setScrollPerc(100);
|
|
394
387
|
screen.render();
|
|
395
388
|
}
|
|
396
|
-
|
|
397
|
-
inputBox.focus();
|
|
398
389
|
}
|
|
399
390
|
|
|
400
|
-
// ──
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
+
}
|
|
409
408
|
|
|
410
409
|
// ── Ctrl+C çıkış ────────────────────────────────────────────────────────────
|
|
411
410
|
screen.key(['C-c'], async () => {
|
|
412
411
|
await runHooks('on-exit', null, { botId: bot.id, botName: bot.name });
|
|
412
|
+
rl.close();
|
|
413
413
|
screen.destroy();
|
|
414
414
|
process.exit(0);
|
|
415
415
|
});
|
|
416
416
|
|
|
417
|
+
rl.on('close', () => process.exit(0));
|
|
418
|
+
|
|
417
419
|
// ── on-start hooks ──────────────────────────────────────────────────────────
|
|
418
420
|
await runHooks('on-start', null, { botId: bot.id, botName: bot.name });
|
|
419
421
|
|
|
420
422
|
screen.render();
|
|
423
|
+
promptLoop();
|
|
421
424
|
}
|
|
422
425
|
|
|
423
426
|
// ── Fallback: blessed yoksa eski readline tabanlı chat ────────────────────────
|