natureco-cli 5.43.0 → 5.43.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": "5.43.0",
3
+ "version": "5.43.2",
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"
@@ -25,19 +25,51 @@ const CHECKS = [
25
25
 
26
26
  function doctor(params) {
27
27
  try {
28
- const [action, checkName] = params || [];
28
+ const args = params || [];
29
+ const fix = args.includes('--fix') || args[0] === 'fix';
30
+ // --fix bir flag; action'lardan ayıkla (ör. "doctor --fix" → run+fix).
31
+ const positional = args.filter(a => a !== '--fix');
32
+ const [action, checkName] = positional;
29
33
 
30
- if (!action || action === 'run') return cmdRun();
34
+ if (fix || !action || action === 'run') return cmdRun({ fix });
31
35
  if (action === 'list') return cmdList();
32
36
  if (action === 'check') return cmdCheck(checkName);
33
37
 
34
38
  console.log(chalk.red(`\n Unknown doctor action: ${action}\n`));
35
- console.log(chalk.gray(' Usage: natureco doctor [run|list|check <name>]\n'));
39
+ console.log(chalk.gray(' Usage: natureco doctor [run|list|check <name>|--fix]\n'));
36
40
  } catch (err) {
37
41
  console.log(chalk.red(`\n Doctor error: ${err.message}\n`));
38
42
  }
39
43
  }
40
44
 
45
+ // v5.43.2: --fix — düzeltilebilir sorunları otomatik onar. Eskiden --fix hiç
46
+ // işlenmiyordu ("Unknown doctor action: --fix"), README'de belgeli olmasına rağmen.
47
+ function applyFixes() {
48
+ const applied = [];
49
+ const failed = [];
50
+ // 1. Eksik veri dizinlerini oluştur
51
+ const REQUIRED = ['sources', 'concepts', 'cache', 'skills', 'memory', 'sessions', 'backups', 'hooks', 'audit'];
52
+ try { if (!fs.existsSync(BASE_DIR)) fs.mkdirSync(BASE_DIR, { recursive: true, mode: 0o700 }); } catch (e) { failed.push('~/.natureco: ' + e.message); }
53
+ for (const d of REQUIRED) {
54
+ const dir = path.join(BASE_DIR, d);
55
+ if (!fs.existsSync(dir)) {
56
+ try { fs.mkdirSync(dir, { recursive: true }); applied.push('created dir: ' + d); }
57
+ catch (e) { failed.push(d + ': ' + e.message); }
58
+ }
59
+ }
60
+ // 2. Hassas dosya/dizin izinlerini sıkılaştır (POSIX) — API key'li config gizli kalmalı
61
+ if (process.platform !== 'win32') {
62
+ try { fs.chmodSync(BASE_DIR, 0o700); applied.push('~/.natureco → 0700'); } catch {}
63
+ if (fs.existsSync(CONFIG_FILE)) {
64
+ try {
65
+ const cur = fs.statSync(CONFIG_FILE).mode & 0o777;
66
+ if (cur !== 0o600) { fs.chmodSync(CONFIG_FILE, 0o600); applied.push('config.json → 0600'); }
67
+ } catch {}
68
+ }
69
+ }
70
+ return { applied, failed };
71
+ }
72
+
41
73
  function cmdList() {
42
74
  F.list(CHECKS.map(c => ({ label: c.name, value: c.label })));
43
75
  }
@@ -65,8 +97,24 @@ function cmdCheck(name) {
65
97
  }
66
98
  }
67
99
 
68
- function cmdRun() {
69
- F.header('System Doctor · Tüm Sistem Kontrolleri', { icon: '🩺' });
100
+ function cmdRun(opts = {}) {
101
+ F.header(opts.fix ? 'System Doctor · Otomatik Düzeltme (--fix)' : 'System Doctor · Tüm Sistem Kontrolleri', { icon: opts.fix ? '🔧' : '🩺' });
102
+
103
+ // v5.43.2: --fix modunda önce düzeltilebilir sorunları onar, sonra kontrolleri çalıştır.
104
+ if (opts.fix) {
105
+ const { applied, failed } = applyFixes();
106
+ if (applied.length) {
107
+ console.log('\n' + tui.C.green(' 🔧 Düzeltildi:'));
108
+ applied.forEach(a => console.log(' ' + tui.C.text('• ' + a)));
109
+ } else {
110
+ console.log('\n' + tui.C.muted(' 🔧 Düzeltilecek bir şey yok — sistem zaten düzgün.'));
111
+ }
112
+ if (failed.length) {
113
+ console.log('\n' + tui.C.amber(' ⚠️ Otomatik düzeltilemedi:'));
114
+ failed.forEach(f => console.log(' ' + tui.C.muted('• ' + f)));
115
+ }
116
+ console.log('');
117
+ }
70
118
 
71
119
  const rows = [];
72
120
  let passed = 0;
@@ -277,3 +325,5 @@ function runCheck(name) {
277
325
  }
278
326
 
279
327
  module.exports = doctor;
328
+ // v5.43.2: test için — --fix otomatik düzeltme regresyonu
329
+ module.exports.applyFixes = applyFixes;
@@ -213,7 +213,10 @@ function restoreConfig(backupFile) {
213
213
  const data = parseConfigContent(content);
214
214
  validateConfig(data);
215
215
  createBackup();
216
- fs.writeFileSync(ACTIVE_CONFIG_FILE, JSON.stringify(data, null, 2), 'utf8');
216
+ // v5.43.1 GÜVENLİK: saveConfig gibi 0600 — restore, API key'li config.json'ı
217
+ // dünya-okunabilir hale getirmemeli. mode yalnızca yeni dosyaya uygulanır; chmod şart.
218
+ fs.writeFileSync(ACTIVE_CONFIG_FILE, JSON.stringify(data, null, 2), { encoding: 'utf8', mode: 0o600 });
219
+ try { fs.chmodSync(ACTIVE_CONFIG_FILE, 0o600); } catch { /* best-effort */ }
217
220
  _configCache = data;
218
221
  _configHash = computeHash(data);
219
222
  return { path: backupPath, timestamp: path.basename(backupPath).replace(/^config-|\.json$/g, '') };