natureco-cli 5.7.8 → 5.7.10
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/repl.js +3 -7
- package/src/utils/paste-safe-input.js +56 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.10",
|
|
4
4
|
"description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"natureco": "bin/natureco.js"
|
package/src/commands/repl.js
CHANGED
|
@@ -24,7 +24,7 @@ const chalk = require('chalk');
|
|
|
24
24
|
const tui = require('../utils/tui');
|
|
25
25
|
const { loadToolDefinitions, toOpenAIFormat, executeTool } = require('../utils/tools');
|
|
26
26
|
const { accumulateToolCallDeltas, finalizeToolCalls } = require('../utils/streaming-tools');
|
|
27
|
-
const { createPasteSafeInput, createOutputFilter, enableBracketedPaste, disableBracketedPaste, restoreNewlines } = require('../utils/paste-safe-input');
|
|
27
|
+
const { createPasteSafeInput, createOutputFilter, enableBracketedPaste, disableBracketedPaste, restoreNewlines, clearPasteContext } = require('../utils/paste-safe-input');
|
|
28
28
|
|
|
29
29
|
// v5.4.6: Model adi sizintisini engelle — global'e ata, callback'lerden erisebilir olsun
|
|
30
30
|
const MODEL_NAMES_TO_HIDE = ['MiniMax-M2.5', 'MiniMaxM2.5', 'minimaxm25', 'Claude-3', 'GPT-4', 'ChatGPT'];
|
|
@@ -728,12 +728,8 @@ async function startRepl(args) {
|
|
|
728
728
|
const line = restoreNewlines(input).trim();
|
|
729
729
|
if (!line) { rl.prompt(); return; }
|
|
730
730
|
|
|
731
|
-
// Çok satırlı paste
|
|
732
|
-
|
|
733
|
-
const newlineCount = (line.match(/\n/g) || []).length;
|
|
734
|
-
if (newlineCount > 0) {
|
|
735
|
-
process.stdout.write(`\x1b[${newlineCount + 1}A\x1b[J`);
|
|
736
|
-
}
|
|
731
|
+
// Çok satırlı paste: output filter'a echo'yu durdurma sinyalini ver
|
|
732
|
+
clearPasteContext();
|
|
737
733
|
|
|
738
734
|
// Slash komutlar
|
|
739
735
|
if (line.startsWith('/')) {
|
|
@@ -38,6 +38,12 @@ const { PassThrough } = require('stream');
|
|
|
38
38
|
const PASTE_START = '\x1b[200~';
|
|
39
39
|
const PASTE_END = '\x1b[201~';
|
|
40
40
|
|
|
41
|
+
// Input proxy ile output filter arasında paste durumunu paylaşır.
|
|
42
|
+
// escapeEmbeddedNewlines paste algıladığında bu context'i set eder,
|
|
43
|
+
// output filter tüm ekoyu yutar (terminalde hiçbir şey gözükmez),
|
|
44
|
+
// repl.js line handler'ı context'i temizler.
|
|
45
|
+
let _pasteContext = null; // { lineCount } or null
|
|
46
|
+
|
|
41
47
|
// Yapıştırılan içindeki satır sonlarını gizlemek için kullanılan placeholder.
|
|
42
48
|
// Gerçek kullanıcı girdisinde pratikte hiç geçmeyecek bir dizi.
|
|
43
49
|
const NEWLINE_PLACEHOLDER = '\u2424\u2424LINEBREAK\u2424\u2424';
|
|
@@ -87,6 +93,14 @@ function escapeEmbeddedNewlines(str) {
|
|
|
87
93
|
// (Tek istisna: test ortamında PassThrough kullanılır, orada da
|
|
88
94
|
// testler karakter-karakter yazacak şekilde güncellenmiştir.)
|
|
89
95
|
if (newlineCount === 0) return str;
|
|
96
|
+
|
|
97
|
+
// Paste algılandı — output filter'a sinyal ver ve summary yaz
|
|
98
|
+
const lineCount = newlineCount + 1;
|
|
99
|
+
_pasteContext = { lineCount };
|
|
100
|
+
if (process.stdout.isTTY) {
|
|
101
|
+
process.stdout.write(`\r\x1b[2K[Pasted ~${lineCount} lines]\n`);
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
return str.replace(/\r\n|\r|\n/g, NEWLINE_PLACEHOLDER);
|
|
91
105
|
}
|
|
92
106
|
|
|
@@ -182,9 +196,12 @@ function restoreNewlines(line) {
|
|
|
182
196
|
|
|
183
197
|
/**
|
|
184
198
|
* createOutputFilter — Readline'ın output'unda dolaşan placeholder
|
|
185
|
-
* karakterlerini (NEWLINE_PLACEHOLDER)
|
|
186
|
-
*
|
|
187
|
-
*
|
|
199
|
+
* karakterlerini (NEWLINE_PLACEHOLDER) TAMAMEN gizleyen bir wrapper.
|
|
200
|
+
* Kullanıcı terminalde ne placeholder yazılarını ne de satır sonlarını
|
|
201
|
+
* görür — paste içeriği terminal ekosunda yer kaplamaz.
|
|
202
|
+
*
|
|
203
|
+
* Paste'in içeriği terminalde görünmez; repl.js line handler'ı paste
|
|
204
|
+
* algılandığında "[Pasted ~N lines]" gibi kısa bir özet yazar.
|
|
188
205
|
*
|
|
189
206
|
* Kullanım:
|
|
190
207
|
* const outFilter = createOutputFilter(process.stdout);
|
|
@@ -194,45 +211,66 @@ function restoreNewlines(line) {
|
|
|
194
211
|
* Readline, echo mekanizmasıyla her karakteri output.write() ile
|
|
195
212
|
* terminale yazar. Placeholder karakterleri de tek tek yazılır.
|
|
196
213
|
* Bu fonksiyon bir state machine tutar: karakterleri placeholder
|
|
197
|
-
* ile eşleştirir, tam eşleşme olursa
|
|
198
|
-
* olduğu gibi geçirir. Kısmi
|
|
199
|
-
*
|
|
200
|
-
* buffer'da bekletilir.
|
|
214
|
+
* ile eşleştirir, tam eşleşme olursa placeholder'ı ATAR (terminalde
|
|
215
|
+
* hiçbir iz kalmaz), olmazsa karakteri olduğu gibi geçirir. Kısmi
|
|
216
|
+
* eşleşmeler (chunk sınırında bölünmüş placeholder) sonraki
|
|
217
|
+
* write()'da tamamlanmak üzere partial buffer'da bekletilir.
|
|
201
218
|
*/
|
|
202
219
|
function createOutputFilter(output = process.stdout) {
|
|
203
220
|
let partial = '';
|
|
204
221
|
|
|
205
222
|
const filter = {
|
|
206
223
|
write(data) {
|
|
224
|
+
// Paste aktifken tüm ekoyu yut — terminalde hiçbir şey gözükmez
|
|
225
|
+
if (_pasteContext !== null) {
|
|
226
|
+
// Placeholder state machine'i çalıştır (sonraki write'lar için
|
|
227
|
+
// partial buffer temiz kalsın) ama output'a hiçbir şey yazma.
|
|
228
|
+
const str = data.toString('utf8');
|
|
229
|
+
let i = 0;
|
|
230
|
+
while (i < str.length) {
|
|
231
|
+
if (partial.length > 0) {
|
|
232
|
+
const expected = NEWLINE_PLACEHOLDER[partial.length];
|
|
233
|
+
const ch = str[i];
|
|
234
|
+
if (ch === expected) {
|
|
235
|
+
partial += ch;
|
|
236
|
+
i++;
|
|
237
|
+
if (partial === NEWLINE_PLACEHOLDER) partial = '';
|
|
238
|
+
} else {
|
|
239
|
+
partial = '';
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
if (str[i] === NEWLINE_PLACEHOLDER[0]) {
|
|
243
|
+
partial = str[i];
|
|
244
|
+
}
|
|
245
|
+
i++;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
|
|
207
251
|
const str = data.toString('utf8');
|
|
208
252
|
let result = '';
|
|
209
253
|
let i = 0;
|
|
210
254
|
|
|
211
255
|
while (i < str.length) {
|
|
212
256
|
if (partial.length > 0) {
|
|
213
|
-
// Kısmi eşleşme var — devamını bekle
|
|
214
257
|
const expected = NEWLINE_PLACEHOLDER[partial.length];
|
|
215
258
|
const ch = str[i];
|
|
216
259
|
if (ch === expected) {
|
|
217
260
|
partial += ch;
|
|
218
261
|
i++;
|
|
219
262
|
if (partial === NEWLINE_PLACEHOLDER) {
|
|
220
|
-
result += '\n';
|
|
221
263
|
partial = '';
|
|
222
264
|
}
|
|
223
265
|
} else {
|
|
224
|
-
// Eşleşme bozuldu — partial buffer'ı boşalt
|
|
225
266
|
result += partial;
|
|
226
267
|
partial = '';
|
|
227
|
-
// ch'i tekrar dene (yeni placeholder başlangıcı olabilir)
|
|
228
|
-
// continue ile aynı i değerinde else-if'e düş
|
|
229
268
|
}
|
|
230
269
|
} else {
|
|
231
270
|
const ch = str[i];
|
|
232
271
|
if (ch === NEWLINE_PLACEHOLDER[0]) {
|
|
233
272
|
partial = ch;
|
|
234
273
|
i++;
|
|
235
|
-
// Tek karakterlik placeholder değil, bekle
|
|
236
274
|
} else {
|
|
237
275
|
result += ch;
|
|
238
276
|
i++;
|
|
@@ -271,6 +309,9 @@ function createOutputFilter(output = process.stdout) {
|
|
|
271
309
|
return filter;
|
|
272
310
|
}
|
|
273
311
|
|
|
312
|
+
function setPasteContext(ctx) { _pasteContext = ctx; }
|
|
313
|
+
function clearPasteContext() { _pasteContext = null; }
|
|
314
|
+
|
|
274
315
|
module.exports = {
|
|
275
316
|
createPasteSafeInput,
|
|
276
317
|
createOutputFilter,
|
|
@@ -278,4 +319,6 @@ module.exports = {
|
|
|
278
319
|
disableBracketedPaste,
|
|
279
320
|
restoreNewlines,
|
|
280
321
|
NEWLINE_PLACEHOLDER,
|
|
322
|
+
setPasteContext,
|
|
323
|
+
clearPasteContext,
|
|
281
324
|
};
|