natureco-cli 2.23.4 → 2.23.6
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/bin/natureco.js +36 -15
- package/package.json +7 -10
- package/src/commands/chat.js +34 -4
- package/src/commands/code.js +45 -23
- package/src/commands/doctor.js +2 -2
- package/src/commands/gateway.js +1 -2
- package/src/commands/help.js +1 -1
- package/src/commands/migrate.js +5 -44
- package/src/commands/sessions.js +70 -183
- package/src/commands/telegram.js +1 -2
- package/src/commands/ultrareview.js +0 -7
- package/src/commands/update.js +2 -17
- package/src/commands/whatsapp.js +1 -2
- package/src/tools/bash.js +6 -4
- package/src/tools/filesystem.js +2 -62
- package/src/tools/git.js +39 -0
- package/src/tools/list_dir.js +5 -3
- package/src/utils/agents.js +7 -4
- package/src/utils/api.js +185 -11
- package/src/utils/commands.js +12 -7
- package/src/utils/config.js +2 -2
- package/src/utils/gateway-ws.js +73 -63
- package/src/utils/hooks.js +16 -11
- package/src/utils/inquirer-wrapper.js +8 -10
- package/src/utils/mcp.js +6 -2
- package/src/utils/path-utils.js +23 -0
- package/src/utils/sessions.js +170 -109
- package/src/utils/skills.js +25 -8
- package/src/utils/tool-runner.js +8 -7
package/bin/natureco.js
CHANGED
|
@@ -97,6 +97,9 @@ program
|
|
|
97
97
|
.command('chat [bot-name...]')
|
|
98
98
|
.description('Start interactive chat with a bot (uses default bot if not specified)')
|
|
99
99
|
.option('--resume [session-id]', 'Resume a previous session')
|
|
100
|
+
.option('--continue', 'son oturumu devam ettir')
|
|
101
|
+
.option('--list', 'geçmiş oturumları listele')
|
|
102
|
+
.option('--no-stream', 'streaming devre dışı')
|
|
100
103
|
.action((botNameParts, options) => {
|
|
101
104
|
const botName = Array.isArray(botNameParts) ? botNameParts.join(' ') : botNameParts;
|
|
102
105
|
chat(botName, options);
|
|
@@ -105,9 +108,12 @@ program
|
|
|
105
108
|
program
|
|
106
109
|
.command('code [file]')
|
|
107
110
|
.description('Agentic coding modu — dosya oku, değiştir, komut çalıştır')
|
|
108
|
-
.
|
|
111
|
+
.option('--dir <path>', 'çalışma dizini', process.cwd())
|
|
112
|
+
.option('--no-stream', 'streaming devre dışı')
|
|
113
|
+
.option('--dry-run', 'değişiklikleri göster ama uygulama')
|
|
114
|
+
.action((file, options) => {
|
|
109
115
|
const codeCmd = require('../src/commands/code');
|
|
110
|
-
codeCmd(file);
|
|
116
|
+
codeCmd(file, options);
|
|
111
117
|
});
|
|
112
118
|
|
|
113
119
|
program
|
|
@@ -194,11 +200,26 @@ program
|
|
|
194
200
|
});
|
|
195
201
|
|
|
196
202
|
program
|
|
197
|
-
.command('sessions [action] [
|
|
198
|
-
.description('
|
|
199
|
-
.action((action,
|
|
200
|
-
const
|
|
201
|
-
|
|
203
|
+
.command('sessions [action] [id]')
|
|
204
|
+
.description('Oturum yönetimi (list|delete|show)')
|
|
205
|
+
.action((action, id) => {
|
|
206
|
+
const { listSessions, deleteSession } = require('../src/utils/sessions');
|
|
207
|
+
if (!action || action === 'list') {
|
|
208
|
+
const sessions = listSessions();
|
|
209
|
+
if (!sessions.length) {
|
|
210
|
+
console.log('Kayıtlı oturum yok.');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
sessions.forEach(s => {
|
|
214
|
+
console.log(`[${s.id}] ${s.savedAt.slice(0,10)} — ${s.preview || '(boş)'} (${s.messageCount} mesaj)`);
|
|
215
|
+
});
|
|
216
|
+
} else if (action === 'delete') {
|
|
217
|
+
const ok = deleteSession(id);
|
|
218
|
+
console.log(ok ? 'Oturum silindi.' : 'Oturum bulunamadı.');
|
|
219
|
+
} else {
|
|
220
|
+
const sessionsCmd = require('../src/commands/sessions');
|
|
221
|
+
sessionsCmd(action, id);
|
|
222
|
+
}
|
|
202
223
|
});
|
|
203
224
|
|
|
204
225
|
program
|
|
@@ -250,19 +271,19 @@ program
|
|
|
250
271
|
});
|
|
251
272
|
|
|
252
273
|
program
|
|
253
|
-
.command('whatsapp <action>')
|
|
254
|
-
.description('WhatsApp integration (connect|disconnect|status)')
|
|
255
|
-
.action((action) => {
|
|
274
|
+
.command('whatsapp <action> [number]')
|
|
275
|
+
.description('WhatsApp integration (connect|disconnect|status|allow)')
|
|
276
|
+
.action((action, number) => {
|
|
256
277
|
const whatsappCmd = require('../src/commands/whatsapp');
|
|
257
|
-
whatsappCmd(action);
|
|
278
|
+
whatsappCmd(action, number);
|
|
258
279
|
});
|
|
259
280
|
|
|
260
281
|
program
|
|
261
|
-
.command('telegram <action>')
|
|
262
|
-
.description('Telegram integration (connect|disconnect|status)')
|
|
263
|
-
.action((action) => {
|
|
282
|
+
.command('telegram <action> [chatId]')
|
|
283
|
+
.description('Telegram integration (connect|disconnect|status|allow)')
|
|
284
|
+
.action((action, chatId) => {
|
|
264
285
|
const telegramCmd = require('../src/commands/telegram');
|
|
265
|
-
telegramCmd(action);
|
|
286
|
+
telegramCmd(action, chatId);
|
|
266
287
|
});
|
|
267
288
|
|
|
268
289
|
program
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.6",
|
|
4
4
|
"description": "NatureCo AI Bot Terminal Interface",
|
|
5
|
-
"main": "bin/natureco.js",
|
|
6
5
|
"bin": {
|
|
7
|
-
"natureco": "
|
|
6
|
+
"natureco": "bin/natureco.js"
|
|
8
7
|
},
|
|
9
8
|
"files": [
|
|
10
9
|
"bin/",
|
|
@@ -25,21 +24,19 @@
|
|
|
25
24
|
"license": "MIT",
|
|
26
25
|
"dependencies": {
|
|
27
26
|
"@whiskeysockets/baileys": "^7.0.0-rc10",
|
|
28
|
-
"blessed": "^0.1.81",
|
|
29
|
-
"boxen": "^8.0.1",
|
|
30
27
|
"chalk": "^4.1.2",
|
|
31
28
|
"commander": "^11.1.0",
|
|
32
|
-
"conf": "^10.2.0",
|
|
33
|
-
"eventsource": "^2.0.2",
|
|
34
29
|
"inquirer": "^13.4.3",
|
|
35
|
-
"node-cron": "^
|
|
36
|
-
"node-telegram-bot-api": "^0.
|
|
30
|
+
"node-cron": "^4.2.1",
|
|
31
|
+
"node-telegram-bot-api": "^0.67.0",
|
|
37
32
|
"ora": "^9.4.0",
|
|
38
33
|
"pino": "^8.21.0",
|
|
39
34
|
"qrcode-terminal": "^0.12.0",
|
|
35
|
+
"semver": "^7.8.1",
|
|
40
36
|
"ws": "^8.20.0"
|
|
41
37
|
},
|
|
42
38
|
"engines": {
|
|
43
39
|
"node": ">=16.0.0"
|
|
44
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"//": "TODO: form-data güvenlik açığı — node-telegram-bot-api güncelleme gerektirir"
|
|
45
42
|
}
|
package/src/commands/chat.js
CHANGED
|
@@ -12,7 +12,7 @@ const { addToHistory } = require('../utils/history');
|
|
|
12
12
|
const { getMemoryPrompt, extractMemoryFromMessage, loadMemory, clearMemory, addMemoryEntry } = require('../utils/memory');
|
|
13
13
|
const { getCommands, getCommandContent } = require('../utils/commands');
|
|
14
14
|
const { runHooks } = require('../utils/hooks');
|
|
15
|
-
const { createSession, loadSession, getLatestSession, addMessageToSession } = require('../utils/sessions');
|
|
15
|
+
const { createSession, loadSession, getLatestSession, addMessageToSession, loadLastSession, listSessions, saveSession } = require('../utils/sessions');
|
|
16
16
|
const { getToolDefinitions, executeToolCalls, getSessionStats, resetSessionStats } = require('../utils/tool-runner');
|
|
17
17
|
const { extractToolCalls } = require('../utils/tool-adapter');
|
|
18
18
|
|
|
@@ -63,6 +63,20 @@ async function chat(botName, options = {}) {
|
|
|
63
63
|
const config = getConfig();
|
|
64
64
|
const version = require('../../package.json').version;
|
|
65
65
|
|
|
66
|
+
// ── Session listeleme ──────────────────────────────────────────────────────
|
|
67
|
+
if (options.list) {
|
|
68
|
+
const sessions = listSessions('chat');
|
|
69
|
+
if (!sessions.length) {
|
|
70
|
+
console.log(chalk.gray('\nKayıtlı oturum yok.\n'));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
sessions.forEach(s => {
|
|
74
|
+
console.log(` [${s.id}] ${s.savedAt.slice(0, 10)} — ${s.preview || '(boş)'} (${s.messageCount} mesaj)`);
|
|
75
|
+
});
|
|
76
|
+
console.log();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
// ── Bot seçimi ──────────────────────────────────────────────────────────────
|
|
67
81
|
let botList;
|
|
68
82
|
try {
|
|
@@ -122,6 +136,12 @@ async function chat(botName, options = {}) {
|
|
|
122
136
|
session = options.resume === true
|
|
123
137
|
? getLatestSession(bot.id) || createSession(bot.id, bot.name)
|
|
124
138
|
: loadSession(bot.id, options.resume) || createSession(bot.id, bot.name);
|
|
139
|
+
} else if (options.continue) {
|
|
140
|
+
const last = loadLastSession('chat');
|
|
141
|
+
if (last) {
|
|
142
|
+
console.log(chalk.cyan(` ↻ Son oturum yüklendi (${last.messages.length} mesaj)\n`));
|
|
143
|
+
}
|
|
144
|
+
session = createSession(bot.id, bot.name);
|
|
125
145
|
} else {
|
|
126
146
|
session = createSession(bot.id, bot.name);
|
|
127
147
|
}
|
|
@@ -274,7 +294,7 @@ async function chat(botName, options = {}) {
|
|
|
274
294
|
console.log(chalk.white('You ') + userMessage);
|
|
275
295
|
startLoading();
|
|
276
296
|
try {
|
|
277
|
-
const res = await sendMessage(apiKey || config.providerApiKey, bot.id, msg, conversationId, customPrompt);
|
|
297
|
+
const res = await sendMessage(apiKey || config.providerApiKey, bot.id, msg, conversationId, customPrompt, options);
|
|
278
298
|
stopLoading();
|
|
279
299
|
if (res.conversation_id) conversationId = res.conversation_id;
|
|
280
300
|
const reply = res.reply || res.message || '';
|
|
@@ -307,7 +327,7 @@ async function chat(botName, options = {}) {
|
|
|
307
327
|
|
|
308
328
|
try {
|
|
309
329
|
const toolDefinitions = getToolDefinitions();
|
|
310
|
-
let response = await _sendMessage(apiKey || config.providerApiKey, bot.id, userMessage, conversationId, systemPrompt, toolDefinitions);
|
|
330
|
+
let response = await _sendMessage(apiKey || config.providerApiKey, bot.id, userMessage, conversationId, systemPrompt, toolDefinitions, options);
|
|
311
331
|
stopLoading();
|
|
312
332
|
|
|
313
333
|
if (response.conversation_id) conversationId = response.conversation_id;
|
|
@@ -321,7 +341,7 @@ async function chat(botName, options = {}) {
|
|
|
321
341
|
const toolResults = await executeToolCalls(toolCalls);
|
|
322
342
|
const toolMsg = toolResults.map(tr => `Tool: ${tr.name}\nResult: ${tr.result.success ? (tr.result.output || '') : tr.result.error}`).join('\n\n');
|
|
323
343
|
startLoading();
|
|
324
|
-
response = await _sendMessage(apiKey || config.providerApiKey, bot.id, toolMsg, conversationId, systemPrompt, toolDefinitions);
|
|
344
|
+
response = await _sendMessage(apiKey || config.providerApiKey, bot.id, toolMsg, conversationId, systemPrompt, toolDefinitions, options);
|
|
325
345
|
stopLoading();
|
|
326
346
|
if (response.conversation_id) conversationId = response.conversation_id;
|
|
327
347
|
iter++;
|
|
@@ -354,6 +374,16 @@ async function chat(botName, options = {}) {
|
|
|
354
374
|
await runHooks('on-exit', null, { botId: bot.id, botName: bot.name });
|
|
355
375
|
rl.close();
|
|
356
376
|
const { filesChanged, commandsRun } = getSessionStats();
|
|
377
|
+
if (messagesCount > 0) {
|
|
378
|
+
const historyMessages = [];
|
|
379
|
+
if (session.messages?.length) {
|
|
380
|
+
for (const m of session.messages) {
|
|
381
|
+
historyMessages.push({ role: 'user', content: m.user });
|
|
382
|
+
historyMessages.push({ role: 'assistant', content: m.bot });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
saveSession('chat', historyMessages, { botId: bot.id, botName: bot.name });
|
|
386
|
+
}
|
|
357
387
|
if (filesChanged > 0 || commandsRun > 0 || messagesCount > 0) {
|
|
358
388
|
console.log(chalk.gray('\n─── Session Özeti ───'));
|
|
359
389
|
if (filesChanged > 0) console.log(chalk.green(` ✓ ${filesChanged} dosya değiştirildi`));
|
package/src/commands/code.js
CHANGED
|
@@ -142,13 +142,13 @@ function buildIndexPrompt(index) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// ── Proje hafızası ────────────────────────────────────────────────────────────
|
|
145
|
-
function getProjectMemoryPath() {
|
|
146
|
-
return path.join(
|
|
145
|
+
function getProjectMemoryPath(workDir) {
|
|
146
|
+
return path.join(workDir, '.natureco', 'project.md');
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
function loadProjectMemory() {
|
|
149
|
+
function loadProjectMemory(workDir) {
|
|
150
150
|
try {
|
|
151
|
-
const p = getProjectMemoryPath();
|
|
151
|
+
const p = getProjectMemoryPath(workDir);
|
|
152
152
|
if (fs.existsSync(p)) return fs.readFileSync(p, 'utf8');
|
|
153
153
|
} catch {}
|
|
154
154
|
return null;
|
|
@@ -171,11 +171,11 @@ async function generateSummary(messages, providerConfig) {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
async function saveProjectMemory(messages, providerConfig) {
|
|
174
|
+
async function saveProjectMemory(messages, providerConfig, workDir) {
|
|
175
175
|
const sp = startSpinner('Proje hafızası güncelleniyor...');
|
|
176
176
|
const summary = await generateSummary(messages, providerConfig);
|
|
177
177
|
stopSpinner(sp, 'Proje hafızası güncellendi', true);
|
|
178
|
-
const memPath = getProjectMemoryPath();
|
|
178
|
+
const memPath = getProjectMemoryPath(workDir);
|
|
179
179
|
const dir = path.dirname(memPath);
|
|
180
180
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
181
181
|
const existing = fs.existsSync(memPath) ? fs.readFileSync(memPath, 'utf8') : '# Proje Hafızası\n';
|
|
@@ -288,14 +288,35 @@ async function streamMessage(providerConfig, messages, tools) {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
// ── Tool execution ────────────────────────────────────────────────────────────
|
|
291
|
-
const DANGEROUS = [
|
|
291
|
+
const DANGEROUS = [/\brm\b/, /\brmdir\b/, /\bdelete\b/i, /\bdrop\b/i, /\btruncate\b/i];
|
|
292
292
|
|
|
293
|
-
async function runToolCall(toolCall, stats) {
|
|
293
|
+
async function runToolCall(toolCall, stats, dryRun = false) {
|
|
294
294
|
const inputPreview = JSON.stringify(toolCall.input).slice(0, 60);
|
|
295
295
|
|
|
296
296
|
const needsConfirm =
|
|
297
297
|
toolCall.name === 'write_file' ||
|
|
298
|
-
(toolCall.name === 'bash' && DANGEROUS.some(
|
|
298
|
+
(toolCall.name === 'bash' && DANGEROUS.some(re => re.test(toolCall.input.command || '')));
|
|
299
|
+
|
|
300
|
+
// Dry-run: write_file'ı engelle, diff göster
|
|
301
|
+
if (dryRun && toolCall.name === 'write_file') {
|
|
302
|
+
let oldContent = '';
|
|
303
|
+
try { oldContent = fs.readFileSync(toolCall.input.path, 'utf-8'); } catch {}
|
|
304
|
+
const newContent = toolCall.input.content || '';
|
|
305
|
+
const oldLines = oldContent.split('\n');
|
|
306
|
+
const newLines = newContent.split('\n');
|
|
307
|
+
console.log(chalk.gray(`\n 📄 ${toolCall.input.path}`));
|
|
308
|
+
newLines.forEach(line => {
|
|
309
|
+
if (line && !oldLines.includes(line)) console.log(chalk.green(' + ' + line));
|
|
310
|
+
});
|
|
311
|
+
oldLines.forEach(line => {
|
|
312
|
+
if (line && !newLines.includes(line)) console.log(chalk.red(' - ' + line));
|
|
313
|
+
});
|
|
314
|
+
console.log(chalk.yellow('\n ⚠️ DRY RUN — dosya değiştirilmedi\n'));
|
|
315
|
+
stats.filesChanged++;
|
|
316
|
+
stats.changedFiles.push(toolCall.input.path || '?');
|
|
317
|
+
stats.toolCallCount++;
|
|
318
|
+
return { success: true, output: '[DRY RUN] Değişiklik gösterildi, uygulanmadı' };
|
|
319
|
+
}
|
|
299
320
|
|
|
300
321
|
if (needsConfirm) {
|
|
301
322
|
console.log(chalk.yellow(`\n ⚠️ ${toolCall.name}: ${inputPreview}`));
|
|
@@ -319,7 +340,6 @@ async function runToolCall(toolCall, stats) {
|
|
|
319
340
|
stats.changedFiles.push(toolCall.input.path || '?');
|
|
320
341
|
console.log(chalk.green(` ✓ ${toolCall.input.path} güncellendi`));
|
|
321
342
|
if (stats.changedFiles.length === 1) {
|
|
322
|
-
// İlk değişiklikte ipucu göster
|
|
323
343
|
console.log(chalk.gray(` 💡 git add . && /commit ile kaydet`));
|
|
324
344
|
}
|
|
325
345
|
}
|
|
@@ -331,7 +351,7 @@ async function runToolCall(toolCall, stats) {
|
|
|
331
351
|
}
|
|
332
352
|
|
|
333
353
|
// ── Test runner ───────────────────────────────────────────────────────────────
|
|
334
|
-
async function runTests(projectIndex, conversationMessages, tools, providerConfig, displayBotName) {
|
|
354
|
+
async function runTests(projectIndex, conversationMessages, tools, providerConfig, displayBotName, workDir) {
|
|
335
355
|
const testScript = projectIndex.packageJson?.scripts?.test;
|
|
336
356
|
if (!testScript || testScript.includes('no test')) return;
|
|
337
357
|
|
|
@@ -344,7 +364,7 @@ async function runTests(projectIndex, conversationMessages, tools, providerConfi
|
|
|
344
364
|
console.log(chalk.gray('\n npm test çalışıyor...\n'));
|
|
345
365
|
try {
|
|
346
366
|
const output = execSync('npm test', {
|
|
347
|
-
cwd:
|
|
367
|
+
cwd: workDir, timeout: 30000, stdio: 'pipe',
|
|
348
368
|
}).toString();
|
|
349
369
|
console.log(chalk.green(' ✅ Testler geçti!\n'));
|
|
350
370
|
} catch (err) {
|
|
@@ -366,6 +386,7 @@ async function runTests(projectIndex, conversationMessages, tools, providerConfi
|
|
|
366
386
|
|
|
367
387
|
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
368
388
|
async function code(targetFile, options = {}) {
|
|
389
|
+
const workDir = options.dir || process.cwd();
|
|
369
390
|
const apiKey = getApiKey();
|
|
370
391
|
const config = getConfig();
|
|
371
392
|
const version = require('../../package.json').version;
|
|
@@ -411,7 +432,7 @@ async function code(targetFile, options = {}) {
|
|
|
411
432
|
|
|
412
433
|
// ── Proje indexing ───────────────────────────────────────────────────────────
|
|
413
434
|
const indexSpinner = startSpinner('Proje indexleniyor...');
|
|
414
|
-
const projectIndex = await indexProject(
|
|
435
|
+
const projectIndex = await indexProject(workDir);
|
|
415
436
|
stopSpinner(indexSpinner, `${projectIndex.type.toUpperCase()} projesi — ${projectIndex.files.length} dosya`, true);
|
|
416
437
|
|
|
417
438
|
// ── Sistem prompt ────────────────────────────────────────────────────────────
|
|
@@ -431,7 +452,7 @@ ${indexPrompt}`;
|
|
|
431
452
|
if (memoryPrompt) systemPrompt += '\n\n' + memoryPrompt;
|
|
432
453
|
|
|
433
454
|
// ── Proje hafızası ────────────────────────────────────────────────────────
|
|
434
|
-
const projectMemory = loadProjectMemory();
|
|
455
|
+
const projectMemory = loadProjectMemory(workDir);
|
|
435
456
|
if (projectMemory) {
|
|
436
457
|
systemPrompt += `\n\n## Proje Geçmişi (.natureco/project.md)\n${projectMemory.slice(0, 2000)}`;
|
|
437
458
|
}
|
|
@@ -496,6 +517,7 @@ ${indexPrompt}`;
|
|
|
496
517
|
const w = process.stdout.columns || 120;
|
|
497
518
|
console.log(chalk.gray('\n' + '─'.repeat(w)));
|
|
498
519
|
console.log(chalk.gray(' Agent Session Özeti'));
|
|
520
|
+
if (options.dryRun) console.log(chalk.yellow(' ⚠️ DRY RUN — hiçbir dosya değiştirilmedi'));
|
|
499
521
|
console.log(chalk.gray('─'.repeat(w)));
|
|
500
522
|
console.log(` ${chalk.green('✓')} ${stats.filesChanged} dosya değiştirildi`);
|
|
501
523
|
console.log(` ${chalk.green('✓')} ${stats.commandsRun} komut çalıştırıldı`);
|
|
@@ -515,7 +537,7 @@ ${indexPrompt}`;
|
|
|
515
537
|
console.log(chalk.gray(`\n ▶ ${cmd} çalıştırılıyor...\n`));
|
|
516
538
|
try {
|
|
517
539
|
const output = execSync(cmd, {
|
|
518
|
-
cwd:
|
|
540
|
+
cwd: workDir, timeout: 30000, stdio: 'pipe',
|
|
519
541
|
}).toString();
|
|
520
542
|
console.log(chalk.green(' ✓ Başarılı:'));
|
|
521
543
|
console.log(chalk.gray(' ' + output.slice(0, 500).split('\n').join('\n ')));
|
|
@@ -590,7 +612,7 @@ ${indexPrompt}`;
|
|
|
590
612
|
}
|
|
591
613
|
case 'index': {
|
|
592
614
|
const sp = startSpinner('Proje yeniden indexleniyor...');
|
|
593
|
-
const newIndex = await indexProject(
|
|
615
|
+
const newIndex = await indexProject(workDir);
|
|
594
616
|
stopSpinner(sp, `${newIndex.files.length} dosya indexlendi`, true);
|
|
595
617
|
// Sistem prompt'u güncelle
|
|
596
618
|
conversationMessages[0].content = conversationMessages[0].content.replace(
|
|
@@ -617,8 +639,8 @@ ${indexPrompt}`;
|
|
|
617
639
|
}
|
|
618
640
|
case 'git': {
|
|
619
641
|
try {
|
|
620
|
-
const status = execSync('git status --short', { cwd:
|
|
621
|
-
const log = execSync('git log --oneline -5', { cwd:
|
|
642
|
+
const status = execSync('git status --short', { cwd: workDir, stdio: 'pipe' }).toString().trim();
|
|
643
|
+
const log = execSync('git log --oneline -5', { cwd: workDir, stdio: 'pipe' }).toString().trim();
|
|
622
644
|
console.log(chalk.yellow('\n Git Durumu:'));
|
|
623
645
|
console.log(status ? chalk.gray(' ' + status.split('\n').join('\n ')) : chalk.gray(' temiz'));
|
|
624
646
|
console.log(chalk.yellow('\n Son Commitler:'));
|
|
@@ -631,7 +653,7 @@ ${indexPrompt}`;
|
|
|
631
653
|
}
|
|
632
654
|
case 'commit': {
|
|
633
655
|
try {
|
|
634
|
-
const diff = execSync('git diff --staged', { cwd:
|
|
656
|
+
const diff = execSync('git diff --staged', { cwd: workDir, stdio: 'pipe' }).toString();
|
|
635
657
|
if (!diff.trim()) {
|
|
636
658
|
console.log(chalk.red('\n Staged değişiklik yok.'));
|
|
637
659
|
console.log(chalk.gray(' Önce: git add .\n'));
|
|
@@ -646,7 +668,7 @@ ${indexPrompt}`;
|
|
|
646
668
|
message: ' Commit edilsin mi?', default: true,
|
|
647
669
|
}]);
|
|
648
670
|
if (ok) {
|
|
649
|
-
execSync(`git commit -m "${commitMsg.replace(/"/g, '\\"')}"`, { cwd:
|
|
671
|
+
execSync(`git commit -m "${commitMsg.replace(/"/g, '\\"')}"`, { cwd: workDir, stdio: 'pipe' });
|
|
650
672
|
console.log(chalk.green(' ✓ Commit yapıldı!\n'));
|
|
651
673
|
} else {
|
|
652
674
|
console.log(chalk.gray(' İptal edildi.\n'));
|
|
@@ -709,7 +731,7 @@ ${indexPrompt}`;
|
|
|
709
731
|
|
|
710
732
|
for (let ti = 0; ti < streamResult.toolCalls.length; ti++) {
|
|
711
733
|
const toolCall = streamResult.toolCalls[ti];
|
|
712
|
-
const result = await runToolCall(toolCall, stats);
|
|
734
|
+
const result = await runToolCall(toolCall, stats, options.dryRun);
|
|
713
735
|
const resultStr = result.success !== false
|
|
714
736
|
? (result.output || JSON.stringify(result))
|
|
715
737
|
: `Hata: ${result.error}`;
|
|
@@ -734,7 +756,7 @@ ${indexPrompt}`;
|
|
|
734
756
|
}
|
|
735
757
|
|
|
736
758
|
if (stats.filesChanged > prevFilesChanged && projectIndex.packageJson?.scripts?.test) {
|
|
737
|
-
const fixPrompt = await runTests(projectIndex, conversationMessages, tools, providerConfig, displayBotName);
|
|
759
|
+
const fixPrompt = await runTests(projectIndex, conversationMessages, tools, providerConfig, displayBotName, workDir);
|
|
738
760
|
if (fixPrompt) {
|
|
739
761
|
await handleMessage(fixPrompt);
|
|
740
762
|
}
|
|
@@ -763,7 +785,7 @@ ${indexPrompt}`;
|
|
|
763
785
|
message: chalk.yellow("Bu session'ı proje hafızasına kaydet?"),
|
|
764
786
|
default: true,
|
|
765
787
|
}]);
|
|
766
|
-
if (save) await saveProjectMemory(conversationMessages, providerConfig);
|
|
788
|
+
if (save) await saveProjectMemory(conversationMessages, providerConfig, workDir);
|
|
767
789
|
} catch {}
|
|
768
790
|
}
|
|
769
791
|
showSummary();
|
package/src/commands/doctor.js
CHANGED
|
@@ -277,7 +277,7 @@ async function doctor(options) {
|
|
|
277
277
|
criticalPassed++;
|
|
278
278
|
results.push({ status: 'ok', message: 'Provider erişilebilir' });
|
|
279
279
|
} catch (err) {
|
|
280
|
-
console.log(chalk.red('
|
|
280
|
+
console.log(chalk.red('Bağlantı hatası: ' + err.message));
|
|
281
281
|
results.push({ status: 'error', message: 'Provider erişilemiyor' });
|
|
282
282
|
}
|
|
283
283
|
} else {
|
|
@@ -317,7 +317,7 @@ async function doctor(options) {
|
|
|
317
317
|
results.push({ status: 'info', message: 'Versiyon kontrol edilemedi' });
|
|
318
318
|
}
|
|
319
319
|
} catch (err) {
|
|
320
|
-
console.log(chalk.
|
|
320
|
+
console.log(chalk.red('Bağlantı hatası: ' + err.message));
|
|
321
321
|
results.push({ status: 'info', message: 'Versiyon kontrol edilemedi' });
|
|
322
322
|
}
|
|
323
323
|
|
package/src/commands/gateway.js
CHANGED
|
@@ -8,7 +8,7 @@ const { getSkills } = require('../utils/skills');
|
|
|
8
8
|
const { getMcpServers } = require('../utils/mcp');
|
|
9
9
|
|
|
10
10
|
// WhatsApp imports
|
|
11
|
-
let makeWASocket, useMultiFileAuthState,
|
|
11
|
+
let makeWASocket, useMultiFileAuthState, fetchLatestBaileysVersion, Browsers;
|
|
12
12
|
const pino = require('pino');
|
|
13
13
|
const logger = pino({ level: 'silent' });
|
|
14
14
|
|
|
@@ -18,7 +18,6 @@ function loadBaileys() {
|
|
|
18
18
|
const baileys = require('@whiskeysockets/baileys');
|
|
19
19
|
makeWASocket = baileys.default;
|
|
20
20
|
useMultiFileAuthState = baileys.useMultiFileAuthState;
|
|
21
|
-
DisconnectReason = baileys.DisconnectReason;
|
|
22
21
|
fetchLatestBaileysVersion = baileys.fetchLatestBaileysVersion;
|
|
23
22
|
Browsers = baileys.Browsers;
|
|
24
23
|
}
|
package/src/commands/help.js
CHANGED
|
@@ -64,7 +64,7 @@ function help() {
|
|
|
64
64
|
console.log(chalk.cyan.bold('\n Otomasyon\n'));
|
|
65
65
|
printCmd('natureco cron add', 'Zamanlanmış görev oluştur');
|
|
66
66
|
printCmd('natureco cron list', 'Cron görevlerini listele');
|
|
67
|
-
printCmd('natureco cron
|
|
67
|
+
printCmd('natureco cron remove', 'Cron görevi sil');
|
|
68
68
|
printCmd('natureco hooks create <tip>', 'Hook oluştur (pre-message, post-message...)');
|
|
69
69
|
printCmd('natureco commands create <ad>','Özel /komut oluştur');
|
|
70
70
|
printCmd('natureco ultrareview <dosya>','Kod inceleme — güvenlik, performans, kalite');
|
package/src/commands/migrate.js
CHANGED
|
@@ -3,7 +3,8 @@ const path = require('path');
|
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const { execSync } = require('child_process');
|
|
6
|
-
const { getConfig,
|
|
6
|
+
const { getConfig, setConfigValue } = require('../utils/config');
|
|
7
|
+
const { normalizeWindowsPaths } = require('../utils/path-utils');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Normalize WhatsApp number from JID format to clean phone number
|
|
@@ -345,27 +346,7 @@ async function migrate(options) {
|
|
|
345
346
|
|
|
346
347
|
// Fix Windows paths in .js files
|
|
347
348
|
if (file.endsWith('.js')) {
|
|
348
|
-
|
|
349
|
-
content = content.replace(/\\/g, '/');
|
|
350
|
-
|
|
351
|
-
// Then normalize Windows path patterns (comprehensive)
|
|
352
|
-
// Handle escaped backslashes in strings (C:\\\\Users\\\\user\\\\ → homedir/)
|
|
353
|
-
content = content
|
|
354
|
-
.replace(/C:\/\/\/\/Users\/\/\/\/user\/\/\/\//g, `${os.homedir()}/`)
|
|
355
|
-
.replace(/C:\/Users\/user\//g, `${os.homedir()}/`)
|
|
356
|
-
.replace(/C:\/Users\/user\//g, `${os.homedir()}/`)
|
|
357
|
-
// Double slash versions (escaped in strings)
|
|
358
|
-
.replace(/C:\/\/Users\/\/user\/\/\.natureco\/\//g, `${os.homedir()}/.natureco/`)
|
|
359
|
-
.replace(/C:\/\/Users\/\/user\/\//g, `${os.homedir()}/`)
|
|
360
|
-
.replace(/E:\/\/\.natureco\/\//g, `${os.homedir()}/.natureco/`)
|
|
361
|
-
// String literals with quotes
|
|
362
|
-
.replace(/'C:\/Users\/user\/\.natureco\//g, `'${os.homedir()}/.natureco/`)
|
|
363
|
-
.replace(/"C:\/Users\/user\/\.natureco\//g, `"${os.homedir()}/.natureco/`)
|
|
364
|
-
.replace(/'C:\/\/\/\/Users\/\/\/\/user\/\/\/\/\.natureco\/\/\/\//g, `'${os.homedir()}/.natureco/`)
|
|
365
|
-
// General patterns
|
|
366
|
-
.replace(/E:\/\.openclaw\//g, `${os.homedir()}/.natureco/`)
|
|
367
|
-
.replace(/\.openclaw\//g, '.natureco/')
|
|
368
|
-
.replace(/workspace\/scripts\\/g, 'workspace/scripts/');
|
|
349
|
+
content = normalizeWindowsPaths(content);
|
|
369
350
|
}
|
|
370
351
|
|
|
371
352
|
// Write fixed content
|
|
@@ -469,27 +450,7 @@ async function migrate(options) {
|
|
|
469
450
|
let prompt = job.payload?.message || '';
|
|
470
451
|
|
|
471
452
|
// Fix Windows paths in prompts (comprehensive)
|
|
472
|
-
|
|
473
|
-
prompt = prompt.replace(/\\/g, '/');
|
|
474
|
-
|
|
475
|
-
// Then normalize Windows path patterns
|
|
476
|
-
// Handle escaped backslashes and string literals
|
|
477
|
-
prompt = prompt
|
|
478
|
-
.replace(/C:\/\/\/\/Users\/\/\/\/user\/\/\/\//g, `${os.homedir()}/`)
|
|
479
|
-
.replace(/C:\/Users\/user\//g, `${os.homedir()}/`)
|
|
480
|
-
.replace(/C:\/Users\/user\//g, `${os.homedir()}/`)
|
|
481
|
-
// Double slash versions (escaped in strings)
|
|
482
|
-
.replace(/C:\/\/Users\/\/user\/\/\.natureco\/\//g, `${os.homedir()}/.natureco/`)
|
|
483
|
-
.replace(/C:\/\/Users\/\/user\/\//g, `${os.homedir()}/`)
|
|
484
|
-
.replace(/E:\/\/\.natureco\/\//g, `${os.homedir()}/.natureco/`)
|
|
485
|
-
// String literals with quotes
|
|
486
|
-
.replace(/'C:\/Users\/user\/\.natureco\//g, `'${os.homedir()}/.natureco/`)
|
|
487
|
-
.replace(/"C:\/Users\/user\/\.natureco\//g, `"${os.homedir()}/.natureco/`)
|
|
488
|
-
.replace(/'C:\/\/\/\/Users\/\/\/\/user\/\/\/\/\.natureco\/\/\/\//g, `'${os.homedir()}/.natureco/`)
|
|
489
|
-
// General patterns
|
|
490
|
-
.replace(/E:\/\.openclaw\//g, `${os.homedir()}/.natureco/`)
|
|
491
|
-
.replace(/\.openclaw\//g, '.natureco/')
|
|
492
|
-
.replace(/workspace\/scripts\\/g, 'workspace/scripts/');
|
|
453
|
+
prompt = normalizeWindowsPaths(prompt);
|
|
493
454
|
|
|
494
455
|
if (prompt.length > 300) {
|
|
495
456
|
prompt = prompt.slice(0, 300);
|
|
@@ -540,7 +501,7 @@ async function migrate(options) {
|
|
|
540
501
|
|
|
541
502
|
if (Array.isArray(allowFrom) && allowFrom.length > 0) {
|
|
542
503
|
// Save to NatureCo config
|
|
543
|
-
|
|
504
|
+
setConfigValue('telegramAllowedChats', allowFrom);
|
|
544
505
|
report.telegram = allowFrom;
|
|
545
506
|
}
|
|
546
507
|
}
|