natureco-cli 1.0.7 → 1.0.9

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": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "main": "bin/natureco.js",
6
6
  "bin": {
@@ -25,15 +25,18 @@ async function gateway() {
25
25
  // Normal gateway ekranı
26
26
  const version = packageJson.version;
27
27
 
28
- // Ana kutu
28
+ console.clear();
29
+
30
+ // Ana logo kutusu - daha büyük ve etkileyici
29
31
  const title = boxen(
30
- chalk.green.bold(`🌿 NatureCo Terminal v${version}\n\n`) +
31
- chalk.gray('AI botlarınızla terminal\'den\n') +
32
- chalk.gray('konuşun, workflow\'ları otomatize\n') +
33
- chalk.gray('edin.'),
32
+ chalk.green.bold('🌿 NatureCo Terminal\n') +
33
+ chalk.green.bold(` v${version}\n\n`) +
34
+ chalk.gray('AI botlarınızla terminal\'den konuşun\n') +
35
+ chalk.gray('Workflow\'ları otomatize edin\n') +
36
+ chalk.gray('Yetenekler ekleyin, MCP entegre edin'),
34
37
  {
35
- padding: 1,
36
- margin: 1,
38
+ padding: { top: 1, bottom: 1, left: 3, right: 3 },
39
+ margin: { top: 1, bottom: 0, left: 0, right: 0 },
37
40
  borderStyle: 'round',
38
41
  borderColor: 'green',
39
42
  align: 'center',
@@ -41,43 +44,69 @@ async function gateway() {
41
44
  );
42
45
 
43
46
  console.log(title);
47
+ console.log(chalk.gray('─'.repeat(60)));
48
+ console.log('');
44
49
 
45
- // Durum bilgileri
50
+ // Durum bilgileri - emoji ve ikonlarla
46
51
  if (config.apiKey) {
47
52
  const maskedKey = config.apiKey.substring(0, 7) + '...';
48
- console.log(chalk.cyan(' Giriş yapıldı:'), chalk.white(maskedKey));
53
+ console.log(chalk.cyan('🔑 Giriş yapıldı:'), chalk.white(maskedKey));
49
54
  } else {
50
- console.log(chalk.yellow(' Giriş yapılmadı'), chalk.gray('(natureco login)'));
55
+ console.log(chalk.yellow('🔑 Giriş yapılmadı'), chalk.gray('(natureco login)'));
51
56
  }
52
57
 
53
58
  if (config.defaultBot) {
54
- console.log(chalk.cyan(' Aktif bot:'), chalk.white(config.defaultBot));
59
+ console.log(chalk.cyan('🤖 Aktif bot:'), chalk.white(config.defaultBot));
55
60
  } else {
56
- console.log(chalk.gray(' Aktif bot: Yok'));
61
+ console.log(chalk.gray('🤖 Aktif bot: Yok'));
57
62
  }
58
63
 
59
64
  const skills = getSkills();
60
65
  const skillCount = skills.length;
61
- console.log(chalk.cyan(' Skills:'), chalk.white(`${skillCount} yüklü`));
66
+ console.log(chalk.cyan(' Skills:'), chalk.white(`${skillCount} yüklü`));
62
67
 
63
68
  const mcpServers = getMcpServers();
64
69
  const mcpCount = Object.keys(mcpServers).length;
65
70
  const activeMcpCount = Object.values(mcpServers).filter(s => !s.disabled).length;
66
- console.log(chalk.cyan(' MCP:'), chalk.white(`${activeMcpCount}/${mcpCount} aktif`));
71
+ console.log(chalk.cyan('🔌 MCP:'), chalk.white(`${activeMcpCount}/${mcpCount} aktif`));
67
72
 
73
+ console.log('');
74
+ console.log(chalk.gray('─'.repeat(60)));
68
75
  console.log('');
69
76
 
70
- // Komutlar
71
- console.log(chalk.bold('Komutlar:'));
72
- console.log(chalk.yellow(' chat <bot> '), chalk.gray('Bot ile konuş'));
73
- console.log(chalk.yellow(' bots '), chalk.gray('Botlarını listele'));
74
- console.log(chalk.yellow(' skills '), chalk.gray('Skill\'leri yönet'));
75
- console.log(chalk.yellow(' mcp '), chalk.gray('MCP sunucularını yönet'));
76
- console.log(chalk.yellow(' init '), chalk.gray('Projeyi başlat'));
77
- console.log(chalk.yellow(' ask "soru" '), chalk.gray('Tek seferlik soru'));
78
- console.log(chalk.yellow(' config '), chalk.gray('Ayarları yönet'));
77
+ // Komutlar - daha okunabilir format
78
+ console.log(chalk.green.bold('Komutlar:\n'));
79
+
80
+ console.log(chalk.yellow(' natureco chat <bot>'));
81
+ console.log(chalk.gray(' Bot ile interaktif sohbet başlat\n'));
82
+
83
+ console.log(chalk.yellow(' natureco bots'));
84
+ console.log(chalk.gray(' Tüm botlarını listele\n'));
85
+
86
+ console.log(chalk.yellow(' natureco ask "soru"'));
87
+ console.log(chalk.gray(' Tek seferlik soru sor\n'));
88
+
89
+ console.log(chalk.yellow(' natureco skills'));
90
+ console.log(chalk.gray(' Skill\'leri yönet (install, remove, list)\n'));
91
+
92
+ console.log(chalk.yellow(' natureco mcp'));
93
+ console.log(chalk.gray(' MCP sunucularını yönet\n'));
94
+
95
+ console.log(chalk.yellow(' natureco init'));
96
+ console.log(chalk.gray(' Mevcut dizinde proje başlat\n'));
97
+
98
+ console.log(chalk.yellow(' natureco config'));
99
+ console.log(chalk.gray(' Ayarları görüntüle ve düzenle\n'));
100
+
101
+ console.log(chalk.yellow(' natureco help'));
102
+ console.log(chalk.gray(' Tüm komutları ve örnekleri göster\n'));
103
+
104
+ console.log(chalk.gray('─'.repeat(60)));
79
105
  console.log('');
80
- console.log(chalk.gray('Yardım için: '), chalk.cyan('natureco help'));
106
+
107
+ // Hızlı başlat ve döküman
108
+ console.log(chalk.cyan('💬 Hızlı başlat:'), chalk.white('natureco chat'));
109
+ console.log(chalk.cyan('📚 Döküman:'), chalk.white('natureco.me/docs'));
81
110
  console.log('');
82
111
  }
83
112
 
@@ -34,6 +34,17 @@ async function setup() {
34
34
  console.log(chalk.cyan('✦ Varsayılan ayarlar yükleniyor...'));
35
35
  console.log(chalk.green(' ✓ Ayarlar hazır\n'));
36
36
 
37
+ // Mevcut config'i kontrol et
38
+ let existingConfig = {};
39
+ if (fs.existsSync(CONFIG_FILE)) {
40
+ try {
41
+ const data = fs.readFileSync(CONFIG_FILE, 'utf-8');
42
+ existingConfig = JSON.parse(data);
43
+ } catch {
44
+ existingConfig = {};
45
+ }
46
+ }
47
+
37
48
  // AI sağlayıcı seç
38
49
  process.stdin.resume();
39
50
  const { aiProvider } = await inquirer.prompt([
@@ -98,72 +109,136 @@ async function setup() {
98
109
  ]);
99
110
 
100
111
  if (wantNaturecoKey) {
101
- process.stdin.resume();
102
- const { ncKey } = await inquirer.prompt([
103
- {
104
- type: 'input',
105
- name: 'ncKey',
106
- message: 'NatureCo API key:',
107
- validate: (input) => {
108
- const trimmed = input.trim();
109
- if (trimmed.length === 0) return true; // Opsiyonel
110
- if (!trimmed.startsWith('nc_') && !trimmed.startsWith('nco_')) {
111
- return 'API key nc_ veya nco_ ile başlamalı';
112
- }
113
- return true;
112
+ // Kayıtlı NatureCo key varsa hatırlat
113
+ if (existingConfig.apiKey) {
114
+ const maskedKey = existingConfig.apiKey.slice(0, 6) + '...';
115
+ process.stdin.resume();
116
+ const { useExistingNcKey } = await inquirer.prompt([
117
+ {
118
+ type: 'confirm',
119
+ name: 'useExistingNcKey',
120
+ message: `Kayıtlı NatureCo API key bulundu: ${maskedKey}. Bunu kullanmak ister misiniz?`,
121
+ default: true,
114
122
  },
115
- },
116
- ]);
117
- if (ncKey.trim().length > 0) {
118
- naturecoApiKey = ncKey.trim();
123
+ ]);
124
+
125
+ if (useExistingNcKey) {
126
+ naturecoApiKey = existingConfig.apiKey;
127
+ }
128
+ }
129
+
130
+ if (!naturecoApiKey) {
131
+ process.stdin.resume();
132
+ const { ncKey } = await inquirer.prompt([
133
+ {
134
+ type: 'input',
135
+ name: 'ncKey',
136
+ message: 'NatureCo API key:',
137
+ validate: (input) => {
138
+ const trimmed = input.trim();
139
+ if (trimmed.length === 0) return true; // Opsiyonel
140
+ if (!trimmed.startsWith('nc_') && !trimmed.startsWith('nco_')) {
141
+ return 'API key nc_ veya nco_ ile başlamalı';
142
+ }
143
+ return true;
144
+ },
145
+ },
146
+ ]);
147
+ if (ncKey.trim().length > 0) {
148
+ naturecoApiKey = ncKey.trim();
149
+ }
119
150
  }
120
151
  }
121
152
  } else {
122
- // NatureCo seçildiyse normal akış
123
- process.stdin.resume();
124
- const { apiKey } = await inquirer.prompt([
125
- {
126
- type: 'input',
127
- name: 'apiKey',
128
- message: 'NatureCo API key girin:',
129
- validate: async (input) => {
130
- if (!input || input.trim().length === 0) {
131
- return 'API key gerekli';
132
- }
153
+ // NatureCo seçildiyse
154
+ // Kayıtlı API key varsa hatırlat
155
+ if (existingConfig.apiKey) {
156
+ const maskedKey = existingConfig.apiKey.slice(0, 6) + '...';
157
+ process.stdin.resume();
158
+ const { useExistingKey } = await inquirer.prompt([
159
+ {
160
+ type: 'confirm',
161
+ name: 'useExistingKey',
162
+ message: `Kayıtlı API key bulundu: ${maskedKey}. Bunu kullanmak ister misiniz?`,
163
+ default: true,
164
+ },
165
+ ]);
166
+
167
+ if (useExistingKey) {
168
+ // Mevcut key'i doğrula
169
+ console.log(chalk.yellow('\n ⏳ API key doğrulanıyor...'));
170
+ try {
171
+ const response = await fetch('https://api.natureco.me/api/v1/bots', {
172
+ headers: {
173
+ 'Authorization': `Bearer ${existingConfig.apiKey}`,
174
+ 'Content-Type': 'application/json',
175
+ },
176
+ });
133
177
 
134
- const trimmed = input.trim();
135
- if (!trimmed.startsWith('nc_') && !trimmed.startsWith('nco_')) {
136
- return 'API key nc_ veya nco_ ile başlamalı';
178
+ if (response.ok) {
179
+ const data = await response.json();
180
+ if (data.bots && data.bots.length > 0) {
181
+ console.log(chalk.green(' ✓ API key doğrulandı\n'));
182
+ naturecoApiKey = existingConfig.apiKey;
183
+ } else {
184
+ console.log(chalk.red(' ✗ Bu API key ile bot bulunamadı\n'));
185
+ }
186
+ } else {
187
+ console.log(chalk.red(' ✗ Geçersiz API key\n'));
137
188
  }
189
+ } catch (err) {
190
+ console.log(chalk.red(` ✗ API hatası: ${err.message}\n`));
191
+ }
192
+ }
193
+ }
138
194
 
139
- console.log(chalk.yellow('\n ⏳ API key doğrulanıyor...'));
140
- try {
141
- const response = await fetch('https://api.natureco.me/api/v1/bots', {
142
- headers: {
143
- 'Authorization': `Bearer ${trimmed}`,
144
- 'Content-Type': 'application/json',
145
- },
146
- });
147
-
148
- if (!response.ok) {
149
- return 'Geçersiz API key';
195
+ // Yeni key sor
196
+ if (!naturecoApiKey) {
197
+ process.stdin.resume();
198
+ const { apiKey } = await inquirer.prompt([
199
+ {
200
+ type: 'input',
201
+ name: 'apiKey',
202
+ message: 'NatureCo API key girin:',
203
+ validate: async (input) => {
204
+ if (!input || input.trim().length === 0) {
205
+ return 'API key gerekli';
150
206
  }
151
207
 
152
- const data = await response.json();
153
- if (!data.bots || data.bots.length === 0) {
154
- return 'Bu API key ile bot bulunamadı';
208
+ const trimmed = input.trim();
209
+ if (!trimmed.startsWith('nc_') && !trimmed.startsWith('nco_')) {
210
+ return 'API key nc_ veya nco_ ile başlamalı';
155
211
  }
156
212
 
157
- console.log(chalk.green(' API key doğrulandı\n'));
158
- return true;
159
- } catch (err) {
160
- return `API hatası: ${err.message}`;
161
- }
213
+ console.log(chalk.yellow('\n API key doğrulanıyor...'));
214
+ try {
215
+ const response = await fetch('https://api.natureco.me/api/v1/bots', {
216
+ headers: {
217
+ 'Authorization': `Bearer ${trimmed}`,
218
+ 'Content-Type': 'application/json',
219
+ },
220
+ });
221
+
222
+ if (!response.ok) {
223
+ return 'Geçersiz API key';
224
+ }
225
+
226
+ const data = await response.json();
227
+ if (!data.bots || data.bots.length === 0) {
228
+ return 'Bu API key ile bot bulunamadı';
229
+ }
230
+
231
+ console.log(chalk.green(' ✓ API key doğrulandı\n'));
232
+ return true;
233
+ } catch (err) {
234
+ return `API hatası: ${err.message}`;
235
+ }
236
+ },
162
237
  },
163
- },
164
- ]);
238
+ ]);
165
239
 
166
- naturecoApiKey = apiKey.trim();
240
+ naturecoApiKey = apiKey.trim();
241
+ }
167
242
  }
168
243
 
169
244
  // Bot seçimi (sadece NatureCo key varsa)
@@ -171,26 +246,127 @@ async function setup() {
171
246
  let selectedBotId = null;
172
247
 
173
248
  if (naturecoApiKey) {
174
- console.log(chalk.yellow('⏳ Botlar yükleniyor...\n'));
175
- try {
176
- const botList = await getBots(naturecoApiKey);
177
-
178
- if (botList && botList.bots && botList.bots.length > 0) {
249
+ // Kayıtlı bot varsa hatırlat
250
+ if (existingConfig.defaultBot && existingConfig.defaultBotId) {
251
+ process.stdin.resume();
252
+ const { useExistingBot } = await inquirer.prompt([
253
+ {
254
+ type: 'confirm',
255
+ name: 'useExistingBot',
256
+ message: `Kayıtlı bot bulundu: ${existingConfig.defaultBot}. Bunu kullanmak ister misiniz?`,
257
+ default: true,
258
+ },
259
+ ]);
260
+
261
+ if (useExistingBot) {
262
+ selectedBot = { name: existingConfig.defaultBot };
263
+ selectedBotId = existingConfig.defaultBotId;
264
+ }
265
+ }
266
+
267
+ if (!selectedBot) {
268
+ console.log(chalk.yellow('⏳ Botlar yükleniyor...\n'));
269
+ try {
270
+ const botList = await getBots(naturecoApiKey);
271
+
272
+ if (botList && botList.bots && botList.bots.length > 0) {
273
+ process.stdin.resume();
274
+ const { botId } = await inquirer.prompt([
275
+ {
276
+ type: 'list',
277
+ name: 'botId',
278
+ message: 'Varsayılan bot seçin:',
279
+ choices: botList.bots.map(b => ({ name: b.name, value: b.id })),
280
+ },
281
+ ]);
282
+
283
+ selectedBotId = botId;
284
+ selectedBot = botList.bots.find(b => b.id === botId);
285
+ }
286
+ } catch (err) {
287
+ console.log(chalk.yellow(`⚠️ Bot listesi alınamadı: ${err.message}\n`));
288
+ }
289
+ }
290
+ }
291
+
292
+ // Telegram entegrasyonu (NatureCo seçildiyse veya NatureCo key varsa)
293
+ let telegramToken = null;
294
+ let telegramUserId = null;
295
+
296
+ if (naturecoApiKey && selectedBotId) {
297
+ // Kayıtlı Telegram botu varsa hatırlat
298
+ if (existingConfig.telegramToken) {
299
+ process.stdin.resume();
300
+ const { useExistingTelegram } = await inquirer.prompt([
301
+ {
302
+ type: 'confirm',
303
+ name: 'useExistingTelegram',
304
+ message: 'Kayıtlı Telegram botu bulundu. Bunu kullanmak ister misiniz?',
305
+ default: true,
306
+ },
307
+ ]);
308
+
309
+ if (useExistingTelegram) {
310
+ telegramToken = existingConfig.telegramToken;
311
+ telegramUserId = existingConfig.telegramUserId;
312
+ }
313
+ }
314
+
315
+ if (!telegramToken) {
316
+ process.stdin.resume();
317
+ const { wantTelegram } = await inquirer.prompt([
318
+ {
319
+ type: 'confirm',
320
+ name: 'wantTelegram',
321
+ message: 'Telegram entegrasyonu eklemek ister misiniz?',
322
+ default: false,
323
+ },
324
+ ]);
325
+
326
+ if (wantTelegram) {
179
327
  process.stdin.resume();
180
- const { botId } = await inquirer.prompt([
328
+ const telegramAnswers = await inquirer.prompt([
329
+ {
330
+ type: 'input',
331
+ name: 'token',
332
+ message: 'Telegram bot token:',
333
+ validate: (val) => val.trim() !== '' || 'Token boş olamaz',
334
+ },
181
335
  {
182
- type: 'list',
183
- name: 'botId',
184
- message: 'Varsayılan bot seçin:',
185
- choices: botList.bots.map(b => ({ name: b.name, value: b.id })),
336
+ type: 'input',
337
+ name: 'userId',
338
+ message: 'Telegram kullanıcı ID\'niz (t.me/userinfobot ile öğrenebilirsiniz):',
339
+ validate: (val) => val.trim() !== '' || 'Kullanıcı ID boş olamaz',
186
340
  },
187
341
  ]);
188
342
 
189
- selectedBotId = botId;
190
- selectedBot = botList.bots.find(b => b.id === botId);
343
+ telegramToken = telegramAnswers.token.trim();
344
+ telegramUserId = telegramAnswers.userId.trim();
345
+
346
+ // Telegram'ı bağla
347
+ try {
348
+ const response = await fetch('https://api.natureco.me/api/agent/telegram/connect', {
349
+ method: 'POST',
350
+ headers: {
351
+ 'Content-Type': 'application/json',
352
+ 'Authorization': `Bearer ${naturecoApiKey}`,
353
+ },
354
+ body: JSON.stringify({
355
+ agent_id: selectedBotId,
356
+ telegram_bot_token: telegramToken,
357
+ telegram_user_id: telegramUserId,
358
+ }),
359
+ });
360
+
361
+ if (response.ok) {
362
+ console.log(chalk.green('\n✅ Telegram bağlantısı başarılı!\n'));
363
+ } else {
364
+ console.log(chalk.yellow('\n⚠️ Telegram bağlantısı kurulamadı\n'));
365
+ }
366
+ } catch (err) {
367
+ console.log(chalk.yellow(`\n⚠️ Telegram bağlantı hatası: ${err.message}\n`));
368
+ }
191
369
  }
192
- } catch (err) {
193
- console.log(chalk.yellow(`⚠️ Bot listesi alınamadı: ${err.message}\n`));
194
370
  }
195
371
  }
196
372
 
@@ -216,6 +392,11 @@ async function setup() {
216
392
  config.defaultBotId = selectedBotId;
217
393
  }
218
394
 
395
+ if (telegramToken) {
396
+ config.telegramToken = telegramToken;
397
+ config.telegramUserId = telegramUserId;
398
+ }
399
+
219
400
  saveConfig(config);
220
401
 
221
402
  // Kurulum tamamlandı
@@ -228,6 +409,10 @@ async function setup() {
228
409
  if (selectedBot) {
229
410
  console.log(chalk.cyan('Varsayılan Bot:'), chalk.white(selectedBot.name));
230
411
  }
412
+
413
+ if (telegramToken) {
414
+ console.log(chalk.cyan('Telegram:'), chalk.green('✓ Bağlı'));
415
+ }
231
416
 
232
417
  console.log(chalk.cyan('Config:'), chalk.white(CONFIG_FILE));
233
418
  console.log('');