natureco-cli 2.23.30 → 2.23.32
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 +178 -167
- package/package.json +1 -1
- package/src/commands/acp.js +39 -0
- package/src/commands/admin-rpc.js +83 -0
- package/src/commands/agent.js +214 -23
- package/src/commands/agents.js +114 -30
- package/src/commands/approvals.js +172 -11
- package/src/commands/ask.js +1 -1
- package/src/commands/browser.js +815 -0
- package/src/commands/capability.js +195 -22
- package/src/commands/channels.js +422 -267
- package/src/commands/chat.js +5 -8
- package/src/commands/clawbot.js +19 -0
- package/src/commands/code.js +3 -2
- package/src/commands/commitments.js +125 -9
- package/src/commands/completion.js +40 -32
- package/src/commands/config.js +228 -30
- package/src/commands/configure.js +84 -67
- package/src/commands/cron.js +239 -19
- package/src/commands/daemon.js +34 -4
- package/src/commands/dashboard.js +47 -374
- package/src/commands/devices.js +53 -26
- package/src/commands/directory.js +146 -14
- package/src/commands/dns.js +148 -10
- package/src/commands/docs.js +119 -26
- package/src/commands/doctor.js +143 -492
- package/src/commands/exec-policy.js +57 -48
- package/src/commands/gateway.js +492 -249
- package/src/commands/health.js +141 -11
- package/src/commands/help.js +24 -25
- package/src/commands/hooks.js +141 -87
- package/src/commands/infer.js +1442 -41
- package/src/commands/logs.js +122 -99
- package/src/commands/mcp.js +121 -309
- package/src/commands/memory.js +128 -0
- package/src/commands/message.js +720 -140
- package/src/commands/models.js +39 -1
- package/src/commands/node.js +77 -77
- package/src/commands/nodes.js +278 -22
- package/src/commands/onboard.js +115 -56
- package/src/commands/pairing.js +108 -107
- package/src/commands/path.js +206 -0
- package/src/commands/plugins.js +35 -1
- package/src/commands/proxy.js +159 -8
- package/src/commands/qr.js +55 -13
- package/src/commands/reset.js +101 -94
- package/src/commands/secrets.js +104 -21
- package/src/commands/sessions.js +110 -51
- package/src/commands/setup.js +229 -649
- package/src/commands/skills.js +67 -1
- package/src/commands/status.js +101 -127
- package/src/commands/tasks.js +208 -100
- package/src/commands/terminal.js +130 -12
- package/src/commands/transcripts.js +24 -1
- package/src/commands/tui.js +41 -0
- package/src/commands/uninstall.js +73 -92
- package/src/commands/update.js +146 -91
- package/src/commands/web-fetch.js +34 -0
- package/src/commands/webhooks.js +58 -66
- package/src/commands/wiki.js +783 -0
- package/src/utils/agents-md.js +85 -0
- package/src/utils/api.js +40 -41
- package/src/utils/format.js +144 -0
- package/src/utils/headless.js +2 -1
- package/src/utils/parallel-tools.js +106 -0
- package/src/utils/sub-agent.js +148 -0
- package/src/utils/token-budget.js +304 -0
- package/src/utils/tool-runner.js +7 -5
- package/src/utils/web-fetch.js +107 -0
package/src/commands/logs.js
CHANGED
|
@@ -1,99 +1,122 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
|
|
6
|
-
const LOG_FILE = path.join(os.homedir(), '.natureco', '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const LOG_FILE = path.join(os.homedir(), '.natureco', 'natureco.log');
|
|
7
|
+
|
|
8
|
+
function ensureLog() {
|
|
9
|
+
const dir = path.dirname(LOG_FILE);
|
|
10
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
11
|
+
if (!fs.existsSync(LOG_FILE)) fs.writeFileSync(LOG_FILE, '', 'utf8');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function logs(args) {
|
|
15
|
+
const [action, ...params] = args || [];
|
|
16
|
+
|
|
17
|
+
if (!action || action === 'show') return cmdShow(params[0] ? parseInt(params[0], 10) : 50);
|
|
18
|
+
if (action === 'tail') return cmdTail();
|
|
19
|
+
if (action === 'search') return cmdSearch(params.join(' '));
|
|
20
|
+
if (action === 'clear') return cmdClear();
|
|
21
|
+
if (action === 'path') return cmdPath();
|
|
22
|
+
|
|
23
|
+
console.log(chalk.red(`\n Unknown logs action: ${action}\n`));
|
|
24
|
+
console.log(chalk.gray(' Usage: natureco logs <action> [params]'));
|
|
25
|
+
console.log(chalk.gray(' Actions: tail, show <lines>, search <term>, clear, path\n'));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function cmdShow(lines) {
|
|
30
|
+
ensureLog();
|
|
31
|
+
const content = fs.readFileSync(LOG_FILE, 'utf8');
|
|
32
|
+
const allLines = content.split('\n').filter(l => l.trim());
|
|
33
|
+
|
|
34
|
+
if (lines < 1) lines = 50;
|
|
35
|
+
const last = allLines.slice(-lines);
|
|
36
|
+
|
|
37
|
+
console.log(chalk.cyan(`\n Logs (last ${last.length} of ${allLines.length} lines)\n`));
|
|
38
|
+
for (const line of last) {
|
|
39
|
+
printColoredLine(line);
|
|
40
|
+
}
|
|
41
|
+
console.log('');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function cmdTail() {
|
|
45
|
+
ensureLog();
|
|
46
|
+
console.log(chalk.cyan('\n Tailing log file... (Ctrl+C to stop)\n'));
|
|
47
|
+
let lastSize = fs.statSync(LOG_FILE).size;
|
|
48
|
+
|
|
49
|
+
const watcher = setInterval(() => {
|
|
50
|
+
try {
|
|
51
|
+
const stat = fs.statSync(LOG_FILE);
|
|
52
|
+
if (stat.size > lastSize) {
|
|
53
|
+
const fd = fs.openSync(LOG_FILE, 'r');
|
|
54
|
+
const buf = Buffer.alloc(stat.size - lastSize);
|
|
55
|
+
fs.readSync(fd, buf, 0, buf.length, lastSize);
|
|
56
|
+
fs.closeSync(fd);
|
|
57
|
+
const newLines = buf.toString('utf8').split('\n').filter(l => l.trim());
|
|
58
|
+
for (const line of newLines) printColoredLine(line);
|
|
59
|
+
lastSize = stat.size;
|
|
60
|
+
}
|
|
61
|
+
} catch {}
|
|
62
|
+
}, 500);
|
|
63
|
+
|
|
64
|
+
process.on('SIGINT', () => {
|
|
65
|
+
clearInterval(watcher);
|
|
66
|
+
console.log(chalk.gray('\n Tail stopped.\n'));
|
|
67
|
+
process.exit(0);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function cmdSearch(term) {
|
|
72
|
+
if (!term) {
|
|
73
|
+
console.log(chalk.red('\n Usage: natureco logs search <term>\n'));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ensureLog();
|
|
78
|
+
const content = fs.readFileSync(LOG_FILE, 'utf8');
|
|
79
|
+
const lines = content.split('\n').filter(l => l.trim());
|
|
80
|
+
const lower = term.toLowerCase();
|
|
81
|
+
const results = lines.filter(l => l.toLowerCase().includes(lower));
|
|
82
|
+
|
|
83
|
+
if (results.length === 0) {
|
|
84
|
+
console.log(chalk.yellow(`\n No matches for "${term}"\n`));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.log(chalk.cyan(`\n Found ${results.length} match(es) for "${term}"\n`));
|
|
89
|
+
for (const line of results.slice(-50)) {
|
|
90
|
+
const idx = line.toLowerCase().indexOf(lower);
|
|
91
|
+
if (idx === -1) { printColoredLine(line); continue; }
|
|
92
|
+
const before = line.slice(0, idx);
|
|
93
|
+
const match = line.slice(idx, idx + term.length);
|
|
94
|
+
const after = line.slice(idx + term.length);
|
|
95
|
+
console.log(chalk.gray(' ') + chalk.gray(before) + chalk.yellow(match) + chalk.gray(after));
|
|
96
|
+
}
|
|
97
|
+
console.log('');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function cmdClear() {
|
|
101
|
+
ensureLog();
|
|
102
|
+
fs.writeFileSync(LOG_FILE, '', 'utf8');
|
|
103
|
+
console.log(chalk.gray('\n Log file cleared.\n'));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function cmdPath() {
|
|
107
|
+
console.log(chalk.cyan(`\n Log file: ${LOG_FILE}\n`));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function printColoredLine(line) {
|
|
111
|
+
if (line.includes('[error]') || line.includes('ERROR') || line.includes('❌')) {
|
|
112
|
+
console.log(chalk.red(' ' + line));
|
|
113
|
+
} else if (line.includes('[warn]') || line.includes('WARN') || line.includes('⚠')) {
|
|
114
|
+
console.log(chalk.yellow(' ' + line));
|
|
115
|
+
} else if (line.includes('[info]') || line.includes('INFO')) {
|
|
116
|
+
console.log(chalk.cyan(' ' + line));
|
|
117
|
+
} else {
|
|
118
|
+
console.log(chalk.gray(' ' + line));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = logs;
|
package/src/commands/mcp.js
CHANGED
|
@@ -1,309 +1,121 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
]);
|
|
124
|
-
serverName = name;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Şablon seç
|
|
128
|
-
const { useTemplate } = await inquirer.prompt([
|
|
129
|
-
{
|
|
130
|
-
type: 'confirm',
|
|
131
|
-
name: 'useTemplate',
|
|
132
|
-
message: 'Hazır şablon kullanmak ister misiniz?',
|
|
133
|
-
default: true,
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
136
|
-
|
|
137
|
-
if (useTemplate) {
|
|
138
|
-
const { template } = await inquirer.prompt([
|
|
139
|
-
{
|
|
140
|
-
type: 'list',
|
|
141
|
-
name: 'template',
|
|
142
|
-
message: 'Şablon seçin:',
|
|
143
|
-
choices: templateNames.map(key => ({
|
|
144
|
-
name: `${templates[key].name} - ${templates[key].description}`,
|
|
145
|
-
value: key,
|
|
146
|
-
})),
|
|
147
|
-
},
|
|
148
|
-
]);
|
|
149
|
-
|
|
150
|
-
const selectedTemplate = templates[template];
|
|
151
|
-
|
|
152
|
-
// Environment variables
|
|
153
|
-
const envVars = {};
|
|
154
|
-
const config = getConfig();
|
|
155
|
-
|
|
156
|
-
if (selectedTemplate.env && Object.keys(selectedTemplate.env).length > 0) {
|
|
157
|
-
console.log(chalk.yellow('\nEnvironment variable\'ları ayarlayın:\n'));
|
|
158
|
-
|
|
159
|
-
for (const [key, defaultValue] of Object.entries(selectedTemplate.env)) {
|
|
160
|
-
// Special handling for GitHub token
|
|
161
|
-
if (template === 'github' && key === 'GITHUB_TOKEN') {
|
|
162
|
-
const existingToken = config.githubToken;
|
|
163
|
-
|
|
164
|
-
const { value } = await inquirer.prompt([
|
|
165
|
-
{
|
|
166
|
-
type: 'password',
|
|
167
|
-
name: 'value',
|
|
168
|
-
message: `${key} (ghp_xxx):`,
|
|
169
|
-
default: existingToken || '',
|
|
170
|
-
validate: (input) => {
|
|
171
|
-
if (!input || input.trim().length === 0) {
|
|
172
|
-
return 'GitHub token gerekli';
|
|
173
|
-
}
|
|
174
|
-
if (!input.startsWith('ghp_') && !input.startsWith('github_pat_')) {
|
|
175
|
-
return 'Geçersiz GitHub token formatı';
|
|
176
|
-
}
|
|
177
|
-
return true;
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
]);
|
|
181
|
-
|
|
182
|
-
envVars[key] = value;
|
|
183
|
-
|
|
184
|
-
// Save to config for future use
|
|
185
|
-
config.githubToken = value;
|
|
186
|
-
saveConfig(config);
|
|
187
|
-
console.log(chalk.gray(' ✓ GitHub token config\'e kaydedildi\n'));
|
|
188
|
-
|
|
189
|
-
} else {
|
|
190
|
-
const { value } = await inquirer.prompt([
|
|
191
|
-
{
|
|
192
|
-
type: 'input',
|
|
193
|
-
name: 'value',
|
|
194
|
-
message: `${key}:`,
|
|
195
|
-
default: defaultValue,
|
|
196
|
-
},
|
|
197
|
-
]);
|
|
198
|
-
envVars[key] = value;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
try {
|
|
204
|
-
addMcpServer(serverName, template);
|
|
205
|
-
|
|
206
|
-
// Update env vars if provided
|
|
207
|
-
if (Object.keys(envVars).length > 0) {
|
|
208
|
-
updateMcpServer(serverName, { env: envVars });
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
console.log(chalk.green(`\n✅ MCP sunucu eklendi: ${serverName}\n`));
|
|
212
|
-
console.log(chalk.gray('Test etmek için: ') + chalk.cyan(`natureco mcp test ${serverName}\n`));
|
|
213
|
-
} catch (err) {
|
|
214
|
-
console.log(chalk.red(`\n❌ Hata: ${err.message}\n`));
|
|
215
|
-
process.exit(1);
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
// Custom config
|
|
219
|
-
const { command } = await inquirer.prompt([
|
|
220
|
-
{
|
|
221
|
-
type: 'input',
|
|
222
|
-
name: 'command',
|
|
223
|
-
message: 'Komut:',
|
|
224
|
-
default: 'npx',
|
|
225
|
-
},
|
|
226
|
-
]);
|
|
227
|
-
|
|
228
|
-
const { args } = await inquirer.prompt([
|
|
229
|
-
{
|
|
230
|
-
type: 'input',
|
|
231
|
-
name: 'args',
|
|
232
|
-
message: 'Argümanlar (boşlukla ayırın):',
|
|
233
|
-
},
|
|
234
|
-
]);
|
|
235
|
-
|
|
236
|
-
const customConfig = {
|
|
237
|
-
command,
|
|
238
|
-
args: args.split(' ').filter(a => a.length > 0),
|
|
239
|
-
env: {},
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
try {
|
|
243
|
-
addMcpServer(serverName, null, customConfig);
|
|
244
|
-
console.log(chalk.green(`\n✅ MCP sunucu eklendi: ${serverName}\n`));
|
|
245
|
-
} catch (err) {
|
|
246
|
-
console.log(chalk.red(`\n❌ Hata: ${err.message}\n`));
|
|
247
|
-
process.exit(1);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function removeMcpServerCommand(params) {
|
|
253
|
-
if (params.length === 0) {
|
|
254
|
-
console.log(chalk.red('\n❌ Sunucu adı gerekli\n'));
|
|
255
|
-
console.log(chalk.gray('Kullanım: natureco mcp remove <sunucu-adı>\n'));
|
|
256
|
-
process.exit(1);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const serverName = params[0];
|
|
260
|
-
|
|
261
|
-
try {
|
|
262
|
-
removeMcpServer(serverName);
|
|
263
|
-
console.log(chalk.green(`\n✅ MCP sunucu kaldırıldı: ${serverName}\n`));
|
|
264
|
-
} catch (err) {
|
|
265
|
-
console.log(chalk.red(`\n❌ Hata: ${err.message}\n`));
|
|
266
|
-
process.exit(1);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function testMcpServerCommand(params) {
|
|
271
|
-
if (params.length === 0) {
|
|
272
|
-
console.log(chalk.red('\n❌ Sunucu adı gerekli\n'));
|
|
273
|
-
console.log(chalk.gray('Kullanım: natureco mcp test <sunucu-adı>\n'));
|
|
274
|
-
process.exit(1);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const serverName = params[0];
|
|
278
|
-
|
|
279
|
-
console.log(chalk.yellow(`\n⏳ Test ediliyor: ${serverName}...\n`));
|
|
280
|
-
|
|
281
|
-
try {
|
|
282
|
-
testMcpServer(serverName);
|
|
283
|
-
console.log(chalk.green(`✅ Bağlantı başarılı: ${serverName}\n`));
|
|
284
|
-
} catch (err) {
|
|
285
|
-
console.log(chalk.red(`❌ Bağlantı başarısız: ${err.message}\n`));
|
|
286
|
-
process.exit(1);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function toggleMcpServerCommand(params, enabled) {
|
|
291
|
-
if (params.length === 0) {
|
|
292
|
-
console.log(chalk.red('\n❌ Sunucu adı gerekli\n'));
|
|
293
|
-
console.log(chalk.gray(`Kullanım: natureco mcp ${enabled ? 'enable' : 'disable'} <sunucu-adı>\n`));
|
|
294
|
-
process.exit(1);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const serverName = params[0];
|
|
298
|
-
|
|
299
|
-
try {
|
|
300
|
-
toggleMcpServer(serverName, enabled);
|
|
301
|
-
const status = enabled ? 'aktif' : 'devre dışı';
|
|
302
|
-
console.log(chalk.green(`\n✅ MCP sunucu ${status}: ${serverName}\n`));
|
|
303
|
-
} catch (err) {
|
|
304
|
-
console.log(chalk.red(`\n❌ Hata: ${err.message}\n`));
|
|
305
|
-
process.exit(1);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
module.exports = mcp;
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const MCP_CONFIG = path.join(os.homedir(), '.natureco', 'mcp-servers.json');
|
|
7
|
+
|
|
8
|
+
function loadServers() {
|
|
9
|
+
if (!fs.existsSync(MCP_CONFIG)) return {};
|
|
10
|
+
try { return JSON.parse(fs.readFileSync(MCP_CONFIG, 'utf8')); }
|
|
11
|
+
catch { return {}; }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function saveServers(servers) {
|
|
15
|
+
const dir = path.dirname(MCP_CONFIG);
|
|
16
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
17
|
+
fs.writeFileSync(MCP_CONFIG, JSON.stringify(servers, null, 2), 'utf8');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function mcp(args) {
|
|
21
|
+
const [action, ...params] = args || [];
|
|
22
|
+
|
|
23
|
+
if (!action || action === 'list') return cmdList();
|
|
24
|
+
if (action === 'serve') return cmdServe();
|
|
25
|
+
if (action === 'show') return cmdShow(params[0]);
|
|
26
|
+
if (action === 'set') return cmdSet(params[0], params.slice(1));
|
|
27
|
+
if (action === 'unset') return cmdUnset(params[0]);
|
|
28
|
+
|
|
29
|
+
console.log(chalk.red(`\n Unknown mcp action: ${action}\n`));
|
|
30
|
+
console.log(chalk.gray(' Usage: natureco mcp <action> [params]'));
|
|
31
|
+
console.log(chalk.gray(' Actions: serve, list, show <name>, set, unset <name>\n'));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function cmdServe() {
|
|
36
|
+
console.log(chalk.cyan('\n MCP Server\n'));
|
|
37
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
38
|
+
console.log(` ${chalk.white('Endpoint:')} ${chalk.green('http://127.0.0.1:3848/mcp')}`);
|
|
39
|
+
console.log(` ${chalk.white('Status:')} ${chalk.gray('Would start MCP server here')}`);
|
|
40
|
+
console.log('');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function cmdList() {
|
|
44
|
+
const servers = loadServers();
|
|
45
|
+
const names = Object.keys(servers);
|
|
46
|
+
|
|
47
|
+
console.log(chalk.cyan('\n MCP Servers\n'));
|
|
48
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
49
|
+
|
|
50
|
+
if (names.length === 0) {
|
|
51
|
+
console.log(chalk.gray(' No MCP servers configured.\n'));
|
|
52
|
+
console.log(chalk.gray(' Add one: ') + chalk.cyan('natureco mcp set <name> <command> [args...]\n'));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const name of names) {
|
|
57
|
+
const s = servers[name];
|
|
58
|
+
const status = s.disabled ? chalk.red('disabled') : chalk.green('enabled');
|
|
59
|
+
console.log(` ${chalk.white(name)} ${chalk.gray(`— ${status}`)}`);
|
|
60
|
+
console.log(chalk.gray(` Command: ${s.command} ${(s.args || []).join(' ')}`));
|
|
61
|
+
}
|
|
62
|
+
console.log('');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function cmdShow(name) {
|
|
66
|
+
if (!name) {
|
|
67
|
+
console.log(chalk.red('\n Usage: natureco mcp show <name>\n'));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const servers = loadServers();
|
|
72
|
+
const s = servers[name];
|
|
73
|
+
if (!s) {
|
|
74
|
+
console.log(chalk.yellow(`\n MCP server "${name}" not found.\n`));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(chalk.cyan(`\n MCP Server: ${name}\n`));
|
|
79
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
80
|
+
console.log(` ${chalk.white('Command:')} ${chalk.white(s.command)} ${chalk.gray((s.args || []).join(' '))}`);
|
|
81
|
+
console.log(` ${chalk.white('Status:')} ${s.disabled ? chalk.red('disabled') : chalk.green('enabled')}`);
|
|
82
|
+
if (s.env && Object.keys(s.env).length > 0) {
|
|
83
|
+
console.log(` ${chalk.white('Env:')} ${chalk.gray(Object.keys(s.env).join(', '))}`);
|
|
84
|
+
}
|
|
85
|
+
console.log('');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function cmdSet(name, rest) {
|
|
89
|
+
if (!name || rest.length === 0) {
|
|
90
|
+
console.log(chalk.red('\n Usage: natureco mcp set <name> <command> [args...]\n'));
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const servers = loadServers();
|
|
95
|
+
servers[name] = {
|
|
96
|
+
command: rest[0],
|
|
97
|
+
args: rest.slice(1),
|
|
98
|
+
disabled: false,
|
|
99
|
+
};
|
|
100
|
+
saveServers(servers);
|
|
101
|
+
console.log(chalk.green(`\n MCP server "${name}" configured.\n`));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function cmdUnset(name) {
|
|
105
|
+
if (!name) {
|
|
106
|
+
console.log(chalk.red('\n Usage: natureco mcp unset <name>\n'));
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const servers = loadServers();
|
|
111
|
+
if (!servers[name]) {
|
|
112
|
+
console.log(chalk.yellow(`\n MCP server "${name}" not found.\n`));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
delete servers[name];
|
|
117
|
+
saveServers(servers);
|
|
118
|
+
console.log(chalk.gray(`\n MCP server "${name}" removed.\n`));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = mcp;
|