natureco-cli 1.0.21 → 1.0.23
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/README.md +130 -322
- package/package.json +3 -1
- package/src/commands/whatsapp.js +134 -34
package/README.md
CHANGED
|
@@ -1,386 +1,194 @@
|
|
|
1
1
|
# NatureCo CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/natureco-cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[]()
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Terminal-native AI agent CLI — chat with your bots, automate workflows, and connect Telegram, Discord, Slack & more. A powerful alternative to Claude Code & OpenClaw.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
**Mac/Linux:**
|
|
10
|
-
```bash
|
|
11
|
-
curl -fsSL https://natureco.me/install.sh | bash
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
**Windows (PowerShell):**
|
|
15
|
-
```powershell
|
|
16
|
-
iwr -useb https://natureco.me/install.ps1 | iex
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Manuel Kurulum
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install -g natureco-cli
|
|
23
|
-
```
|
|
9
|
+
## Features
|
|
24
10
|
|
|
25
|
-
**
|
|
26
|
-
-
|
|
11
|
+
- **Terminal-Native Chat** — Interactive conversations with your AI bots directly from the command line with full context awareness
|
|
12
|
+
- **Multi-Platform Integration** — Connect Telegram, Discord, Slack, and WhatsApp bots with simple commands and QR code authentication
|
|
13
|
+
- **Skill System** — Extend bot capabilities with NatureHub and ClawHub skills (thousands of pre-built skills available)
|
|
14
|
+
- **MCP Support** — Integrate Model Context Protocol servers for filesystem, GitHub, databases, and custom tools
|
|
15
|
+
- **AI-Powered Git** — Automated code review, intelligent commit messages, and PR generation with context-aware analysis
|
|
16
|
+
- **Web Dashboard** — Beautiful glassmorphism UI at localhost:3848 for browser-based chat and bot management
|
|
17
|
+
- **WebSocket Gateway** — Real-time bidirectional communication server for custom integrations and live updates
|
|
18
|
+
- **Automation Tools** — Schedule cron jobs, create hooks, and build custom commands for workflow automation
|
|
19
|
+
- **Code Analysis** — Deep code review with security, performance, and quality scoring via ultrareview command
|
|
20
|
+
- **System Health** — Built-in doctor command checks Node.js, API keys, integrations, and auto-fixes common issues
|
|
27
21
|
|
|
28
22
|
## Quick Start
|
|
29
23
|
|
|
30
24
|
```bash
|
|
31
|
-
#
|
|
32
|
-
natureco
|
|
25
|
+
# Install globally
|
|
26
|
+
npm install -g natureco-cli
|
|
33
27
|
|
|
34
|
-
#
|
|
35
|
-
natureco
|
|
28
|
+
# Login with your API key
|
|
29
|
+
natureco login
|
|
36
30
|
|
|
37
31
|
# Start chatting
|
|
38
|
-
natureco chat
|
|
32
|
+
natureco chat
|
|
39
33
|
```
|
|
40
34
|
|
|
41
|
-
The first time you run `natureco`, it will automatically guide you through the setup process:
|
|
42
|
-
1. Create `~/.natureco/` directory
|
|
43
|
-
2. Enter and validate your API key
|
|
44
|
-
3. Select your default bot
|
|
45
|
-
4. Optionally connect Telegram
|
|
46
|
-
|
|
47
35
|
## Commands
|
|
48
36
|
|
|
49
|
-
###
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
natureco
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
natureco
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
### Temel Komutlar
|
|
38
|
+
|
|
39
|
+
| Komut | Açıklama |
|
|
40
|
+
|-------|----------|
|
|
41
|
+
| `natureco` | Gateway ekranını açar — sistem durumu, aktif bot, skill sayısı |
|
|
42
|
+
| `natureco setup` | Kurulum sihirbazını başlatır — API key, bot seç, Telegram/Discord bağla |
|
|
43
|
+
| `natureco login` | API key ile giriş yapar, config'e kaydeder |
|
|
44
|
+
| `natureco logout` | Çıkış yapar, config'i temizler |
|
|
45
|
+
| `natureco help` | Tüm komutları ve örnekleri listeler |
|
|
46
|
+
| `natureco doctor` | Sistem sağlık kontrolü — Node, API key, bot, skill, entegrasyon durumu |
|
|
47
|
+
| `natureco doctor --fix` | Sorunları otomatik onarır — güncellemeleri yükler, config'i yeniler |
|
|
48
|
+
| `natureco update` | Yeni versiyon var mı kontrol eder |
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
# Login
|
|
63
|
-
natureco login
|
|
50
|
+
### Sohbet
|
|
64
51
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
| Komut | Açıklama |
|
|
53
|
+
|-------|----------|
|
|
54
|
+
| `natureco chat` | Varsayılan botla interaktif sohbet başlatır |
|
|
55
|
+
| `natureco chat "Bot Adı"` | Belirli bir botla sohbet başlatır |
|
|
56
|
+
| `natureco chat --resume` | En son oturuma devam eder |
|
|
57
|
+
| `natureco ask "soru"` | Tek seferlik soru sorar, cevap alır, çıkar |
|
|
58
|
+
| `natureco run script.md` | Markdown dosyasını bota prompt olarak gönderir |
|
|
59
|
+
| `natureco bots` | Tüm botlarınızı listeler (ID, provider, durum) |
|
|
68
60
|
|
|
69
|
-
|
|
61
|
+
**Chat İçi Komutlar:**
|
|
70
62
|
|
|
71
|
-
|
|
63
|
+
| Komut | Açıklama |
|
|
64
|
+
|-------|----------|
|
|
65
|
+
| `/clear` | Ekranı temizler |
|
|
66
|
+
| `/bot` | Bot listesini gösterir veya bot değiştirir |
|
|
67
|
+
| `/skills` | Aktif skill'leri gösterir |
|
|
68
|
+
| `/memory` | Hafıza durumunu gösterir |
|
|
69
|
+
| `/commands` | Özel komutları listeler |
|
|
70
|
+
| `/help` | Chat yardımını gösterir |
|
|
71
|
+
| `exit` veya `quit` | Sohbetten çıkar |
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
# List your bots
|
|
75
|
-
natureco bots
|
|
76
|
-
```
|
|
73
|
+
### Skill Sistemi
|
|
77
74
|
|
|
78
|
-
|
|
75
|
+
| Komut | Açıklama |
|
|
76
|
+
|-------|----------|
|
|
77
|
+
| `natureco skills` | Yüklü skill'leri listeler (kaynak, açıklama) |
|
|
78
|
+
| `natureco skills install slug` | NatureHub'dan skill yükler |
|
|
79
|
+
| `natureco skills install clawhub:slug` | ClawHub'dan skill yükler (binlerce skill) |
|
|
80
|
+
| `natureco skills browse` | Popüler skill listesini gösterir, interaktif seçim |
|
|
81
|
+
| `natureco skills search "sorgu"` | Skill arar |
|
|
82
|
+
| `natureco skills remove slug` | Skill'i kaldırır |
|
|
83
|
+
| `natureco skills create ad` | Yeni skill şablonu oluşturur |
|
|
79
84
|
|
|
80
|
-
|
|
81
|
-
# Start interactive chat
|
|
82
|
-
natureco chat "Bot Name"
|
|
83
|
-
```
|
|
85
|
+
### Entegrasyonlar
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
- `↑` `↓` - Navigate command history
|
|
87
|
+
| Komut | Açıklama |
|
|
88
|
+
|-------|----------|
|
|
89
|
+
| `natureco telegram connect` | Telegram botunu bağlar (token + kullanıcı ID) |
|
|
90
|
+
| `natureco discord connect` | Discord botunu bağlar |
|
|
91
|
+
| `natureco slack connect` | Slack workspace'ine bağlanır |
|
|
92
|
+
| `natureco whatsapp connect` | WhatsApp'ı QR kod ile bağlar |
|
|
92
93
|
|
|
93
|
-
###
|
|
94
|
+
### MCP Sunucuları
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
natureco
|
|
96
|
+
| Komut | Açıklama |
|
|
97
|
+
|-------|----------|
|
|
98
|
+
| `natureco mcp list` | Bağlı MCP sunucularını listeler |
|
|
99
|
+
| `natureco mcp add` | MCP sunucu ekler (filesystem, github, postgres...) |
|
|
100
|
+
| `natureco mcp templates` | Hazır MCP şablonlarını listeler |
|
|
98
101
|
|
|
99
|
-
|
|
100
|
-
echo "Summarize this file" | natureco ask
|
|
101
|
-
```
|
|
102
|
+
### Otomasyon
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
| Komut | Açıklama |
|
|
105
|
+
|-------|----------|
|
|
106
|
+
| `natureco ultrareview dosya.js` | Kodu derinlemesine inceler — güvenlik, performans, kalite puanlar |
|
|
107
|
+
| `natureco git review` | Staged değişiklikleri bota inceletir |
|
|
108
|
+
| `natureco git commit` | AI ile commit mesajı üretir ve commit atar |
|
|
109
|
+
| `natureco cron add` | Zamanlanmış görev oluşturur (her gün, her X saatte) |
|
|
110
|
+
| `natureco cron list` | Cron görevlerini listeler |
|
|
111
|
+
| `natureco cron start` | Cron daemon'unu başlatır |
|
|
112
|
+
| `natureco cron stop` | Cron daemon'unu durdurur |
|
|
113
|
+
| `natureco hooks create tip` | Hook oluşturur (pre-message, post-message, on-start...) |
|
|
114
|
+
| `natureco commands create ad` | Özel /komut oluşturur (chat'te /ad ile kullan) |
|
|
104
115
|
|
|
105
|
-
|
|
106
|
-
# Run markdown script
|
|
107
|
-
natureco run script.md
|
|
108
|
-
```
|
|
116
|
+
### Arayüz & Sunucular
|
|
109
117
|
|
|
110
|
-
|
|
118
|
+
| Komut | Açıklama |
|
|
119
|
+
|-------|----------|
|
|
120
|
+
| `natureco dashboard` | Web arayüzünü açar (localhost:3848) — tarayıcıda chat |
|
|
121
|
+
| `natureco dashboard stop` | Dashboard'u durdurur |
|
|
122
|
+
| `natureco dashboard status` | Dashboard durumunu kontrol eder |
|
|
123
|
+
| `natureco gateway start` | WebSocket sunucusunu başlatır (ws://localhost:3847) |
|
|
124
|
+
| `natureco gateway stop` | Gateway'i durdurur |
|
|
125
|
+
| `natureco gateway status` | Gateway durumunu kontrol eder |
|
|
126
|
+
| `natureco config list` | Tüm ayarları gösterir |
|
|
127
|
+
| `natureco config set key val` | Ayar değiştirir (örn: defaultBot, theme) |
|
|
128
|
+
| `natureco init` | Mevcut klasörde .natureco/ proje klasörü oluşturur |
|
|
111
129
|
|
|
112
|
-
|
|
113
|
-
# Initialize NatureCo project
|
|
114
|
-
natureco init
|
|
115
|
-
```
|
|
130
|
+
## Integrations
|
|
116
131
|
|
|
117
|
-
|
|
118
|
-
- `.natureco/config.json` - Project configuration
|
|
119
|
-
- `.natureco/AGENTS.md` - Bot instructions
|
|
120
|
-
- `.natureco/skills/` - Project-specific skills
|
|
132
|
+
### Telegram
|
|
121
133
|
|
|
122
|
-
|
|
134
|
+
Connect your Telegram bot to receive and respond to messages directly through NatureCo. Supports both bot token and user ID authentication.
|
|
123
135
|
|
|
124
136
|
```bash
|
|
125
|
-
|
|
126
|
-
natureco skills
|
|
127
|
-
|
|
128
|
-
# Install skill from NatureHub
|
|
129
|
-
natureco skills install code-review
|
|
130
|
-
|
|
131
|
-
# Remove skill
|
|
132
|
-
natureco skills remove code-review
|
|
133
|
-
|
|
134
|
-
# Update all skills
|
|
135
|
-
natureco skills update --all
|
|
136
|
-
|
|
137
|
-
# Create new skill
|
|
138
|
-
natureco skills create my-skill
|
|
137
|
+
natureco telegram connect
|
|
139
138
|
```
|
|
140
139
|
|
|
141
|
-
|
|
142
|
-
1. `.natureco/skills/` - Project skills
|
|
143
|
-
2. `~/.natureco/skills/` - User skills
|
|
144
|
-
3. Built-in skills (code-review, summarize, translate)
|
|
145
|
-
|
|
146
|
-
### Configuration
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
# List all config
|
|
150
|
-
natureco config list
|
|
151
|
-
|
|
152
|
-
# Get value
|
|
153
|
-
natureco config get defaultBot
|
|
140
|
+
### Discord
|
|
154
141
|
|
|
155
|
-
|
|
156
|
-
natureco config set defaultBotId <bot-id>
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### MCP Servers
|
|
142
|
+
Integrate Discord bots with full support for server channels, DMs, and slash commands. Seamless setup with OAuth2 flow.
|
|
160
143
|
|
|
161
144
|
```bash
|
|
162
|
-
|
|
163
|
-
natureco mcp list
|
|
164
|
-
|
|
165
|
-
# Show available templates
|
|
166
|
-
natureco mcp templates
|
|
167
|
-
|
|
168
|
-
# Add MCP server (interactive)
|
|
169
|
-
natureco mcp add
|
|
170
|
-
|
|
171
|
-
# Add with specific name
|
|
172
|
-
natureco mcp add my-server
|
|
173
|
-
|
|
174
|
-
# Remove MCP server
|
|
175
|
-
natureco mcp remove my-server
|
|
176
|
-
|
|
177
|
-
# Test connection
|
|
178
|
-
natureco mcp test my-server
|
|
179
|
-
|
|
180
|
-
# Enable/disable server
|
|
181
|
-
natureco mcp enable my-server
|
|
182
|
-
natureco mcp disable my-server
|
|
145
|
+
natureco discord connect
|
|
183
146
|
```
|
|
184
147
|
|
|
185
|
-
|
|
186
|
-
- `filesystem` - File system operations (read, write, list)
|
|
187
|
-
- `github` - GitHub operations (issues, PRs, commits)
|
|
188
|
-
- `postgres` - PostgreSQL database operations
|
|
189
|
-
- `sqlite` - SQLite database operations
|
|
190
|
-
- `brave-search` - Web search using Brave Search API
|
|
148
|
+
### Slack
|
|
191
149
|
|
|
192
|
-
|
|
150
|
+
Connect to Slack workspaces and enable bot interactions in channels and direct messages. Supports Slack App authentication.
|
|
193
151
|
|
|
194
152
|
```bash
|
|
195
|
-
|
|
196
|
-
natureco update
|
|
153
|
+
natureco slack connect
|
|
197
154
|
```
|
|
198
155
|
|
|
199
|
-
|
|
156
|
+
### WhatsApp
|
|
200
157
|
|
|
201
|
-
|
|
158
|
+
Link WhatsApp accounts using QR code authentication. Send and receive messages through your AI bot with full media support.
|
|
202
159
|
|
|
203
160
|
```bash
|
|
204
|
-
natureco
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Features
|
|
208
|
-
|
|
209
|
-
### 🎯 First-Time Setup Wizard
|
|
210
|
-
- Automatic setup on first run
|
|
211
|
-
- Interactive API key validation
|
|
212
|
-
- Bot selection
|
|
213
|
-
- Optional Telegram integration
|
|
214
|
-
- Creates `~/.natureco/` directory structure
|
|
215
|
-
|
|
216
|
-
### 🔐 Secure Authentication
|
|
217
|
-
- API key stored in `~/.natureco/config.json`
|
|
218
|
-
- Supports both `nco_` and `nc_` key formats
|
|
219
|
-
|
|
220
|
-
### 🤖 Interactive Chat
|
|
221
|
-
- Real-time conversation with AI bots
|
|
222
|
-
- Command history with arrow keys
|
|
223
|
-
- In-chat commands (/clear, /bot, /skills, /help)
|
|
224
|
-
- Conversation history saved to `~/.natureco/history/`
|
|
225
|
-
|
|
226
|
-
### 🎯 Skills System
|
|
227
|
-
- Three-tier skill hierarchy (builtin/user/project)
|
|
228
|
-
- Automatic skill prompt injection
|
|
229
|
-
- Requirement gating (bins, env vars, OS platform)
|
|
230
|
-
- Install from NatureHub
|
|
231
|
-
|
|
232
|
-
### 📝 Project Context
|
|
233
|
-
- AGENTS.md for project-specific instructions
|
|
234
|
-
- Automatic prompt injection in chat
|
|
235
|
-
- Per-project configuration
|
|
236
|
-
|
|
237
|
-
### 🔌 MCP Server Support
|
|
238
|
-
- Manage MCP servers from CLI
|
|
239
|
-
- 5 ready-to-use templates (filesystem, github, postgres, sqlite, brave-search)
|
|
240
|
-
- Test connections before use
|
|
241
|
-
- Enable/disable servers
|
|
242
|
-
- Config stored in `~/.natureco/config.json`
|
|
243
|
-
|
|
244
|
-
### 🔄 Auto-Update Notifications
|
|
245
|
-
- Automatic update check every 24 hours
|
|
246
|
-
- Manual update check with `natureco update`
|
|
247
|
-
- Notifies when new version is available
|
|
248
|
-
|
|
249
|
-
### 🎨 Beautiful UI
|
|
250
|
-
- Colorful terminal interface with chalk
|
|
251
|
-
- Loading animations with spinners
|
|
252
|
-
- Boxed gateway screen
|
|
253
|
-
- Monospace formatting
|
|
254
|
-
|
|
255
|
-
### 🌍 Cross-Platform
|
|
256
|
-
- Windows, macOS, Linux support
|
|
257
|
-
- PowerShell and Bash compatible
|
|
258
|
-
- Native Node.js fetch (no dependencies)
|
|
259
|
-
|
|
260
|
-
## File Structure
|
|
261
|
-
|
|
262
|
-
```
|
|
263
|
-
~/.natureco/
|
|
264
|
-
├── config.json # Global config (includes mcpServers)
|
|
265
|
-
├── skills/ # User skills
|
|
266
|
-
└── history/ # Chat history
|
|
267
|
-
└── <bot-id>.json
|
|
268
|
-
|
|
269
|
-
.natureco/ # Project folder
|
|
270
|
-
├── config.json # Project config
|
|
271
|
-
├── AGENTS.md # Bot instructions
|
|
272
|
-
└── skills/ # Project skills
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## Skill Format
|
|
276
|
-
|
|
277
|
-
Skills are defined in `SKILL.md` files:
|
|
278
|
-
|
|
279
|
-
```markdown
|
|
280
|
-
---
|
|
281
|
-
name: code-review
|
|
282
|
-
description: Code review and suggestions
|
|
283
|
-
metadata: {"natureco": {"requires": {"bins": ["node"]}, "os": ["win32","darwin","linux"]}}
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
# Code Review Skill
|
|
287
|
-
|
|
288
|
-
This skill performs code review...
|
|
161
|
+
natureco whatsapp connect
|
|
289
162
|
```
|
|
290
163
|
|
|
291
|
-
##
|
|
292
|
-
|
|
293
|
-
```json
|
|
294
|
-
{
|
|
295
|
-
"apiKey": "nc_...",
|
|
296
|
-
"defaultBot": "Nature Bot V3",
|
|
297
|
-
"defaultBotId": "uuid",
|
|
298
|
-
"skills": {
|
|
299
|
-
"enabled": true,
|
|
300
|
-
"list": ["code-review", "summarize"]
|
|
301
|
-
},
|
|
302
|
-
"mcpServers": {
|
|
303
|
-
"filesystem": {
|
|
304
|
-
"command": "npx",
|
|
305
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
|
|
306
|
-
"env": {},
|
|
307
|
-
"disabled": false,
|
|
308
|
-
"autoApprove": []
|
|
309
|
-
},
|
|
310
|
-
"github": {
|
|
311
|
-
"command": "npx",
|
|
312
|
-
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
313
|
-
"env": {
|
|
314
|
-
"GITHUB_TOKEN": "ghp_..."
|
|
315
|
-
},
|
|
316
|
-
"disabled": false,
|
|
317
|
-
"autoApprove": []
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
## API Endpoints
|
|
324
|
-
|
|
325
|
-
- Base URL: `https://api.natureco.me`
|
|
326
|
-
- Bots: `GET /api/v1/bots`
|
|
327
|
-
- Chat: `POST /api/agent/chat`
|
|
164
|
+
## Dashboard
|
|
328
165
|
|
|
329
|
-
|
|
166
|
+
Launch a beautiful web interface at `localhost:3848` with glassmorphism design and dark mode. Features include:
|
|
330
167
|
|
|
331
|
-
-
|
|
332
|
-
|
|
333
|
-
|
|
168
|
+
- Real-time chat with all your bots
|
|
169
|
+
- Bot switching and configuration
|
|
170
|
+
- Skill and MCP management
|
|
171
|
+
- Live system stats and health monitoring
|
|
172
|
+
- Responsive design for desktop and mobile
|
|
334
173
|
|
|
335
174
|
```bash
|
|
336
|
-
|
|
337
|
-
natureco
|
|
338
|
-
# Follow the interactive setup wizard
|
|
339
|
-
|
|
340
|
-
# Quick question
|
|
341
|
-
natureco ask "List my tasks for this week"
|
|
342
|
-
|
|
343
|
-
# Run a script
|
|
344
|
-
natureco run deploy-checklist.md
|
|
345
|
-
|
|
346
|
-
# Chat with bot switching
|
|
347
|
-
natureco chat "Nature Bot V3"
|
|
348
|
-
# In chat: /bot "Code Assistant"
|
|
349
|
-
|
|
350
|
-
# Install and use skills
|
|
351
|
-
natureco skills install code-review
|
|
352
|
-
natureco chat "Nature Bot V3"
|
|
353
|
-
# Skills are automatically injected
|
|
354
|
-
|
|
355
|
-
# Add MCP server
|
|
356
|
-
natureco mcp add
|
|
357
|
-
# Select template: filesystem
|
|
358
|
-
# MCP server added
|
|
359
|
-
|
|
360
|
-
# Test MCP connection
|
|
361
|
-
natureco mcp test filesystem
|
|
362
|
-
|
|
363
|
-
# List all MCP servers
|
|
364
|
-
natureco mcp list
|
|
175
|
+
natureco dashboard
|
|
365
176
|
```
|
|
366
177
|
|
|
367
|
-
|
|
178
|
+

|
|
368
179
|
|
|
369
|
-
|
|
370
|
-
Run `natureco login` and enter your API key.
|
|
180
|
+
## Support
|
|
371
181
|
|
|
372
|
-
|
|
373
|
-
|
|
182
|
+
- **Documentation:** [natureco.me/docs](https://natureco.me/docs)
|
|
183
|
+
- **CLI Docs:** [natureco.me/cli](https://natureco.me/cli)
|
|
184
|
+
- **npm Package:** [npmjs.com/package/natureco-cli](https://www.npmjs.com/package/natureco-cli)
|
|
185
|
+
- **GitHub Issues:** [github.com/natureco/cli/issues](https://github.com/natureco/cli/issues)
|
|
186
|
+
- **API Reference:** [natureco.me/api](https://natureco.me/api)
|
|
374
187
|
|
|
375
|
-
|
|
376
|
-
Check skill requirements with `natureco skills` - ensure required binaries and env vars are available.
|
|
188
|
+
## License
|
|
377
189
|
|
|
378
|
-
|
|
379
|
-
- Check if `npx` is installed: `npx --version`
|
|
380
|
-
- Verify environment variables are set correctly
|
|
381
|
-
- Test connection: `natureco mcp test <server-name>`
|
|
382
|
-
- Check server logs in terminal output
|
|
190
|
+
MIT © NatureCo
|
|
383
191
|
|
|
384
|
-
|
|
192
|
+
---
|
|
385
193
|
|
|
386
|
-
|
|
194
|
+
**Version:** 1.0.21 | **Node.js:** >=18.0.0 | **Platform:** macOS, Windows, Linux
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "NatureCo AI Bot Terminal Interface",
|
|
5
5
|
"main": "bin/natureco.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
"chalk": "^4.1.2",
|
|
29
29
|
"commander": "^11.1.0",
|
|
30
30
|
"conf": "^10.2.0",
|
|
31
|
+
"eventsource": "^2.0.2",
|
|
31
32
|
"inquirer": "^8.2.7",
|
|
32
33
|
"node-cron": "^2.0.3",
|
|
33
34
|
"ora": "^5.4.1",
|
|
35
|
+
"qrcode-terminal": "^0.12.0",
|
|
34
36
|
"ws": "^8.20.0"
|
|
35
37
|
},
|
|
36
38
|
"engines": {
|
package/src/commands/whatsapp.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const inquirer = require('inquirer');
|
|
3
|
+
const qrcode = require('qrcode-terminal');
|
|
4
|
+
const EventSource = require('eventsource');
|
|
3
5
|
const { getApiKey, getConfig, saveConfig } = require('../utils/config');
|
|
4
6
|
const { getBots } = require('../utils/api');
|
|
5
7
|
|
|
@@ -61,17 +63,17 @@ async function connectWhatsApp() {
|
|
|
61
63
|
|
|
62
64
|
console.log(chalk.cyan('\n📱 WhatsApp bağlantısı QR kod ile yapılır.'));
|
|
63
65
|
console.log(chalk.gray('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n'));
|
|
64
|
-
console.log(chalk.yellow('⏳
|
|
66
|
+
console.log(chalk.yellow('⏳ Session oluşturuluyor...\n'));
|
|
65
67
|
|
|
66
68
|
try {
|
|
67
|
-
|
|
69
|
+
// Create WhatsApp session
|
|
70
|
+
const response = await fetch('http://localhost:3000/connect', {
|
|
68
71
|
method: 'POST',
|
|
69
72
|
headers: {
|
|
70
73
|
'Content-Type': 'application/json',
|
|
71
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
72
74
|
},
|
|
73
75
|
body: JSON.stringify({
|
|
74
|
-
|
|
76
|
+
bot_id: botId,
|
|
75
77
|
}),
|
|
76
78
|
});
|
|
77
79
|
|
|
@@ -82,37 +84,87 @@ async function connectWhatsApp() {
|
|
|
82
84
|
|
|
83
85
|
const data = await response.json();
|
|
84
86
|
|
|
85
|
-
if (data.
|
|
86
|
-
|
|
87
|
-
console.log(chalk.cyan('QR Kod:'));
|
|
88
|
-
console.log(data.qr_code);
|
|
89
|
-
console.log('');
|
|
90
|
-
|
|
91
|
-
if (data.qr_url) {
|
|
92
|
-
console.log(chalk.cyan('QR URL:'), chalk.white(data.qr_url));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
console.log(chalk.gray('\n1. WhatsApp\'ı açın'));
|
|
96
|
-
console.log(chalk.gray('2. Ayarlar > Bağlı Cihazlar > Cihaz Bağla'));
|
|
97
|
-
console.log(chalk.gray('3. Bu QR kodu taratın\n'));
|
|
98
|
-
} else if (data.connection_url) {
|
|
99
|
-
console.log(chalk.green('✅ Bağlantı linki hazır!\n'));
|
|
100
|
-
console.log(chalk.cyan('Bağlantı URL:'), chalk.white(data.connection_url));
|
|
101
|
-
console.log(chalk.gray('\nBu linki tarayıcıda açın ve QR kodu taratın.\n'));
|
|
102
|
-
} else {
|
|
103
|
-
console.log(chalk.green('✅ WhatsApp bağlantısı başlatıldı!\n'));
|
|
104
|
-
console.log(chalk.gray('Bağlantı durumunu kontrol edin: natureco whatsapp status\n'));
|
|
87
|
+
if (!data.session_id) {
|
|
88
|
+
throw new Error('No session ID returned');
|
|
105
89
|
}
|
|
106
90
|
|
|
107
|
-
|
|
91
|
+
console.log(chalk.green('✅ Session oluşturuldu!\n'));
|
|
92
|
+
console.log(chalk.cyan('Session ID:'), chalk.white(data.session_id));
|
|
93
|
+
console.log(chalk.yellow('\n⏳ QR kod bekleniyor...\n'));
|
|
94
|
+
|
|
95
|
+
// Save session ID to config
|
|
96
|
+
config.whatsappSessionId = data.session_id;
|
|
108
97
|
config.whatsappConnected = true;
|
|
109
98
|
config.whatsappBotId = botId;
|
|
110
99
|
saveConfig(config);
|
|
111
100
|
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
// Connect to SSE endpoint for QR code
|
|
102
|
+
const sseUrl = `http://localhost:3000/qr/${data.session_id}`;
|
|
103
|
+
const eventSource = new EventSource(sseUrl);
|
|
104
|
+
|
|
105
|
+
let qrDisplayed = false;
|
|
106
|
+
|
|
107
|
+
eventSource.onmessage = (event) => {
|
|
108
|
+
try {
|
|
109
|
+
const eventData = JSON.parse(event.data);
|
|
110
|
+
|
|
111
|
+
if (eventData.type === 'qr') {
|
|
112
|
+
if (!qrDisplayed) {
|
|
113
|
+
console.log(chalk.green('✅ QR kod hazır!\n'));
|
|
114
|
+
|
|
115
|
+
// Display QR code in terminal using the text version
|
|
116
|
+
if (eventData.qrText) {
|
|
117
|
+
qrcode.generate(eventData.qrText, { small: true });
|
|
118
|
+
} else if (eventData.qr) {
|
|
119
|
+
// Fallback: try to extract from base64 data URL
|
|
120
|
+
console.log(chalk.yellow('QR kod alındı (base64 format)\n'));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
console.log('');
|
|
124
|
+
console.log(chalk.gray('1. WhatsApp\'ı açın'));
|
|
125
|
+
console.log(chalk.gray('2. Ayarlar > Bağlı Cihazlar > Cihaz Bağla'));
|
|
126
|
+
console.log(chalk.gray('3. Bu QR kodu taratın\n'));
|
|
127
|
+
console.log(chalk.yellow('⏳ QR kod taranması bekleniyor...\n'));
|
|
128
|
+
|
|
129
|
+
qrDisplayed = true;
|
|
130
|
+
}
|
|
131
|
+
} else if (eventData.type === 'ready') {
|
|
132
|
+
console.log(chalk.green('✅ WhatsApp bağlandı!\n'));
|
|
133
|
+
console.log(chalk.cyan('Bot:'), chalk.white(selectedBot.name));
|
|
134
|
+
console.log(chalk.gray('Botunuz WhatsApp\'ta aktif.\n'));
|
|
135
|
+
eventSource.close();
|
|
136
|
+
process.exit(0);
|
|
137
|
+
} else if (eventData.type === 'error') {
|
|
138
|
+
console.log(chalk.red(`\n❌ Hata: ${eventData.error}\n`));
|
|
139
|
+
eventSource.close();
|
|
140
|
+
process.exit(1);
|
|
141
|
+
} else if (eventData.type === 'disconnected') {
|
|
142
|
+
console.log(chalk.yellow(`\n⚠️ Bağlantı kesildi: ${eventData.reason}\n`));
|
|
143
|
+
eventSource.close();
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
console.error(chalk.red('Event parse error:'), err.message);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
eventSource.onerror = (err) => {
|
|
152
|
+
console.log(chalk.red('\n❌ SSE connection error\n'));
|
|
153
|
+
console.log(chalk.gray('Make sure WhatsApp service is running on http://localhost:3000\n'));
|
|
154
|
+
eventSource.close();
|
|
155
|
+
process.exit(1);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Handle Ctrl+C
|
|
159
|
+
process.on('SIGINT', () => {
|
|
160
|
+
console.log(chalk.yellow('\n\n⚠️ Bağlantı iptal edildi\n'));
|
|
161
|
+
eventSource.close();
|
|
162
|
+
process.exit(0);
|
|
163
|
+
});
|
|
164
|
+
|
|
114
165
|
} catch (err) {
|
|
115
166
|
console.log(chalk.red(`\n❌ Connection failed: ${err.message}\n`));
|
|
167
|
+
console.log(chalk.gray('Make sure WhatsApp service is running on http://localhost:3000\n'));
|
|
116
168
|
process.exit(1);
|
|
117
169
|
}
|
|
118
170
|
}
|
|
@@ -143,18 +195,21 @@ async function disconnectWhatsApp() {
|
|
|
143
195
|
|
|
144
196
|
const apiKey = getApiKey();
|
|
145
197
|
|
|
146
|
-
if (apiKey && config.
|
|
198
|
+
if (apiKey && config.whatsappSessionId) {
|
|
147
199
|
try {
|
|
148
|
-
await fetch('
|
|
200
|
+
const response = await fetch('http://localhost:3000/disconnect', {
|
|
149
201
|
method: 'POST',
|
|
150
202
|
headers: {
|
|
151
203
|
'Content-Type': 'application/json',
|
|
152
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
153
204
|
},
|
|
154
205
|
body: JSON.stringify({
|
|
155
|
-
|
|
206
|
+
session_id: config.whatsappSessionId,
|
|
156
207
|
}),
|
|
157
208
|
});
|
|
209
|
+
|
|
210
|
+
if (response.ok) {
|
|
211
|
+
console.log(chalk.green('\n✅ WhatsApp session disconnected from server\n'));
|
|
212
|
+
}
|
|
158
213
|
} catch (err) {
|
|
159
214
|
console.log(chalk.yellow(`\n⚠️ API disconnect failed: ${err.message}`));
|
|
160
215
|
}
|
|
@@ -163,13 +218,14 @@ async function disconnectWhatsApp() {
|
|
|
163
218
|
// Remove from config
|
|
164
219
|
delete config.whatsappConnected;
|
|
165
220
|
delete config.whatsappBotId;
|
|
221
|
+
delete config.whatsappSessionId;
|
|
166
222
|
saveConfig(config);
|
|
167
223
|
|
|
168
|
-
console.log(chalk.green('
|
|
224
|
+
console.log(chalk.green('✅ WhatsApp disconnected locally\n'));
|
|
169
225
|
console.log(chalk.gray('Note: You may need to manually remove the device from WhatsApp settings.\n'));
|
|
170
226
|
}
|
|
171
227
|
|
|
172
|
-
function statusWhatsApp() {
|
|
228
|
+
async function statusWhatsApp() {
|
|
173
229
|
const config = getConfig();
|
|
174
230
|
|
|
175
231
|
if (!config.whatsappConnected) {
|
|
@@ -178,12 +234,56 @@ function statusWhatsApp() {
|
|
|
178
234
|
return;
|
|
179
235
|
}
|
|
180
236
|
|
|
181
|
-
|
|
237
|
+
const apiKey = getApiKey();
|
|
238
|
+
|
|
239
|
+
// Try to get status from API if session ID exists
|
|
240
|
+
if (apiKey && config.whatsappSessionId) {
|
|
241
|
+
try {
|
|
242
|
+
console.log(chalk.yellow('\n⏳ Checking connection status...\n'));
|
|
243
|
+
|
|
244
|
+
const response = await fetch(`http://localhost:3000/status/${config.whatsappSessionId}`, {
|
|
245
|
+
method: 'GET',
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
if (response.ok) {
|
|
249
|
+
const data = await response.json();
|
|
250
|
+
|
|
251
|
+
if (data.status === 'connected') {
|
|
252
|
+
console.log(chalk.green('✅ WhatsApp connected\n'));
|
|
253
|
+
} else if (data.status === 'pending') {
|
|
254
|
+
console.log(chalk.yellow('⏳ WhatsApp connection pending\n'));
|
|
255
|
+
console.log(chalk.gray('Waiting for QR code scan...\n'));
|
|
256
|
+
} else {
|
|
257
|
+
console.log(chalk.red('❌ WhatsApp disconnected\n'));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
console.log(chalk.cyan('Session ID:'), chalk.white(data.session_id));
|
|
261
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(data.bot_id));
|
|
262
|
+
console.log(chalk.cyan('Created:'), chalk.white(data.created_at));
|
|
263
|
+
|
|
264
|
+
if (data.connected_at) {
|
|
265
|
+
console.log(chalk.cyan('Connected:'), chalk.white(data.connected_at));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
console.log('');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
} catch (err) {
|
|
272
|
+
console.log(chalk.yellow(`⚠️ Could not fetch status: ${err.message}\n`));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Fallback to local config
|
|
277
|
+
console.log(chalk.green('\n✅ WhatsApp connected (local)\n'));
|
|
182
278
|
|
|
183
279
|
if (config.whatsappBotId) {
|
|
184
280
|
console.log(chalk.cyan('Bot ID:'), chalk.white(config.whatsappBotId));
|
|
185
281
|
}
|
|
186
282
|
|
|
283
|
+
if (config.whatsappSessionId) {
|
|
284
|
+
console.log(chalk.cyan('Session ID:'), chalk.white(config.whatsappSessionId));
|
|
285
|
+
}
|
|
286
|
+
|
|
187
287
|
console.log(chalk.gray('\nDisconnect with: natureco whatsapp disconnect\n'));
|
|
188
288
|
}
|
|
189
289
|
|