natureco-cli 2.12.3 → 2.12.5
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 +1 -1
- package/src/commands/cron.js +13 -1
- package/src/commands/dashboard.js +2 -2
- package/src/commands/migrate.js +35 -7
package/package.json
CHANGED
package/src/commands/cron.js
CHANGED
|
@@ -113,12 +113,24 @@ function listCrons() {
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// Load config for fallback targets
|
|
117
|
+
const { getConfig } = require('../utils/config');
|
|
118
|
+
const config = getConfig();
|
|
119
|
+
const defaultWhatsappTarget = config.whatsappPhone || 'N/A';
|
|
120
|
+
const defaultTelegramTarget = (config.telegramAllowedChats && config.telegramAllowedChats[0]) || 'N/A';
|
|
121
|
+
|
|
116
122
|
console.log(chalk.green(`\n📅 Kayıtlı Cron'lar (${crons.length})\n`));
|
|
117
123
|
|
|
118
124
|
crons.forEach((c, i) => {
|
|
125
|
+
// Use target from cron or fallback to config
|
|
126
|
+
let target = c.target;
|
|
127
|
+
if (!target || target === 'undefined') {
|
|
128
|
+
target = c.action === 'telegram' ? defaultTelegramTarget : defaultWhatsappTarget;
|
|
129
|
+
}
|
|
130
|
+
|
|
119
131
|
console.log(chalk.cyan(`${i + 1}. ${c.name}`));
|
|
120
132
|
console.log(chalk.gray(` Zamanlama: ${c.schedule}`));
|
|
121
|
-
console.log(chalk.gray(` Kanal: ${c.action} → ${
|
|
133
|
+
console.log(chalk.gray(` Kanal: ${c.action} → ${target}`));
|
|
122
134
|
console.log(chalk.gray(` Prompt: ${c.prompt.substring(0, 60)}${c.prompt.length > 60 ? '...' : ''}`));
|
|
123
135
|
console.log(chalk.gray(` Durum: ${c.enabled ? '✅ Aktif' : '❌ Pasif'}`));
|
|
124
136
|
console.log('');
|
|
@@ -211,7 +211,7 @@ body::before{
|
|
|
211
211
|
<div class="header-bot-name" id="header-bot-name">Nature Bot</div>
|
|
212
212
|
<div class="header-bot-model" id="header-bot-model">NatureCo</div>
|
|
213
213
|
</div>
|
|
214
|
-
<div class="version-badge" id="version-badge">v2.12.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.12.5</div>
|
|
215
215
|
</div>
|
|
216
216
|
<div class="messages" id="messages"></div>
|
|
217
217
|
<div class="input-area">
|
|
@@ -341,7 +341,7 @@ function dashboard(action) {
|
|
|
341
341
|
apiKey: cfg.apiKey,
|
|
342
342
|
defaultBot: cfg.defaultBot,
|
|
343
343
|
defaultBotId: cfg.defaultBotId,
|
|
344
|
-
version: 'v2.12.
|
|
344
|
+
version: 'v2.12.5',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
package/src/commands/migrate.js
CHANGED
|
@@ -51,12 +51,19 @@ async function migrate(options) {
|
|
|
51
51
|
facts: []
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
// Clean markdown bold syntax (** Gencay → Gencay)
|
|
55
|
+
if (memory.name) {
|
|
56
|
+
memory.name = memory.name.replace(/\*\*/g, '').trim();
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
if (timezoneMatch) {
|
|
55
|
-
|
|
60
|
+
let timezone = timezoneMatch[1].trim().replace(/\*\*/g, '').trim();
|
|
61
|
+
memory.facts.push(`Timezone: ${timezone}`);
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
if (notesMatch) {
|
|
59
|
-
|
|
65
|
+
let notes = notesMatch[1].trim().replace(/\*\*/g, '').trim();
|
|
66
|
+
memory.facts.push(notes);
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
// Save to NatureCo memory
|
|
@@ -81,6 +88,10 @@ async function migrate(options) {
|
|
|
81
88
|
const cronData = JSON.parse(fs.readFileSync(cronJobsPath, 'utf8'));
|
|
82
89
|
const jobs = cronData.jobs || cronData || []; // jobs property or direct array
|
|
83
90
|
|
|
91
|
+
// Get WhatsApp target from config
|
|
92
|
+
const config = getConfig();
|
|
93
|
+
const whatsappTarget = config.whatsappPhone || '+905422842631'; // fallback
|
|
94
|
+
|
|
84
95
|
const naturecoCrons = [];
|
|
85
96
|
|
|
86
97
|
for (const job of jobs) {
|
|
@@ -100,35 +111,52 @@ async function migrate(options) {
|
|
|
100
111
|
|
|
101
112
|
// Determine action based on delivery channel
|
|
102
113
|
let action = 'whatsapp'; // default
|
|
114
|
+
let target = whatsappTarget;
|
|
115
|
+
|
|
103
116
|
if (job.delivery?.channel === 'telegram') {
|
|
104
117
|
action = 'telegram';
|
|
118
|
+
// Get telegram target from config if available
|
|
119
|
+
const telegramChats = config.telegramAllowedChats || [];
|
|
120
|
+
target = telegramChats[0] || ''; // Use first allowed chat
|
|
105
121
|
}
|
|
106
122
|
|
|
107
|
-
// Get prompt (
|
|
123
|
+
// Get prompt (max 300 chars)
|
|
108
124
|
let prompt = job.payload?.message || '';
|
|
109
|
-
if (prompt.length >
|
|
110
|
-
prompt = prompt.slice(0,
|
|
125
|
+
if (prompt.length > 300) {
|
|
126
|
+
prompt = prompt.slice(0, 300);
|
|
111
127
|
}
|
|
112
128
|
|
|
113
129
|
naturecoCrons.push({
|
|
114
130
|
name: job.name || 'Unnamed Job',
|
|
115
131
|
schedule: job.schedule.expr,
|
|
116
132
|
action: action,
|
|
133
|
+
target: target,
|
|
117
134
|
prompt: prompt,
|
|
135
|
+
enabled: true, // Enable migrated crons
|
|
118
136
|
});
|
|
119
137
|
}
|
|
120
138
|
|
|
121
139
|
// Save to NatureCo crons
|
|
122
140
|
const cronsFile = path.join(os.homedir(), '.natureco', 'crons.json');
|
|
123
141
|
|
|
124
|
-
//
|
|
142
|
+
// Load existing crons and check for duplicates by name
|
|
125
143
|
let existingCrons = [];
|
|
126
144
|
if (fs.existsSync(cronsFile)) {
|
|
127
145
|
existingCrons = JSON.parse(fs.readFileSync(cronsFile, 'utf8'));
|
|
128
146
|
}
|
|
129
147
|
|
|
130
|
-
|
|
148
|
+
// Filter out duplicates (check by name)
|
|
149
|
+
const existingNames = existingCrons.map(c => c.name);
|
|
150
|
+
const toAdd = naturecoCrons.filter(c => !existingNames.includes(c.name));
|
|
151
|
+
|
|
152
|
+
// Merge without duplicates
|
|
153
|
+
const mergedCrons = [...existingCrons, ...toAdd];
|
|
131
154
|
fs.writeFileSync(cronsFile, JSON.stringify(mergedCrons, null, 2));
|
|
155
|
+
|
|
156
|
+
// Update report with actual added count
|
|
157
|
+
if (toAdd.length < naturecoCrons.length) {
|
|
158
|
+
console.log(chalk.yellow(`⚠️ ${naturecoCrons.length - toAdd.length} cron zaten mevcut, atlandı`));
|
|
159
|
+
}
|
|
132
160
|
}
|
|
133
161
|
} catch (err) {
|
|
134
162
|
console.log(chalk.gray('⚠️ Cron migration atlandı:', err.message));
|