natureco-cli 2.20.1 → 2.20.2

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.20.1",
3
+ "version": "2.20.2",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "main": "bin/natureco.js",
6
6
  "bin": {
@@ -451,6 +451,36 @@ ${indexPrompt}`;
451
451
  console.log();
452
452
  }
453
453
 
454
+ // ── Komut çalıştır + hata döngüsü ───────────────────────────────────────────
455
+ async function runAndFix(cmd) {
456
+ console.log(chalk.gray(`\n ▶ ${cmd} çalıştırılıyor...\n`));
457
+ try {
458
+ const output = execSync(cmd, {
459
+ cwd: process.cwd(), timeout: 30000, stdio: 'pipe',
460
+ }).toString();
461
+ console.log(chalk.green(' ✓ Başarılı:'));
462
+ console.log(chalk.gray(' ' + output.slice(0, 500).split('\n').join('\n ')));
463
+ console.log();
464
+ } catch (err) {
465
+ const errorOutput = (err.stderr?.toString() || err.stdout?.toString() || err.message || '').slice(0, 500);
466
+ console.log(chalk.red(' ✗ Hata:'));
467
+ console.log(chalk.gray(' ' + errorOutput.split('\n').join('\n ')));
468
+ console.log();
469
+
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
+
476
+ if (fix) {
477
+ const fixMessage = `Şu komut çalıştırıldı: ${cmd}\nHata oluştu:\n${errorOutput}\nBu hatayı analiz et ve düzelt.`;
478
+ console.log(chalk.cyan('\n Düzeltiliyor...\n'));
479
+ await handleMessage(fixMessage);
480
+ }
481
+ }
482
+ }
483
+
454
484
  // ── Mesaj gönder + tool loop ──────────────────────────────────────────────
455
485
  async function handleMessage(userMessage) {
456
486
  userMessage = userMessage.trim();
@@ -466,6 +496,8 @@ ${indexPrompt}`;
466
496
  ['/summary', 'Session özetini göster'],
467
497
  ['/done', 'Bitir ve özet göster'],
468
498
  ['/index', 'Projeyi yeniden indexle'],
499
+ ['/run <cmd>','Komutu çalıştır, hata varsa düzelt'],
500
+ ['/test', 'Testleri çalıştır, hata varsa düzelt'],
469
501
  ['/git', 'Git durumu ve son commitler'],
470
502
  ['/commit', 'Staged değişiklikleri AI ile commit et'],
471
503
  ['/help', 'Bu yardım'],
@@ -492,6 +524,22 @@ ${indexPrompt}`;
492
524
  );
493
525
  return;
494
526
  }
527
+ case 'run': {
528
+ const runCmd = userMessage.slice(4).trim() || 'node index.js';
529
+ await runAndFix(runCmd);
530
+ return;
531
+ }
532
+ case 'test': {
533
+ const testCmd = projectIndex.packageJson?.scripts?.test
534
+ ? 'npm test'
535
+ : projectIndex.type === 'python' ? 'python -m pytest' : null;
536
+ if (!testCmd) {
537
+ console.log(chalk.red(' Test komutu bulunamadı.\n'));
538
+ return;
539
+ }
540
+ await runAndFix(testCmd);
541
+ return;
542
+ }
495
543
  case 'git': {
496
544
  try {
497
545
  const status = execSync('git status --short', { cwd: process.cwd(), stdio: 'pipe' }).toString().trim();