banana-code 1.2.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +246 -0
  3. package/banana.js +5464 -0
  4. package/lib/agenticRunner.js +1884 -0
  5. package/lib/borderRenderer.js +41 -0
  6. package/lib/commandRunner.js +205 -0
  7. package/lib/completer.js +286 -0
  8. package/lib/config.js +301 -0
  9. package/lib/contextBuilder.js +324 -0
  10. package/lib/diffViewer.js +295 -0
  11. package/lib/fileManager.js +224 -0
  12. package/lib/historyManager.js +124 -0
  13. package/lib/hookManager.js +1143 -0
  14. package/lib/imageHandler.js +268 -0
  15. package/lib/inlineComplete.js +192 -0
  16. package/lib/interactivePicker.js +254 -0
  17. package/lib/lmStudio.js +226 -0
  18. package/lib/markdownRenderer.js +423 -0
  19. package/lib/mcpClient.js +288 -0
  20. package/lib/modelRegistry.js +350 -0
  21. package/lib/monkeyModels.js +97 -0
  22. package/lib/oauthOpenAI.js +167 -0
  23. package/lib/parser.js +134 -0
  24. package/lib/promptManager.js +96 -0
  25. package/lib/providerClients.js +1014 -0
  26. package/lib/providerManager.js +130 -0
  27. package/lib/providerStore.js +413 -0
  28. package/lib/statusBar.js +283 -0
  29. package/lib/streamHandler.js +306 -0
  30. package/lib/subAgentManager.js +406 -0
  31. package/lib/tokenCounter.js +132 -0
  32. package/lib/visionAnalyzer.js +163 -0
  33. package/lib/watcher.js +138 -0
  34. package/models.json +57 -0
  35. package/package.json +42 -0
  36. package/prompts/base.md +23 -0
  37. package/prompts/code-agent-glm.md +16 -0
  38. package/prompts/code-agent-gptoss.md +25 -0
  39. package/prompts/code-agent-nemotron.md +17 -0
  40. package/prompts/code-agent-qwen.md +20 -0
  41. package/prompts/code-agent.md +70 -0
  42. package/prompts/plan.md +44 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matt Johnston
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,246 @@
1
+ # Banana Code
2
+
3
+ AI coding agent CLI powered by Monkey Models. Run cloud models with 4 quality tiers, or connect Anthropic/OpenAI/OpenRouter with `/connect`.
4
+
5
+ ## What's New in v1.2.0
6
+
7
+ - **Monkey Models integration** - 4 branded tiers: Silverback, Mandrill, Gibbon, Tamarin
8
+ - **Multi-provider support** - Monkey Models (default) + Anthropic/OpenAI/OpenRouter
9
+ - **Vision via cloud proxy** - Images routed through Gemini Flash transparently
10
+ - **Extensible prompts** - Drop `.md` files in `prompts/` for custom system prompts
11
+ - **Agentic mode built-in** - Tool-calling loop runs locally (read_file, list_files, search_code)
12
+ - **Model shown in prompt** - `[mandrill] You -->` so you always know what tier you're using
13
+
14
+ ## Prerequisites
15
+
16
+ 1. **Node.js** 18+
17
+ 2. **Monkey Models token** (set via `BANANA_MONKEY_TOKEN` env var or `/connect`)
18
+ 3. **LM Studio** (optional, for local model fallback)
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install -g banana-code
24
+ ```
25
+
26
+ ### Upgrade
27
+
28
+ ```bash
29
+ npm install -g banana-code@latest
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```bash
35
+ cd your-project
36
+ banana
37
+ ```
38
+
39
+ ### One-Shot Mode
40
+
41
+ ```bash
42
+ banana "Add a dark mode toggle to the header"
43
+ ```
44
+
45
+ ### YOLO Mode (auto-apply all changes)
46
+
47
+ ```bash
48
+ banana yolo
49
+ ```
50
+
51
+ ## Model Tiers
52
+
53
+ Switch between Monkey Models tiers:
54
+
55
+ ```
56
+ /model Show all models
57
+ /model silverback Switch to Silverback (best quality, heavy coding)
58
+ /model mandrill Switch to Mandrill (balanced, default)
59
+ /model gibbon Switch to Gibbon (fast, quick fixes)
60
+ /model tamarin Switch to Tamarin (budget, simple tasks)
61
+ /model anthropic:claude-sonnet-4.6 Switch to connected Anthropic model
62
+ /model openai:codex-5.3-medium Switch to connected OpenAI Codex model
63
+ /model search gemini Search OpenRouter catalog and add/switch model
64
+ ```
65
+
66
+ Connect remote providers:
67
+
68
+ ```
69
+ /connect Interactive provider wizard
70
+ /connect anthropic Connect Anthropic with API key
71
+ /connect openrouter Connect OpenRouter with API key
72
+ /connect openai Connect OpenAI via OAuth device code
73
+ /connect status Show connection status
74
+ ```
75
+
76
+ Model choice persists across sessions. The active model shows in your prompt:
77
+
78
+ ```
79
+ [mandrill] You --> fix the auth bug
80
+ [silverback] You --> refactor this whole module
81
+ ```
82
+
83
+ ## Prompt System
84
+
85
+ Banana ships with two prompts:
86
+
87
+ - `base` - General coding assistant (default)
88
+ - `code-agent` - Optimized for agentic tool-calling mode
89
+
90
+ Add custom prompts by dropping `.md` files in the `prompts/` directory:
91
+
92
+ ```
93
+ /prompt Show available prompts
94
+ /prompt base Switch to base prompt
95
+ ```
96
+
97
+ ## Commands
98
+
99
+ ### File Commands
100
+
101
+ | Command | Description |
102
+ |---------|-------------|
103
+ | `/files` | List files currently in context |
104
+ | `/read <path>` | Add file to context (supports globs) |
105
+ | `/unread <path>` | Remove file from context |
106
+ | `/tree` | Show project structure |
107
+ | `/find <pattern>` | Find files matching pattern |
108
+ | `/grep <text>` | Search for text in files |
109
+ | `/image <path>` | Add image (vision via Monkey Models proxy) |
110
+
111
+ ### Mode Commands
112
+
113
+ | Command | Description |
114
+ |---------|-------------|
115
+ | `/plan` | Toggle PLAN mode (preview only) |
116
+ | `/ask` | Toggle ASK mode (questions only) |
117
+ | `/yolo` | Toggle YOLO mode (auto-apply) |
118
+ | `/agent` | Toggle agentic mode (AI reads files on demand) |
119
+ | `/steer <message>` | Steer next turn, or interrupt + redirect a running turn |
120
+ | `/model [name]` | Show/switch model |
121
+ | `/connect [provider]` | Connect/manage remote providers |
122
+ | `/prompt [name]` | Show/switch system prompt |
123
+
124
+ ### Git, Session, Config, System
125
+
126
+ | Command | Description |
127
+ |---------|-------------|
128
+ | `/git` | Git status |
129
+ | `/diff` | Uncommitted changes |
130
+ | `/log` | Recent commits |
131
+ | `/clear` | Clear conversation & context |
132
+ | `/save <name>` | Save session |
133
+ | `/load <name>` | Load session |
134
+ | `/config` | Show configuration |
135
+ | `/run <cmd>` | Run shell command |
136
+ | `/undo` | Show backups |
137
+ | `/restore <path>` | Restore from backup |
138
+ | `/help` | All commands |
139
+
140
+ ## Keyboard Shortcuts
141
+
142
+ | Key | Action |
143
+ |-----|--------|
144
+ | `Up` / `Down` | Navigate command history |
145
+ | `Tab` | Auto-complete |
146
+ | `Shift+Tab` | Cycle modes (code -> plan -> ask) |
147
+ | `Alt+V` | Paste screenshot from clipboard |
148
+ | `Escape` | Cancel current request |
149
+
150
+ ## Architecture
151
+
152
+ ```
153
+ Banana Code v1.2.0 ──────────> Monkey Models (cloud API)
154
+ ├── banana.js 4 tiers: Silverback, Mandrill, Gibbon, Tamarin
155
+ ├── models.json + Remote Providers (Anthropic, OpenAI, OpenRouter)
156
+ ├── prompts/ + LM Studio (local fallback)
157
+ │ ├── base.md
158
+ │ └── code-agent.md
159
+ └── lib/
160
+ ├── monkeyModels.js Monkey Models API client
161
+ ├── lmStudio.js Local LM Studio API client (fallback)
162
+ ├── providerStore.js Global provider credentials/aliases
163
+ ├── providerManager.js Provider routing + auth handling
164
+ ├── modelRegistry.js Model switching
165
+ ├── promptManager.js Prompt loading
166
+ ├── agenticRunner.js Tool-calling loop
167
+ ├── streamHandler.js SSE processing
168
+ ├── visionAnalyzer.js Vision via Monkey Models proxy
169
+ └── [9 more modules]
170
+ ```
171
+
172
+ ## Vision Support
173
+
174
+ Images are sent as `image_url` content blocks to Monkey Models. The server transparently proxies them through Gemini Flash for analysis and injects a rich text description for the coding model.
175
+
176
+ - Clipboard paste (`Alt+V`) and file path (`/image screenshot.png`)
177
+ - Supported formats: base64 data URIs and public URLs
178
+
179
+ ## Project Instructions
180
+
181
+ Create `BANANA.md` in your project root for project-specific AI context (like CLAUDE.md for Claude Code):
182
+
183
+ ```markdown
184
+ # BANANA.md
185
+
186
+ This file provides project-specific instructions to Banana Code.
187
+
188
+ ## Project Overview
189
+ - React 18 with TypeScript
190
+ - Use functional components
191
+ - API is in src/api/
192
+ ```
193
+
194
+ Also supports the legacy `.banana/instructions.md` as a fallback.
195
+
196
+ ## Steering Messages
197
+
198
+ Use `/steer` to inject additional guidance into the next turn without editing prompts:
199
+
200
+ ```text
201
+ /steer Focus on minimal diffs and skip refactors unless requested
202
+ /steer status
203
+ /steer show
204
+ /steer clear
205
+ /steer on
206
+ /steer off
207
+ ```
208
+
209
+ Queued steering messages are inserted as extra user guidance before your next request, then automatically consumed after a successful turn.
210
+ If a turn is currently running, enter `/steer <text>` and press Enter to interrupt and continue with the new steering.
211
+
212
+ ## Environment Variables
213
+
214
+ | Variable | Purpose | Default |
215
+ |----------|---------|---------|
216
+ | `BANANA_MONKEY_TOKEN` | Monkey Models API token | -- |
217
+ | `BANANA_LM_STUDIO_URL` | LM Studio URL (local fallback) | `http://localhost:1234` |
218
+ | `GEMINI_API_KEY` | Gemini vision fallback | -- |
219
+ | `ANTHROPIC_API_KEY` | Anthropic API key fallback (if not saved via `/connect`) | -- |
220
+ | `OPENROUTER_API_KEY` | OpenRouter API key fallback (if not saved via `/connect`) | -- |
221
+ | `BANANA_DEBUG` | Enable/disable debug logging (`1`/`0`) | `1` (enabled by default) |
222
+ | `BANANA_DEBUG_PATH` | Debug log file path | `~/.banana/logs/banana-YYYY-MM-DD.log` |
223
+
224
+ By default, Banana writes debug logs to `~/.banana/logs/` on every run.
225
+ Set `BANANA_DEBUG=0` to turn this off.
226
+
227
+ ## Changelog
228
+
229
+ ### v1.2.0
230
+ - Rebranded from Ripley Code to Banana Code
231
+ - Monkey Models integration (4 cloud tiers: Silverback, Mandrill, Gibbon, Tamarin)
232
+ - Vision via Monkey Models Gemini proxy
233
+ - Banana yellow (#FFD60A) color scheme
234
+ - New ASCII banner and breathing glow animation
235
+
236
+ ### v4.0.0 (as Ripley Code)
237
+ - Direct LM Studio connection (removed AI Router dependency)
238
+ - Named model profiles with `/model` switching
239
+ - Auto-discovery of model IDs from LM Studio
240
+ - Local vision model support with Gemini fallback
241
+ - Extensible prompt system (drop .md files in prompts/)
242
+ - Agentic tool-calling loop runs locally
243
+
244
+ ## License
245
+
246
+ MIT