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.
Files changed (69) hide show
  1. package/bin/natureco.js +178 -167
  2. package/package.json +1 -1
  3. package/src/commands/acp.js +39 -0
  4. package/src/commands/admin-rpc.js +83 -0
  5. package/src/commands/agent.js +214 -23
  6. package/src/commands/agents.js +114 -30
  7. package/src/commands/approvals.js +172 -11
  8. package/src/commands/ask.js +1 -1
  9. package/src/commands/browser.js +815 -0
  10. package/src/commands/capability.js +195 -22
  11. package/src/commands/channels.js +422 -267
  12. package/src/commands/chat.js +5 -8
  13. package/src/commands/clawbot.js +19 -0
  14. package/src/commands/code.js +3 -2
  15. package/src/commands/commitments.js +125 -9
  16. package/src/commands/completion.js +40 -32
  17. package/src/commands/config.js +228 -30
  18. package/src/commands/configure.js +84 -67
  19. package/src/commands/cron.js +239 -19
  20. package/src/commands/daemon.js +34 -4
  21. package/src/commands/dashboard.js +47 -374
  22. package/src/commands/devices.js +53 -26
  23. package/src/commands/directory.js +146 -14
  24. package/src/commands/dns.js +148 -10
  25. package/src/commands/docs.js +119 -26
  26. package/src/commands/doctor.js +143 -492
  27. package/src/commands/exec-policy.js +57 -48
  28. package/src/commands/gateway.js +492 -249
  29. package/src/commands/health.js +141 -11
  30. package/src/commands/help.js +24 -25
  31. package/src/commands/hooks.js +141 -87
  32. package/src/commands/infer.js +1442 -41
  33. package/src/commands/logs.js +122 -99
  34. package/src/commands/mcp.js +121 -309
  35. package/src/commands/memory.js +128 -0
  36. package/src/commands/message.js +720 -140
  37. package/src/commands/models.js +39 -1
  38. package/src/commands/node.js +77 -77
  39. package/src/commands/nodes.js +278 -22
  40. package/src/commands/onboard.js +115 -56
  41. package/src/commands/pairing.js +108 -107
  42. package/src/commands/path.js +206 -0
  43. package/src/commands/plugins.js +35 -1
  44. package/src/commands/proxy.js +159 -8
  45. package/src/commands/qr.js +55 -13
  46. package/src/commands/reset.js +101 -94
  47. package/src/commands/secrets.js +104 -21
  48. package/src/commands/sessions.js +110 -51
  49. package/src/commands/setup.js +229 -649
  50. package/src/commands/skills.js +67 -1
  51. package/src/commands/status.js +101 -127
  52. package/src/commands/tasks.js +208 -100
  53. package/src/commands/terminal.js +130 -12
  54. package/src/commands/transcripts.js +24 -1
  55. package/src/commands/tui.js +41 -0
  56. package/src/commands/uninstall.js +73 -92
  57. package/src/commands/update.js +146 -91
  58. package/src/commands/web-fetch.js +34 -0
  59. package/src/commands/webhooks.js +58 -66
  60. package/src/commands/wiki.js +783 -0
  61. package/src/utils/agents-md.js +85 -0
  62. package/src/utils/api.js +40 -41
  63. package/src/utils/format.js +144 -0
  64. package/src/utils/headless.js +2 -1
  65. package/src/utils/parallel-tools.js +106 -0
  66. package/src/utils/sub-agent.js +148 -0
  67. package/src/utils/token-budget.js +304 -0
  68. package/src/utils/tool-runner.js +7 -5
  69. package/src/utils/web-fetch.js +107 -0
@@ -1,92 +1,73 @@
1
- const chalk = require('chalk');
2
- const inquirer = require('../utils/inquirer-wrapper');
3
- const fs = require('fs');
4
- const path = require('path');
5
- const os = require('os');
6
- const { CONFIG_DIR } = require('../utils/config');
7
-
8
- async function uninstall(args) {
9
- const all = args?.includes('--all');
10
- const yes = args?.includes('--yes') || args?.includes('-y');
11
- const dryRun = args?.includes('--dry-run');
12
-
13
- console.log('');
14
- console.log(chalk.gray(' ' + '─'.repeat(48)));
15
- console.log(chalk.red.bold('\n NatureCo CLI — Kaldırma\n'));
16
-
17
- const actions = [];
18
-
19
- // Gateway service PID
20
- const pidFile = path.join(CONFIG_DIR, 'gateway.pid');
21
- if (fs.existsSync(pidFile)) actions.push('Gateway durdurulacak');
22
-
23
- // Config ve data
24
- if (all) {
25
- actions.push(`~/.natureco/ klasörü silinecek (config, hafıza, session'lar)`);
26
- } else {
27
- actions.push('Gateway ve dashboard durdurulacak');
28
- actions.push('~/.natureco/gateway.pid ve dashboard.pid silinecek');
29
- }
30
-
31
- actions.push('npm uninstall -g natureco-cli komutu gösterilecek');
32
-
33
- if (dryRun) {
34
- console.log(chalk.yellow(' Dry-run modu — hiçbir şey silinmeyecek\n'));
35
- actions.forEach(a => console.log(chalk.gray(` • ${a}`)));
36
- console.log('');
37
- return;
38
- }
39
-
40
- console.log(chalk.yellow(' Yapılacaklar:\n'));
41
- actions.forEach(a => console.log(chalk.gray(` • ${a}`)));
42
- console.log('');
43
-
44
- if (!yes) {
45
- const { confirm } = await inquirer.prompt([{
46
- type: 'confirm',
47
- name: 'confirm',
48
- message: ' Devam etmek istediğinizden emin misiniz?',
49
- default: false,
50
- }]);
51
- if (!confirm) {
52
- console.log(chalk.gray('\n İptal edildi.\n'));
53
- return;
54
- }
55
- }
56
-
57
- // Gateway durdur
58
- if (fs.existsSync(pidFile)) {
59
- try {
60
- const pid = parseInt(fs.readFileSync(pidFile, 'utf-8').trim());
61
- if (pid) process.kill(pid, 'SIGTERM');
62
- fs.unlinkSync(pidFile);
63
- console.log(chalk.green(' Gateway durduruldu'));
64
- } catch {}
65
- }
66
-
67
- // Dashboard durdur
68
- const dashPid = path.join(CONFIG_DIR, 'dashboard.pid');
69
- if (fs.existsSync(dashPid)) {
70
- try {
71
- const pid = parseInt(fs.readFileSync(dashPid, 'utf-8').trim());
72
- if (pid) process.kill(pid, 'SIGTERM');
73
- fs.unlinkSync(dashPid);
74
- console.log(chalk.green(' ✓ Dashboard durduruldu'));
75
- } catch {}
76
- }
77
-
78
- // --all ise tüm veriyi sil
79
- if (all && fs.existsSync(CONFIG_DIR)) {
80
- fs.rmSync(CONFIG_DIR, { recursive: true, force: true });
81
- console.log(chalk.green(' ✓ ~/.natureco/ silindi'));
82
- }
83
-
84
- console.log('');
85
- console.log(chalk.green(' ✓ Temizlik tamamlandı!'));
86
- console.log('');
87
- console.log(chalk.gray(' CLI\'yi tamamen kaldırmak için:'));
88
- console.log(chalk.cyan(' npm uninstall -g natureco-cli'));
89
- console.log('');
90
- }
91
-
92
- module.exports = uninstall;
1
+ const chalk = require('chalk');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
5
+ const { execSync } = require('child_process');
6
+ const readline = require('readline');
7
+
8
+ const BASE_DIR = path.join(os.homedir(), '.natureco');
9
+
10
+ function rlQuestion(query) {
11
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
12
+ return new Promise(resolve => {
13
+ rl.question(query, answer => { rl.close(); resolve(answer.trim().toLowerCase()); });
14
+ });
15
+ }
16
+
17
+ async function uninstall(params) {
18
+ try {
19
+ const [action] = params || [];
20
+
21
+ if (action === 'dry-run') return cmdDryRun();
22
+
23
+ if (!action || action === 'run') return await cmdRun();
24
+
25
+ console.log(chalk.red(`\n Unknown uninstall action: ${action}\n`));
26
+ console.log(chalk.gray(' Usage: natureco uninstall [run|dry-run]\n'));
27
+ } catch (err) {
28
+ console.log(chalk.red(`\n Uninstall error: ${err.message}\n`));
29
+ }
30
+ }
31
+
32
+ function cmdDryRun() {
33
+ console.log(chalk.cyan('\n Uninstall — Dry Run\n'));
34
+ console.log(chalk.gray(' Would remove:\n'));
35
+
36
+ if (fs.existsSync(BASE_DIR)) {
37
+ console.log(chalk.gray(' • ') + chalk.white('~/.natureco/') + chalk.gray(' — all config and data'));
38
+ } else {
39
+ console.log(chalk.gray(' • ') + chalk.white('~/.natureco/') + chalk.gray(' — not found'));
40
+ }
41
+
42
+ console.log(chalk.gray('') + chalk.white('npm uninstall -g natureco-cli'));
43
+ console.log(chalk.gray(' • ') + chalk.white('Remove global symlink\n'));
44
+ }
45
+
46
+ async function cmdRun() {
47
+ console.log(chalk.cyan('\n Uninstall NatureCo\n'));
48
+
49
+ const answer = await rlQuestion(chalk.red(' This will remove all NatureCo data. Continue? [y/N]: '));
50
+ if (answer !== 'y' && answer !== 'yes') {
51
+ console.log(chalk.gray('\n Cancelled.\n'));
52
+ return;
53
+ }
54
+
55
+ if (fs.existsSync(BASE_DIR)) {
56
+ console.log(chalk.gray(' Removing ~/.natureco/...'));
57
+ fs.rmSync(BASE_DIR, { recursive: true, force: true });
58
+ console.log(chalk.green(' ✓ Removed ~/.natureco/'));
59
+ }
60
+
61
+ console.log(chalk.gray(' Uninstalling global package...'));
62
+ try {
63
+ execSync('npm uninstall -g natureco-cli', { stdio: 'inherit' });
64
+ console.log(chalk.green(' ✓ Global package uninstalled'));
65
+ } catch (e) {
66
+ console.log(chalk.yellow(' Could not uninstall package: ' + e.message));
67
+ console.log(chalk.gray(' Try manually: npm uninstall -g natureco-cli'));
68
+ }
69
+
70
+ console.log(chalk.green('\n Uninstall complete.\n'));
71
+ }
72
+
73
+ module.exports = uninstall;
@@ -1,91 +1,146 @@
1
- const chalk = require('chalk');
2
- const { execSync } = require('child_process');
3
- const semver = require('semver');
4
- const inquirer = require('../utils/inquirer-wrapper');
5
- const packageJson = require('../../package.json');
6
-
7
- async function update() {
8
- const currentVersion = packageJson.version;
9
-
10
- console.log(chalk.yellow('\n⏳ Güncelleme kontrol ediliyor...\n'));
11
-
12
- try {
13
- // npm registry'den en son versiyonu al
14
- const response = await fetch('https://registry.npmjs.org/natureco-cli/latest');
15
- const data = await response.json();
16
- const latestVersion = data.version;
17
-
18
- console.log(chalk.cyan('Mevcut versiyon:'), chalk.white(`v${currentVersion}`));
19
- console.log(chalk.cyan('En son versiyon:'), chalk.white(`v${latestVersion}`));
20
- console.log('');
21
-
22
- if (currentVersion === latestVersion) {
23
- console.log(chalk.green(`✅ Zaten güncel: v${currentVersion}\n`));
24
- return;
25
- }
26
-
27
- // Versiyon karşılaştırması
28
- const isNewer = semver.gt(latestVersion, currentVersion);
29
-
30
- if (isNewer) {
31
- console.log(chalk.green(`✅ Yeni versiyon mevcut: v${currentVersion} → v${latestVersion}\n`));
32
- console.log(chalk.gray('Güncellemek için:\n'));
33
- console.log(chalk.cyan(' npm install -g natureco-cli@latest --force\n'));
34
-
35
- // İsteğe bağlı otomatik güncelleme
36
- const { shouldUpdate } = await inquirer.prompt([
37
- {
38
- type: 'confirm',
39
- name: 'shouldUpdate',
40
- message: 'Şimdi güncellensin mi?',
41
- default: true,
42
- },
43
- ]);
44
-
45
- if (shouldUpdate) {
46
- console.log(chalk.yellow('\n⏳ Güncelleme yapılıyor...\n'));
47
-
48
- try {
49
- execSync('npm install -g natureco-cli@latest --force', {
50
- stdio: 'inherit',
51
- });
52
-
53
- console.log(chalk.green(`\n✅ Güncelleme tamamlandı! v${latestVersion}\n`));
54
- } catch (err) {
55
- console.log(chalk.red('\n Güncelleme başarısız oldu.\n'));
56
- console.log(chalk.gray('Manuel olarak güncellemek için:\n'));
57
- console.log(chalk.cyan(' npm install -g natureco-cli@latest --force\n'));
58
- }
59
- } else {
60
- console.log(chalk.gray('\nGüncelleme iptal edildi.\n'));
61
- }
62
- } else {
63
- console.log(chalk.green(`✅ Zaten güncel: v${currentVersion}\n`));
64
- }
65
- } catch (err) {
66
- // Fetch başarısız olursa fallback olarak npm view kullan
67
- try {
68
- const latestVersion = execSync('npm view natureco-cli version', {
69
- encoding: 'utf8',
70
- stdio: ['pipe', 'pipe', 'ignore'],
71
- }).trim();
72
-
73
- console.log(chalk.cyan('Mevcut versiyon:'), chalk.white(`v${currentVersion}`));
74
- console.log(chalk.cyan('En son versiyon:'), chalk.white(`v${latestVersion}`));
75
- console.log('');
76
-
77
- if (currentVersion === latestVersion) {
78
- console.log(chalk.green(`✅ Zaten güncel: v${currentVersion}\n`));
79
- } else {
80
- console.log(chalk.green(`✅ Yeni versiyon mevcut: v${currentVersion} → v${latestVersion}\n`));
81
- console.log(chalk.gray('Güncellemek için:\n'));
82
- console.log(chalk.cyan(' npm install -g natureco-cli@latest --force\n'));
83
- }
84
- } catch (fallbackErr) {
85
- console.log(chalk.gray('Güncelleme kontrolü yapılamadı.\n'));
86
- console.log(chalk.gray('İnternet bağlantınızı kontrol edin.\n'));
87
- }
88
- }
89
- }
90
-
91
- module.exports = update;
1
+ const chalk = require('chalk');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
5
+ const { execSync } = require('child_process');
6
+ const readline = require('readline');
7
+
8
+ const VERSION_FILE = path.join(os.homedir(), '.natureco', 'version.json');
9
+
10
+ function rlQuestion(query) {
11
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
12
+ return new Promise(resolve => {
13
+ rl.question(query, answer => { rl.close(); resolve(answer.trim().toLowerCase()); });
14
+ });
15
+ }
16
+
17
+ function loadVersion() {
18
+ if (!fs.existsSync(VERSION_FILE)) return { installed: null, checked: null };
19
+ try { return JSON.parse(fs.readFileSync(VERSION_FILE, 'utf8')); }
20
+ catch { return { installed: null, checked: null }; }
21
+ }
22
+
23
+ function saveVersion(data) {
24
+ const dir = path.dirname(VERSION_FILE);
25
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
26
+ fs.writeFileSync(VERSION_FILE, JSON.stringify(data, null, 2), 'utf8');
27
+ }
28
+
29
+ function getCurrentVersion() {
30
+ try {
31
+ const pkg = require('../../package.json');
32
+ return pkg.version;
33
+ } catch {
34
+ return '0.0.0';
35
+ }
36
+ }
37
+
38
+ function getLatestVersion() {
39
+ try {
40
+ const result = execSync('npm view natureco-cli version', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
41
+ return result.trim();
42
+ } catch {
43
+ return null;
44
+ }
45
+ }
46
+
47
+ async function update(params) {
48
+ try {
49
+ const [action] = params || [];
50
+
51
+ if (!action || action === 'status') return cmdStatus();
52
+ if (action === 'run') return await cmdRun();
53
+ if (action === 'wizard') return await cmdWizard();
54
+
55
+ console.log(chalk.red(`\n Unknown update action: ${action}\n`));
56
+ console.log(chalk.gray(' Usage: natureco update [run|status|wizard]\n'));
57
+ } catch (err) {
58
+ console.log(chalk.red(`\n Update error: ${err.message}\n`));
59
+ }
60
+ }
61
+
62
+ function cmdStatus() {
63
+ const current = getCurrentVersion();
64
+ const latest = getLatestVersion();
65
+ const ver = loadVersion();
66
+
67
+ console.log(chalk.cyan('\n Update Status\n'));
68
+ console.log(chalk.white(' Installed: ') + chalk.cyan('v' + current));
69
+
70
+ if (latest) {
71
+ console.log(chalk.white(' Latest: ') + chalk.cyan('v' + latest));
72
+ if (current === latest) {
73
+ console.log(chalk.green(' You are up to date.\n'));
74
+ } else {
75
+ console.log(chalk.yellow(' Update available: v' + current + ' → v' + latest + '\n'));
76
+ }
77
+ } else {
78
+ console.log(chalk.gray(' Could not check latest version.\n'));
79
+ }
80
+
81
+ saveVersion({ installed: current, checked: new Date().toISOString(), latest: latest || ver.latest });
82
+ }
83
+
84
+ async function cmdRun() {
85
+ const current = getCurrentVersion();
86
+ const latest = getLatestVersion();
87
+
88
+ if (!latest) {
89
+ console.log(chalk.yellow('\n Could not fetch latest version. Check your internet connection.\n'));
90
+ return;
91
+ }
92
+
93
+ if (current === latest) {
94
+ console.log(chalk.green('\n Already up to date (v' + current + ').\n'));
95
+ return;
96
+ }
97
+
98
+ console.log(chalk.cyan('\n Updating: v' + current + ' → v' + latest + '\n'));
99
+
100
+ try {
101
+ execSync('npm update -g natureco-cli', { stdio: 'inherit' });
102
+ saveVersion({ installed: latest, updated: new Date().toISOString(), latest });
103
+ console.log(chalk.green('\n ✓ Updated to v' + latest + '\n'));
104
+ } catch (e) {
105
+ console.log(chalk.red('\n Update failed: ' + e.message + '\n'));
106
+ console.log(chalk.gray(' Try: npm install -g natureco-cli@latest\n'));
107
+ }
108
+ }
109
+
110
+ async function cmdWizard() {
111
+ const current = getCurrentVersion();
112
+ const latest = getLatestVersion();
113
+
114
+ console.log(chalk.cyan('\n Update Wizard\n'));
115
+
116
+ if (!latest) {
117
+ console.log(chalk.yellow(' Could not check for updates.\n'));
118
+ return;
119
+ }
120
+
121
+ console.log(chalk.white(' Current: v' + current));
122
+ console.log(chalk.white(' Latest: v' + latest));
123
+
124
+ if (current === latest) {
125
+ console.log(chalk.green('\n You are up to date!\n'));
126
+ return;
127
+ }
128
+
129
+ const answer = await rlQuestion(chalk.yellow(' Update to v' + latest + '? [Y/n]: '));
130
+ if (answer === 'n' || answer === 'no') {
131
+ console.log(chalk.gray('\n Skipped.\n'));
132
+ return;
133
+ }
134
+
135
+ console.log(chalk.gray('\n Installing...\n'));
136
+
137
+ try {
138
+ execSync('npm install -g natureco-cli@latest', { stdio: 'inherit' });
139
+ saveVersion({ installed: latest, updated: new Date().toISOString(), latest });
140
+ console.log(chalk.green('\n ✓ Updated to v' + latest + '\n'));
141
+ } catch (e) {
142
+ console.log(chalk.red('\n Update failed: ' + e.message + '\n'));
143
+ }
144
+ }
145
+
146
+ module.exports = update;
@@ -0,0 +1,34 @@
1
+ const { fetchAsMarkdown } = require('../utils/web-fetch');
2
+ const chalk = require('chalk');
3
+
4
+ async function webFetch(url) {
5
+ if (!url) {
6
+ console.log(chalk.yellow('\n Usage: natureco web-fetch <url>\n'));
7
+ console.log(chalk.gray(' Fetches a URL and converts it to clean markdown.\n'));
8
+ return;
9
+ }
10
+
11
+ console.log(chalk.gray(` Fetching: ${url}\n`));
12
+
13
+ const result = await fetchAsMarkdown(url);
14
+
15
+ if (result.error) {
16
+ console.log(chalk.red(` ❌ ${result.error}\n`));
17
+ return;
18
+ }
19
+
20
+ if (result.title) {
21
+ console.log(chalk.white(' Title: ') + chalk.cyan(result.title));
22
+ }
23
+ console.log(chalk.gray(` Source: ${result.url}`));
24
+ console.log(chalk.gray(` Fetched: ${result.fetchedAt}`));
25
+ console.log('');
26
+
27
+ if (result.content) {
28
+ console.log(result.content);
29
+ } else {
30
+ console.log(chalk.yellow(' No content extracted.\n'));
31
+ }
32
+ }
33
+
34
+ module.exports = webFetch;
@@ -1,79 +1,71 @@
1
1
  const chalk = require('chalk');
2
- const inquirer = require('../utils/inquirer-wrapper');
3
- const { getConfig, saveConfig } = require('../utils/config');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
4
5
 
5
- async function webhooks(action) {
6
- if (!action || action === 'connect') return connectWebhook();
7
- if (action === 'disconnect') return disconnectWebhook();
8
- if (action === 'status') return statusWebhooks();
9
- if (action === 'list') return listWebhooks();
10
- console.log(chalk.red('\n❌ Unknown action\n'));
11
- console.log(chalk.gray('Available actions: connect, disconnect, status, list\n'));
12
- process.exit(1);
6
+ const WEBHOOKS_FILE = path.join(os.homedir(), '.natureco', 'webhooks.json');
7
+
8
+ function loadWebhooks() {
9
+ if (!fs.existsSync(WEBHOOKS_FILE)) return [];
10
+ try { return JSON.parse(fs.readFileSync(WEBHOOKS_FILE, 'utf8')); }
11
+ catch { return []; }
13
12
  }
14
13
 
15
- async function connectWebhook() {
16
- const config = getConfig();
17
- if (!config.providerUrl) { console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n')); process.exit(1); }
18
- console.log(chalk.yellow('\n⏳ Webhook bağlantısı hazırlanıyor...\n'));
19
- console.log(chalk.gray('Gelen webhook\'lar NatureCo\'nun gateway\'ine yönlendirilir.\n'));
20
- const answers = await inquirer.prompt([
21
- { type: 'input', name: 'name', message: 'Webhook adı:', validate: v => v.trim() ? true : 'Gerekli' },
22
- { type: 'input', name: 'path', message: 'Webhook yolu (örn: /my-webhook):', validate: v => v.startsWith('/') ? true : 'Yol / ile başlamalı' },
23
- { type: 'input', name: 'secret', message: 'Webhook secret (opsiyonel):' },
24
- ]);
25
- const webhooks = config.webhooks || [];
26
- const entry = {
27
- id: `webhook_${Date.now()}`,
28
- name: answers.name.trim(),
29
- path: answers.path.trim(),
30
- secret: answers.secret.trim() || '',
31
- createdAt: new Date().toISOString(),
32
- };
33
- webhooks.push(entry);
34
- config.webhooks = webhooks;
35
- config.webhookEnabled = true;
36
- saveConfig(config);
37
- console.log(chalk.green('\n✅ Webhook eklendi!\n'));
38
- console.log(chalk.cyan('ID:'), chalk.white(entry.id));
39
- console.log(chalk.cyan('İsim:'), chalk.white(entry.name));
40
- console.log(chalk.cyan('Yol:'), chalk.white(entry.path));
41
- console.log(chalk.gray('\nGateway ile başlatmak için: natureco gateway start\n'));
14
+ function saveWebhooks(webhooks) {
15
+ const dir = path.dirname(WEBHOOKS_FILE);
16
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
17
+ fs.writeFileSync(WEBHOOKS_FILE, JSON.stringify(webhooks, null, 2), 'utf8');
18
+ }
19
+
20
+ function webhooks(args) {
21
+ const [action, subAction, ...params] = args || [];
22
+
23
+ if (!action || action === 'list') return cmdList();
24
+ if (action === 'gmail' && subAction === 'setup') return cmdGmailSetup();
25
+ if (action === 'gmail' && subAction === 'run') return cmdGmailRun();
26
+
27
+ console.log(chalk.red(`\n Unknown webhooks action: ${action} ${subAction || ''}\n`));
28
+ console.log(chalk.gray(' Usage: natureco webhooks <action> [params]'));
29
+ console.log(chalk.gray(' Actions: list, gmail setup, gmail run\n'));
30
+ process.exit(1);
42
31
  }
43
32
 
44
- async function disconnectWebhook() {
45
- const config = getConfig();
46
- const webhooks = config.webhooks || [];
47
- if (webhooks.length === 0) { console.log(chalk.gray('\n⚠️ No webhooks configured\n')); return; }
48
- const { confirm } = await inquirer.prompt([{ type: 'confirm', name: 'confirm', message: 'Tüm webhook\'ları kaldırmak istediğinize emin misiniz?', default: false }]);
49
- if (!confirm) { console.log(chalk.gray('\nCancelled\n')); return; }
50
- delete config.webhooks;
51
- delete config.webhookEnabled;
52
- saveConfig(config);
53
- console.log(chalk.green('\n✅ All webhooks removed\n'));
33
+ function cmdList() {
34
+ const webhooks = loadWebhooks();
35
+
36
+ console.log(chalk.cyan(`\n Webhooks (${webhooks.length})\n`));
37
+ console.log(chalk.gray(' ' + ''.repeat(48)));
38
+
39
+ if (webhooks.length === 0) {
40
+ console.log(chalk.gray(' No webhooks configured.\n'));
41
+ return;
42
+ }
43
+
44
+ for (const w of webhooks) {
45
+ console.log(` ${chalk.white(w.name || w.id || 'unnamed')}`);
46
+ if (w.url) console.log(chalk.gray(` URL: ${w.url}`));
47
+ if (w.path) console.log(chalk.gray(` Path: ${w.path}`));
48
+ if (w.type) console.log(chalk.gray(` Type: ${w.type}`));
49
+ }
50
+ console.log('');
54
51
  }
55
52
 
56
- function listWebhooks() {
57
- const config = getConfig();
58
- const webhooks = config.webhooks || [];
59
- if (webhooks.length === 0) { console.log(chalk.gray('\n⚠️ No webhooks configured\n')); return; }
60
- console.log(chalk.green(`\n✅ ${webhooks.length} webhook(s) configured\n`));
61
- webhooks.forEach(w => {
62
- console.log(chalk.cyan(' ID:'), chalk.white(w.id));
63
- console.log(chalk.cyan(' İsim:'), chalk.white(w.name));
64
- console.log(chalk.cyan(' Yol:'), chalk.white(w.path));
65
- if (w.secret) console.log(chalk.cyan(' Secret:'), chalk.gray('✓ ayarlı'));
66
- console.log('');
67
- });
53
+ function cmdGmailSetup() {
54
+ console.log(chalk.cyan('\n Gmail Pub/Sub Webhook Setup\n'));
55
+ console.log(chalk.gray(' ' + '─'.repeat(48)));
56
+ console.log(` ${chalk.white('Status:')} ${chalk.yellow('Not configured')}`);
57
+ console.log('');
58
+ console.log(chalk.gray(' To set up Gmail webhooks:'));
59
+ console.log(chalk.gray(' 1. Enable Gmail API in Google Cloud Console'));
60
+ console.log(chalk.gray(' 2. Create a Pub/Sub topic'));
61
+ console.log(chalk.gray(' 3. Configure the push endpoint'));
62
+ console.log(chalk.gray(' 4. Run: natureco webhooks gmail run'));
63
+ console.log('');
68
64
  }
69
65
 
70
- function statusWebhooks() {
71
- const config = getConfig();
72
- const webhooks = config.webhooks || [];
73
- if (webhooks.length === 0) { console.log(chalk.gray('\n⚠️ No webhooks configured\n')); console.log(chalk.gray('Add with: natureco webhooks connect\n')); return; }
74
- console.log(chalk.green(`\n✅ Webhooks active (${webhooks.length} route(s))\n`));
75
- webhooks.forEach(w => console.log(chalk.white(` ${w.path} → ${w.name}`)));
76
- console.log(chalk.gray('\nDisconnect with: natureco webhooks disconnect\n'));
66
+ function cmdGmailRun() {
67
+ console.log(chalk.cyan('\n Triggering Gmail Webhook\n'));
68
+ console.log(chalk.gray(' (Stub Gmail webhook execution not implemented)\n'));
77
69
  }
78
70
 
79
71
  module.exports = webhooks;