natureco-cli 5.20.0 → 5.20.1
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 +1 -1
- package/src/commands/help.js +3 -1
- package/src/commands/naturehub.js +105 -55
- package/src/commands/repl.js +1 -1
- package/src/tools/workflow.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.20.
|
|
3
|
+
"version": "5.20.1",
|
|
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"
|
package/src/commands/help.js
CHANGED
|
@@ -98,7 +98,9 @@ function help() {
|
|
|
98
98
|
icon: '🌿',
|
|
99
99
|
title: 'NatureCo Native',
|
|
100
100
|
rows: [
|
|
101
|
-
{ name: 'natureco naturehub post "<text>"', desc: '
|
|
101
|
+
{ name: 'natureco naturehub post "<text>"', desc: 'NatureCo API ile bota mesaj gönder' },
|
|
102
|
+
{ name: 'natureco naturehub list', desc: 'Botlarını listele' },
|
|
103
|
+
{ name: 'natureco naturehub info [bot_id]', desc: 'Bot detayı' },
|
|
102
104
|
{ name: 'natureco medium draft <file.md>', desc: 'Medium makale taslağı' },
|
|
103
105
|
{ name: 'natureco medium publish <file.md>', desc: 'Medium\'da yayınla' },
|
|
104
106
|
{ name: 'natureco seo audit <url>', desc: 'SEO denetimi (skor 0-100)' },
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* natureco naturehub —
|
|
2
|
+
* natureco naturehub — NatureCo Bot API iletişimi
|
|
3
3
|
*
|
|
4
|
-
* natureco.me
|
|
4
|
+
* natureco.me/api/v1/bots endpoint'lerini kullanır.
|
|
5
5
|
* Kullanım:
|
|
6
|
-
* natureco naturehub post <text>
|
|
7
|
-
* natureco naturehub list
|
|
8
|
-
* natureco naturehub
|
|
9
|
-
* natureco naturehub config
|
|
6
|
+
* natureco naturehub post <text> Bota mesaj gönder
|
|
7
|
+
* natureco naturehub list Botları listele
|
|
8
|
+
* natureco naturehub info [bot_id] Bot detayı
|
|
9
|
+
* natureco naturehub config Ayarları göster
|
|
10
10
|
*
|
|
11
|
-
* API
|
|
11
|
+
* API: https://natureco.me/api/v1/bots
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
const chalk = require('chalk');
|
|
@@ -17,20 +17,35 @@ const { URL } = require('url');
|
|
|
17
17
|
const audit = require('../utils/audit');
|
|
18
18
|
|
|
19
19
|
const API_BASE = 'https://api.natureco.me';
|
|
20
|
+
const API_PREFIX = '/api/v1';
|
|
20
21
|
const CONFIG_KEY = 'naturehub';
|
|
21
22
|
|
|
23
|
+
function getApiKey() {
|
|
24
|
+
try {
|
|
25
|
+
const { getConfig } = require('../utils/config');
|
|
26
|
+
const cfg = getConfig();
|
|
27
|
+
return cfg?.apiKey || null;
|
|
28
|
+
} catch { return null; }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getBotId() {
|
|
32
|
+
try {
|
|
33
|
+
const { getConfig } = require('../utils/config');
|
|
34
|
+
const cfg = getConfig();
|
|
35
|
+
return cfg?.naturecoBotId || null;
|
|
36
|
+
} catch { return null; }
|
|
37
|
+
}
|
|
38
|
+
|
|
22
39
|
async function apiCall(path, options = {}) {
|
|
23
|
-
// Geliştirme aşamasında placeholder — gerçek API hazır olunca kullanılacak
|
|
24
|
-
// Şimdilik simüle edelim ve kullanıcıya rehberlik edelim
|
|
25
40
|
return new Promise((resolve, reject) => {
|
|
26
|
-
const url = new URL(path, API_BASE);
|
|
41
|
+
const url = new URL(API_PREFIX + path, API_BASE);
|
|
27
42
|
const reqOptions = {
|
|
28
43
|
hostname: url.hostname,
|
|
29
44
|
path: url.pathname + url.search,
|
|
30
45
|
method: options.method || 'GET',
|
|
31
46
|
headers: {
|
|
32
47
|
'Content-Type': 'application/json',
|
|
33
|
-
'User-Agent': 'natureco-cli/
|
|
48
|
+
'User-Agent': 'natureco-cli/5.20',
|
|
34
49
|
...(options.token ? { 'Authorization': `Bearer ${options.token}` } : {}),
|
|
35
50
|
...options.headers,
|
|
36
51
|
},
|
|
@@ -54,51 +69,43 @@ async function apiCall(path, options = {}) {
|
|
|
54
69
|
});
|
|
55
70
|
}
|
|
56
71
|
|
|
57
|
-
async function getToken() {
|
|
58
|
-
const { getConfig } = require('../utils/config');
|
|
59
|
-
const cfg = getConfig();
|
|
60
|
-
return cfg?.naturehubToken || cfg?.apiKey || null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
72
|
async function cmdPost(args) {
|
|
64
73
|
const text = args.join(' ').trim();
|
|
65
74
|
if (!text) {
|
|
66
75
|
console.log(chalk.red('\n Kullanım: natureco naturehub post "<mesaj>"\n'));
|
|
67
76
|
return;
|
|
68
77
|
}
|
|
69
|
-
if (text.length > 500) {
|
|
70
|
-
console.log(chalk.yellow('\n ⚠️ Mesaj 500 karakteri aşıyor. Kısaltılacak.\n'));
|
|
71
|
-
}
|
|
72
|
-
const shortText = text.slice(0, 500);
|
|
73
|
-
|
|
74
|
-
console.log(chalk.cyan('\n 📤 Nature Hub\'a gönderiliyor...\n'));
|
|
75
|
-
console.log(chalk.gray(` "${shortText}"\n`));
|
|
76
78
|
|
|
77
|
-
const token =
|
|
79
|
+
const token = getApiKey();
|
|
78
80
|
if (!token) {
|
|
79
|
-
console.log(chalk.yellow(' ⚠️
|
|
80
|
-
|
|
81
|
-
console.log(chalk.gray(' Veya genel API key: ') + chalk.cyan('natureco login'));
|
|
82
|
-
console.log('');
|
|
83
|
-
console.log(chalk.gray(' Şimdilik yerel olarak kaydedildi.\n'));
|
|
84
|
-
saveLocal(shortText);
|
|
85
|
-
audit.log(audit.ACTIONS.INFO, { source: 'naturehub', action: 'post', local: true });
|
|
81
|
+
console.log(chalk.yellow('\n ⚠️ API key tanımlı değil. Önce `natureco login` ile giriş yapın.\n'));
|
|
82
|
+
saveLocal(text);
|
|
86
83
|
return;
|
|
87
84
|
}
|
|
88
85
|
|
|
86
|
+
const botId = getBotId();
|
|
87
|
+
if (!botId) {
|
|
88
|
+
console.log(chalk.yellow('\n ⚠️ Bot ID tanımlı değil. `natureco naturehub list` ile botlarınızı görün.\n'));
|
|
89
|
+
console.log(chalk.gray(' Ayarlamak için: natureco config set naturecoBotId <bot_id>\n'));
|
|
90
|
+
saveLocal(text);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log(chalk.cyan(`\n 📤 Bota mesaj gönderiliyor (${botId})...\n`));
|
|
95
|
+
console.log(chalk.gray(` "${text.slice(0, 200)}"\n`));
|
|
96
|
+
|
|
89
97
|
try {
|
|
90
|
-
const result = await apiCall(
|
|
98
|
+
const result = await apiCall(`/bots/${botId}/messages`, {
|
|
91
99
|
method: 'POST',
|
|
92
100
|
token,
|
|
93
|
-
body: {
|
|
101
|
+
body: { message: text, user_id: 'cli' },
|
|
94
102
|
});
|
|
95
103
|
console.log(chalk.green(' ✓ Gönderildi!\n'));
|
|
96
|
-
if (result.
|
|
97
|
-
audit.log(audit.ACTIONS.INFO, { source: 'naturehub', action: 'post',
|
|
104
|
+
if (result.reply) console.log(chalk.cyan(` 💬 Bot: ${result.reply}\n`));
|
|
105
|
+
audit.log(audit.ACTIONS.INFO, { source: 'naturehub', action: 'post', botId });
|
|
98
106
|
} catch (e) {
|
|
99
|
-
console.log(chalk.
|
|
100
|
-
|
|
101
|
-
saveLocal(shortText);
|
|
107
|
+
console.log(chalk.red(` ✗ Hata: ${e.message}\n`));
|
|
108
|
+
saveLocal(text);
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -114,24 +121,67 @@ function saveLocal(text) {
|
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
async function cmdList() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
const token = getApiKey();
|
|
125
|
+
if (!token) {
|
|
126
|
+
console.log(chalk.yellow('\n ⚠️ API key tanımlı değil.\n'));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log(chalk.cyan('\n 🤖 Botlarınız\n'));
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const result = await apiCall('/bots', { method: 'GET', token });
|
|
134
|
+
const bots = Array.isArray(result) ? result : (result.bots || result.data || []);
|
|
135
|
+
if (bots.length === 0) {
|
|
136
|
+
console.log(chalk.gray(' Henüz botunuz yok.\n'));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
for (const b of bots) {
|
|
140
|
+
console.log(` ${chalk.cyan('●')} ${b.name || b.id} ${chalk.gray(`(${b.id})`)}`);
|
|
141
|
+
if (b.description) console.log(` ${chalk.gray(b.description)}`);
|
|
142
|
+
console.log('');
|
|
143
|
+
}
|
|
144
|
+
console.log(chalk.gray(' Bot ID ayarlamak için: natureco config set naturecoBotId <id>\n'));
|
|
145
|
+
} catch (e) {
|
|
146
|
+
console.log(chalk.red(` ✗ Hata: ${e.message}\n`));
|
|
147
|
+
}
|
|
121
148
|
}
|
|
122
149
|
|
|
123
|
-
async function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
async function cmdInfo(botId) {
|
|
151
|
+
const token = getApiKey();
|
|
152
|
+
if (!token) {
|
|
153
|
+
console.log(chalk.yellow('\n ⚠️ API key tanımlı değil.\n'));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const id = botId || getBotId();
|
|
158
|
+
if (!id) {
|
|
159
|
+
console.log(chalk.yellow('\n Bot ID gerekli: natureco naturehub info <bot_id>\n'));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
console.log(chalk.cyan(`\n 🤖 Bot: ${id}\n`));
|
|
164
|
+
try {
|
|
165
|
+
const result = await apiCall(`/bots/${id}`, { method: 'GET', token });
|
|
166
|
+
console.log(` ${chalk.bold('ID:')} ${result.id}`);
|
|
167
|
+
console.log(` ${chalk.bold('İsim:')} ${result.name || '-'}`);
|
|
168
|
+
console.log(` ${chalk.bold('Açıklama:')} ${result.description || '-'}`);
|
|
169
|
+
console.log(` ${chalk.bold('Durum:')} ${result.status || 'active'}`);
|
|
170
|
+
console.log('');
|
|
171
|
+
} catch (e) {
|
|
172
|
+
console.log(chalk.red(` ✗ Hata: ${e.message}\n`));
|
|
173
|
+
}
|
|
127
174
|
}
|
|
128
175
|
|
|
129
176
|
async function cmdConfig() {
|
|
130
177
|
const { getConfig } = require('../utils/config');
|
|
131
178
|
const cfg = getConfig();
|
|
132
|
-
console.log(chalk.cyan('\n ⚙️
|
|
133
|
-
console.log(chalk.gray('
|
|
134
|
-
console.log(chalk.gray('
|
|
179
|
+
console.log(chalk.cyan('\n ⚙️ NatureCo API Ayarları\n'));
|
|
180
|
+
console.log(chalk.gray(' API Key: ') + (cfg.apiKey ? chalk.green('✓ ayarlı') : chalk.yellow('yok')));
|
|
181
|
+
console.log(chalk.gray(' Bot ID: ') + (cfg.naturecoBotId ? chalk.green(cfg.naturecoBotId) : chalk.yellow('ayarlanmamış')));
|
|
182
|
+
console.log(chalk.gray('\n Giriş: ') + chalk.cyan('natureco login'));
|
|
183
|
+
console.log(chalk.gray(' Bot ID: ') + chalk.cyan('natureco config set naturecoBotId <id>'));
|
|
184
|
+
console.log(chalk.gray(' Botlar: ') + chalk.cyan('natureco naturehub list'));
|
|
135
185
|
console.log('');
|
|
136
186
|
}
|
|
137
187
|
|
|
@@ -139,16 +189,16 @@ async function naturehub(args) {
|
|
|
139
189
|
const [action, ...params] = args || [];
|
|
140
190
|
if (!action || action === 'help') {
|
|
141
191
|
console.log(chalk.yellow('\n Kullanım:'));
|
|
142
|
-
console.log(chalk.gray(' natureco naturehub post <
|
|
143
|
-
console.log(chalk.gray(' natureco naturehub list
|
|
144
|
-
console.log(chalk.gray(' natureco naturehub
|
|
145
|
-
console.log(chalk.gray(' natureco naturehub config
|
|
192
|
+
console.log(chalk.gray(' natureco naturehub post "<mesaj>" Bota mesaj gönder'));
|
|
193
|
+
console.log(chalk.gray(' natureco naturehub list Botları listele'));
|
|
194
|
+
console.log(chalk.gray(' natureco naturehub info [bot_id] Bot detayı'));
|
|
195
|
+
console.log(chalk.gray(' natureco naturehub config Ayarlar'));
|
|
146
196
|
console.log('');
|
|
147
197
|
return;
|
|
148
198
|
}
|
|
149
199
|
if (action === 'post') return cmdPost(params);
|
|
150
200
|
if (action === 'list') return cmdList();
|
|
151
|
-
if (action === '
|
|
201
|
+
if (action === 'info') return cmdInfo(params[0]);
|
|
152
202
|
if (action === 'config') return cmdConfig();
|
|
153
203
|
console.log(chalk.red(`\n Bilinmeyen action: ${action}\n`));
|
|
154
204
|
}
|
package/src/commands/repl.js
CHANGED
|
@@ -118,7 +118,7 @@ const CLI_COMMANDS = {
|
|
|
118
118
|
'/models': { desc: 'Modeller', run: ['models', 'list'] },
|
|
119
119
|
'/memory-ls': { desc: 'Memory dosyaları', run: ['memory', 'list'] },
|
|
120
120
|
'/seo': { desc: 'SEO denetimi (URL gerek)', needsArg: true, run: ['seo', 'audit'] },
|
|
121
|
-
'/naturehub': { desc: '
|
|
121
|
+
'/naturehub': { desc: 'Bota mesaj gönder (text gerek)', needsArg: true, run: ['naturehub', 'post'] },
|
|
122
122
|
'/dashboard': { desc: 'Web dashboard başlat (port 7421)', run: ['dashboard', 'start'] },
|
|
123
123
|
};
|
|
124
124
|
|
package/src/tools/workflow.js
CHANGED
|
@@ -177,7 +177,12 @@ async function workflow(params) {
|
|
|
177
177
|
plan = JSON.parse(jsonStr);
|
|
178
178
|
if (!plan.steps || !Array.isArray(plan.steps)) throw new Error('Steps bulunamadi');
|
|
179
179
|
} catch (e) {
|
|
180
|
-
|
|
180
|
+
// JSON parse hatasi — modelin ham ciktisini passthrough chat olarak goster
|
|
181
|
+
const rawReply = planResult.choices?.[0]?.message?.content || '';
|
|
182
|
+
if (rawReply) {
|
|
183
|
+
return { success: true, workflowId: 'passthrough', name: 'Direct Chat', status: 'completed', totalSteps: 0, completedSteps: 0, results: [{ step: 0, tool: 'chat', status: 'done', result: { reply: rawReply } }], passthrough: true, reply: rawReply };
|
|
184
|
+
}
|
|
185
|
+
return { success: false, error: 'Plan cozumlenemedi: ' + e.message, raw: rawReply.slice(0, 500) };
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
// Save plan
|