natureco-cli 5.7.9 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "5.7.9",
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"
@@ -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,13 +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: placeholder'lar output'tan gizlendiği için
732
- // terminalde tek satırda birikmiş olan paste ekosunu temizle,
733
- // yerine özet yaz.
734
- const newlineCount = (line.match(/\n/g) || []).length;
735
- if (newlineCount > 0) {
736
- process.stdout.write(`\x1b[1A\x1b[J[Pasted ~${newlineCount + 1} lines]\n`);
737
- }
731
+ // Çok satırlı paste: output filter'a echo'yu durdurma sinyalini ver
732
+ clearPasteContext();
738
733
 
739
734
  // Slash komutlar
740
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
 
@@ -207,35 +221,56 @@ function createOutputFilter(output = process.stdout) {
207
221
 
208
222
  const filter = {
209
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
+
210
251
  const str = data.toString('utf8');
211
252
  let result = '';
212
253
  let i = 0;
213
254
 
214
255
  while (i < str.length) {
215
256
  if (partial.length > 0) {
216
- // Kısmi eşleşme var — devamını bekle
217
257
  const expected = NEWLINE_PLACEHOLDER[partial.length];
218
258
  const ch = str[i];
219
259
  if (ch === expected) {
220
260
  partial += ch;
221
261
  i++;
222
262
  if (partial === NEWLINE_PLACEHOLDER) {
223
- // Placeholder'ı terminalde gösterme — output'tan tamamen çıkar
224
263
  partial = '';
225
264
  }
226
265
  } else {
227
- // Eşleşme bozuldu — partial buffer'ı boşalt
228
266
  result += partial;
229
267
  partial = '';
230
- // ch'i tekrar dene (yeni placeholder başlangıcı olabilir)
231
- // continue ile aynı i değerinde else-if'e düş
232
268
  }
233
269
  } else {
234
270
  const ch = str[i];
235
271
  if (ch === NEWLINE_PLACEHOLDER[0]) {
236
272
  partial = ch;
237
273
  i++;
238
- // Tek karakterlik placeholder değil, bekle
239
274
  } else {
240
275
  result += ch;
241
276
  i++;
@@ -274,6 +309,9 @@ function createOutputFilter(output = process.stdout) {
274
309
  return filter;
275
310
  }
276
311
 
312
+ function setPasteContext(ctx) { _pasteContext = ctx; }
313
+ function clearPasteContext() { _pasteContext = null; }
314
+
277
315
  module.exports = {
278
316
  createPasteSafeInput,
279
317
  createOutputFilter,
@@ -281,4 +319,6 @@ module.exports = {
281
319
  disableBracketedPaste,
282
320
  restoreNewlines,
283
321
  NEWLINE_PLACEHOLDER,
322
+ setPasteContext,
323
+ clearPasteContext,
284
324
  };