@banaxi/banana-code 1.3.0 → 1.4.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banaxi/banana-code",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "🍌 BananaCode",
5
5
  "keywords": [
6
6
  "banana",
package/src/index.js CHANGED
@@ -67,7 +67,7 @@ async function handleSlashCommand(command) {
67
67
  providerInstance = createProvider();
68
68
  console.log(chalk.green(`Switched provider to ${newProv} (${config.model}).`));
69
69
  } else {
70
- console.log(chalk.yellow(`Usage: /provider <gemini|claude|openai|ollama_cloud|ollama>`));
70
+ console.log(chalk.yellow(`Usage: /provider <gemini|claude|openai|mistral|ollama_cloud|ollama>`));
71
71
  }
72
72
  break;
73
73
  case '/model':
@@ -386,7 +386,7 @@ async function handleSlashCommand(command) {
386
386
  case '/help':
387
387
  console.log(chalk.yellow(`
388
388
  Available commands:
389
- /provider <name> - Switch AI provider (gemini, claude, openai, ollama_cloud, ollama)
389
+ /provider <name> - Switch AI provider (gemini, claude, openai, mistral, ollama_cloud, ollama)
390
390
  /model [name] - Switch model within current provider (opens menu if name omitted)
391
391
  /chats - List persistent chat sessions
392
392
  /clear - Clear chat history
@@ -47,7 +47,7 @@ export class OllamaCloudProvider {
47
47
  model: this.modelName,
48
48
  messages: this.messages,
49
49
  tools: this.tools.length > 0 ? this.tools : undefined,
50
- stream: false // Cloud API sometimes prefers non-streaming or different SSE formats
50
+ stream: true
51
51
  })
52
52
  });
53
53
 
@@ -57,28 +57,57 @@ export class OllamaCloudProvider {
57
57
  throw new Error(`HTTP ${response.status}: ${errorText}`);
58
58
  }
59
59
 
60
- const data = await response.json();
61
- spinner.stop();
60
+ const reader = response.body.getReader();
61
+ const decoder = new TextDecoder();
62
+ let currentChunkResponse = '';
63
+ let lastMessageObj = null;
64
+
65
+ while (true) {
66
+ const { done, value } = await reader.read();
67
+ if (done) break;
68
+
69
+ const chunk = decoder.decode(value, { stream: true });
70
+ const lines = chunk.split('\n').filter(l => l.trim() !== '');
71
+
72
+ for (const line of lines) {
73
+ try {
74
+ const data = JSON.parse(line);
75
+ if (data.message) {
76
+ lastMessageObj = data.message;
77
+ if (data.message.content) {
78
+ const content = data.message.content;
79
+ if (spinner.isSpinning && !this.config.useMarkedTerminal) spinner.stop();
80
+ if (!this.config.useMarkedTerminal) {
81
+ process.stdout.write(chalk.cyan(content));
82
+ }
83
+ currentChunkResponse += content;
84
+ finalResponse += content;
85
+ }
86
+ }
87
+ } catch (e) {
88
+ // Ignore partial JSON chunks
89
+ }
90
+ }
91
+ }
62
92
 
63
- const messageObj = data.message;
93
+ if (spinner.isSpinning) spinner.stop();
64
94
 
65
- if (messageObj.content) {
66
- if (this.config.useMarkedTerminal) {
67
- printMarkdown(messageObj.content);
68
- } else {
69
- process.stdout.write(chalk.cyan(messageObj.content));
70
- }
71
- finalResponse += messageObj.content;
95
+ if (currentChunkResponse && this.config.useMarkedTerminal) {
96
+ printMarkdown(currentChunkResponse);
97
+ }
98
+
99
+ if (!lastMessageObj) {
100
+ throw new Error("Empty response from Ollama Cloud");
72
101
  }
73
102
 
74
- this.messages.push(messageObj);
103
+ this.messages.push(lastMessageObj);
75
104
 
76
- if (!messageObj.tool_calls || messageObj.tool_calls.length === 0) {
105
+ if (!lastMessageObj.tool_calls || lastMessageObj.tool_calls.length === 0) {
77
106
  console.log();
78
107
  break;
79
108
  }
80
109
 
81
- for (const call of messageObj.tool_calls) {
110
+ for (const call of lastMessageObj.tool_calls) {
82
111
  const fn = call.function;
83
112
  console.log(chalk.yellow(`\n[Banana Calling Tool: ${fn.name}]`));
84
113