natureco-cli 2.23.24 → 2.23.26

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": "2.23.24",
3
+ "version": "2.23.26",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "bin": {
6
6
  "natureco": "bin/natureco.js"
@@ -206,6 +206,16 @@ async function streamMessage(providerConfig, messages, tools) {
206
206
  return { text: result?.message?.content || '', toolCalls };
207
207
  }
208
208
 
209
+ async function confirmAction(message) {
210
+ return new Promise(resolve => {
211
+ rl.question(chalk.yellow(`⚠ ${message}\n[? Devam edilsin mi? (Y/n) `), answer => {
212
+ const confirmed = !answer || answer.toLowerCase() === 'y';
213
+ console.log(chalk.gray(` ✓ Devam edilsin mi? ${confirmed ? 'Yes' : 'No'}`));
214
+ resolve(confirmed);
215
+ });
216
+ });
217
+ }
218
+
209
219
  // ── Tool execution ────────────────────────────────────────────────────────────
210
220
  const DANGEROUS = [/\brm\b/, /\brmdir\b/, /\bdelete\b/i, /\bdrop\b/i, /\btruncate\b/i];
211
221
 
@@ -239,10 +249,7 @@ async function runToolCall(toolCall, stats, dryRun = false) {
239
249
 
240
250
  if (needsConfirm) {
241
251
  console.log(chalk.yellow(`\n ⚠️ ${toolCall.name}: ${inputPreview}`));
242
- const { ok } = await inquirer.prompt([{
243
- type: 'confirm', name: 'ok',
244
- message: ' Devam edilsin mi?', default: true,
245
- }]);
252
+ const ok = await confirmAction('Devam edilsin mi?');
246
253
  if (!ok) {
247
254
  console.log(chalk.gray(' İptal edildi.\n'));
248
255
  return { success: false, output: 'Kullanıcı iptal etti.' };
@@ -274,11 +281,8 @@ async function runTests(projectIndex, conversationMessages, tools, providerConfi
274
281
  const testScript = projectIndex.packageJson?.scripts?.test;
275
282
  if (!testScript || testScript.includes('no test')) return;
276
283
 
277
- const { confirm } = await inquirer.prompt([{
278
- type: 'confirm', name: 'confirm',
279
- message: chalk.yellow(' 🧪 Testleri çalıştıralım mı?'), default: true,
280
- }]);
281
- if (!confirm) return;
284
+ const confirmed = await confirmAction('🧪 Testleri çalıştıralım mı?');
285
+ if (!confirmed) return;
282
286
 
283
287
  console.log(chalk.gray('\n npm test çalışıyor...\n'));
284
288
  try {
@@ -292,10 +296,7 @@ async function runTests(projectIndex, conversationMessages, tools, providerConfi
292
296
  console.log(chalk.gray(' ' + errOutput.split('\n').join('\n ')));
293
297
  console.log();
294
298
 
295
- const { fix } = await inquirer.prompt([{
296
- type: 'confirm', name: 'fix',
297
- message: chalk.yellow(' Agent test hatasını düzeltsin mi?'), default: true,
298
- }]);
299
+ const fix = await confirmAction('Agent test hatasını düzeltsin mi?');
299
300
  if (fix) {
300
301
  return `Test hatası oluştu:\n${errOutput}\nBu hatayı düzelt.`;
301
302
  }
@@ -467,12 +468,7 @@ ${indexPrompt}`;
467
468
  console.log(chalk.gray(' ' + errorOutput.split('\n').join('\n ')));
468
469
  console.log();
469
470
 
470
- const { fix } = await inquirer.prompt([{
471
- type: 'confirm', name: 'fix',
472
- message: chalk.yellow(' Hatayı otomatik düzeltmemi ister misin?'),
473
- default: true,
474
- }]);
475
-
471
+ const fix = await confirmAction('Hatayı otomatik düzeltmemi ister misin?');
476
472
  if (fix) {
477
473
  const fixMessage = `Şu komut çalıştırıldı: ${cmd}\nHata oluştu:\n${errorOutput}\nBu hatayı analiz et ve düzelt.`;
478
474
  console.log(chalk.cyan('\n Düzeltiliyor...\n'));
@@ -582,10 +578,7 @@ ${indexPrompt}`;
582
578
  const commitMsg = await generateCommitMessage(diff.slice(0, 2000), providerConfig);
583
579
  stopSpinner(sp, 'Commit mesajı hazır', true);
584
580
  console.log(chalk.cyan(`\n Önerilen: ${chalk.white(commitMsg)}\n`));
585
- const { ok } = await inquirer.prompt([{
586
- type: 'confirm', name: 'ok',
587
- message: ' Commit edilsin mi?', default: true,
588
- }]);
581
+ const ok = await confirmAction('Commit edilsin mi?');
589
582
  if (ok) {
590
583
  execSync(`git commit -m "${commitMsg.replace(/"/g, '\\"')}"`, { cwd: workDir, stdio: 'pipe' });
591
584
  console.log(chalk.green(' ✓ Commit yapıldı!\n'));
@@ -693,18 +686,18 @@ ${indexPrompt}`;
693
686
  if (rl) {
694
687
  try { rl.removeAllListeners(); rl.close(); } catch {}
695
688
  }
696
- rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
689
+ rl = readline.createInterface({
690
+ input: process.stdin,
691
+ output: process.stdout,
692
+ terminal: true,
693
+ });
697
694
 
698
695
  rl.on('SIGINT', async () => {
699
696
  console.log('\n');
700
697
  rl.pause();
701
698
  if (conversationMessages.filter(m => m.role === 'user').length > 0) {
702
699
  try {
703
- const { save } = await inquirer.prompt([{
704
- type: 'confirm', name: 'save',
705
- message: chalk.yellow("Bu session'ı proje hafızasına kaydet?"),
706
- default: true,
707
- }]);
700
+ const save = await confirmAction("Bu session'ı proje hafızasına kaydet?");
708
701
  if (save) await saveProjectMemory(conversationMessages, providerConfig, workDir);
709
702
  } catch {}
710
703
  }
@@ -712,25 +705,25 @@ ${indexPrompt}`;
712
705
  process.exit(0);
713
706
  });
714
707
 
715
- // close event → inquirer tool onayı sırasında tetiklenebilir, hemen yeniden oluştur
716
- rl.on('close', () => {
717
- if (process.exitCode !== undefined) return;
718
- createRl();
719
- });
708
+ rl.on('close', () => {});
720
709
  }
721
710
 
722
711
  async function promptLoop() {
723
712
  while (true) {
724
- const msg = await new Promise(resolve => {
725
- rl.question(chalk.gray('> '), resolve);
726
- });
713
+ let msg;
714
+ try {
715
+ msg = await new Promise(resolve => {
716
+ rl.question(chalk.gray('> '), resolve);
717
+ });
718
+ } catch {
719
+ continue;
720
+ }
727
721
 
728
722
  process.stdout.write('\x1b[1A\x1b[2K');
729
723
 
730
724
  const trimmed = msg.trim();
731
725
  if (!trimmed) continue;
732
726
  if (['exit', 'quit', 'çıkış', 'q'].includes(trimmed.toLowerCase())) {
733
- rl.close();
734
727
  process.exit(0);
735
728
  }
736
729