natureco-cli 2.13.11 → 2.13.13
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/dashboard.js +2 -2
- package/src/utils/api.js +49 -11
package/package.json
CHANGED
|
@@ -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.13.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.13.13</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.13.
|
|
344
|
+
version: 'v2.13.13',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
package/src/utils/api.js
CHANGED
|
@@ -172,6 +172,30 @@ function normalizeMcpToolSchema(tool) {
|
|
|
172
172
|
return { ...tool, inputSchema: normalizedSchema };
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Minimize MCP tool schema to reduce token usage
|
|
177
|
+
* Truncates descriptions and removes unnecessary fields
|
|
178
|
+
*/
|
|
179
|
+
function minimizeMcpTool(tool) {
|
|
180
|
+
return {
|
|
181
|
+
name: tool.name,
|
|
182
|
+
description: (tool.description || '').slice(0, 100),
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: tool.inputSchema?.type || 'object',
|
|
185
|
+
properties: Object.fromEntries(
|
|
186
|
+
Object.entries(tool.inputSchema?.properties || {}).map(([k, v]) => [
|
|
187
|
+
k,
|
|
188
|
+
{
|
|
189
|
+
type: v.type,
|
|
190
|
+
...(v.enum ? { enum: v.enum } : {}) // Include enum only if exists
|
|
191
|
+
}
|
|
192
|
+
])
|
|
193
|
+
),
|
|
194
|
+
required: tool.inputSchema?.required || []
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
175
199
|
/**
|
|
176
200
|
* Coerce MCP tool parameters to match schema types
|
|
177
201
|
*/
|
|
@@ -370,7 +394,7 @@ function getProviderConfig() {
|
|
|
370
394
|
*/
|
|
371
395
|
function formatToolsForOpenAI() {
|
|
372
396
|
const localTools = getToolDefinitions();
|
|
373
|
-
const mcpTools = getMcpToolsForAI(); //
|
|
397
|
+
const mcpTools = getMcpToolsForAI().map(minimizeMcpTool); // Minimize MCP tools
|
|
374
398
|
|
|
375
399
|
// Normalize MCP tools before combining
|
|
376
400
|
const normalizedMcpTools = mcpTools.map(tool => normalizeMcpToolSchema(tool));
|
|
@@ -393,7 +417,7 @@ function formatToolsForOpenAI() {
|
|
|
393
417
|
*/
|
|
394
418
|
function formatToolsForAnthropic() {
|
|
395
419
|
const localTools = getToolDefinitions();
|
|
396
|
-
const mcpTools = getMcpToolsForAI(); //
|
|
420
|
+
const mcpTools = getMcpToolsForAI().map(minimizeMcpTool); // Minimize MCP tools
|
|
397
421
|
|
|
398
422
|
// Normalize MCP tools before combining
|
|
399
423
|
const normalizedMcpTools = mcpTools.map(tool => normalizeMcpToolSchema(tool));
|
|
@@ -696,8 +720,8 @@ async function sendMessage(apiKey, botId, message, conversationId = null, skillP
|
|
|
696
720
|
// Get user's home directory
|
|
697
721
|
const homeDir = os.homedir();
|
|
698
722
|
|
|
699
|
-
//
|
|
700
|
-
|
|
723
|
+
// Base system prompt for terminal assistant with dynamic home directory
|
|
724
|
+
const baseSystemPrompt = `You are a terminal assistant. When users ask for file listing, command execution, or directory viewing, you MUST use the available tools (bash, read_file, write_file, list_dir, web_search, http_request). Never say 'run this command' - execute it yourself using tools and show the result.
|
|
701
725
|
|
|
702
726
|
IMPORTANT: The user's home directory is: ${homeDir}
|
|
703
727
|
When listing home directory, always use list_dir with path: "${homeDir}"
|
|
@@ -726,23 +750,29 @@ TOOL SELECTION GUIDE:
|
|
|
726
750
|
- web_search: Use when users ask about current information, news, weather, or anything requiring internet search
|
|
727
751
|
- http_request: Use for API calls, webhooks, fetching URLs, testing endpoints`;
|
|
728
752
|
|
|
753
|
+
let systemPrompt = baseSystemPrompt;
|
|
754
|
+
|
|
729
755
|
// Add MCP tool guidance if MCP servers are loaded
|
|
756
|
+
let mcpPrompt = '';
|
|
730
757
|
const mcpTools = getMcpTools();
|
|
731
758
|
if (mcpTools.length > 0) {
|
|
732
759
|
const mcpServerNames = Object.keys(mcpClients);
|
|
733
760
|
|
|
734
|
-
|
|
761
|
+
mcpPrompt = `\n\nMCP SERVERS (${mcpServerNames.length}):`;
|
|
735
762
|
|
|
736
763
|
for (const serverName of mcpServerNames) {
|
|
737
764
|
const serverTools = mcpClients[serverName].tools;
|
|
738
|
-
|
|
765
|
+
mcpPrompt += `\n- ${serverName}: ${serverTools.length} tools`;
|
|
739
766
|
}
|
|
740
767
|
|
|
741
|
-
|
|
742
|
-
|
|
768
|
+
mcpPrompt += `\n\nWhen filesystem MCP is loaded, use list_directory (not list_dir), read_file from MCP (not local).`;
|
|
769
|
+
mcpPrompt += `\nFor GitHub MCP, prefer list_issues over search_issues.`;
|
|
770
|
+
|
|
771
|
+
systemPrompt += mcpPrompt;
|
|
743
772
|
}
|
|
744
773
|
|
|
745
774
|
// Add available skills information
|
|
775
|
+
let skillsPrompt = '';
|
|
746
776
|
const skillsDir = path.join(homeDir, '.natureco', 'skills');
|
|
747
777
|
if (fs.existsSync(skillsDir)) {
|
|
748
778
|
try {
|
|
@@ -752,20 +782,28 @@ TOOL SELECTION GUIDE:
|
|
|
752
782
|
});
|
|
753
783
|
|
|
754
784
|
if (skills.length > 0) {
|
|
755
|
-
|
|
785
|
+
skillsPrompt = `\n\nAVAILABLE SKILLS:`;
|
|
756
786
|
|
|
757
787
|
// Show only first 10 skills, summarize the rest
|
|
758
788
|
if (skills.length > 10) {
|
|
759
|
-
|
|
789
|
+
skillsPrompt += `\nInstalled skills (${skills.length} total): ${skills.slice(0, 10).join(', ')} and ${skills.length - 10} more.`;
|
|
760
790
|
} else {
|
|
761
|
-
|
|
791
|
+
skillsPrompt += `\nInstalled skills: ${skills.join(', ')}`;
|
|
762
792
|
}
|
|
793
|
+
|
|
794
|
+
systemPrompt += skillsPrompt;
|
|
763
795
|
}
|
|
764
796
|
} catch (err) {
|
|
765
797
|
// Silently skip if skills directory can't be read
|
|
766
798
|
}
|
|
767
799
|
}
|
|
768
800
|
|
|
801
|
+
// Log system prompt components
|
|
802
|
+
console.log('[API] Base system prompt:', baseSystemPrompt.length, 'chars');
|
|
803
|
+
console.log('[API] MCP prompt:', mcpPrompt.length, 'chars');
|
|
804
|
+
console.log('[API] Skills prompt:', skillsPrompt.length, 'chars');
|
|
805
|
+
console.log('[API] Total system prompt:', systemPrompt.length, 'chars, ~', Math.round(systemPrompt.length / 4), 'tokens');
|
|
806
|
+
|
|
769
807
|
return sendMessageToProvider(apiKey, message, conversationId, systemPrompt);
|
|
770
808
|
}
|
|
771
809
|
|