natureco-cli 5.38.0 → 5.39.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to NatureCo CLI will be documented in this file.
4
4
 
5
+ ## [5.39.0] - 2026-07-08 — "CROSS-PLATFORM: grep_search + social_open Windows'ta kırıktı, düzeltildi"
6
+
7
+ Platform-uyumluluk denetimi: 90 aracın 18'i platform-özel. Çekirdek chat/code araçlarının Windows VE macOS'ta çalışması hedeflendi. 2 çekirdek/computer-use aracı saf Windows'ta kırıktı.
8
+
9
+ ### 🐛 Cross-platform düzeltmeler
10
+ - **grep_search saf Windows'ta tamamen kırıktı (ÇEKİRDEK araç)**: komut tespiti `spawn('which', ...)` + fallback `spawn('grep', ...)` kullanıyordu — `which` ve `grep` Windows'ta YOK (Git Bash olmadan). Ripgrep kurulu değilse arama hiç çalışmıyordu (bu makinede E2E'de çalışması yalnızca Git Bash kurulu olduğu içindi). Artık: (a) komut tespiti `rg --version` ile (which/where farkını bypass eder), (b) fallback **saf Node.js** dizin-tarama + regex (hiçbir Unix komutu gerekmez, node_modules/.git atlar, glob filtre, ikili-dosya atlama, 2MB sınırı). ripgrep varsa yine hız için kullanılır.
11
+ - **social_open Windows/Linux'ta hard-red**: `if (!IS_MAC) return {error:"sadece macOS"}` → tamamen reddediyordu. Artık platformlar arası URL açma: macOS `open`, Windows `cmd /c start`, Linux `xdg-open`.
12
+
13
+ ### ✓ Doğrulanan cross-platform durum (denetim)
14
+ - **Zaten cross-platform**: list_dir/read_file/write_file/edit_file (saf Node fs), http_request (Node http), git (v5.38 execFileSync, git PATH'te standart), code_execution (v5.38 py/python/node fallback), web_search/duckduckgo (Node http).
15
+ - **bash**: `shell:true` = platform-native shell (Windows cmd.exe, *nix sh) — doğru; agent OS'u sysMsg'den bilir (`İşletim sistemi: <platform>`) → platform-uygun komut seçer.
16
+ - **Tasarım gereği macOS-only (8 araç)**: mac_app_open/quit, mac_notify, macos_screenshot, notes/reminder/calendar_add, mac_alarm — osascript tabanlı; Windows'ta net "sadece macOS" mesajı (kullanıcının Mac'inde çalışır).
17
+
18
+ Doğrulama: grep_search Node fallback E2E (tool:node, rg'siz çalıştı); 527 test yeşil (6 yeni: grep-search Node fallback — dizin atlama, glob, maxResults, case-insensitive, geçersiz-regex), ESLint temiz.
19
+
5
20
  ## [5.38.0] - 2026-07-08 — "FİNAL DOĞRULAMA: git/code_execution/http_request düzeltmeleri + git enjeksiyon açığı kapatıldı"
6
21
 
7
22
  Final doğrulama re-run'inde (agent yolu E2E) 3 fonksiyonel sorun + 1 güvenlik açığı bulundu ve düzeltildi.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "5.38.0",
3
+ "version": "5.39.0",
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"
@@ -36,23 +36,75 @@ async function grepSearch({ pattern, path: searchPath = null, caseSensitive = fa
36
36
  }
37
37
  }
38
38
  }
39
- // ripgrep varsa onu kullan, yoksa fallback grep
39
+ // ripgrep varsa onu kullan (hizli), yoksa SAF NODE fallback.
40
+ // v5.39: eski fallback `grep` komutuydu → Windows'ta yok (Git Bash gerekir).
41
+ // Artik hicbir Unix komutuna bagimli degil: rg opsiyonel hizlandirma.
40
42
  const useRipgrep = await checkCommand('rg');
41
43
 
42
44
  if (useRipgrep) {
43
45
  return await grepWithRipgrep(pattern, cwd, caseSensitive, includePattern, maxResults);
44
46
  }
45
- return await grepWithFallback(pattern, cwd, caseSensitive, maxResults);
47
+ return grepWithNode(pattern, cwd, caseSensitive, includePattern, maxResults);
46
48
  }
47
49
 
48
50
  async function checkCommand(cmd) {
51
+ // v5.39: `which`/`where` platform-farkini bypass et — komutu dogrudan --version ile
52
+ // dene. PATH'te varsa 0 doner. (which Windows'ta yok, where *nix'te yok.)
49
53
  return new Promise((resolve) => {
50
- const proc = spawn('which', [cmd]);
51
- proc.on('close', code => resolve(code === 0));
52
- proc.on('error', () => resolve(false));
54
+ let done = false;
55
+ const fin = (v) => { if (!done) { done = true; resolve(v); } };
56
+ try {
57
+ const proc = spawn(cmd, ['--version'], { stdio: 'ignore' });
58
+ proc.on('close', code => fin(code === 0));
59
+ proc.on('error', () => fin(false));
60
+ } catch { fin(false); }
53
61
  });
54
62
  }
55
63
 
64
+ // v5.39: SAF NODE icerik aramasi — platformdan ve harici komuttan bagimsiz.
65
+ function grepWithNode(pattern, cwd, caseSensitive, includePattern, maxResults) {
66
+ const results = [];
67
+ let re;
68
+ const flags = caseSensitive ? 'g' : 'gi';
69
+ try { re = new RegExp(pattern, flags); }
70
+ catch { re = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), flags); }
71
+ let globRe = null;
72
+ if (includePattern) {
73
+ const esc = includePattern.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*').replace(/\?/g, '.');
74
+ globRe = new RegExp('^' + esc + '$', 'i');
75
+ }
76
+ const IGNORE = new Set(['node_modules', '.git', 'dist', 'build', '.next', 'coverage', '.cache', '.turbo']);
77
+ const walk = (dir) => {
78
+ if (results.length >= maxResults) return;
79
+ let entries;
80
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
81
+ for (const e of entries) {
82
+ if (results.length >= maxResults) break;
83
+ const full = path.join(dir, e.name);
84
+ if (e.isDirectory()) { if (!IGNORE.has(e.name)) walk(full); continue; }
85
+ if (!e.isFile()) continue;
86
+ if (globRe && !globRe.test(e.name)) continue;
87
+ let content;
88
+ try {
89
+ if (fs.statSync(full).size > 2 * 1024 * 1024) continue; // 2MB üstü atla
90
+ content = fs.readFileSync(full, 'utf8');
91
+ } catch { continue; }
92
+ if (content.includes('\x00')) continue; // ikili dosya (null byte)
93
+ const lines = content.split(/\r?\n/);
94
+ for (let i = 0; i < lines.length; i++) {
95
+ re.lastIndex = 0;
96
+ if (re.test(lines[i])) {
97
+ results.push({ file: full, line: i + 1, text: lines[i].trim().slice(0, 300) });
98
+ if (results.length >= maxResults) break;
99
+ }
100
+ }
101
+ }
102
+ };
103
+ const start = (fs.existsSync(cwd) && fs.statSync(cwd).isFile()) ? path.dirname(cwd) : cwd;
104
+ walk(start);
105
+ return { success: true, pattern, tool: 'node', count: results.length, results };
106
+ }
107
+
56
108
  async function grepWithRipgrep(pattern, cwd, caseSensitive, includePattern, maxResults) {
57
109
  return new Promise((resolve) => {
58
110
  const args = [
@@ -125,49 +177,6 @@ async function grepWithRipgrep(pattern, cwd, caseSensitive, includePattern, maxR
125
177
  });
126
178
  }
127
179
 
128
- async function grepWithFallback(pattern, cwd, caseSensitive, maxResults) {
129
- return new Promise((resolve) => {
130
- const args = ['-r', '-n', caseSensitive ? '' : '-i'];
131
- if (process.platform === 'darwin') args.push('-E');
132
- else args.push('-E');
133
- args.push(pattern);
134
- args.push(cwd);
135
-
136
- const proc = spawn('grep', args);
137
- let stdout = '';
138
- let stderr = '';
139
- // v5.6.32: Memory taşmasını önle - max 5MB output
140
- let stdoutBytes = 0;
141
- const MAX_OUTPUT = 5 * 1024 * 1024; // 5MB
142
- let truncated = false;
143
- const addStdout = (d) => {
144
- if (truncated) return;
145
- stdoutBytes += d.length;
146
- if (stdoutBytes > MAX_OUTPUT) {
147
- truncated = true;
148
- stdout += '\n[OUTPUT TRUNCATED - exceeded 5MB limit]';
149
- return;
150
- }
151
- stdout += d.toString();
152
- };
153
- proc.stdout.on('data', addStdout);
154
-
155
- proc.on('close', (code) => {
156
- const results = [];
157
- const lines = stdout.split('\n').filter(Boolean);
158
- for (const line of lines) {
159
- if (results.length >= maxResults) break;
160
- const match = line.match(/^(.+?):(\d+):(.*)$/);
161
- if (match) {
162
- results.push({ file: match[1], line: parseInt(match[2]), text: match[3] });
163
- }
164
- }
165
- resolve({ success: true, pattern, tool: 'grep', count: results.length, results });
166
- });
167
- proc.on('error', (e) => resolve({ success: false, error: e.message }));
168
- });
169
- }
170
-
171
180
  module.exports = {
172
181
  name: 'grep_search',
173
182
  description: 'Dosya içeriklerinde pattern ara (ripgrep veya grep). Örn: pattern="TODO", path="~/projects".',
@@ -185,4 +194,7 @@ module.exports = {
185
194
  async execute(params) {
186
195
  return await grepSearch(params);
187
196
  },
197
+
198
+ // v5.39: test icin — saf Node fallback'i rg'den bagimsiz dogrulamak icin
199
+ _grepWithNode: grepWithNode,
188
200
  };
@@ -124,9 +124,14 @@ function detectPlatform(input) {
124
124
  };
125
125
  }
126
126
 
127
- async function socialOpen(params) {
128
- if (!IS_MAC) return { success: false, error: "Henüz sadece macOS destekleniyor" };
127
+ // v5.39: platformlar arası URL açma — macOS `open`, Windows `start`, Linux `xdg-open`.
128
+ function openUrlProc(url, browserApp) {
129
+ if (IS_MAC) return spawn("open", browserApp ? ["-a", browserApp, url] : [url]);
130
+ if (process.platform === "win32") return spawn("cmd", ["/c", "start", "", url], { windowsHide: true });
131
+ return spawn("xdg-open", [url]); // linux + diğer *nix
132
+ }
129
133
 
134
+ async function socialOpen(params) {
130
135
  const { query, platform, username } = params;
131
136
 
132
137
  if (!query && !platform && !username) {
@@ -146,20 +151,19 @@ async function socialOpen(params) {
146
151
  note = detected.note;
147
152
  }
148
153
 
149
- const browser = getOpenBrowser();
154
+ const browser = IS_MAC ? getOpenBrowser() : null; // pgrep sadece macOS
150
155
  return new Promise((resolve) => {
151
- const args = browser ? ["-a", browser, url] : [url];
152
- const proc = spawn("open", args);
156
+ const proc = openUrlProc(url, browser);
153
157
  proc.on("close", (code) => {
154
158
  if (code === 0) {
155
159
  resolve({
156
160
  success: true,
157
161
  message: browser
158
162
  ? `${browser}'da yeni sekmede açıldı`
159
- : "Yeni tarayıcı penceresinde açıldı",
163
+ : "Varsayılan tarayıcıda açıldı",
160
164
  platform: platformName,
161
165
  url,
162
- browser: browser || "new",
166
+ browser: browser || "default",
163
167
  ...(note ? { note } : {}),
164
168
  });
165
169
  } else {