natureco-cli 5.6.12 → 5.6.14

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": "5.6.12",
3
+ "version": "5.6.14",
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"
@@ -1,241 +1,242 @@
1
- const chalk = require('chalk');
2
- const F = require('../utils/format');
3
- const fs = require('fs');
4
- const path = require('path');
5
- const os = require('os');
6
- const inquirer = require('../utils/inquirer-wrapper');
7
- const { getConfig, saveConfig } = require('../utils/config');
8
- const { getBots } = require('../utils/api');
9
-
10
- const BINDINGS_FILE = path.join(os.homedir(), '.natureco', 'agent-bindings.json');
11
- const IDENTITIES_FILE = path.join(os.homedir(), '.natureco', 'agent-identities.json');
12
-
13
- function loadBindings() {
14
- try {
15
- if (fs.existsSync(BINDINGS_FILE)) return JSON.parse(fs.readFileSync(BINDINGS_FILE, 'utf8'));
16
- } catch {}
17
- return {};
18
- }
19
-
20
- function saveBindings(data) {
21
- fs.mkdirSync(path.dirname(BINDINGS_FILE), { recursive: true });
22
- fs.writeFileSync(BINDINGS_FILE, JSON.stringify(data, null, 2));
23
- }
24
-
25
- function loadIdentities() {
26
- try {
27
- if (fs.existsSync(IDENTITIES_FILE)) return JSON.parse(fs.readFileSync(IDENTITIES_FILE, 'utf8'));
28
- } catch {}
29
- return {};
30
- }
31
-
32
- function saveIdentities(data) {
33
- fs.mkdirSync(path.dirname(IDENTITIES_FILE), { recursive: true });
34
- fs.writeFileSync(IDENTITIES_FILE, JSON.stringify(data, null, 2));
35
- }
36
-
37
- async function agents(args) {
38
- const [action, ...params] = (args || []);
39
-
40
- if (!action || action === 'list') return listAgents();
41
- if (action === 'set') return setActiveAgent(params[0]);
42
- if (action === 'info') return agentInfo(params[0]);
43
- if (action === 'add') return addAgent();
44
- if (action === 'bindings') return listBindings();
45
- if (action === 'bind') return bindAgent(params[0], params[1]);
46
- if (action === 'unbind') return unbindAgent(params[0], params[1]);
47
- if (action === 'set-identity') return setIdentity(params[0], params.slice(1).join(' '));
48
-
49
- console.log(chalk.red(`\n ❌ Bilinmeyen komut: ${action}\n`));
50
- console.log(chalk.gray(' Kullanım: natureco agents [list|set|info|add|bindings|bind|unbind|set-identity]\n'));
51
- process.exit(1);
52
- }
53
-
54
- async function listAgents() {
55
- const config = getConfig();
56
- const apiKey = config.providerApiKey || config.apiKey || '';
57
-
58
- F.info('Agentlar yükleniyor...');
59
-
60
- let botList = { bots: [] };
61
- try {
62
- botList = await getBots(apiKey);
63
- } catch {}
64
-
65
- console.log('\n' + tui.styled(' 🤖 Agents', { color: tui.PALETTE.primary, bold: true }));
66
- console.log(tui.styled(' ' + '─'.repeat(56), { color: tui.PALETTE.border }));
67
-
68
- if (!botList.bots?.length) {
69
- console.log('\n ' + tui.C.muted('Agent bulunamadı.'));
70
- console.log(' ' + tui.C.muted('Oluşturmak için: ') + tui.C.brand('developers.natureco.me'));
71
- console.log('');
72
- return;
73
- }
74
-
75
- const rows = botList.bots.map(bot => ({
76
- name: bot.name + (config.botName === bot.name ? ' ●' : ''),
77
- id: bot.id,
78
- provider: bot.ai_provider || 'groq',
79
- model: bot.model || '',
80
- active: config.botName === bot.name,
81
- }));
82
-
83
- console.log('\n' + tui.table(rows, [
84
- {
85
- key: 'name', label: 'İsim', minWidth: 18,
86
- render: r => r.active
87
- ? tui.styled(r.name, { color: tui.PALETTE.success, bold: true })
88
- : tui.C.text(r.name)
89
- },
90
- { key: 'id', label: 'ID', minWidth: 16, render: r => tui.C.muted(r.id) },
91
- { key: 'provider', label: 'Provider', minWidth: 12, render: r => tui.C.text(r.provider) },
92
- { key: 'model', label: 'Model', minWidth: 18, render: r => tui.C.muted(r.model) },
93
- ], { borderStyle: 'round', zebra: true }));
94
-
95
- console.log('\n ' + tui.C.muted('Değiştirmek için: ') + tui.C.brand('natureco agents set <bot-adı>'));
96
- console.log('');
97
- }
98
-
99
- async function setActiveAgent(botName) {
100
- const config = getConfig();
101
- const apiKey = config.providerApiKey || config.apiKey || '';
102
-
103
- let botList = { bots: [] };
104
- try {
105
- botList = await getBots(apiKey);
106
- } catch {}
107
-
108
- if (!botName) {
109
- if (!botList.bots?.length) {
110
- console.log(chalk.gray('\n Agent bulunamadı.\n'));
111
- return;
112
- }
113
- const { selected } = await inquirer.prompt([{
114
- type: 'list',
115
- name: 'selected',
116
- message: ' Aktif agent seç:',
117
- choices: botList.bots.map(b => ({ name: b.name, value: b.name })),
118
- }]);
119
- botName = selected;
120
- }
121
-
122
- const bot = botList.bots?.find(b => b.name === botName || b.id === botName);
123
- if (!bot && botList.bots?.length) {
124
- console.log(chalk.red(`\n Agent bulunamadı: ${botName}\n`));
125
- process.exit(1);
126
- }
127
-
128
- config.botName = botName;
129
- if (bot?.id) config.defaultBotId = bot.id;
130
- saveConfig(config);
131
-
132
- console.log(chalk.green(`\n ✓ Aktif agent: ${botName}\n`));
133
- }
134
-
135
- async function agentInfo(botName) {
136
- const config = getConfig();
137
- const apiKey = config.providerApiKey || config.apiKey || '';
138
- const name = botName || config.botName;
139
-
140
- if (!name) {
141
- F.error('Agent adı belirtin: natureco agents info <bot-adı>');
142
- return;
143
- }
144
-
145
- let botList = { bots: [] };
146
- try {
147
- botList = await getBots(apiKey);
148
- } catch {}
149
-
150
- const bot = botList.bots?.find(b => b.name === name || b.id === name);
151
-
152
- F.header('Agent: ' + name);
153
-
154
- if (bot) {
155
- F.kv('ID', bot.id);
156
- F.kv('Provider', bot.ai_provider || 'groq');
157
- if (bot.model) F.kv('Model', bot.model);
158
- if (bot.system_prompt) {
159
- F.kv('Prompt', bot.system_prompt.slice(0, 80) + (bot.system_prompt.length > 80 ? '...' : ''));
160
- }
161
- } else {
162
- F.meta('(Detay alınamadı)');
163
- }
164
-
165
- try {
166
- const { loadMemory } = require('../utils/memory');
167
- const mem = loadMemory(bot?.id || 'universal-provider');
168
- if (mem.name || mem.facts?.length) {
169
- if (mem.name) F.kv('Kullanıcı', mem.name);
170
- F.kv('Hafıza', (mem.facts || []).length + ' bilgi');
171
- }
172
- } catch {}
173
- }
174
-
175
- async function addAgent() {
176
- console.log('');
177
- console.log(chalk.gray(' Yeni agent oluşturmak için Developers Portal\'ı kullanın:'));
178
- console.log(chalk.cyan(' developers.natureco.me\n'));
179
- console.log(chalk.gray(' Oluşturduktan sonra: ') + chalk.cyan('natureco agents list\n'));
180
- }
181
-
182
- // ── Bindings ──────────────────────────────────────────────────────────────────
183
-
184
- function listBindings() {
185
- const bindings = loadBindings();
186
- const keys = Object.keys(bindings);
187
-
188
- F.section('Bindings (' + keys.length + ')');
189
-
190
- if (keys.length === 0) {
191
- F.meta('Henüz binding yok.');
192
- return;
193
- }
194
-
195
- const items = [];
196
- keys.forEach(agentId => {
197
- bindings[agentId].forEach(ch => items.push(agentId + ' → ' + ch));
198
- });
199
- F.list(items);
200
- }
201
-
202
- function bindAgent(agentId, channel) {
203
- if (!agentId || !channel) {
204
- F.error('Kullanım: natureco agents bind <agentId> <channel>');
205
- return;
206
- }
207
- const bindings = loadBindings();
208
- if (!bindings[agentId]) bindings[agentId] = [];
209
- if (!bindings[agentId].includes(channel)) bindings[agentId].push(channel);
210
- saveBindings(bindings);
211
- F.success('Agent ' + agentId + ' → ' + channel + ' bağlandı');
212
- }
213
-
214
- function unbindAgent(agentId, channel) {
215
- if (!agentId || !channel) {
216
- F.error('Kullanım: natureco agents unbind <agentId> <channel>');
217
- return;
218
- }
219
- const bindings = loadBindings();
220
- if (!bindings[agentId]) {
221
- F.warning('Agent ' + agentId + ' için binding bulunamadı');
222
- return;
223
- }
224
- bindings[agentId] = bindings[agentId].filter(ch => ch !== channel);
225
- if (bindings[agentId].length === 0) delete bindings[agentId];
226
- saveBindings(bindings);
227
- F.success('Agent ' + agentId + ' → ' + channel + ' bağlantısı kaldırıldı');
228
- }
229
-
230
- function setIdentity(agentId, identity) {
231
- if (!agentId) {
232
- F.error('Kullanım: natureco agents set-identity <agentId> <identity>');
233
- return;
234
- }
235
- const identities = loadIdentities();
236
- identities[agentId] = identity || 'default';
237
- saveIdentities(identities);
238
- F.success('Agent ' + agentId + ' identity: ' + (identity || 'default'));
239
- }
240
-
241
- module.exports = agents;
1
+ const chalk = require('chalk');
2
+ const tui = require('../utils/tui');
3
+ const F = require('../utils/format');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+ const inquirer = require('../utils/inquirer-wrapper');
8
+ const { getConfig, saveConfig } = require('../utils/config');
9
+ const { getBots } = require('../utils/api');
10
+
11
+ const BINDINGS_FILE = path.join(os.homedir(), '.natureco', 'agent-bindings.json');
12
+ const IDENTITIES_FILE = path.join(os.homedir(), '.natureco', 'agent-identities.json');
13
+
14
+ function loadBindings() {
15
+ try {
16
+ if (fs.existsSync(BINDINGS_FILE)) return JSON.parse(fs.readFileSync(BINDINGS_FILE, 'utf8'));
17
+ } catch {}
18
+ return {};
19
+ }
20
+
21
+ function saveBindings(data) {
22
+ fs.mkdirSync(path.dirname(BINDINGS_FILE), { recursive: true });
23
+ fs.writeFileSync(BINDINGS_FILE, JSON.stringify(data, null, 2));
24
+ }
25
+
26
+ function loadIdentities() {
27
+ try {
28
+ if (fs.existsSync(IDENTITIES_FILE)) return JSON.parse(fs.readFileSync(IDENTITIES_FILE, 'utf8'));
29
+ } catch {}
30
+ return {};
31
+ }
32
+
33
+ function saveIdentities(data) {
34
+ fs.mkdirSync(path.dirname(IDENTITIES_FILE), { recursive: true });
35
+ fs.writeFileSync(IDENTITIES_FILE, JSON.stringify(data, null, 2));
36
+ }
37
+
38
+ async function agents(args) {
39
+ const [action, ...params] = (args || []);
40
+
41
+ if (!action || action === 'list') return listAgents();
42
+ if (action === 'set') return setActiveAgent(params[0]);
43
+ if (action === 'info') return agentInfo(params[0]);
44
+ if (action === 'add') return addAgent();
45
+ if (action === 'bindings') return listBindings();
46
+ if (action === 'bind') return bindAgent(params[0], params[1]);
47
+ if (action === 'unbind') return unbindAgent(params[0], params[1]);
48
+ if (action === 'set-identity') return setIdentity(params[0], params.slice(1).join(' '));
49
+
50
+ console.log(chalk.red(`\n Bilinmeyen komut: ${action}\n`));
51
+ console.log(chalk.gray(' Kullanım: natureco agents [list|set|info|add|bindings|bind|unbind|set-identity]\n'));
52
+ process.exit(1);
53
+ }
54
+
55
+ async function listAgents() {
56
+ const config = getConfig();
57
+ const apiKey = config.providerApiKey || config.apiKey || '';
58
+
59
+ F.info('Agentlar yükleniyor...');
60
+
61
+ let botList = { bots: [] };
62
+ try {
63
+ botList = await getBots(apiKey);
64
+ } catch {}
65
+
66
+ console.log('\n' + tui.styled(' 🤖 Agents', { color: tui.PALETTE.primary, bold: true }));
67
+ console.log(tui.styled(' ' + '─'.repeat(56), { color: tui.PALETTE.border }));
68
+
69
+ if (!botList.bots?.length) {
70
+ console.log('\n ' + tui.C.muted('Agent bulunamadı.'));
71
+ console.log(' ' + tui.C.muted('Oluşturmak için: ') + tui.C.brand('developers.natureco.me'));
72
+ console.log('');
73
+ return;
74
+ }
75
+
76
+ const rows = botList.bots.map(bot => ({
77
+ name: bot.name + (config.botName === bot.name ? ' ●' : ''),
78
+ id: bot.id,
79
+ provider: bot.ai_provider || 'groq',
80
+ model: bot.model || '—',
81
+ active: config.botName === bot.name,
82
+ }));
83
+
84
+ console.log('\n' + tui.table(rows, [
85
+ {
86
+ key: 'name', label: 'İsim', minWidth: 18,
87
+ render: r => r.active
88
+ ? tui.styled(r.name, { color: tui.PALETTE.success, bold: true })
89
+ : tui.C.text(r.name)
90
+ },
91
+ { key: 'id', label: 'ID', minWidth: 16, render: r => tui.C.muted(r.id) },
92
+ { key: 'provider', label: 'Provider', minWidth: 12, render: r => tui.C.text(r.provider) },
93
+ { key: 'model', label: 'Model', minWidth: 18, render: r => tui.C.muted(r.model) },
94
+ ], { borderStyle: 'round', zebra: true }));
95
+
96
+ console.log('\n ' + tui.C.muted('Değiştirmek için: ') + tui.C.brand('natureco agents set <bot-adı>'));
97
+ console.log('');
98
+ }
99
+
100
+ async function setActiveAgent(botName) {
101
+ const config = getConfig();
102
+ const apiKey = config.providerApiKey || config.apiKey || '';
103
+
104
+ let botList = { bots: [] };
105
+ try {
106
+ botList = await getBots(apiKey);
107
+ } catch {}
108
+
109
+ if (!botName) {
110
+ if (!botList.bots?.length) {
111
+ console.log(chalk.gray('\n Agent bulunamadı.\n'));
112
+ return;
113
+ }
114
+ const { selected } = await inquirer.prompt([{
115
+ type: 'list',
116
+ name: 'selected',
117
+ message: ' Aktif agent seç:',
118
+ choices: botList.bots.map(b => ({ name: b.name, value: b.name })),
119
+ }]);
120
+ botName = selected;
121
+ }
122
+
123
+ const bot = botList.bots?.find(b => b.name === botName || b.id === botName);
124
+ if (!bot && botList.bots?.length) {
125
+ console.log(chalk.red(`\n ❌ Agent bulunamadı: ${botName}\n`));
126
+ process.exit(1);
127
+ }
128
+
129
+ config.botName = botName;
130
+ if (bot?.id) config.defaultBotId = bot.id;
131
+ saveConfig(config);
132
+
133
+ console.log(chalk.green(`\n ✓ Aktif agent: ${botName}\n`));
134
+ }
135
+
136
+ async function agentInfo(botName) {
137
+ const config = getConfig();
138
+ const apiKey = config.providerApiKey || config.apiKey || '';
139
+ const name = botName || config.botName;
140
+
141
+ if (!name) {
142
+ F.error('Agent adı belirtin: natureco agents info <bot-adı>');
143
+ return;
144
+ }
145
+
146
+ let botList = { bots: [] };
147
+ try {
148
+ botList = await getBots(apiKey);
149
+ } catch {}
150
+
151
+ const bot = botList.bots?.find(b => b.name === name || b.id === name);
152
+
153
+ F.header('Agent: ' + name);
154
+
155
+ if (bot) {
156
+ F.kv('ID', bot.id);
157
+ F.kv('Provider', bot.ai_provider || 'groq');
158
+ if (bot.model) F.kv('Model', bot.model);
159
+ if (bot.system_prompt) {
160
+ F.kv('Prompt', bot.system_prompt.slice(0, 80) + (bot.system_prompt.length > 80 ? '...' : ''));
161
+ }
162
+ } else {
163
+ F.meta('(Detay alınamadı)');
164
+ }
165
+
166
+ try {
167
+ const { loadMemory } = require('../utils/memory');
168
+ const mem = loadMemory(bot?.id || 'universal-provider');
169
+ if (mem.name || mem.facts?.length) {
170
+ if (mem.name) F.kv('Kullanıcı', mem.name);
171
+ F.kv('Hafıza', (mem.facts || []).length + ' bilgi');
172
+ }
173
+ } catch {}
174
+ }
175
+
176
+ async function addAgent() {
177
+ console.log('');
178
+ console.log(chalk.gray(' Yeni agent oluşturmak için Developers Portal\'ı kullanın:'));
179
+ console.log(chalk.cyan(' developers.natureco.me\n'));
180
+ console.log(chalk.gray(' Oluşturduktan sonra: ') + chalk.cyan('natureco agents list\n'));
181
+ }
182
+
183
+ // ── Bindings ──────────────────────────────────────────────────────────────────
184
+
185
+ function listBindings() {
186
+ const bindings = loadBindings();
187
+ const keys = Object.keys(bindings);
188
+
189
+ F.section('Bindings (' + keys.length + ')');
190
+
191
+ if (keys.length === 0) {
192
+ F.meta('Henüz binding yok.');
193
+ return;
194
+ }
195
+
196
+ const items = [];
197
+ keys.forEach(agentId => {
198
+ bindings[agentId].forEach(ch => items.push(agentId + ' → ' + ch));
199
+ });
200
+ F.list(items);
201
+ }
202
+
203
+ function bindAgent(agentId, channel) {
204
+ if (!agentId || !channel) {
205
+ F.error('Kullanım: natureco agents bind <agentId> <channel>');
206
+ return;
207
+ }
208
+ const bindings = loadBindings();
209
+ if (!bindings[agentId]) bindings[agentId] = [];
210
+ if (!bindings[agentId].includes(channel)) bindings[agentId].push(channel);
211
+ saveBindings(bindings);
212
+ F.success('Agent ' + agentId + ' → ' + channel + ' bağlandı');
213
+ }
214
+
215
+ function unbindAgent(agentId, channel) {
216
+ if (!agentId || !channel) {
217
+ F.error('Kullanım: natureco agents unbind <agentId> <channel>');
218
+ return;
219
+ }
220
+ const bindings = loadBindings();
221
+ if (!bindings[agentId]) {
222
+ F.warning('Agent ' + agentId + ' için binding bulunamadı');
223
+ return;
224
+ }
225
+ bindings[agentId] = bindings[agentId].filter(ch => ch !== channel);
226
+ if (bindings[agentId].length === 0) delete bindings[agentId];
227
+ saveBindings(bindings);
228
+ F.success('Agent ' + agentId + ' → ' + channel + ' bağlantısı kaldırıldı');
229
+ }
230
+
231
+ function setIdentity(agentId, identity) {
232
+ if (!agentId) {
233
+ F.error('Kullanım: natureco agents set-identity <agentId> <identity>');
234
+ return;
235
+ }
236
+ const identities = loadIdentities();
237
+ identities[agentId] = identity || 'default';
238
+ saveIdentities(identities);
239
+ F.success('Agent ' + agentId + ' identity: ' + (identity || 'default'));
240
+ }
241
+
242
+ module.exports = agents;
package/src/tools/soul.js CHANGED
@@ -125,19 +125,29 @@ function soulAction(params) {
125
125
  const action = params.action || "show";
126
126
  const all = findAll();
127
127
  const loaded = Object.keys(all).length;
128
+ // v5.6.13: Dosya yollarini kisalt (home ile baslat)
129
+ const shortenPath = (p) => {
130
+ if (!p) return '';
131
+ const home = require('os').homedir();
132
+ if (p.startsWith(home)) return '~' + p.slice(home.length);
133
+ return p;
134
+ };
128
135
 
129
136
  if (action === "show") {
130
137
  if (loaded === 0) {
131
138
  return {
132
139
  success: false,
133
- error: "Hicbir SOUL dosyasi bulunamadi. Aranacak yerler:\n" + SOUL_PATHS.join("\n"),
140
+ error: "Hicbir SOUL dosyasi bulunamadi. Aranacak yerler:\n" + SOUL_PATHS.map(shortenPath).join("\n"),
134
141
  };
135
142
  }
136
143
  return {
137
144
  success: true,
138
145
  loaded: loaded,
139
- files: Object.fromEntries(Object.entries(all).map(([k, v]) => [k, { path: v.path, content: v.content }])),
140
- summary: summarizeSoul(buildSoulContext(), 4000),
146
+ files: Object.fromEntries(Object.entries(all).map(([k, v]) => [k, {
147
+ path: shortenPath(v.path),
148
+ content: v.content ? v.content.slice(0, 500) + (v.content.length > 500 ? '... [truncated]' : '') : ''
149
+ }])),
150
+ summary: summarizeSoul(buildSoulContext(), 2000),
141
151
  message: loaded + " SOUL dosyasi yuklendi: " + Object.keys(all).join(", "),
142
152
  };
143
153
  }
@@ -148,12 +158,12 @@ function soulAction(params) {
148
158
  loaded: loaded,
149
159
  total: SOUL_FILES.length,
150
160
  files: Object.fromEntries(Object.entries(all).map(([k, v]) => ({
151
- path: v.path,
161
+ path: shortenPath(v.path),
152
162
  size: fs.statSync(v.path).size,
153
163
  modifiedAt: fs.statSync(v.path).mtime.toISOString(),
154
164
  lineCount: v.content.split("\n").length,
155
165
  }))),
156
- searched: SOUL_PATHS,
166
+ searched: SOUL_PATHS.map(shortenPath),
157
167
  };
158
168
  }
159
169