natureco-cli 5.20.3 → 5.21.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 +779 -750
- package/README.md +608 -608
- package/bin/natureco.js +1099 -1095
- package/package.json +95 -94
- package/scripts/generate-qr.js +21 -0
- package/scripts/import-curated-skills-log.json +5 -0
- package/scripts/import-curated-skills.js +262 -0
- package/scripts/import-skills-log.json +167 -0
- package/scripts/import-skills.js +261 -0
- package/scripts/postinstall.js +125 -0
- package/src/commands/agent.js +280 -280
- package/src/commands/ask.js +4 -2
- package/src/commands/naturehub.js +206 -282
- package/src/commands/repl.js +1594 -1580
- package/src/providers/mem0-memory.js +121 -121
- package/src/providers/supermemory-memory.js +117 -117
- package/src/tools/llm_task.js +150 -150
- package/src/tools/mac_alarm.js +199 -199
- package/src/tools/workflow.js +424 -424
- package/src/utils/api.js +1211 -1188
- package/src/utils/cost-tracker.js +361 -360
- package/src/utils/inquirer-wrapper.js +43 -31
- package/src/utils/paste-safe-input.js +346 -334
- package/src/utils/process-errors.js +129 -115
- package/src/utils/provider-detect.js +76 -72
- package/src/utils/skills.js +1 -1
- package/src/utils/system-prompt.js +136 -136
- package/src/utils/tools.js +324 -324
- package/README.md.bak +0 -565
- package/src/tools/http.js +0 -78
|
@@ -1,282 +1,206 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* natureco naturehub — NatureCo
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* natureco naturehub
|
|
7
|
-
* natureco naturehub
|
|
8
|
-
* natureco naturehub
|
|
9
|
-
* natureco naturehub
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
...
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
res.on('
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
req.on('
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
console.log(chalk.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.log(chalk.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
console.log(chalk.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
console.log(`
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
console.log(` ${chalk.bold('
|
|
168
|
-
console.log(` ${chalk.bold('
|
|
169
|
-
console.log(` ${chalk.bold('
|
|
170
|
-
console.log(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
console.log(chalk.
|
|
181
|
-
console.log(chalk.gray('
|
|
182
|
-
console.log(chalk.gray('
|
|
183
|
-
console.log(chalk.gray('
|
|
184
|
-
console.log(chalk.gray('
|
|
185
|
-
console.log(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
console.log(chalk.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
token,
|
|
208
|
-
body: { content, type: 'text', tags: [], mood: '🌿' },
|
|
209
|
-
});
|
|
210
|
-
console.log(chalk.green(' ✓ Robot House\'a gönderildi!\n'));
|
|
211
|
-
if (result.post?.id) console.log(chalk.gray(` ID: ${result.post.id}\n`));
|
|
212
|
-
audit.log(audit.ACTIONS.INFO, { source: 'naturehub', action: 'robot-house' });
|
|
213
|
-
} catch (e) {
|
|
214
|
-
console.log(chalk.red(` ✗ Hata: ${e.message}\n`));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
async function cmdForum(args) {
|
|
219
|
-
const text = args.join(' ').trim();
|
|
220
|
-
const titleMatch = text.match(/^"([^"]+)"\s*(.*)$/);
|
|
221
|
-
let title, content;
|
|
222
|
-
|
|
223
|
-
if (titleMatch) {
|
|
224
|
-
title = titleMatch[1].trim();
|
|
225
|
-
content = titleMatch[2].trim();
|
|
226
|
-
} else {
|
|
227
|
-
const parts = text.split(/\s+/);
|
|
228
|
-
title = parts[0];
|
|
229
|
-
content = parts.slice(1).join(' ');
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (!title || !content) {
|
|
233
|
-
console.log(chalk.red('\n Kullanım: natureco naturehub forum "<başlık>" <içerik>\n'));
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const token = getApiKey();
|
|
238
|
-
if (!token) {
|
|
239
|
-
console.log(chalk.yellow('\n ⚠️ API key tanımlı değil. Önce `natureco login` ile giriş yapın.\n'));
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
console.log(chalk.cyan('\n 📤 Forum\'a gönderiliyor...\n'));
|
|
244
|
-
console.log(chalk.gray(` Başlık: ${title}\n`));
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
const result = await apiCall('/forum', {
|
|
248
|
-
method: 'POST',
|
|
249
|
-
token,
|
|
250
|
-
body: { title, content },
|
|
251
|
-
});
|
|
252
|
-
console.log(chalk.green(' ✓ Forum\'a gönderildi!\n'));
|
|
253
|
-
if (result.post?.id) console.log(chalk.gray(` ID: ${result.post.id}\n`));
|
|
254
|
-
audit.log(audit.ACTIONS.INFO, { source: 'naturehub', action: 'forum' });
|
|
255
|
-
} catch (e) {
|
|
256
|
-
console.log(chalk.red(` ✗ Hata: ${e.message}\n`));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
async function naturehub(args) {
|
|
261
|
-
const [action, ...params] = args || [];
|
|
262
|
-
if (!action || action === 'help') {
|
|
263
|
-
console.log(chalk.yellow('\n Kullanım:'));
|
|
264
|
-
console.log(chalk.gray(' natureco naturehub post "<mesaj>" Bota mesaj gönder'));
|
|
265
|
-
console.log(chalk.gray(' natureco naturehub robot-house "<içerik>" Robot House gönderisi'));
|
|
266
|
-
console.log(chalk.gray(' natureco naturehub forum "<başlık>" <içerik> Forum gönderisi'));
|
|
267
|
-
console.log(chalk.gray(' natureco naturehub list Botları listele'));
|
|
268
|
-
console.log(chalk.gray(' natureco naturehub info [bot_id] Bot detayı'));
|
|
269
|
-
console.log(chalk.gray(' natureco naturehub config Ayarlar'));
|
|
270
|
-
console.log('');
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (action === 'post') return cmdPost(params);
|
|
274
|
-
if (action === 'robot-house' || action === 'robot_house' || action === 'robothouse') return cmdRobotHouse(params);
|
|
275
|
-
if (action === 'forum') return cmdForum(params);
|
|
276
|
-
if (action === 'list') return cmdList();
|
|
277
|
-
if (action === 'info') return cmdInfo(params[0]);
|
|
278
|
-
if (action === 'config') return cmdConfig();
|
|
279
|
-
console.log(chalk.red(`\n Bilinmeyen action: ${action}\n`));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
module.exports = naturehub;
|
|
1
|
+
/**
|
|
2
|
+
* natureco naturehub — NatureCo Bot API iletişimi
|
|
3
|
+
*
|
|
4
|
+
* natureco.me/api/v1/bots endpoint'lerini kullanır.
|
|
5
|
+
* Kullanım:
|
|
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
|
+
*
|
|
11
|
+
* API: https://natureco.me/api/v1/bots
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const chalk = require('chalk');
|
|
15
|
+
const https = require('https');
|
|
16
|
+
const { URL } = require('url');
|
|
17
|
+
const audit = require('../utils/audit');
|
|
18
|
+
|
|
19
|
+
const API_BASE = 'https://api.natureco.me';
|
|
20
|
+
const API_PREFIX = '/api/v1';
|
|
21
|
+
const CONFIG_KEY = 'naturehub';
|
|
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
|
+
|
|
39
|
+
async function apiCall(path, options = {}) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const url = new URL(API_PREFIX + path, API_BASE);
|
|
42
|
+
const reqOptions = {
|
|
43
|
+
hostname: url.hostname,
|
|
44
|
+
path: url.pathname + url.search,
|
|
45
|
+
method: options.method || 'GET',
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
'User-Agent': 'natureco-cli/5.20',
|
|
49
|
+
...(options.token ? { 'Authorization': `Bearer ${options.token}` } : {}),
|
|
50
|
+
...options.headers,
|
|
51
|
+
},
|
|
52
|
+
timeout: 10000,
|
|
53
|
+
};
|
|
54
|
+
const req = https.request(reqOptions, (res) => {
|
|
55
|
+
let data = '';
|
|
56
|
+
res.on('data', (chunk) => data += chunk);
|
|
57
|
+
res.on('end', () => {
|
|
58
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
59
|
+
try { resolve(JSON.parse(data)); } catch { resolve(data); }
|
|
60
|
+
} else {
|
|
61
|
+
reject(new Error(`HTTP ${res.statusCode}: ${data.slice(0, 200)}`));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
req.on('error', reject);
|
|
66
|
+
req.on('timeout', () => { req.destroy(); reject(new Error('Timeout')); });
|
|
67
|
+
if (options.body) req.write(JSON.stringify(options.body));
|
|
68
|
+
req.end();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function cmdPost(args) {
|
|
73
|
+
const text = args.join(' ').trim();
|
|
74
|
+
if (!text) {
|
|
75
|
+
console.log(chalk.red('\n Kullanım: natureco naturehub post "<mesaj>"\n'));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const token = getApiKey();
|
|
80
|
+
if (!token) {
|
|
81
|
+
console.log(chalk.yellow('\n ⚠️ API key tanımlı değil. Önce `natureco login` ile giriş yapın.\n'));
|
|
82
|
+
saveLocal(text);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
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
|
+
|
|
97
|
+
try {
|
|
98
|
+
const result = await apiCall(`/bots/${botId}/messages`, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
token,
|
|
101
|
+
body: { message: text, user_id: 'cli' },
|
|
102
|
+
});
|
|
103
|
+
console.log(chalk.green(' ✓ Gönderildi!\n'));
|
|
104
|
+
if (result.reply) console.log(chalk.cyan(` 💬 Bot: ${result.reply}\n`));
|
|
105
|
+
audit.log(audit.ACTIONS.INFO, { source: 'naturehub', action: 'post', botId });
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.log(chalk.red(` ✗ Hata: ${e.message}\n`));
|
|
108
|
+
saveLocal(text);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function saveLocal(text) {
|
|
113
|
+
const fs = require('fs');
|
|
114
|
+
const path = require('path');
|
|
115
|
+
const os = require('os');
|
|
116
|
+
const file = path.join(os.homedir(), '.natureco', 'naturehub-pending.jsonl');
|
|
117
|
+
const dir = path.dirname(file);
|
|
118
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
119
|
+
fs.appendFileSync(file, JSON.stringify({ ts: new Date().toISOString(), text }) + '\n');
|
|
120
|
+
console.log(chalk.gray(` Kayıt: ${file}\n`));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function cmdList() {
|
|
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
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
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
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function cmdConfig() {
|
|
177
|
+
const { getConfig } = require('../utils/config');
|
|
178
|
+
const cfg = getConfig();
|
|
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'));
|
|
185
|
+
console.log('');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function naturehub(args) {
|
|
189
|
+
const [action, ...params] = args || [];
|
|
190
|
+
if (!action || action === 'help') {
|
|
191
|
+
console.log(chalk.yellow('\n Kullanım:'));
|
|
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'));
|
|
196
|
+
console.log('');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (action === 'post') return cmdPost(params);
|
|
200
|
+
if (action === 'list') return cmdList();
|
|
201
|
+
if (action === 'info') return cmdInfo(params[0]);
|
|
202
|
+
if (action === 'config') return cmdConfig();
|
|
203
|
+
console.log(chalk.red(`\n Bilinmeyen action: ${action}\n`));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
module.exports = naturehub;
|