@nomad-e/bluma-cli 0.2.1 → 0.5.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/README.md CHANGED
@@ -1,1237 +1,369 @@
1
- # BluMa CLI — Base Language Unit · Model Agent
1
+ # BluMa CLI — AI-Powered Agent for Advanced Software Engineering
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@nomad-e/bluma-cli.svg?style=flat-square)](https://www.npmjs.com/package/@nomad-e/bluma-cli)
4
- [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](LICENSE)
5
- [![Node.js >=20](https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat-square)](https://nodejs.org/)
6
-
7
- ![Factorai.sh Banner](assets/bg.png)
8
-
9
-
10
- **BluMa** is a CLI-based model agent for advanced software engineering workflows. Built with React/Ink 5, it provides an interactive terminal interface for LLM-powered automation, code generation, refactoring, and task execution. Features persistent sessions, contextual reasoning, smart feedback, coordinator mode for worker orchestration, and extensible tools/skills architecture.
11
-
12
- > **Credit:** BluMa was conceived and architected by **Alex Fonseca**.
13
-
14
- **Current Version:** 0.1.84
15
-
16
- ---
17
-
18
- ## Table of Contents
19
-
20
- - [Overview](#overview)
21
- - [Key Features](#key-features)
22
- - [Requirements](#requirements)
23
- - [Installation](#installation)
24
- - [Quick Start](#quick-start)
25
- - [Configuration](#configuration)
26
- - [Architecture](#architecture)
27
- - [Native Tools](#native-tools)
28
- - [Skills System](#skills-system)
29
- - [Runtime & Orchestration](#runtime--orchestration)
30
- - [Slash Commands](#slash-commands)
31
- - [Development](#development)
32
- - [Testing](#testing)
33
- - [Contributing](#contributing)
34
- - [License](#license)
35
-
36
- ---
37
-
38
- ## Overview
39
-
40
- BluMa operates as a **conversational agent** in the terminal, combining:
41
-
42
- - **Rich UI Layer**: React/Ink 5 components for interactive prompts, live overlays, and real-time feedback
43
- - **Agent Layer**: LLM orchestration via FactorRouter with tool invocation and context management
44
- - **Runtime Layer**: Task tracking, plugin system, hooks, diagnostics, session management, and coordinator mode
45
- - **Tool Layer**: 50+ native tools + MCP SDK integration for external tools
46
-
47
- The agent maintains persistent conversation history, workspace snapshots, and coding memory across sessions.
48
-
49
- ---
50
-
51
- ## Key Features
52
-
53
- ### Core Agent
54
- - **Interactive CLI**: Rich terminal UI with React/Ink 5
55
- - **Session Persistence**: Automatic save/load of conversation and tool history
56
- - **Context Management**: Token-aware context compression with history anchoring
57
- - **Smart Feedback**: Technical suggestions and automated checks
58
- - **Confirmation System**: Controlled execution with whitelists and previews
59
- - **Coding Memory**: Persistent notes about codebase decisions (`~/.bluma/coding_memory.json`)
60
-
61
- ### Runtime & Orchestration (v0.1.41+)
62
- - **Plugin System**: Load plugins from `.bluma/plugins/` or `~/.bluma/plugins/`
63
- - **Hook Registry**: Event-driven lifecycle tracking (tool calls, decisions, state changes)
64
- - **Task Store**: Persistent task management with PLANNING → EXECUTION → VERIFICATION flow
65
- - **Session Registry**: Multi-session support with process health monitoring
66
- - **Thread System**: Multi-thread conversation management with isolated contexts
67
- - **Diagnostics**: Real-time system snapshot (tasks, hooks, plugins, sessions)
68
- - **Tool Execution Policy**: Intelligent decisions based on sandbox mode and safety
69
-
70
- ### Tools & Skills
71
- - **50+ Native Tools**: File operations, search, shell commands, web fetch, agent coordination, task management, MCP resources, cron scheduling, LSP queries, notebook editing, REPL execution
72
- - **Coordinator Mode**: Orchestrator playbook for delegating work to background workers
73
- - **MCP Integration**: Model Context Protocol SDK for external tool servers
74
- - **Skills System**: Pluggable knowledge modules (git, PDF, Excel, etc.)
75
- - **Agent Coordination**: Spawn/wait/list subagents for parallel work with bidirectional mailbox system
76
-
77
- ### UI Components
78
- - **Slash Commands**: 30+ built-in commands (`/help`, `/model`, `/tasks`, `/plugins`, `/threads`, etc.)
79
- - **Live Overlays**: Working timers, progress indicators, streaming text
80
- - **Diff Previews**: Side-by-side code comparisons before edits
81
- - **Tool Result Cards**: Structured display of tool outputs
82
- - **Session Panels**: Real-time monitoring with log streaming
83
- - **Thread Management**: Multi-thread conversation UI with thread switching
84
-
85
- ---
3
+ ![BluMa Background](assets/bg.png)
86
4
 
87
- ## Requirements
5
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%2.0-blue.svg?style=flat-square)](LICENSE)
6
+ [![Node.js >=20](https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat-square)](https://nodejs.org/)
7
+ [![Version](https://img.shields.io/npm/v/@nomad-e/bluma-cli?style=flat-square)](https://www.npmjs.com/package/@nomad-e/bluma-cli)
8
+ [![Build Status](https://img.shields.io/badge/build-passing-brightgreen?style=flat-square)](https://github.com/Nomad-e/bluma-cli/actions)
9
+ [![Tests](https://img.shields.io/badge/tests-Jest-blue?style=flat-square)](https://jestjs.io/)
10
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg?style=flat-square)](https://www.typescriptlang.org/)
11
+ [![Code Style](https://img.shields.io/badge/code_style-Prettier-ff69b4?style=flat-square)](https://prettier.io/)
12
+ [![Downloads](https://img.shields.io/npm/dm/@nomad-e/bluma-cli?style=flat-square)](https://www.npmjs.com/package/@nomad-e/bluma-cli)
88
13
 
89
- - **Node.js**: >= 20
90
- - **npm**: >= 9
91
- - **FactorRouter**: API key and URL for LLM backend
14
+ **BluMa** is an independent AI agent CLI for automation and advanced software engineering. It combines powerful tool orchestration, multi-agent coordination, and intelligent context management to help you build software faster and with higher quality.
92
15
 
93
16
  ---
94
17
 
95
- ## Installation
96
-
97
- ### Global Installation (Recommended)
18
+ ## 🚀 Quick Start
98
19
 
99
20
  ```bash
21
+ # Install globally
100
22
  npm install -g @nomad-e/bluma-cli
101
- ```
102
-
103
- **Linux/macOS** (if permission errors):
104
- ```bash
105
- sudo npm install -g @nomad-e/bluma-cli
106
- ```
107
23
 
108
- > **macOS Note**: After installation, run `bluma` **without** sudo to avoid permission issues.
24
+ # Run BluMa (new session)
25
+ bluma
109
26
 
110
- ### Local Development
27
+ # Resume a previous session
28
+ bluma resume {session_id}
111
29
 
112
- ```bash
113
- git clone <repository-url>
114
- cd bluma-cli
30
+ # Or run from source
115
31
  npm install
116
32
  npm run build
117
- ```
118
-
119
- ### Environment Setup
120
-
121
- Set these environment variables globally:
122
-
123
- ```bash
124
- # Linux/macOS: Add to ~/.bashrc, ~/.zshrc, or ~/.bash_profile
125
- export FACTOR_ROUTER_KEY="sk-fai-your-key-here"
126
- export FACTOR_ROUTER_URL="http://host:8003/router-api"
127
-
128
- # Then reload
129
- source ~/.bashrc # or ~/.zshrc
130
- ```
131
-
132
- **Windows (PowerShell)**:
133
- ```powershell
134
- [Environment]::SetEnvironmentVariable("FACTOR_ROUTER_KEY", "sk-fai-your-key-here", "User")
135
- [Environment]::SetEnvironmentVariable("FACTOR_ROUTER_URL", "http://host:8003/router-api", "User")
136
- ```
137
-
138
- ---
139
-
140
- ## Quick Start
141
-
142
- ```bash
143
- # Launch BluMa
144
- bluma
145
-
146
- # Or from local development
147
33
  npm start
148
34
  ```
149
35
 
150
- ### First Interaction
151
-
152
- ```
153
- > help me create a React component
154
- > find all files containing "useEffect"
155
- > run npm test in the background
156
- > /tasks to see active tasks
157
- > /model to switch LLM model
158
- > /threads to manage conversation threads
159
- ```
160
-
161
36
  ---
162
37
 
163
- ## Configuration
164
-
165
- ### Runtime Settings (`~/.bluma/settings.json`)
166
-
167
- ```json
168
- {
169
- "model": "auto",
170
- "reasoningEffort": "medium",
171
- "outputStyle": "concise",
172
- "sandboxMode": "confirm",
173
- "alwaysAcceptTools": ["read_file_lines", "grep_search"],
174
- "theme": "default"
175
- }
176
- ```
177
-
178
- | Setting | Values | Description |
179
- |---------|--------|-------------|
180
- | `model` | `auto` | LLM model (FactorRouter decides) |
181
- | `reasoningEffort` | `low`, `medium`, `high` | Reasoning depth |
182
- | `outputStyle` | `concise`, `balanced`, `verbose` | Response style |
183
- | `sandboxMode` | `confirm`, `auto`, `strict` | Tool execution policy |
184
-
185
- ### Directory Structure
186
-
187
- ```
188
- ~/.bluma/
189
- ├── settings.json # Runtime configuration
190
- ├── coding_memory.json # Persistent coding notes
191
- ├── artifacts/ # Saved plans and documents
192
- ├── plugins/ # Global plugins
193
- ├── sessions/ # Session history
194
- └── threads/ # Thread storage
195
- ```
38
+ ## ✨ Key Features
39
+
40
+ ### 🤖 **Native Tools** (45+ tools)
41
+ Comprehensive toolset organized by category with risk levels and auto-approve policies.
42
+ Tools are now modularly structured in `src/app/agent/tools/` with separate UI components:
43
+
44
+ **Filesystem** (10 tools):
45
+ - `ls_tool`, `read_file_lines`, `count_file_lines`, `find_by_name`, `grep_search`
46
+ - `view_file_outline`, `edit_tool`, `file_write`, `notebook_edit`, `lsp_query`
47
+
48
+ **Execution** (6 tools):
49
+ - `shell_command`, `command_status`, `send_command_input`, `kill_command`
50
+ - `repl` (interactive code execution for Python/Node/Bash)
51
+ - `task_output` (real-time output following)
52
+
53
+ **Communication** (7 tools):
54
+ - `message`, `ask_user_question`, `brief`, `send_message`
55
+ - `list_mailbox_messages`, `poll_mailbox`, `signal_mailbox`
56
+
57
+ **Planning** (11 tools):
58
+ - `todo`, `task_boundary`, `task_create`, `task_update`, `task_stop`
59
+ - `task_list`, `task_get`, `enter_plan_mode`, `exit_plan_mode`
60
+ - `cron_create`, `cron_list`, `cron_delete`
61
+
62
+ **Knowledge** (10 tools):
63
+ - `search_web`, `web_fetch`, `load_skill`, `coding_memory`
64
+ - `ctx_inspect`, `dream`, `context_collapse`, `snip`
65
+ - `list_mcp_resources`, `read_mcp_resource`
66
+
67
+ **Agent Coordination** (4 tools):
68
+ - `spawn_agent`, `wait_agent`, `list_agents`, `kill_agent`
69
+
70
+ **FactorAI Sandbox** (5 tools):
71
+ - `factorai.sh.create_next_app`, `factorai.sh.deploy_app`
72
+ - `factorai.sh.get_app_status`, `factorai.sh.apply_app_changes`
73
+ - `factorai.sh.redeploy_app`
74
+
75
+ ### 🧠 **Multi-Agent Orchestration**
76
+ - **Coordinator Mode**: Product Owner + Engineering Manager hybrid that delegates to specialist workers
77
+ - **Parallel Execution**: Launch multiple workers concurrently for research, implementation, and verification
78
+ - **Mailbox IPC**: Bidirectional communication between coordinator and workers via `send_message`, `list_mailbox_messages`, `poll_mailbox`, `signal_mailbox`
79
+ - **Worker Types**: Researchers, implementers, verifiers with specialized roles
80
+ - **Session Registry**: Track and manage agent sessions with lifecycle events
81
+
82
+ ### 📝 **Slash Commands** (80+ commands)
83
+ Quick access to common operations across 5 categories:
84
+
85
+ - **Session** (25+): `/clear`, `/sessions`, `/attach`, `/follow`, `/bridge`, `/status`, `/logs`, `/resume`, `/kill`, `/compact`, `/export`, `/summarize`, `/history`, `/share`, `/copy`, `/commit`, `/pr`, `/release`, `/snip`, `/collapse`, `/brief`, `/undo`, `/redo`, `/thread` (with subcommands: list/new/resume/fork/rename/archive/delete)
86
+ - **Inspect** (30+): `/plugins`, `/plugin`, `/diagnostics`, `/permissions`, `/features`, `/hooks`, `/model`, `/effort`, `/style`, `/sandbox`, `/worktree`, `/statusline`, `/skills`, `/tools`, `/mcp`, `/debug-workers`, `/cost`, `/memory`, `/stats`, `/theme`, `/keybindings`, `/vim`, `/ctx`, `/dream`, `/diff`, `/editor`, `/config`, `/file`, `/search`, `/context`, `/token`, `/settings`, `/alias`, `/macro`, `/thread stats`
87
+ - **Agent** (15+): `/agent`, `/agents`, `/img`, `/image`, `/init`, `/review`, `/explain`, `/fix`, `/debug`, `/bug`, `/test`, `/optimize`, `/refactor`, `/document`, `/chat`, `/code`, `/terminal`, `/template`
88
+ - **Help**: `/help`
89
+ - **Input**: `Ctrl+V`/`Cmd+V` (paste image/text/file), `Ctrl+Shift+I` (same as Ctrl+V)
90
+
91
+ ### 🎯 **Intelligent Context Management**
92
+ - **Auto Memory**: Persistent coding notes across sessions (`coding_memory`)
93
+ - **Context Collapse**: Advanced history compaction with multiple strategies (aggressive, moderate, minimal, target token budget)
94
+ - **Snip Tool**: Extract and remove old conversation snippets (extract/remove/auto modes)
95
+ - **Dream Engine**: Background memory consolidation — deduplicates, merges, prunes, and enriches coding memory entries
96
+ - **Token Tracking**: Real-time token usage monitoring with `ctx_inspect`
97
+ - **Thread Management**: Full thread lifecycle with create, resume, fork, rename, archive, delete operations
98
+
99
+ ### 🛠️ **Plan Mode**
100
+ Structured problem-solving workflow with 3 phases:
101
+ 1. **PLANNING**: Research and design
102
+ 2. **EXECUTION**: Implementation
103
+ 3. **VERIFICATION**: Testing and validation
104
+
105
+ ### 🔧 **Skills System**
106
+ Extendable expertise modules with progressive disclosure:
107
+ - **git-commit**: Conventional commits automation with BluMa watermark
108
+ - **git-pr**: Pull request creation and management
109
+ - **git-release**: Full release engineering workflow (version bumps, changelog, tags, npm publish)
110
+ - **pdf**: PDF generation and manipulation (reports, merge, forms, OCR)
111
+ - **xlsx**: Spreadsheet processing (create, edit, formulas, charting, cleaning)
112
+ - **skill-creator**: Create custom skills
113
+
114
+ ### 🎨 **Modern UI**
115
+ - Built with **Ink** (React for CLI)
116
+ - **Shimmer effects** for working states (WorkingShimmerText, Spinner with ShimmerChar/FlashingChar)
117
+ - **Streamlined transcript** with syntax highlighting (HighlightedCode, MarkdownRenderer)
118
+ - **Bottom dock** for status and controls (BlumaBottomDock, StatusBar)
119
+ - **Worker overlay** for multi-agent visualization (WorkerOverlay, WorkerStatusList)
120
+ - **Real-time streaming** (StreamingMarkdown, StreamingText, TypewriterText)
121
+ - **Animated indicators** (Spinner, ProgressBar)
122
+ - **Theme system** with configurable themes (blumaTerminal theme)
123
+
124
+ ### 🔒 **Sandbox Security**
125
+ - **Permission modes**: Local (auto-approve) vs Sandbox (confirmation required)
126
+ - **Policy enforcement**: `rm -rf` protection, sudo blocking, dangerous command detection
127
+ - **Tool risk levels**: safe, write, execute, network — with per-mode auto-approve settings
128
+ - **FactorAI integration**: Optional sandbox backend for isolated execution with workspace manifest persistence
129
+
130
+ ### 📦 **Performance**
131
+ - **TypeScript**: Full type safety with strict mode
132
+ - **ES Modules**: Modern module system with bundler resolution
133
+ - **React 19**: Latest React with concurrent features
134
+ - **Optimized rendering**: Memoized message blocks, offscreen freeze, expandable previews
135
+
136
+ ### 🔌 **MCP Support**
137
+ - **Model Context Protocol**: Connect to external MCP servers
138
+ - **Resource listing**: Discover and read MCP resources
139
+ - **SSE transport**: Server-Sent Events for real-time communication
140
+
141
+ ### 🧵 **Thread Management**
142
+ - **Thread lifecycle**: Create, resume, fork, rename, archive, delete threads
143
+ - **Thread stats**: View thread metadata and statistics
144
+ - **Codex-style interface**: Familiar thread management commands
196
145
 
197
146
  ---
198
147
 
199
- ## Architecture
148
+ ## 🏗️ Architecture
200
149
 
201
150
  ```
202
151
  ┌─────────────────────────────────────────────────────────────┐
203
- UI Layer
204
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
205
- Bluma Input │ │ Slash ToolResult
206
- │ Session Prompt Commands │ │ Display │ │
207
- │ │ (Ink) │ │ │ │ │ │ │ │
208
- └────┬─────┘ └────┬─────┘ └────┬─────┘ └──────┬───────┘
209
- │ │ │ │ │ │
210
- ┌────┴────────────┴────────────┴──────────────┴─────┐
211
- │ │ BlumaShell / BlumaViewport
212
- │ │ BlumaTranscript / BlumaBottomDock │ │
213
- └────────────────────────────────────────────────────┘
214
- └─────────────────────────────────────────────────────────────┘
215
-
216
- ┌─────────────────────────────┼────────────────────────────────┐
217
- │ Agent Layer │
218
- │ ┌──────────────┐ ┌──────────┐ ┌──────────────────────┐ │
219
- │ │ Agent │ │ BluMa │ │ RouteManager │ │
220
- │ │ Orchestrator│ │ Core │ │ (FactorRouter) │ │
221
- │ └──────┬───────┘ └────┬─────┘ └──────────┬───────────┘ │
222
- │ │ │ │ │
223
- │ ┌──────┴───────┐ ┌────┴────┐ ┌───────────┴──────────┐ │
224
- │ │ ToolInvoker │ │ LLM │ │ PromptBuilder │ │
225
- │ │ │ │ Client │ │ + ContextManager │ │
226
- │ └──────────────┘ └─────────┘ └──────────────────────┘ │
227
- │ ┌──────────────────────────────────────────────────────┐ │
228
- │ │ Thread Manager / Thread Store │ │
229
- │ └──────────────────────────────────────────────────────┘ │
230
- └─────────────────────────────────────────────────────────────┘
231
-
232
- ┌─────────────────────────────┼────────────────────────────────┐
233
- │ Runtime Layer │
234
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
235
- │ │TaskStore │ │HookReg. │ │PluginReg.│ │SessionReg. │ │
236
- │ │ │ │ │ │ │ │ │ │
237
- │ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
238
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
239
- │ │Sandbox │ │ToolExec │ │Diagnostics│ │SessionView │ │
240
- │ │Policy │ │Policy │ │ │ │ │ │
241
- │ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
242
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
243
- │ │Feature │ │Plan Mode │ │Tool Auto │ │Tool Permission│ │
244
- │ │Flags │ │Session │ │Approve │ │Classifier │ │
245
- │ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
246
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
247
- │ │Mailbox │ │Worker │ │Permission│ │Thread │ │
248
- │ │Registry │ │Context │ │Rules │ │Manager │ │
249
- │ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
250
- └─────────────────────────────────────────────────────────────┘
251
-
252
- ┌─────────────────────────────┼────────────────────────────────┐
253
- │ Tools Layer │
254
- │ ┌──────────────────────────────────────────────────────┐ │
255
- │ │ Native Tools (50+) │ │
256
- │ │ edit_tool, file_write, shell_command, grep_search, │ │
257
- │ │ spawn_agent, wait_agent, list_agents, │ │
258
- │ │ send_message, list_mailbox_messages, signal_mailbox,│ │
259
- │ │ todo, task_boundary, task_create, task_list, │ │
260
- │ │ task_get, task_update, task_stop, │ │
261
- │ │ coding_memory, search_web, web_fetch, load_skill, │ │
262
- │ │ message, ask_user_question, repl, │ │
263
- │ │ list_mcp_resources, read_mcp_resource, │ │
264
- │ │ cron_create, cron_list, cron_delete, │ │
265
- │ │ lsp_query, notebook_edit, │ │
266
- │ │ enter_plan_mode, exit_plan_mode, ... │ │
267
- │ └──────────────────────────────────────────────────────┘ │
268
- │ ┌──────────────────────────────────────────────────────┐ │
269
- │ │ MCP SDK Integration │ │
270
- │ │ External tool servers via MCP │ │
271
- │ └──────────────────────────────────────────────────────┘ │
152
+ BluMa CLI (Ink UI)
153
+ ├─────────────────────────────────────────────────────────────┤
154
+ BlumaShellBlumaViewportBlumaTranscript
155
+ BlumaBottomDockBlumaWorkersOverlay PlanPopup
156
+ ├─────────────────────────────────────────────────────────────┤
157
+ useBlumaSessionRuntime (Hook)
158
+ ├─────────────────────────────────────────────────────────────┤
159
+ Session Registry Agent Core │ Tool Invoker │
160
+ Thread Manager Prompt Builder │ Mailbox IPC
161
+ ├─────────────────────────────────────────────────────────────┤
162
+ Native Tools (45+) Skills (6) │ MCP Clients │
163
+ │ FactorAI Sandbox │ Hook Registry │ Feature Flags │
272
164
  └─────────────────────────────────────────────────────────────┘
273
165
  ```
274
166
 
275
- ---
276
-
277
- ## Native Tools
278
-
279
- BluMa includes **50+ built-in tools** organized by category:
280
-
281
- ### File Operations
282
- | Tool | Description |
283
- |------|-------------|
284
- | `edit_tool` | Replace text in files (precise, multi-line, batch edits) |
285
- | `file_write` | Create/overwrite entire files |
286
- | `read_file_lines` | Read specific line ranges (up to 2000 lines) |
287
- | `count_file_lines` | Get file line count |
288
- | `ls_tool` | List directories with filtering and pagination |
289
- | `find_by_name` | Glob-based file search |
290
- | `grep_search` | Text/regex search across files |
291
- | `view_file_outline` | Show code structure (classes, functions, interfaces) |
292
- | `notebook_edit` | Edit Jupyter `.ipynb` files (cells operations) |
293
-
294
- ### Shell & Commands
295
- | Tool | Description |
296
- |------|-------------|
297
- | `shell_command` | Execute background commands |
298
- | `command_status` | Check command progress/output |
299
- | `send_command_input` | Send input to running commands' stdin |
300
- | `kill_command` | Terminate running commands |
301
-
302
- ### Agent Coordination (v0.1.60+)
303
- | Tool | Description |
304
- |------|-------------|
305
- | `spawn_agent` | Create background worker agents |
306
- | `wait_agent` | Wait for agent completion |
307
- | `list_agents` | List active/completed agents |
308
- | `send_message` | Send follow-up to running worker (continue without re-spawn) |
309
- | `list_mailbox_messages` | Read messages from workers (progress, permission requests) |
310
- | `signal_mailbox` | Send ack/nack/progress signals to workers |
311
- | `poll_mailbox` | Poll mailbox for new messages |
312
-
313
- ### Task & Project Management
314
- | Tool | Description |
315
- |------|-------------|
316
- | `todo` | Manage task lists |
317
- | `task_boundary` | Track task phases (PLANNING/EXECUTION/VERIFICATION) |
318
- | `task_create` | Create session-scoped tasks |
319
- | `task_list` | List all session tasks |
320
- | `task_get` | Get one task by id |
321
- | `task_update` | Update task fields |
322
- | `task_stop` | Cancel a task |
323
- | `task_output` | Read task output in real-time |
324
- | `create_artifact` | Save documents under `<workspace>/.bluma/artifacts/<session>/` |
325
- | `read_artifact` | Read artifacts from the current session directory |
326
-
327
- ### Thread Management (v0.1.84+)
328
- | Tool | Description |
329
- |------|-------------|
330
- | `thread_create` | Create new conversation thread |
331
- | `thread_list` | List all threads |
332
- | `thread_switch` | Switch to different thread |
333
- | `thread_archive` | Archive a thread |
334
-
335
- ### Knowledge & Research
336
- | Tool | Description |
337
- |------|-------------|
338
- | `search_web` | Search programming solutions (Reddit, GitHub, StackOverflow) |
339
- | `web_fetch` | Fetch and analyze remote URLs |
340
- | `load_skill` | Activate domain-specific skills |
341
- | `coding_memory` | CRUD for persistent coding notes |
342
-
343
- ### Communication & Interaction
344
- | Tool | Description |
345
- |------|-------------|
346
- | `message` | Post user-visible chat (info/result types) |
347
- | `ask_user_question` | Ask multiple-choice questions in terminal |
348
-
349
- ### MCP & Resources
350
- | Tool | Description |
351
- |------|-------------|
352
- | `list_mcp_resources` | List resources from MCP servers |
353
- | `read_mcp_resource` | Read a resource URI from MCP server |
354
-
355
- ### Scheduling
356
- | Tool | Description |
357
- |------|-------------|
358
- | `cron_create` | Schedule one-shot or repeating reminders |
359
- | `cron_list` | List scheduled cron jobs |
360
- | `cron_delete` | Cancel scheduled job |
361
-
362
- ### Development Tools
363
- | Tool | Description |
364
- |------|-------------|
365
- | `lsp_query` | LSP go-to-definition or references (TS/JS) |
366
- | `repl` | Interactive code execution (Python, Node, Bash) |
367
-
368
- ### Specialized
369
- | Tool | Description |
370
- |------|-------------|
371
- | `context_collapse` | Collapse context window |
372
- | `dream_engine` | Auto-dream feature (coding memory consolidation) |
373
- | `brief` | Generate project brief |
374
- | `ctx_inspect` | Inspect current context |
375
- | `snip` | Code snippet management |
376
- | `coordinator_tools` | Coordinator mode utilities |
377
- | `create-next-app` | Scaffold Next.js project with shadcn/ui + Tailwind |
378
- | `deploy-app` | Deploy Next.js to Severino hosting |
379
-
380
- ### Plan Mode
381
- | Tool | Description |
382
- |------|-------------|
383
- | `enter_plan_mode` | Enter plan-only mode (edits require confirmation) |
384
- | `exit_plan_mode` | Leave plan mode |
167
+ ### Modular Tool Architecture
168
+
169
+ Each tool in `src/app/agent/tools/` follows a consistent structure:
170
+
171
+ ```
172
+ ToolName/
173
+ ├── index.ts # Public API exports
174
+ ├── ToolName.ts # Core implementation logic
175
+ ├── UI.tsx # React/Ink UI component
176
+ └── types.ts # Type definitions
177
+ ```
178
+
179
+ This modular design enables:
180
+ - **Independent testing** of each tool
181
+ - **Clear separation** of logic and presentation
182
+ - **Easy discovery** and maintenance
183
+ - **Consistent patterns** across the codebase
184
+
185
+ ### Core Components
186
+
187
+ - **`src/main.ts`**: Entry point with CLI mode, agent mode, session management
188
+ - **`src/app/ui/`**: React/Ink UI components
189
+ - `App.tsx`: Main orchestrator
190
+ - `BlumaSession.tsx`: Session management and UI lifecycle
191
+ - `components/`: Reusable UI elements (40+ components)
192
+ - `hooks/`: React hooks for state management
193
+ - `theme/`: Theme system and terminal styling
194
+ - `utils/`: Utility functions and slash command registry
195
+ - **`src/app/agent/`**: AI agent core
196
+ - `core/`: Prompt building, context management, LLM integration, thread management
197
+ - `tools/`: **Modular tool architecture** 43+ tool directories, each with:
198
+ - Implementation logic (`*.ts`)
199
+ - UI components (`UI.tsx`)
200
+ - Type definitions (`types.ts`)
201
+ - Index exports (`index.ts`)
202
+ - `runtime/`: Session runtime, sandbox policy, plugin system, hook registry
203
+ - `session_manager/`: Multi-session orchestration
204
+ - `subagents/`: Worker system with base LLM subagent and coordinator tools
205
+ - `bluma/`: BluMa-specific core logic and turn start payload
206
+ - **`src/app/agent/config/`**: Configuration files and skill definitions
207
+ - **`src/ink/`**: Ink renderer shims and compatibility layer
208
+ - **`src/shims/`**: Build-time shims for react-compiler-runtime and bidi-js
209
+ - **`native/`**: Rust-based native modules (clipboard, yoga-layout)
210
+ - **`vscode-extension/`**: VS Code extension for chat integration
385
211
 
386
212
  ---
387
213
 
388
- ## Current Features
389
-
390
- ### Thread System (v0.1.84+)
391
- **Multi-thread conversation management** for isolated contexts:
392
-
393
- ```typescript
394
- // Create a new thread
395
- thread_create({
396
- name: "Feature Implementation",
397
- context: "Working on authentication module"
398
- })
399
-
400
- // List all threads
401
- thread_list()
402
-
403
- // Switch between threads
404
- thread_switch({ threadId: "thread-123" })
405
- ```
406
-
407
- **Key Benefits:**
408
- - **Isolated contexts** - Each thread maintains separate conversation history
409
- - **Parallel work** - Work on multiple features simultaneously
410
- - **Context preservation** - Switch without losing previous context
411
- - **Thread-specific memory** - Coding memories scoped to threads
412
-
413
- ### Mailbox System (Bidirectional Communication)
414
- **Push-based communication** between coordinator and workers using EventEmitter:
415
-
416
- ```typescript
417
- // Coordinator sends follow-up to running worker
418
- send_message({
419
- to: "worker-session-id",
420
- message: "Fix the null pointer in src/auth/validate.ts:42..."
421
- })
422
-
423
- // Coordinator reads messages from workers
424
- list_mailbox_messages({
425
- from: "worker-session-id",
426
- type: "progress_update",
427
- unreadOnly: true
428
- })
429
-
430
- // Workers send progress/permission requests
431
- signal_mailbox({
432
- sessionId: "coordinator-session-id",
433
- type: "progress",
434
- data: { percent: 50 }
435
- })
436
- ```
437
-
438
- **Key Benefits:**
439
- - **No polling needed** - EventEmitter pushes messages instantly
440
- - **Permission requests** - Workers can request permissions mid-execution
441
- - **Progress tracking** - Real-time progress updates
442
- - **Follow-up commands** - Continue workers without re-spawn
443
-
444
- ### Permission System
445
- **Granular permission rules** with allow/deny patterns:
446
-
447
- ```typescript
448
- // Check permission for tool invocation
449
- permissionRulesEngine.checkPermission('edit_tool', {
450
- filepath: '/src/auth/validate.ts'
451
- })
452
- // Returns: 'allow' | 'deny' | 'ask'
453
-
454
- // Add custom rule
455
- permissionRulesEngine.addRule({
456
- type: 'allow',
457
- toolPattern: 'read_*',
458
- pathPattern: '**/*.md',
459
- scope: 'global'
460
- })
461
- ```
462
-
463
- **Features:**
464
- - **Tool patterns** - Wildcard matching for tool names
465
- - **Path patterns** - Glob-based file path matching
466
- - **Command patterns** - Shell command pattern matching
467
- - **Scopes** - global, workspace, session-level rules
468
-
469
- ### Worker Context Isolation
470
- **AsyncLocalStorage-based context** for in-process workers:
471
-
472
- ```typescript
473
- import { runWithWorkerContext, createWorkerContext } from './worker_context'
474
-
475
- const ctx = createWorkerContext({
476
- workerType: 'research',
477
- name: 'auth-investigation'
478
- })
479
-
480
- await runWithWorkerContext(ctx, async () => {
481
- // Worker code runs with isolated context
482
- // Shares LLM/MCP clients but has unique context
483
- })
484
- ```
485
-
486
- ### REPL Tool
487
- **Interactive code execution** for rapid prototyping:
488
-
489
- ```typescript
490
- repl({
491
- language: 'python',
492
- code: `
493
- import pandas as pd
494
- df = pd.DataFrame({'a': [1, 2, 3]})
495
- print(df.sum())
496
- `,
497
- timeout: 30000
498
- })
499
- ```
500
-
501
- **Supported languages:** Python, Node.js, Bash
502
-
503
- ### Context Auto-Compact
504
- **Automatic context compression** with history anchoring:
505
-
506
- - **Budget:** 240k tokens
507
- - **Trigger:** 70% of budget (168k tokens)
508
- - **Strategy:** Compress old turns, keep last 10 turns complete
509
- - **Anchor:** System message with compressed summary
510
-
511
- ```typescript
512
- const { messages, newAnchor } = await createApiContextWindow(
513
- fullHistory,
514
- currentAnchor,
515
- compressedTurnSliceCount,
516
- llmService,
517
- userContext
518
- )
519
- ```
520
-
521
- ### Session Memory Extractor
522
- **Automatic memory extraction** from conversations:
523
-
524
- ```typescript
525
- const memories = await memoryExtractor.extractMemoriesFromSession(messages)
526
- // Returns: ExtractedMemory[] with type, content, confidence, tags
527
-
528
- // Get relevant memories for query
529
- const relevant = await memoryExtractor.getRelevantMemories('authentication')
530
- ```
531
-
532
- **Memory types:** codebase_knowledge, preference, decision, pattern, bugfix, architecture
533
-
534
- ### Vim Mode
535
- **Vim-like keybindings** in input prompt:
536
-
537
- - **Modes:** normal, insert, visual, command
538
- - **Motions:** h/j/k/l, w/b, 0/$, g/G
539
- - **Operators:** d (delete), c (change), y (yank)
540
- - **Commands:** `:w`, `:q`, etc.
541
-
542
- ```typescript
543
- // Enable vim mode
544
- /vim toggle
545
- ```
214
+ ## 📋 Configuration
546
215
 
547
- ### Themes System
548
- **6 configurable UI themes:**
216
+ ### Environment Variables
549
217
 
550
- | Theme | Description |
551
- |-------|-------------|
552
- | `default` | Classic dark terminal |
553
- | `dracula` | Purple accents |
554
- | `github` | GitHub Dark mode |
555
- | `monokai` | Vibrant green accents |
556
- | `nord` | Arctic blue palette |
557
- | `tokyo` | Tokyo Night blue-purple |
218
+ Create a `.env` file in your project root:
558
219
 
559
220
  ```bash
560
- /theme dracula
561
- ```
221
+ # Required for AI features
222
+ FACTOR_ROUTER_KEY=your_key
223
+ FACTOR_ROUTER_URL=https://api.factorai.sh
562
224
 
563
- ### Init Subagent
564
- **Automatic BluMa.md generation:**
225
+ # Optional: MCP Server
226
+ MCP_SSE_URL=http://localhost:3000/sse
565
227
 
566
- ```bash
567
- /init
228
+ # Optional: FactorAI Sandbox
229
+ FACTORAI_BASE_URL=http://localhost:8080
230
+ FACTORAI_API_KEY=your-sandbox-key
568
231
  ```
569
232
 
570
- Scans repository and generates comprehensive codebase documentation including:
571
- - Project overview
572
- - Technology stack detection
573
- - Directory structure with annotations
574
- - Key configs and scripts
575
- - CLI commands
576
- - Operational notes
577
-
578
- ### Coding Memory Consolidate
579
- **Deduplication of coding memories:**
580
-
581
- ```typescript
582
- consolidateCodingMemoryFile()
583
- // Merges duplicate entries by normalized text
584
- // Keeps oldest ID, merges tags
585
- // Creates backup .bak file
586
- ```
233
+ ### Runtime Modes
587
234
 
588
- ---
235
+ BluMa supports different permission modes:
589
236
 
590
- ## Skills System
237
+ - **Local Mode**: Auto-approve safe operations
238
+ - **Sandbox Mode**: Require confirmation for write/execute operations
591
239
 
592
- Skills are **self-contained knowledge modules** that extend BluMa with domain expertise. They use **Progressive Disclosure** to manage context efficiently.
593
-
594
- ### Skill Sources (Priority Order)
595
-
596
- | Priority | Source | Path |
597
- |----------|--------|------|
598
- | 1 | **Bundled** | `dist/config/skills/` |
599
- | 2 | **Project** | `{cwd}/.bluma/skills/` |
600
- | 3 | **Global** | `~/.bluma/skills/` |
601
-
602
- ### Progressive Disclosure Levels
603
-
604
- ```
605
- Level 1: description (frontmatter)
606
- Always visible. Cost: ~1 line per skill.
607
- Purpose: Let agent DECIDE to activate.
608
-
609
- ↓ agent calls load_skill(name)
610
-
611
- Level 2: SKILL.md body
612
- Injected when activated. Cost: 50-300 lines.
613
- Purpose: Core instructions and quick-start.
614
-
615
- ↓ agent reads reference or runs script (if needed)
616
-
617
- Level 3a: references/*.md
618
- Read on-demand. Cost: only when read.
619
- Purpose: Advanced documentation.
620
-
621
- Level 3b: scripts/*.py
622
- Executed on-demand. Cost: zero context.
623
- Purpose: Pre-built utilities.
624
- ```
625
-
626
- ### Available Skills
627
-
628
- | Skill | Description |
629
- |-------|-------------|
630
- | `git-commit` | Conventional commits, staging, commit messages |
631
- | `git-pr` | Pull requests, code review preparation |
632
- | `git-release` | Version bumps, changelogs, git tags, GitHub releases |
633
- | `pdf` | PDF creation, extraction, merging, OCR |
634
- | `xlsx` | Spreadsheet operations, formulas, charts |
635
- | `skill-creator` | Author new BluMa skills |
636
-
637
- ### Loading Skills
638
-
639
- ```typescript
640
- // Via command
641
- > load the git-commit skill
642
-
643
- // Via tool call
644
- load_skill({ skill_name: "git-commit" })
240
+ Set via environment or runtime config:
241
+ ```bash
242
+ BLUMA_PERMISSION_MODE=sandbox
645
243
  ```
646
244
 
647
- Skills inject domain knowledge and best practices into the agent's context. Each skill has:
648
- - **Frontmatter**: Description and dependencies (always visible)
649
- - **Body**: Core instructions (injected on activation)
650
- - **References**: Advanced docs (read on-demand)
651
- - **Scripts**: Executable utilities (zero context cost)
652
-
653
245
  ---
654
246
 
655
- ## Runtime & Orchestration
247
+ ## 🛠️ Development
656
248
 
657
- ### Task Store
249
+ ### Prerequisites
658
250
 
659
- Track work with PLANNING → EXECUTION → VERIFICATION phases:
660
-
661
- ```typescript
662
- task_boundary({
663
- task_name: "Implementing Authentication",
664
- mode: "PLANNING",
665
- task_status: "Creating middleware structure"
666
- });
667
- ```
251
+ - Node.js >= 20
252
+ - npm >= 9
668
253
 
669
- ### Thread Manager (v0.1.84+)
254
+ ### Setup
670
255
 
671
- Manage multiple conversation threads:
672
-
673
- ```typescript
674
- // Thread operations
675
- thread_create({ name: "Feature A" })
676
- thread_list()
677
- thread_switch({ threadId: "..." })
678
- thread_archive({ threadId: "..." })
679
- ```
256
+ ```bash
257
+ # Clone the repository
258
+ git clone https://github.com/Nomad-e/bluma-cli.git
259
+ cd bluma-cli
680
260
 
681
- ### Hook Registry
261
+ # Install dependencies
262
+ npm install
682
263
 
683
- Event-driven lifecycle tracking:
264
+ # Build the project
265
+ npm run build
684
266
 
685
- ```typescript
686
- // Hooks fire on: tool_calls, decisions, state_changes
687
- registerHook('tool_calls', (event) => {
688
- console.log(`Tool ${event.toolName} executed`);
689
- });
267
+ # Start BluMa
268
+ npm start
690
269
  ```
691
270
 
692
- ### Plugin Registry
693
-
694
- Load plugins from `.bluma/plugins/`:
695
-
696
- ```bash
697
- > /plugins list # Show loaded plugins
698
- > /plugins load my-plugin # Load a plugin
699
- ```
271
+ ### Scripts
700
272
 
701
- ### Session Registry
273
+ | Script | Description |
274
+ |--------|-------------|
275
+ | `npm run build` | TypeScript check + bundle |
276
+ | `npm run build:native` | Build native modules |
277
+ | `npm run build:all` | Build native + TypeScript |
278
+ | `npm run precommit` | Run pre-commit validation |
279
+ | `npm start` | Build + run BluMa |
280
+ | `npm test` | Run Jest tests |
281
+ | `npm run test:watch` | Watch mode for tests |
282
+ | `npm run test:parallel` | Parallel test execution |
283
+ | `npm run test:parallel:fast` | Fast parallel tests with 8 workers |
284
+ | `npm run lint` | ESLint check |
285
+ | `npm run lint:fix` | Auto-fix lint errors |
702
286
 
703
- Multi-session support with health monitoring:
287
+ ### Testing
704
288
 
705
289
  ```bash
706
- > /sessions list # List all sessions
707
- > /sessions logs <id> # Stream session logs
708
- > /sessions kill <id> # Terminate session
709
- ```
290
+ # Run all tests
291
+ npm test
710
292
 
711
- ### Diagnostics
293
+ # Run specific test file
294
+ npm test -- tests/tool_invocation.spec.ts
712
295
 
713
- Real-time system snapshot:
296
+ # Watch mode
297
+ npm run test:watch
714
298
 
715
- ```bash
716
- > /diagnostics # Full system status
717
- > /diagnostics tasks # Task overview
718
- > /diagnostics hooks # Hook registry status
719
- > /diagnostics plugins # Plugin registry status
720
- > /diagnostics sessions # Active sessions
721
- > /diagnostics threads # Thread overview
299
+ # Parallel tests (faster)
300
+ npm run test:parallel:fast
722
301
  ```
723
302
 
724
- ### Runtime Files
725
-
726
- | File | Purpose |
727
- |------|---------|
728
- | `~/.bluma/task_state.json` | Persistent task tracking |
729
- | `~/.bluma/hooks.json` | Hook registry state |
730
- | `~/.bluma/sessions/` | Session history and logs |
731
- | `~/.bluma/plugins/` | Global plugin storage |
732
- | `~/.bluma/threads/` | Thread storage |
303
+ ### Contributing
733
304
 
734
- ### Tool Execution Policy
735
-
736
- BluMa uses intelligent tool execution based on sandbox mode:
737
-
738
- | Sandbox Mode | Behavior |
739
- |--------------|----------|
740
- | `confirm` | Prompt for dangerous tools (shell, edit, write) |
741
- | `auto` | Auto-approve safe tools, confirm risky ones |
742
- | `strict` | Require confirmation for all tools |
743
-
744
- Safe tools (always auto-approved): `read_file_lines`, `grep_search`, `ls_tool`, `find_by_name`, `count_file_lines`, `view_file_outline`
305
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed contribution guidelines.
745
306
 
746
307
  ---
747
308
 
748
- ## Slash Commands
749
-
750
- Built-in terminal commands (type `/` to see all):
751
-
752
- ### Session & UI
753
- | Command | Description |
754
- |---------|-------------|
755
- | `/clear` | Clear chat below welcome panel |
756
- | `/sessions` | Show registered sessions (current + historical) |
757
- | `/attach <id>` | Live-follow a session log stream |
758
- | `/follow <id>` | Alias of /attach for live session follow |
759
- | `/bridge` | Show session bridge state and follow instructions |
760
- | `/status <id>` | Show session status for a session id |
761
- | `/logs <id>` | Show recent logs for a session id |
762
- | `/resume <id>` | Resume a session from the current CLI |
763
- | `/kill <id>` | Send SIGTERM to a session by id |
764
- | `/tasks [list\|add\|complete\|update\|remove\|clear]` | Manage task list |
765
- | `/plan [show\|start\|end]` | Manage the active task boundary |
766
- | `/compact` | Manually compact conversation context |
767
- | `/export` | Export conversation as markdown |
768
-
769
- ### Threads (v0.1.84+)
770
- | Command | Description |
771
- |---------|-------------|
772
- | `/threads` | List all conversation threads |
773
- | `/thread [id]` | Switch to thread or show current |
774
- | `/thread new [name]` | Create new thread |
775
- | `/thread archive [id]` | Archive a thread |
776
-
777
- ### Agent
778
- | Command | Description |
779
- |---------|-------------|
780
- | `/img ./shot.png [question]` | Send local image(s) to the model |
781
- | `/image` | Alias of /img |
782
- | `/init` | Run init subagent — BluMa.md codebase documentation |
783
- | `/agent [default\|coordinator]` | Set prompt profile (coordinator playbook for worker orchestration) |
784
- | `/agents` | List worker/agent sessions (spawn_agent children) |
785
-
786
- ### Inspect
787
- | Command | Description |
788
- |---------|-------------|
789
- | `/plugins` | List installed plugins and plugin paths |
790
- | `/plugin <name>` | Inspect one plugin |
791
- | `/diagnostics` | Show a consolidated health snapshot |
792
- | `/permissions` | Inspect sandbox and tool rules; set mode |
793
- | `/hooks` | Inspect, enable, disable, or clear lifecycle hooks |
794
- | `/model [list\|name\|auto]` | Show, list, or set the active model |
795
- | `/effort [low\|medium\|high]` | Show or set reasoning effort |
796
- | `/style [default\|compact\|brief]` | Show or set output style |
797
- | `/sandbox [on\|off]` | Show or toggle sandbox mode |
798
- | `/worktree [path]` | Show or set workspace root |
799
- | `/statusline` | Show the current session statusline summary |
800
- | `/skills` | List load_skill modules, dirs, and conflicts |
801
- | `/tools [grep]` | List native tools (optional filter) |
802
- | `/mcp [fs]` | List MCP tools (optional filter) |
803
- | `/features` | Feature flags: `/features` or `/features <key> on\|off` |
804
- | `/debug-workers` | Show running workers, PIDs, memory, and event bus state |
805
- | `/cost` | Show session cost and token usage |
806
- | `/memory` | Manage session memories |
807
- | `/stats` | Detailed session statistics |
808
- | `/theme` | Change UI theme |
809
- | `/keybindings` | Show or configure keybindings |
810
- | `/vim` | Toggle vim mode |
811
-
812
- ### Help
813
- | Command | Description |
814
- |---------|-------------|
815
- | `/help` | List all slash commands (grouped) |
816
-
817
- ### Input (Keyboard Shortcuts)
818
- | Shortcut | Description |
819
- |----------|-------------|
820
- | `Ctrl+V / Cmd+V` | Paste from clipboard: image → cache `~/.cache/bluma/clipboard`; text; or file path as image |
821
- | `Ctrl+Shift+I` | Same as Ctrl+V (paste image, text, or file path) |
822
- | `Ctrl+O` | Expand truncated previews in tool results |
309
+ ## 📚 Documentation
823
310
 
824
- ---
311
+ - **[Developer Guide](docs/BLUMA_DEVELOPER_GUIDE.md)**: Complete technical reference
312
+ - **[Skills Guide](docs/SKILLS.md)**: How to create and use skills
313
+ - **[Mailbox IPC](docs/MAILBOX_IPC.md)**: Multi-agent communication
314
+ - **[CI/CD](docs/CI-TEST.md)**: Continuous integration setup
315
+ - **[Message Queue](docs/message-queue-design.md)**: IPC system design
316
+ - **[Parallel Tests](docs/parallel-tests.md)**: Test parallelization guide
825
317
 
826
- ## Development
318
+ ---
827
319
 
828
- ### Build
320
+ ## 🎯 Use Cases
829
321
 
322
+ ### 1. **Code Analysis & Refactoring**
830
323
  ```bash
831
- npm run build # Production build
832
- npm run build:native # Build native modules
833
- npm run build:all # Build native + main
834
- npm start # Build + run
835
- ```
836
-
837
- ### Lint
324
+ # Ask BluMa to analyze your codebase
325
+ bluma
838
326
 
839
- ```bash
840
- npm run lint # Check code style
841
- npm run lint:fix # Auto-fix issues
327
+ # Then use slash commands
328
+ /explain src/app/agent/core/prompt_builder.ts
329
+ /refactor src/utils/helpers.ts
330
+ /fix src/components/Button.tsx
842
331
  ```
843
332
 
844
- ### Test
845
-
333
+ ### 2. **Multi-Agent Development**
846
334
  ```bash
847
- npm test # Run all tests
848
- npm run test:watch # Watch mode
849
- npm run test:parallel # Parallel test execution
850
- npm run test:parallel:fast # Fast parallel with 8 workers
851
- ```
852
-
853
- ### Project Structure
335
+ # Coordinator mode: delegate to workers
336
+ "Build a new feature with research, implementation, and verification"
854
337
 
338
+ # BluMa automatically spawns:
339
+ # - Researcher: Investigate codebase structure
340
+ # - Implementer: Write the code
341
+ # - Verifier: Run tests and validate
855
342
  ```
856
- src/
857
- ├── app/
858
- │ ├── agent/
859
- │ │ ├── agent.ts # Main orchestrator
860
- │ │ ├── bluma/ # Core agent logic
861
- │ │ │ ├── core/
862
- │ │ │ │ ├── bluma.ts # BluMaAgent class
863
- │ │ │ │ └── turn_start_payload.ts
864
- │ │ │ ├── context/
865
- │ │ │ │ └── auto_compact.ts # Automatic context compaction
866
- │ │ │ ├── memory/
867
- │ │ │ │ └── session_memory.ts # Session memory
868
- │ │ │ └── types/
869
- │ │ │ └── errors.ts # Error type definitions
870
- │ │ ├── config/
871
- │ │ │ ├── native_tools.json # Tool definitions (50+)
872
- │ │ │ ├── skills/ # Bundled skills
873
- │ │ │ │ ├── git-commit/
874
- │ │ │ │ ├── git-pr/
875
- │ │ │ │ ├── git-release/ # Version bumps, changelogs, releases
876
- │ │ │ │ ├── pdf/
877
- │ │ │ │ ├── skill-creator/
878
- │ │ │ │ └── xlsx/
879
- │ │ │ │ └── scripts/
880
- │ │ │ │ └── office/ # Office document handling
881
- │ │ ├── core/ # LLM, context, prompts
882
- │ │ │ ├── context-api/ # Context management
883
- │ │ │ │ ├── context_manager.ts # Token-aware context
884
- │ │ │ │ ├── history_anchor.ts # Conversation anchoring
885
- │ │ │ │ └── token_counter.ts # Tiktoken integration
886
- │ │ │ ├── llm/ # LLM client
887
- │ │ │ │ ├── llm.ts # FactorRouter client
888
- │ │ │ │ ├── llm_errors.ts # LLM error formatting
889
- │ │ │ │ ├── streaming_delta.ts # Streaming delta handling
890
- │ │ │ │ └── tool_call_normalizer.ts
891
- │ │ │ ├── prompt/ # Prompt engineering
892
- │ │ │ │ ├── prompt_builder.ts # Dynamic prompts
893
- │ │ │ │ ├── workspace_snapshot.ts
894
- │ │ │ │ ├── mcp_instructions.ts
895
- │ │ │ │ ├── model_info.ts
896
- │ │ │ │ ├── production_sandbox_prompt.ts
897
- │ │ │ │ ├── system_prompt_sections.ts
898
- │ │ │ │ ├── system_reminders.ts
899
- │ │ │ │ └── tool_guidance.ts
900
- │ │ │ ├── thread/ # Thread management (v0.1.84+)
901
- │ │ │ │ ├── index.ts
902
- │ │ │ │ ├── thread_manager.ts
903
- │ │ │ │ ├── thread_store.ts
904
- │ │ │ │ └── types.ts
905
- │ │ │ └── context_viz.ts # Context visualization
906
- │ │ ├── docs/
907
- │ │ │ └── TOOL_PARITY.md # Tool parity documentation
908
- │ │ ├── feedback/
909
- │ │ │ └── feedback_system.ts # Smart feedback system
910
- │ │ │ └── feedback_scoring.ts # User feedback scoring
911
- │ │ ├── runtime/ # Orchestration layer
912
- │ │ │ ├── diagnostics.ts # System snapshots
913
- │ │ │ ├── feature_flags.ts # Feature gates
914
- │ │ │ ├── hook_registry.ts # Event-driven hooks
915
- │ │ │ ├── native_tool_catalog.ts # Tool registry
916
- │ │ │ ├── permission_bridge.ts # Leader↔Worker permission system
917
- │ │ │ ├── permission_rules.ts # Permission rule definitions
918
- │ │ │ ├── tool_permission_classifier.ts
919
- │ │ │ ├── plan_mode_session.ts # Plan mode state
920
- │ │ │ ├── plugin_registry.ts # Plugin system
921
- │ │ │ ├── plugin_runtime.ts # Plugin execution
922
- │ │ │ ├── runtime_config.ts # Runtime settings
923
- │ │ │ ├── sandbox_policy.ts # Safety policies
924
- │ │ │ ├── session_registry.ts # Multi-session mgmt
925
- │ │ │ ├── session_view.ts # Session monitoring
926
- │ │ │ ├── task_store.ts # Task lifecycle
927
- │ │ │ ├── tool_auto_approve.ts # Auto-approve rules
928
- │ │ │ ├── tool_execution_policy.ts
929
- │ │ │ ├── tool_orchestration.ts # Parallel read eligibility
930
- │ │ │ ├── mailbox_registry.ts # Mailbox system
931
- │ │ │ ├── worker_context.ts # Worker context management
932
- │ │ │ └── factorai_context.ts # FactorAI app context
933
- │ │ ├── session_manager/
934
- │ │ │ └── session_manager.ts # Session persistence
935
- │ │ ├── skills/
936
- │ │ │ └── skill_loader.ts # 3-source skill loading
937
- │ │ ├── subagents/ # Subagent system
938
- │ │ │ ├── base_llm_subagent.ts
939
- │ │ │ ├── init/ # Init subagent (BluMa.md)
940
- │ │ │ │ ├── init_subagent.ts # Deep project analysis
941
- │ │ │ │ ├── init_system_prompt.ts
942
- │ │ │ │ └── contracts.ts
943
- │ │ │ ├── registry.ts
944
- │ │ │ ├── subagents_bluma.ts # SubAgent orchestration
945
- │ │ │ ├── types.ts # SubAgent type definitions
946
- │ │ │ └── worker_system_prompt.ts
947
- │ │ ├── tools/
948
- │ │ │ ├── mcp/
949
- │ │ │ │ └── mcp_client.ts # MCP SDK client
950
- │ │ │ ├── shared/
951
- │ │ │ │ └── token_utils.ts # Token utilities
952
- │ │ │ └── natives/ # 50+ native tool implementations
953
- │ │ │ ├── agent_coordination.ts
954
- │ │ │ ├── ask_user_question.ts
955
- │ │ │ ├── async_command.ts
956
- │ │ │ ├── coding_memory.ts
957
- │ │ │ ├── coding_memory_consolidate.ts
958
- │ │ │ ├── coordinator_tools.ts
959
- │ │ │ ├── count_lines.ts
960
- │ │ │ ├── edit.ts
961
- │ │ │ ├── file_write.ts
962
- │ │ │ ├── find_by_name.ts
963
- │ │ │ ├── grep_search.ts
964
- │ │ │ ├── list_mailbox_messages.ts
965
- │ │ │ ├── load_skill.ts
966
- │ │ │ ├── ls.ts
967
- │ │ │ ├── lsp_query.ts
968
- │ │ │ ├── mcp_resources.ts
969
- │ │ │ ├── message.ts
970
- │ │ │ ├── notebook_edit.ts
971
- │ │ │ ├── plan_mode_tools.ts
972
- │ │ │ ├── poll_mailbox.ts
973
- │ │ │ ├── readLines.ts
974
- │ │ │ ├── repl.ts
975
- │ │ │ ├── search_web.ts
976
- │ │ │ ├── send_message.ts
977
- │ │ │ ├── session_cron.ts
978
- │ │ │ ├── shell_command.ts
979
- │ │ │ ├── signal_mailbox.ts
980
- │ │ │ ├── task_boundary.ts
981
- │ │ │ ├── task_output.ts
982
- │ │ │ ├── task_tools.ts
983
- │ │ │ ├── todo.ts
984
- │ │ │ ├── view_file_outline.ts
985
- │ │ │ └── web_fetch.ts
986
- │ │ ├── types/
987
- │ │ │ └── index.ts
988
- │ │ └── utils/
989
- │ │ ├── blumamd.ts # BluMa markdown utilities
990
- │ │ ├── coordinator_prompt.ts # Coordinator mode playbook
991
- │ │ ├── logger.ts # Logging utilities
992
- │ │ ├── update_check.ts
993
- │ │ └── user_message_images.ts
994
- │ └── ui/
995
- │ ├── App.tsx # Main UI component
996
- │ ├── BlumaSession.tsx # Session component (v0.1.84+)
997
- │ ├── Asci/
998
- │ │ └── AsciiArt.ts
999
- │ ├── components/ # 35+ UI components
1000
- │ │ ├── AnimatedBorder.tsx
1001
- │ │ ├── AskUserQuestionPrompt.tsx
1002
- │ │ ├── AssistantMessageDisplay.tsx
1003
- │ │ ├── BlumaBottomDock.tsx # Bottom dock (v0.1.84+)
1004
- │ │ ├── BlumaShell.tsx # Shell container (v0.1.84+)
1005
- │ │ ├── BlumaTranscript.tsx # Message transcript (v0.1.84+)
1006
- │ │ ├── BlumaViewport.tsx # Viewport container (v0.1.84+)
1007
- │ │ ├── BlumaWorkersOverlay.tsx # Workers overlay (v0.1.84+)
1008
- │ │ ├── CollapsibleResult.tsx
1009
- │ │ ├── ConfirmationPrompt.tsx # Permission confirmation dialog
1010
- │ │ ├── CtrlOToExpand.tsx # Ctrl+O expansion (v0.1.84+)
1011
- │ │ ├── EditToolDiffPanel.tsx # Diff preview for edits
1012
- │ │ ├── ErrorMessage.tsx
1013
- │ │ ├── ExpandedPreviewBlock.tsx
1014
- │ │ ├── FilePathLink.tsx # File path links (v0.1.84+)
1015
- │ │ ├── HighlightedCode.tsx # Syntax highlighting (v0.1.84+)
1016
- │ │ ├── InputPrompt.tsx # User input
1017
- │ │ ├── InteractiveMenu.tsx # Interactive menu component
1018
- │ │ ├── MarkdownRenderer.tsx
1019
- │ │ ├── ProgressBar.tsx
1020
- │ │ ├── ReasoningDisplay.tsx # LLM reasoning
1021
- │ │ ├── SessionStats.tsx
1022
- │ │ ├── SimpleDiff.tsx
1023
- │ │ ├── SlashCommands.tsx # 30+ commands
1024
- │ │ ├── StartupUpdateGate.tsx # Update check gate
1025
- │ │ ├── StatusNotification.tsx
1026
- │ │ ├── StreamingText.tsx # Live text output
1027
- │ │ ├── TaskDisplay.tsx
1028
- │ │ ├── TodoPlanDisplay.tsx # Task visualization
1029
- │ │ ├── ToolCallDisplay.tsx
1030
- │ │ ├── ToolInvocationBlock.tsx
1031
- │ │ ├── ToolResultCard.tsx # Structured results
1032
- │ │ ├── ToolResultDisplay.tsx
1033
- │ │ ├── TypewriterText.tsx
1034
- │ │ ├── UpdateNotice.tsx
1035
- │ │ ├── WorkerOverlay.tsx # Worker status overlay
1036
- │ │ ├── WorkerStatusList.tsx # Active workers list
1037
- │ │ ├── WorkerTranscript.tsx # Worker conversation transcript
1038
- │ │ ├── WorkingTimer.tsx # Work duration timer
1039
- │ │ ├── WorkingShimmerText.tsx # Shimmer text effect
1040
- │ │ ├── streamingTextFlush.ts
1041
- │ │ ├── toolCallRenderers.tsx
1042
- │ │ └── slash-commands/ # Slash command renderers
1043
- │ │ ├── SessionLivePanel.tsx
1044
- │ │ ├── SlashCommands.types.ts
1045
- │ │ ├── commandHelpers.tsx
1046
- │ │ ├── constants.ts
1047
- │ │ └── renderers/
1048
- │ │ ├── index.ts
1049
- │ │ ├── configRenderers.tsx
1050
- │ │ ├── infoRenderers.tsx
1051
- │ │ ├── permissionRenderers.tsx
1052
- │ │ ├── pluginRenderers.tsx
1053
- │ │ ├── sessionRenderers.tsx
1054
- │ │ ├── staticRenderers.tsx
1055
- │ │ ├── taskRenderers.tsx
1056
- │ │ └── threadRenderers.tsx # Thread renderers (v0.1.84+)
1057
- │ ├── constants/
1058
- │ │ ├── historyLayout.ts # History layout constants
1059
- │ │ ├── inputPaste.ts # Input paste constants
1060
- │ │ ├── toolUiPreview.ts # Tool UI preview constants
1061
- │ │ └── toolUiSymbols.ts # Tool UI symbols
1062
- │ ├── hooks/
1063
- │ │ ├── useAtCompletion.ts # Completion hook
1064
- │ │ ├── useBlumaSessionRuntime.tsx # Session runtime hook (v0.1.84+)
1065
- │ │ └── useWorkerProgress.ts # Worker progress hook
1066
- │ ├── prompts/
1067
- │ │ └── initCommandPrompt.ts # Init command prompt
1068
- │ ├── theme/
1069
- │ │ ├── blumaTerminal.ts
1070
- │ │ ├── themes.ts # Theme definitions
1071
- │ │ └── m3Layout.tsx # Material Design 3 layout
1072
- │ └── utils/
1073
- │ ├── clipboardImage.ts
1074
- │ ├── editToolDiffUtils.ts
1075
- │ ├── expandPreviewHotkey.ts
1076
- │ ├── expandablePreviewStore.ts
1077
- │ ├── formatTurnDurationMs.ts
1078
- │ ├── inlineImageInputLabels.ts
1079
- │ ├── pathDisplay.ts
1080
- │ ├── shellToolNames.ts
1081
- │ ├── slashRegistry.ts
1082
- │ ├── terminalTitle.ts # Terminal title keeper
1083
- │ ├── toolActionLabels.ts # Tool action labels
1084
- │ ├── toolDisplayLabels.ts # Tool display labels
1085
- │ ├── toolInvocationPairing.ts
1086
- │ ├── toolResultStatusStore.ts
1087
- │ ├── update_message.ts
1088
- │ ├── useSimpleInputBuffer.ts
1089
- │ └── vim_engine.ts # Vim mode engine
1090
- ├── main.ts # Entry point
1091
- └── types/
1092
- └── semver-functions.d.ts
1093
- ```
1094
-
1095
- ---
1096
-
1097
- ## Testing
1098
343
 
344
+ ### 3. **Release Engineering**
1099
345
  ```bash
1100
- npm test # Run all tests
1101
- npm run test:watch # Watch mode
1102
- npm run test:parallel # Parallel execution
1103
- npm run test:parallel:fast # Fast mode with 8 workers
346
+ /release patch # Auto-detect version bump
347
+ /release minor --dry-run # Preview release
1104
348
  ```
1105
349
 
1106
- ### Test Structure
1107
-
1108
- ```
1109
- tests/ # 40+ test files
1110
- ├── agent_*.spec.ts # Agent routing, overlays, coordination
1111
- ├── edit_tool.spec.ts # File editing operations
1112
- ├── file_write.spec.ts # File write operations
1113
- ├── sandbox_policy.spec.ts # Tool execution policies
1114
- ├── task_runtime.integration.spec.ts # Task lifecycle
1115
- ├── context_compression.integration.spec.ts # Context management
1116
- ├── hook_registry.spec.ts # Hook system and event tracking
1117
- ├── plugin_registry.spec.ts # Plugin loading and lifecycle
1118
- ├── session_registry.spec.ts # Session management
1119
- ├── session_manager.spec.ts # Session lifecycle
1120
- ├── tool_execution_policy.spec.ts # Safe vs dangerous tool decisions
1121
- ├── diagnostics.spec.ts # System diagnostics
1122
- ├── runtime_config.spec.ts # Runtime configuration
1123
- ├── slash_routing.spec.ts # Slash command routing
1124
- ├── subagents_flow.integration.spec.ts # Subagent coordination
1125
- ├── prompt_builder.spec.ts # Prompt engineering
1126
- ├── token_counter.spec.ts # Token counting
1127
- ├── coding_memory.spec.ts # Persistent memory
1128
- ├── web_fetch.spec.ts # Web fetching
1129
- ├── workspace_snapshot.spec.ts # Workspace analysis
1130
- ├── ui_*.spec.ts(x) # UI component tests
1131
- ├── llm_stream_partial.spec.ts # LLM streaming partial handling
1132
- ├── llm_errors.spec.ts # LLM error handling
1133
- ├── context_manager_sanitize.spec.ts # Context sanitization
1134
- ├── coordinator-worker-mailbox.integration.spec.ts # Mailbox system
1135
- ├── jest-resolver.cjs # Jest resolver configuration
1136
- └── ... # Additional integration and unit tests
350
+ ### 4. **Pull Request Creation**
351
+ ```bash
352
+ /pr "feat: add new authentication" # Create PR with conventional commit
1137
353
  ```
1138
354
 
1139
355
  ---
1140
356
 
1141
- ## Contributing
1142
-
1143
- See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
1144
-
1145
- ### Quick Contribution Guide
1146
-
1147
- 1. **Fork** the repository
1148
- 2. Create a branch: `feat/add-feature` or `fix/bug-description`
1149
- 3. Make changes following the style guide
1150
- 4. Add/update tests
1151
- 5. Ensure build passes: `npm run build && npm test`
1152
- 6. Open a Pull Request
1153
-
1154
- ### Style Guide
1155
-
1156
- - Use **English** for code, comments, and commits
1157
- - 2-space indentation
1158
- - TypeScript with modern React patterns
1159
- - Follow existing code structure
1160
-
1161
- ---
1162
-
1163
- ## License
357
+ ## 📄 License
1164
358
 
1165
359
  Apache 2.0 — see [LICENSE](LICENSE) for details.
1166
360
 
1167
361
  ---
1168
362
 
1169
- ## Support
1170
-
1171
- - **Issues**: [GitHub Issues](https://github.com/nomad-e/bluma-cli/issues)
1172
- - **Documentation**: This README + `docs/` directory
1173
- - **Author & Architect**: Alex Fonseca (conceived and architected BluMa)
1174
- - **npm Package**: [@nomad-e/bluma-cli](https://www.npmjs.com/package/@nomad-e/bluma-cli)
1175
-
1176
- ### Runtime Modules
1177
-
1178
- BluMa's runtime layer provides enterprise-grade orchestration:
1179
-
1180
- | Module | Purpose | Key Features |
1181
- |--------|---------|--------------|
1182
- | `task_store.ts` | Task lifecycle | PLANNING → EXECUTION → VERIFICATION phases, persistence |
1183
- | `thread_manager.ts` | Thread management | Multi-thread conversations, context isolation |
1184
- | `hook_registry.ts` | Event system | Tool calls, decisions, state changes |
1185
- | `plugin_registry.ts` | Plugin system | Load from `.bluma/plugins/`, lifecycle management |
1186
- | `session_registry.ts` | Multi-session | Process health monitoring, session isolation |
1187
- | `mailbox_registry.ts` | Communication | Bidirectional coordinator-worker messaging |
1188
- | `worker_context.ts` | Worker isolation | AsyncLocalStorage-based context |
1189
- | `permission_rules.ts` | Permissions | Granular allow/deny rules |
1190
- | `sandbox_policy.ts` | Safety | Safe vs dangerous tool classification |
1191
- | `tool_execution_policy.ts` | Execution rules | Auto-approve, confirm, block decisions |
1192
- | `diagnostics.ts` | System snapshots | Tasks, hooks, plugins, sessions overview |
1193
- | `session_view.ts` | Session monitoring | Log streaming, status display |
1194
- | `native_tool_catalog.ts` | Tool registry | Discovery and metadata |
1195
- | `runtime_config.ts` | Settings | Runtime configuration management |
1196
- | `feature_flags.ts` | Feature gates | Opt-in features via env or settings |
1197
- | `plan_mode_session.ts` | Plan mode | Forces confirmation for edits/writes |
1198
- | `tool_auto_approve.ts` | Auto-approve | Effective approve rules |
1199
- | `tool_orchestration.ts` | Parallel reads | Eligibility for parallel execution |
1200
- | `tool_permission_classifier` | Tool classification | Classify tool invocations |
1201
- | `plugin_runtime.ts` | Plugin execution | Plugin runtime context |
1202
-
1203
- ### UI Components
1204
-
1205
- Key UI components that power the rich terminal experience:
1206
-
1207
- | Component | Purpose |
1208
- |-----------|---------|
1209
- | `BlumaSession.tsx` | Main session component with event handling |
1210
- | `BlumaShell.tsx` | Shell container for layout |
1211
- | `BlumaViewport.tsx` | Viewport container for responsive layout |
1212
- | `BlumaTranscript.tsx` | Message transcript display |
1213
- | `BlumaBottomDock.tsx` | Bottom dock for status and controls |
1214
- | `BlumaWorkersOverlay.tsx` | Overlay for worker status |
1215
- | `EditToolDiffPanel.tsx` | Side-by-side diff previews before edits |
1216
- | `ToolResultCard.tsx` | Structured tool output display |
1217
- | `SlashCommands.tsx` | Command palette and help |
1218
- | `StreamingText.tsx` | Live text output with typing effects |
1219
- | `ReasoningDisplay.tsx` | LLM reasoning visualization |
1220
- | `TodoPlanDisplay.tsx` | Task list visualization |
1221
- | `SessionStats.tsx` | Session metrics and status |
1222
- | `AnimatedBorder.tsx` | Visual feedback for active elements |
1223
- | `CollapsibleResult.tsx` | Expandable result sections |
1224
- | `ProgressBar.tsx` | Progress indicators |
1225
- | `AskUserQuestionPrompt.tsx` | Multiple-choice question UI |
1226
- | `ToolInvocationBlock.tsx` | Tool call visualization |
1227
- | `AssistantMessageDisplay.tsx` | Assistant message formatting |
1228
- | `CtrlOToExpand.tsx` | Ctrl+O expansion for previews |
1229
- | `FilePathLink.tsx` | Clickable file path links |
1230
- | `HighlightedCode.tsx` | Syntax highlighted code blocks |
1231
- | `WorkingShimmerText.tsx` | Shimmer text effect for loading states |
363
+ ## 👤 Author
364
+
365
+ **Alex Fonseca** [@nomad-e](https://github.com/Nomad-e)
1232
366
 
1233
367
  ---
1234
368
 
1235
- <p align="center">
1236
- <sub>Built with ❤️ by NomadEngenuity</sub>
1237
- </p>
369
+ *BluMa CLI v0.3.1 — Built with TypeScript, React/Ink, and ES modules.*